pub struct Slider<'a> { /* private fields */ }Expand description
A slider over an f64.
Need (input): a slider over a number.
Implementations§
Source§impl<'a> Slider<'a>
impl<'a> Slider<'a>
Sourcepub fn new(value: &'a mut f64, label: &str, soft: RangeInclusive<f64>) -> Self
pub fn new(value: &'a mut f64, label: &str, soft: RangeInclusive<f64>) -> Self
A slider spanning soft, which is also its hard range until
Slider::hard widens it.
Sourcepub fn from_descriptor(value: &'a mut f64, d: &Descriptor) -> Self
pub fn from_descriptor(value: &'a mut f64, d: &Descriptor) -> Self
From a value descriptor: its label, ranges, steps, unit, precision, display scale and default.
Sourcepub fn hard(self, hard: RangeInclusive<f64>) -> Self
pub fn hard(self, hard: RangeInclusive<f64>) -> Self
The range a typed value may reach (it always holds the soft range).
Sourcepub fn step(self, step: f64) -> Self
pub fn step(self, step: f64) -> Self
The step of arrows and the wheel; also sets the precision.
Sourcepub fn display_scale(self, scale: f64) -> Self
pub fn display_scale(self, scale: f64) -> Self
Shown and typed as value * scale (a fraction as a
percentage: 100).
Sourcepub fn logarithmic(self) -> Self
pub fn logarithmic(self) -> Self
A logarithmic bar (Curve::Logarithmic).
Sourcepub fn gradient(self, gradient: Gradient) -> Self
pub fn gradient(self, gradient: Gradient) -> Self
The track painted with a gradient (hue, temperature) along the bar.
Sourcepub fn state(self, state: FieldState) -> Self
pub fn state(self, state: FieldState) -> Self
The field’s state, drawn and announced as every field’s
(crate::field): a read-only slider takes the focus and
refuses changes, a disabled one is greyed and skipped by Tab,
with its reason as the tooltip.
Sourcepub fn ramp(self, min: impl Into<RampColor>, max: impl Into<RampColor>) -> Self
pub fn ramp(self, min: impl Into<RampColor>, max: impl Into<RampColor>) -> Self
A colour for the minimum and one for the maximum, the value
drawn in the colour between them, blended in Oklab over the
soft range (Ramp): a token path
("danger") or a Color32 each.
Drawn in RampMode::Value unless
ramp_track says otherwise; a
high-contrast theme draws the theme’s own fill instead.
Sourcepub fn ramp_stops(self, stops: &[(f32, RampColor)]) -> Self
pub fn ramp_stops(self, stops: &[(f32, RampColor)]) -> Self
A colour ramp through stops (place, colour), places from 0
(the soft start) to 1 (its end): for hue-like scales.
Sourcepub fn ramp_track(self) -> Self
pub fn ramp_track(self) -> Self
The ramp across the whole track, the value marked on it by
the thumb or the pointer (RampMode::Track),
so the scale reads before a touch; nothing without a ramp.
Sourcepub fn vertical(self) -> Self
pub fn vertical(self) -> Self
A vertical slider, as a mixer’s fader: up is more. The same gestures along the other axis (a drag up does what a drag right does on a horizontal bar; Up and Right step up), the value at the top, the label at the bottom, under the track. It has no quad button.
Sourcepub fn size(self, size: Vec2) -> Self
pub fn size(self, size: Vec2) -> Self
Its size, in points: the room it fills (a slot). By default a
horizontal slider takes the width available (at least
MIN_WIDTH) and a row’s height; a vertical one is
VERTICAL_LENGTH high and a row and a half wide.
Sourcepub fn compact(self) -> Self
pub fn compact(self) -> Self
The compact representation: the value alone, the label in the tooltip (and still the bar’s name for assistive technologies). A slider too narrow for its label and value turns compact by itself, and drops the unit when even the value does not fit.
Sourcepub fn scrub(self) -> Self
pub fn scrub(self) -> Self
The scrub field: the label and the value in a plain field, with
no fill and no thumb, for a dense row (a HUD, a property sheet)
where the value matters more than where it sits in its range. The
slider’s gestures, keys, typed entry, menu, history and
accessibility stay: a drag along the field scrubs the value over
the soft range, whatever the field’s width, or at a set speed with
Slider::travel. Too narrow for its
label, it shows the value alone, as Slider::compact does.
Horizontal only: a vertical slider keeps its track.
Sourcepub fn travel(self, points: f32) -> Self
pub fn travel(self, points: f32) -> Self
Points of drag over the soft range, whatever the bar’s length: a
scrub field that moves at a set speed (a value’s sensitivity, its
soft range over so many points) rather than across its width. By
default the bar’s length; the fine and coarse modifiers still
scale it. As Knob::travel.
Whether a right click (or the context menu key) opens the value’s
menu: “Type a value”, and “Reset” with a default. On by default;
off for a host that gives the slider a menu of its own (its
“Type a value” item calls request_typed_entry).
Sourcepub fn on_change(self, hook: impl FnMut(&Change) -> Verdict + 'a) -> Self
pub fn on_change(self, hook: impl FnMut(&Change) -> Verdict + 'a) -> Self
Sees every change before it is written (module docs, “Hooks”).
Sourcepub fn quad(self, icon: Icon, label: &str) -> Self
pub fn quad(self, icon: Icon, label: &str) -> Self
A quad button at the end of the bar (a colour picker): its click
is in SliderOutput::quad_clicked. label names it.
Sourcepub fn quad_toggle(self, icon: Icon, label: &str, on: &'a mut bool) -> Self
pub fn quad_toggle(self, icon: Icon, label: &str, on: &'a mut bool) -> Self
A quad button toggling on (an effect on or off), lit when on.
Sourcepub fn show(self, ui: &mut Ui) -> SliderOutput
pub fn show(self, ui: &mut Ui) -> SliderOutput
Draws the slider; says what changed.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Slider<'a>
impl<'a> !RefUnwindSafe for Slider<'a>
impl<'a> !Send for Slider<'a>
impl<'a> !Sync for Slider<'a>
impl<'a> Unpin for Slider<'a>
impl<'a> UnsafeUnpin for Slider<'a>
impl<'a> !UnwindSafe for Slider<'a>
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more