summaryrefslogtreecommitdiffstats
path: root/examples/layout
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/layout
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/layout')
-rw-r--r--examples/layout/src/main.rs34
1 files changed, 9 insertions, 25 deletions
diff --git a/examples/layout/src/main.rs b/examples/layout/src/main.rs
index 17c51e3d..713e2b70 100644
--- a/examples/layout/src/main.rs
+++ b/examples/layout/src/main.rs
@@ -1,4 +1,3 @@
-use iced::executor;
use iced::keyboard;
use iced::mouse;
use iced::widget::{
@@ -6,15 +5,18 @@ use iced::widget::{
row, scrollable, text,
};
use iced::{
- color, Alignment, Application, Command, Element, Font, Length, Point,
- Rectangle, Renderer, Settings, Subscription, Theme,
+ color, Alignment, Element, Font, Length, Point, Rectangle, Renderer,
+ Subscription, Theme,
};
pub fn main() -> iced::Result {
- Layout::run(Settings::default())
+ iced::program(Layout::title, Layout::update, Layout::view)
+ .subscription(Layout::subscription)
+ .theme(Layout::theme)
+ .run()
}
-#[derive(Debug)]
+#[derive(Default, Debug)]
struct Layout {
example: Example,
explain: bool,
@@ -29,28 +31,12 @@ enum Message {
ThemeSelected(Theme),
}
-impl Application for Layout {
- type Message = Message;
- type Theme = Theme;
- type Executor = executor::Default;
- type Flags = ();
-
- fn new(_flags: Self::Flags) -> (Self, Command<Message>) {
- (
- Self {
- example: Example::default(),
- explain: false,
- theme: Theme::Light,
- },
- Command::none(),
- )
- }
-
+impl Layout {
fn title(&self) -> String {
format!("{} - Layout - Iced", self.example.title)
}
- fn update(&mut self, message: Self::Message) -> Command<Message> {
+ fn update(&mut self, message: Message) {
match message {
Message::Next => {
self.example = self.example.next();
@@ -65,8 +51,6 @@ impl Application for Layout {
self.theme = theme;
}
}
-
- Command::none()
}
fn subscription(&self) -> Subscription<Message> {