diff --git a/src/param.rs b/src/param.rs index d0a41743..3be54abd 100644 --- a/src/param.rs +++ b/src/param.rs @@ -52,6 +52,18 @@ pub trait Param: Display { /// hundredth of the normalized range instead. fn next_step(&self, from: Self::Plain) -> Self::Plain; + /// The same as [`previous_step()`][Self::previous_step()], but for normalized values. This is + /// mostly useful for GUI widgets. + fn previous_normaliezd_step(&self, from: f32) -> f32 { + self.preview_normalized(self.previous_step(self.preview_plain(from))) + } + + /// The same as [`next_step()`][Self::next_step()], but for normalized values. This is mostly + /// useful for GUI widgets. + fn next_normaliezd_step(&self, from: f32) -> f32 { + self.preview_normalized(self.next_step(self.preview_plain(from))) + } + /// Set this parameter based on a plain, unnormalized value. This does **not** snap to step /// sizes for continuous parameters (i.e. [`FloatParam`]). /// diff --git a/src/param/internals.rs b/src/param/internals.rs index c084fb9f..ab63f386 100644 --- a/src/param/internals.rs +++ b/src/param/internals.rs @@ -149,6 +149,8 @@ impl ParamPtr { param_ptr_forward!(pub unsafe fn unit(&self) -> &'static str); param_ptr_forward!(pub unsafe fn normalized_value(&self) -> f32); param_ptr_forward!(pub unsafe fn step_count(&self) -> Option); + param_ptr_forward!(pub unsafe fn previous_normaliezd_step(&self, from: f32) -> f32); + param_ptr_forward!(pub unsafe fn next_normaliezd_step(&self, from: f32) -> f32); param_ptr_forward!(pub unsafe fn set_normalized_value(&self, normalized: f32)); param_ptr_forward!(pub unsafe fn update_smoother(&self, sample_rate: f32, reset: bool)); param_ptr_forward!(pub unsafe fn initialize_block_smoother(&mut self, max_block_size: usize));