Show off the Default shorthand
This commit is contained in:
parent
54bcf52912
commit
6f67235c15
|
@ -19,7 +19,7 @@ extern crate nih_plug;
|
||||||
|
|
||||||
use nih_plug::{
|
use nih_plug::{
|
||||||
formatters,
|
formatters,
|
||||||
params::{FloatParam, Param, Params, Range},
|
params::{BoolParam, FloatParam, Param, Params, Range},
|
||||||
plugin::{BufferConfig, BusConfig, Plugin, ProcessStatus, Vst3Plugin},
|
plugin::{BufferConfig, BusConfig, Plugin, ProcessStatus, Vst3Plugin},
|
||||||
util,
|
util,
|
||||||
};
|
};
|
||||||
|
@ -35,6 +35,9 @@ struct GainParams {
|
||||||
#[id = "gain"]
|
#[id = "gain"]
|
||||||
pub gain: FloatParam,
|
pub gain: FloatParam,
|
||||||
|
|
||||||
|
#[id = "as_long_as_this_name_stays_constant"]
|
||||||
|
pub the_field_name_can_change: BoolParam,
|
||||||
|
|
||||||
/// This field isn't used in this exampleq, but anything written to the vector would be restored
|
/// This field isn't used in this exampleq, but anything written to the vector would be restored
|
||||||
/// together with a preset/state file saved for this plugin. This can be useful for storign
|
/// together with a preset/state file saved for this plugin. This can be useful for storign
|
||||||
/// things like sample data.
|
/// things like sample data.
|
||||||
|
@ -70,6 +73,13 @@ impl Default for GainParams {
|
||||||
value_to_string: formatters::f32_rounded(2),
|
value_to_string: formatters::f32_rounded(2),
|
||||||
string_to_value: None,
|
string_to_value: None,
|
||||||
},
|
},
|
||||||
|
// For brevity's sake you can also use the default values. Don't forget to set the field
|
||||||
|
// name, default value, and range though.
|
||||||
|
the_field_name_can_change: BoolParam {
|
||||||
|
value: false,
|
||||||
|
name: "Important Value",
|
||||||
|
..BoolParam::default()
|
||||||
|
},
|
||||||
random_data: RwLock::new(Vec::new()),
|
random_data: RwLock::new(Vec::new()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue