pub struct SliderState { /* private fields */ }Expand description
Retained ordered values, thumb focus, and pointer geometry for one slider in one window.
Values snap to steps measured from the minimum. Both endpoints are reachable, including a maximum that is not on the step grid. Range, step, and thumb count are fixed for the entity’s lifetime. Applications observe this state to redraw.
Implementations§
Source§impl SliderState
impl SliderState
Sourcepub fn new(
range: RangeInclusive<f32>,
step: f32,
values: impl IntoIterator<Item = f32>,
cx: &mut Context<'_, Self>,
) -> Self
pub fn new( range: RangeInclusive<f32>, step: f32, values: impl IntoIterator<Item = f32>, cx: &mut Context<'_, Self>, ) -> Self
Creates one thumb per initial value. Thumb identities and count remain fixed. Values are clamped and snapped, and equal values are allowed.
§Panics
Endpoints must be finite with min < max; step must be finite and positive.
Values must be finite, nonempty, and ordered after normalization.
pub fn values(&self) -> &[f32]
pub fn min_value(&self) -> f32
pub fn max_value(&self) -> f32
pub fn step_value(&self) -> f32
Sourcepub fn percentage(&self, index: usize) -> f32
pub fn percentage(&self, index: usize) -> f32
The thumb center’s fraction along the travel rail, in 0..=1.
pub fn thumb_focus_handle(&self, index: usize) -> &FocusHandle
pub fn is_disabled(&self) -> bool
Sourcepub fn set_values(
&mut self,
values: impl IntoIterator<Item = f32>,
window: &mut Window,
cx: &mut Context<'_, Self>,
)
pub fn set_values( &mut self, values: impl IntoIterator<Item = f32>, window: &mut Window, cx: &mut Context<'_, Self>, )
Replaces all values, preserving thumb count and order. Emits one event only when the normalized values change. The initial validation rules still apply. Programmatic changes remain allowed while user interaction is disabled.
Sourcepub fn set_thumb_value(
&mut self,
index: usize,
value: f32,
window: &mut Window,
cx: &mut Context<'_, Self>,
)
pub fn set_thumb_value( &mut self, index: usize, value: f32, window: &mut Window, cx: &mut Context<'_, Self>, )
Sets one thumb, snapping from the global minimum and clamping to its neighbors so thumbs never cross. Equal adjacent values are allowed. Programmatic changes remain allowed while user interaction is disabled.
Sourcepub fn set_disabled(
&mut self,
disabled: bool,
window: &mut Window,
cx: &mut Context<'_, Self>,
)
pub fn set_disabled( &mut self, disabled: bool, window: &mut Window, cx: &mut Context<'_, Self>, )
Disables user interaction and removes all thumbs from normal Tab order. An already-focused thumb retains its focus binding so Tab can leave it.
Trait Implementations§
impl EventEmitter<SliderEvent> for SliderState
Auto Trait Implementations§
impl !RefUnwindSafe for SliderState
impl !UnwindSafe for SliderState
impl Forget for SliderState
impl Freeze for SliderState
impl Move for SliderState
impl Send for SliderState
impl Sync for SliderState
impl Unpin for SliderState
impl UnsafeUnpin for SliderStatewhere
*const u8 is !null: UnsafeUnpin,
PhantomData<f32>: UnsafeUnpin,
PhantomData<FocusHandle>: UnsafeUnpin,
Blanket Implementations§
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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