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>) -> ValueSlider
pub fn new(value: Binding<f32>) -> ValueSlider
A control over 0.0–1.0 bound to value, stepping by 0.01.
Sourcepub fn range(self, min: f32, max: f32) -> ValueSlider
pub fn range(self, min: f32, max: f32) -> ValueSlider
The value range; also resets the step to 1/100 of the range.
Sourcepub fn step(self, step: f32) -> ValueSlider
pub fn step(self, step: f32) -> ValueSlider
The keyboard increment (call after ValueSlider::range).
Sourcepub fn unit(self, unit: impl Into<String>) -> ValueSlider
pub fn unit(self, unit: impl Into<String>) -> ValueSlider
Text right after the number, such as % or px.
Sourcepub fn label(self, label: impl Into<String>) -> ValueSlider
pub fn label(self, label: impl Into<String>) -> ValueSlider
What the value is, such as “Opacity”, for screen readers. See Self::show_label.
Sourcepub fn show_label(self) -> ValueSlider
pub fn show_label(self) -> ValueSlider
Also writes the label before the value.
Sourcepub fn value_format(
self,
format: impl Fn(f32) -> String + 'static,
) -> ValueSlider
pub fn value_format( self, format: impl Fn(f32) -> String + 'static, ) -> ValueSlider
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) -> ValueSlider
pub fn neutral(self, neutral: f32) -> ValueSlider
The value at rest: see Slider::neutral.
Sourcepub fn slider_width(self, width: f32) -> ValueSlider
pub fn slider_width(self, width: f32) -> ValueSlider
The width of the slider in the popover, in logical pixels (200 by default).
Sourcepub fn field(self) -> ValueSlider
pub fn field(self) -> ValueSlider
A number field with the unit and a small arrow that opens the slider, instead of a button. Enter or leaving the field takes what was typed, up to the limits; text that is not a number, or Escape, brings the value back. Up and Down take a step.
Sourcepub fn disabled(self, disabled: bool) -> ValueSlider
pub fn disabled(self, disabled: bool) -> ValueSlider
Turns it off: it fades, leaves the tab order and does not open.
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§
impl<T> AutoreleaseSafe for Twhere
T: ?Sized,
impl<T> AutoreleaseSafe for Twhere
T: ?Sized,
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<T, U> ToSample<U> for Twhere
U: FromSample<T>,
impl<T, U> ToSample<U> for Twhere
U: FromSample<T>,
fn to_sample_(self) -> U
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.