Add methods for normalized parameter stepping
This is mostly useful for GUIs.
This commit is contained in:
parent
95370667d7
commit
a6e35cfaa9
12
src/param.rs
12
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`]).
|
||||
///
|
||||
|
|
|
@ -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<usize>);
|
||||
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));
|
||||
|
|
Loading…
Reference in a new issue