From ff2519b1d43d481987351a83b6dd7237524c21f0 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 27 Jul 2022 06:49:20 +0200 Subject: Replace stateful widgets with new `iced_pure` API --- examples/solar_system/src/main.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'examples/solar_system') diff --git a/examples/solar_system/src/main.rs b/examples/solar_system/src/main.rs index fc53d8f7..c59d73a8 100644 --- a/examples/solar_system/src/main.rs +++ b/examples/solar_system/src/main.rs @@ -7,14 +7,15 @@ //! //! [1]: https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Basic_animations#An_animated_solar_system use iced::application; -use iced::canvas::{self, Cursor, Path, Stroke}; use iced::executor; use iced::theme::{self, Theme}; use iced::time; +use iced::widget::canvas; +use iced::widget::canvas::{Cursor, Path, Stroke}; use iced::window; use iced::{ - Application, Canvas, Color, Command, Element, Length, Point, Rectangle, - Settings, Size, Subscription, Vector, + Application, Color, Command, Element, Length, Point, Rectangle, Settings, + Size, Subscription, Vector, }; use std::time::Instant; @@ -68,8 +69,8 @@ impl Application for SolarSystem { time::every(std::time::Duration::from_millis(10)).map(Message::Tick) } - fn view(&mut self) -> Element { - Canvas::new(&mut self.state) + fn view(&self) -> Element { + canvas(&self.state) .width(Length::Fill) .height(Length::Fill) .into() @@ -145,8 +146,11 @@ impl State { } impl canvas::Program for State { + type State = (); + fn draw( &self, + _state: &Self::State, _theme: &Theme, bounds: Rectangle, _cursor: Cursor, -- cgit