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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
//! # `pane_ui`
//!
//! A RON-driven, hot-reloadable UI library for [wgpu](https://github.com/gfx-rs/wgpu).
//!
//! Define your entire UI in a `.ron` file. No layout code, no style code, no wiring code.
//! Edit the file while your app runs and the UI updates instantly — menus, styles, and
//! shaders alike. Your game loop stays untouched.
//!
//! ---
//!
//! ## Modes
//!
//! Choose the integration that fits your architecture:
//!
//! | Mode | Owns window? | GPU required? | Use when |
//! |------|:---:|:---:|---|
//! | [`run`] | ✅ | ✅ | Pane IS the app |
//! | [`overlay`] / [`PaneOverlay`] | ❌ | ✅ | Compositing onto your renderer |
//! | [`headless`] / [`PaneHeadless`] | ❌ | ❌ | Tests, servers, CI |
//!
//! ### Standalone
//!
//! Pane owns the window and event loop entirely.
//!
//! ```no_run
//! // Simplest — one line, no callbacks
//! pane::run("assets/menu.ron");
//!
//! // With callback — handle actions and call write/toast each frame
//! pane::run_with("assets/menu.ron", |ui, action| {
//! if let pane::PaneAction::Custom(ref id) = action {
//! if id == "save" { ui.push_toast("Saved!", 2.0, 0.0, -400.0, 300.0, 60.0); }
//! }
//! });
//! ```
//!
//! ### Overlay
//!
//! Composites onto your existing wgpu renderer. You keep your device, queue, and loop.
//!
//! ```ignore
//! // Startup — pass Some(gilrs) to share your gamepad context, or None to auto-create one
//! let mut ui = pane::overlay("assets/hud.ron", &device, &queue, format, None);
//!
//! // In your event loop
//! ui.handle_event(&event, window_width, window_height);
//!
//! // In your render pass — call after your own draw commands
//! for action in ui.draw(&mut encoder, &view, pw, ph) {
//! match action {
//! pane::PaneAction::Custom(tag) => println!("button: {tag}"),
//! pane::PaneAction::Slider(id, val) => println!("{id} = {val:.2}"),
//! pane::PaneAction::Toggle(id, checked) => println!("{id} = {checked}"),
//! pane::PaneAction::Quit => std::process::exit(0),
//! _ => {}
//! }
//! }
//! ```
//!
//! ### Headless
//!
//! No GPU, no window. Useful for testing UI logic in CI or driving a server-side state machine.
//!
//! ```no_run
//! let mut menu = pane::headless("assets/menu.ron");
//! menu.press("play_button");
//! let actions = menu.update(1.0 / 60.0);
//! ```
//!
//! ---
//!
//! ## Coordinate System
//!
//! Pane uses a **centered, resolution-independent** coordinate system:
//!
//! - `(0.0, 0.0)` is always the center of the screen
//! - The screen height is always `1080` units regardless of actual resolution
//! - Width scales proportionally — widescreen just adds space on the sides
//! - Positive Y is downward
//!
//! A button at `x: -170.0, y: 0.0` is centered vertically on every screen.
//! You never write resolution-specific layout.
//!
//! ---
//!
//! ## Widgets
//!
//! 15 built-in widget types, all defined in RON:
//!
//! `Button` · `Toggle` · `Slider` · `TextBox` · `Dropdown` · `RadioGroup` ·
//! `ScrollList` · `ScrollPane` · `Bar` · `Popout` · `Label` · `Divider` ·
//! `Image` · `ProgressBar` · `Tabs`
//!
//! Plus `Actor` — a non-interactive animated element that follows the cursor
//! or moves to programmatic targets.
//!
//! ---
//!
//! ## Actions
//!
//! [`PaneOverlay::draw`] and [`PaneHeadless::update`] return a vector of [`PaneAction`]
//! each frame. Match on these to drive your application:
//!
//! ```no_run
//! # use pane::PaneAction;
//! # let actions: Vec<PaneAction> = vec![];
//! for action in actions {
//! match action {
//! PaneAction::Custom(tag) => { /* button pressed */ }
//! PaneAction::Slider(id, value) => { /* slider moved */ }
//! PaneAction::Toggle(id, checked) => { /* toggle flipped */ }
//! PaneAction::Dropdown(id, idx, label) => { /* selection changed */ }
//! PaneAction::Radio(id, idx, label) => { /* selection changed */ }
//! PaneAction::TextChanged(id, text) => { /* keystroke */ }
//! PaneAction::TextSubmitted(id, text) => { /* enter pressed */ }
//! PaneAction::SwitchRoot(name) => { /* root changed */ }
//! PaneAction::Quit => { std::process::exit(0); }
//! }
//! }
//! ```
//!
//! ---
//!
//! ## Runtime API
//!
//! Read or write any widget's value from code at any time. Useful for syncing UI
//! to app state on startup, or driving a progress bar mid-game.
//!
//! ```ignore
//! # use pane::WriteValue;
//! # let mut ui: pane::PaneOverlay = todo!();
//! // Read — returns the UiItem definition + current visual state
//! if let Some((pane::api::UiItem::Slider(s), _)) = ui.read("volume") {
//! println!("volume = {}", s.value);
//! }
//!
//! // Write — silently sets value without firing PaneActions
//! ui.write("volume", &WriteValue::Slider(0.8));
//! ui.write("mute", &WriteValue::Toggle(true));
//! ui.write("name", &WriteValue::Text("Player 1".into()));
//! ui.write("quality", &WriteValue::Selected(2));
//!
//! // Toast notification (also triggerable directly from RON via on_press: Toast(...))
//! ui.push_toast("Settings saved", 2.0, 0.0, -400.0, 300.0, 60.0);
//! ```
//!
//! ---
//!
//! ## Hot Reload
//!
//! Set `hot_reload: true` in your root `.ron` file. While your app runs:
//!
//! - Save a menu `.ron` → layout and behaviour update instantly
//! - Save a style `.ron` → visual design updates instantly
//! - Save a `.wgsl` shader → shader recompiles and updates instantly
//!
//! No restart. No recompile. Just save.
//!
//! Requires the `dev` feature for runtime style loading:
//!
//! ```toml
//! pane_ui = { version = "0.1", features = ["dev"] }
//! ```
//!
//! ---
//!
//! ## Controller Support
//!
//! All widgets support gamepad navigation with no extra configuration:
//!
//! - **D-pad / left stick** — moves focus to the nearest widget in that direction
//! - **South (A / Cross)** — confirms; activates focused widget
//! - **East (B / Circle)** — cancels; closes popout panels
//! - **Sliders** — left/right adjusts value continuously
//! - **Scroll lists & panes** — focus scrolls to keep the active item visible
//! - **Popouts** — confirm opens, up/down navigates inside, cancel closes
//!
//! Pass your existing `gilrs::Gilrs` to share it with your game:
//!
//! ```no_run
//! # let (device, queue, format) = todo!();
//! # let gilrs: gilrs::Gilrs = todo!();
//! // Share your game's gilrs context
//! let ui = pane::overlay("assets/hud.ron", &device, &queue, format, Some(gilrs));
//!
//! // Or let pane_ui manage its own
//! let ui = pane::overlay("assets/hud.ron", &device, &queue, format, None);
//! ```
//!
//! ---
//!
//! ## Custom Styles & Shaders
//!
//! Drop `.ron` style files in your style directory and `.wgsl` shaders in your shader
//! directory. Reference them by filename (without extension). Users and modders can
//! reskin your entire UI without touching your code.
//!
//! ```ron
//! (
//! shader_dirs: ["shaders"],
//! style_dirs: ["styles"],
//! roots: [
//! (
//! name: "main_menu",
//! buttons: [
//! (
//! id: "my_btn",
//! style: "my_custom_style", // loads styles/my_custom_style.ron
//! on_press: Custom("clicked"),
//! // ...
//! ),
//! ],
//! ),
//! ],
//! )
//! ```
//!
//! 6 built-in styles are always available: `frosted_glass` · `retro` · `plain` ·
//! `glass_pill` · `emboss` · `sharp_outline`
//!
//! ---
//!
//! ## Debugging
//!
//! Enable debug logging to print every internal message to stdout:
//!
//! ```no_run
//! # let mut ui: pane::PaneOverlay = todo!();
//! // Overlay or headless
//! ui.set_debug(true);
//! ```
//!
//! ```text
//! // Standalone — set the environment variable before running
//! PANE_DEBUG=1 cargo run
//! ```
// ── Public modules ────────────────────────────────────────────────────────────
// ── Internal modules ──────────────────────────────────────────────────────────
pub
pub
pub
pub
pub
pub
pub
pub
pub
pub
pub
pub
pub
// ── Re-exports ────────────────────────────────────────────────────────────────
/// Re-exported for convenience — pass a `gilrs::Gilrs` to [`overlay`] to share
/// your existing gamepad context with `pane_ui`.
pub use gilrs;
pub use ;