1
0
Fork 0

Automatically implement Param::set_normalized_value()

This commit is contained in:
Robbert van der Helm 2022-03-21 13:17:28 +01:00
parent 021d175264
commit 40d99a5cb3
5 changed files with 3 additions and 21 deletions

View file

@ -84,7 +84,9 @@ pub trait Param: Display {
/// continuous parameters (i.e. [`FloatParam`]). /// continuous parameters (i.e. [`FloatParam`]).
/// ///
/// This does **not** update the smoother. /// 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 /// 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 /// plugin formats already have support for units, in which case it shouldn't be part of this

View file

@ -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 { fn normalized_value_to_string(&self, normalized: f32, _include_unit: bool) -> String {
let value = self.preview_plain(normalized); let value = self.preview_plain(normalized);
match (value, &self.value_to_string) { match (value, &self.value_to_string) {

View file

@ -134,10 +134,6 @@ impl<T: Enum + PartialEq> Param for EnumParam<T> {
self.inner.set_plain_value(T::to_index(plain) as i32) 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 { fn normalized_value_to_string(&self, normalized: f32, include_unit: bool) -> String {
self.inner self.inner
.normalized_value_to_string(normalized, include_unit) .normalized_value_to_string(normalized, include_unit)
@ -203,10 +199,6 @@ impl Param for EnumParamInner {
self.inner.set_plain_value(plain) 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 { fn normalized_value_to_string(&self, normalized: f32, _include_unit: bool) -> String {
let index = self.preview_plain(normalized); let index = self.preview_plain(normalized);
self.variants[index as usize].to_string() self.variants[index as usize].to_string()

View file

@ -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 { fn normalized_value_to_string(&self, normalized: f32, include_unit: bool) -> String {
let value = self.preview_plain(normalized); let value = self.preview_plain(normalized);
match (&self.value_to_string, &self.step_size, include_unit) { match (&self.value_to_string, &self.step_size, include_unit) {

View file

@ -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 { fn normalized_value_to_string(&self, normalized: f32, include_unit: bool) -> String {
let value = self.preview_plain(normalized); let value = self.preview_plain(normalized);
match (&self.value_to_string, include_unit) { match (&self.value_to_string, include_unit) {