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/scrollable.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 'style/src/scrollable.rs')
-rw-r--r-- | style/src/scrollable.rs | 51 |
1 files changed, 22 insertions, 29 deletions
diff --git a/style/src/scrollable.rs b/style/src/scrollable.rs index 6f37305f..d2348510 100644 --- a/style/src/scrollable.rs +++ b/style/src/scrollable.rs @@ -1,14 +1,26 @@ //! Change the appearance of a scrollable. +use crate::container; use crate::core::{Background, Border, Color}; -/// The appearance of a scrollable. +/// The appearance of a scrolable. +#[derive(Debug, Clone, Copy)] +pub struct Appearance { + /// The [`container::Appearance`] of a scrollable. + pub container: container::Appearance, + /// The [`Scrollbar`] appearance. + pub scrollbar: Scrollbar, + /// The [`Background`] of the gap between a horizontal and vertical scrollbar. + pub gap: Option<Background>, +} + +/// The appearance of the scrollbar of a scrollable. #[derive(Debug, Clone, Copy)] pub struct Scrollbar { - /// The [`Background`] of a scrollable. + /// The [`Background`] of a scrollbar. pub background: Option<Background>, - /// The [`Border`] of a scrollable. + /// The [`Border`] of a scrollbar. pub border: Border, - /// The appearance of the [`Scroller`] of a scrollable. + /// The appearance of the [`Scroller`] of a scrollbar. pub scroller: Scroller, } @@ -26,37 +38,18 @@ pub trait StyleSheet { /// The supported style of the [`StyleSheet`]. type Style: Default; - /// Produces the style of an active scrollbar. - fn active(&self, style: &Self::Style) -> Scrollbar; + /// Produces the [`Appearance`] of an active scrollable. + fn active(&self, style: &Self::Style) -> Appearance; - /// Produces the style of a scrollbar when the scrollable is being hovered. + /// Produces the [`Appearance`] of a scrollable when it is being hovered. fn hovered( &self, style: &Self::Style, is_mouse_over_scrollbar: bool, - ) -> Scrollbar; + ) -> Appearance; - /// Produces the style of a scrollbar that is being dragged. - fn dragging(&self, style: &Self::Style) -> Scrollbar { + /// Produces the [`Appearance`] of a scrollable when it is being dragged. + fn dragging(&self, style: &Self::Style) -> Appearance { self.hovered(style, true) } - - /// Produces the style of an active horizontal scrollbar. - fn active_horizontal(&self, style: &Self::Style) -> Scrollbar { - self.active(style) - } - - /// Produces the style of a horizontal scrollbar when the scrollable is being hovered. - fn hovered_horizontal( - &self, - style: &Self::Style, - is_mouse_over_scrollbar: bool, - ) -> Scrollbar { - self.hovered(style, is_mouse_over_scrollbar) - } - - /// Produces the style of a horizontal scrollbar that is being dragged. - fn dragging_horizontal(&self, style: &Self::Style) -> Scrollbar { - self.hovered_horizontal(style, true) - } } |