Skip to main content

Knob

Struct Knob 

Source
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>

Source

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.

Source

pub fn hard(self, hard: RangeInclusive<f64>) -> Self

The range a typed value may reach (it always holds the soft range).

Source

pub fn step(self, step: f64) -> Self

The step of arrows and the wheel; also sets the precision.

Source

pub fn coarse(self, coarse: f64) -> Self

The coarse step (Shift, Page Up and Page Down).

Source

pub fn unit(self, unit: &str) -> Self

Shown after the value (EV, %).

Source

pub fn precision(self, decimals: usize) -> Self

Digits after the decimal separator.

Source

pub fn display_scale(self, scale: f64) -> Self

Shown and typed as value * scale (a fraction as a percentage: 100).

Source

pub fn integer(self) -> Self

Whole numbers only.

Source

pub fn signed(self) -> Self

A plus sign before positive values (+1.50 EV).

Source

pub fn logarithmic(self) -> Self

A logarithmic bar (Curve::Logarithmic).

Source

pub fn gradient(self, gradient: Gradient) -> Self

The track painted with a gradient (hue, temperature) along the bar.

Source

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.

Source

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.

Source

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.

Source

pub fn ramp_with(self, ramp: Ramp) -> Self

A colour ramp built beforehand.

Source

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.

Source

pub fn default(self, default: f64) -> Self

What a double click goes back to.

Source

pub fn on_change(self, hook: impl FnMut(&Change) -> Verdict + 'a) -> Self

Sees every change before it is written, as the slider’s hook.

Source

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.

Source

pub fn drag(self, mode: KnobDrag) -> Self

How a drag turns this knob, over the pointer profile’s (options.knob_drag).

Source

pub fn wheel(self, wheel: KnobWheel) -> Self

When the wheel turns this knob; by default as the pointer profile says.

Source

pub fn menu(self, on: bool) -> Self

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).

Source

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.

Source

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.

Source

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.

Source

pub fn show(self, ui: &mut Ui) -> SliderOutput

Draws the knob; says what changed.

Trait Implementations§

Source§

impl<'a> Debug for Knob<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Widget for Knob<'_>

Source§

fn ui(self, ui: &mut Ui) -> Response

Allocate space, interact, paint, and return a [Response]. Read more
§

fn boxed<'a>(self) -> Box<dyn FnOnce(&mut Ui) -> Response + 'a>
where Self: Sized + 'a,

Box this widget for dynamic dispatch.

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

§

fn simd_from(_simd: S, value: T) -> T

§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

§

fn simd_into(self, simd: S) -> T

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,