Make the LEL layout look perty.

main
Zed A. Shaw 3 days ago
parent 9e6038dd7d
commit 87149af4c7
  1. 8
      README.md
  2. 6
      demos/calc.cpp

@ -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…
Cancel
Save