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
//! Commands an application sends to its window, and the window state it
//! reads.
//!
//! An application that draws its own title bar asks the window system to move,
//! resize, maximize or close the window: [`start_move`] and
//! [`start_resize`] from the pointer-down handler of the area that starts the
//! gesture, [`toggle_maximize`] from a maximize button, [`close`] from a
//! close button. The commands queue on the application the running code
//! belongs to, and the windowing layer takes them with
//! [`App::take_window_commands`](crate::App::take_window_commands) and applies
//! them to the window. A headless application has no windowing layer, so the
//! queue keeps the commands for a test to inspect.
//!
//! The windowing layer applies the commands after the input event whose
//! handler queued them, while that event is still being handled. An
//! interactive move or resize is only honored while the press that started it
//! is being reported, which is why a command belongs in the pointer-down
//! handler of the area that starts it, not in its release handler.
//!
//! [`maximized`] reports whether the window is maximized. It is a reactive
//! read: a binding that reads it reruns when the windowing layer reports a
//! new state through
//! [`App::set_window_state`](crate::App::set_window_state).
//!
//! [`Cursor`] chooses the pointer's look over a node, set with the
//! [`cursor`](crate::element::Element::cursor) builder. The cursor shows
//! wherever the pointer is over the node, and setting one does not change
//! which node a press or hover lands on.
//!
//! Code that runs with no live application above it, such as an owner whose
//! application was dropped, queues nothing: the commands do nothing there,
//! and [`maximized`] reads `false`.
//!
//! On the web target the windowing layer applies no commands and reports the
//! state as never maximized, so these functions queue and read without
//! effect. That rests on winit's web backend, which refuses the move and
//! resize calls and treats maximize as a no-op through winit 0.30; a winit
//! upgrade that changes this changes the behavior here.
//!
//! # Examples
//!
//! A title bar area that moves the window while it is pressed, and a binding
//! that shows a restore hint while the window is maximized:
//!
//! ```
//! use smudge_core::geometry::Color;
//! use smudge_core::style::px;
//! use smudge_core::widget::panel;
//! use smudge_core::window;
//!
//! let header = panel()
//! .width(px(320.0))
//! .height(px(36.0))
//! .background(Color::rgb(24, 26, 32))
//! .on_pointer_down(|_| window::start_move())
//! .child(panel().height(px(8.0)).hidden(|| window::maximized()));
//! ```
use RefCell;
use ;
use crate;
/// The edge or corner of a window that an interactive resize pulls.
/// One request to change the window, as
/// [`App::take_window_commands`](crate::App::take_window_commands) hands it
/// to the windowing layer.
/// The window state the windowing layer reports to the application.
///
/// More fields may follow, so a state is built from the default and the
/// `with_` methods rather than as a struct literal:
///
/// ```
/// use smudge_core::window::WindowState;
///
/// let state = WindowState::default().with_maximized(true);
/// assert!(state.maximized);
/// ```
/// The look of the pointer over a node.
///
/// The windowing layer shows the cursor of the deepest enabled node under the
/// pointer that sets one, and the platform default when none does. The resize
/// variants name the direction the resize would pull, so an edge handle
/// shows the same look the window system uses when it resizes that edge.
/// Queues a command to start an interactive move of the window.
///
/// Call it from the pointer-down handler of the area that starts the move,
/// because the window system honors the request only while the press that
/// started it is being handled. With no application above the running code
/// the call does nothing.
/// Queues a command to start an interactive resize of the window from
/// `edge`.
///
/// Call it from the pointer-down handler of the handle that starts the
/// resize, because the window system honors the request only while the press
/// that started it is being handled. With no application above the running
/// code the call does nothing.
/// Queues a command to maximize the window, or to restore it when it is
/// already maximized.
///
/// With no application above the running code the call does nothing.
/// Queues a command to close the window and end the run.
///
/// With no application above the running code the call does nothing.
/// Returns whether the window is maximized, as the windowing layer last
/// reported it.
///
/// This is a reactive read: a binding that calls it reruns when the state
/// changes, including a rerun or a memo recomputation that runs with no
/// owner current. A windowing layer that reports nothing, such as a headless
/// test, leaves it at `false`, and so does code with no live application
/// above it.
/// Appends `command` to the command queue of the application the running
/// code belongs to, or drops it when no live application is above the code.
/// Returns the window book of the application the running code belongs to.
///
/// A running effect or memo names its application through the owner it was
/// created under, because its reruns run with no owner current. Other code,
/// such as an input handler, names it through the current owner.
/// Replaces the window state the application's [`maximized`] reads, but only
/// when it changed, so an equal report wakes no binding.
pub
/// Takes every command queued so far, in the order they were queued.
pub
/// Creates the book of a new application, whose [`maximized`] signal is
/// created under the application's root owner so it dies with it.
pub
/// The queued commands and the window state of one application.
///
/// The application owns the book. Window commands reach it from any owner
/// under the application's root, and the windowing layer drains it and feeds
/// the state signal back.
pub
/// Returns the window book of the application `owner` belongs to, walking up
/// the owner chain to the root that holds it.