summaryrefslogtreecommitdiffstats
path: root/examples/visible_bounds
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-03-17 18:37:29 +0100
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-03-17 18:37:29 +0100
commit78e78d20b6c816b476aec0015a413753aee58725 (patch)
treec1c184dc9c649ac21e57b8749370a131d39e5d76 /examples/visible_bounds
parentc4be7efce55ba8c2e11f3da70c41c91dab2698fa (diff)
downloadiced-78e78d20b6c816b476aec0015a413753aee58725.tar.gz
iced-78e78d20b6c816b476aec0015a413753aee58725.tar.bz2
iced-78e78d20b6c816b476aec0015a413753aee58725.zip
Use `Program` API in `visible_bounds` example
Diffstat (limited to 'examples/visible_bounds')
-rw-r--r--examples/visible_bounds/src/main.rs37
1 files changed, 8 insertions, 29 deletions
diff --git a/examples/visible_bounds/src/main.rs b/examples/visible_bounds/src/main.rs
index 400d5753..332b6a7b 100644
--- a/examples/visible_bounds/src/main.rs
+++ b/examples/visible_bounds/src/main.rs
@@ -1,19 +1,22 @@
use iced::event::{self, Event};
-use iced::executor;
use iced::mouse;
use iced::widget::{
column, container, horizontal_space, row, scrollable, text, vertical_space,
};
use iced::window;
use iced::{
- Alignment, Application, Color, Command, Element, Font, Length, Point,
- Rectangle, Settings, Subscription, Theme,
+ Alignment, Color, Command, Element, Font, Length, Point, Rectangle,
+ Subscription, Theme,
};
pub fn main() -> iced::Result {
- Example::run(Settings::default())
+ iced::program("Visible Bounds - Iced", Example::update, Example::view)
+ .subscription(Example::subscription)
+ .theme(|_| Theme::Dark)
+ .run()
}
+#[derive(Default)]
struct Example {
mouse_position: Option<Point>,
outer_bounds: Option<Rectangle>,
@@ -29,27 +32,7 @@ enum Message {
InnerBoundsFetched(Option<Rectangle>),
}
-impl Application for Example {
- type Message = Message;
- type Theme = Theme;
- type Flags = ();
- type Executor = executor::Default;
-
- fn new(_flags: Self::Flags) -> (Self, Command<Message>) {
- (
- Self {
- mouse_position: None,
- outer_bounds: None,
- inner_bounds: None,
- },
- Command::none(),
- )
- }
-
- fn title(&self) -> String {
- String::from("Visible bounds - Iced")
- }
-
+impl Example {
fn update(&mut self, message: Message) -> Command<Message> {
match message {
Message::MouseMoved(position) => {
@@ -172,10 +155,6 @@ impl Application for Example {
_ => None,
})
}
-
- fn theme(&self) -> Theme {
- Theme::Dark
- }
}
use once_cell::sync::Lazy;