diff --git a/nih_plug_egui/src/widgets/param_slider.rs b/nih_plug_egui/src/widgets/param_slider.rs index 57ac4ec1..f56eaa75 100644 --- a/nih_plug_egui/src/widgets/param_slider.rs +++ b/nih_plug_egui/src/widgets/param_slider.rs @@ -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. diff --git a/src/param.rs b/src/param.rs index de32cf9f..5a28b98d 100644 --- a/src/param.rs +++ b/src/param.rs @@ -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; diff --git a/src/param/boolean.rs b/src/param/boolean.rs index 9e627323..9de70f88 100644 --- a/src/param/boolean.rs +++ b/src/param/boolean.rs @@ -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 } diff --git a/src/param/enums.rs b/src/param/enums.rs index 8d083e62..0696bec3 100644 --- a/src/param/enums.rs +++ b/src/param/enums.rs @@ -114,10 +114,6 @@ impl Param for EnumParam { 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() } diff --git a/src/param/float.rs b/src/param/float.rs index 708ca82d..54eb810f 100644 --- a/src/param/float.rs +++ b/src/param/float.rs @@ -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 } diff --git a/src/param/integer.rs b/src/param/integer.rs index b37c71c0..f3b3dd3d 100644 --- a/src/param/integer.rs +++ b/src/param/integer.rs @@ -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 }