pub struct ValueSlider { /* private fields */ }Expand description
A value shown small, as “100% ▾”, that opens a Slider in a popover, for bars with no
room for a slider of their own.
Enter or Space on the button opens it with the keyboard in the slider: the arrows, Home
and End change the value, and Escape closes it and goes back to the button. With
ValueSlider::field the number can also be typed.
use ravenrs_reactive::State;
use ravenrs_widgets::{Ui, ValueSlider};
let opacity = State::new(100.0_f32);
let control = ValueSlider::new(opacity.binding()).range(0.0, 100.0).step(1.0).unit("%").label("Opacity");
let mut ui = Ui::new(control, ravenrs_style::Theme::raven_dark());
ui.update();Implementations§
Source§impl ValueSlider
impl ValueSlider
Sourcepub fn new(value: Binding<f32>) -> Self
pub fn new(value: Binding<f32>) -> Self
A control 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 ValueSlider::range).
Sourcepub fn unit(self, unit: impl Into<String>) -> Self
pub fn unit(self, unit: impl Into<String>) -> Self
Text right after the number, such as % or px.
Sourcepub fn label(self, label: impl Into<String>) -> Self
pub fn label(self, label: impl Into<String>) -> Self
What the value is, such as “Opacity”, for screen readers. See Self::show_label.
Sourcepub fn show_label(self) -> Self
pub fn show_label(self) -> Self
Also writes the label before the value.
Sourcepub fn value_format(self, format: impl Fn(f32) -> String + 'static) -> Self
pub fn value_format(self, format: impl Fn(f32) -> String + 'static) -> Self
Writes the value as this function does, instead of the number and the unit.
Self::field goes on showing the number, since that is what can be typed.
Sourcepub fn neutral(self, neutral: f32) -> Self
pub fn neutral(self, neutral: f32) -> Self
The value at rest: see Slider::neutral.
Sourcepub fn slider_width(self, width: f32) -> Self
pub fn slider_width(self, width: f32) -> Self
The width of the slider in the popover, in logical pixels (200 by default).
Trait Implementations§
Source§impl Debug for ValueSlider
impl Debug for ValueSlider
Auto Trait Implementations§
impl !RefUnwindSafe for ValueSlider
impl !Send for ValueSlider
impl !Sync for ValueSlider
impl !UnwindSafe for ValueSlider
impl Freeze for ValueSlider
impl Unpin for ValueSlider
impl UnsafeUnpin for ValueSlider
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.