Automatically implement Param::set_normalized_value()
This commit is contained in:
parent
021d175264
commit
40d99a5cb3
|
@ -84,7 +84,9 @@ pub trait Param: Display {
|
|||
/// continuous parameters (i.e. [`FloatParam`]).
|
||||
///
|
||||
/// This does **not** update the smoother.
|
||||
fn set_normalized_value(&mut self, normalized: f32);
|
||||
fn set_normalized_value(&mut self, normalized: f32) {
|
||||
self.set_plain_value(self.preview_plain(normalized))
|
||||
}
|
||||
|
||||
/// Get the string representation for a normalized value. Used as part of the wrappers. Most
|
||||
/// plugin formats already have support for units, in which case it shouldn't be part of this
|
||||
|
|
|
@ -92,10 +92,6 @@ impl Param for BoolParam {
|
|||
}
|
||||
}
|
||||
|
||||
fn set_normalized_value(&mut self, normalized: f32) {
|
||||
self.set_plain_value(self.preview_plain(normalized));
|
||||
}
|
||||
|
||||
fn normalized_value_to_string(&self, normalized: f32, _include_unit: bool) -> String {
|
||||
let value = self.preview_plain(normalized);
|
||||
match (value, &self.value_to_string) {
|
||||
|
|
|
@ -134,10 +134,6 @@ impl<T: Enum + PartialEq> Param for EnumParam<T> {
|
|||
self.inner.set_plain_value(T::to_index(plain) as i32)
|
||||
}
|
||||
|
||||
fn set_normalized_value(&mut self, normalized: f32) {
|
||||
self.inner.set_normalized_value(normalized)
|
||||
}
|
||||
|
||||
fn normalized_value_to_string(&self, normalized: f32, include_unit: bool) -> String {
|
||||
self.inner
|
||||
.normalized_value_to_string(normalized, include_unit)
|
||||
|
@ -203,10 +199,6 @@ impl Param for EnumParamInner {
|
|||
self.inner.set_plain_value(plain)
|
||||
}
|
||||
|
||||
fn set_normalized_value(&mut self, normalized: f32) {
|
||||
self.inner.set_normalized_value(normalized)
|
||||
}
|
||||
|
||||
fn normalized_value_to_string(&self, normalized: f32, _include_unit: bool) -> String {
|
||||
let index = self.preview_plain(normalized);
|
||||
self.variants[index as usize].to_string()
|
||||
|
|
|
@ -149,10 +149,6 @@ impl Param for FloatParam {
|
|||
}
|
||||
}
|
||||
|
||||
fn set_normalized_value(&mut self, normalized: f32) {
|
||||
self.set_plain_value(self.preview_plain(normalized));
|
||||
}
|
||||
|
||||
fn normalized_value_to_string(&self, normalized: f32, include_unit: bool) -> String {
|
||||
let value = self.preview_plain(normalized);
|
||||
match (&self.value_to_string, &self.step_size, include_unit) {
|
||||
|
|
|
@ -125,10 +125,6 @@ impl Param for IntParam {
|
|||
}
|
||||
}
|
||||
|
||||
fn set_normalized_value(&mut self, normalized: f32) {
|
||||
self.set_plain_value(self.preview_plain(normalized));
|
||||
}
|
||||
|
||||
fn normalized_value_to_string(&self, normalized: f32, include_unit: bool) -> String {
|
||||
let value = self.preview_plain(normalized);
|
||||
match (&self.value_to_string, include_unit) {
|
||||
|
|
Loading…
Reference in a new issue