Add a declarative <ProgressBar> for displaying task progress. The widget takes a normalized value in [0.0 … 1.0], optional text, and common UX options like percentage display, width hint, disabled state, and tooltip.
- Covers a ubiquitous “in-progress” UI pattern for downloads, imports, long-running jobs.
- Keeps templates concise and consistent with EFx’s attribute model.
- Plays well with live updates in native and
wasm32-unknown-unknown builds.
Scope
- Tag:
<ProgressBar>
- Required:
value={number_expr} (float in 0..=1; clamped at render if out of range).
- Optional attributes:
text="...", showPercentage=bool, desiredWidth=f32, enabled=bool, tooltip="...", id="...".
- Events: none (display-only), but the
Response should allow hover tooltips.
- Children: none (text is via
text="...").
Non-goals (here): indeterminate/animated barber-pole, custom colors/skins.
Proposed API (sketch)
Template
efx!(ui, r#"
<ProgressBar value={job.progress} text="Importing…" showPercentage="true" desiredWidth="240"/>
"#);
Conceptual mapping to egui
let v = (value as f32).clamp(0.0, 1.0);
let mut pb = egui::ProgressBar::new(v);
if let Some(t) = text { pb = pb.text(t); }
if show_percentage { pb = pb.show_percentage(); }
if let Some(w) = desired_width { pb = pb.desired_width(w); }
let resp = if enabled { ui.add(pb) } else { ui.add_enabled(false, pb) };
if let Some(tip) = tooltip { resp.on_hover_text(tip); }
Tasks
Add a declarative
<ProgressBar>for displaying task progress. The widget takes a normalizedvaluein [0.0 … 1.0], optional text, and common UX options like percentage display, width hint, disabled state, and tooltip.wasm32-unknown-unknownbuilds.Scope
<ProgressBar>value={number_expr}(float in 0..=1; clamped at render if out of range).text="...",showPercentage=bool,desiredWidth=f32,enabled=bool,tooltip="...",id="...".Responseshould allow hover tooltips.text="...").Non-goals (here): indeterminate/animated barber-pole, custom colors/skins.
Proposed API (sketch)
Template
Conceptual mapping to egui
Tasks
AST & parsing
<ProgressBar>node with attributes:value,text,showPercentage,desiredWidth,enabled,tooltip,id.textattribute and children are supplied (children not allowed).Codegen
value={expr}(float-like), clamp to[0.0, 1.0]at render time.text,showPercentage,desiredWidth,enabled,tooltip,idto the egui builder andResponse.Diagnostics
value→ clear compile error with expected signature.value→ type error with hint.<ProgressBar>doesn’t take children; usetext="...".Examples & docs
examples/progress_bar.rs: simulated task updatingprogressover time; with/without percentage.docs/cookbook.mdand entry todocs/tags.md.Tests
value, wrong type, children supplied, unknown attrs.wasm32-unknown-unknown(no runtime launch).