diff --git a/README.md b/README.md index 73a95a3..45c3574 100644 --- a/README.md +++ b/README.md @@ -83,7 +83,114 @@ by downloading everything, OSX already has most things, and Linux is...well...Li ## Using LEL -Coming soon.. +To use LEL with GUECS you first initialize a `guecs::UI` class with its position and size. Here's +an example taken from the `demos/calc.cpp` example: + +```cpp +$gui.position(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT); +``` + +Then you configure a layout with the LEL formatting language: + +```cpp +$gui.layout( + "[*%(400)stack|_|_|_]" + "[*%(400)readout|_|_|_]" + "[push|pop|clear|eq]" + "[add|sub|mul|div]" + "[btn7|btn8|btn9]" + "[btn4|btn5|btn6]" + "[btn1|btn2|btn3]" + "[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. + +Once you have that you can give your panel a background and render a debug layout: + +```cpp + void render(sf::RenderWindow& window) { + $gui.render(window); + $gui.debug_layout(window); + } +``` + +Since this first version works with SFML this render only takes a `sf::RenderWindow` and renders the +gui to it. With these two calls you'll get red lines showing you the grid specified in `layout()`. + +This lets you refine the layout grid without requiring any components. Keep working the LEL layout until the grid looks good, then add some rectangles and labels: +```cpp +for(auto& [name, cell] : $gui.cells()) { + auto id = $gui.entity(name); + $gui.set(id, {}); + $gui.set