You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Base/usr/share/man/man5/GML-Syntax.md
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -90,6 +90,7 @@ A property's `value` is required to be either a JSON value or another object. Ob
90
90
Among the supported JSON values, these types can be further distinguished:
91
91
92
92
-`int`: Regular JSON integer, note that JSON floats are not currently used.
93
+
-`ui_dimension`: either positive integers, that work just like `int`, or special meaning values as JSON strings; see [UI Dimensions](help://man/5/GML-UI-Dimensions)
93
94
-`bool`: Regular JSON boolean, may be enclosed in quotes but this is discouraged.
94
95
-`string`: JSON string, also used as a basis for other types.
95
96
-`readonly_string`: String-valued property that cannot be changed from C++ later.
@@ -99,6 +100,7 @@ Among the supported JSON values, these types can be further distinguished:
99
100
-`text_wrapping`: Special case of `enum` for `Gfx::TextWrapping`. One of `Wrap` or `DontWrap`.
100
101
-`rect`: A JSON object of four `int`s specifying a rectangle. The keys are `x`, `y`, `width`, `height`.
101
102
-`size`: A JSON array of two `int`s specifying two sizes in the format `[width, height]`.
103
+
-`ui_size`: A JSON array of two `ui_dimension`s specifying two sizes in the format `[width, height]`
102
104
-`margins`: A JSON array or object specifying four-directional margins as `int`s. If this is a JSON object, the four keys `top`, `right`, `bottom`, `left` are used. If this is a JSON array, there can be one to four integers. These have the following meaning (see also `GUI::Margins`):
103
105
-`[ all_four_margins ]`
104
106
-`[ top_and_bottom, right_and_left ]`
@@ -232,3 +234,4 @@ GML files can be found in the SerenityOS source tree with the `*.gml` extension.
UI Dimension (or [GUI::UIDimension](file:///usr/src/serenity/Userland/Libraries/LibGUI/UIDimensions.h) in c++) is a special, union — of positive integer and enum — like, type that is used to represent dimensions in a user interface context.
8
+
9
+
It can either store positive integers ≥0 or special meaning values from a pre determined set.
10
+
11
+
## Basic Syntax
12
+
13
+
In GML UI Dimensions that are "regular" values (integer ≥0) are represented by JSON's int type,
14
+
while "special" values are represented by their name as a JSON string type.
15
+
16
+
# Special Values
17
+
18
+
Special Values carry size information that would otherwise not be intuitively possible to be transported by an integer (positive or negative) alone.
19
+
20
+
Importantly, while any "regular" (i.e. int ≥0) UI Dimension values might (by convention) be assigned to any UI Dimension property, many properties only allow a subset of the "special" values to be assigned to them.
21
+
22
+
| Name | c++ name | GML/JSON representation | General meaning |
| Regular |`GUI::SpecialDimension::Regular` (mock) | int ≥0 | This is a regular integer value specifying a specific size |
25
+
| Grow |`GUI::SpecialDimension::Grow`|`"grow"`| Grow to the maximum size the surrounding allows |
26
+
| OpportunisticGrow |`GUI::SpecialDimension::OpportunisticGrow`|`"opportunistic_grow"`| Grow when the opportunity arises, meaning — only when all other widgets have already grown to their maximum size, and only opportunistically growing widgets are left |
27
+
| Fit |`GUI::SpecialDimension::Fit`|`"fit"`| Grow exactly to the size of the surrounding as determined by other factors, but do not call for e.g. expansion of the parent container itself |
28
+
| Shrink |`GUI::SpecialDimension::Shrink`|`"shrink"`| Shrink to the smallest size possible |
0 commit comments