summaryrefslogtreecommitdiffstats
path: root/examples/visible_bounds/src
diff options
context:
space:
mode:
authorLibravatar Gigas002 <24297712+Gigas002@users.noreply.github.com>2024-03-19 22:09:36 +0900
committerLibravatar GitHub <noreply@github.com>2024-03-19 22:09:36 +0900
commitf3a1c785b2743e9c48c3d28df0c6772ce579d7c8 (patch)
tree1b39799f45878d89b4f9e2f9bea8fa8a7ed07150 /examples/visible_bounds/src
parentc9453cd55d84f0dd2ad0050208863d036c98843f (diff)
parent8ce16aba6204cb5c02a709cdf79c309f7b7e0196 (diff)
downloadiced-f3a1c785b2743e9c48c3d28df0c6772ce579d7c8.tar.gz
iced-f3a1c785b2743e9c48c3d28df0c6772ce579d7c8.tar.bz2
iced-f3a1c785b2743e9c48c3d28df0c6772ce579d7c8.zip
Merge branch 'iced-rs:master' into viewer_content_fit
Diffstat (limited to 'examples/visible_bounds/src')
-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;