Skip to main content

Crate dfui

Crate dfui 

Source
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 taffy;

Modules§

anim
Time-based transitions for values drawn in paint.
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.
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. view rebuilds the tree; framework-owned per-widget state survives rebuilds, keyed by tree position or key.
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 notify after changing data the view reads; widgets::watch rebuilds 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::scroll works 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 over blur.
Sleep
The future sleep returns.
State
Framework-owned per-widget state slot.
Text
Fonts plus lazily-built glyph outlines, rendered analytically on the GPU.
TextLayout
Theme
The colors widgets draw with. Return one from App::theme, or provide one 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 Theme color by name, resolved where the widget is painted.

Traits§

App
Root of the UI. State lives in stateful widgets and in external sources that builders read; view runs 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§

run
Opens a window showing app and runs until it’s closed. On the web it returns at once and the browser drives the app; on Android use run_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.