跳到正文

Progress

表示确定或不确定的任务进度,可组合标签和轨道。

正在加载交互演示…

#导入

从 quickgui 导入 progress。

use quickgui::*;

#用法

progress(0.4, 1.0).w(240.0).h(8.0).rounded(4.0)

#结构

  • progress::root
  • progress::track
  • progress::indicator
  • progress::label
  • progress::value

#API 参考

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

Progress

查看源码
pub fn new(value: f64, maximum: f64) -> Self

Create a determinate indicator between `0.0` and `maximum`. A non-finite or non-positive maximum falls back to `1.0`; the value is clamped into range.

fractionpub fn fraction(fraction: f64) -> Self—

Create a determinate indicator from a `0.0..=1.0` completion fraction.

pub fn fraction(fraction: f64) -> Self
查看源码
indeterminatepub fn indeterminate() -> Self—

Create an indicator for work whose completion is unknown.

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

Attach a human-readable value such as `"3 of 12 files"`. Assistive technology prefers this over the raw number when present. An empty string clears it. The text is not rendered; the application owns every visible label.

pub fn value_text(mut self, text: impl Into<Arc<str>>) -> Self
查看源码
idpub fn id(mut self, id: impl Into<ElementId>) -> Self—

Give this indicator a stable identity so its label and value parts can be related to it. Without an identity the parts are still decorated, but QuickGUI cannot point the root's accessible name and description at them, so the application supplies its own `accessibility_label`. Existing code that never declares an identity is unchanged.

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. The result is what [`Self::display_value`] returns for a caller-owned value part, and what assistive technology reads unless [`Self::value_text`] overrides it.

pub fn format(mut self, format: ValueFormat) -> Self
查看源码
statuspub fn status(&self) -> ProgressStatus—

Which of Base UI's three progress states this indicator is in.

pub fn status(&self) -> ProgressStatus
查看源码
statepub fn state(&self) -> ProgressPartState—

A copyable snapshot of what Base UI exposes as `data-*` attributes.

pub fn state(&self) -> ProgressPartState
查看源码
display_valuepub fn display_value(&self) -> Option<Arc<str>>—

The formatted text for a caller-owned value part, or `None` while indeterminate.

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. An explicit [`Self::value_text`] wins over [`Self::format`], matching Base UI's `getAriaValueText` precedence.

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

Stable identity of the label part, when this indicator 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 indicator 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 indicator 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 indicator declares one.

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

Configures current value for this part.

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

Configures maximum for this part.

pub const fn maximum(&self) -> f64
查看源码
is_indeterminatepub const fn is_indeterminate(&self) -> bool—

Configures is indeterminate for this part.

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

The `0.0..=1.0` completion fraction, or `None` while indeterminate. Applications use this to size a caller-owned fill.

pub fn completion(&self) -> Option<f32>
查看源码

Progress::root_with

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

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

Progress::root

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

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

Progress::track_with

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

Decorate the caller-owned track that the fill is measured inside. The track is decoration: the root already carries the numeric value and bounds, so the track and everything under it stay out of the accessible name.

Progress::track

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

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

Progress::indicator_with

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

Hide an application-owned fill or animation from the accessible name.

Progress::indicator

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

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

Progress::label_with

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

Assign the stable mounted label target the root points at.

Progress::label

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

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

Progress::value

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

Assign the stable mounted value target the root points at. Put [`Self::display_value`] inside it; QuickGUI never renders the text itself. Create the unstyled value text part.

Progress::value_with

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

progress

查看源码
pub fn progress(value: f64, maximum: f64) -> Element

Create an unstyled determinate progress root. This shorthand is equivalent to `Progress::new(value, maximum).root_with(div())`.