1
0
Fork 0

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.
This commit is contained in:
Robbert van der Helm 2022-05-01 17:08:08 +02:00
parent 40b555bfbd
commit 54d2a4cd2c
3 changed files with 23 additions and 23 deletions

View file

@ -12,24 +12,24 @@ pub struct BoolParam {
/// The field's current value. Should be initialized with the default value. /// The field's current value. Should be initialized with the default value.
pub value: bool, pub value: bool,
/// The field's default value. /// The field's default value.
pub default: bool, default: bool,
/// Flags to control the parameter's behavior. See [`ParamFlags`]. /// 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 /// 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 /// 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 /// multiple times in rapid succession, and it can be run from both the GUI and the audio
/// thread. /// thread.
pub value_changed: Option<Arc<dyn Fn(bool) + Send + Sync>>, value_changed: Option<Arc<dyn Fn(bool) + Send + Sync>>,
/// The parameter's human readable display name. /// The parameter's human readable display name.
pub name: String, name: String,
/// Optional custom conversion function from a boolean value to a string. /// Optional custom conversion function from a boolean value to a string.
pub value_to_string: Option<Arc<dyn Fn(bool) -> String + Send + Sync>>, value_to_string: Option<Arc<dyn Fn(bool) -> String + Send + Sync>>,
/// Optional custom conversion function from a string to a boolean value. If the string cannot /// 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 /// be parsed, then this should return a `None`. If this happens while the parameter is being
/// updated then the update will be canceled. /// updated then the update will be canceled.
pub string_to_value: Option<Arc<dyn Fn(&str) -> Option<bool> + Send + Sync>>, string_to_value: Option<Arc<dyn Fn(&str) -> Option<bool> + Send + Sync>>,
} }
#[allow(clippy::derivable_impls)] #[allow(clippy::derivable_impls)]

View file

@ -26,13 +26,13 @@ pub struct FloatParam {
/// locality, but it does allow for a much nicer declarative API. /// locality, but it does allow for a much nicer declarative API.
pub value: f32, pub value: f32,
/// The field's default plain, unnormalized value. /// The field's default plain, unnormalized value.
pub default: f32, default: f32,
/// An optional smoother that will automatically interpolate between the new automation values /// An optional smoother that will automatically interpolate between the new automation values
/// set by the host. /// set by the host.
pub smoothed: Smoother<f32>, pub smoothed: Smoother<f32>,
/// Flags to control the parameter's behavior. See [`ParamFlags`]. /// 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 /// 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 /// the parameter's new **plain** value. This should not do anything expensive as it may be
/// called multiple times in rapid succession. /// 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. /// 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. /// TODO: We probably also want to pass the old value to this function.
pub value_changed: Option<Arc<dyn Fn(f32) + Send + Sync>>, value_changed: Option<Arc<dyn Fn(f32) + Send + Sync>>,
/// The distribution of the parameter's values. /// 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 /// 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 /// 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. /// this is also used when formatting the parameter. This must be a positive, nonzero number.
pub step_size: Option<f32>, step_size: Option<f32>,
/// The parameter's human readable display name. /// 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 /// 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. /// 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. /// Optional custom conversion function from a plain **unnormalized** value to a string.
pub value_to_string: Option<Arc<dyn Fn(f32) -> String + Send + Sync>>, value_to_string: Option<Arc<dyn Fn(f32) -> String + Send + Sync>>,
/// Optional custom conversion function from a string to a plain **unnormalized** value. If the /// 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 /// 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. /// 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 /// The input string may or may not contain the unit, so you will need to be able to handle
/// that. /// that.
pub string_to_value: Option<Arc<dyn Fn(&str) -> Option<f32> + Send + Sync>>, string_to_value: Option<Arc<dyn Fn(&str) -> Option<f32> + Send + Sync>>,
} }
impl Default for FloatParam { impl Default for FloatParam {

View file

@ -26,13 +26,13 @@ pub struct IntParam {
/// locality, but it does allow for a much nicer declarative API. /// locality, but it does allow for a much nicer declarative API.
pub value: i32, pub value: i32,
/// The field's default plain, unnormalized value. /// 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 /// An optional smoother that will automatically interpolate between the new automation values
/// set by the host. /// set by the host.
pub smoothed: Smoother<i32>, pub smoothed: Smoother<i32>,
/// Flags to control the parameter's behavior. See [`ParamFlags`]. /// 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 /// 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 /// the parameter's new **plain** value. This should not do anything expensive as it may be
/// called multiple times in rapid succession. /// 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. /// 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. /// TODO: We probably also want to pass the old value to this function.
pub value_changed: Option<Arc<dyn Fn(i32) + Send + Sync>>, pub(crate) value_changed: Option<Arc<dyn Fn(i32) + Send + Sync>>,
/// The distribution of the parameter's values. /// The distribution of the parameter's values.
pub range: IntRange, pub(crate) range: IntRange,
/// The parameter's human readable display name. /// 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 /// 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. /// 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. /// Optional custom conversion function from a plain **unnormalized** value to a string.
pub value_to_string: Option<Arc<dyn Fn(i32) -> String + Send + Sync>>, pub(crate) value_to_string: Option<Arc<dyn Fn(i32) -> String + Send + Sync>>,
/// Optional custom conversion function from a string to a plain **unnormalized** value. If the /// 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 /// 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. /// 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 /// The input string may or may not contain the unit, so you will need to be able to handle
/// that. /// that.
pub string_to_value: Option<Arc<dyn Fn(&str) -> Option<i32> + Send + Sync>>, pub(crate) string_to_value: Option<Arc<dyn Fn(&str) -> Option<i32> + Send + Sync>>,
} }
impl Default for IntParam { impl Default for IntParam {