diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/clock/src/main.rs | 4 | ||||
-rw-r--r-- | examples/download_progress/src/main.rs | 3 | ||||
-rw-r--r-- | examples/events/src/main.rs | 3 | ||||
-rw-r--r-- | examples/pane_grid/src/main.rs | 6 | ||||
-rw-r--r-- | examples/pokedex/src/main.rs | 5 | ||||
-rw-r--r-- | examples/solar_system/src/main.rs | 9 | ||||
-rw-r--r-- | examples/stopwatch/src/main.rs | 3 | ||||
-rw-r--r-- | examples/svg/Cargo.toml | 1 | ||||
-rw-r--r-- | examples/svg/src/main.rs | 26 | ||||
-rw-r--r-- | examples/todos/src/main.rs | 3 |
10 files changed, 33 insertions, 30 deletions
diff --git a/examples/clock/src/main.rs b/examples/clock/src/main.rs index d8266f06..d3a4261b 100644 --- a/examples/clock/src/main.rs +++ b/examples/clock/src/main.rs @@ -23,8 +23,9 @@ enum Message { impl Application for Clock { type Executor = executor::Default; type Message = Message; + type Flags = (); - fn new() -> (Self, Command<Message>) { + fn new(_flags: ()) -> (Self, Command<Message>) { ( Clock { now: chrono::Local::now().into(), @@ -66,6 +67,7 @@ impl Application for Clock { Container::new(canvas) .width(Length::Fill) .height(Length::Fill) + .padding(20) .center_x() .center_y() .into() diff --git a/examples/download_progress/src/main.rs b/examples/download_progress/src/main.rs index 6c3094f7..c37ae678 100644 --- a/examples/download_progress/src/main.rs +++ b/examples/download_progress/src/main.rs @@ -26,8 +26,9 @@ pub enum Message { impl Application for Example { type Executor = executor::Default; type Message = Message; + type Flags = (); - fn new() -> (Example, Command<Message>) { + fn new(_flags: ()) -> (Example, Command<Message>) { ( Example::Idle { button: button::State::new(), diff --git a/examples/events/src/main.rs b/examples/events/src/main.rs index 0c9dca05..066fc230 100644 --- a/examples/events/src/main.rs +++ b/examples/events/src/main.rs @@ -22,8 +22,9 @@ enum Message { impl Application for Events { type Executor = executor::Default; type Message = Message; + type Flags = (); - fn new() -> (Events, Command<Message>) { + fn new(_flags: ()) -> (Events, Command<Message>) { (Events::default(), Command::none()) } diff --git a/examples/pane_grid/src/main.rs b/examples/pane_grid/src/main.rs index dafc396c..b4bbd68f 100644 --- a/examples/pane_grid/src/main.rs +++ b/examples/pane_grid/src/main.rs @@ -106,11 +106,10 @@ impl Sandbox for Example { .on_resize(Message::Resized) .on_key_press(handle_hotkey); - Column::new() + Container::new(pane_grid) .width(Length::Fill) .height(Length::Fill) .padding(10) - .push(pane_grid) .into() } } @@ -213,9 +212,10 @@ impl Content { .push(Text::new(format!("Pane {}", id)).size(30)) .push(controls); - Container::new(Column::new().padding(5).push(content)) + Container::new(content) .width(Length::Fill) .height(Length::Fill) + .padding(5) .center_y() .style(style::Pane { is_focused: focus.is_some(), diff --git a/examples/pokedex/src/main.rs b/examples/pokedex/src/main.rs index 4449b901..e7afa8f5 100644 --- a/examples/pokedex/src/main.rs +++ b/examples/pokedex/src/main.rs @@ -29,8 +29,9 @@ enum Message { impl Application for Pokedex { type Executor = iced::executor::Default; type Message = Message; + type Flags = (); - fn new() -> (Pokedex, Command<Message>) { + fn new(_flags: ()) -> (Pokedex, Command<Message>) { ( Pokedex::Loading, Command::perform(Pokemon::search(), Message::PokemonFound), @@ -225,7 +226,7 @@ enum Error { impl From<reqwest::Error> for Error { fn from(error: reqwest::Error) -> Error { - dbg!(&error); + dbg!(error); Error::APIError } diff --git a/examples/solar_system/src/main.rs b/examples/solar_system/src/main.rs index 4c239806..1967b7c5 100644 --- a/examples/solar_system/src/main.rs +++ b/examples/solar_system/src/main.rs @@ -7,8 +7,8 @@ //! //! [1]: https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Basic_animations#An_animated_solar_system use iced::{ - canvas, executor, Application, Canvas, Color, Command, Container, Element, - Length, Point, Settings, Size, Subscription, Vector, + canvas, executor, window, Application, Canvas, Color, Command, Container, + Element, Length, Point, Settings, Size, Subscription, Vector, }; use std::time::Instant; @@ -33,8 +33,9 @@ enum Message { impl Application for SolarSystem { type Executor = executor::Default; type Message = Message; + type Flags = (); - fn new() -> (Self, Command<Message>) { + fn new(_flags: ()) -> (Self, Command<Message>) { ( SolarSystem { state: State::new(), @@ -95,7 +96,7 @@ impl State { pub fn new() -> State { let now = Instant::now(); - let (width, height) = Settings::default().window.size; + let (width, height) = window::Settings::default().size; State { start: now, diff --git a/examples/stopwatch/src/main.rs b/examples/stopwatch/src/main.rs index d84c4817..5a54ed2b 100644 --- a/examples/stopwatch/src/main.rs +++ b/examples/stopwatch/src/main.rs @@ -30,8 +30,9 @@ enum Message { impl Application for Stopwatch { type Executor = iced_futures::executor::AsyncStd; type Message = Message; + type Flags = (); - fn new() -> (Stopwatch, Command<Message>) { + fn new(_flags: ()) -> (Stopwatch, Command<Message>) { ( Stopwatch { duration: Duration::default(), diff --git a/examples/svg/Cargo.toml b/examples/svg/Cargo.toml index 161ee6a8..d8f83ac2 100644 --- a/examples/svg/Cargo.toml +++ b/examples/svg/Cargo.toml @@ -7,4 +7,3 @@ publish = false [dependencies] iced = { path = "../..", features = ["svg"] } -env_logger = "0.7" diff --git a/examples/svg/src/main.rs b/examples/svg/src/main.rs index 811fdfb5..e19eeca2 100644 --- a/examples/svg/src/main.rs +++ b/examples/svg/src/main.rs @@ -1,19 +1,16 @@ -use iced::{Column, Container, Element, Length, Sandbox, Settings, Svg}; +use iced::{Container, Element, Length, Sandbox, Settings, Svg}; pub fn main() { - env_logger::init(); - Tiger::run(Settings::default()) } -#[derive(Default)] struct Tiger; impl Sandbox for Tiger { type Message = (); fn new() -> Self { - Self::default() + Tiger } fn title(&self) -> String { @@ -23,18 +20,17 @@ impl Sandbox for Tiger { fn update(&mut self, _message: ()) {} fn view(&mut self) -> Element<()> { - let content = Column::new().padding(20).push( - Svg::new(format!( - "{}/resources/tiger.svg", - env!("CARGO_MANIFEST_DIR") - )) - .width(Length::Fill) - .height(Length::Fill), - ); - - Container::new(content) + let svg = Svg::from_path(format!( + "{}/resources/tiger.svg", + env!("CARGO_MANIFEST_DIR") + )) + .width(Length::Fill) + .height(Length::Fill); + + Container::new(svg) .width(Length::Fill) .height(Length::Fill) + .padding(20) .center_x() .center_y() .into() diff --git a/examples/todos/src/main.rs b/examples/todos/src/main.rs index 7e866b19..c9cbcc69 100644 --- a/examples/todos/src/main.rs +++ b/examples/todos/src/main.rs @@ -40,8 +40,9 @@ enum Message { impl Application for Todos { type Executor = iced::executor::Default; type Message = Message; + type Flags = (); - fn new() -> (Todos, Command<Message>) { + fn new(_flags: ()) -> (Todos, Command<Message>) { ( Todos::Loading, Command::perform(SavedState::load(), Message::Loaded), |