i_slint_common/enums.rs
1// Copyright © SixtyFPS GmbH <info@slint.dev>
2// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
3
4//! This module contains all enums exposed in the .slint language.
5
6// cSpell: ignore evenodd grabbable horizontalbox horizontallayout nesw standardbutton standardtableview verticalbox verticallayout
7
8/// Call a macro with every enum exposed in the .slint language
9///
10/// ## Example
11/// ```rust
12/// macro_rules! print_enums {
13/// ($( $(#[$enum_doc:meta])* enum $Name:ident { $( $(#[$value_doc:meta])* $Value:ident,)* })*) => {
14/// $(println!("{} => [{}]", stringify!($Name), stringify!($($Value),*));)*
15/// }
16/// }
17/// i_slint_common::for_each_enums!(print_enums);
18/// ```
19#[macro_export]
20macro_rules! for_each_enums {
21 ($macro:ident) => {
22 $macro.
80 Nonzero,
81 /// The ["evenodd" fill rule as defined in SVG](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/fill-rule#evenodd)
82 Evenodd,
83 }
84
85 /// Use this enum to add standard buttons to a `Dialog`. The look and positioning
86 /// of these `StandardButton`s depends on the environment
87 /// (OS, UI environment, etc.) the application runs in.
88 enum StandardButtonKind {
89 /// A "OK" button that accepts a `Dialog`, closing it when clicked.
90 Ok,
91 /// A "Cancel" button that rejects a `Dialog`, closing it when clicked.
92 Cancel,
93 /// A "Apply" button that should accept values from a
94 /// `Dialog` without closing it.
95 Apply,
96 /// A "Close" button, which should close a `Dialog` without looking at values.
97 Close,
98 /// A "Reset" button, which should reset the `Dialog` to its initial state.
99 Reset,
100 /// A "Help" button, which should bring up context related documentation when clicked.
101 Help,
102 /// A "Yes" button, used to confirm an action.
103 Yes,
104 /// A "No" button, used to deny an action.
105 No,
106 /// A "Abort" button, used to abort an action.
107 Abort,
108 /// A "Retry" button, used to retry a failed action.
109 Retry,
110 /// A "Ignore" button, used to ignore a failed action.
111 Ignore,
112 }
113
114 /// This enum represents the value of the `dialog-button-role` property which can be added to
115 /// any element within a `Dialog` to put that item in the button row, and its exact position
116 /// depends on the role and the platform.
117 enum DialogButtonRole {
118 /// This isn't a button meant to go into the bottom row
119 None,
120 /// This is the role of the main button to click to accept the dialog. e.g. "Ok" or "Yes"
121 Accept,
122 /// This is the role of the main button to click to reject the dialog. e.g. "Cancel" or "No"
123 Reject,
124 /// This is the role of the "Apply" button
125 Apply,
126 /// This is the role of the "Reset" button
127 Reset,
128 /// This is the role of the "Help" button
129 Help,
130 /// This is the role of any other button that performs another action.
131 Action,
132 }
133
134 /// This enum describes the different reasons for a FocusEvent
135 #[non_exhaustive]
136 enum FocusReason {
137 /// A built-in function invocation caused the event (`.focus()`, `.clear-focus()`)
138 Programmatic,
139 /// Keyboard navigation caused the event (tabbing)
140 TabNavigation,
141 /// A mouse click caused the event
142 PointerClick,
143 /// A popup caused the event
144 PopupActivation,
145 /// The window manager changed the active window and caused the event
146 WindowActivation,
147 }
148
149 /// The enum reports what happened to the `PointerEventButton` in the event
150 enum PointerEventKind {
151 /// The action was cancelled.
152 Cancel,
153 /// The button was pressed.
154 Down,
155 /// The button was released.
156 Up,
157 /// The pointer has moved,
158 Move,
159 }
160
161 /// This enum describes the different types of buttons for a pointer event,
162 /// typically on a mouse or a pencil.
163 #[non_exhaustive]
164 enum PointerEventButton {
165 /// A button that is none of left, right, middle, back or forward. For example,
166 /// this is used for the task button on a mouse with many buttons.
167 Other,
168 /// The left button.
169 Left,
170 /// The right button.
171 Right,
172 /// The center button.
173 Middle,
174 /// The back button.
175 Back,
176 /// The forward button.
177 Forward,
178 }
179
180 /// This enum represents different types of mouse cursors. It's a subset of the mouse cursors available in CSS.
181 /// For details and pictograms see the [MDN Documentation for cursor](https://developer.mozilla.org/en-US/docs/Web/CSS/cursor#values).
182 /// Depending on the backend and used OS unidirectional resize cursors may be replaced with bidirectional ones.
183 enum MouseCursor {
184 /// The systems default cursor.
185 Default,
186 /// No cursor is displayed.
187 None,
188 //context_menu,
189 /// A cursor indicating help information.
190 Help,
191 /// A pointing hand indicating a link.
192 Pointer,
193 /// The program is busy but can still be interacted with.
194 Progress,
195 /// The program is busy.
196 Wait,
197 //cell,
198 /// A crosshair.
199 Crosshair,
200 /// A cursor indicating selectable text.
201 Text,
202 //vertical_text,
203 /// An alias or shortcut is being created.
204 Alias,
205 /// A copy is being created.
206 Copy,
207 /// Something is to be moved.
208 Move,
209 /// Something can't be dropped here.
210 NoDrop,
211 /// An action isn't allowed
212 NotAllowed,
213 /// Something is grabbable.
214 Grab,
215 /// Something is being grabbed.
216 Grabbing,
217 //all_scroll,
218 /// Indicating that a column is resizable horizontally.
219 ColResize,
220 /// Indicating that a row is resizable vertically.
221 RowResize,
222 /// Unidirectional resize north.
223 NResize,
224 /// Unidirectional resize east.
225 EResize,
226 /// Unidirectional resize south.
227 SResize,
228 /// Unidirectional resize west.
229 WResize,
230 /// Unidirectional resize north-east.
231 NeResize,
232 /// Unidirectional resize north-west.
233 NwResize,
234 /// Unidirectional resize south-east.
235 SeResize,
236 /// Unidirectional resize south-west.
237 SwResize,
238 /// Bidirectional resize east-west.
239 EwResize,
240 /// Bidirectional resize north-south.
241 NsResize,
242 /// Bidirectional resize north-east-south-west.
243 NeswResize,
244 /// Bidirectional resize north-west-south-east.
245 NwseResize,
246 //zoom_in,
247 //zoom_out,
248 }
249
250 /// This enum defines how the source image shall fit into an `Image` element.
251 enum ImageFit {
252 /// Scales and stretches the source image to fit the width and height of the `Image` element.
253 Fill,
254 /// The source image is scaled to fit into the `Image` element's dimension while preserving the aspect ratio.
255 Contain,
256 /// The source image is scaled to cover into the `Image` element's dimension while preserving the aspect ratio.
257 /// If the aspect ratio of the source image doesn't match the element's one, then the image will be clipped to fit.
258 Cover,
259 /// Preserves the size of the source image in logical pixels.
260 /// The source image will still be scaled by the scale factor that applies to all elements in the window.
261 /// Any extra space will be left blank.
262 Preserve,
263 }
264
265 /// This enum specifies the horizontal alignment of the source image.
266 enum ImageHorizontalAlignment {
267 /// Aligns the source image at the center of the `Image` element.
268 Center,
269 /// Aligns the source image at the left of the `Image` element.
270 Left,
271 /// Aligns the source image at the right of the `Image` element.
272 Right,
273 }
274
275 /// This enum specifies the vertical alignment of the source image.
276 enum ImageVerticalAlignment {
277 /// Aligns the source image at the center of the `Image` element.
278 Center,
279 /// Aligns the source image at the top of the `Image` element.
280 Top,
281 /// Aligns the source image at the bottom of the `Image` element.
282 Bottom,
283 }
284
285 /// This enum specifies how the source image will be scaled.
286 enum ImageRendering {
287 /// The image is scaled with a linear interpolation algorithm.
288 Smooth,
289 /// The image is scaled with the nearest neighbor algorithm.
290 Pixelated,
291 }
292
293 /// This enum specifies how the source image will be tiled.
294 enum ImageTiling {
295 /// The source image will not be tiled.
296 None,
297 /// The source image will be repeated to fill the `Image` element.
298 Repeat,
299 /// The source image will be repeated and scaled to fill the `Image` element, ensuring an integer number of repetitions.
300 Round,
301 }
302
303 /// This enum is used to define the type of the input field.
304 #[non_exhaustive]
305 enum InputType {
306 /// The default value. This will render all characters normally
307 Text,
308 /// This will render all characters with a character that defaults to "*"
309 Password,
310 /// This will only accept and render number characters (0-9)
311 Number,
312 /// This will accept and render characters if it's valid part of a decimal
313 Decimal,
314 }
315
316 /// Enum representing the `alignment` property of a
317 /// `HorizontalBox`, a `VerticalBox`,
318 /// a `HorizontalLayout`, or `VerticalLayout`.
319 enum LayoutAlignment {
320 /// Use the minimum size of all elements in a layout, distribute remaining space
321 /// based on `*-stretch` among all elements.
322 Stretch,
323 /// Use the preferred size for all elements, distribute remaining space evenly before the
324 /// first and after the last element.
325 Center,
326 /// Use the preferred size for all elements, put remaining space after the last element.
327 Start,
328 /// Use the preferred size for all elements, put remaining space before the first
329 /// element.
330 End,
331 /// Use the preferred size for all elements, distribute remaining space evenly between
332 /// elements.
333 SpaceBetween,
334 /// Use the preferred size for all elements, distribute remaining space evenly
335 /// between the elements, and use half spaces at the start and end.
336 SpaceAround,
337 /// Use the preferred size for all elements, distribute remaining space evenly before the
338 /// first element, after the last element and between elements.
339 SpaceEvenly,
340 }
341
342 /// PathEvent is a low-level data structure describing the composition of a path. Typically it is
343 /// generated at compile time from a higher-level description, such as SVG commands.
344 enum PathEvent {
345 /// The beginning of the path.
346 Begin,
347 /// A straight line on the path.
348 Line,
349 /// A quadratic bezier curve on the path.
350 Quadratic,
351 /// A cubic bezier curve on the path.
352 Cubic,
353 /// The end of the path that remains open.
354 EndOpen,
355 /// The end of a path that is closed.
356 EndClosed,
357 }
358
359 /// This enum represents the different values for the `accessible-role` property, used to describe the
360 /// role of an element in the context of assistive technology such as screen readers.
361 #[non_exhaustive]
362 enum AccessibleRole {
363 /// The element isn't accessible.
364 None,
365 /// The element is a `Button` or behaves like one.
366 Button,
367 /// The element is a `CheckBox` or behaves like one.
368 Checkbox,
369 /// The element is a `ComboBox` or behaves like one.
370 Combobox,
371 /// The element is a `GroupBox` or behaves like one.
372 Groupbox,
373 /// The element is an `Image` or behaves like one. This is automatically applied to `Image` elements.
374 Image,
375 /// The element is a `ListView` or behaves like one.
376 List,
377 /// The element is a `Slider` or behaves like one.
378 Slider,
379 /// The element is a `SpinBox` or behaves like one.
380 Spinbox,
381 /// The element is a `Tab` or behaves like one.
382 Tab,
383 /// The element is similar to the tab bar in a `TabWidget`.
384 TabList,
385 /// The element is a container for tab content.
386 TabPanel,
387 /// The role for a `Text` element. This is automatically applied to `Text` elements.
388 Text,
389 /// The role for a `TableView` or behaves like one.
390 Table,
391 /// The role for a TreeView or behaves like one. (Not provided yet)
392 Tree,
393 /// The element is a `ProgressIndicator` or behaves like one.
394 ProgressIndicator,
395 /// The role for widget with editable text such as a `LineEdit` or a `TextEdit`.
396 /// This is automatically applied to `TextInput` elements.
397 TextInput,
398 /// The element is a `Switch` or behaves like one.
399 Switch,
400 /// The element is an item in a `ListView`.
401 ListItem,
402 }
403
404 /// This enum represents the different values of the `sort-order` property.
405 /// It's used to sort a `StandardTableView` by a column.
406 enum SortOrder {
407 /// The column is unsorted.
408 Unsorted,
409
410 /// The column is sorted in ascending order.
411 Ascending,
412
413 /// The column is sorted in descending order.
414 Descending,
415 }
416
417 /// Represents the orientation of an element or widget such as the `Slider`.
418 enum Orientation {
419 /// Element is oriented horizontally.
420 Horizontal,
421 /// Element is oriented vertically.
422 Vertical,
423 }
424
425 /// This enum indicates the color scheme used by the widget style. Use this to explicitly switch
426 /// between dark and light schemes, or choose Unknown to fall back to the system default.
427 enum ColorScheme {
428 /// The scheme is not known and a system wide setting configures this. This could mean that
429 /// the widgets are shown in a dark or light scheme, but it could also be a custom color scheme.
430 Unknown,
431 /// The style chooses light colors for the background and dark for the foreground.
432 Dark,
433 /// The style chooses dark colors for the background and light for the foreground.
434 Light,
435 }
436
437 /// This enum describes the direction of an animation.
438 enum AnimationDirection {
439 /// The ["normal" direction as defined in CSS](https://developer.mozilla.org/en-US/docs/Web/CSS/animation-direction#normal).
440 Normal,
441 /// The ["reverse" direction as defined in CSS](https://developer.mozilla.org/en-US/docs/Web/CSS/animation-direction#reverse).
442 Reverse,
443 /// The ["alternate" direction as defined in CSS](https://developer.mozilla.org/en-US/docs/Web/CSS/animation-direction#alternate).
444 Alternate,
445 /// The ["alternate reverse" direction as defined in CSS](https://developer.mozilla.org/en-US/docs/Web/CSS/animation-direction#alternate-reverse).
446 AlternateReverse,
447 }
448
449 /// This enum describes the scrollbar visibility
450 enum ScrollBarPolicy {
451 /// Scrollbar will be visible only when needed
452 AsNeeded,
453 /// Scrollbar never shown
454 AlwaysOff,
455 /// Scrollbar always visible
456 AlwaysOn,
457 }
458
459 // This enum describes the close behavior of `PopupWindow`
460 enum PopupClosePolicy {
461 /// Closes the `PopupWindow` when user clicks or presses the escape key.
462 CloseOnClick,
463
464 /// Closes the `PopupWindow` when user clicks outside of the popup or presses the escape key.
465 CloseOnClickOutside,
466
467 /// Does not close the `PopupWindow` automatically when user clicks.
468 NoAutoClose,
469 }
470
471 /// This enum describes the appearance of the ends of stroked paths.
472 enum LineCap {
473 /// The stroke ends with a flat edge that is perpendicular to the path.
474 Butt,
475 /// The stroke ends with a rounded edge.
476 Round,
477 /// The stroke ends with a square projection beyond the path.
478 Square,
479 }
480
481 /// This enum describes the detected operating system types.
482 #[non_exhaustive]
483 enum OperatingSystemType {
484 /// This variant includes any version of Android running mobile phones, tablets, as well as embedded Android devices.
485 Android,
486 /// This variant covers iOS running on iPhones and iPads.
487 Ios,
488 /// This variant covers macOS running on Apple's Mac computers.
489 Macos,
490 /// This variant covers any version of Linux, except Android.
491 Linux,
492 /// This variant covers Microsoft Windows.
493 Windows,
494 /// This variant is reported when the operating system is none of the above.
495 Other,
496 }
497 ];
498 };
499}