Progress
表示确定或不确定的任务进度,可组合标签和轨道。
正在加载交互演示…
progress(0.4, 1.0).w(240.0).h(8.0).rounded(4.0)#导入
从 quickgui 导入 progress。
use quickgui::*;#用法
progress(0.4, 1.0).w(240.0).h(8.0).rounded(4.0)#结构
progress::rootprogress::trackprogress::indicatorprogress::labelprogress::value
#API 参考
展开条目查看说明和完整签名。短横线表示声明中未记录默认值。
Progress
查看源码pub fn new(value: f64, maximum: f64) -> SelfCreate 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—
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>—
maximumpub const fn maximum(&self) -> f64—
is_indeterminatepub 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) -> ElementDecorate an application-owned root without adding layout or appearance.
Progress::root
查看源码pub fn root(&self) -> ElementCreate the unstyled root part. Use [`Self::root_with`] to supply an existing element.
Progress::track_with
查看源码pub fn track_with(&self, track: Element) -> ElementDecorate 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) -> ElementCreate the unstyled track part. Use [`Self::track_with`] to supply an existing element.
Progress::indicator_with
查看源码pub fn indicator_with(&self, indicator: Element) -> ElementHide an application-owned fill or animation from the accessible name.
Progress::indicator
查看源码pub fn indicator(&self) -> ElementCreate the unstyled indicator part. Use [`Self::indicator_with`] to supply an existing element.
Progress::label_with
查看源码pub fn label_with(&self, label: Element) -> ElementAssign the stable mounted label target the root points at.
Progress::label
查看源码pub fn label(&self) -> ElementCreate the unstyled label part. Use [`Self::label_with`] to supply an existing element.
Progress::value
查看源码pub fn value(&self) -> ElementAssign 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) -> Elementprogress
查看源码pub fn progress(value: f64, maximum: f64) -> ElementCreate an unstyled determinate progress root. This shorthand is equivalent to `Progress::new(value, maximum).root_with(div())`.
