Update docs

This commit is contained in:
Insality 2025-03-18 22:58:13 +02:00
parent 44b735adda
commit f786b20951
17 changed files with 399228 additions and 57 deletions

View File

@ -137,7 +137,10 @@ end
Create a new lua file to create a new widget class. This widget can be created with `self.druid:new_widget(widget_class, [template], [nodes])`
Usually this widget lua file is placed nearby with the `GUI` file it belong to and have the same name.
```lua
---@class your_widget_class: druid.widget
local M = {}
function M:init()
@ -155,18 +158,13 @@ return M
### API Documentation
**Druid** offers a wide range of components and functions. To facilitate usage, **Druid** provides comprehensive API documentation with examples and annotations.
Best start is from the [Quick API Reference](api/quick_api_reference.md)
Start reading the API documentation [here](https://insality.github.io/druid/modules/Druid.html).
With next quick links:
**Druid** provide the *EmmyLua* annotations to add autocomplete inside your IDE. Check [EmmyLua Setup here](docs_md/advanced-setup.md#emmylua-annotations).
### Create custom components
If you want to create your own components, refer to the [Create Custom Components](docs_md/02-creating_custom_components.md) section in the documentation.
Custom components are one of the most powerful features of **Druid**. They allow you to create your own components effortlessly and utilize them in your game.
- [Druid Instance](api/druid_instance_api.md) - **Druid** instance returned from `druid.new(self)`
- [Helper](api/helper_api.md) - A lot of useful functions
- [Widgets](wiki/widgets.md) - All widgets with examples
## Druid Components
@ -208,10 +206,24 @@ All **Druid** components using [Defold Event](https://github.com/Insality/defold
- **event:unsubscribe**(callback)
- **event:clear**()
You can subscribe several callbacks to a single event.
Examples:
```lua
button.on_click_event:subscribe(function(self, args)
print("Button clicked!")
end)
scroll.on_scroll:subscribe(function(self, position)
print("Scroll scrolled!")
end)
input.on_input_unselect:subscribe(function(self, text)
print("User enter input:", text)
end)
```
## Details
- **Druid** processes input in a stack-based manner. The most recently created button will be checked first. Create your input GUI components from back to front.
@ -230,15 +242,15 @@ Or refer directly to the [**example folder**](https://github.com/Insality/druid/
## Documentation
You can find the full **Druid** functions at [Quick API Reference](api/quick_api_reference.md)
To better understand **Druid**, read the following documentation:
- [How To GUI in Defold](https://forum.defold.com/t/how-to-gui-in-defold/73256)
- [Widgets](wiki/widgets.md)
- [Druid components](docs_md/01-components.md)
- [Create custom components](docs_md/02-creating_custom_components.md)
- [See FAQ article](docs_md/FAQ.md)
- [Druid styles](docs_md/03-styles.md)
You can find the full **Druid** [documentation here](https://insality.github.io/druid/modules/Druid.html).
## Licenses

View File

@ -0,0 +1,97 @@
# druid.widget.fps_panel API
> at /druid/widget/fps_panel/fps_panel.lua
## Functions
- [init](#init)
- [on_remove](#on_remove)
- [update](#update)
- [push_fps_value](#push_fps_value)
## Fields
- [root](#root)
- [delta_time](#delta_time)
- [collect_time](#collect_time)
- [collect_time_counter](#collect_time_counter)
- [graph_samples](#graph_samples)
- [fps_samples](#fps_samples)
- [mini_graph](#mini_graph)
- [text_min_fps](#text_min_fps)
- [text_fps](#text_fps)
- [timer_id](#timer_id)
- [previous_time](#previous_time)
### init
---
```lua
fps_panel:init()
```
### on_remove
---
```lua
fps_panel:on_remove()
```
### update
---
```lua
fps_panel:update([dt])
```
- **Parameters:**
- `[dt]` *(any)*:
### push_fps_value
---
```lua
fps_panel:push_fps_value()
```
## Fields
<a name="root"></a>
- **root** (_node_)
<a name="delta_time"></a>
- **delta_time** (_number_): in seconds
<a name="collect_time"></a>
- **collect_time** (_integer_): in seconds
<a name="collect_time_counter"></a>
- **collect_time_counter** (_integer_)
<a name="graph_samples"></a>
- **graph_samples** (_number_)
<a name="fps_samples"></a>
- **fps_samples** (_table_): Store frame time in seconds last collect_time seconds
<a name="mini_graph"></a>
- **mini_graph** (_druid.widget.mini_graph_): Widget to display a several lines with different height in a row
Init, set amount of samples and max value of value means that the line will be at max height
Use `push_line_value` to add a new value to the line
Or `set_line_value` to set a value to the line by index
Setup colors inside template file (at minimum and maximum)
<a name="text_min_fps"></a>
- **text_min_fps** (_druid.text_): The component to handle text behaviour over a GUI Text node, mainly used to automatically adjust text size to fit the text area
<a name="text_fps"></a>
- **text_fps** (_druid.text_): The component to handle text behaviour over a GUI Text node, mainly used to automatically adjust text size to fit the text area
<a name="timer_id"></a>
- **timer_id** (_unknown_)
<a name="previous_time"></a>
- **previous_time** (_unknown_)

View File

@ -0,0 +1,105 @@
# druid.widget.memory_panel API
> at /druid/widget/memory_panel/memory_panel.lua
## Functions
- [init](#init)
- [on_remove](#on_remove)
- [set_low_memory_limit](#set_low_memory_limit)
- [push_next_value](#push_next_value)
- [update_text_memory](#update_text_memory)
## Fields
- [root](#root)
- [delta_time](#delta_time)
- [samples_count](#samples_count)
- [memory_limit](#memory_limit)
- [mini_graph](#mini_graph)
- [max_value](#max_value)
- [text_per_second](#text_per_second)
- [text_memory](#text_memory)
- [memory](#memory)
- [memory_samples](#memory_samples)
- [timer_id](#timer_id)
### init
---
```lua
memory_panel:init()
```
### on_remove
---
```lua
memory_panel:on_remove()
```
### set_low_memory_limit
---
```lua
memory_panel:set_low_memory_limit([limit])
```
- **Parameters:**
- `[limit]` *(any)*:
### push_next_value
---
```lua
memory_panel:push_next_value()
```
### update_text_memory
---
```lua
memory_panel:update_text_memory()
```
## Fields
<a name="root"></a>
- **root** (_node_)
<a name="delta_time"></a>
- **delta_time** (_number_)
<a name="samples_count"></a>
- **samples_count** (_integer_)
<a name="memory_limit"></a>
- **memory_limit** (_integer_)
<a name="mini_graph"></a>
- **mini_graph** (_druid.widget.mini_graph_): Widget to display a several lines with different height in a row
Init, set amount of samples and max value of value means that the line will be at max height
Use `push_line_value` to add a new value to the line
Or `set_line_value` to set a value to the line by index
Setup colors inside template file (at minimum and maximum)
<a name="max_value"></a>
- **max_value** (_druid.text_): The component to handle text behaviour over a GUI Text node, mainly used to automatically adjust text size to fit the text area
<a name="text_per_second"></a>
- **text_per_second** (_druid.text_): The component to handle text behaviour over a GUI Text node, mainly used to automatically adjust text size to fit the text area
<a name="text_memory"></a>
- **text_memory** (_druid.text_): The component to handle text behaviour over a GUI Text node, mainly used to automatically adjust text size to fit the text area
<a name="memory"></a>
- **memory** (_unknown_)
<a name="memory_samples"></a>
- **memory_samples** (_table_)
<a name="timer_id"></a>
- **timer_id** (_unknown_)

View File

@ -1,4 +1,4 @@
# widget.mini_graph API
# druid.widget.mini_graph API
> at /druid/widget/mini_graph/mini_graph.lua
@ -8,8 +8,6 @@ Use `push_line_value` to add a new value to the line
Or `set_line_value` to set a value to the line by index
Setup colors inside template file (at minimum and maximum)
## Table of Contents
## Functions
- [init](#init)
@ -96,8 +94,6 @@ mini_graph:set_line_value(index, value)
```
Set normalized to control the color of the line
for index = 1, mini_graph:get_samples() do
end
- **Parameters:**
- `index` *(number)*:
@ -106,7 +102,9 @@ Set normalized to control the color of the line
- **Example Usage:**
```lua
mini_graph:set_line_value(index, math.random())
for index = 1, mini_graph:get_samples() do
mini_graph:set_line_value(index, math.random())
end
```
### get_line_value
@ -184,7 +182,7 @@ mini_graph:toggle_hide()
```
- **Returns:**
- `` *(widget.mini_graph)*:
- `` *(druid.widget.mini_graph)*:
## Fields
@ -192,7 +190,7 @@ mini_graph:toggle_hide()
- **root** (_node_)
<a name="text_header"></a>
- **text_header** (_druid.text_)
- **text_header** (_druid.text_): The component to handle text behaviour over a GUI Text node, mainly used to automatically adjust text size to fit the text area
<a name="icon_drag"></a>
- **icon_drag** (_node_)
@ -201,7 +199,7 @@ mini_graph:toggle_hide()
- **content** (_node_)
<a name="layout"></a>
- **layout** (_druid.layout_)
- **layout** (_druid.layout_): The component used for managing the layout of nodes, placing them inside the node size with respect to the size and pivot of each node
<a name="prefab_line"></a>
- **prefab_line** (_node_)
@ -225,7 +223,7 @@ mini_graph:toggle_hide()
- **values** (_table_)
<a name="container"></a>
- **container** (_druid.container_)
- **container** (_druid.container_): The component used for managing the size and positions with other containers relations to create a adaptable layouts
<a name="default_size"></a>
- **default_size** (_vector3_)

View File

@ -0,0 +1,97 @@
# druid.widget.property_button API
> at /druid/widget/properties_panel/properties/property_button.lua
## Functions
- [init](#init)
- [on_click](#on_click)
- [set_text_property](#set_text_property)
- [set_text_button](#set_text_button)
- [set_color](#set_color)
## Fields
- [root](#root)
- [container](#container)
- [text_name](#text_name)
- [button](#button)
- [text_button](#text_button)
- [druid](#druid)
- [selected](#selected)
### init
---
```lua
property_button:init()
```
### on_click
---
```lua
property_button:on_click()
```
### set_text_property
---
```lua
property_button:set_text_property(text)
```
- **Parameters:**
- `text` *(string)*:
- **Returns:**
- `` *(druid.widget.property_button)*:
### set_text_button
---
```lua
property_button:set_text_button(text)
```
- **Parameters:**
- `text` *(string)*:
- **Returns:**
- `` *(druid.widget.property_button)*:
### set_color
---
```lua
property_button:set_color([color_value])
```
- **Parameters:**
- `[color_value]` *(any)*:
## Fields
<a name="root"></a>
- **root** (_node_)
<a name="container"></a>
- **container** (_druid.container_): The component used for managing the size and positions with other containers relations to create a adaptable layouts
<a name="text_name"></a>
- **text_name** (_druid.text_): The component to handle text behaviour over a GUI Text node, mainly used to automatically adjust text size to fit the text area
<a name="button"></a>
- **button** (_druid.button_): Druid component to make clickable node with various interaction callbacks
<a name="text_button"></a>
- **text_button** (_druid.text_): The component to handle text behaviour over a GUI Text node, mainly used to automatically adjust text size to fit the text area
<a name="druid"></a>
- **druid** (_druid.instance_): The Druid Factory used to create components
<a name="selected"></a>
- **selected** (_node_)

View File

@ -0,0 +1,112 @@
# druid.widget.property_checkbox API
> at /druid/widget/properties_panel/properties/property_checkbox.lua
## Functions
- [init](#init)
- [set_value](#set_value)
- [get_value](#get_value)
- [on_click](#on_click)
- [set_text_property](#set_text_property)
- [on_change](#on_change)
## Fields
- [root](#root)
- [druid](#druid)
- [text_name](#text_name)
- [button](#button)
- [selected](#selected)
- [icon](#icon)
- [container](#container)
- [on_change_value](#on_change_value)
### init
---
```lua
property_checkbox:init()
```
### set_value
---
```lua
property_checkbox:set_value(value, [is_instant])
```
- **Parameters:**
- `value` *(boolean)*:
- `[is_instant]` *(any)*:
### get_value
---
```lua
property_checkbox:get_value()
```
- **Returns:**
- `` *(boolean)*:
### on_click
---
```lua
property_checkbox:on_click()
```
### set_text_property
---
```lua
property_checkbox:set_text_property(text)
```
Set the text property of the checkbox
- **Parameters:**
- `text` *(string)*:
### on_change
---
```lua
property_checkbox:on_change(callback)
```
Set the callback function for when the checkbox value changes
- **Parameters:**
- `callback` *(function)*:
## Fields
<a name="root"></a>
- **root** (_node_)
<a name="druid"></a>
- **druid** (_druid.instance_): The Druid Factory used to create components
<a name="text_name"></a>
- **text_name** (_druid.text_): The component to handle text behaviour over a GUI Text node, mainly used to automatically adjust text size to fit the text area
<a name="button"></a>
- **button** (_druid.button_): Druid component to make clickable node with various interaction callbacks
<a name="selected"></a>
- **selected** (_node_)
<a name="icon"></a>
- **icon** (_node_)
<a name="container"></a>
- **container** (_druid.container_): The component used for managing the size and positions with other containers relations to create a adaptable layouts
<a name="on_change_value"></a>
- **on_change_value** (_unknown_)

View File

@ -0,0 +1,90 @@
# druid.widget.property_input API
> at /druid/widget/properties_panel/properties/property_input.lua
## Functions
- [init](#init)
- [set_text_property](#set_text_property)
- [set_text_value](#set_text_value)
- [on_change](#on_change)
## Fields
- [root](#root)
- [container](#container)
- [text_name](#text_name)
- [button](#button)
- [druid](#druid)
- [selected](#selected)
- [rich_input](#rich_input)
### init
---
```lua
property_input:init()
```
### set_text_property
---
```lua
property_input:set_text_property(text)
```
- **Parameters:**
- `text` *(string)*:
- **Returns:**
- `` *(druid.widget.property_input)*:
### set_text_value
---
```lua
property_input:set_text_value(text)
```
- **Parameters:**
- `text` *(string|number)*:
- **Returns:**
- `` *(druid.widget.property_input)*:
### on_change
---
```lua
property_input:on_change(callback, [callback_context])
```
- **Parameters:**
- `callback` *(fun(self: druid.widget.property_input, text: string))*:
- `[callback_context]` *(any)*:
## Fields
<a name="root"></a>
- **root** (_node_)
<a name="container"></a>
- **container** (_druid.container_): The component used for managing the size and positions with other containers relations to create a adaptable layouts
<a name="text_name"></a>
- **text_name** (_druid.text_): The component to handle text behaviour over a GUI Text node, mainly used to automatically adjust text size to fit the text area
<a name="button"></a>
- **button** (_druid.button_): Druid component to make clickable node with various interaction callbacks
<a name="druid"></a>
- **druid** (_druid.instance_): The Druid Factory used to create components
<a name="selected"></a>
- **selected** (_node_)
<a name="rich_input"></a>
- **rich_input** (_druid.rich_input_): The component that handles a rich text input field, it's a wrapper around the druid.input component

View File

@ -0,0 +1,171 @@
# druid.widget.property_left_right_selector API
> at /druid/widget/properties_panel/properties/property_left_right_selector.lua
## Functions
- [init](#init)
- [set_text](#set_text)
- [on_button_left](#on_button_left)
- [on_button_right](#on_button_right)
- [add_step](#add_step)
- [set_number_type](#set_number_type)
- [set_array_type](#set_array_type)
- [set_value](#set_value)
- [get_value](#get_value)
## Fields
- [root](#root)
- [druid](#druid)
- [text_name](#text_name)
- [button](#button)
- [selected](#selected)
- [value](#value)
- [on_change_value](#on_change_value)
- [text_value](#text_value)
- [button_left](#button_left)
- [button_right](#button_right)
- [container](#container)
- [number_type](#number_type)
- [array_type](#array_type)
### init
---
```lua
property_left_right_selector:init()
```
### set_text
---
```lua
property_left_right_selector:set_text([text])
```
- **Parameters:**
- `[text]` *(any)*:
- **Returns:**
- `` *(druid.widget.property_left_right_selector)*:
### on_button_left
---
```lua
property_left_right_selector:on_button_left()
```
### on_button_right
---
```lua
property_left_right_selector:on_button_right()
```
### add_step
---
```lua
property_left_right_selector:add_step(koef)
```
- **Parameters:**
- `koef` *(number)*: -1 0 1, on 0 will not move
### set_number_type
---
```lua
property_left_right_selector:set_number_type([min], [max], [is_loop], [steps])
```
- **Parameters:**
- `[min]` *(any)*:
- `[max]` *(any)*:
- `[is_loop]` *(any)*:
- `[steps]` *(any)*:
- **Returns:**
- `` *(druid.widget.property_left_right_selector)*:
### set_array_type
---
```lua
property_left_right_selector:set_array_type([array], [is_loop], [steps])
```
- **Parameters:**
- `[array]` *(any)*:
- `[is_loop]` *(any)*:
- `[steps]` *(any)*:
- **Returns:**
- `` *(druid.widget.property_left_right_selector)*:
### set_value
---
```lua
property_left_right_selector:set_value(value, [is_instant])
```
- **Parameters:**
- `value` *(string|number)*:
- `[is_instant]` *(any)*:
### get_value
---
```lua
property_left_right_selector:get_value()
```
- **Returns:**
- `` *(string|number)*:
## Fields
<a name="root"></a>
- **root** (_node_)
<a name="druid"></a>
- **druid** (_druid.instance_): The Druid Factory used to create components
<a name="text_name"></a>
- **text_name** (_druid.text_): The component to handle text behaviour over a GUI Text node, mainly used to automatically adjust text size to fit the text area
<a name="button"></a>
- **button** (_druid.button_): Druid component to make clickable node with various interaction callbacks
<a name="selected"></a>
- **selected** (_node_)
<a name="value"></a>
- **value** (_string_)
<a name="on_change_value"></a>
- **on_change_value** (_event_): fun(value: string|number)
<a name="text_value"></a>
- **text_value** (_druid.text_): The component to handle text behaviour over a GUI Text node, mainly used to automatically adjust text size to fit the text area
<a name="button_left"></a>
- **button_left** (_druid.button_): Druid component to make clickable node with various interaction callbacks
<a name="button_right"></a>
- **button_right** (_druid.button_): Druid component to make clickable node with various interaction callbacks
<a name="container"></a>
- **container** (_druid.container_): The component used for managing the size and positions with other containers relations to create a adaptable layouts
<a name="number_type"></a>
- **number_type** (_table_)
<a name="array_type"></a>
- **array_type** (_table_)

View File

@ -0,0 +1,150 @@
# druid.widget.property_slider API
> at /druid/widget/properties_panel/properties/property_slider.lua
## Functions
- [init](#init)
- [set_text_function](#set_text_function)
- [set_text_property](#set_text_property)
- [on_change](#on_change)
- [set_value](#set_value)
- [get_value](#get_value)
- [update_value](#update_value)
- [set_number_type](#set_number_type)
## Fields
- [root](#root)
- [container](#container)
- [druid](#druid)
- [text_name](#text_name)
- [text_value](#text_value)
- [slider](#slider)
- [on_change_value](#on_change_value)
- [selected](#selected)
- [min](#min)
- [max](#max)
- [step](#step)
### init
---
```lua
property_slider:init()
```
### set_text_function
---
```lua
property_slider:set_text_function(callback)
```
- **Parameters:**
- `callback` *(fun(value: number):string)*:
### set_text_property
---
```lua
property_slider:set_text_property(text)
```
Sets the text property of the slider
- **Parameters:**
- `text` *(string)*:
### on_change
---
```lua
property_slider:on_change(callback)
```
Sets the callback function for when the slider value changes
- **Parameters:**
- `callback` *(fun(value: number))*:
### set_value
---
```lua
property_slider:set_value(value, [is_instant])
```
- **Parameters:**
- `value` *(number)*:
- `[is_instant]` *(any)*:
### get_value
---
```lua
property_slider:get_value()
```
- **Returns:**
- `` *(number)*:
### update_value
---
```lua
property_slider:update_value([value])
```
- **Parameters:**
- `[value]` *(any)*:
### set_number_type
---
```lua
property_slider:set_number_type([min], [max], [step])
```
- **Parameters:**
- `[min]` *(any)*:
- `[max]` *(any)*:
- `[step]` *(any)*:
## Fields
<a name="root"></a>
- **root** (_node_)
<a name="container"></a>
- **container** (_druid.container_): The component used for managing the size and positions with other containers relations to create a adaptable layouts
<a name="druid"></a>
- **druid** (_druid.instance_): The Druid Factory used to create components
<a name="text_name"></a>
- **text_name** (_druid.text_): The component to handle text behaviour over a GUI Text node, mainly used to automatically adjust text size to fit the text area
<a name="text_value"></a>
- **text_value** (_druid.text_): The component to handle text behaviour over a GUI Text node, mainly used to automatically adjust text size to fit the text area
<a name="slider"></a>
- **slider** (_druid.slider_): The component to make a draggable node over a line with a progress report
<a name="on_change_value"></a>
- **on_change_value** (_event_): fun(value:number)
<a name="selected"></a>
- **selected** (_node_)
<a name="min"></a>
- **min** (_integer_)
<a name="max"></a>
- **max** (_integer_)
<a name="step"></a>
- **step** (_number_)

View File

@ -0,0 +1,66 @@
# druid.widget.property_text API
> at /druid/widget/properties_panel/properties/property_text.lua
## Functions
- [init](#init)
- [set_text_property](#set_text_property)
- [set_text_value](#set_text_value)
## Fields
- [root](#root)
- [container](#container)
- [text_name](#text_name)
- [text_right](#text_right)
### init
---
```lua
property_text:init()
```
### set_text_property
---
```lua
property_text:set_text_property(text)
```
- **Parameters:**
- `text` *(string)*:
- **Returns:**
- `` *(druid.widget.property_text)*:
### set_text_value
---
```lua
property_text:set_text_value([text])
```
- **Parameters:**
- `[text]` *(string|nil)*:
- **Returns:**
- `` *(druid.widget.property_text)*:
## Fields
<a name="root"></a>
- **root** (_node_)
<a name="container"></a>
- **container** (_druid.container_): The component used for managing the size and positions with other containers relations to create a adaptable layouts
<a name="text_name"></a>
- **text_name** (_druid.text_): The component to handle text behaviour over a GUI Text node, mainly used to automatically adjust text size to fit the text area
<a name="text_right"></a>
- **text_right** (_druid.text_): The component to handle text behaviour over a GUI Text node, mainly used to automatically adjust text size to fit the text area

View File

@ -0,0 +1,104 @@
# druid.widget.property_vector3 API
> at /druid/widget/properties_panel/properties/property_vector3.lua
## Functions
- [init](#init)
- [set_text_property](#set_text_property)
- [set_value](#set_value)
## Fields
- [root](#root)
- [container](#container)
- [text_name](#text_name)
- [button](#button)
- [druid](#druid)
- [selected_x](#selected_x)
- [selected_y](#selected_y)
- [selected_z](#selected_z)
- [rich_input_x](#rich_input_x)
- [rich_input_y](#rich_input_y)
- [rich_input_z](#rich_input_z)
- [value](#value)
- [on_change](#on_change)
### init
---
```lua
property_vector3:init()
```
### set_text_property
---
```lua
property_vector3:set_text_property(text)
```
- **Parameters:**
- `text` *(string)*:
- **Returns:**
- `` *(druid.widget.property_vector3)*:
### set_value
---
```lua
property_vector3:set_value(x, y, z)
```
- **Parameters:**
- `x` *(number)*:
- `y` *(number)*:
- `z` *(number)*:
- **Returns:**
- `` *(druid.widget.property_vector3)*:
## Fields
<a name="root"></a>
- **root** (_node_)
<a name="container"></a>
- **container** (_druid.container_): The component used for managing the size and positions with other containers relations to create a adaptable layouts
<a name="text_name"></a>
- **text_name** (_druid.text_): The component to handle text behaviour over a GUI Text node, mainly used to automatically adjust text size to fit the text area
<a name="button"></a>
- **button** (_druid.button_): Druid component to make clickable node with various interaction callbacks
<a name="druid"></a>
- **druid** (_druid.instance_): The Druid Factory used to create components
<a name="selected_x"></a>
- **selected_x** (_node_)
<a name="selected_y"></a>
- **selected_y** (_node_)
<a name="selected_z"></a>
- **selected_z** (_node_)
<a name="rich_input_x"></a>
- **rich_input_x** (_druid.rich_input_): The component that handles a rich text input field, it's a wrapper around the druid.input component
<a name="rich_input_y"></a>
- **rich_input_y** (_druid.rich_input_): The component that handles a rich text input field, it's a wrapper around the druid.input component
<a name="rich_input_z"></a>
- **rich_input_z** (_druid.rich_input_): The component that handles a rich text input field, it's a wrapper around the druid.input component
<a name="value"></a>
- **value** (_unknown_)
<a name="on_change"></a>
- **on_change** (_unknown_)

View File

@ -0,0 +1,366 @@
# druid.widget.properties_panel API
> at /druid/widget/properties_panel/properties_panel.lua
## Functions
- [properties_constructors](#properties_constructors)
- [init](#init)
- [on_remove](#on_remove)
- [on_drag_widget](#on_drag_widget)
- [clear_created_properties](#clear_created_properties)
- [clear](#clear)
- [on_size_changed](#on_size_changed)
- [update](#update)
- [add_checkbox](#add_checkbox)
- [add_slider](#add_slider)
- [add_button](#add_button)
- [add_input](#add_input)
- [add_text](#add_text)
- [add_left_right_selector](#add_left_right_selector)
- [add_vector3](#add_vector3)
- [add_inner_widget](#add_inner_widget)
- [add_widget](#add_widget)
- [remove](#remove)
- [set_hidden](#set_hidden)
- [is_hidden](#is_hidden)
- [set_properties_per_page](#set_properties_per_page)
- [set_page](#set_page)
## Fields
- [root](#root)
- [scroll](#scroll)
- [layout](#layout)
- [container](#container)
- [container_content](#container_content)
- [container_scroll_view](#container_scroll_view)
- [contaienr_scroll_content](#contaienr_scroll_content)
- [button_hidden](#button_hidden)
- [text_header](#text_header)
- [paginator](#paginator)
- [properties](#properties)
- [content](#content)
- [default_size](#default_size)
- [current_page](#current_page)
- [properties_per_page](#properties_per_page)
- [property_checkbox_prefab](#property_checkbox_prefab)
- [property_slider_prefab](#property_slider_prefab)
- [property_button_prefab](#property_button_prefab)
- [property_input_prefab](#property_input_prefab)
- [property_text_prefab](#property_text_prefab)
- [property_left_right_selector_prefab](#property_left_right_selector_prefab)
- [property_vector3_prefab](#property_vector3_prefab)
- [is_dirty](#is_dirty)
### properties_constructors
---
```lua
properties_panel:properties_constructors()
```
List of properties functions to create a new widget. Used to not spawn non-visible widgets but keep the reference
### init
---
```lua
properties_panel:init()
```
### on_remove
---
```lua
properties_panel:on_remove()
```
### on_drag_widget
---
```lua
properties_panel:on_drag_widget([dx], [dy])
```
- **Parameters:**
- `[dx]` *(any)*:
- `[dy]` *(any)*:
### clear_created_properties
---
```lua
properties_panel:clear_created_properties()
```
### clear
---
```lua
properties_panel:clear()
```
### on_size_changed
---
```lua
properties_panel:on_size_changed([new_size])
```
- **Parameters:**
- `[new_size]` *(any)*:
### update
---
```lua
properties_panel:update([dt])
```
- **Parameters:**
- `[dt]` *(any)*:
### add_checkbox
---
```lua
properties_panel:add_checkbox([on_create])
```
- **Parameters:**
- `[on_create]` *(fun(checkbox: druid.widget.property_checkbox)|nil)*:
- **Returns:**
- `` *(druid.widget.properties_panel)*:
### add_slider
---
```lua
properties_panel:add_slider([on_create])
```
- **Parameters:**
- `[on_create]` *(fun(slider: druid.widget.property_slider)|nil)*:
- **Returns:**
- `` *(druid.widget.properties_panel)*:
### add_button
---
```lua
properties_panel:add_button([on_create])
```
- **Parameters:**
- `[on_create]` *(fun(button: druid.widget.property_button)|nil)*:
- **Returns:**
- `` *(druid.widget.properties_panel)*:
### add_input
---
```lua
properties_panel:add_input([on_create])
```
- **Parameters:**
- `[on_create]` *(fun(input: druid.widget.property_input)|nil)*:
- **Returns:**
- `` *(druid.widget.properties_panel)*:
### add_text
---
```lua
properties_panel:add_text([on_create])
```
- **Parameters:**
- `[on_create]` *(fun(text: druid.widget.property_text)|nil)*:
- **Returns:**
- `` *(druid.widget.properties_panel)*:
### add_left_right_selector
---
```lua
properties_panel:add_left_right_selector([on_create])
```
- **Parameters:**
- `[on_create]` *(fun(selector: druid.widget.property_left_right_selector)|nil)*:
- **Returns:**
- `` *(druid.widget.properties_panel)*:
### add_vector3
---
```lua
properties_panel:add_vector3([on_create])
```
- **Parameters:**
- `[on_create]` *(fun(vector3: druid.widget.property_vector3)|nil)*:
- **Returns:**
- `` *(druid.widget.properties_panel)*:
### add_inner_widget
---
```lua
properties_panel:add_inner_widget(widget_class, [template], [nodes], [on_create])
```
- **Parameters:**
- `widget_class` *(<T:druid.widget>)*:
- `[template]` *(string|nil)*:
- `[nodes]` *(node|table<hash, node>|nil)*:
- `[on_create]` *(fun(widget: <T:druid.widget>)|nil)*:
- **Returns:**
- `` *(druid.widget.properties_panel)*:
### add_widget
---
```lua
properties_panel:add_widget(create_widget_callback)
```
- **Parameters:**
- `create_widget_callback` *(fun():druid.widget)*:
- **Returns:**
- `` *(druid.widget.properties_panel)*:
### remove
---
```lua
properties_panel:remove([widget])
```
- **Parameters:**
- `[widget]` *(any)*:
### set_hidden
---
```lua
properties_panel:set_hidden([is_hidden])
```
- **Parameters:**
- `[is_hidden]` *(any)*:
### is_hidden
---
```lua
properties_panel:is_hidden()
```
- **Returns:**
- `` *(unknown)*:
### set_properties_per_page
---
```lua
properties_panel:set_properties_per_page(properties_per_page)
```
- **Parameters:**
- `properties_per_page` *(number)*:
### set_page
---
```lua
properties_panel:set_page([page])
```
- **Parameters:**
- `[page]` *(any)*:
## Fields
<a name="root"></a>
- **root** (_node_)
<a name="scroll"></a>
- **scroll** (_druid.scroll_)
<a name="layout"></a>
- **layout** (_druid.layout_): The component used for managing the layout of nodes, placing them inside the node size with respect to the size and pivot of each node
<a name="container"></a>
- **container** (_druid.container_): The component used for managing the size and positions with other containers relations to create a adaptable layouts
<a name="container_content"></a>
- **container_content** (_druid.container_): The component used for managing the size and positions with other containers relations to create a adaptable layouts
<a name="container_scroll_view"></a>
- **container_scroll_view** (_druid.container_): The component used for managing the size and positions with other containers relations to create a adaptable layouts
<a name="contaienr_scroll_content"></a>
- **contaienr_scroll_content** (_druid.container_): The component used for managing the size and positions with other containers relations to create a adaptable layouts
<a name="button_hidden"></a>
- **button_hidden** (_druid.button_): Druid component to make clickable node with various interaction callbacks
<a name="text_header"></a>
- **text_header** (_druid.text_): The component to handle text behaviour over a GUI Text node, mainly used to automatically adjust text size to fit the text area
<a name="paginator"></a>
- **paginator** (_druid.widget.property_left_right_selector_)
<a name="properties"></a>
- **properties** (_druid.widget[]_): List of created properties
<a name="content"></a>
- **content** (_node_)
<a name="default_size"></a>
- **default_size** (_vector3_)
<a name="current_page"></a>
- **current_page** (_integer_)
<a name="properties_per_page"></a>
- **properties_per_page** (_integer_)
<a name="property_checkbox_prefab"></a>
- **property_checkbox_prefab** (_node_)
<a name="property_slider_prefab"></a>
- **property_slider_prefab** (_node_)
<a name="property_button_prefab"></a>
- **property_button_prefab** (_node_)
<a name="property_input_prefab"></a>
- **property_input_prefab** (_node_)
<a name="property_text_prefab"></a>
- **property_text_prefab** (_node_)
<a name="property_left_right_selector_prefab"></a>
- **property_left_right_selector_prefab** (_node_)
<a name="property_vector3_prefab"></a>
- **property_vector3_prefab** (_node_)
<a name="is_dirty"></a>
- **is_dirty** (_boolean_)

View File

@ -25,6 +25,7 @@
19. [Text](#text)
20. [Timer](#timer)
4. [Helper](#helper)
5. [Widgets](#widgets)
# API Reference
@ -50,11 +51,12 @@ self.druid:final()
self.druid:update(dt)
self.druid:on_input(action_id, action)
self.druid:on_message(message_id, message, sender)
self.druid:on_window_event([window_event])
-- Component creation
-- Custom components
self.druid:new(component, ...)
self.druid:new_widget(widget, [template], [nodes], ...)
-- Built-in components
self.druid:new_button(node, [callback], [params], [anim_node])
self.druid:new_text(node, [value], [no_adjust])
self.druid:new_grid(parent_node, item, [in_row])
@ -76,6 +78,7 @@ self.druid:new_hotkey(keys_array, [callback], [callback_argument])
self.druid:new_slider(pin_node, end_pos, [callback])
self.druid:new_timer(node, [seconds_from], [seconds_to], [callback])
-- Operational
self.druid:remove(component)
self.druid:set_blacklist(blacklist_components)
self.druid:set_whitelist(whitelist_components)
@ -85,7 +88,7 @@ self.druid:set_whitelist(whitelist_components)
### [Base Component](components/base/component_api.md)
Basic methods for all components.
Basic methods for all components and widgets.
```lua
component:get_childrens()
@ -102,6 +105,9 @@ component:set_input_priority(value, [is_temporary])
component:set_nodes(nodes)
component:set_style([druid_style])
component:set_template([template])
-- All widgets goes with created Druid instance
widget.druid
```
### [Blocker](components/base/blocker_api.md)
@ -116,15 +122,42 @@ blocker:set_enabled(state)
### [Button](components/base/button_api.md)
```lua
local button = self.druid:new_button(node, [callback], [params], [anim_node])
local button = require("druid.base.button")
button:get_key_trigger()
button:is_enabled()
button:set_check_function([check_function], [failure_callback])
button:set_click_zone([zone])
button:init(node_or_node_id, [callback], [custom_args], [anim_node])
button:set_animations_disabled()
button:set_enabled([state])
button:is_enabled()
button:set_click_zone([zone])
button:set_key_trigger(key)
button:get_key_trigger()
button:set_check_function([check_function], [failure_callback])
button:set_web_user_interaction([is_web_mode])
button.on_click
button.on_pressed
button.on_repeated_click
button.on_long_click
button.on_double_click
button.on_hold_callback
button.on_click_outside
button.node
button.node_id
button.anim_node
button.params
button.hover
button.click_zone
button.start_scale
button.start_pos
button.disabled
button.key_trigger
button.style
button.druid
button.is_repeated_started
button.last_pressed_time
button.last_released_time
button.click_in_row
button.can_action
```
### [Container](components/extended/container_api.md)
@ -447,3 +480,142 @@ helper.sign(val)
helper.step(current, target, step)
helper.table_to_string(t)
```
## [Widgets](widgets_api.md)
### [FPS Panel](widgets/fps_panel_api.md)
```lua
local fps_panel = require("druid.widget.fps_panel.fps_panel")
fps_panel:init()
fps_panel:on_remove()
fps_panel:update([dt])
fps_panel:push_fps_value()
fps_panel.root
fps_panel.delta_time
fps_panel.collect_time
fps_panel.collect_time_counter
fps_panel.graph_samples
fps_panel.fps_samples
fps_panel.mini_graph
fps_panel.text_min_fps
fps_panel.text_fps
fps_panel.timer_id
fps_panel.previous_time
```
### [Memory Panel](widgets/memory_panel_api.md)
```lua
local memory_panel = require("druid.widget.memory_panel.memory_panel")
memory_panel:init()
memory_panel:on_remove()
memory_panel:set_low_memory_limit([limit])
memory_panel:push_next_value()
memory_panel:update_text_memory()
memory_panel.root
memory_panel.delta_time
memory_panel.samples_count
memory_panel.memory_limit
memory_panel.mini_graph
memory_panel.max_value
memory_panel.text_per_second
memory_panel.text_memory
memory_panel.memory
memory_panel.memory_samples
memory_panel.timer_id
```
### [Mini Graph](widgets/mini_graph_api.md)
```lua
local mini_graph = require("druid.widget.mini_graph.mini_graph")
mini_graph:init()
mini_graph:on_remove()
mini_graph:clear()
mini_graph:set_samples([samples])
mini_graph:get_samples()
mini_graph:set_line_value(index, value)
mini_graph:get_line_value([index])
mini_graph:push_line_value([value])
mini_graph:set_max_value([max_value])
mini_graph:set_line_height([index])
mini_graph:get_lowest_value()
mini_graph:get_highest_value()
mini_graph:on_drag_widget([dx], [dy])
mini_graph:toggle_hide()
mini_graph.root
mini_graph.text_header
mini_graph.icon_drag
mini_graph.content
mini_graph.layout
mini_graph.prefab_line
mini_graph.color_zero
mini_graph.color_one
mini_graph.is_hidden
mini_graph.max_value
mini_graph.lines
mini_graph.values
mini_graph.container
mini_graph.default_size
mini_graph.samples
```
### [Properties Panel](widgets/properties_panel_api.md)
```lua
local properties_panel = require("druid.widget.properties_panel.properties_panel")
properties_panel:properties_constructors()
properties_panel:init()
properties_panel:on_remove()
properties_panel:on_drag_widget([dx], [dy])
properties_panel:clear_created_properties()
properties_panel:clear()
properties_panel:on_size_changed([new_size])
properties_panel:update([dt])
properties_panel:add_checkbox([on_create])
properties_panel:add_slider([on_create])
properties_panel:add_button([on_create])
properties_panel:add_input([on_create])
properties_panel:add_text([on_create])
properties_panel:add_left_right_selector([on_create])
properties_panel:add_vector3([on_create])
properties_panel:add_inner_widget(widget_class, [template], [nodes], [on_create])
properties_panel:add_widget(create_widget_callback)
properties_panel:remove([widget])
properties_panel:set_hidden([is_hidden])
properties_panel:is_hidden()
properties_panel:set_properties_per_page(properties_per_page)
properties_panel:set_page([page])
properties_panel.root
properties_panel.scroll
properties_panel.layout
properties_panel.container
properties_panel.container_content
properties_panel.container_scroll_view
properties_panel.contaienr_scroll_content
properties_panel.button_hidden
properties_panel.text_header
properties_panel.paginator
properties_panel.properties
properties_panel.content
properties_panel.default_size
properties_panel.current_page
properties_panel.properties_per_page
properties_panel.property_checkbox_prefab
properties_panel.property_slider_prefab
properties_panel.property_button_prefab
properties_panel.property_input_prefab
properties_panel.property_text_prefab
properties_panel.property_left_right_selector_prefab
properties_panel.property_vector3_prefab
properties_panel.is_dirty
```

