1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
//! mirui — a `no_std`, ECS-driven UI framework for embedded, mobile,
//! desktop, Linux, and WebAssembly targets. Layout, hit testing, and draw geometry
//! use 24.8 fixed point before submission to the software framebuffer,
//! SDL GPU, WGPU, Web Canvas, Linux framebuffer/DRM, and NuttX backends.
//!
//! # Quick Start
//!
//! ```toml
//! [dependencies]
//! mirui = { version = "0.46", features = ["sdl"] }
//! ```
//!
//! The snippet below builds against mirui's default features and is
//! verified by `cargo test --doc`. Swap `FramebufSurface` for
//! `mirui::surface::sdl::SdlSurface::new("hello", 480, 320)` (with the
//! `sdl` feature) to run on a desktop window instead of into a
//! user-supplied flush callback.
//!
//! ```no_run
//! use mirui::prelude::*;
//! use mirui::surface::framebuf::FramebufSurface;
//! use mirui::render::texture::ColorFormat;
//! use mirui::types::PhysicalRect;
//!
//! let backend = FramebufSurface::with_format(
//! 480, 320, ColorFormat::RGBA8888,
//! |_bytes: &[u8], _area: PhysicalRect| { /* push to your display */ },
//! );
//! let mut app = App::new(backend);
//! app.with_default_widgets().with_default_systems();
//!
//! let root = app.spawn_root().id();
//!
//! ui! {
//! :(
//! parent: root
//! world: &mut app.world
//! :)
//!
//! header (
//! bg_color: ColorToken::Primary,
//! text_color: ColorToken::OnPrimary,
//! text: "Hello mirui!",
//! border_radius: 8
//! ) {}
//! };
//!
//! app.run();
//! ```
//!
//! # Other targets
//!
//! mirui also runs in browsers through Web Canvas, on Android and iOS
//! through direct WGPU or bounded software rasterization, on Linux
//! framebuffer/DRM devices, on NuttX, and on bare-metal RISC-V and ARM
//! Cortex-M MCUs through [`surface::framebuf::FramebufSurface`]. The
//! mobile, ESP32-C3, and multi-target walkthrough lives in
//! [`docs/quickstart.md`][quickstart].
//!
//! [quickstart]: https://github.com/W-Mai/mirui/blob/main/docs/quickstart.md
//!
//! # Module map
//!
//! - [`app`]: the [`App`][app::App] entry point, the [`Plugin`][app::plugin::Plugin]
//! trait, and bundled plugins.
//! - [`core`]: cross-cutting infrastructure — cache, resource, the
//! [`reactive`][core::reactive] runtime (Signal / Computed / Effect),
//! perf tracing, timer.
//! - [`ecs`]: World, Entity, Component, Resource, Query, System, SystemScheduler.
//! - [`ui`]: widget tree primitives (Style, View, Theme, Dirty),
//! [`ui::layout`] (flexbox + absolute positioning), and [`ui::widgets`]
//! (built-in widget instances — buttons, sliders, lazy lists, effects).
//! - [`render`]: software rasterizer, paths, textures, draw commands, font,
//! and concrete [`render::backends`] (sw / sdl_gpu / wgpu / web_canvas).
//! - [`input`]: input dispatch, gestures, hit-testing, focus,
//! and visual [`input::feedback`] overlays.
//! - [`surface`]: backend trait + bundled SDL2 / framebuffer / SDL_GPU /
//! wgpu / web_canvas / Linux / NuttX implementations.
//! - [`text`]: bounded Unicode layout, shaping contracts, and font-format adapters.
//! - [`anim`]: easing, springs, motion components.
//! - [`types`]: Color / Dimension / Fixed / Point / Rect / Transform / Viewport.
extern crate alloc;
// Lets `trace_span!` / `trace_fn` expand to `mirui::core::perf::enter(...)`
// uniformly — the crate has to be able to refer to itself by name
// for the absolute path to resolve in our own modules.
extern crate self as mirui;
pub use ;
// Re-export so `ui!`-generated code references `Rc` through `mirui`, working in
// both std and no_std user crates without an `extern crate alloc` of their own.
pub use Cell as __Cell;
pub use RefCell as __RefCell;
pub use Cow as __Cow;
pub use Rc as __Rc;
pub use Vec as __Vec;
/// Glob-imports the types and macros nearly every application file
/// needs. Default prelude — `use mirui::prelude::*;`.
///
/// Sub-preludes for less common surfaces:
///
/// - [`prelude::plugin`] for writing custom [`Plugin`][app::plugin::Plugin]s
/// - [`prelude::backend`] for picking / wiring a [`Surface`][surface::Surface]
/// - [`prelude::draw`] for emitting [`DrawCommand`][render::DrawCommand]s
/// from a custom widget view