Skip to main content

Slider

Struct Slider 

Source
pub struct Slider { /* private fields */ }
Expand description

A controlled, unstyled slider descriptor.

The application owns the track, range fill, thumb, tick marks, labels, colors, and motion. QuickGUI supplies stable part identities, the Slider role with numeric value/min/max/step and orientation, captured pointer arithmetic, and typed keyboard actions.

A single-thumb slider projects the Slider role on its root. A multi-thumb slider projects a group root and one Slider role per thumb, each bounded by its neighbors, matching the WAI-ARIA multi-thumb pattern.

Implementations§

Source§

impl Slider

Source

pub fn new(root_id: impl Into<ElementId>, state: &SliderState) -> Self

Source

pub const fn root_id(self) -> ElementId

Source

pub const fn state(self) -> SliderState

Source

pub fn track_id(self) -> ElementId

Source

pub fn range_id(self) -> ElementId

Source

pub fn thumb_id(self, index: usize) -> ElementId

Source

pub fn label_id(self) -> ElementId

Stable identity of the label part.

Source

pub fn value_id(self) -> ElementId

Stable identity of the value part.

Source

pub fn control_id(self) -> ElementId

Stable identity of the control part.

Source

pub const fn is_single_thumb(self) -> bool

Whether this slider projects its value on the root instead of on each thumb.

Source

pub fn root_with(self, root: Element) -> Element

Decorate an application-owned root without adding layout or appearance.

A single-thumb slider becomes the focusable Slider itself. Pair it with Self::key_with to attach the typed keyboard actions.

Source

pub fn root(self) -> Element

Create the unstyled root part. Use Self::root_with to supply an existing element.

Source

pub fn key_with<V: 'static>( self, cx: &mut ViewContext<'_, V>, root: Element, access: fn(&mut V) -> &mut SliderState, ) -> Element

Attach QuickGUI’s typed slider keyboard actions to a single-thumb root.

Install slider_key_bindings once on the application keymap. Multi-thumb sliders use SliderThumb::key_with instead so each thumb owns its own focus.

Source

pub fn key<V: 'static>( self, cx: &mut ViewContext<'_, V>, access: fn(&mut V) -> &mut SliderState, ) -> Element

Create the unstyled key part. Use Self::key_with to supply an existing element.

Source

pub fn key_with_accessor<V: 'static>( self, cx: &mut ViewContext<'_, V>, root: Element, access: StateAccessor<V, SliderState>, ) -> Element

Attach the typed slider keyboard actions against a per-instance state accessor.

Source

pub fn track_with(self, track: Element) -> Element

Decorate an application-owned track.

Base UI uses Self::control_with as the larger interactive surface. A declaration that omits Control can keep the earlier behavior by attaching a crate::ViewContext::pointer_listener registered for Self::track_id and forwarding the event to SliderState::apply_pointer with the size the caller laid out.

Source

pub fn track(self) -> Element

Create the unstyled track part. Use Self::track_with to supply an existing element.

Source

pub fn range_with(self, range: Element) -> Element

Decorate the application-owned fill between the slider’s minimum and its value.

Source

pub fn range(self) -> Element

Create the unstyled range part. Use Self::range_with to supply an existing element.

Source

pub fn indicator_with(self, indicator: Element) -> Element

Base UI’s Indicator name for the filled part of the track.

This is the same decorator as Self::range_with; both names stay supported.

Source

pub fn indicator(self) -> Element

Create the unstyled indicator part. Use Self::indicator_with to supply an existing element.

Source

pub fn control_with(self, control: Element) -> Element

Decorate the caller-owned interactive area that carries the slider’s pointer capture.

Base UI separates the Control — the region a press acts on — from the Track it paints. Attach a crate::ViewContext::pointer_listener registered for Self::control_id and forward the event to SliderState::apply_pointer_change with the size the caller laid out. A caller that omits this part can keep pointer capture on Self::track_with.

Source

pub fn control(self) -> Element

Create the unstyled control part. Use Self::control_with to supply an existing element.

Source

pub fn label_with(self, label: Element) -> Element

Assign the stable mounted label target the slider points at.

A single-thumb slider takes its accessible name from this part. A multi-thumb slider names its group from it, and each thumb still needs its own accessible name.

Source

pub fn label(self) -> Element

Create the unstyled label part. Use Self::label_with to supply an existing element.

Source

pub fn value_with(self, value: Element) -> Element

Assign the stable mounted value target the slider points at.

Put Self::display_value inside it; QuickGUI never renders the text itself.

Source

pub fn value(self) -> Element

Create the unstyled value part. Use Self::value_with to supply an existing element.

Source

pub fn display_value(self, format: &ValueFormat) -> Arc<str> ⓘ

Format every thumb value into one string for a caller-owned value part.

This is Base UI’s Root format prop applied through the shared crate::ValueFormat. A range slider joins its thumbs with an en dash, which is the shape Base UI’s Value renders by default.

Source

pub fn thumb(self, index: usize) -> Option<SliderThumb>

Describe one thumb.

Indices at or past SliderState::thumb_count return None so a caller-driven loop stays bounded by the state instead of by its own arithmetic.

Trait Implementations§

Source§

impl Clone for Slider

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Slider

Source§

impl Debug for Slider

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Slider

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Slider

Auto Trait Implementations§

§

impl Forget for Slider

§

impl Freeze for Slider

§

impl Move for Slider

§

impl RefUnwindSafe for Slider

§

impl Send for Slider

§

impl Sync for Slider

§

impl Unpin for Slider

§

impl UnsafeUnpin for Slider

§

impl UnwindSafe for Slider

Blanket Implementations§

Source§

impl<T> Action for T
where T: Clone + PartialEq + 'static,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> TryClone for T
where T: Clone,

Source§

fn try_clone(&self) -> Result<T, Error>

Clones self, possibly returning an error.
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more