diff options
author | 2024-03-16 05:33:47 +0100 | |
---|---|---|
committer | 2024-03-16 05:33:47 +0100 | |
commit | c22269bff3085012d326a0df77bf27ad5bcb41b7 (patch) | |
tree | 1083f21d012ab2bac88fb51537d4dc431bc7f170 /examples/custom_quad | |
parent | 0524e9b4571d264018656418f02a1f9e27e268d7 (diff) | |
download | iced-c22269bff3085012d326a0df77bf27ad5bcb41b7.tar.gz iced-c22269bff3085012d326a0df77bf27ad5bcb41b7.tar.bz2 iced-c22269bff3085012d326a0df77bf27ad5bcb41b7.zip |
Introduce `Program` API
Diffstat (limited to 'examples/custom_quad')
-rw-r--r-- | examples/custom_quad/src/main.rs | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/examples/custom_quad/src/main.rs b/examples/custom_quad/src/main.rs index f64379fa..c093e240 100644 --- a/examples/custom_quad/src/main.rs +++ b/examples/custom_quad/src/main.rs @@ -82,12 +82,10 @@ mod quad { } use iced::widget::{column, container, slider, text}; -use iced::{ - Alignment, Color, Element, Length, Sandbox, Settings, Shadow, Vector, -}; +use iced::{Alignment, Color, Element, Length, Shadow, Vector}; pub fn main() -> iced::Result { - Example::run(Settings::default()) + iced::run("Custom Quad - Iced", Example::update, Example::view) } struct Example { @@ -109,9 +107,7 @@ enum Message { ShadowBlurRadiusChanged(f32), } -impl Sandbox for Example { - type Message = Message; - +impl Example { fn new() -> Self { Self { radius: [50.0; 4], @@ -124,10 +120,6 @@ impl Sandbox for Example { } } - fn title(&self) -> String { - String::from("Custom widget - Iced") - } - fn update(&mut self, message: Message) { let [tl, tr, br, bl] = self.radius; match message { @@ -203,3 +195,9 @@ impl Sandbox for Example { .into() } } + +impl Default for Example { + fn default() -> Self { + Self::new() + } +} |