From c22269bff3085012d326a0df77bf27ad5bcb41b7 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sat, 16 Mar 2024 05:33:47 +0100 Subject: Introduce `Program` API --- examples/tooltip/src/main.rs | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) (limited to 'examples/tooltip') diff --git a/examples/tooltip/src/main.rs b/examples/tooltip/src/main.rs index ee757311..b6603068 100644 --- a/examples/tooltip/src/main.rs +++ b/examples/tooltip/src/main.rs @@ -1,12 +1,13 @@ use iced::widget::tooltip::Position; use iced::widget::{button, container, tooltip}; -use iced::{Element, Length, Sandbox, Settings}; +use iced::{Element, Length}; pub fn main() -> iced::Result { - Example::run(Settings::default()) + iced::run("Tooltip - Iced", Tooltip::update, Tooltip::view) } -struct Example { +#[derive(Default)] +struct Tooltip { position: Position, } @@ -15,28 +16,16 @@ enum Message { ChangePosition, } -impl Sandbox for Example { - type Message = Message; - - fn new() -> Self { - Self { - position: Position::Bottom, - } - } - - fn title(&self) -> String { - String::from("Tooltip - Iced") - } - +impl Tooltip { fn update(&mut self, message: Message) { match message { Message::ChangePosition => { let position = match &self.position { - Position::FollowCursor => Position::Top, Position::Top => Position::Bottom, Position::Bottom => Position::Left, Position::Left => Position::Right, Position::Right => Position::FollowCursor, + Position::FollowCursor => Position::Top, }; self.position = position; -- cgit