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
//! Built-in GUI for truce plugins.
//!
//! Orchestrates the two `truce_gui_types::RenderBackend` impls into
//! editor types: with the default `cpu` feature, `BuiltinEditor`
//! rasterises widgets to a `truce_cpu::CpuBackend` (tiny-skia)
//! pixmap and blits it to a wgpu surface; with the `gpu` feature,
//! `GpuEditor` renders directly through `truce_gpu::WgpuBackend`.
//! The non-runtime data types (layout, widget regions, interaction
//! state, theme, render trait) live in `truce-gui-types` and the
//! plugin traits in `truce-plugin`; this crate re-exports them so
//! existing `truce_gui::...` paths keep working.
// Widget-drawing helpers, `RenderBackend` trait methods, and interaction
// dispatch all take many independent geometry / state / theme arguments.
// The long signatures are intentional; bundling them into builder
// structs would obscure call sites without simplifying any single
// call.
// `blit` (CPU pixmap → wgpu surface upload) is only needed for the
// cpu path. Gated together with `truce-cpu`.
// baseview-bound editor is macOS / Windows / Linux only. iOS
// embeds the editor in a UIView managed by the AUv3 view
// controller - see [`editor_ios`]. `BuiltinEditor` itself stays
// available regardless of the `cpu` feature so the wgpu-only
// `GpuEditor` can wrap it; the cpu-specific fields and Editor
// trait impl inside this module are individually gated.
pub use editor_ios as editor;
// The wgpu-backed editor wraps `BuiltinEditor` to render through
// `truce_gpu::WgpuBackend`. Lives here so the user-facing renderer
// crate (truce-gui) is a one-stop dep for plugin authors; the wgpu
// primitives stay an implementation detail in truce-gpu.
// `CpuBackend` (tiny-skia `RenderBackend` impl) + `font` (fontdue
// glyph cache) live in the sibling `truce-cpu` crate so the CPU
// rasterizer is a peer of `truce-gpu`'s `WgpuBackend` in the crate
// graph. Re-exported under their historical `truce_gui::*` paths
// so existing call sites keep working. Available whenever the `cpu`
// feature is on *or* we're building for iOS — iOS always rasterizes
// through `CpuBackend` (see `editor_ios`), independent of features,
// so `truce-cpu` is a hard dep there.
pub use ColorExt;
pub use CpuBackend;
pub use font;
// Internal sub-module path that `backend_cpu` used to occupy.
// Re-export the lightweight data + trait surface from `truce-gui-types`
// so old `truce_gui::layout::*` / `truce_gui::widgets::*` /
// `truce_gui::theme::*` paths continue to resolve. New code can import
// directly from `truce_gui_types`.
pub use ios;
pub use ;
pub use ;
// Re-export plugin-logic traits from `truce-plugin` for the same
// backward-compat reason.
pub use ;
pub use __plugin_logic_deps;
pub use BuiltinEditor;
pub use GpuEditor;
pub use ;
/// Construct truce's default editor for a plugin's `editor()` impl.
///
/// Picks the renderer based on which feature is enabled:
///
/// - `gpu` (opt-in): wraps a [`BuiltinEditor`] in a `GpuEditor`
/// that renders directly through `truce_gpu::WgpuBackend`.
/// - `cpu` (default): returns a [`BuiltinEditor`] whose `Editor`
/// impl rasterises to a tiny-skia pixmap and blits it to a wgpu
/// surface.
/// - iOS: always returns the iOS `BuiltinEditor` (UIView-hosted
/// `CAMetalLayer`); the `gpu` feature has no effect on iOS.
///
/// Most layout-only plugins implement [`truce_plugin::PluginLogic::editor`] as:
///
/// ```ignore
/// fn editor(&self) -> Box<dyn truce_core::Editor> {
/// truce_gui::default_editor(
/// self.params.clone(),
/// GridLayout::build(vec![ /* widgets */ ]),
/// )
/// }
/// ```
///
/// Only compiled when a renderer feature (`cpu` or `gpu`) is on.
/// Crates that depend on `truce-gui` purely for its types / platform
/// helpers (e.g. `truce-egui`, `truce-iced`, `truce-slint`) can build
/// it with neither feature and simply not call this function.
/// Fluent shorthand for [`default_editor`]. Build a `GridLayout`,
/// then close the `editor()` impl with `.into_editor(&self.params)`:
///
/// ```ignore
/// fn editor(&self) -> Box<dyn truce_core::Editor> {
/// GridLayout::build(vec![ /* widgets */ ])
/// .with_title("GAIN")
/// .into_editor(&self.params)
/// }
/// ```
///
/// Equivalent to `default_editor(self.params.clone(), layout)` - the
/// `&Arc<P>` is cloned internally so the call site stays free of an
/// explicit `.clone()`. Bring it into scope with
/// `use truce_gui::IntoLayoutEditor;` (it can't ride along on
/// `truce::prelude`, which deliberately doesn't depend on this crate).
///
/// The method name mirrors [`truce_core::IntoEditor::into_editor`] (the
/// blanket "box a concrete editor" helper used by egui / iced / slint),
/// so every `editor()` impl ends the same way - layout plugins just
/// pass their params.
///
/// Same feature gating as [`default_editor`]: only compiled when a
/// renderer feature (`cpu` / `gpu`) is on, or on iOS.
/// Get the display scale factor used to size the next editor.
///
/// Screenshot rendering pins this to a deterministic value via
/// [`truce_core::screenshot::override_scale`] (default 2.0) so a
/// reference PNG baked on one host renders at the same physical
/// dimensions on any other. Outside screenshot rendering the
/// override is unset and we return the platform's main-screen DPI
/// query (Retina = 2.0, normal = 1.0).