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

source

pub const root: Wrapper<root> = _

source§

impl ParamWidgetBase

source

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 ParamEvents which are automatically handled by the VIZIA wrapper.

source

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.

source

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()].

source

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.

source

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.

source

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.

source

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.

source

pub fn name(&self) -> &str

Calls the corresponding method on the underlying ParamPtr object.

source

pub fn unit(&self) -> &'static str

Calls the corresponding method on the underlying ParamPtr object.

source

pub fn poly_modulation_id(&self) -> Option<u32>

Calls the corresponding method on the underlying ParamPtr object.

source

pub fn modulated_plain_value(&self) -> f32

Calls the corresponding method on the underlying ParamPtr object.

source

pub fn unmodulated_plain_value(&self) -> f32

Calls the corresponding method on the underlying ParamPtr object.

source

pub fn modulated_normalized_value(&self) -> f32

Calls the corresponding method on the underlying ParamPtr object.

source

pub fn unmodulated_normalized_value(&self) -> f32

Calls the corresponding method on the underlying ParamPtr object.

source

pub fn default_plain_value(&self) -> f32

Calls the corresponding method on the underlying ParamPtr object.

source

pub fn default_normalized_value(&self) -> f32

Calls the corresponding method on the underlying ParamPtr object.

source

pub fn step_count(&self) -> Option<usize>

Calls the corresponding method on the underlying ParamPtr object.

source

pub fn previous_normalized_step(&self, from: f32, finer: bool) -> f32

Calls the corresponding method on the underlying ParamPtr object.

source

pub fn next_normalized_step(&self, from: f32, finer: bool) -> f32

Calls the corresponding method on the underlying ParamPtr object.

source

pub fn normalized_value_to_string( &self, normalized: f32, include_unit: bool ) -> String

Calls the corresponding method on the underlying ParamPtr object.

source

pub fn string_to_normalized_value(&self, string: &str) -> Option<f32>

Calls the corresponding method on the underlying ParamPtr object.

source

pub fn preview_normalized(&self, plain: f32) -> f32

Calls the corresponding method on the underlying ParamPtr object.

source

pub fn preview_plain(&self, normalized: f32) -> f32

Calls the corresponding method on the underlying ParamPtr object.

source

pub fn flags(&self) -> ParamFlags

Calls the corresponding method on the underlying ParamPtr object.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<S> FromSample<S> for S

§

fn from_sample_(s: S) -> S

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T, U> ToSample<U> for Twhere U: FromSample<T>,

§

fn to_sample_(self) -> U

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Any for Twhere T: Any,

§

impl<S, T> Duplex<S> for Twhere T: FromSample<S> + ToSample<S>,