Introduce Program API
This commit is contained in:
parent
0524e9b457
commit
c22269bff3
43 changed files with 1141 additions and 831 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue