Skip to content

Commit

Permalink
Added missing docs
Browse files Browse the repository at this point in the history
  • Loading branch information
britzl committed Sep 2, 2024
1 parent 4cf6acc commit 6587014
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 6 deletions.
62 changes: 56 additions & 6 deletions docs/en/manuals/gui.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,28 +33,75 @@ The central editing area shows the GUI. The toolbar in the top right corner of t

A white rectangle shows the bounds of the currently selected layout, of the default display width and height as set in the project settings.

## Gui properties

Selecting the root "Gui" node in the *Outline* shows the *Properties* for the GUI component:

Script
*Script*
: The GUI script bound to this GUI component.

Material
: The material used when rendering this GUI.
*Material*
: The material used when rendering this GUI. Note that it is also possible to add multiple materials to a Gui from the Outline panel and assign these to individual nodes.

Adjust Reference
*Adjust Reference*
: Controls how each node's *Adjust Mode* should be calculated:

- `Per Node` adjusts each node against the adjusted size of the parent node, or the resized screen.
- `Disable` turns off node adjust mode. This forces all nodes to keep their set size.

Max Nodes
*Max Nodes*
: The maximum number of nodes for this GUI.

*Max Dynamic Textures*
: The maximum number of textures that can be created using [`gui.new_texture()`](/ref/stable/gui/#gui.new_texture:texture_id-width-height-type-buffer-flip)


## Runtime manipulation

You can manipulate GUI properties in runtime using `go.get()` and `go.set()`:

Fonts
: Get or set a font used in a GUI.

```lua
go.property("mybigfont", resource.font("/assets/mybig.font"))

function init(self)
local current_font = go.get("#gui", "bigfont")
go.set("#gui", "bigfont", self.mybigfont)
end
```

Materials
: Get or set a material used in a GUI.

```lua
go.property("mymaterial", resource.font("/assets/my.material"))

function init(self)
local current_material = go.get("#gui", "specialmaterial")
go.set("#gui", "specialmaterial", self.mymaterial)
end
```

Textures
: Get or set a texture (atlas) used in a GUI.

```lua
go.property("myatlas", resource.font("/assets/my.atlas"))

function init(self)
local current_atlas = go.get("#gui", "theme")
go.set("#gui", "theme", self.myatlas)
end
```


## Dependencies

The resource tree in a Defold game is static so any dependencies that you need for your GUI nodes need to be added to the component. The *Outline* groups all dependencies by type under "folders":

![dependencies](images/gui/dependencies.png){srcset="images/gui/[email protected] 2x"}
![dependencies](images/gui/dependencies.png)

To add a new dependency, <kbd>right click</kbd> the "Gui" root in the *Outline*, then select <kbd>Add ▸ [type]</kbd> from the popup context menu.

Expand Down Expand Up @@ -134,6 +181,9 @@ Font (text nodes)
Texture (box and pie nodes)
: The texture to draw on the node. This is a reference to an image or animation in an atlas or tile source.

Material (box, pie nodes, text and particlefx nodes)
: The material to use when drawing the node. This can either be a material added to the Materials section of the outline or left blank to use the default material assigned to the GUI component.

Slice 9 (box nodes)
: Set to preserve the pixel size of the node's texture around the edges when the node is resized. See the [Box node documentation](/manuals/gui-box) for details.

Expand Down
Binary file modified docs/en/manuals/images/gui/dependencies.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/en/manuals/images/gui/[email protected]
Binary file not shown.

0 comments on commit 6587014

Please sign in to comment.