summaryrefslogtreecommitdiffstats
path: root/examples/solar_system
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-07-27 06:49:20 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-07-27 06:49:20 +0200
commitff2519b1d43d481987351a83b6dd7237524c21f0 (patch)
tree5731eeb7eb1247d4a8951de0d5bc5d8102640559 /examples/solar_system
parentc44267b85f7aaa2997e3caf1323b837d95818c22 (diff)
downloadiced-ff2519b1d43d481987351a83b6dd7237524c21f0.tar.gz
iced-ff2519b1d43d481987351a83b6dd7237524c21f0.tar.bz2
iced-ff2519b1d43d481987351a83b6dd7237524c21f0.zip
Replace stateful widgets with new `iced_pure` API
Diffstat (limited to 'examples/solar_system')
-rw-r--r--examples/solar_system/src/main.rs14
1 files changed, 9 insertions, 5 deletions
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<Message> {
- Canvas::new(&mut self.state)
+ fn view(&self) -> Element<Message> {
+ canvas(&self.state)
.width(Length::Fill)
.height(Length::Fill)
.into()
@@ -145,8 +146,11 @@ impl State {
}
impl<Message> canvas::Program<Message> for State {
+ type State = ();
+
fn draw(
&self,
+ _state: &Self::State,
_theme: &Theme,
bounds: Rectangle,
_cursor: Cursor,