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
impl Gauge
Sourcepub fn range(self, min: f32, max: f32) -> Self
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.
Sourcepub fn label(self, label: impl Into<String>) -> Self
pub fn label(self, label: impl Into<String>) -> Self
A name drawn before the meter, e.g. “Memory”.
Sourcepub fn label_width(self, cells: u16) -> Self
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 ….
Sourcepub fn value_text(self, text: impl Into<String>) -> Self
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”.
Sourcepub fn thresholds(self, warning: f32, danger: f32) -> Self
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§
impl StructuralPartialEq for Gauge
Source§impl<Msg: 'static> Widget<Msg> for Gauge
impl<Msg: 'static> Widget<Msg> for Gauge
Source§fn measure(&self, _cx: &mut MeasureCx<'_>, available: Size) -> Size
fn measure(&self, _cx: &mut MeasureCx<'_>, available: Size) -> Size
available.Source§fn paint_overlay(&self, _cx: &mut PaintCx<'_>, _anchor: Rect)
fn paint_overlay(&self, _cx: &mut PaintCx<'_>, _anchor: Rect)
PaintCx::request_overlay. anchor is the area the widget was painted in.Source§fn event(&self, _cx: &mut EventCx<'_, Msg>, _event: &Event) -> bool
fn event(&self, _cx: &mut EventCx<'_, Msg>, _event: &Event) -> bool
true when the event was used; unused key and scroll events
bubble to the parent widget.Source§fn children_mut(&mut self) -> &mut [Node<Msg>]
fn children_mut(&mut self) -> &mut [Node<Msg>]
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> 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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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