pub struct Slider { /* private fields */ }Expand description
A draggable value between min and max. Arrow keys adjust it by step.
use ravenrs_reactive::State;
use ravenrs_widgets::{Slider, Ui};
let volume = State::new(40.0_f32);
let slider = Slider::new(volume.binding()).range(0.0, 100.0).step(5.0).width(240.0).show_value();
let mut ui = Ui::new(slider, ravenrs_style::Theme::raven_dark());
ui.update();Implementations§
Source§impl Slider
impl Slider
Sourcepub fn new(value: Binding<f32>) -> Self
pub fn new(value: Binding<f32>) -> Self
A slider over 0.0–1.0 bound to value, stepping by 0.01.
Sourcepub fn range(self, min: f32, max: f32) -> Self
pub fn range(self, min: f32, max: f32) -> Self
The value range; also resets the step to 1/100 of the range.
Sourcepub fn step(self, step: f32) -> Self
pub fn step(self, step: f32) -> Self
The keyboard increment (call after Slider::range).
Sourcepub fn width(self, width: f32) -> Self
pub fn width(self, width: f32) -> Self
Fixed width in logical pixels; by default the slider stretches.
Sourcepub fn label(self, label: impl Into<String>) -> Self
pub fn label(self, label: impl Into<String>) -> Self
The name screen readers announce, such as “Volume”.
Sourcepub fn marks(self, marks: impl IntoIterator<Item = f32>) -> Self
pub fn marks(self, marks: impl IntoIterator<Item = f32>) -> Self
Notches on the track at these values, such as where chapters begin.
Sourcepub fn track_colors(self, colors: impl IntoIterator<Item = Color>) -> Self
pub fn track_colors(self, colors: impl IntoIterator<Item = Color>) -> Self
Paints the track with these colors, evenly spaced from one end to the other, when the colors are what the value means, as from cold to warm. There is then no fill. The colors are data, so they come from whoever knows what they mean.
Sourcepub fn neutral(self, neutral: f32) -> Self
pub fn neutral(self, neutral: f32) -> Self
The value at rest, such as zero in the middle of the range. The fill starts there instead of at the minimum, and a double click, Backspace or Delete return to it.
Sourcepub fn show_value(self) -> Self
pub fn show_value(self) -> Self
Shows the value at the right of the track, with as many decimals as the step has.
Sourcepub fn value_format(self, format: impl Fn(f32) -> String + 'static) -> Self
pub fn value_format(self, format: impl Fn(f32) -> String + 'static) -> Self
Shows the value at the right of the track as this function writes it, which screen readers read too.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Slider
impl !Send for Slider
impl !Sync for Slider
impl !UnwindSafe for Slider
impl Freeze for Slider
impl Unpin for Slider
impl UnsafeUnpin for Slider
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
impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<V> ViewExt for Vwhere
V: View,
impl<V> ViewExt for Vwhere
V: View,
Source§fn padding(self, padding: impl Into<Insets>) -> Styled<Self>
fn padding(self, padding: impl Into<Insets>) -> Styled<Self>
Source§fn background(self, fill: impl Into<Fill>) -> Styled<Self>
fn background(self, fill: impl Into<Fill>) -> Styled<Self>
Source§fn frame(self, width: Option<f32>, height: Option<f32>) -> Styled<Self>
fn frame(self, width: Option<f32>, height: Option<f32>) -> Styled<Self>
None keeps the content size.