From 34e7c6593a9e0f56cee5db18b7258717cf6bc11b Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 6 Mar 2024 20:30:58 +0100 Subject: Use `Style` struct pattern instead of trait for all widgets --- widget/src/vertical_slider.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'widget/src/vertical_slider.rs') diff --git a/widget/src/vertical_slider.rs b/widget/src/vertical_slider.rs index b51aa2bf..47c400c7 100644 --- a/widget/src/vertical_slider.rs +++ b/widget/src/vertical_slider.rs @@ -54,7 +54,7 @@ pub struct VerticalSlider<'a, T, Message, Theme = crate::Theme> { on_release: Option, width: f32, height: Length, - style: fn(&Theme, Status) -> Appearance, + style: Style, } impl<'a, T, Message, Theme> VerticalSlider<'a, T, Message, Theme> @@ -75,7 +75,7 @@ where /// `Message`. pub fn new(range: RangeInclusive, value: T, on_change: F) -> Self where - Theme: Style, + Style: Default, F: 'a + Fn(T) -> Message, { let value = if value >= *range.start() { @@ -100,7 +100,7 @@ where on_release: None, width: Self::DEFAULT_WIDTH, height: Length::Fill, - style: Theme::style(), + style: Style::default(), } } @@ -136,10 +136,7 @@ where } /// Sets the style of the [`VerticalSlider`]. - pub fn style( - mut self, - style: impl Into Appearance>, - ) -> Self { + pub fn style(mut self, style: fn(&Theme, Status) -> Appearance) -> Self { self.style = style.into(); self } @@ -357,7 +354,7 @@ where let bounds = layout.bounds(); let is_mouse_over = cursor.is_over(bounds); - let style = (self.style)( + let style = (self.style.0)( theme, if state.is_dragging { Status::Dragged -- cgit