A small monospaced line under a live demo that prints the parameters driving it (read from the same fields, never typed by hand), each also a number control.
El::caption_params puts it under the demo.
Installation
Components are distributed as source. Copy it and what it depends on into your project, then change it as you need:
cargo run --release --bin amenui -- add caption --to ../my-appFiles copied: src/widgets/caption.rs, src/widgets/mod.rs, src/widgets/number.rs
Usage
use amenui::widgets::{caption};
fn view() -> El<Msg> {
let (w, r) = (120.0_f32, 8.0_f32);
let spec = Spec { min: 0.0, max: 400.0, step: 1.0, decimals: 0, unit: "px" };
let params = [CaptionParam::new("width", w, spec), CaptionParam::new("radius", r, spec)];
space(w, 40.0).radius(r).fill(Paint::ACCENT).key("cap1/demo")
.caption_params("cap1", format!("rect(w={w:.0}, r={r:.0})"), ¶ms, Msg::Num)
}API
| Functions | caption |
|---|---|
| Props | key, formula (the line, written from the same fields the demo reads), params (CaptionParam: name, value, spec, draft), msg. |
| Files | src/widgets/caption.rs |
| Depends on | base, number |
| Response to fronts | nudge (a control: pushed as one piece by fronts, held and condensing at most to Look::legible_cap) |
| Recomposition | keyed labels recompose when their text changes |
Keyboard and accessibility
| States | rest; a number being typed (see number); a changed value recomposes its digits. |
|---|---|
| Keys and messages | msg(i, Edit) from parameter i's control. |
On the web every control is mirrored into the page as an element with its role and name, so screen readers and the browser's own focus see it (DESIGN.md §1.14).