pub struct Selector(/* private fields */);
Expand description
Defines the values and ranges selected by a slider.
Selectors are set on the selector
property.
Implementations§
source§impl Selector
impl Selector
sourcepub fn value<T: SelectorValue>(
selection: impl IntoVar<T>,
min: T,
max: T,
) -> Self
pub fn value<T: SelectorValue>( selection: impl IntoVar<T>, min: T, max: T, ) -> Self
New with single value thumb of type T
that can be set any value in the min..=max
range.
sourcepub fn value_with<T>(
selection: impl IntoVar<T>,
to_offset: impl Fn(&T) -> Factor + Send + 'static,
from_offset: impl Fn(Factor) -> T + Send + 'static,
) -> Selfwhere
T: VarValue,
pub fn value_with<T>(
selection: impl IntoVar<T>,
to_offset: impl Fn(&T) -> Factor + Send + 'static,
from_offset: impl Fn(Factor) -> T + Send + 'static,
) -> Selfwhere
T: VarValue,
New with a single value thumb of type T
.
The value must convert to a normalized factor [0.fct()..=1.fct()]
where 0.fct()
is the minimum possible value and 1.fct()
is the maximum
possible value. If a value outside of this range is returned it is clamped to the range and the selection
variable is updated back.
sourcepub fn range<T: SelectorValue>(
range: impl IntoVar<Range<T>>,
min: T,
max: T,
) -> Self
pub fn range<T: SelectorValue>( range: impl IntoVar<Range<T>>, min: T, max: T, ) -> Self
New with two value thumbs of type T
that can be set any value in the min..=max
range.
sourcepub fn range_with<T>(
range: impl IntoVar<Range<T>>,
to_offset: impl Fn(&T) -> Factor + Send + 'static,
from_offset: impl Fn(Factor) -> T + Send + 'static,
) -> Selfwhere
T: VarValue,
pub fn range_with<T>(
range: impl IntoVar<Range<T>>,
to_offset: impl Fn(&T) -> Factor + Send + 'static,
from_offset: impl Fn(Factor) -> T + Send + 'static,
) -> Selfwhere
T: VarValue,
New with two values thumbs that define a range of type T
.
The conversion closure have the same constraints as value_with
.
sourcepub fn many<T: SelectorValue>(
many: impl IntoVar<Vec<T>>,
min: T,
max: T,
) -> Self
pub fn many<T: SelectorValue>( many: impl IntoVar<Vec<T>>, min: T, max: T, ) -> Self
New with many value thumbs of type T
that can be set any value in the min..=max
range.
sourcepub fn many_with<T>(
many: impl IntoVar<Vec<T>>,
to_offset: impl Fn(&T) -> Factor + Send + 'static,
from_offset: impl Fn(Factor) -> T + Send + 'static,
) -> Selfwhere
T: VarValue,
pub fn many_with<T>(
many: impl IntoVar<Vec<T>>,
to_offset: impl Fn(&T) -> Factor + Send + 'static,
from_offset: impl Fn(Factor) -> T + Send + 'static,
) -> Selfwhere
T: VarValue,
New with many value thumbs of type T
.
The conversion closure have the same constraints as value_with
.
sourcepub fn to_offset<T: VarValue>(&self, t: &T) -> Option<Factor>
pub fn to_offset<T: VarValue>(&self, t: &T) -> Option<Factor>
Convert the value to a normalized factor.
If T
is not the same type returns None
.
sourcepub fn from_offset<T: VarValue>(
&self,
offset: impl IntoValue<Factor>,
) -> Option<T>
pub fn from_offset<T: VarValue>( &self, offset: impl IntoValue<Factor>, ) -> Option<T>
Convert the normalized factor to a value T
.
If T
is not the same type returns None
.
sourcepub fn thumbs(&self) -> Vec<ThumbValue>
pub fn thumbs(&self) -> Vec<ThumbValue>
Gets the value thumbs.
sourcepub fn set(
&self,
nearest_thumb: impl IntoValue<Factor>,
to: impl IntoValue<Factor>,
)
pub fn set( &self, nearest_thumb: impl IntoValue<Factor>, to: impl IntoValue<Factor>, )
Move the nearest_thumb
to a new offset.
Note that ranges don’t invert, this operation may swap the thumb roles.
sourcepub fn selection(&self) -> BoxedAnyVar
pub fn selection(&self) -> BoxedAnyVar
The selection var.
Downcast to T
or Range<T>
to get and set the value.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Selector
impl !RefUnwindSafe for Selector
impl Send for Selector
impl Sync for Selector
impl Unpin for Selector
impl !UnwindSafe for Selector
Blanket Implementations§
source§impl<T> AnyVarValue for Twhere
T: VarValue,
impl<T> AnyVarValue for Twhere
T: VarValue,
source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
dyn Any
methods.source§fn clone_boxed(&self) -> Box<dyn AnyVarValue>
fn clone_boxed(&self) -> Box<dyn AnyVarValue>
source§fn clone_boxed_var(&self) -> Box<dyn AnyVar>
fn clone_boxed_var(&self) -> Box<dyn AnyVar>
LocalVar<Self>
.source§fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
self
equals other
.source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more