summaryrefslogtreecommitdiffstats
path: root/widget/src/vertical_slider.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-03-12 14:47:36 +0100
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-03-12 14:52:29 +0100
commitafd138dba697976f61e335555b69417c4c84f7f2 (patch)
treeec2c5713fd5beca8abe4f1a9f96e643ca0d7ac4d /widget/src/vertical_slider.rs
parent58a0d5b7fff3000c46f5f2c468fce9442c78ef20 (diff)
downloadiced-afd138dba697976f61e335555b69417c4c84f7f2.tar.gz
iced-afd138dba697976f61e335555b69417c4c84f7f2.tar.bz2
iced-afd138dba697976f61e335555b69417c4c84f7f2.zip
Use closures for `Slider::style` and `VerticalSlider::style`
Diffstat (limited to '')
-rw-r--r--widget/src/vertical_slider.rs13
1 files changed, 8 insertions, 5 deletions
diff --git a/widget/src/vertical_slider.rs b/widget/src/vertical_slider.rs
index f7030584..2aa8f4d1 100644
--- a/widget/src/vertical_slider.rs
+++ b/widget/src/vertical_slider.rs
@@ -51,7 +51,7 @@ pub struct VerticalSlider<'a, T, Message, Theme = crate::Theme> {
on_release: Option<Message>,
width: f32,
height: Length,
- style: Style<Theme>,
+ style: Style<'a, Theme>,
}
impl<'a, T, Message, Theme> VerticalSlider<'a, T, Message, Theme>
@@ -72,7 +72,7 @@ where
/// `Message`.
pub fn new<F>(range: RangeInclusive<T>, value: T, on_change: F) -> Self
where
- Theme: DefaultStyle,
+ Theme: DefaultStyle + 'a,
F: 'a + Fn(T) -> Message,
{
let value = if value >= *range.start() {
@@ -97,7 +97,7 @@ where
on_release: None,
width: Self::DEFAULT_WIDTH,
height: Length::Fill,
- style: Theme::default_style(),
+ style: Box::new(Theme::default_style),
}
}
@@ -133,8 +133,11 @@ where
}
/// Sets the style of the [`VerticalSlider`].
- pub fn style(mut self, style: fn(&Theme, Status) -> Appearance) -> Self {
- self.style = style.into();
+ pub fn style(
+ mut self,
+ style: impl Fn(&Theme, Status) -> Appearance + 'a,
+ ) -> Self {
+ self.style = Box::new(style);
self
}