diff options
author | 2023-03-27 16:17:02 +0200 | |
---|---|---|
committer | 2023-03-27 16:17:02 +0200 | |
commit | 4e409bb383be103a6ecd66d1e52a0a8d41fd7ddb (patch) | |
tree | 4f250f235d71d661fec52acd448c1953d7fab66c /style/src/theme.rs | |
parent | b74ff9f1caa0ddf4a45d7560b38c04efaa448154 (diff) | |
parent | dcccf7064d506abb3aab15227e6cdf34d852514d (diff) | |
download | iced-4e409bb383be103a6ecd66d1e52a0a8d41fd7ddb.tar.gz iced-4e409bb383be103a6ecd66d1e52a0a8d41fd7ddb.tar.bz2 iced-4e409bb383be103a6ecd66d1e52a0a8d41fd7ddb.zip |
Merge pull request #1669 from GyulyVGC/master
Added scrollable style `focused` to be displayed when mouse is over the scrollable area
Diffstat (limited to 'style/src/theme.rs')
-rw-r--r-- | style/src/theme.rs | 48 |
1 files changed, 32 insertions, 16 deletions
diff --git a/style/src/theme.rs b/style/src/theme.rs index 4ba4facf..0ebd82a4 100644 --- a/style/src/theme.rs +++ b/style/src/theme.rs @@ -906,31 +906,41 @@ impl scrollable::StyleSheet for Theme { } } - fn hovered(&self, style: &Self::Style) -> scrollable::Scrollbar { + fn hovered( + &self, + style: &Self::Style, + is_mouse_over_scrollbar: bool, + ) -> scrollable::Scrollbar { match style { Scrollable::Default => { - let palette = self.extended_palette(); + if is_mouse_over_scrollbar { + let palette = self.extended_palette(); - scrollable::Scrollbar { - background: palette.background.weak.color.into(), - border_radius: 2.0, - border_width: 0.0, - border_color: Color::TRANSPARENT, - scroller: scrollable::Scroller { - color: palette.primary.strong.color, + scrollable::Scrollbar { + background: palette.background.weak.color.into(), border_radius: 2.0, border_width: 0.0, border_color: Color::TRANSPARENT, - }, + scroller: scrollable::Scroller { + color: palette.primary.strong.color, + border_radius: 2.0, + border_width: 0.0, + border_color: Color::TRANSPARENT, + }, + } + } else { + self.active(style) } } - Scrollable::Custom(custom) => custom.hovered(self), + Scrollable::Custom(custom) => { + custom.hovered(self, is_mouse_over_scrollbar) + } } } fn dragging(&self, style: &Self::Style) -> scrollable::Scrollbar { match style { - Scrollable::Default => self.hovered(style), + Scrollable::Default => self.hovered(style, true), Scrollable::Custom(custom) => custom.dragging(self), } } @@ -942,10 +952,16 @@ impl scrollable::StyleSheet for Theme { } } - fn hovered_horizontal(&self, style: &Self::Style) -> scrollable::Scrollbar { + fn hovered_horizontal( + &self, + style: &Self::Style, + is_mouse_over_scrollbar: bool, + ) -> scrollable::Scrollbar { match style { - Scrollable::Default => self.hovered(style), - Scrollable::Custom(custom) => custom.hovered_horizontal(self), + Scrollable::Default => self.hovered(style, is_mouse_over_scrollbar), + Scrollable::Custom(custom) => { + custom.hovered_horizontal(self, is_mouse_over_scrollbar) + } } } @@ -954,7 +970,7 @@ impl scrollable::StyleSheet for Theme { style: &Self::Style, ) -> scrollable::Scrollbar { match style { - Scrollable::Default => self.hovered_horizontal(style), + Scrollable::Default => self.hovered_horizontal(style, true), Scrollable::Custom(custom) => custom.dragging_horizontal(self), } } |