Skip to main content

value_slider

Function value_slider 

Source
pub fn value_slider<'a, Message: Clone + 'a>(
    range: RangeInclusive<f32>,
    value: f32,
    step: f32,
    on_change: impl Fn(f32) -> Message + 'a,
    on_release: Option<Message>,
    readout: String,
    scale: FontScale,
) -> Element<'a, Message>
Expand description

A slider with its value written beside it in the mono font.

The readout is what makes a slider usable for a setting: dragging to “about there” is fine for volume and useless for a gap in pixels, where the number is the point. The caller formats it, because only the caller knows whether it is pixels, a scale or a percentage.

on_release is for settings that write a file: sending every intermediate value of a drag to disk is a rewrite per pixel.