跳到正文

Meter

显示已知范围内的标量测量值,并带有语义化的低值、高值和最佳区间。

正在加载交互演示…

#导入

从 quickgui 导入 meter。

use quickgui::*;

#用法

meter(70.0, 0.0, 100.0).w(240.0).h(8.0)

#结构

  • meter::root
  • meter::track
  • meter::indicator
  • meter::label
  • meter::value

#API 参考

展开条目查看说明和完整签名。短横线表示声明中未记录默认值。

pub fn new(value: f64, minimum: f64, maximum: f64) -> Self

Create a meter. Non-finite bounds fall back to `0.0..=1.0` and an inverted range is swapped.

lowpub fn low(mut self, low: f64) -> Self—

Mark the upper end of the low range. Values outside the meter bounds are clamped.

pub fn low(mut self, low: f64) -> Self
查看源码
highpub fn high(mut self, high: f64) -> Self—

Mark the lower end of the high range.

pub fn high(mut self, high: f64) -> Self
查看源码
optimumpub fn optimum(mut self, optimum: f64) -> Self—

Mark the most favorable value inside the range.

pub fn optimum(mut self, optimum: f64) -> Self
查看源码
idpub fn id(mut self, id: impl Into<ElementId>) -> Self—

Give this meter a stable identity so its label and value parts can be related to it.

pub fn id(mut self, id: impl Into<ElementId>) -> Self
查看源码
formatpub fn format(mut self, format: ValueFormat) -> Self—

Attach a bounded value formatter, Base UI's `format` prop.

pub fn format(mut self, format: ValueFormat) -> Self
查看源码
value_textpub fn value_text(mut self, text: impl Into<Arc<str>>) -> Self—

Attach a human-readable value that assistive technology prefers over the raw number. This is Base UI's `getAriaValueText`; an empty string clears it. It wins over [`Self::format`].

pub fn value_text(mut self, text: impl Into<Arc<str>>) -> Self
查看源码
display_valuepub fn display_value(&self) -> Option<Arc<str>>—

The formatted text for a caller-owned value part.

pub fn display_value(&self) -> Option<Arc<str>>
查看源码
accessible_valuepub fn accessible_value(&self) -> Option<Arc<str>>—

The text assistive technology reads for the value, if any.

pub fn accessible_value(&self) -> Option<Arc<str>>
查看源码
label_idpub fn label_id(&self) -> Option<ElementId>—

Stable identity of the label part, when this meter declares one.

pub fn label_id(&self) -> Option<ElementId>
查看源码
value_idpub fn value_id(&self) -> Option<ElementId>—

Stable identity of the value part, when this meter declares one.

pub fn value_id(&self) -> Option<ElementId>
查看源码
track_idpub fn track_id(&self) -> Option<ElementId>—

Stable identity of the track part, when this meter declares one.

pub fn track_id(&self) -> Option<ElementId>
查看源码
indicator_idpub fn indicator_id(&self) -> Option<ElementId>—

Stable identity of the indicator part, when this meter declares one.

pub fn indicator_id(&self) -> Option<ElementId>
查看源码
current_valuepub const fn current_value(&self) -> f64—

Configures current value for this part.

pub const fn current_value(&self) -> f64
查看源码
minimumpub const fn minimum(&self) -> f64—

Configures minimum for this part.

pub const fn minimum(&self) -> f64
查看源码
maximumpub const fn maximum(&self) -> f64—

Configures maximum for this part.

pub const fn maximum(&self) -> f64
查看源码
low_valuepub const fn low_value(&self) -> Option<f64>—

Configures low value for this part.

pub const fn low_value(&self) -> Option<f64>
查看源码
high_valuepub const fn high_value(&self) -> Option<f64>—

Configures high value for this part.

pub const fn high_value(&self) -> Option<f64>
查看源码
optimum_valuepub const fn optimum_value(&self) -> Option<f64>—

Configures optimum value for this part.

pub const fn optimum_value(&self) -> Option<f64>
查看源码
completionpub fn completion(&self) -> f32—

The `0.0..=1.0` position of the value inside the meter's range.

pub fn completion(&self) -> f32
查看源码
is_lowpub fn is_low(&self) -> bool—

Whether the value falls at or below [`Self::low`].

pub fn is_low(&self) -> bool
查看源码
is_highpub fn is_high(&self) -> bool—

Whether the value falls at or above [`Self::high`].

pub fn is_high(&self) -> bool
查看源码

Meter::root_with

查看源码
pub fn root_with(&self, root: Element) -> Element

Decorate an application-owned root without adding layout or appearance.

Meter::root

查看源码
pub fn root(&self) -> Element

Create the unstyled root part. Use [`Self::root_with`] to supply an existing element.

Meter::track_with

查看源码
pub fn track_with(&self, track: Element) -> Element

Decorate the caller-owned track that the fill is measured inside.

Meter::track

查看源码
pub fn track(&self) -> Element

Create the unstyled track part. Use [`Self::track_with`] to supply an existing element.

Meter::indicator_with

查看源码
pub fn indicator_with(&self, indicator: Element) -> Element

Hide an application-owned fill from the accessible name.

Meter::indicator

查看源码
pub fn indicator(&self) -> Element

Create the unstyled indicator part. Use [`Self::indicator_with`] to supply an existing element.

Meter::label_with

查看源码
pub fn label_with(&self, label: Element) -> Element

Assign the stable mounted label target the root points at.

Meter::label

查看源码
pub fn label(&self) -> Element

Create the unstyled label part. Use [`Self::label_with`] to supply an existing element.

Meter::value

查看源码
pub fn value(&self) -> Element

Assign the stable mounted value target the root points at. Create the unstyled value text part.

Meter::value_with

查看源码
pub fn value_with(&self, value: Element) -> Element
pub fn meter(value: f64, minimum: f64, maximum: f64) -> Element

Create an unstyled meter root. This shorthand is equivalent to `Meter::new(value, minimum, maximum).root_with(div())`.