kui-core
The headless model behind kui: a per-frame flat tree, flex layout, text shaping, events as data and a quad display list.
A Core owns one window's worth of state. Each frame the app rebuilds a
flat tree of NodeSpecs through a Ui, the core runs a clay-style flex
layout over it, shapes the text and emits a DisplayList of quads for a
renderer. Input arrives as InputEvents and comes back out as UiEvents
whose payloads are plain-data Values. There is no window, no GPU and no
clock in this crate. Most Rust apps use kui-native, which re-exports all
of kui-core; depend on kui-core directly for a custom runner, a binding
to another language, or headless tests.
Install
Features: devtools (default) draws the inspector panel on request;
derive re-exports #[derive(Message)]; conformance enables the scene
corpus and the headless test driver (test infrastructure only).
Example
A frame built and clicked with no window at all:
use ;
let mut core = new;
core.set_inspect; // keep a readable snapshot of each finished frame
// One frame: begin, declare the tree, finish (layout and emission).
let mut ui = core.frame;
ui.configure_root;
ui.text;
button;
ui.finish;
// What a renderer draws: a flat list of quads.
let = core.output;
assert!;
// Input goes in as `InputEvent`s and comes out as `UiEvent`s carrying
// the payload the view declared.
let button = core
.nodes
.into_iter
.find
.expect;
core.handle_input;
core.handle_input;
let events = core.handle_input;
assert!;
Where it fits
| Crate | What it is |
|---|---|
| kui-core | The model: tree, layout, text, events, display list (this crate) |
| kui-wgpu | The renderer: draws a DisplayList with wgpu |
| kui-native | The windowed runner most Rust apps use; re-exports kui-core |
| kui-derive | #[derive(Message)] for typed payloads |
| kui-lua | Lua binding |
| kui-ffi | C binding |
| kui-node (npm) | Node binding |
Documentation
- API reference: https://docs.rs/kui-core
- The book: https://kui-book.qxuken.dev
- Repository: https://github.com/qxuken/kui
License
MIT