397647
doc.json Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,7 @@
# Styles
## Overview
Styles - set of functions and parameters for components to customize their behavior.
Styles is a table, where key is name of component, and value is style table for this component.
@ -8,29 +9,33 @@ Styles is a table, where key is name of component, and value is style table for
In component API documentation, you can find the style API for this component. Or just lookup for existing styles and modify them.
## Usage
Setup default druid style for all druid instances via `druid.set_default_style`
You can pass _nil_ or _empty_table_ to use default values for all components (no styles)
```lua
local druid = require("druid.druid")
local my_style = require("my.amazing.style")
function init(self)
druid.set_default_style(my_style)
druid.set_default_style(my_style)
end
```
Setup custom style to specific druid instance:
```lua
local druid = require("druid.druid")
local my_style = require("my.amazing.style")
function init(self)
-- This druid instance will be use my_style as default
self.druid = druid.new(self, my_style)
-- This druid instance will be use my_style as default
self.druid = druid.new(self, my_style)
end
```
Change component style with _set_style_ function
```lua
local druid = require("druid.druid")
local my_style = require("my.amazing.style")

View File

@ -1,6 +1,5 @@
# Advanced Druid Setup
## Input Bindings
By default, **Druid** uses all key names from Defold's default `/builtins/input/all.input_binding` for input bindings.
@ -96,23 +95,3 @@ local function on_window_callback(self, event, data)
end
window.set_listener(on_window_callback)
```
## Lua Annotations
[EmmyLua](https://emmylua.github.io/annotation.html) is a Lua annotation library. It is a useful tool for enabling Lua code autocompletion in editors such as [VSCode](https://github.com/EmmyLua/VSCode-EmmyLua) and [IntelliJ IDEA](https://github.com/EmmyLua/IntelliJ-EmmyLua).
Since dependencies cannot be processed by external editors, to use the EmmyLua annotations, you should copy the _druid/annotations.lua_ file to your project.
Remember that you can restart the EmmyLua server to refresh the changes if something goes wrong.
After the annotations are processed, you should specify the type of "Druid" in the "require" statement:
```lua
---@type druid
local druid = require("druid.druid")
-- Now the autocomplete is working
```
<img src="../media/emmy_lua_preview.png" width="700">