diff options
author | 2024-03-16 15:53:03 +0100 | |
---|---|---|
committer | 2024-03-16 15:54:37 +0100 | |
commit | 93ae790da14544667176ecdbdd6a4eaaa98a248a (patch) | |
tree | 4af03301f9a16049d29be305c48b4054a3afee99 /examples/scrollable | |
parent | 5a986897d22f6d79a7a1fbaa4f3d1aaa1f9ca3bb (diff) | |
download | iced-93ae790da14544667176ecdbdd6a4eaaa98a248a.tar.gz iced-93ae790da14544667176ecdbdd6a4eaaa98a248a.tar.bz2 iced-93ae790da14544667176ecdbdd6a4eaaa98a248a.zip |
Implement `Program::load` to specify startup `Command`
Diffstat (limited to 'examples/scrollable')
-rw-r--r-- | examples/scrollable/src/main.rs | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/examples/scrollable/src/main.rs b/examples/scrollable/src/main.rs index 3e1b0408..a6f3c689 100644 --- a/examples/scrollable/src/main.rs +++ b/examples/scrollable/src/main.rs @@ -11,12 +11,11 @@ static SCROLLABLE_ID: Lazy<scrollable::Id> = Lazy::new(scrollable::Id::unique); pub fn main() -> iced::Result { iced::application( - ScrollableDemo::new, + "Scrollable - Iced", ScrollableDemo::update, ScrollableDemo::view, ) .theme(ScrollableDemo::theme) - .title("Scrollable - Iced") .run() } @@ -49,18 +48,15 @@ enum Message { } impl ScrollableDemo { - fn new() -> (Self, Command<Message>) { - ( - ScrollableDemo { - scrollable_direction: Direction::Vertical, - scrollbar_width: 10, - scrollbar_margin: 0, - scroller_width: 10, - current_scroll_offset: scrollable::RelativeOffset::START, - alignment: scrollable::Alignment::Start, - }, - Command::none(), - ) + fn new() -> Self { + ScrollableDemo { + scrollable_direction: Direction::Vertical, + scrollbar_width: 10, + scrollbar_margin: 0, + scroller_width: 10, + current_scroll_offset: scrollable::RelativeOffset::START, + alignment: scrollable::Alignment::Start, + } } fn update(&mut self, message: Message) -> Command<Message> { @@ -339,6 +335,12 @@ impl ScrollableDemo { } } +impl Default for ScrollableDemo { + fn default() -> Self { + Self::new() + } +} + fn progress_bar_custom_style(theme: &Theme) -> progress_bar::Appearance { progress_bar::Appearance { background: theme.extended_palette().background.strong.color.into(), |