summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2021-09-01 19:21:49 +0700
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2021-09-02 13:29:34 +0700
commit76698ff2b5753e637b14533650c0d28e681be3c5 (patch)
tree6b3376df6ac84598b03f2885598b7908e993fe4a /examples
parentb7b7741578257bbf6a8b873c360182e2c9b920ab (diff)
downloadiced-76698ff2b5753e637b14533650c0d28e681be3c5.tar.gz
iced-76698ff2b5753e637b14533650c0d28e681be3c5.tar.bz2
iced-76698ff2b5753e637b14533650c0d28e681be3c5.zip
Make `Command` implementations platform-specific
This allows us to introduce a platform-specific `Action` to both `iced_native` and `iced_web` and remove the `Clipboard` from `Application::update` to maintain purity. Additionally, this should let us implement further actions to let users query and modify the shell environment (e.g. window, clipboard, and more!)
Diffstat (limited to 'examples')
-rw-r--r--examples/clock/src/main.rs10
-rw-r--r--examples/download_progress/src/main.rs10
-rw-r--r--examples/events/src/main.rs12
-rw-r--r--examples/game_of_life/src/main.rs10
-rw-r--r--examples/integration_opengl/src/controls.rs11
-rw-r--r--examples/integration_wgpu/src/controls.rs11
-rw-r--r--examples/menu/src/main.rs9
-rw-r--r--examples/pane_grid/src/main.rs11
-rw-r--r--examples/pokedex/src/main.rs10
-rw-r--r--examples/solar_system/src/main.rs10
-rw-r--r--examples/stopwatch/src/main.rs10
-rw-r--r--examples/todos/src/main.rs10
-rw-r--r--examples/url_handler/src/main.rs10
13 files changed, 39 insertions, 95 deletions
diff --git a/examples/clock/src/main.rs b/examples/clock/src/main.rs
index 9bcc827b..b317ac00 100644
--- a/examples/clock/src/main.rs
+++ b/examples/clock/src/main.rs
@@ -1,7 +1,7 @@
use iced::{
canvas::{self, Cache, Canvas, Cursor, Geometry, LineCap, Path, Stroke},
- executor, time, Application, Clipboard, Color, Command, Container, Element,
- Length, Point, Rectangle, Settings, Subscription, Vector,
+ executor, time, Application, Color, Command, Container, Element, Length,
+ Point, Rectangle, Settings, Subscription, Vector,
};
pub fn main() -> iced::Result {
@@ -40,11 +40,7 @@ impl Application for Clock {
String::from("Clock - Iced")
}
- fn update(
- &mut self,
- message: Message,
- _clipboard: &mut Clipboard,
- ) -> Command<Message> {
+ fn update(&mut self, message: Message) -> Command<Message> {
match message {
Message::Tick(local_time) => {
let now = local_time;
diff --git a/examples/download_progress/src/main.rs b/examples/download_progress/src/main.rs
index 6f844e66..cd024926 100644
--- a/examples/download_progress/src/main.rs
+++ b/examples/download_progress/src/main.rs
@@ -1,6 +1,6 @@
use iced::{
- button, executor, Align, Application, Button, Clipboard, Column, Command,
- Container, Element, Length, ProgressBar, Settings, Subscription, Text,
+ button, executor, Align, Application, Button, Column, Command, Container,
+ Element, Length, ProgressBar, Settings, Subscription, Text,
};
mod download;
@@ -43,11 +43,7 @@ impl Application for Example {
String::from("Download progress - Iced")
}
- fn update(
- &mut self,
- message: Message,
- _clipboard: &mut Clipboard,
- ) -> Command<Message> {
+ fn update(&mut self, message: Message) -> Command<Message> {
match message {
Message::Add => {
self.last_id = self.last_id + 1;
diff --git a/examples/events/src/main.rs b/examples/events/src/main.rs
index 446c190b..911ff425 100644
--- a/examples/events/src/main.rs
+++ b/examples/events/src/main.rs
@@ -1,7 +1,7 @@
use iced::{
- button, executor, Align, Application, Button, Checkbox, Clipboard, Column,
- Command, Container, Element, HorizontalAlignment, Length, Settings,
- Subscription, Text,
+ button, executor, Align, Application, Button, Checkbox, Column, Command,
+ Container, Element, HorizontalAlignment, Length, Settings, Subscription,
+ Text,
};
use iced_native::{window, Event};
@@ -40,11 +40,7 @@ impl Application for Events {
String::from("Events - Iced")
}
- fn update(
- &mut self,
- message: Message,
- _clipboard: &mut Clipboard,
- ) -> Command<Message> {
+ fn update(&mut self, message: Message) -> Command<Message> {
match message {
Message::EventOccurred(event) if self.enabled => {
self.last.push(event);
diff --git a/examples/game_of_life/src/main.rs b/examples/game_of_life/src/main.rs
index c3e16e8b..2d46634f 100644
--- a/examples/game_of_life/src/main.rs
+++ b/examples/game_of_life/src/main.rs
@@ -12,8 +12,8 @@ use iced::slider::{self, Slider};
use iced::time;
use iced::window;
use iced::{
- Align, Application, Checkbox, Clipboard, Column, Command, Container,
- Element, Length, Row, Settings, Subscription, Text,
+ Align, Application, Checkbox, Column, Command, Container, Element, Length,
+ Row, Settings, Subscription, Text,
};
use preset::Preset;
use std::time::{Duration, Instant};
@@ -71,11 +71,7 @@ impl Application for GameOfLife {
String::from("Game of Life - Iced")
}
- fn update(
- &mut self,
- message: Message,
- _clipboard: &mut Clipboard,
- ) -> Command<Message> {
+ fn update(&mut self, message: Message) -> Command<Message> {
match message {
Message::Grid(message, version) => {
if version == self.version {
diff --git a/examples/integration_opengl/src/controls.rs b/examples/integration_opengl/src/controls.rs
index 13b7fbc2..ddc6827c 100644
--- a/examples/integration_opengl/src/controls.rs
+++ b/examples/integration_opengl/src/controls.rs
@@ -1,7 +1,7 @@
use iced_glow::Renderer;
use iced_glutin::{
- slider, Align, Clipboard, Color, Column, Command, Element, Length, Program,
- Row, Slider, Text,
+ slider, Align, Color, Column, Command, Element, Length, Program, Row,
+ Slider, Text,
};
pub struct Controls {
@@ -30,13 +30,8 @@ impl Controls {
impl Program for Controls {
type Renderer = Renderer;
type Message = Message;
- type Clipboard = Clipboard;
- fn update(
- &mut self,
- message: Message,
- _clipboard: &mut Clipboard,
- ) -> Command<Message> {
+ fn update(&mut self, message: Message) -> Command<Message> {
match message {
Message::BackgroundColorChanged(color) => {
self.background_color = color;
diff --git a/examples/integration_wgpu/src/controls.rs b/examples/integration_wgpu/src/controls.rs
index 36ee9b7e..824f9f53 100644
--- a/examples/integration_wgpu/src/controls.rs
+++ b/examples/integration_wgpu/src/controls.rs
@@ -1,7 +1,7 @@
use iced_wgpu::Renderer;
use iced_winit::{
- slider, Align, Clipboard, Color, Column, Command, Element, Length, Program,
- Row, Slider, Text,
+ slider, Align, Color, Column, Command, Element, Length, Program, Row,
+ Slider, Text,
};
pub struct Controls {
@@ -30,13 +30,8 @@ impl Controls {
impl Program for Controls {
type Renderer = Renderer;
type Message = Message;
- type Clipboard = Clipboard;
- fn update(
- &mut self,
- message: Message,
- _clipboard: &mut Clipboard,
- ) -> Command<Message> {
+ fn update(&mut self, message: Message) -> Command<Message> {
match message {
Message::BackgroundColorChanged(color) => {
self.background_color = color;
diff --git a/examples/menu/src/main.rs b/examples/menu/src/main.rs
index 7403713c..810afa00 100644
--- a/examples/menu/src/main.rs
+++ b/examples/menu/src/main.rs
@@ -1,7 +1,6 @@
use iced::menu::{self, Menu};
use iced::{
- executor, Application, Clipboard, Command, Container, Element, Length,
- Settings, Text,
+ executor, Application, Command, Container, Element, Length, Settings, Text,
};
use iced_native::keyboard::{Hotkey, KeyCode, Modifiers};
@@ -92,11 +91,7 @@ impl Application for App {
])
}
- fn update(
- &mut self,
- message: Message,
- _clipboard: &mut Clipboard,
- ) -> Command<Message> {
+ fn update(&mut self, message: Message) -> Command<Message> {
match message {
Message::MenuActivated(entry) => self.selected = Some(entry),
}
diff --git a/examples/pane_grid/src/main.rs b/examples/pane_grid/src/main.rs
index 3bd8aa25..5a134756 100644
--- a/examples/pane_grid/src/main.rs
+++ b/examples/pane_grid/src/main.rs
@@ -1,8 +1,7 @@
use iced::{
button, executor, keyboard, pane_grid, scrollable, Align, Application,
- Button, Clipboard, Color, Column, Command, Container, Element,
- HorizontalAlignment, Length, PaneGrid, Row, Scrollable, Settings,
- Subscription, Text,
+ Button, Color, Column, Command, Container, Element, HorizontalAlignment,
+ Length, PaneGrid, Row, Scrollable, Settings, Subscription, Text,
};
use iced_native::{event, subscription, Event};
@@ -51,11 +50,7 @@ impl Application for Example {
String::from("Pane grid - Iced")
}
- fn update(
- &mut self,
- message: Message,
- _clipboard: &mut Clipboard,
- ) -> Command<Message> {
+ fn update(&mut self, message: Message) -> Command<Message> {
match message {
Message::Split(axis, pane) => {
let result = self.panes.split(
diff --git a/examples/pokedex/src/main.rs b/examples/pokedex/src/main.rs
index da1d5d5d..fdf667cc 100644
--- a/examples/pokedex/src/main.rs
+++ b/examples/pokedex/src/main.rs
@@ -1,6 +1,6 @@
use iced::{
- button, futures, image, Align, Application, Button, Clipboard, Column,
- Command, Container, Element, Length, Row, Settings, Text,
+ button, futures, image, Align, Application, Button, Column, Command,
+ Container, Element, Length, Row, Settings, Text,
};
pub fn main() -> iced::Result {
@@ -48,11 +48,7 @@ impl Application for Pokedex {
format!("{} - Pokédex", subtitle)
}
- fn update(
- &mut self,
- message: Message,
- _clipboard: &mut Clipboard,
- ) -> Command<Message> {
+ fn update(&mut self, message: Message) -> Command<Message> {
match message {
Message::PokemonFound(Ok(pokemon)) => {
*self = Pokedex::Loaded {
diff --git a/examples/solar_system/src/main.rs b/examples/solar_system/src/main.rs
index 8f844828..c8f74978 100644
--- a/examples/solar_system/src/main.rs
+++ b/examples/solar_system/src/main.rs
@@ -8,8 +8,8 @@
//! [1]: https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Basic_animations#An_animated_solar_system
use iced::{
canvas::{self, Cursor, Path, Stroke},
- executor, time, window, Application, Canvas, Clipboard, Color, Command,
- Element, Length, Point, Rectangle, Settings, Size, Subscription, Vector,
+ executor, time, window, Application, Canvas, Color, Command, Element,
+ Length, Point, Rectangle, Settings, Size, Subscription, Vector,
};
use std::time::Instant;
@@ -48,11 +48,7 @@ impl Application for SolarSystem {
String::from("Solar system - Iced")
}
- fn update(
- &mut self,
- message: Message,
- _clipboard: &mut Clipboard,
- ) -> Command<Message> {
+ fn update(&mut self, message: Message) -> Command<Message> {
match message {
Message::Tick(instant) => {
self.state.update(instant);
diff --git a/examples/stopwatch/src/main.rs b/examples/stopwatch/src/main.rs
index 51972e01..983cf3e6 100644
--- a/examples/stopwatch/src/main.rs
+++ b/examples/stopwatch/src/main.rs
@@ -1,6 +1,6 @@
use iced::{
- button, executor, time, Align, Application, Button, Clipboard, Column,
- Command, Container, Element, HorizontalAlignment, Length, Row, Settings,
+ button, executor, time, Align, Application, Button, Column, Command,
+ Container, Element, HorizontalAlignment, Length, Row, Settings,
Subscription, Text,
};
use std::time::{Duration, Instant};
@@ -49,11 +49,7 @@ impl Application for Stopwatch {
String::from("Stopwatch - Iced")
}
- fn update(
- &mut self,
- message: Message,
- _clipboard: &mut Clipboard,
- ) -> Command<Message> {
+ fn update(&mut self, message: Message) -> Command<Message> {
match message {
Message::Toggle => match self.state {
State::Idle => {
diff --git a/examples/todos/src/main.rs b/examples/todos/src/main.rs
index 97415475..7a8ecc1a 100644
--- a/examples/todos/src/main.rs
+++ b/examples/todos/src/main.rs
@@ -1,7 +1,7 @@
use iced::{
button, scrollable, text_input, Align, Application, Button, Checkbox,
- Clipboard, Column, Command, Container, Element, Font, HorizontalAlignment,
- Length, Row, Scrollable, Settings, Text, TextInput,
+ Column, Command, Container, Element, Font, HorizontalAlignment, Length,
+ Row, Scrollable, Settings, Text, TextInput,
};
use serde::{Deserialize, Serialize};
@@ -58,11 +58,7 @@ impl Application for Todos {
format!("Todos{} - Iced", if dirty { "*" } else { "" })
}
- fn update(
- &mut self,
- message: Message,
- _clipboard: &mut Clipboard,
- ) -> Command<Message> {
+ fn update(&mut self, message: Message) -> Command<Message> {
match self {
Todos::Loading => {
match message {
diff --git a/examples/url_handler/src/main.rs b/examples/url_handler/src/main.rs
index f14e5227..ee2d249a 100644
--- a/examples/url_handler/src/main.rs
+++ b/examples/url_handler/src/main.rs
@@ -1,6 +1,6 @@
use iced::{
- executor, Application, Clipboard, Command, Container, Element, Length,
- Settings, Subscription, Text,
+ executor, Application, Command, Container, Element, Length, Settings,
+ Subscription, Text,
};
use iced_native::{
event::{MacOS, PlatformSpecific},
@@ -34,11 +34,7 @@ impl Application for App {
String::from("Url - Iced")
}
- fn update(
- &mut self,
- message: Message,
- _clipboard: &mut Clipboard,
- ) -> Command<Message> {
+ fn update(&mut self, message: Message) -> Command<Message> {
match message {
Message::EventOccurred(event) => {
if let Event::PlatformSpecific(PlatformSpecific::MacOS(