1
0
Fork 0

Use a default implementation for Param::normalized_value()

This commit is contained in:
Robbert van der Helm 2022-03-21 13:15:17 +01:00
parent f084f14095
commit 021d175264
6 changed files with 5 additions and 24 deletions

View file

@ -2,10 +2,10 @@ use std::sync::Arc;
use egui::{vec2, Key, Response, Sense, Stroke, TextEdit, TextStyle, Ui, Vec2, Widget, WidgetText};
use lazy_static::lazy_static;
use nih_plug::prelude::{Param, ParamSetter};
use parking_lot::Mutex;
use super::util;
use nih_plug::prelude::{Param, ParamSetter};
/// When shift+dragging a parameter, one pixel dragged corresponds to this much change in the
/// noramlized parameter.
@ -74,7 +74,7 @@ impl<'a, P: Param> ParamSlider<'a, P> {
}
fn string_value(&self) -> String {
format!("{}", self.param)
self.param.to_string()
}
/// Enable the keyboard entry part of the widget.

View file

@ -34,8 +34,9 @@ pub trait Param: Display {
fn plain_value(&self) -> Self::Plain;
/// Get the normalized `[0, 1]` value for this parameter.
/// TODO: Add a default implementation for this one as well
fn normalized_value(&self) -> f32;
fn normalized_value(&self) -> f32 {
self.preview_normalized(self.plain_value())
}
/// Get the unnormalized default value for this parameter.
fn default_plain_value(&self) -> Self::Plain;

View file

@ -69,10 +69,6 @@ impl Param for BoolParam {
self.value
}
fn normalized_value(&self) -> f32 {
self.preview_normalized(self.value)
}
fn default_plain_value(&self) -> Self::Plain {
self.default
}

View file

@ -114,10 +114,6 @@ impl<T: Enum + PartialEq> Param for EnumParam<T> {
T::from_index(self.inner.plain_value() as usize)
}
fn normalized_value(&self) -> f32 {
self.inner.normalized_value()
}
fn default_plain_value(&self) -> Self::Plain {
T::from_index(self.inner.default_plain_value() as usize)
}
@ -187,10 +183,6 @@ impl Param for EnumParamInner {
self.inner.plain_value()
}
fn normalized_value(&self) -> f32 {
self.inner.normalized_value()
}
fn default_plain_value(&self) -> Self::Plain {
self.inner.default_plain_value()
}

View file

@ -111,10 +111,6 @@ impl Param for FloatParam {
self.value
}
fn normalized_value(&self) -> f32 {
self.preview_normalized(self.value)
}
fn default_plain_value(&self) -> Self::Plain {
self.default
}

View file

@ -102,10 +102,6 @@ impl Param for IntParam {
self.value
}
fn normalized_value(&self) -> f32 {
self.preview_normalized(self.value)
}
fn default_plain_value(&self) -> Self::Plain {
self.default
}