diff options
Diffstat (limited to 'examples/vectorial_text/src/main.rs')
-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() + } +} |