aboutsummaryrefslogtreecommitdiff
path: root/src/scrollable.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/scrollable.rs')
-rw-r--r--src/scrollable.rs78
1 files changed, 57 insertions, 21 deletions
diff --git a/src/scrollable.rs b/src/scrollable.rs
index f7bed54..0277ea8 100644
--- a/src/scrollable.rs
+++ b/src/scrollable.rs
@@ -1,6 +1,6 @@
-use iced_widget::core::{Background, Border, border};
+use iced_widget::core::{Background, Border, Shadow, border};
use iced_widget::scrollable::{
- Catalog, Rail, Scroller, Status, Style, StyleFn,
+ AutoScroll, Catalog, Rail, Scroller, Status, Style, StyleFn,
};
use super::Theme;
@@ -26,7 +26,7 @@ impl Catalog for Theme {
pub fn default(theme: &Theme, status: Status) -> Style {
let surface = theme.colors().surface;
- let active = Rail {
+ let active_rail = Rail {
background: None,
scroller: Scroller {
color: surface.text,
@@ -35,20 +35,35 @@ pub fn default(theme: &Theme, status: Status) -> Style {
border: Border::default(),
};
- let disabled = Rail {
+ let disabled_rail = Rail {
background: Some(Background::Color(disabled_container(surface.text))),
scroller: Scroller {
color: disabled_text(surface.text),
border: border::rounded(400),
},
- ..active
+ ..active_rail
+ };
+
+ let active_auto_scroll = AutoScroll {
+ background: surface.color.into(),
+ border: border::rounded(500).width(1).color(surface.text),
+ icon: surface.text,
+ shadow: Shadow::default(),
+ };
+
+ let disabled_auto_scroll = AutoScroll {
+ background: disabled_container(surface.text).into(),
+ border: border::rounded(400),
+ icon: disabled_text(surface.text),
+ shadow: Shadow::default(),
};
let style = Style {
container: surface_container(theme),
- vertical_rail: active,
- horizontal_rail: active,
+ vertical_rail: active_rail,
+ horizontal_rail: active_rail,
gap: None,
+ auto_scroll: active_auto_scroll,
};
match status {
@@ -57,14 +72,21 @@ pub fn default(theme: &Theme, status: Status) -> Style {
is_vertical_scrollbar_disabled,
} => Style {
horizontal_rail: if is_horizontal_scrollbar_disabled {
- disabled
+ disabled_rail
} else {
- active
+ active_rail
},
vertical_rail: if is_vertical_scrollbar_disabled {
- disabled
+ disabled_rail
+ } else {
+ active_rail
+ },
+ auto_scroll: if is_vertical_scrollbar_disabled
+ && is_horizontal_scrollbar_disabled
+ {
+ disabled_auto_scroll
} else {
- active
+ active_auto_scroll
},
..style
},
@@ -83,23 +105,30 @@ pub fn default(theme: &Theme, status: Status) -> Style {
),
border: border::rounded(400),
},
- ..active
+ ..active_rail
};
Style {
horizontal_rail: if is_horizontal_scrollbar_disabled {
- disabled
+ disabled_rail
} else if is_horizontal_scrollbar_hovered {
hovered_rail
} else {
- active
+ active_rail
},
vertical_rail: if is_vertical_scrollbar_disabled {
- disabled
+ disabled_rail
} else if is_vertical_scrollbar_hovered {
hovered_rail
} else {
- active
+ active_rail
+ },
+ auto_scroll: if is_vertical_scrollbar_disabled
+ && is_horizontal_scrollbar_disabled
+ {
+ disabled_auto_scroll
+ } else {
+ active_auto_scroll
},
..style
}
@@ -119,23 +148,30 @@ pub fn default(theme: &Theme, status: Status) -> Style {
),
border: border::rounded(400),
},
- ..active
+ ..active_rail
};
Style {
horizontal_rail: if is_horizontal_scrollbar_disabled {
- disabled
+ disabled_rail
} else if is_horizontal_scrollbar_dragged {
dragged_rail
} else {
- active
+ active_rail
},
vertical_rail: if is_vertical_scrollbar_disabled {
- disabled
+ disabled_rail
} else if is_vertical_scrollbar_dragged {
dragged_rail
} else {
- active
+ active_rail
+ },
+ auto_scroll: if is_vertical_scrollbar_disabled
+ && is_horizontal_scrollbar_disabled
+ {
+ disabled_auto_scroll
+ } else {
+ active_auto_scroll
},
..style
}