A small box floating over an area (picture in picture): drag it anywhere; let go, the throw's projected end picks the nearest corner and a spring takes it there.
Arrow keys move it between corners. Dragged, thrown and gliding, it leaves a trail in the field map (El::stirr; the preset sets how strong): decoration it passes loosens a little and drifts the way it went.
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 floating --to ../my-appFiles copied: src/widgets/floating.rs, src/gesture.rs, src/widgets/mod.rs
Usage
use amenui::widgets::{floating};
fn view() -> El<Msg> {
let mut f = Floating::default();
f.area = (300.0, 180.0);
f.size = (120.0, 72.0);
f.place(3);
layers([floating("fl1", &f, text("00:42", 12.0, Paint::TEXT).key("fl1/t"), Msg::Float)])
.width(300.0).height(180.0).radius(8.0).border(1.0, Paint::FAINT).clip()
}API
| Functions | floating |
|---|---|
| Props | key, floating (Floating: size, area, corner_inset, projection_decel, spring, rubber), content, msg. |
| Files | src/widgets/floating.rs, src/gesture.rs |
| Depends on | base |
| 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 | resting in a corner, dragged (captured until release), springing to a corner; arrow keys move it to the neighbouring corner when focused. |
|---|---|
| Keys and messages | msg(FloatMsg) for every drag step and arrow key; the application calls Floating::update with it and Floating::step on every tick while Floating::moving(). |
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).