pub struct Slider<'a, T: Numeric> { /* private fields */ }Expand description
A horizontal numeric slider.
let mut cpu = 42.0_f32;
ui.add(Slider::new(&mut cpu, 0.0..=100.0).label("CPU limit").suffix("%"));Implementations§
Source§impl<'a, T: Numeric> Slider<'a, T>
impl<'a, T: Numeric> Slider<'a, T>
Sourcepub fn new(value: &'a mut T, range: RangeInclusive<T>) -> Self
pub fn new(value: &'a mut T, range: RangeInclusive<T>) -> Self
Create a slider bound to value, constrained to range.
Sourcepub fn label(self, label: impl Into<WidgetText>) -> Self
pub fn label(self, label: impl Into<WidgetText>) -> Self
Show a label above the slider.
Sourcepub fn suffix(self, suffix: impl Into<String>) -> Self
pub fn suffix(self, suffix: impl Into<String>) -> Self
Suffix appended to the formatted 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 value display.
Sourcepub fn step(self, step: f64) -> Self
pub fn step(self, step: f64) -> Self
Snap the value to multiples of step (in the slider’s value units).
Integer-typed sliders snap to 1.0 automatically unless overridden.
Sourcepub fn accent(self, accent: Accent) -> Self
pub fn accent(self, accent: Accent) -> Self
Pick the fill colour from one of the theme accents. 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().
Trait Implementations§
Auto Trait Implementations§
impl<'a, T> Freeze for Slider<'a, T>where
T: Freeze,
impl<'a, T> !RefUnwindSafe for Slider<'a, T>
impl<'a, T> !Send for Slider<'a, T>
impl<'a, T> !Sync for Slider<'a, T>
impl<'a, T> Unpin for Slider<'a, T>where
T: Unpin,
impl<'a, T> UnsafeUnpin for Slider<'a, T>where
T: UnsafeUnpin,
impl<'a, T> !UnwindSafe for Slider<'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
Mutably borrows from an owned value. Read more