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.
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().