diff options
author | 2024-03-16 17:09:00 +0100 | |
---|---|---|
committer | 2024-03-16 17:09:00 +0100 | |
commit | 503a48e89977437bf8b7bf485f416a15a2e83ed0 (patch) | |
tree | 30306bbaee7a31090ace9d7725d46c2c0027fe6b /examples/pane_grid | |
parent | 0524e9b4571d264018656418f02a1f9e27e268d7 (diff) | |
parent | cfc0383bbfff083786840e3f1fd499e5991fa629 (diff) | |
download | iced-503a48e89977437bf8b7bf485f416a15a2e83ed0.tar.gz iced-503a48e89977437bf8b7bf485f416a15a2e83ed0.tar.bz2 iced-503a48e89977437bf8b7bf485f416a15a2e83ed0.zip |
Merge pull request #2331 from iced-rs/program-api
`Program` API
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..4c46f550 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::sandbox("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, |