Expand description
Declarative UI framework that draws shapes, text and icons analytically in one wgpu shader.
Re-exports§
pub use anim::Animated;pub use path::Path;pub use path::Shape;pub use source::Cache;pub use source::Latest;pub use source::cached;pub use source::polled;pub use source::Wanted;pub use source::blocking;pub use wgpu;pub use taffy;
Modules§
- anim
- Time-based transitions for values drawn in
paint. - icons
- Line icons for common actions, drawn in a 24×24 box with 2 px strokes
and round ends, in the style of Lucide.
widgets::pageuses them; apps can too, withiconandicon_button. - kinetic
- Drag-to-scroll with fling, for widgets that scroll themselves.
- model
- Data behind lists, tables and trees, apart from the widgets that show it. Widgets ask a model how many items there are, for an item and for its key; they rebuild with the rest of the tree and diff rows by key.
- path
- Filled outlines drawn the same way as glyphs.
- source
- Async sources for builders: a fetch repeated on a schedule (
polled), blocking work moved to a thread (blocking), a stream collector that keeps only the newest item (Latest) and results kept by key across rebuilds (Cache,cached). - widgets
- Starter widget set. Composite widgets should be plain functions over these.
Structs§
- Bitmap
- Immutable RGBA8 pixels, cheap to clone and safe to build on any thread. Decoding is up to the app; the GPU copy lives until the last clone drops.
- BuildCx
- Color
- An sRGB color with straight alpha, each channel in 0..=1. Blending happens in sRGB, as in browsers.
- Element
- A retained node description.
viewrebuilds the tree; framework-owned per-widget state survives rebuilds, keyed by tree position orkey. - EventCx
- Focus
- How a widget takes keyboard focus; see
Widget::focus. - Font
- TrueType/OpenType font data. Fonts are told apart by address, so keep each
one in a
static; it is parsed on first use, and data that doesn’t parse draws in the default font. - Handle
- Typed reference to a stateful widget’s state, cheap to capture in handlers.
- Instant
- A measurement of a monotonically nondecreasing clock.
Opaque and useful only with
Duration. - Notifier
- Asks the UI to rebuild, from any thread: worker threads hold clones and
call
notifyafter changing data the view reads;widgets::watchrebuilds its subtree when that happens. Notifies before the UI exists, or several in a burst, cost one rebuild. - PaintCx
- Pixels
- A rendered frame: sRGB RGBA8, row-major.
- Placement
- Boxes
Widget::scrollworks from, logical px. - Rect
- An axis-aligned box in logical px, y growing downward.
- Scope
- Values provided by ancestors (
provide), innermost last. - Shadow
- A soft shadow: the shape’s box moved by
offset, its edge faded overblur. - Sleep
- The future
sleepreturns. - State
- Framework-owned per-widget state slot.
- Text
- Fonts plus lazily-built glyph outlines, rendered analytically on the GPU.
- Text
Layout - Theme
- The colors widgets draw with. Return one from
App::theme, orprovideone to restyle a subtree; the default is a light look.
Enums§
- Event
- Ink
- What a widget paints with: a fixed color, a theme role, or whatever contrasts with the button or surface around it.
- Key
- Keyboard
- The soft keyboard a text field asks for.
- Layer
- What a layer widget is laid out over.
- Role
- A
Themecolor by name, resolved where the widget is painted.
Traits§
- App
- Root of the UI. State lives in
statefulwidgets and in external sources that builders read;viewruns again whenever any of it changes. - Widget
- Primitive building block. Composite widgets are plain functions returning
Element; implement this only for new layout/paint/input behavior.
Functions§
- gpu
- The device and queue the window draws with, once it has them: textures for
Bitmap::from_texturecome from this device. It changes when the GPU is set up again, as on an Android resume. - hdr
- Whether the window shows HDR now: the app asked (
App::hdr) and the screen takes HDR10. Bitmap values above 1.0 are brighter than SDR white only then; otherwise they clip, so video should be tone-mapped. - run
- Opens a window showing
appand runs until it’s closed. On the web it returns at once and the browser drives the app; on Android userun_android. - sleep
- Completes after
d, on every platform including the web. Driven by the dfui event loop, so await it in builder sources, not on another runtime.
Type Aliases§
- OnChange
- A handler for the value a widget reports (a toggle’s state, a slider’s
value, a picked index), as widgets with an
on_changestore it.