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 ] |
20 | macro_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 | /// The enum reports what happened to the `PointerEventButton` in the event |
135 | enum PointerEventKind { |
136 | /// The action was cancelled. |
137 | Cancel, |
138 | /// The button was pressed. |
139 | Down, |
140 | /// The button was released. |
141 | Up, |
142 | /// The pointer has moved, |
143 | Move, |
144 | } |
145 | |
146 | /// This enum describes the different types of buttons for a pointer event, |
147 | /// typically on a mouse or a pencil. |
148 | #[non_exhaustive] |
149 | enum PointerEventButton { |
150 | /// A button that is none of left, right, middle, back or forward. For example, |
151 | /// this is used for the task button on a mouse with many buttons. |
152 | Other, |
153 | /// The left button. |
154 | Left, |
155 | /// The right button. |
156 | Right, |
157 | /// The center button. |
158 | Middle, |
159 | /// The back button. |
160 | Back, |
161 | /// The forward button. |
162 | Forward, |
163 | } |
164 | |
165 | /// This enum represents different types of mouse cursors. It's a subset of the mouse cursors available in CSS. |
166 | /// For details and pictograms see the [MDN Documentation for cursor](https://developer.mozilla.org/en-US/docs/Web/CSS/cursor#values). |
167 | /// Depending on the backend and used OS unidirectional resize cursors may be replaced with bidirectional ones. |
168 | enum MouseCursor { |
169 | /// The systems default cursor. |
170 | Default, |
171 | /// No cursor is displayed. |
172 | None, |
173 | //context_menu, |
174 | /// A cursor indicating help information. |
175 | Help, |
176 | /// A pointing hand indicating a link. |
177 | Pointer, |
178 | /// The program is busy but can still be interacted with. |
179 | Progress, |
180 | /// The program is busy. |
181 | Wait, |
182 | //cell, |
183 | /// A crosshair. |
184 | Crosshair, |
185 | /// A cursor indicating selectable text. |
186 | Text, |
187 | //vertical_text, |
188 | /// An alias or shortcut is being created. |
189 | Alias, |
190 | /// A copy is being created. |
191 | Copy, |
192 | /// Something is to be moved. |
193 | Move, |
194 | /// Something can't be dropped here. |
195 | NoDrop, |
196 | /// An action isn't allowed |
197 | NotAllowed, |
198 | /// Something is grabbable. |
199 | Grab, |
200 | /// Something is being grabbed. |
201 | Grabbing, |
202 | //all_scroll, |
203 | /// Indicating that a column is resizable horizontally. |
204 | ColResize, |
205 | /// Indicating that a row is resizable vertically. |
206 | RowResize, |
207 | /// Unidirectional resize north. |
208 | NResize, |
209 | /// Unidirectional resize east. |
210 | EResize, |
211 | /// Unidirectional resize south. |
212 | SResize, |
213 | /// Unidirectional resize west. |
214 | WResize, |
215 | /// Unidirectional resize north-east. |
216 | NeResize, |
217 | /// Unidirectional resize north-west. |
218 | NwResize, |
219 | /// Unidirectional resize south-east. |
220 | SeResize, |
221 | /// Unidirectional resize south-west. |
222 | SwResize, |
223 | /// Bidirectional resize east-west. |
224 | EwResize, |
225 | /// Bidirectional resize north-south. |
226 | NsResize, |
227 | /// Bidirectional resize north-east-south-west. |
228 | NeswResize, |
229 | /// Bidirectional resize north-west-south-east. |
230 | NwseResize, |
231 | //zoom_in, |
232 | //zoom_out, |
233 | } |
234 | |
235 | /// This enum defines how the source image shall fit into an `Image` element. |
236 | enum ImageFit { |
237 | /// Scales and stretches the source image to fit the width and height of the `Image` element. |
238 | Fill, |
239 | /// The source image is scaled to fit into the `Image` element's dimension while preserving the aspect ratio. |
240 | Contain, |
241 | /// The source image is scaled to cover into the `Image` element's dimension while preserving the aspect ratio. |
242 | /// If the aspect ratio of the source image doesn't match the element's one, then the image will be clipped to fit. |
243 | Cover, |
244 | /// Preserves the size of the source image in logical pixels. |
245 | /// The source image will still be scaled by the scale factor that applies to all elements in the window. |
246 | /// Any extra space will be left blank. |
247 | Preserve, |
248 | } |
249 | |
250 | /// This enum specifies the horizontal alignment of the source image. |
251 | enum ImageHorizontalAlignment { |
252 | /// Aligns the source image at the center of the `Image` element. |
253 | Center, |
254 | /// Aligns the source image at the left of the `Image` element. |
255 | Left, |
256 | /// Aligns the source image at the right of the `Image` element. |
257 | Right, |
258 | } |
259 | |
260 | /// This enum specifies the vertical alignment of the source image. |
261 | enum ImageVerticalAlignment { |
262 | /// Aligns the source image at the center of the `Image` element. |
263 | Center, |
264 | /// Aligns the source image at the top of the `Image` element. |
265 | Top, |
266 | /// Aligns the source image at the bottom of the `Image` element. |
267 | Bottom, |
268 | } |
269 | |
270 | /// This enum specifies how the source image will be scaled. |
271 | enum ImageRendering { |
272 | /// The image is scaled with a linear interpolation algorithm. |
273 | Smooth, |
274 | /// The image is scaled with the nearest neighbor algorithm. |
275 | Pixelated, |
276 | } |
277 | |
278 | /// This enum specifies how the source image will be tiled. |
279 | enum ImageTiling { |
280 | /// The source image will not be tiled. |
281 | None, |
282 | /// The source image will be repeated to fill the `Image` element. |
283 | Repeat, |
284 | /// The source image will be repeated and scaled to fill the `Image` element, ensuring an integer number of repetitions. |
285 | Round, |
286 | } |
287 | |
288 | /// This enum is used to define the type of the input field. |
289 | #[non_exhaustive] |
290 | enum InputType { |
291 | /// The default value. This will render all characters normally |
292 | Text, |
293 | /// This will render all characters with a character that defaults to "*" |
294 | Password, |
295 | /// This will only accept and render number characters (0-9) |
296 | Number, |
297 | /// This will accept and render characters if it's valid part of a decimal |
298 | Decimal, |
299 | } |
300 | |
301 | /// Enum representing the `alignment` property of a |
302 | /// `HorizontalBox`, a `VerticalBox`, |
303 | /// a `HorizontalLayout`, or `VerticalLayout`. |
304 | enum LayoutAlignment { |
305 | /// Use the minimum size of all elements in a layout, distribute remaining space |
306 | /// based on `*-stretch` among all elements. |
307 | Stretch, |
308 | /// Use the preferred size for all elements, distribute remaining space evenly before the |
309 | /// first and after the last element. |
310 | Center, |
311 | /// Use the preferred size for all elements, put remaining space after the last element. |
312 | Start, |
313 | /// Use the preferred size for all elements, put remaining space before the first |
314 | /// element. |
315 | End, |
316 | /// Use the preferred size for all elements, distribute remaining space evenly between |
317 | /// elements. |
318 | SpaceBetween, |
319 | /// Use the preferred size for all elements, distribute remaining space evenly before the |
320 | /// first element, after the last element and between elements. |
321 | SpaceAround, |
322 | } |
323 | |
324 | /// PathEvent is a low-level data structure describing the composition of a path. Typically it is |
325 | /// generated at compile time from a higher-level description, such as SVG commands. |
326 | enum PathEvent { |
327 | /// The beginning of the path. |
328 | Begin, |
329 | /// A straight line on the path. |
330 | Line, |
331 | /// A quadratic bezier curve on the path. |
332 | Quadratic, |
333 | /// A cubic bezier curve on the path. |
334 | Cubic, |
335 | /// The end of the path that remains open. |
336 | EndOpen, |
337 | /// The end of a path that is closed. |
338 | EndClosed, |
339 | } |
340 | |
341 | /// This enum represents the different values for the `accessible-role` property, used to describe the |
342 | /// role of an element in the context of assistive technology such as screen readers. |
343 | #[non_exhaustive] |
344 | enum AccessibleRole { |
345 | /// The element isn't accessible. |
346 | None, |
347 | /// The element is a `Button` or behaves like one. |
348 | Button, |
349 | /// The element is a `CheckBox` or behaves like one. |
350 | Checkbox, |
351 | /// The element is a `ComboBox` or behaves like one. |
352 | Combobox, |
353 | /// The element is a `GroupBox` or behaves like one. |
354 | Groupbox, |
355 | /// The element is an `Image` or behaves like one. This is automatically applied to `Image` elements. |
356 | Image, |
357 | /// The element is a `ListView` or behaves like one. |
358 | List, |
359 | /// The element is a `Slider` or behaves like one. |
360 | Slider, |
361 | /// The element is a `SpinBox` or behaves like one. |
362 | Spinbox, |
363 | /// The element is a `Tab` or behaves like one. |
364 | Tab, |
365 | /// The element is similar to the tab bar in a `TabWidget`. |
366 | TabList, |
367 | /// The element is a container for tab content. |
368 | TabPanel, |
369 | /// The role for a `Text` element. This is automatically applied to `Text` elements. |
370 | Text, |
371 | /// The role for a `TableView` or behaves like one. |
372 | Table, |
373 | /// The role for a TreeView or behaves like one. (Not provided yet) |
374 | Tree, |
375 | /// The element is a `ProgressIndicator` or behaves like one. |
376 | ProgressIndicator, |
377 | /// The role for widget with editable text such as a `LineEdit` or a `TextEdit`. |
378 | /// This is automatically applied to `TextInput` elements. |
379 | TextInput, |
380 | /// The element is a `Switch` or behaves like one. |
381 | Switch, |
382 | /// The element is an item in a `ListView`. |
383 | ListItem, |
384 | } |
385 | |
386 | /// This enum represents the different values of the `sort-order` property. |
387 | /// It's used to sort a `StandardTableView` by a column. |
388 | enum SortOrder { |
389 | /// The column is unsorted. |
390 | Unsorted, |
391 | |
392 | /// The column is sorted in ascending order. |
393 | Ascending, |
394 | |
395 | /// The column is sorted in descending order. |
396 | Descending, |
397 | } |
398 | |
399 | /// Represents the orientation of an element or widget such as the `Slider`. |
400 | enum Orientation { |
401 | /// Element is oriented horizontally. |
402 | Horizontal, |
403 | /// Element is oriented vertically. |
404 | Vertical, |
405 | } |
406 | |
407 | /// This enum indicates the color scheme used by the widget style. Use this to explicitly switch |
408 | /// between dark and light schemes, or choose Unknown to fall back to the system default. |
409 | enum ColorScheme { |
410 | /// The scheme is not known and a system wide setting configures this. This could mean that |
411 | /// the widgets are shown in a dark or light scheme, but it could also be a custom color scheme. |
412 | Unknown, |
413 | /// The style chooses light colors for the background and dark for the foreground. |
414 | Dark, |
415 | /// The style chooses dark colors for the background and light for the foreground. |
416 | Light, |
417 | } |
418 | |
419 | /// This enum describes the direction of an animation. |
420 | enum AnimationDirection { |
421 | /// The ["normal" direction as defined in CSS](https://developer.mozilla.org/en-US/docs/Web/CSS/animation-direction#normal). |
422 | Normal, |
423 | /// The ["reverse" direction as defined in CSS](https://developer.mozilla.org/en-US/docs/Web/CSS/animation-direction#reverse). |
424 | Reverse, |
425 | /// The ["alternate" direction as defined in CSS](https://developer.mozilla.org/en-US/docs/Web/CSS/animation-direction#alternate). |
426 | Alternate, |
427 | /// The ["alternate reverse" direction as defined in CSS](https://developer.mozilla.org/en-US/docs/Web/CSS/animation-direction#alternate-reverse). |
428 | AlternateReverse, |
429 | } |
430 | |
431 | /// This enum describes the scrollbar visibility |
432 | enum ScrollBarPolicy { |
433 | /// Scrollbar will be visible only when needed |
434 | AsNeeded, |
435 | /// Scrollbar never shown |
436 | AlwaysOff, |
437 | /// Scrollbar always visible |
438 | AlwaysOn, |
439 | } |
440 | |
441 | // This enum describes the close behavior of `PopupWindow` |
442 | enum PopupClosePolicy { |
443 | /// Closes the `PopupWindow` when user clicks or presses the escape key. |
444 | CloseOnClick, |
445 | |
446 | /// Closes the `PopupWindow` when user clicks outside of the popup or presses the escape key. |
447 | CloseOnClickOutside, |
448 | |
449 | /// Does not close the `PopupWindow` automatically when user clicks. |
450 | NoAutoClose, |
451 | } |
452 | |
453 | /// This enum describes the appearance of the ends of stroked paths. |
454 | enum LineCap { |
455 | /// The stroke ends with a flat edge that is perpendicular to the path. |
456 | Butt, |
457 | /// The stroke ends with a rounded edge. |
458 | Round, |
459 | /// The stroke ends with a square projection beyond the path. |
460 | Square, |
461 | } |
462 | ]; |
463 | }; |
464 | } |
465 | |