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
//! FerroUI in one dependency.
//!
//! The facade crate of FerroUI: it has no code of its own. It re-exports the
//! crates of the framework, each under the name of its crate without the
//! `ferroui-` prefix (`ferroui-base` is [`base`], `ferroui-themes-fluent` is
//! `themes_fluent`), and gathers the types of a minimal application in a
//! [`prelude`]. Features choose the parts, so that an application names one
//! dependency:
//!
//! ```toml
//! [dependencies]
//! ferroui = "=0.1.0-preview.2"
//! ```
//!
//! The crates of one release depend on one another at exactly that version,
//! so the facade selects one consistent set of them.
//!
//! # Modules and features
//!
//! | Module | Crate | Feature | Default |
//! |---|---|---|---|
//! | [`base`] | `ferroui-base` | always | |
//! | [`controls`] | `ferroui-controls` | always | |
//! | [`markup`] | `ferroui-markup` | always | |
//! | `desktop`, `skia`, `harfbuzz`; `native` on macOS, `win32` on Windows, `x11` on Linux | `ferroui-desktop` and the crates it selects among | `desktop` | yes |
//! | `themes_fluent` | `ferroui-themes-fluent` | `fluent` | yes |
//! | `themes_simple` | `ferroui-themes-simple` | `simple` | no |
//! | `themes_winui` | `ferroui-themes-winui` | `winui-theme` | no |
//! | `markup_xaml`, `markup_xaml_loader` | `ferroui-markup-xaml`, `ferroui-markup-xaml-loader` (run-time loading) | `xaml` | no |
//! | `controls_color_picker` | `ferroui-controls-color-picker` | `color-picker` | no |
//! | `dialogs` | `ferroui-dialogs` | `dialogs` | no |
//! | `browser`, `skia`, `harfbuzz` | `ferroui-browser` | `browser` | no |
//! | `vello` | `ferroui-vello`; its GPU modes with `vello-hybrid` and `vello-gpu` | `vello` | no |
//! | `headless` | `ferroui-headless` | `headless` | no |
//! | `opengl`, `metal`, `vulkan` | the platform graphics contracts | `opengl`, `metal`, `vulkan` | no |
//!
//! An application for the browser turns the default features off and names
//! `browser` and a theme. The build-time crates (`ferroui-build`,
//! `ferroui-build-scan`, `xamlx`) are not part of the facade: a crate that
//! compiles its markup in its build script names `ferroui-build` as a build
//! dependency, and the code the compiler writes names the crates it calls by
//! their own names, so such a crate depends on those crates directly.
//!
//! # A minimal application
//!
//! An application is a class derived from [`Application`](controls::Application)
//! that adds a theme to its styles and creates its main window when the
//! framework has finished initialising; `main` configures it with the
//! application builder and starts it with the classic desktop lifetime:
//!
//! ```no_run
//! use ferroui::prelude::*;
//!
//! #[repr(C)]
//! pub struct App {
//! base: Application,
//! }
//!
//! ferro_class!(App: Application);
//! ferro_impl_classes!(App: FerroObjectImpl);
//!
//! impl NewApplication for App {
//! fn new_application() -> Ref<Self> {
//! instantiate(Self { base: Application::construct() })
//! }
//! }
//!
//! impl ApplicationImpl for App {
//! fn initialize(this: &Self) {
//! Self::parent_initialize(this);
//! this.styles().add(FluentTheme::new().as_style());
//! }
//!
//! fn on_framework_initialization_completed(this: &Self) {
//! let lifetime = this.application_lifetime();
//! if let Some(desktop) = lifetime.as_ref().and_then(|l| l.as_classic_desktop_style_application_lifetime()) {
//! let button = Button::new();
//! button.set_content(Some(std::rc::Rc::new("Click me".to_string())));
//! button.click(|_, _| println!("Button clicked"));
//!
//! let window = Window::new();
//! window.set_title(Some("Hello".to_string()));
//! window.set_content(Some(Control::boxed(button)));
//! desktop.set_main_window(Some(window));
//! }
//! Self::parent_on_framework_initialization_completed(this);
//! }
//! }
//!
//! fn main() -> std::process::ExitCode {
//! let args: Vec<String> = std::env::args().skip(1).collect();
//! let exit_code = AppBuilder::configure::<App>()
//! .use_platform_detect()
//! .start_with_classic_desktop_lifetime(&args);
//! std::process::ExitCode::from(exit_code as u8)
//! }
//! ```
//!
//! The same program with a few more controls is the example `hello` of this
//! crate (`cargo run -p ferroui --example hello`).
//!
//! The application builder of the facade is the one of the crates it
//! re-exports: on the desktop, platform detection selects the platform of
//! the operating system, Skia and HarfBuzz, and nothing is initialised until
//! the application is set up.
//!
//! ```
//! # #[cfg(any(target_os = "macos", windows, target_os = "linux"))]
//! # {
//! use ferroui::prelude::*;
//!
//! let builder = AppBuilder::configure::<Application>().use_platform_detect();
//! assert_eq!(builder.rendering_subsystem_name().as_deref(), Some("Skia"));
//! assert_eq!(builder.text_shaping_subsystem_name().as_deref(), Some("HarfBuzz"));
//! assert!(builder.instance().is_none());
//! # }
//! ```
pub use ferroui_base as base;
pub use ferroui_controls as controls;
pub use ferroui_markup as markup;
pub use ferroui_desktop as desktop;
pub use ferroui_native as native;
pub use ferroui_win32 as win32;
pub use ferroui_x11 as x11;
pub use ferroui_harfbuzz as harfbuzz;
pub use ferroui_skia as skia;
pub use ferroui_themes_fluent as themes_fluent;
pub use ferroui_themes_simple as themes_simple;
pub use ferroui_themes_winui as themes_winui;
pub use ferroui_markup_xaml as markup_xaml;
pub use ferroui_markup_xaml_loader as markup_xaml_loader;
pub use ferroui_controls_color_picker as controls_color_picker;
pub use ferroui_dialogs as dialogs;
pub use ferroui_browser as browser;
pub use ferroui_headless as headless;
pub use ferroui_vello as vello;
pub use ferroui_metal as metal;
pub use ferroui_opengl as opengl;
pub use ferroui_vulkan as vulkan;