Make the LEL layout look perty.
This commit is contained in:
parent
9e6038dd7d
commit
87149af4c7
2 changed files with 8 additions and 6 deletions
|
@ -94,14 +94,14 @@ Then you configure a layout with the LEL formatting language:
|
|||
|
||||
```cpp
|
||||
$gui.layout(
|
||||
"[*%(400)stack|_|_|_]"
|
||||
"[*%(400)stack |_|_|_]"
|
||||
"[*%(400)readout|_|_|_]"
|
||||
"[push|pop|clear|eq]"
|
||||
"[add|sub|mul|div]"
|
||||
"[add |sub|mul |div]"
|
||||
"[btn7|btn8|btn9]"
|
||||
"[btn4|btn5|btn6]"
|
||||
"[btn1|btn2|btn3]"
|
||||
"[neg|btn0|_]");
|
||||
"[neg |btn0|_ ]");
|
||||
```
|
||||
|
||||
This creates a simple RPN calculator UI with buttons for numbers, readouts for the results and stack, and basic math operators. For people from other languages, this is actually one big string, but C++ (like C) allows you to "concatenate" strings together that are next to each other, so I just put them on separate lines so they look more like the grid they represent.
|
||||
|
@ -125,6 +125,8 @@ for(auto& [name, cell] : $gui.cells()) {
|
|||
$gui.set<Rectangle>(id, {});
|
||||
$gui.set<Label>(id, { guecs::to_wstring(name) });
|
||||
}
|
||||
|
||||
$gui.init(); // must be called when done
|
||||
```
|
||||
|
||||
You'll notice I have `guecs::to_wstring(name)` which uses the forbidden unicode conversion `codecvt`
|
||||
|
|
|
@ -138,14 +138,14 @@ struct CalculatorUI {
|
|||
CalculatorUI() {
|
||||
$gui.position(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT);
|
||||
$gui.layout(
|
||||
"[*%(400)stack|_|_|_]"
|
||||
"[*%(400)stack |_|_|_]"
|
||||
"[*%(400)readout|_|_|_]"
|
||||
"[push|pop|clear|eq]"
|
||||
"[add|sub|mul|div]"
|
||||
"[add |sub|mul |div]"
|
||||
"[btn7|btn8|btn9]"
|
||||
"[btn4|btn5|btn6]"
|
||||
"[btn1|btn2|btn3]"
|
||||
"[neg|btn0|_]");
|
||||
"[neg |btn0|_ ]");
|
||||
}
|
||||
|
||||
void init() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue