diff options
author | 2024-03-19 22:09:36 +0900 | |
---|---|---|
committer | 2024-03-19 22:09:36 +0900 | |
commit | f3a1c785b2743e9c48c3d28df0c6772ce579d7c8 (patch) | |
tree | 1b39799f45878d89b4f9e2f9bea8fa8a7ed07150 /examples/pane_grid | |
parent | c9453cd55d84f0dd2ad0050208863d036c98843f (diff) | |
parent | 8ce16aba6204cb5c02a709cdf79c309f7b7e0196 (diff) | |
download | iced-f3a1c785b2743e9c48c3d28df0c6772ce579d7c8.tar.gz iced-f3a1c785b2743e9c48c3d28df0c6772ce579d7c8.tar.bz2 iced-f3a1c785b2743e9c48c3d28df0c6772ce579d7c8.zip |
Merge branch 'iced-rs:master' into viewer_content_fit
Diffstat (limited to 'examples/pane_grid')
-rw-r--r-- | examples/pane_grid/src/main.rs | 46 |
1 files changed, 18 insertions, 28 deletions
diff --git a/examples/pane_grid/src/main.rs b/examples/pane_grid/src/main.rs index 5e728ce1..829996d8 100644 --- a/examples/pane_grid/src/main.rs +++ b/examples/pane_grid/src/main.rs @@ -1,17 +1,15 @@ use iced::alignment::{self, Alignment}; -use iced::executor; use iced::keyboard; use iced::widget::pane_grid::{self, PaneGrid}; use iced::widget::{ button, column, container, responsive, row, scrollable, text, }; -use iced::{ - Application, Color, Command, Element, Length, Settings, Size, Subscription, - Theme, -}; +use iced::{Color, Element, Length, Size, Subscription}; pub fn main() -> iced::Result { - Example::run(Settings::default()) + iced::program("Pane Grid - Iced", Example::update, Example::view) + .subscription(Example::subscription) + .run() } struct Example { @@ -35,30 +33,18 @@ enum Message { CloseFocused, } -impl Application for Example { - type Message = Message; - type Theme = Theme; - type Executor = executor::Default; - type Flags = (); - - fn new(_flags: ()) -> (Self, Command<Message>) { +impl Example { + fn new() -> Self { let (panes, _) = pane_grid::State::new(Pane::new(0)); - ( - Example { - panes, - panes_created: 1, - focus: None, - }, - Command::none(), - ) - } - - fn title(&self) -> String { - String::from("Pane grid - Iced") + Example { + panes, + panes_created: 1, + focus: None, + } } - fn update(&mut self, message: Message) -> Command<Message> { + fn update(&mut self, message: Message) { match message { Message::Split(axis, pane) => { let result = @@ -132,8 +118,6 @@ impl Application for Example { } } } - - Command::none() } fn subscription(&self) -> Subscription<Message> { @@ -209,6 +193,12 @@ impl Application for Example { } } +impl Default for Example { + fn default() -> Self { + Example::new() + } +} + const PANE_ID_COLOR_UNFOCUSED: Color = Color::from_rgb( 0xFF as f32 / 255.0, 0xC7 as f32 / 255.0, |