Struct nih_plug_vizia::widgets::param_base::ParamWidgetBase
source · pub struct ParamWidgetBase { /* private fields */ }
Expand description
A helper for creating parameter widgets. The general idea is that a parameter widget struct can
adds a ParamWidgetBase
field on its struct, and then calls ParamWidgetBase::view()
in its
view build function. The stored ParamWidgetbBase
object can then be used in the widget’s event
handlers to interact with the parameter.
Implementations§
source§impl ParamWidgetBase
impl ParamWidgetBase
sourcepub fn new<L, Params, P, FMap>(
cx: &mut Context,
params: L,
params_to_param: FMap
) -> Selfwhere
L: Lens<Target = Params> + Clone,
Params: 'static,
P: Param,
FMap: Fn(&Params) -> &P + Copy + 'static,
pub fn new<L, Params, P, FMap>( cx: &mut Context, params: L, params_to_param: FMap ) -> Selfwhere L: Lens<Target = Params> + Clone, Params: 'static, P: Param, FMap: Fn(&Params) -> &P + Copy + 'static,
Creates a ParamWidgetBase
for the given parameter. This can be stored on a widget object
and used as part of the widget’s event handling. To accommodate VIZIA’s mapping system,
you’ll need to provide a lens containing your Params
implementation object (check out how
the Data
struct is used in gain_gui_vizia
) and a projection function that maps the
Params
object to the parameter you want to display a widget for. Parameter changes are
handled by emitting ParamEvent
s which are automatically handled by
the VIZIA wrapper.
sourcepub fn view<L, Params, P, FMap, F, R>(
cx: &mut Context,
params: L,
params_to_param: FMap,
content: F
) -> Rwhere
L: Lens<Target = Params> + Clone,
Params: 'static,
P: Param + 'static,
FMap: Fn(&Params) -> &P + Copy + 'static,
F: FnOnce(&mut Context, ParamWidgetData<L, Params, P, FMap>) -> R,
pub fn view<L, Params, P, FMap, F, R>( cx: &mut Context, params: L, params_to_param: FMap, content: F ) -> Rwhere L: Lens<Target = Params> + Clone, Params: 'static, P: Param + 'static, FMap: Fn(&Params) -> &P + Copy + 'static, F: FnOnce(&mut Context, ParamWidgetData<L, Params, P, FMap>) -> R,
Create a view using the a parameter’s data. This is not tied to a particular
ParamWidgetBase
instance, but it allows you to easily create lenses for the parameter’s
values and access static parameter data.
sourcepub fn build_view<L, Params, P, FMap, F, R>(
params: L,
params_to_param: FMap,
content: F
) -> impl FnOnce(&mut Context) -> Rwhere
L: Lens<Target = Params> + Clone,
Params: 'static,
P: Param + 'static,
FMap: Fn(&Params) -> &P + Copy + 'static,
F: FnOnce(&mut Context, ParamWidgetData<L, Params, P, FMap>) -> R,
pub fn build_view<L, Params, P, FMap, F, R>( params: L, params_to_param: FMap, content: F ) -> impl FnOnce(&mut Context) -> Rwhere L: Lens<Target = Params> + Clone, Params: 'static, P: Param + 'static, FMap: Fn(&Params) -> &P + Copy + 'static, F: FnOnce(&mut Context, ParamWidgetData<L, Params, P, FMap>) -> R,
A shorthand for view()
that can be used directly as an argument to
[View::build()
].
sourcepub fn make_lens<L, Params, P, FMap, F, R>(
params: L,
params_to_param: FMap,
f: F
) -> impl Lens<Target = R>where
L: Lens<Target = Params> + Clone,
Params: 'static,
P: Param + 'static,
FMap: Fn(&Params) -> &P + Copy + 'static,
F: Fn(&P) -> R + Clone + 'static,
R: Clone + 'static,
pub fn make_lens<L, Params, P, FMap, F, R>( params: L, params_to_param: FMap, f: F ) -> impl Lens<Target = R>where L: Lens<Target = Params> + Clone, Params: 'static, P: Param + 'static, FMap: Fn(&Params) -> &P + Copy + 'static, F: Fn(&P) -> R + Clone + 'static, R: Clone + 'static,
Convenience function for using ParamWidgetData::make_lens()
. Whenever possible,
view()
should be used instead.
sourcepub fn begin_set_parameter(&self, cx: &mut EventContext<'_>)
pub fn begin_set_parameter(&self, cx: &mut EventContext<'_>)
Start an automation gesture. This must be called before set_normalized_value()
is called. Usually this is done on mouse down.
sourcepub fn set_normalized_value(
&self,
cx: &mut EventContext<'_>,
normalized_value: f32
)
pub fn set_normalized_value( &self, cx: &mut EventContext<'_>, normalized_value: f32 )
Set the normalized value for a parameter if that would change the parameter’s plain value
(to avoid unnecessary duplicate parameter changes). begin_set_parameter()
must be
called before this is called to start an automation gesture, and end_set_parameter()
must
be called at the end of the gesture.
sourcepub fn end_set_parameter(&self, cx: &mut EventContext<'_>)
pub fn end_set_parameter(&self, cx: &mut EventContext<'_>)
End an automation gesture. This must be called at the end of a gesture, after zero or more
set_normalized_value()
calls. Usually this is done on mouse down.
sourcepub fn unit(&self) -> &'static str
pub fn unit(&self) -> &'static str
Calls the corresponding method on the underlying ParamPtr
object.
sourcepub fn poly_modulation_id(&self) -> Option<u32>
pub fn poly_modulation_id(&self) -> Option<u32>
Calls the corresponding method on the underlying ParamPtr
object.
sourcepub fn modulated_plain_value(&self) -> f32
pub fn modulated_plain_value(&self) -> f32
Calls the corresponding method on the underlying ParamPtr
object.
sourcepub fn unmodulated_plain_value(&self) -> f32
pub fn unmodulated_plain_value(&self) -> f32
Calls the corresponding method on the underlying ParamPtr
object.
sourcepub fn modulated_normalized_value(&self) -> f32
pub fn modulated_normalized_value(&self) -> f32
Calls the corresponding method on the underlying ParamPtr
object.
sourcepub fn unmodulated_normalized_value(&self) -> f32
pub fn unmodulated_normalized_value(&self) -> f32
Calls the corresponding method on the underlying ParamPtr
object.
sourcepub fn default_plain_value(&self) -> f32
pub fn default_plain_value(&self) -> f32
Calls the corresponding method on the underlying ParamPtr
object.
sourcepub fn default_normalized_value(&self) -> f32
pub fn default_normalized_value(&self) -> f32
Calls the corresponding method on the underlying ParamPtr
object.
sourcepub fn step_count(&self) -> Option<usize>
pub fn step_count(&self) -> Option<usize>
Calls the corresponding method on the underlying ParamPtr
object.
sourcepub fn previous_normalized_step(&self, from: f32, finer: bool) -> f32
pub fn previous_normalized_step(&self, from: f32, finer: bool) -> f32
Calls the corresponding method on the underlying ParamPtr
object.
sourcepub fn next_normalized_step(&self, from: f32, finer: bool) -> f32
pub fn next_normalized_step(&self, from: f32, finer: bool) -> f32
Calls the corresponding method on the underlying ParamPtr
object.
sourcepub fn normalized_value_to_string(
&self,
normalized: f32,
include_unit: bool
) -> String
pub fn normalized_value_to_string( &self, normalized: f32, include_unit: bool ) -> String
Calls the corresponding method on the underlying ParamPtr
object.
sourcepub fn string_to_normalized_value(&self, string: &str) -> Option<f32>
pub fn string_to_normalized_value(&self, string: &str) -> Option<f32>
Calls the corresponding method on the underlying ParamPtr
object.
sourcepub fn preview_normalized(&self, plain: f32) -> f32
pub fn preview_normalized(&self, plain: f32) -> f32
Calls the corresponding method on the underlying ParamPtr
object.
sourcepub fn preview_plain(&self, normalized: f32) -> f32
pub fn preview_plain(&self, normalized: f32) -> f32
Calls the corresponding method on the underlying ParamPtr
object.
sourcepub fn flags(&self) -> ParamFlags
pub fn flags(&self) -> ParamFlags
Calls the corresponding method on the underlying ParamPtr
object.