Document visible = false and no_prepend = true

This commit is contained in:
luk3yx 2023-01-13 15:24:45 +13:00
parent 299ccfcddc
commit 9cad6a94bd
2 changed files with 35 additions and 0 deletions

View File

@ -345,3 +345,37 @@ gui.Button{
```
The style elements are invisible and won't affect padding.
## Experimental features
These features might be broken in the future.
### Hiding elements
Elements inside boxes can have `visible = false` set to hide them from the
player. Elements hidden this way will still take up space like with
`visibility: hidden;` in CSS.
### `no_prepend[]`
You can set `no_prepend = true` on the "root" element to disable formspec
prepends.
Example:
```lua
local my_gui = flow.make_gui(function(player, ctx)
return gui.VBox{
no_prepend = true,
gui.Button{label = "Button 1"},
-- There will be an empty space where the second button would be
gui.Button{label = "Button 2", visible = false},
gui.Button{label = "Button 3"},
}
end)
```
![Screenshot](https://user-images.githubusercontent.com/3182651/212222545-baee3669-15cd-410d-a638-c63b65a8811b.png)

View File

@ -419,6 +419,7 @@ local function render_ast(node)
res[#res + 1] = {type = "no_prepend"}
end
if node.fbgcolor then
-- TODO: Fix this
res[#res + 1] = {
type = "bgcolor",
bgcolor = node.fbgcolor,