pub struct Slider { /* private fields */ }Expand description
An Expressive slider. Base owns the value and step grid. The caller retains the state entity and observes its SliderEvent notifications.
Implementations§
Source§impl Slider
impl Slider
Sourcepub fn new(
id: impl Into<ElementId>,
name: impl Into<SharedString>,
state: &Entity<SliderState>,
) -> Self
pub fn new( id: impl Into<ElementId>, name: impl Into<SharedString>, state: &Entity<SliderState>, ) -> Self
Creates a horizontal single-value slider bound to state with an element ID and accessible name.
Sourcepub fn range(
id: impl Into<ElementId>,
start_name: impl Into<SharedString>,
end_name: impl Into<SharedString>,
state: &Entity<SliderState>,
) -> Self
pub fn range( id: impl Into<ElementId>, start_name: impl Into<SharedString>, end_name: impl Into<SharedString>, state: &Entity<SliderState>, ) -> Self
Supplies the two accessible names of a slider with a Base range value.
Sourcepub fn kind(self, kind: SliderKind) -> Self
pub fn kind(self, kind: SliderKind) -> Self
Selects standard start-anchored or centered active track geometry.
Sourcepub fn axis(self, axis: Axis) -> Self
pub fn axis(self, axis: Axis) -> Self
Sets the slider orientation (Axis::Horizontal by default).
Sourcepub fn reverse_vertical(self, reverse: bool) -> Self
pub fn reverse_vertical(self, reverse: bool) -> Self
Increases vertical sliders from top to bottom. Horizontal sliders follow the window direction.
Sourcepub fn size(self, size: ControlSize) -> Self
pub fn size(self, size: ControlSize) -> Self
Selects the expressive track size. ExtraSmall (16 dp) is the default.
Sourcepub fn disabled(self, disabled: bool) -> Self
pub fn disabled(self, disabled: bool) -> Self
Disables pointer dragging, keyboard adjustment, and focus traversal when true.
Sourcepub fn tick_intervals(self, intervals: u16) -> Self
pub fn tick_intervals(self, intervals: u16) -> Self
Draws equally spaced ticks in the visual range without changing the Base value scale. Pass the number of intervals, including the two endpoints.
Sourcepub fn icon(self, icon: impl IntoElement) -> Self
pub fn icon(self, icon: impl IntoElement) -> Self
Places an optional decorative icon inside the active track on medium and larger sizes.
Sourcepub fn track(self, element: impl IntoElement) -> Self
pub fn track(self, element: impl IntoElement) -> Self
Replaces the built-in track, icon, and marker artwork. The slider retains its input region.
Sourcepub fn track_style(self, style: SliderTrackStyle) -> Self
pub fn track_style(self, style: SliderTrackStyle) -> Self
Sets the built-in track dimensions. Thickness also sizes a custom track’s slot.
Sourcepub fn thumb(self, which: RangeThumb, element: impl IntoElement) -> Self
pub fn thumb(self, which: RangeThumb, element: impl IntoElement) -> Self
Replaces the handle artwork. Use RangeThumb::End for a single value.
Sourcepub fn thumb_style(self, which: RangeThumb, style: SliderThumbStyle) -> Self
pub fn thumb_style(self, which: RangeThumb, style: SliderThumbStyle) -> Self
Sets per-handle size and colors. Use RangeThumb::End for a single value.
Sourcepub fn colors(self, colors: SliderColors) -> Self
pub fn colors(self, colors: SliderColors) -> Self
Overrides enabled and disabled track, thumb, and tick colors.
Sourcepub fn track_focus(self, which: RangeThumb, focus: &FocusHandle) -> Self
pub fn track_focus(self, which: RangeThumb, focus: &FocusHandle) -> Self
Uses the caller’s focus handle for one handle instead of an internal keyed handle.
Use RangeThumb::End for a single-value slider.
Sourcepub fn interaction_source(
self,
which: RangeThumb,
source: &Entity<InteractionSource>,
) -> Self
pub fn interaction_source( self, which: RangeThumb, source: &Entity<InteractionSource>, ) -> Self
Observes one handle under the slider ID paired with "start" or "end".
Sourcepub fn draw_ticks(
self,
draw: impl Fn(SliderMarker, &mut Window, &mut App) + 'static,
) -> Self
pub fn draw_ticks( self, draw: impl Fn(SliderMarker, &mut Window, &mut App) + 'static, ) -> Self
Replaces the default dot painter for visual ticks.
Sourcepub fn draw_stop_indicators(
self,
draw: impl Fn(SliderMarker, &mut Window, &mut App) + 'static,
) -> Self
pub fn draw_stop_indicators( self, draw: impl Fn(SliderMarker, &mut Window, &mut App) + 'static, ) -> Self
Replaces the default dot painter for track stops.
Sourcepub fn show_stop_indicators(self, show: bool) -> Self
pub fn show_stop_indicators(self, show: bool) -> Self
Controls whether endpoint stop dots are drawn on the track. Defaults to true.
Sourcepub fn value_indicator(self, show: bool) -> Self
pub fn value_indicator(self, show: bool) -> Self
Enables the value indicator during dragging and keyboard focus. It is enabled by default.
Sourcepub fn format_value(
self,
format: impl Fn(f32) -> SharedString + 'static,
) -> Self
pub fn format_value( self, format: impl Fn(f32) -> SharedString + 'static, ) -> Self
Formats the current value of the handle whose indicator is visible.
Trait Implementations§
Source§impl IntoElement for Slider
impl IntoElement for Slider
Source§type Element = ViewElement<Slider>
type Element = ViewElement<Slider>
Source§fn into_element(self) -> Self::Element
fn into_element(self) -> Self::Element
Element.Source§fn into_any_element(self) -> AnyElement
fn into_any_element(self) -> AnyElement
AnyElement.Source§impl RenderOnce for Slider
impl RenderOnce for Slider
Source§fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement
fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement
Render::render() method
which takes a mutable reference.Auto Trait Implementations§
impl !RefUnwindSafe for Slider
impl !Send for Slider
impl !Sync for Slider
impl !UnwindSafe for Slider
impl Forget for Slider
impl Freeze for Slider
impl Move for Slider
impl Unpin for Slider
impl UnsafeUnpin for Slider
Blanket Implementations§
Source§impl<E> AnimationExt for Ewhere
E: IntoElement + 'static,
impl<E> AnimationExt for Ewhere
E: IntoElement + 'static,
Source§fn with_animation(
self,
id: impl Into<ElementId>,
animation: Animation,
animator: impl Fn(Self, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
fn with_animation(
self,
id: impl Into<ElementId>,
animation: Animation,
animator: impl Fn(Self, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
Source§fn with_animations(
self,
id: impl Into<ElementId>,
animations: Vec<Animation>,
animator: impl Fn(Self, usize, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
fn with_animations(
self,
id: impl Into<ElementId>,
animations: Vec<Animation>,
animator: impl Fn(Self, usize, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
Source§fn with_spring<T>(
self,
id: impl Into<ElementId>,
animation: SpringAnimation<T>,
animator: impl FnOnce(Self, <T as SpringTarget>::Output) -> Self + 'static,
) -> SpringAnimationElement<Self>
fn with_spring<T>( self, id: impl Into<ElementId>, animation: SpringAnimation<T>, animator: impl FnOnce(Self, <T as SpringTarget>::Output) -> Self + 'static, ) -> SpringAnimationElement<Self>
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> FluentBuilder for Twhere
T: IntoElement,
impl<T> FluentBuilder for Twhere
T: IntoElement,
Source§fn map<U>(self, f: impl FnOnce(Self) -> U) -> Uwhere
Self: Sized,
fn map<U>(self, f: impl FnOnce(Self) -> U) -> Uwhere
Self: Sized,
Source§fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Selfwhere
Self: Sized,
fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Selfwhere
Self: Sized,
Source§fn when_else(
self,
condition: bool,
then: impl FnOnce(Self) -> Self,
else_fn: impl FnOnce(Self) -> Self,
) -> Selfwhere
Self: Sized,
fn when_else(
self,
condition: bool,
then: impl FnOnce(Self) -> Self,
else_fn: impl FnOnce(Self) -> Self,
) -> Selfwhere
Self: Sized,
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 moreSource§impl<T> MaterialElementExt for Twhere
T: IntoElement,
impl<T> MaterialElementExt for Twhere
T: IntoElement,
Source§fn badge_label(self, text: impl Into<SharedString>) -> Badge
fn badge_label(self, text: impl Into<SharedString>) -> Badge
Badge to this element’s upper trailing edge.Source§fn badge_count(self, count: usize, maximum: usize) -> Badge
fn badge_count(self, count: usize, maximum: usize) -> Badge
Badge to this element’s upper trailing edge.Source§fn tooltip(
self,
id: impl Into<ElementId>,
text: impl Into<SharedString>,
) -> Tooltip
fn tooltip( self, id: impl Into<ElementId>, text: impl Into<SharedString>, ) -> Tooltip
Tooltip.Menu.Menu
whose items are built lazily only while the menu is open.Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<E> TestTextExt for Ewhere
E: IntoElement,
impl<E> TestTextExt for Ewhere
E: IntoElement,
Source§fn test_text(self, text: impl Into<SharedString>) -> Self::Element
fn test_text(self, text: impl Into<SharedString>) -> Self::Element
test-support, records text each time the element paints.
Otherwise returns the element it builds.Source§fn test_alt_text(self, text: impl Into<SharedString>) -> Self::Element
fn test_alt_text(self, text: impl Into<SharedString>) -> Self::Element
Self::test_text for an image’s alternative text, which
stands in for what the element draws.