Skip to main content

a2ui_egui/
lib.rs

1//! egui backend for A2UI.
2//!
3//! Translates an A2UI component tree (the flat `id → ComponentModel` map owned
4//! by [`a2ui_base::model`]) into egui immediate-mode widgets and bridges egui
5//! interactions back to the framework-agnostic interaction layer in `a2ui_base`.
6//!
7//! Unlike the ratatui backend (immediate-mode painting on a character grid with
8//! a manual measure pass) and the Slint backend (retained-mode, forced into a
9//! flat index-array + bounded-depth `Node0..N` chain because Slint can't
10//! recurse), egui is **native-recursive** and **auto-layouts**: the walker in
11//! [`walker`] recurses directly into a `&mut egui::Ui`, with no `build.rs` and
12//! no measure pass. Interactive components (TextField/Slider/CheckBox/…) use
13//! real egui widgets, bridged to the data-model-as-source-of-truth via the
14//! persistent [`edit_state::EditBuffers`] map.
15//!
16//! Everything here lives behind the `backend` cargo feature, which pulls in the
17//! egui + eframe runtime. Without it this crate is an empty shell (it compiles
18//! with no dependencies beyond `a2ui-base`), keeping the workspace's default
19//! build light.
20
21#![cfg_attr(not(feature = "backend"), allow(unused_imports))]
22
23#[cfg(feature = "backend")]
24pub mod app;
25#[cfg(feature = "backend")]
26pub mod components;
27#[cfg(feature = "backend")]
28pub mod edit_state;
29#[cfg(feature = "backend")]
30pub mod interaction;
31#[cfg(feature = "backend")]
32pub mod walker;
33
34/// The eframe app — owns the surface state and drives the immediate-mode render
35/// loop. Construct from the gallery (or any host) and hand to `eframe`.
36#[cfg(feature = "backend")]
37pub use app::EguiApp;
38
39/// Re-export the core interaction pieces backends compose against, so consumers
40/// can `use a2ui_egui::{dispatch_event, apply_event_result, ...}` in one place.
41#[cfg(feature = "backend")]
42pub use a2ui_base::components::dispatch_event;
43#[cfg(feature = "backend")]
44pub use a2ui_base::focus::FocusManager;
45#[cfg(feature = "backend")]
46pub use a2ui_base::interaction::apply_event_result;