summaryrefslogtreecommitdiffstats
path: root/style/src/scrollable.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector0193@gmail.com>2022-07-09 02:28:52 +0200
committerLibravatar GitHub <noreply@github.com>2022-07-09 02:28:52 +0200
commite053e25d2ccb17f7a162685a106a8bbd915a873f (patch)
tree5304f3ea2712e8889c7278ec5e57418f484d8f6c /style/src/scrollable.rs
parent66eb6263003c1bbedd1fd14d6b12f172d20a6211 (diff)
parent7105db97a53d90adf429091298f31c90974d8f08 (diff)
downloadiced-e053e25d2ccb17f7a162685a106a8bbd915a873f.tar.gz
iced-e053e25d2ccb17f7a162685a106a8bbd915a873f.tar.bz2
iced-e053e25d2ccb17f7a162685a106a8bbd915a873f.zip
Merge pull request #1362 from iced-rs/theming
Theming
Diffstat (limited to 'style/src/scrollable.rs')
-rw-r--r--style/src/scrollable.rs51
1 files changed, 6 insertions, 45 deletions
diff --git a/style/src/scrollable.rs b/style/src/scrollable.rs
index 748ba888..8da7409c 100644
--- a/style/src/scrollable.rs
+++ b/style/src/scrollable.rs
@@ -22,55 +22,16 @@ pub struct Scroller {
/// A set of rules that dictate the style of a scrollable.
pub trait StyleSheet {
+ type Style: Default + Copy;
+
/// Produces the style of an active scrollbar.
- fn active(&self) -> Scrollbar;
+ fn active(&self, style: Self::Style) -> Scrollbar;
/// Produces the style of an hovered scrollbar.
- fn hovered(&self) -> Scrollbar;
+ fn hovered(&self, style: Self::Style) -> Scrollbar;
/// Produces the style of a scrollbar that is being dragged.
- fn dragging(&self) -> Scrollbar {
- self.hovered()
- }
-}
-
-struct Default;
-
-impl StyleSheet for Default {
- fn active(&self) -> Scrollbar {
- Scrollbar {
- background: None,
- border_radius: 5.0,
- border_width: 0.0,
- border_color: Color::TRANSPARENT,
- scroller: Scroller {
- color: [0.0, 0.0, 0.0, 0.7].into(),
- border_radius: 5.0,
- border_width: 0.0,
- border_color: Color::TRANSPARENT,
- },
- }
- }
-
- fn hovered(&self) -> Scrollbar {
- Scrollbar {
- background: Some(Background::Color([0.0, 0.0, 0.0, 0.3].into())),
- ..self.active()
- }
- }
-}
-
-impl<'a> std::default::Default for Box<dyn StyleSheet + 'a> {
- fn default() -> Self {
- Box::new(Default)
- }
-}
-
-impl<'a, T> From<T> for Box<dyn StyleSheet + 'a>
-where
- T: StyleSheet + 'a,
-{
- fn from(style_sheet: T) -> Self {
- Box::new(style_sheet)
+ fn dragging(&self, style: Self::Style) -> Scrollbar {
+ self.hovered(style)
}
}