Skip to main content

ParamSetter

Struct ParamSetter 

Source
pub struct ParamSetter<'a> {
    pub raw_context: &'a dyn GuiContext,
}
Expand description

A convenience helper for setting parameter values. Any changes made here will be broadcasted to the host and reflected in the plugin’s Params object. These functions should only be called from the main thread.

Fields§

§raw_context: &'a dyn GuiContext

Implementations§

Source§

impl<'a> ParamSetter<'a>

Source

pub fn new(context: &'a dyn GuiContext) -> Self

Source

pub fn begin_set_parameter<P: Param>(&self, param: &P)

Inform the host that you will start automating a parameter. This needs to be called before calling set_parameter() for the specified parameter.

Source

pub fn set_parameter<P: Param>(&self, param: &P, value: P::Plain)

Set a parameter to the specified parameter value. You will need to call begin_set_parameter() before and end_set_parameter() after calling this so the host can properly record automation for the parameter. This can be called multiple times in a row before calling end_set_parameter(), for instance when moving a slider around.

This function assumes you’re already calling this from a GUI thread. Calling any of these functions from any other thread may result in unexpected behavior.

Source

pub fn set_parameter_normalized<P: Param>(&self, param: &P, normalized: f32)

Set a parameter to an already normalized value. Works exactly the same as set_parameter() and needs to follow the same rules, but this may be useful when implementing a GUI.

This does not perform any snapping. Consider converting the normalized value to a plain value and setting that with set_parameter() instead so the normalized value known to the host matches param.normalized_value().

Source

pub fn end_set_parameter<P: Param>(&self, param: &P)

Inform the host that you are done automating a parameter. This needs to be called after one or more set_parameter() calls for a parameter so the host knows the automation gesture has finished.

Auto Trait Implementations§

§

impl<'a> Freeze for ParamSetter<'a>

§

impl<'a> !RefUnwindSafe for ParamSetter<'a>

§

impl<'a> Send for ParamSetter<'a>

§

impl<'a> Sync for ParamSetter<'a>

§

impl<'a> Unpin for ParamSetter<'a>

§

impl<'a> UnsafeUnpin for ParamSetter<'a>

§

impl<'a> !UnwindSafe for ParamSetter<'a>

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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.

Source§

impl<T, U> Into<U> for T
where 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.

Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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.