diff options
author | 2024-03-17 13:46:52 +0100 | |
---|---|---|
committer | 2024-03-17 13:46:52 +0100 | |
commit | 846d76cd3f3f2faae5efbb3fda2a2bcb3b064481 (patch) | |
tree | 44c407d10ffc60856a83019a5794544723ade037 /examples/gradient | |
parent | 9152904af1630a6d373b2fd7c284835bf0a3ca95 (diff) | |
download | iced-846d76cd3f3f2faae5efbb3fda2a2bcb3b064481.tar.gz iced-846d76cd3f3f2faae5efbb3fda2a2bcb3b064481.tar.bz2 iced-846d76cd3f3f2faae5efbb3fda2a2bcb3b064481.zip |
Remove `Sandbox` trait :tada:
Diffstat (limited to 'examples/gradient')
-rw-r--r-- | examples/gradient/src/main.rs | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/examples/gradient/src/main.rs b/examples/gradient/src/main.rs index 8ed4c830..6cfe395a 100644 --- a/examples/gradient/src/main.rs +++ b/examples/gradient/src/main.rs @@ -1,22 +1,17 @@ use iced::application; +use iced::gradient; use iced::widget::{ checkbox, column, container, horizontal_space, row, slider, text, }; -use iced::{gradient, window}; -use iced::{ - Alignment, Color, Element, Length, Radians, Sandbox, Settings, Theme, -}; +use iced::{Alignment, Color, Element, Length, Radians, Theme}; pub fn main() -> iced::Result { tracing_subscriber::fmt::init(); - Gradient::run(Settings { - window: window::Settings { - transparent: true, - ..Default::default() - }, - ..Default::default() - }) + iced::application("Gradient - Iced", Gradient::update, Gradient::view) + .style(Gradient::style) + .transparent(true) + .run() } #[derive(Debug, Clone, Copy)] @@ -35,9 +30,7 @@ enum Message { TransparentToggled(bool), } -impl Sandbox for Gradient { - type Message = Message; - +impl Gradient { fn new() -> Self { Self { start: Color::WHITE, @@ -47,10 +40,6 @@ impl Sandbox for Gradient { } } - fn title(&self) -> String { - String::from("Gradient") - } - fn update(&mut self, message: Message) { match message { Message::StartChanged(color) => self.start = color, @@ -118,6 +107,12 @@ impl Sandbox for Gradient { } } +impl Default for Gradient { + fn default() -> Self { + Self::new() + } +} + fn color_picker(label: &str, color: Color) -> Element<'_, Color> { row![ text(label).width(64), |