1// Copyright © SixtyFPS GmbH <info@slint.dev>
2// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-1.1 OR LicenseRef-Slint-commercial
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![
23 /// This enum describes the different types of alignment of text along the horizontal axis of a [`Text`](elements.md#text) element.
24 enum TextHorizontalAlignment {
25 /// The text will be aligned with the left edge of the containing box.
26 Left,
27 /// The text will be horizontally centered within the containing box.
28 Center,
29 /// The text will be aligned to the right of the containing box.
30 Right,
31 }
32
33 /// This enum describes the different types of alignment of text along the vertical axis of a [`Text`](elements.md#text) element.
34 enum TextVerticalAlignment {
35 /// The text will be aligned to the top of the containing box.
36 Top,
37 /// The text will be vertically centered within the containing box.
38 Center,
39 /// The text will be aligned to the bottom of the containing box.
40 Bottom,
41 }
42
43 /// This enum describes the how the text wrap if it is too wide to fit in the [`Text`](elements.md#text) width.
44 enum TextWrap {
45 /// The text won't wrap, but instead will overflow.
46 NoWrap,
47 /// The text will be wrapped at word boundaries.
48 WordWrap,
49 }
50
51 /// This enum describes the how the text appear if it is too wide to fit in the [`Text`](elements.md#text) width.
52 enum TextOverflow {
53 /// The text will simply be clipped.
54 Clip,
55 /// The text will be elided with `…`.
56 Elide,
57 }
58
59 /// This enum describes whether an event was rejected or accepted by an event handler.
60 enum EventResult {
61 /// The event is rejected by this event handler and may then be handled by the parent item
62 Reject,
63 /// The event is accepted and won't be processed further
64 Accept,
65 }
66
67 /// This enum describes the different ways of deciding what the inside of a shape described by a path shall be.
68 enum FillRule {
69 /// The ["nonzero" fill rule as defined in SVG](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/fill-rule#nonzero).
70 Nonzero,
71 /// The ["evenodd" fill rule as defined in SVG](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/fill-rule#evenodd)
72 Evenodd,
73 }
74
75 /// Use this enum to add standard buttons to a [`Dialog`](elements.md#dialog). The look and positioning
76 /// of these [`StandardButton`](../widgets/standardbutton.md)s depends on the environment
77 /// (OS, UI environment, etc.) the application runs in.
78 enum StandardButtonKind {
79 /// A "OK" button that accepts a [`Dialog`](elements.md#dialog), closing it when clicked.
80 Ok,
81 /// A "Cancel" button that rejects a [`Dialog`](elements.md#dialog), closing it when clicked.
82 Cancel,
83 /// A "Apply" button that should accept values from a
84 /// [`Dialog`](elements.md#dialog) without closing it.
85 Apply,
86 /// A "Close" button, which should close a [`Dialog`](elements.md#dialog) without looking at values.
87 Close,
88 /// A "Reset" button, which should reset the [`Dialog`](elements.md#dialog) to its initial state.
89 Reset,
90 /// A "Help" button, which should bring up context related documentation when clicked.
91 Help,
92 /// A "Yes" button, used to confirm an action.
93 Yes,
94 /// A "No" button, used to deny an action.
95 No,
96 /// A "Abort" button, used to abort an action.
97 Abort,
98 /// A "Retry" button, used to retry a failed action.
99 Retry,
100 /// A "Ignore" button, used to ignore a failed action.
101 Ignore,
102 }
103
104 /// This enum represents the value of the `dialog-button-role` property which can be added to
105 /// any element within a [`Dialog`](elements.md#dialog) to put that item in the button row, and its exact position
106 /// depends on the role and the platform.
107 enum DialogButtonRole {
108 /// This isn't a button meant to go into the bottom row
109 None,
110 /// This is the role of the main button to click to accept the dialog. e.g. "Ok" or "Yes"
111 Accept,
112 /// This is the role of the main button to click to reject the dialog. e.g. "Cancel" or "No"
113 Reject,
114 /// This is the role of the "Apply" button
115 Apply,
116 /// This is the role of the "Reset" button
117 Reset,
118 /// This is the role of the "Help" button
119 Help,
120 /// This is the role of any other button that performs another action.
121 Action,
122 }
123
124 /// The enum reports what happened to the `PointerEventButton` in the event
125 enum PointerEventKind {
126 /// The action was cancelled.
127 Cancel,
128 /// The button was pressed.
129 Down,
130 /// The button was released.
131 Up,
132 /// The pointer has moved,
133 Move,
134 }
135
136 /// This enum describes the different types of buttons for a pointer event,
137 /// typically on a mouse or a pencil.
138 #[non_exhaustive]
139 enum PointerEventButton {
140 /// A button that is none of left, right or middle. For example
141 /// this is used for a fourth button on a mouse with many buttons.
142 Other,
143 /// The left button.
144 Left,
145 /// The right button.
146 Right,
147 /// The center button.
148 Middle,
149 }
150
151 /// This enum represents different types of mouse cursors. It's a subset of the mouse cursors available in CSS.
152 /// For details and pictograms see the [MDN Documentation for cursor](https://developer.mozilla.org/en-US/docs/Web/CSS/cursor#values).
153 /// Depending on the backend and used OS unidirectional resize cursors may be replaced with bidirectional ones.
154 enum MouseCursor {
155 /// The systems default cursor.
156 Default,
157 /// No cursor is displayed.
158 None,
159 //context_menu,
160 /// A cursor indicating help information.
161 Help,
162 /// A pointing hand indicating a link.
163 Pointer,
164 /// The program is busy but can still be interacted with.
165 Progress,
166 /// The program is busy.
167 Wait,
168 //cell,
169 /// A crosshair.
170 Crosshair,
171 /// A cursor indicating selectable text.
172 Text,
173 //vertical_text,
174 /// An alias or shortcut is being created.
175 Alias,
176 /// A copy is being created.
177 Copy,
178 /// Something is to be moved.
179 Move,
180 /// Something can't be dropped here.
181 NoDrop,
182 /// An action isn't allowed
183 NotAllowed,
184 /// Something is grabbable.
185 Grab,
186 /// Something is being grabbed.
187 Grabbing,
188 //all_scroll,
189 /// Indicating that a column is resizable horizontally.
190 ColResize,
191 /// Indicating that a row is resizable vertically.
192 RowResize,
193 /// Unidirectional resize north.
194 NResize,
195 /// Unidirectional resize east.
196 EResize,
197 /// Unidirectional resize south.
198 SResize,
199 /// Unidirectional resize west.
200 WResize,
201 /// Unidirectional resize north-east.
202 NeResize,
203 /// Unidirectional resize north-west.
204 NwResize,
205 /// Unidirectional resize south-east.
206 SeResize,
207 /// Unidirectional resize south-west.
208 SwResize,
209 /// Bidirectional resize east-west.
210 EwResize,
211 /// Bidirectional resize north-south.
212 NsResize,
213 /// Bidirectional resize north-east-south-west.
214 NeswResize,
215 /// Bidirectional resize north-west-south-east.
216 NwseResize,
217 //zoom_in,
218 //zoom_out,
219 }
220
221 /// This enum defines how the source image shall fit into an [`Image`](elements.md#image) element.
222 enum ImageFit {
223 /// Scales and stretches the source image to fit the width and height of the [`Image`](elements.md#image) element.
224 Fill,
225 /// The source image is scaled to fit into the [`Image`](elements.md#image) element's dimension while preserving the aspect ratio.
226 Contain,
227 /// The source image is scaled to cover into the [`Image`](elements.md#image) element's dimension while preserving the aspect ratio.
228 /// If the aspect ratio of the source image doesn't match the element's one, then the image will be clipped to fit.
229 Cover,
230 /// Preserves the size of the source image in logical pixels.
231 /// The source image will still be scaled by the scale factor that applies to all elements in the window.
232 /// Any extra space will be left blank.
233 Preserve,
234 }
235
236 /// This enum specifies the horizontal alignment of the source image.
237 enum ImageHorizontalAlignment {
238 /// Aligns the source image at the center of the [`Image`](elements.md#image) element.
239 Center,
240 /// Aligns the source image at the left of the [`Image`](elements.md#image) element.
241 Left,
242 /// Aligns the source image at the right of the [`Image`](elements.md#image) element.
243 Right,
244 }
245
246 /// This enum specifies the vertical alignment of the source image.
247 enum ImageVerticalAlignment {
248 /// Aligns the source image at the center of the [`Image`](elements.md#image) element.
249 Center,
250 /// Aligns the source image at the top of the [`Image`](elements.md#image) element.
251 Top,
252 /// Aligns the source image at the bottom of the [`Image`](elements.md#image) element.
253 Bottom,
254 }
255
256 /// This enum specifies how the source image will be scaled.
257 enum ImageRendering {
258 /// The image is scaled with a linear interpolation algorithm.
259 Smooth,
260 /// The image is scaled with the nearest neighbor algorithm.
261 Pixelated,
262 }
263
264 /// This enum specifies how the source image will be tiled.
265 enum ImageTiling {
266 /// The source image will not be tiled.
267 None,
268 /// The source image will be repeated to fill the [`Image`](elements.md#image) element.
269 Repeat,
270 /// The source image will be repeated and scaled to fill the [`Image`](elements.md#image) element, ensuring an integer number of repetitions.
271 Round,
272 }
273
274 /// This enum is used to define the type of the input field.
275 #[non_exhaustive]
276 enum InputType {
277 /// The default value. This will render all characters normally
278 Text,
279 /// This will render all characters with a character that defaults to "*"
280 Password,
281 /// This will only accept and render number characters (0-9)
282 Number,
283 /// This will accept and render characters if it's valid part of a decimal
284 Decimal,
285 }
286
287 /// Enum representing the [alignment](../concepts/layouting.md#alignment) property of a
288 /// [`HorizontalBox`](../widgets/horizontalbox.md), a [`VerticalBox`](../widgets/verticalbox.md),
289 /// a [`HorizontalLayout`, or `VerticalLayout`](elements.md#verticallayout-and-horizontallayout).
290 enum LayoutAlignment {
291 /// Use the minimum size of all elements in a layout, distribute remaining space
292 /// based on `*-stretch` among all elements.
293 Stretch,
294 /// Use the preferred size for all elements, distribute remaining space evenly before the
295 /// first and after the last element.
296 Center,
297 /// Use the preferred size for all elements, put remaining space after the last element.
298 Start,
299 /// Use the preferred size for all elements, put remaining space before the first
300 /// element.
301 End,
302 /// Use the preferred size for all elements, distribute remaining space evenly between
303 /// elements.
304 SpaceBetween,
305 /// Use the preferred size for all elements, distribute remaining space evenly before the
306 /// first element, after the last element and between elements.
307 SpaceAround,
308 }
309
310 /// PathEvent is a low-level data structure describing the composition of a path. Typically it is
311 /// generated at compile time from a higher-level description, such as SVG commands.
312 enum PathEvent {
313 /// The beginning of the path.
314 Begin,
315 /// A straight line on the path.
316 Line,
317 /// A quadratic bezier curve on the path.
318 Quadratic,
319 /// A cubic bezier curve on the path.
320 Cubic,
321 /// The end of the path that remains open.
322 EndOpen,
323 /// The end of a path that is closed.
324 EndClosed,
325 }
326
327 /// This enum represents the different values for the `accessible-role` property, used to describe the
328 /// role of an element in the context of assistive technology such as screen readers.
329 enum AccessibleRole {
330 /// The element isn't accessible.
331 None,
332 /// The element is a [`Button`](../widgets/button.md) or behaves like one.
333 Button,
334 /// The element is a [`CheckBox`](../widgets/checkbox.md) or behaves like one.
335 Checkbox,
336 /// The element is a [`ComboBox`](../widgets/combobox.md) or behaves like one.
337 Combobox,
338 /// The element is a [`Slider`](../widgets/slider.md) or behaves like one.
339 Slider,
340 /// The element is a [`SpinBox`](../widgets/spinbox.md) or behaves like one.
341 Spinbox,
342 /// The element is a [`Tab`](../widgets/tabwidget.md) or behaves like one.
343 Tab,
344 /// The role for a [`Text`](elements.md#text) element. It's automatically applied.
345 Text,
346 /// The element is a [`ProgressIndicator`](../widgets/progressindicator.md) or behaves like one.
347 ProgressIndicator,
348 }
349
350 /// This enum represents the different values of the `sort-order` property.
351 /// It's used to sort a [`StandardTableView`](../widgets/standardtableview.md) by a column.
352 enum SortOrder {
353 /// The column is unsorted.
354 Unsorted,
355
356 /// The column is sorted in ascending order.
357 Ascending,
358
359 /// The column is sorted in descending order.
360 Descending,
361 }
362
363 /// Represents the orientation of an element or widget such as the [`Slider`](../widgets/slider.md).
364 enum Orientation {
365 /// Element is oriented horizontally.
366 Horizontal,
367 /// Element is oriented vertically.
368 Vertical,
369 }
370 ];
371 };
372}
373