pub struct Knob<'a> { /* private fields */ }Expand description
A rotary knob over an f64.
Need (input): a rotary knob.
Implementations§
Source§impl<'a> Knob<'a>
impl<'a> Knob<'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 knob spanning soft, which is also its hard range until
Knob::hard widens it.
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 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, as the slider’s hook.
Sourcepub fn size(self, size: Vec2) -> Self
pub fn size(self, size: Vec2) -> Self
Its room, in points (a slot). By default two rows high and as wide as the dial with its label and value beside it.
Sourcepub fn drag(self, mode: KnobDrag) -> Self
pub fn drag(self, mode: KnobDrag) -> Self
How a drag turns this knob, over the pointer profile’s
(options.knob_drag).
Sourcepub fn wheel(self, wheel: KnobWheel) -> Self
pub fn wheel(self, wheel: KnobWheel) -> Self
When the wheel turns this knob; by default as the pointer profile says.
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 knob a menu of its own (its “Type a
value” item calls request_typed_entry).
Sourcepub fn endless(self, ends: Endless) -> Self
pub fn endless(self, ends: Endless) -> Self
An endless knob: a face with no arc and no ends, ticks turning
with the value (one turn over the soft range), driven by the same
drag modes, travel, wheel and keys; its value wraps or has no
bounds (Endless), and each Change carries the motion in
delta, for a host that maps it to nudges (an encoder’s
increments). Home and End do nothing on it; a circular drag’s full
turn is the soft range. Its bar is always linear.
Sourcepub fn hide_pointer(self, on: bool) -> Self
pub fn hide_pointer(self, on: bool) -> Self
Whether a drag hides the pointer and, at its end, puts it back
where the press was, so a long drag is not stopped by the edge of
the screen and the pointer does not wander off the knob; by
default the pointer profile’s sliders’ gestures say
(Gestures::knob_hide_pointer, off). Only in the linear modes:
a circular drag follows the pointer around the dial, which stays
in view. Where the platform refuses (module docs, “Hidden
pointer”), the pointer stays visible or reappears where the drag
ended.
Sourcepub fn travel(self, points: f32) -> Self
pub fn travel(self, points: f32) -> Self
Points of drag over the soft range, in the linear modes
(Vertical, Horizontal, Both), whatever the knob’s size.
Sourcepub fn show(self, ui: &mut Ui) -> SliderOutput
pub fn show(self, ui: &mut Ui) -> SliderOutput
Draws the knob; says what changed.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Knob<'a>
impl<'a> !RefUnwindSafe for Knob<'a>
impl<'a> !Send for Knob<'a>
impl<'a> !Sync for Knob<'a>
impl<'a> Unpin for Knob<'a>
impl<'a> UnsafeUnpin for Knob<'a>
impl<'a> !UnwindSafe for Knob<'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