diff options
author | 2024-02-12 19:36:45 +0100 | |
---|---|---|
committer | 2024-02-12 19:36:45 +0100 | |
commit | 7615b2240c360fea21ef041bfd5b1deb73fc03d1 (patch) | |
tree | 3d4056ab100186b46f6f4423f0584afcfc32e8ac /style/src/theme.rs | |
parent | 891f29eea0cb32f0bee49fbace1757b82e1937f3 (diff) | |
parent | 88e2e26ef4517933442af3dbdca30db2a1bf7ace (diff) | |
download | iced-7615b2240c360fea21ef041bfd5b1deb73fc03d1.tar.gz iced-7615b2240c360fea21ef041bfd5b1deb73fc03d1.tar.bz2 iced-7615b2240c360fea21ef041bfd5b1deb73fc03d1.zip |
Merge pull request #2239 from dtzxporter/scrollable-quad-fill
Introduce an appearance for a scrollable, ability to customize the scrollbar gap.
Diffstat (limited to '')
-rw-r--r-- | style/src/theme.rs | 65 |
1 files changed, 22 insertions, 43 deletions
diff --git a/style/src/theme.rs b/style/src/theme.rs index 5909498f..0b56e101 100644 --- a/style/src/theme.rs +++ b/style/src/theme.rs @@ -1188,18 +1188,22 @@ impl Scrollable { impl scrollable::StyleSheet for Theme { type Style = Scrollable; - fn active(&self, style: &Self::Style) -> scrollable::Scrollbar { + fn active(&self, style: &Self::Style) -> scrollable::Appearance { match style { Scrollable::Default => { let palette = self.extended_palette(); - scrollable::Scrollbar { - background: Some(palette.background.weak.color.into()), - border: Border::with_radius(2), - scroller: scrollable::Scroller { - color: palette.background.strong.color, + scrollable::Appearance { + container: container::Appearance::default(), + scrollbar: scrollable::Scrollbar { + background: Some(palette.background.weak.color.into()), border: Border::with_radius(2), + scroller: scrollable::Scroller { + color: palette.background.strong.color, + border: Border::with_radius(2), + }, }, + gap: None, } } Scrollable::Custom(custom) => custom.active(self), @@ -1210,19 +1214,24 @@ impl scrollable::StyleSheet for Theme { &self, style: &Self::Style, is_mouse_over_scrollbar: bool, - ) -> scrollable::Scrollbar { + ) -> scrollable::Appearance { match style { Scrollable::Default => { if is_mouse_over_scrollbar { let palette = self.extended_palette(); - scrollable::Scrollbar { - background: Some(palette.background.weak.color.into()), - border: Border::with_radius(2), - scroller: scrollable::Scroller { - color: palette.primary.strong.color, + scrollable::Appearance { + scrollbar: scrollable::Scrollbar { + background: Some( + palette.background.weak.color.into(), + ), border: Border::with_radius(2), + scroller: scrollable::Scroller { + color: palette.primary.strong.color, + border: Border::with_radius(2), + }, }, + ..self.active(style) } } else { self.active(style) @@ -1234,42 +1243,12 @@ impl scrollable::StyleSheet for Theme { } } - fn dragging(&self, style: &Self::Style) -> scrollable::Scrollbar { + fn dragging(&self, style: &Self::Style) -> scrollable::Appearance { match style { Scrollable::Default => self.hovered(style, true), Scrollable::Custom(custom) => custom.dragging(self), } } - - fn active_horizontal(&self, style: &Self::Style) -> scrollable::Scrollbar { - match style { - Scrollable::Default => self.active(style), - Scrollable::Custom(custom) => custom.active_horizontal(self), - } - } - - fn hovered_horizontal( - &self, - style: &Self::Style, - is_mouse_over_scrollbar: bool, - ) -> scrollable::Scrollbar { - match style { - Scrollable::Default => self.hovered(style, is_mouse_over_scrollbar), - Scrollable::Custom(custom) => { - custom.hovered_horizontal(self, is_mouse_over_scrollbar) - } - } - } - - fn dragging_horizontal( - &self, - style: &Self::Style, - ) -> scrollable::Scrollbar { - match style { - Scrollable::Default => self.hovered_horizontal(style, true), - Scrollable::Custom(custom) => custom.dragging_horizontal(self), - } - } } /// The style of text. |