summaryrefslogtreecommitdiffstats
path: root/examples/tooltip
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector@hecrj.dev>2024-03-16 17:09:00 +0100
committerLibravatar GitHub <noreply@github.com>2024-03-16 17:09:00 +0100
commit503a48e89977437bf8b7bf485f416a15a2e83ed0 (patch)
tree30306bbaee7a31090ace9d7725d46c2c0027fe6b /examples/tooltip
parent0524e9b4571d264018656418f02a1f9e27e268d7 (diff)
parentcfc0383bbfff083786840e3f1fd499e5991fa629 (diff)
downloadiced-503a48e89977437bf8b7bf485f416a15a2e83ed0.tar.gz
iced-503a48e89977437bf8b7bf485f416a15a2e83ed0.tar.bz2
iced-503a48e89977437bf8b7bf485f416a15a2e83ed0.zip
Merge pull request #2331 from iced-rs/program-api
`Program` API
Diffstat (limited to 'examples/tooltip')
-rw-r--r--examples/tooltip/src/main.rs23
1 files changed, 6 insertions, 17 deletions
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;