From 54d2a4cd2c0e3bbd6e51842b9967f112e8df8996 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Sun, 1 May 2022 17:08:08 +0200 Subject: [PATCH] Hide param fields other than value and smoothed Direct initialization was no longer recommended anyways since now you need to keep the default value in sync. The next couple of commits will add a normalized value field and two more fields to help with modulation. --- src/param/boolean.rs | 12 ++++++------ src/param/float.rs | 18 +++++++++--------- src/param/integer.rs | 16 ++++++++-------- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/param/boolean.rs b/src/param/boolean.rs index 9ab1863e..18ed1c7b 100644 --- a/src/param/boolean.rs +++ b/src/param/boolean.rs @@ -12,24 +12,24 @@ pub struct BoolParam { /// The field's current value. Should be initialized with the default value. pub value: bool, /// The field's default value. - pub default: bool, + default: bool, /// Flags to control the parameter's behavior. See [`ParamFlags`]. - pub flags: ParamFlags, + flags: ParamFlags, /// Optional callback for listening to value changes. The argument passed to this function is /// the parameter's new value. This should not do anything expensive as it may be called /// multiple times in rapid succession, and it can be run from both the GUI and the audio /// thread. - pub value_changed: Option>, + value_changed: Option>, /// The parameter's human readable display name. - pub name: String, + name: String, /// Optional custom conversion function from a boolean value to a string. - pub value_to_string: Option String + Send + Sync>>, + value_to_string: Option String + Send + Sync>>, /// Optional custom conversion function from a string to a boolean value. If the string cannot /// be parsed, then this should return a `None`. If this happens while the parameter is being /// updated then the update will be canceled. - pub string_to_value: Option Option + Send + Sync>>, + string_to_value: Option Option + Send + Sync>>, } #[allow(clippy::derivable_impls)] diff --git a/src/param/float.rs b/src/param/float.rs index 229aa993..bb7e8877 100644 --- a/src/param/float.rs +++ b/src/param/float.rs @@ -26,13 +26,13 @@ pub struct FloatParam { /// locality, but it does allow for a much nicer declarative API. pub value: f32, /// The field's default plain, unnormalized value. - pub default: f32, + default: f32, /// An optional smoother that will automatically interpolate between the new automation values /// set by the host. pub smoothed: Smoother, /// Flags to control the parameter's behavior. See [`ParamFlags`]. - pub flags: ParamFlags, + flags: ParamFlags, /// Optional callback for listening to value changes. The argument passed to this function is /// the parameter's new **plain** value. This should not do anything expensive as it may be /// called multiple times in rapid succession. @@ -41,28 +41,28 @@ pub struct FloatParam { /// parameters struct, move a clone of that `Arc` into this closure, and then modify that. /// /// TODO: We probably also want to pass the old value to this function. - pub value_changed: Option>, + value_changed: Option>, /// The distribution of the parameter's values. - pub range: FloatRange, + range: FloatRange, /// The distance between discrete steps in this parameter. Mostly useful for quantizing GUI /// input. If this is set and if [`value_to_string`][Self::value_to_string] is not set, then /// this is also used when formatting the parameter. This must be a positive, nonzero number. - pub step_size: Option, + step_size: Option, /// The parameter's human readable display name. - pub name: String, + name: String, /// The parameter value's unit, added after [`value_to_string`][Self::value_to_string] if that /// is set. NIH-plug will not automatically add a space before the unit. - pub unit: &'static str, + unit: &'static str, /// Optional custom conversion function from a plain **unnormalized** value to a string. - pub value_to_string: Option String + Send + Sync>>, + value_to_string: Option String + Send + Sync>>, /// Optional custom conversion function from a string to a plain **unnormalized** value. If the /// string cannot be parsed, then this should return a `None`. If this happens while the /// parameter is being updated then the update will be canceled. /// /// The input string may or may not contain the unit, so you will need to be able to handle /// that. - pub string_to_value: Option Option + Send + Sync>>, + string_to_value: Option Option + Send + Sync>>, } impl Default for FloatParam { diff --git a/src/param/integer.rs b/src/param/integer.rs index 0d1e3a19..aa8d2147 100644 --- a/src/param/integer.rs +++ b/src/param/integer.rs @@ -26,13 +26,13 @@ pub struct IntParam { /// locality, but it does allow for a much nicer declarative API. pub value: i32, /// The field's default plain, unnormalized value. - pub default: i32, + pub(crate) default: i32, /// An optional smoother that will automatically interpolate between the new automation values /// set by the host. pub smoothed: Smoother, /// Flags to control the parameter's behavior. See [`ParamFlags`]. - pub flags: ParamFlags, + pub(crate) flags: ParamFlags, /// Optional callback for listening to value changes. The argument passed to this function is /// the parameter's new **plain** value. This should not do anything expensive as it may be /// called multiple times in rapid succession. @@ -41,24 +41,24 @@ pub struct IntParam { /// parameters struct, move a clone of that `Arc` into this closure, and then modify that. /// /// TODO: We probably also want to pass the old value to this function. - pub value_changed: Option>, + pub(crate) value_changed: Option>, /// The distribution of the parameter's values. - pub range: IntRange, + pub(crate) range: IntRange, /// The parameter's human readable display name. - pub name: String, + pub(crate) name: String, /// The parameter value's unit, added after `value_to_string` if that is set. NIH-plug will not /// automatically add a space before the unit. - pub unit: &'static str, + pub(crate) unit: &'static str, /// Optional custom conversion function from a plain **unnormalized** value to a string. - pub value_to_string: Option String + Send + Sync>>, + pub(crate) value_to_string: Option String + Send + Sync>>, /// Optional custom conversion function from a string to a plain **unnormalized** value. If the /// string cannot be parsed, then this should return a `None`. If this happens while the /// parameter is being updated then the update will be canceled. /// /// The input string may or may not contain the unit, so you will need to be able to handle /// that. - pub string_to_value: Option Option + Send + Sync>>, + pub(crate) string_to_value: Option Option + Send + Sync>>, } impl Default for IntParam {