diff options
author | 2024-03-19 22:09:36 +0900 | |
---|---|---|
committer | 2024-03-19 22:09:36 +0900 | |
commit | f3a1c785b2743e9c48c3d28df0c6772ce579d7c8 (patch) | |
tree | 1b39799f45878d89b4f9e2f9bea8fa8a7ed07150 /examples/arc | |
parent | c9453cd55d84f0dd2ad0050208863d036c98843f (diff) | |
parent | 8ce16aba6204cb5c02a709cdf79c309f7b7e0196 (diff) | |
download | iced-f3a1c785b2743e9c48c3d28df0c6772ce579d7c8.tar.gz iced-f3a1c785b2743e9c48c3d28df0c6772ce579d7c8.tar.bz2 iced-f3a1c785b2743e9c48c3d28df0c6772ce579d7c8.zip |
Merge branch 'iced-rs:master' into viewer_content_fit
Diffstat (limited to 'examples/arc')
-rw-r--r-- | examples/arc/src/main.rs | 53 |
1 files changed, 17 insertions, 36 deletions
diff --git a/examples/arc/src/main.rs b/examples/arc/src/main.rs index 6a68cca1..4576404f 100644 --- a/examples/arc/src/main.rs +++ b/examples/arc/src/main.rs @@ -1,20 +1,17 @@ use std::{f32::consts::PI, time::Instant}; -use iced::executor; use iced::mouse; use iced::widget::canvas::{ self, stroke, Cache, Canvas, Geometry, Path, Stroke, }; -use iced::{ - Application, Command, Element, Length, Point, Rectangle, Renderer, - Settings, Subscription, Theme, -}; +use iced::{Element, Length, Point, Rectangle, Renderer, Subscription, Theme}; pub fn main() -> iced::Result { - Arc::run(Settings { - antialiasing: true, - ..Settings::default() - }) + iced::program("Arc - Iced", Arc::update, Arc::view) + .subscription(Arc::subscription) + .theme(|_| Theme::Dark) + .antialiasing(true) + .run() } struct Arc { @@ -27,30 +24,9 @@ enum Message { Tick, } -impl Application for Arc { - type Executor = executor::Default; - type Message = Message; - type Theme = Theme; - type Flags = (); - - fn new(_flags: ()) -> (Self, Command<Message>) { - ( - Arc { - start: Instant::now(), - cache: Cache::default(), - }, - Command::none(), - ) - } - - fn title(&self) -> String { - String::from("Arc - Iced") - } - - fn update(&mut self, _: Message) -> Command<Message> { +impl Arc { + fn update(&mut self, _: Message) { self.cache.clear(); - - Command::none() } fn view(&self) -> Element<Message> { @@ -60,16 +36,21 @@ impl Application for Arc { .into() } - fn theme(&self) -> Theme { - Theme::Dark - } - fn subscription(&self) -> Subscription<Message> { iced::time::every(std::time::Duration::from_millis(10)) .map(|_| Message::Tick) } } +impl Default for Arc { + fn default() -> Self { + Arc { + start: Instant::now(), + cache: Cache::default(), + } + } +} + impl<Message> canvas::Program<Message> for Arc { type State = (); |