diff options
author | 2024-03-16 05:33:47 +0100 | |
---|---|---|
committer | 2024-03-16 05:33:47 +0100 | |
commit | c22269bff3085012d326a0df77bf27ad5bcb41b7 (patch) | |
tree | 1083f21d012ab2bac88fb51537d4dc431bc7f170 /examples/vectorial_text | |
parent | 0524e9b4571d264018656418f02a1f9e27e268d7 (diff) | |
download | iced-c22269bff3085012d326a0df77bf27ad5bcb41b7.tar.gz iced-c22269bff3085012d326a0df77bf27ad5bcb41b7.tar.bz2 iced-c22269bff3085012d326a0df77bf27ad5bcb41b7.zip |
Introduce `Program` API
Diffstat (limited to 'examples/vectorial_text')
-rw-r--r-- | examples/vectorial_text/src/main.rs | 39 |
1 files changed, 14 insertions, 25 deletions
diff --git a/examples/vectorial_text/src/main.rs b/examples/vectorial_text/src/main.rs index 0b9ea938..aa870716 100644 --- a/examples/vectorial_text/src/main.rs +++ b/examples/vectorial_text/src/main.rs @@ -3,18 +3,17 @@ use iced::mouse; use iced::widget::{ canvas, checkbox, column, horizontal_space, row, slider, text, }; -use iced::{ - Element, Length, Point, Rectangle, Renderer, Sandbox, Settings, Theme, - Vector, -}; +use iced::{Element, Length, Point, Rectangle, Renderer, Theme, Vector}; pub fn main() -> iced::Result { - VectorialText::run(Settings { - antialiasing: true, - ..Settings::default() - }) + iced::sandbox(VectorialText::update, VectorialText::view) + .theme(|_| Theme::Dark) + .title("Vectorial Text - Iced") + .antialiased() + .run() } +#[derive(Default)] struct VectorialText { state: State, } @@ -27,19 +26,7 @@ enum Message { ToggleJapanese(bool), } -impl Sandbox for VectorialText { - type Message = Message; - - fn new() -> Self { - Self { - state: State::new(), - } - } - - fn title(&self) -> String { - String::from("Vectorial Text - Iced") - } - +impl VectorialText { fn update(&mut self, message: Message) { match message { Message::SizeChanged(size) => { @@ -106,10 +93,6 @@ impl Sandbox for VectorialText { .padding(20) .into() } - - fn theme(&self) -> Theme { - Theme::Dark - } } struct State { @@ -170,3 +153,9 @@ impl<Message> canvas::Program<Message> for State { vec![geometry] } } + +impl Default for State { + fn default() -> Self { + State::new() + } +} |