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
impl Slider
pub fn new(root_id: impl Into<ElementId>, state: &SliderState) -> Self
pub const fn root_id(self) -> ElementId
pub const fn state(self) -> SliderState
pub fn track_id(self) -> ElementId
pub fn range_id(self) -> ElementId
pub fn thumb_id(self, index: usize) -> ElementId
Sourcepub fn control_id(self) -> ElementId
pub fn control_id(self) -> ElementId
Stable identity of the control part.
Sourcepub const fn is_single_thumb(self) -> bool
pub const fn is_single_thumb(self) -> bool
Whether this slider projects its value on the root instead of on each thumb.
Sourcepub fn root_with(self, root: Element) -> Element
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.
Sourcepub fn root(self) -> Element
pub fn root(self) -> Element
Create the unstyled root part. Use Self::root_with to supply an existing element.
Sourcepub fn key_with<V: 'static>(
self,
cx: &mut ViewContext<'_, V>,
root: Element,
access: fn(&mut V) -> &mut SliderState,
) -> Element
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.
Sourcepub fn key<V: 'static>(
self,
cx: &mut ViewContext<'_, V>,
access: fn(&mut V) -> &mut SliderState,
) -> Element
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.
Sourcepub fn key_with_accessor<V: 'static>(
self,
cx: &mut ViewContext<'_, V>,
root: Element,
access: StateAccessor<V, SliderState>,
) -> Element
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.
Sourcepub fn track_with(self, track: Element) -> Element
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.
Sourcepub fn track(self) -> Element
pub fn track(self) -> Element
Create the unstyled track part. Use Self::track_with to supply an existing element.
Sourcepub fn range_with(self, range: Element) -> Element
pub fn range_with(self, range: Element) -> Element
Decorate the application-owned fill between the slider’s minimum and its value.
Sourcepub fn range(self) -> Element
pub fn range(self) -> Element
Create the unstyled range part. Use Self::range_with to supply an existing element.
Sourcepub fn indicator_with(self, indicator: Element) -> Element
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.
Sourcepub fn indicator(self) -> Element
pub fn indicator(self) -> Element
Create the unstyled indicator part. Use Self::indicator_with to supply an existing element.
Sourcepub fn control_with(self, control: Element) -> Element
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.
Sourcepub fn control(self) -> Element
pub fn control(self) -> Element
Create the unstyled control part. Use Self::control_with to supply an existing element.
Sourcepub fn label_with(self, label: Element) -> Element
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.
Sourcepub fn label(self) -> Element
pub fn label(self) -> Element
Create the unstyled label part. Use Self::label_with to supply an existing element.
Sourcepub fn value_with(self, value: Element) -> Element
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.
Sourcepub fn value(self) -> Element
pub fn value(self) -> Element
Create the unstyled value part. Use Self::value_with to supply an existing element.
Sourcepub fn display_value(self, format: &ValueFormat) -> Arc<str> ⓘ
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.
Sourcepub fn thumb(self, index: usize) -> Option<SliderThumb>
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§
impl Copy for Slider
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§
impl<T> Action for T
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.