tawasuyu

tawasuyu/llimphi

Sovereign retained-mode GPU UI framework in Rust (wgpu+vello+taffy+parley), Elm loop, 40+ widgets.

Rust 660Markdown 302TOML 157RON 312382 Definiciones

⎇ c5a232cf24788ab75a850ffe81eca5a7af50e2f8 llimphi-wasm-runner/examples/run_form.rs Rust · 48 líneas · 1.3 KB Historia Quién tocó qué crudo

chore: refresco desde el monorepo — 27 crates nuevos (anim, lottie, svg, mesh, image, layer, test, wire-view, widgets rag-sidebar/router/lazy-list/rive-button) y sync de los 95 existentes 93253cc22 · Sergio ·

1//! Corre la app WASM Tier 3 `form` (campo de texto + checkbox + saludo) en una
2//! ventana Llimphi. Clickea el campo para enfocarlo y teclea: el host rutea las
3//! teclas como eventos `Text` al guest, que es la fuente de verdad del texto.
4//!
5//! `cargo run -p llimphi-wasm-runner --example run_form --release`
6
7use llimphi_ui::{App, Handle, KeyEvent, View};
8use llimphi_wasm_runner::{RunnerMsg, WasmGuest};
9
10const FORM_WASM: &[u8] = include_bytes!("../assets/form.wasm");
11
12struct Host;
13
14impl App for Host {
15    type Model = WasmGuest;
16    type Msg = RunnerMsg;
17
18    fn title() -> &'static str {
19        "llimphi · wasm runner — form"
20    }
21
22    fn init(_: &Handle<Self::Msg>) -> Self::Model {
23        WasmGuest::load(FORM_WASM, 0).expect("cargar form.wasm")
24    }
25
26    fn update(mut model: Self::Model, msg: Self::Msg, _: &Handle<Self::Msg>) -> Self::Model {
27        if let Err(e) = model.apply(&msg) {
28            eprintln!("wasm dispatch: {e}");
29        }
30        model
31    }
32
33    fn view(model: &Self::Model) -> View<Self::Msg> {
34        model.render()
35    }
36
37    fn on_key(model: &Self::Model, event: &KeyEvent) -> Option<Self::Msg> {
38        model.key_to_msg(event)
39    }
40
41    fn on_focus(_model: &Self::Model, id: Option<u64>) -> Option<Self::Msg> {
42        Some(WasmGuest::focus_msg(id))
43    }
44}
45
46fn main() {
47    llimphi_ui::run::<Host>();
48}