[−][src]Struct iced_audio::core::param::IntParam
A Param
that defines a discrete linear range of i32 values
It stores a unique identifier of user supplied type ID
. This can be an
enum
, u32
, i32
, String
, etc. Each parameter must have a unique ID
value!
Implementations
impl<ID: Debug + Copy + Clone> IntParam<ID>
[src]
pub fn new(id: ID, min: i32, max: i32, value: i32, default_value: i32) -> Self
[src]
Creates a new IntParam
Arguments
id
- an identifier for the parameter (must be unique!)min
- the minimum of the range (inclusive)max
- the maximum of the range (inclusive)value
- the initial value of the parameter (ifvalue
falls outside the range given bymin
andmax
, thenmin
ormax
will be used instead)default_value
- the default value of the parameter (ifdefault_value
falls outside the range given bymin
andmax
, thenmin
ormax
will be used instead)
Panics
This will panic if max
<= min
pub fn set_from_value(&mut self, value: i32)
[src]
Sets the parameter's value to value
If value
falls outside the range given by min
and max
from
IntParam::new()
, then
min
or max
will be used instead.
Value to Normal
calculactions will not be recalculated if the value
has not changed.
pub fn set_from_normal(&mut self, normal: Normal)
[src]
Sets the parameter's value from a Normal
The parameter's resulting Normal
will be calculated from the
resulting parameter's value rounded to the nearest integer.
Example
use iced_audio::{Param, IntParam, Normal}; // id: 0, min: 0, max: 2, value: 1, default_value: 1 let mut param = IntParam::new(0, 0, 2, 1, 1); param.set_from_normal((0.8).into()); assert_eq!(param.value(), 2); assert_eq!(param.normal().value(), 1.0);
pub fn value(&self) -> i32
[src]
Returns the parameter's value
pub fn default_value(&self) -> i32
[src]
Returns the parameter's default value
Trait Implementations
impl<ID: Clone + Debug + Copy> Clone for IntParam<ID>
[src]
impl<ID: Copy + Debug + Clone> Copy for IntParam<ID>
[src]
impl<ID: Debug + Copy + Clone> Debug for IntParam<ID>
[src]
impl<ID: Debug + Copy + Clone> Param for IntParam<ID>
[src]
Auto Trait Implementations
impl<ID> RefUnwindSafe for IntParam<ID> where
ID: RefUnwindSafe,
ID: RefUnwindSafe,
impl<ID> Send for IntParam<ID> where
ID: Send,
ID: Send,
impl<ID> Sync for IntParam<ID> where
ID: Sync,
ID: Sync,
impl<ID> Unpin for IntParam<ID> where
ID: Unpin,
ID: Unpin,
impl<ID> UnwindSafe for IntParam<ID> where
ID: UnwindSafe,
ID: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> SetParameter for T
fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
T: Parameter<Self>,
T: Parameter<Self>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,