summaryrefslogtreecommitdiffstats
path: root/examples/scrollable/src/main.rs
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/scrollable/src/main.rs
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/scrollable/src/main.rs')
-rw-r--r--examples/scrollable/src/main.rs54
1 files changed, 25 insertions, 29 deletions
diff --git a/examples/scrollable/src/main.rs b/examples/scrollable/src/main.rs
index 2ad7272b..240ae908 100644
--- a/examples/scrollable/src/main.rs
+++ b/examples/scrollable/src/main.rs
@@ -1,20 +1,22 @@
-use iced::executor;
use iced::widget::scrollable::Properties;
use iced::widget::{
button, column, container, horizontal_space, progress_bar, radio, row,
scrollable, slider, text, vertical_space, Scrollable,
};
-use iced::{
- Alignment, Application, Border, Color, Command, Element, Length, Settings,
- Theme,
-};
+use iced::{Alignment, Border, Color, Command, Element, Length, Theme};
use once_cell::sync::Lazy;
static SCROLLABLE_ID: Lazy<scrollable::Id> = Lazy::new(scrollable::Id::unique);
pub fn main() -> iced::Result {
- ScrollableDemo::run(Settings::default())
+ iced::program(
+ "Scrollable - Iced",
+ ScrollableDemo::update,
+ ScrollableDemo::view,
+ )
+ .theme(ScrollableDemo::theme)
+ .run()
}
struct ScrollableDemo {
@@ -45,28 +47,16 @@ enum Message {
Scrolled(scrollable::Viewport),
}
-impl Application for ScrollableDemo {
- type Executor = executor::Default;
- type Message = Message;
- type Theme = Theme;
- type Flags = ();
-
- fn new(_flags: Self::Flags) -> (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 title(&self) -> String {
- String::from("Scrollable - Iced")
+impl ScrollableDemo {
+ 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> {
@@ -340,11 +330,17 @@ impl Application for ScrollableDemo {
container(content).padding(20).center_x().center_y().into()
}
- fn theme(&self) -> Self::Theme {
+ fn theme(&self) -> Theme {
Theme::Dark
}
}
+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(),