Skip to main content

Gauge

Struct Gauge 

Source
pub struct Gauge { /* private fields */ }
Expand description

A one-row meter for a value in a range: label, meter and value.

The meter fills in eighths of a cell (whole cells in ASCII mode). With thresholds the fill takes the success, warning or danger tone by value, the parts of the track past each threshold are tinted faintly so the limits are visible before they are reached, and the value carries a marker so the state reads without colour. The value shows a percentage of the range unless a text is given. When the area is too narrow for a meter, only the label and value remain.

A gauge is a readout, not a control: its one value is always written beside the meter, so there is nothing a pointer or a key could move to. It takes no keyboard focus and answers no input. To let someone set the value, use a Slider; to explain a label that had to be cut, wrap the gauge in a Tooltip; to read a value out of a history, use a Sparkline.

Style keys: gauge and gauge.<success|warning|danger> (track, fill, zone for the tint past a threshold), gauge-label (fg), gauge-value and gauge-value.<level> (fg, bold).

Implementations§

Source§

impl Gauge

Source

pub fn new(value: f32) -> Self

A gauge at value in the range 0 to 100.

Source

pub fn range(self, min: f32, max: f32) -> Self

The range the value lives in, e.g. 0.0, 64.0 for gibibytes of memory.

Source

pub fn label(self, label: impl Into<String>) -> Self

A name drawn before the meter, e.g. “Memory”.

Source

pub fn label_width(self, cells: u16) -> Self

Reserves cells for the label, so gauges stacked with different labels line up. Longer labels are cut with .

Source

pub fn value_text(self, text: impl Into<String>) -> Self

Text drawn after the meter instead of the percentage, e.g. “6.2 of 8 GiB”.

Source

pub fn thresholds(self, warning: f32, danger: f32) -> Self

From warning the gauge turns to the warning tone, from danger to the danger tone; below both it is in the success tone. Values are in the gauge’s range.

Trait Implementations§

Source§

impl Clone for Gauge

Source§

fn clone(&self) -> Gauge

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Gauge

Source§

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

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

impl PartialEq for Gauge

Source§

fn eq(&self, other: &Gauge) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Gauge

Source§

impl<Msg: 'static> Widget<Msg> for Gauge

Source§

fn measure(&self, _cx: &mut MeasureCx<'_>, available: Size) -> Size

The size the widget wants when it may use up to available.
Source§

fn paint(&self, cx: &mut PaintCx<'_>, area: Rect)

Draws the widget into area.
Source§

fn paint_overlay(&self, _cx: &mut PaintCx<'_>, _anchor: Rect)

Draws the widget’s overlay after the whole view was painted, when it asked for one with PaintCx::request_overlay. anchor is the area the widget was painted in.
Source§

fn event(&self, _cx: &mut EventCx<'_, Msg>, _event: &Event) -> bool

Handles input. Returns true when the event was used; unused key and scroll events bubble to the parent widget.
Source§

fn focusable(&self) -> bool

Whether the widget can take keyboard focus.
Source§

fn children(&self) -> &[Node<Msg>]

Child nodes, for widgets that contain other widgets.
Source§

fn children_mut(&mut self) -> &mut [Node<Msg>]

Mutable child nodes, used to assign ids.

Auto Trait Implementations§

§

impl Freeze for Gauge

§

impl RefUnwindSafe for Gauge

§

impl Send for Gauge

§

impl Sync for Gauge

§

impl Unpin for Gauge

§

impl UnsafeUnpin for Gauge

§

impl UnwindSafe for Gauge

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.