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
//! **Experimental.** Flexbox UI *layout* and pointer *hit-testing* for the
//! Gizmo ECS — this crate computes geometry and interaction state, and draws
//! nothing at all.
//!
//! `gizmo-ui` builds on [`taffy`] for layout and integrates with the Gizmo ECS.
//! UI elements are entities carrying components such as [`Style`] (layout),
//! [`Node`] (computed geometry), [`BackgroundColor`] and [`Interaction`].
//! Spawn them via the [`NodeBundle`] and [`ButtonBundle`] bundles.
//!
//! [`taffy`] is an **implementation detail**: no taffy type appears in this
//! crate's API. [`Style`] is our own plain-old-data type built from [`Val`]
//! lengths and [`UiRect`]s, and it is translated into a taffy style in exactly
//! one place, inside [`UiContext`]. (Before 0.9 `Style` was a newtype that
//! deref'd to `taffy::style::Style`, and the prelude glob-re-exported taffy's
//! `style` and `geometry` modules; both are gone.)
//!
//! Add `UiPlugin` to an `App` to register the components and run the layout
//! and interaction systems each frame, or call [`register`] to do the same on a
//! bare `World`/`Schedule` without `gizmo-app`. Common types are re-exported
//! from the [`prelude`] module.
//!
//! (`UiPlugin` is behind the non-default `app` feature, so it is deliberately not
//! an intra-doc link here — the link would not resolve in a default `cargo doc`.)
//!
//! # What works
//!
//! Two systems, and they do what their names say:
//!
//! - `ui_layout_system` (`system.rs`) mirrors every entity carrying a [`Style`]
//! into the layout tree held by [`UiContext`], computes layout for each root
//! against the current `WindowInfo` size, and writes the result back into
//! [`Node`] as **absolute** window-pixel `position` + `size` (ancestor offsets
//! are accumulated; the engine's own locations are parent-relative). Entities
//! that lose their [`Style`] have their layout node reclaimed.
//! - `ui_interaction_system` (`interaction.rs`) hit-tests the mouse position
//! from `Input` against each [`Node`]'s half-open `[pos, pos + size)` box and
//! sets [`Interaction`] to `None` / `Hovered` / `Pressed`.
//!
//! The crate carries 27 unit tests covering exactly those two things plus the
//! [`Style`] → taffy conversion: layout write-back, node lifecycle, length
//! conversion, the hit-test predicate and the interaction state machine. That
//! is the part you can rely on.
//!
//! # What does NOT work
//!
//! **This crate emits no vertices and no draw calls.** Its dependencies are
//! `gizmo-core`, `gizmo-math`, `taffy` and (optionally, `app` feature)
//! `gizmo-app` with default features off — no renderer, no `wgpu`. Grepping
//! `src/` for `wgpu`, `vertex`, `draw`, `shader`, `texture`, `font` or `glyph`
//! matched nothing but this paragraph. Concretely:
//!
//! - **There is no text rendering** — no `Text` component, no font loading, no
//! glyph rasterisation, neither here nor in `gizmo-renderer`. This is the
//! single largest missing piece and the reason this crate is labelled
//! experimental (tracked as D7 in the repository's `docs/FIXPLAN.md`).
//! - **[`BackgroundColor`] is written and never read.** The bundles attach it,
//! and no crate in this workspace consumes it. The only consumer of
//! `gizmo-ui` in the workspace at all is the facade's `pub use gizmo_ui as
//! ui` re-export.
//! - **No z-order or occlusion.** The hit-test is a flat loop over every
//! [`Node`], so two overlapping elements both report `Hovered`. The
//! limitation is noted inline in `interaction.rs`.
//! - **No click/focus events, no keyboard handling, no scrolling, no clipping,
//! no text input.** [`Interaction`] is a per-frame recomputed state, not an
//! event stream.
//! - **No CSS Grid.** [`Style`] models the flexbox/block surface only; taffy's
//! grid algorithm is compiled in but unreachable, because there is no way to
//! express `display: grid` or a track template. The full list of taffy
//! properties this crate does not model is in the [`Style`] docs.
//! - A UI entity whose `Parent` is *not* itself a styled UI entity gets no
//! layout: root selection is "has no `Parent` component", and only styled
//! parents get their children attached to the layout tree, so such a subtree
//! is in no root's layout pass and its [`Node`] stays stale. Read from the
//! code, not measured — no test covers it.
//!
//! # What it is good for, and what to use instead
//!
//! Use `gizmo-ui` when you want the engine to solve box geometry and hover/press
//! state for you and you intend to do the drawing yourself: read [`Node`] and
//! [`BackgroundColor`] from your own render pass. Layout and hit-testing are the
//! product here; pixels are your problem.
//!
//! If you want a HUD that is actually visible today, use the `egui` integration
//! in `gizmo-engine` (the `egui` feature, and the `editor` feature on top of
//! it). That path does render, text included, and it does not go through this
//! crate.
//!
//! Note that `gizmo-engine` enables its `ui` feature **by default**, so these
//! types arrive in `gizmo::prelude::*` whether or not you asked for them. Their
//! presence in the prelude is not evidence that anything is being drawn.
//!
//! # Stability
//!
//! Experimental, in the 0.x sense: expect the component set to change when
//! rendering lands (a `Text` component and a draw-list output are the obvious
//! additions). Nothing here is deprecated and nothing is scheduled for removal —
//! the label is about how much of a UI toolkit this is, not about its lifespan.
use ;
use World;
pub use *;
pub use *;
pub use *;
/// Registers the UI components + [`UiContext`] resource and schedules the layout
/// and interaction systems on a [`World`]/[`Schedule`] directly.
///
/// This is the **dependency-light** entry point — it needs only `gizmo-core`, so
/// `gizmo-ui` works as a pure ECS-UI layer without `gizmo-app`. The `app`-feature
/// `UiPlugin` (feature `app`) is a thin wrapper over this.
/// Plugin that registers the UI components and schedules the layout and
/// interaction systems (via [`register`]). Requires the `app` feature.
;
/// Re-exports of the most commonly used UI types.
///
/// Everything here is defined by this crate. `taffy`'s style and geometry
/// modules used to be glob-re-exported from this prelude, which made a
/// third-party layout engine part of the public API; the POD [`Style`] type
/// replaced them and the globs are gone.