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
//! # rungui
//!
//! A small portable GUI toolkit that is a thin layer over the native toolkits: GTK3 on Linux,
//! Win32 on Windows, Cocoa on macOS. Each backend declares the platform's C API by hand; there
//! are no binding crates. Text is UTF-8 in Rust and converted at the boundary (UTF-16 on Win32,
//! `NSString` on Cocoa). Accessibility names and roles are derived by the core and set on the native controls.
//!
//! ## Tutorial
//!
//! 1. Create the [`App`] once, on the main thread.
//! 2. Create widgets with `Widget::new(parent, ..)`. Parents are windows or containers
//! ([`VBox`], [`HBox`], [`Grid`], [`GroupBox`], [`Tabs`]/[`Page`], [`Splitter`]). Containers
//! lay out their children; tune with [`Widget::set_expand`] and friends. A [`Splitter`] takes
//! exactly two children (its panes) and lets the user drag the boundary between them.
//! 3. Attach closures with `on_click`, `on_change`, ... Handles are `Copy` (and `Send`), so just
//! `move` them into closures.
//! 4. `win.show()` then `app.run()`.
//!
//! ```no_run
//! use rungui::*;
//! let app = App::new("hello").unwrap();
//! let win = Window::new("Hello");
//! let col = VBox::new(win);
//! let label = Label::new(col, "Hi");
//! Button::new(col, "Click").on_click(move || label.set_text("Clicked"));
//! win.show();
//! app.run();
//! ```
//!
//! A two-pane layout, e.g. a file browser with a tree on the left and a fixed-pitch preview:
//!
//! ```no_run
//! use rungui::*;
//! let app = App::new("panes").unwrap();
//! let win = Window::new("Panes");
//! win.set_size(640, 400);
//! win.set_min_size(320, 200);
//! let split = Splitter::new(win, Orientation::Horizontal);
//! let tree = Tree::new(split); // first child: left pane
//! let preview = TextArea::new(split); // second child: right pane
//! preview.set_monospace(true);
//! preview.set_wrap(false);
//! preview.set_read_only(true);
//! split.set_position(200); // width of the left pane in pixels
//! split.on_move(move |px| println!("left pane is now {px}px wide"));
//! tree.on_select(move |n| preview.set_text(&n.map(|n| tree.text(n)).unwrap_or_default()));
//! win.show();
//! app.run();
//! ```
//!
//! ## Things to know
//!
//! * Handles never panic. A stale or destroyed handle is inert: setters do nothing, getters
//! return defaults. Creation errors are reported through [`last_error`].
//! * Only [`App::post`] and [`App::quit`] may be called from other threads.
//! * Panics inside callbacks are caught and do not unwind into the toolkit.
//! * For anything the portable API lacks, get the native object with `widget.native_handle()`
//! and call the toolkit directly.
//! * Dialogs: [`message_box`], [`FileDialog`] and [`prompt`] block until answered. Any window can
//! be a modal dialog with [`Window::run_modal`]; Enter in a [`TextInput`] ([`TextInput::on_activate`])
//! and Escape in a window ([`Window::on_cancel`]) are reported to the app.
//! * Optional features (accessibility overrides, sort indicators, popup menus) degrade to
//! no-ops on a backend that lacks them rather than failing.
//! * Build modes: default is the native backend for the target; `--features mock` is a headless
//! in-memory backend for tests; `--features emulate-mac` builds the Cocoa backend on Linux
//! against GNUstep.
// The backend contract (and the headless backend) is public only with the `mock` feature, which is
// how an application's tests drive its UI without a display.
pub use ;
pub use ;
pub use ;
pub use ;
pub use *;
/// Application object. Create exactly one per process, on the main thread, before any widget.
);
/// The most recent creation/timer error on this thread, if any (clears it).
/// Deepest allowed nesting of widgets (a window's children are at depth 1). Layout, accessibility
/// and the toolkits recurse over the widget tree, so creating a widget below this depth fails with
/// [`Error::LimitExceeded`] and returns a dead handle instead of risking a stack overflow.
pub const MAX_NESTING: usize = MAX_NESTING;
/// Mirror horizontal layout (HBox order, Grid columns, VBox cross-axis alignment) for
/// right-to-left locales. Applies to every window of the calling (UI) thread and relayouts them.
/// Default off.