diff options
| author | Polesznyák Márk <contact@pml68.dev> | 2025-11-28 12:19:51 +0100 |
|---|---|---|
| committer | Polesznyák Márk <contact@pml68.dev> | 2025-11-30 01:58:04 +0100 |
| commit | 9eb4a16495921ef65e3fb27277e64e8e9b7b2fd1 (patch) | |
| tree | c7700a1ab1246c49911a09b3cbbd43b6416d21a1 /src/scrollable.rs | |
| parent | feat!: combine `Primary`, `Secondary`, `Tertiary` and `Error` (diff) | |
| download | iced_material-9eb4a16495921ef65e3fb27277e64e8e9b7b2fd1.tar.gz | |
chore: update as necessary for upstream iced changes
Diffstat (limited to 'src/scrollable.rs')
| -rw-r--r-- | src/scrollable.rs | 78 |
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 } |
