From cd03a0dd24e300a8a39006e99ee647045e370591 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 31 Jan 2024 21:53:29 +0100 Subject: Rename `step_fine` in `slider` to `shift_step` --- widget/src/slider.rs | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'widget/src/slider.rs') diff --git a/widget/src/slider.rs b/widget/src/slider.rs index ef451d43..a372f8e7 100644 --- a/widget/src/slider.rs +++ b/widget/src/slider.rs @@ -51,7 +51,7 @@ where { range: RangeInclusive, step: T, - step_fine: Option, + shift_step: Option, value: T, default: Option, on_change: Box Message + 'a>, @@ -63,7 +63,7 @@ where impl<'a, T, Message, Theme> Slider<'a, T, Message, Theme> where - T: Copy + From + std::cmp::PartialOrd, + T: Copy + From + PartialOrd, Message: Clone, Theme: StyleSheet, { @@ -99,7 +99,7 @@ where default: None, range, step: T::from(1), - step_fine: None, + shift_step: None, on_change: Box::new(on_change), on_release: None, width: Length::Fill, @@ -150,10 +150,11 @@ where self } - /// Sets the optional fine-grained step size for the [`Slider`]. - /// If set, this value is used as the step size while shift is pressed. - pub fn step_fine(mut self, step_fine: impl Into) -> Self { - self.step_fine = Some(step_fine.into()); + /// Sets the optional "shift" step for the [`Slider`]. + /// + /// If set, this value is used as the step while the shift key is pressed. + pub fn shift_step(mut self, shift_step: impl Into) -> Self { + self.shift_step = Some(shift_step.into()); self } } @@ -211,7 +212,7 @@ where self.default, &self.range, self.step, - self.step_fine, + self.shift_step, self.on_change.as_ref(), &self.on_release, ) @@ -278,7 +279,7 @@ pub fn update( default: Option, range: &RangeInclusive, step: T, - step_fine: Option, + shift_step: Option, on_change: &dyn Fn(T) -> Message, on_release: &Option, ) -> event::Status @@ -297,7 +298,7 @@ where Some(*range.end()) } else { let step = if state.keyboard_modifiers.shift() { - step_fine.unwrap_or(step) + shift_step.unwrap_or(step) } else { step } @@ -320,7 +321,7 @@ where let increment = |value: T| -> Option { let step = if state.keyboard_modifiers.shift() { - step_fine.unwrap_or(step) + shift_step.unwrap_or(step) } else { step } @@ -338,7 +339,7 @@ where let decrement = |value: T| -> Option { let step = if state.keyboard_modifiers.shift() { - step_fine.unwrap_or(step) + shift_step.unwrap_or(step) } else { step } -- cgit