diff options
author | 2023-01-09 19:23:35 +0100 | |
---|---|---|
committer | 2023-01-09 19:23:35 +0100 | |
commit | 7ccd87c36b54e0d53f65f5774f140a0528ae4504 (patch) | |
tree | bf12f165d43c785adfd4ac906b8f4035035c5d42 /style/src/theme.rs | |
parent | 07d755c6a270bd46fe9752ed57b3ceaddda1f081 (diff) | |
parent | 2d007474dd002dfc936f75f7379f1bbae72c5ad4 (diff) | |
download | iced-7ccd87c36b54e0d53f65f5774f140a0528ae4504.tar.gz iced-7ccd87c36b54e0d53f65f5774f140a0528ae4504.tar.bz2 iced-7ccd87c36b54e0d53f65f5774f140a0528ae4504.zip |
Merge pull request #1550 from bungoboingo/feat/multidirectional-scrolling
[Feature] Multidirectional scrolling
Diffstat (limited to 'style/src/theme.rs')
-rw-r--r-- | style/src/theme.rs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/style/src/theme.rs b/style/src/theme.rs index a766b279..55bfa4ca 100644 --- a/style/src/theme.rs +++ b/style/src/theme.rs @@ -872,6 +872,15 @@ pub enum Scrollable { Custom(Box<dyn scrollable::StyleSheet<Style = Theme>>), } +impl Scrollable { + /// Creates a custom [`Scrollable`] theme. + pub fn custom<T: scrollable::StyleSheet<Style = Theme> + 'static>( + style: T, + ) -> Self { + Self::Custom(Box::new(style)) + } +} + impl scrollable::StyleSheet for Theme { type Style = Scrollable; @@ -925,6 +934,30 @@ impl scrollable::StyleSheet for Theme { 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) -> scrollable::Scrollbar { + match style { + Scrollable::Default => self.hovered(style), + Scrollable::Custom(custom) => custom.hovered_horizontal(self), + } + } + + fn dragging_horizontal( + &self, + style: &Self::Style, + ) -> scrollable::Scrollbar { + match style { + Scrollable::Default => self.hovered_horizontal(style), + Scrollable::Custom(custom) => custom.dragging_horizontal(self), + } + } } /// The style of text. |