pub struct RangeSlider<'a, T: Numeric> { /* private fields */ }Expand description
A horizontal numeric range slider with two thumbs.
Both endpoints are bound to caller-owned values; the widget keeps
low <= high automatically (a thumb dragged past its sibling clamps
to the sibling’s value rather than swapping).
let (mut lo, mut hi): (u32, u32) = (24, 118);
ui.add(
RangeSlider::new(&mut lo, &mut hi, 0u32..=200u32)
.label("Price")
.suffix("$"),
);Implementations§
Source§impl<'a, T: Numeric> RangeSlider<'a, T>
impl<'a, T: Numeric> RangeSlider<'a, T>
Sourcepub fn new(low: &'a mut T, high: &'a mut T, range: RangeInclusive<T>) -> Self
pub fn new(low: &'a mut T, high: &'a mut T, range: RangeInclusive<T>) -> Self
Create a range slider bound to low and high, constrained to range.
Sourcepub fn label(self, label: impl Into<WidgetText>) -> Self
pub fn label(self, label: impl Into<WidgetText>) -> Self
Show a label on the left of the header row above the track.
The label also names the slider for screen readers. Without one, name
the returned response with egui::Response::accessible_name, or with
egui::Response::labelled_by when a caption is drawn beside it.
Sourcepub fn suffix(self, suffix: impl Into<String>) -> Self
pub fn suffix(self, suffix: impl Into<String>) -> Self
Suffix appended to each formatted endpoint value (e.g. "%", " dB").
Sourcepub fn decimals(self, n: usize) -> Self
pub fn decimals(self, n: usize) -> Self
Number of decimal places in the value display. Defaults to 0 for
integer-typed sliders and 2 for float-typed.
Sourcepub fn show_value(self, show: bool) -> Self
pub fn show_value(self, show: bool) -> Self
Hide the right-aligned low – high display in the header row. The
label, if any, still renders. Default: shown.
Sourcepub fn step(self, step: f64) -> Self
pub fn step(self, step: f64) -> Self
Snap values to multiples of step (in the slider’s value units).
Integer-typed sliders snap to 1.0 automatically unless overridden.
Sourcepub fn ticks(self, n: usize) -> Self
pub fn ticks(self, n: usize) -> Self
Draw n evenly-spaced tick marks across the track (including both
endpoints, so .ticks(5) draws 5 ticks at 0%, 25%, 50%, 75%, 100%).
Pass 0 or 1 to suppress ticks.
Sourcepub fn show_tick_labels(self, show: bool) -> Self
pub fn show_tick_labels(self, show: bool) -> Self
When tick marks are drawn, also render the value at each tick beneath
the track. No effect without ticks.
Sourcepub fn accent(self, accent: Accent) -> Self
pub fn accent(self, accent: Accent) -> Self
Pick the fill colour. Default: Accent::Sky.
Sourcepub fn desired_width(self, width: f32) -> Self
pub fn desired_width(self, width: f32) -> Self
Override the slider width. Defaults to ui.available_width().
Sourcepub fn enabled(self, enabled: bool) -> Self
pub fn enabled(self, enabled: bool) -> Self
Disable the widget. A disabled slider still paints its current values but ignores pointer and keyboard input. Default: enabled.
Sourcepub fn id_salt(self, id_salt: impl IdSalt) -> Self
pub fn id_salt(self, id_salt: impl IdSalt) -> Self
Salt used to derive the per-thumb interaction ids. Set this when multiple range sliders share a parent ui so their thumbs don’t collide on focus or drag state.
Sourcepub fn handle(self, handle: SliderHandle) -> Self
pub fn handle(self, handle: SliderHandle) -> Self
Pick the thumb shape. Both thumbs share the same style. Default:
SliderHandle::Circle. Switch to SliderHandle::Line for a thin
vertical bar instead of the standard circular knob.
Trait Implementations§
Source§impl<'a, T: Numeric> Debug for RangeSlider<'a, T>
impl<'a, T: Numeric> Debug for RangeSlider<'a, T>
Auto Trait Implementations§
impl<'a, T> !RefUnwindSafe for RangeSlider<'a, T>
impl<'a, T> !Send for RangeSlider<'a, T>
impl<'a, T> !Sync for RangeSlider<'a, T>
impl<'a, T> !UnwindSafe for RangeSlider<'a, T>
impl<'a, T> Freeze for RangeSlider<'a, T>
impl<'a, T> Unpin for RangeSlider<'a, T>
impl<'a, T> UnsafeUnpin for RangeSlider<'a, T>
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
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