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:
parent
40b555bfbd
commit
54d2a4cd2c
3 changed files with 23 additions and 23 deletions
|
@ -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<Arc<dyn Fn(bool) + Send + Sync>>,
|
||||
value_changed: Option<Arc<dyn Fn(bool) + Send + Sync>>,
|
||||
|
||||
/// 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<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
|
||||
/// 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<Arc<dyn Fn(&str) -> Option<bool> + Send + Sync>>,
|
||||
string_to_value: Option<Arc<dyn Fn(&str) -> Option<bool> + Send + Sync>>,
|
||||
}
|
||||
|
||||
#[allow(clippy::derivable_impls)]
|
||||
|
|
|
@ -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<f32>,
|
||||
|
||||
/// 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<Arc<dyn Fn(f32) + Send + Sync>>,
|
||||
value_changed: Option<Arc<dyn Fn(f32) + Send + Sync>>,
|
||||
|
||||
/// 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<f32>,
|
||||
step_size: Option<f32>,
|
||||
/// 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<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
|
||||
/// 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<Arc<dyn Fn(&str) -> Option<f32> + Send + Sync>>,
|
||||
string_to_value: Option<Arc<dyn Fn(&str) -> Option<f32> + Send + Sync>>,
|
||||
}
|
||||
|
||||
impl Default for FloatParam {
|
||||
|
|
|
@ -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<i32>,
|
||||
|
||||
/// 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<Arc<dyn Fn(i32) + Send + Sync>>,
|
||||
pub(crate) value_changed: Option<Arc<dyn Fn(i32) + Send + Sync>>,
|
||||
|
||||
/// 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<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
|
||||
/// 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<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 {
|
||||
|
|
Loading…
Add table
Reference in a new issue