mirror of
https://github.com/RGBCube/serenity
synced 2025-05-17 20:15:08 +00:00

This is a bundle of changes to the "new" GML documentation that I just noticed two hours ago. - Fix a bunch of typos, wording and style - Rework layout object documentation (they're not widgets!) - Document most of the common properties - Finish (as for now) GML syntax documentation - Extend GML usage explanation - Add symlink "GML" so that man gml works - Add a categorized GML page list to the introduction man page - Cross-link much more Much of the editing of existing docs is clearing up incorrect or imprecise statements. Note that because of massive changes in some places, git won't recognize renames as such.
48 lines
995 B
Markdown
48 lines
995 B
Markdown
## Name
|
|
|
|
GML Usage
|
|
|
|
## Description
|
|
|
|
How to use GML in SerenityOS C++ applications
|
|
|
|
## CMake
|
|
|
|
Include `compile_gml()` your applications CMake file. The header file name and GML string name are not fixed but must follow this convention.
|
|
|
|
```cmake
|
|
compile_gml(MyApp.gml MyAppGML.h my_app_gml)
|
|
```
|
|
|
|
Include the name of the header file that will be compiled from your GML file in your `SOURCES`.
|
|
|
|
```cmake
|
|
set(SOURCES
|
|
MyAppGML.h
|
|
)
|
|
```
|
|
|
|
## C++
|
|
|
|
You can then reference the variable you set (e.g. `my_app_gml`) in your main C++ file using `load_from_gml()`.
|
|
|
|
```cpp
|
|
load_from_gml(my_app_gml);
|
|
```
|
|
|
|
From there, you can use `find_descendant_of_type_named` to select widgets from your GML by their `name` property.
|
|
|
|
```gml
|
|
@GUI::Button {
|
|
name: "mem_add_button"
|
|
text: "M+"
|
|
fixed_width: 35
|
|
fixed_height: 28
|
|
foreground_color: "red"
|
|
}
|
|
```
|
|
Is referenced using...
|
|
```cpp
|
|
load_from_gml(calculator_gml);
|
|
m_mem_add_button = *find_descendant_of_type_named<GUI::Button>("mem_add_button");
|
|
```
|