summaryrefslogtreecommitdiffstats
path: root/examples/loading_spinners
diff options
context:
space:
mode:
authorLibravatar Gigas002 <24297712+Gigas002@users.noreply.github.com>2024-03-19 22:09:36 +0900
committerLibravatar GitHub <noreply@github.com>2024-03-19 22:09:36 +0900
commitf3a1c785b2743e9c48c3d28df0c6772ce579d7c8 (patch)
tree1b39799f45878d89b4f9e2f9bea8fa8a7ed07150 /examples/loading_spinners
parentc9453cd55d84f0dd2ad0050208863d036c98843f (diff)
parent8ce16aba6204cb5c02a709cdf79c309f7b7e0196 (diff)
downloadiced-f3a1c785b2743e9c48c3d28df0c6772ce579d7c8.tar.gz
iced-f3a1c785b2743e9c48c3d28df0c6772ce579d7c8.tar.bz2
iced-f3a1c785b2743e9c48c3d28df0c6772ce579d7c8.zip
Merge branch 'iced-rs:master' into viewer_content_fit
Diffstat (limited to 'examples/loading_spinners')
-rw-r--r--examples/loading_spinners/src/main.rs49
1 files changed, 18 insertions, 31 deletions
diff --git a/examples/loading_spinners/src/main.rs b/examples/loading_spinners/src/main.rs
index 93a4605e..eaa4d57e 100644
--- a/examples/loading_spinners/src/main.rs
+++ b/examples/loading_spinners/src/main.rs
@@ -1,6 +1,5 @@
-use iced::executor;
use iced::widget::{column, container, row, slider, text};
-use iced::{Application, Command, Element, Length, Settings, Theme};
+use iced::{Element, Length};
use std::time::Duration;
@@ -12,51 +11,31 @@ use circular::Circular;
use linear::Linear;
pub fn main() -> iced::Result {
- LoadingSpinners::run(Settings {
- antialiasing: true,
- ..Default::default()
- })
+ iced::program(
+ "Loading Spinners - Iced",
+ LoadingSpinners::update,
+ LoadingSpinners::view,
+ )
+ .antialiasing(true)
+ .run()
}
struct LoadingSpinners {
cycle_duration: f32,
}
-impl Default for LoadingSpinners {
- fn default() -> Self {
- Self {
- cycle_duration: 2.0,
- }
- }
-}
-
#[derive(Debug, Clone, Copy)]
enum Message {
CycleDurationChanged(f32),
}
-impl Application for LoadingSpinners {
- type Message = Message;
- type Flags = ();
- type Executor = executor::Default;
- type Theme = Theme;
-
- fn new(_flags: Self::Flags) -> (Self, Command<Message>) {
- (Self::default(), Command::none())
- }
-
- fn title(&self) -> String {
- String::from("Loading Spinners - Iced")
- }
-
- fn update(&mut self, message: Message) -> Command<Message> {
+impl LoadingSpinners {
+ fn update(&mut self, message: Message) {
match message {
Message::CycleDurationChanged(duration) => {
self.cycle_duration = duration;
}
}
-
- Command::none()
}
fn view(&self) -> Element<Message> {
@@ -115,3 +94,11 @@ impl Application for LoadingSpinners {
.into()
}
}
+
+impl Default for LoadingSpinners {
+ fn default() -> Self {
+ Self {
+ cycle_duration: 2.0,
+ }
+ }
+}