mirror of
https://github.com/robbert-vdh/nih-plug.git
synced 2026-07-01 10:46:55 +00:00
Use a default implementation for Param::normalized_value()
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user