Update API pages

This commit is contained in:
Insality
2025-04-20 12:15:31 +03:00
parent 6e1998b822
commit c33dbd5942
24 changed files with 82 additions and 460 deletions

View File

@@ -38,7 +38,7 @@ The Back Handler constructor
## Fields
<a name="on_back"></a>
- **on_back** (_event_): Trigger on back handler action, fun(self, params)
- **on_back** (_event_): fun(self: druid.back_handler, params: any?) Trigger on back handler action
<a name="params"></a>
- **params** (_any_): Custom args to pass in the callback

View File

@@ -112,10 +112,10 @@ button:is_enabled()
```
Get button enabled state.
By default all Buttons is enabled on creating.
By default all Buttons are enabled on creating.
- **Returns:**
- `is_enabled` *(boolean)*: True, if button is enabled now, False overwise
- `is_enabled` *(boolean)*: True, if button is enabled now, False otherwise
### set_click_zone
@@ -125,7 +125,7 @@ button:set_click_zone([zone])
```
Set additional button click area.
Useful to restrict click outside out stencil node or scrollable content.
Useful to restrict click outside of stencil node or scrollable content.
If button node placed inside stencil node, it will be automatically set to this stencil node.
- **Parameters:**
@@ -168,11 +168,11 @@ Get current key name to trigger this button.
button:set_check_function([check_function], [failure_callback])
```
Set function for additional check for button click availability
Set function for additional check for button click availability.
- **Parameters:**
- `[check_function]` *(function|nil)*: Should return true or false. If true - button can be pressed.
- `[failure_callback]` *(function|nil)*: Function will be called on button click, if check function return false
- `[failure_callback]` *(function|nil)*: Function will be called on button click, if check function returns false
- **Returns:**
- `self` *(druid.button)*: The current button instance
@@ -186,7 +186,7 @@ button:set_web_user_interaction([is_web_mode])
Set Button mode to work inside user HTML5 interaction event.
It's required to make protected things like copy & paste text, show mobile keyboard, etc
The HTML5 button's doesn't call any events except on_click event.
The HTML5 button doesn't call any events except on_click event.
If the game is not HTML, html mode will be not enabled
- **Parameters:**
@@ -198,25 +198,25 @@ If the game is not HTML, html mode will be not enabled
## Fields
<a name="on_click"></a>
- **on_click** (_event_): function(self, custom_args, button_instance)
- **on_click** (_event_): fun(self, custom_args, button_instance)
<a name="on_pressed"></a>
- **on_pressed** (_event_): function(self, custom_args, button_instance)
- **on_pressed** (_event_): fun(self, custom_args, button_instance)
<a name="on_repeated_click"></a>
- **on_repeated_click** (_event_): function(self, custom_args, button_instance, click_count) Repeated click callback, while holding the button
- **on_repeated_click** (_event_): fun(self, custom_args, button_instance, click_count) Repeated click callback, while holding the button
<a name="on_long_click"></a>
- **on_long_click** (_event_): function(self, custom_args, button_instance, hold_time) Callback on long button tap
- **on_long_click** (_event_): fun(self, custom_args, button_instance, hold_time) Callback on long button tap
<a name="on_double_click"></a>
- **on_double_click** (_event_): function(self, custom_args, button_instance, click_amount) Different callback, if tap button 2+ in row
- **on_double_click** (_event_): fun(self, custom_args, button_instance, click_amount) Different callback, if tap button 2+ in row
<a name="on_hold_callback"></a>
- **on_hold_callback** (_event_): function(self, custom_args, button_instance, press_time) Hold callback, before long_click trigger
- **on_hold_callback** (_event_): fun(self, custom_args, button_instance, press_time) Hold callback, before long_click trigger
<a name="on_click_outside"></a>
- **on_click_outside** (_event_): function(self, custom_args, button_instance)
- **on_click_outside** (_event_): fun(self, custom_args, button_instance)
<a name="node"></a>
- **node** (_node_): Clickable node

View File

@@ -243,13 +243,13 @@ Get full template name.
---
```lua
component:set_nodes(nodes)
component:set_nodes([nodes])
```
Set current component nodes, returned from `gui.clone_tree` function.
- **Parameters:**
- `nodes` *(table<hash, node>)*:
- `[nodes]` *(string|node|table<hash, node>|nil)*: The nodes table from gui.clone_tree or prefab node to use for clone or node id to clone
- **Returns:**
- `` *(druid.component)*:
@@ -292,7 +292,7 @@ Get Druid instance for inner component creation.
- **Parameters:**
- `[template]` *(string|nil)*:
- `[nodes]` *(table<hash, node>|nil)*:
- `[nodes]` *(string|node|table<hash, node>|nil)*: The nodes table from gui.clone_tree or prefab node to use for clone or node id to clone
- **Returns:**
- `` *(druid.instance)*:

View File

@@ -334,13 +334,13 @@ Strict drag scroll area. Useful for
- **click_zone** (_node_): Optional click zone to restrict scroll area
<a name="on_scroll"></a>
- **on_scroll** (_event_): Triggered on scroll move with fun(self, position)
- **on_scroll** (_event_): fun(self: druid.scroll, position: vector3) Triggered on scroll move
<a name="on_scroll_to"></a>
- **on_scroll_to** (_event_): Triggered on scroll_to with fun(self, target, is_instant)
- **on_scroll_to** (_event_): fun(self: druid.scroll, target: vector3, is_instant: boolean) Triggered on scroll_to
<a name="on_point_scroll"></a>
- **on_point_scroll** (_event_): Triggered on scroll_to_index with fun(self, index, point)
- **on_point_scroll** (_event_): fun(self: druid.scroll, index: number, point: vector3) Triggered on scroll_to_index
<a name="view_node"></a>
- **view_node** (_node_): The scroll view node (static part)

View File

@@ -4,14 +4,6 @@
The component for manage the nodes position in the grid with various options
## Functions
- [init](#init)# druid.grid API
> at /druid/base/static_grid.lua
The component for manage the nodes position in the grid with various options
## Functions
- [init](#init)
@@ -346,398 +338,19 @@ Sort grid nodes by custom comparator function
## Fields
<a name="on_add_item"></a>
- **on_add_item** (_event_): Trigger on add item event, fun(self, item, index)
- **on_add_item** (_event_): fun(self: druid.grid, item: node, index: number) Trigger on add item event
<a name="on_remove_item"></a>
- **on_remove_item** (_event_): Trigger on remove item event, fun(self, index)
- **on_remove_item** (_event_): fun(self: druid.grid, index: number) Trigger on remove item event
<a name="on_change_items"></a>
- **on_change_items** (_event_): Trigger on change items event, fun(self, index)
- **on_change_items** (_event_): fun(self: druid.grid, index: number) Trigger on change items event
<a name="on_clear"></a>
- **on_clear** (_event_): Trigger on clear event, fun(self)
- **on_clear** (_event_): fun(self: druid.grid) Trigger on clear event
<a name="on_update_positions"></a>
- **on_update_positions** (_event_): Trigger on update positions event, fun(self)
<a name="parent"></a>
- **parent** (_node_): Parent node
<a name="nodes"></a>
- **nodes** (_node[]_): Nodes array
<a name="first_index"></a>
- **first_index** (_number_): First index
<a name="last_index"></a>
- **last_index** (_number_): Last index
<a name="anchor"></a>
- **anchor** (_vector3_): Anchor
<a name="pivot"></a>
- **pivot** (_vector3_): Pivot
<a name="node_size"></a>
- **node_size** (_vector3_): Node size
<a name="border"></a>
- **border** (_vector4_): Border
<a name="in_row"></a>
- **in_row** (_number_): In row
<a name="style"></a>
- **style** (_druid.grid.style_): Style
<a name="node_pivot"></a>
- **node_pivot** (_unknown_)
- [get_pos](#get_pos)
- [get_index](#get_index)
- [get_index_by_node](#get_index_by_node)
- [set_anchor](#set_anchor)
- [refresh](#refresh)
- [set_pivot](#set_pivot)
- [add](#add)
- [set_items](#set_items)
- [remove](#remove)
- [get_size](#get_size)
- [get_size_for](#get_size_for)
- [get_borders](#get_borders)
- [get_all_pos](#get_all_pos)
- [set_position_function](#set_position_function)
- [clear](#clear)
- [get_offset](#get_offset)
- [set_in_row](#set_in_row)
- [set_item_size](#set_item_size)
- [sort_nodes](#sort_nodes)
## Fields
- [on_add_item](#on_add_item)
- [on_remove_item](#on_remove_item)
- [on_change_items](#on_change_items)
- [on_clear](#on_clear)
- [on_update_positions](#on_update_positions)
- [parent](#parent)
- [nodes](#nodes)
- [first_index](#first_index)
- [last_index](#last_index)
- [anchor](#anchor)
- [pivot](#pivot)
- [node_size](#node_size)
- [border](#border)
- [in_row](#in_row)
- [style](#style)
- [node_pivot](#node_pivot)
### init
---
```lua
grid:init(parent, element, [in_row])
```
The constructor for the grid component
- **Parameters:**
- `parent` *(string|node)*: The GUI Node container, where grid's items will be placed
- `element` *(node)*: Element prefab. Need to get it size
- `[in_row]` *(number|nil)*: How many nodes in row can be placed. By default 1
### get_pos
---
```lua
grid:get_pos(index)
```
Return pos for grid node index
- **Parameters:**
- `index` *(number)*: The grid element index
- **Returns:**
- `position` *(vector3)*: Node position
### get_index
---
```lua
grid:get_index(pos)
```
Return grid index by position
- **Parameters:**
- `pos` *(vector3)*: The node position in the grid
- **Returns:**
- `index` *(number)*: The node index
### get_index_by_node
---
```lua
grid:get_index_by_node(node)
```
Return grid index by node
- **Parameters:**
- `node` *(node)*: The gui node in the grid
- **Returns:**
- `index` *(number|nil)*: The node index
### set_anchor
---
```lua
grid:set_anchor(anchor)
```
Set grid anchor. Default anchor is equal to anchor of grid parent node
- **Parameters:**
- `anchor` *(vector3)*: Anchor
### refresh
---
```lua
grid:refresh()
```
Instantly update the grid content
- **Returns:**
- `self` *(druid.grid)*: Current grid instance
### set_pivot
---
```lua
grid:set_pivot(pivot)
```
Set grid pivot
- **Parameters:**
- `pivot` *(constant)*: The new pivot
- **Returns:**
- `self` *(druid.grid)*: Current grid instance
### add
---
```lua
grid:add(item, [index], [shift_policy], [is_instant])
```
Add new item to the grid
- **Parameters:**
- `item` *(node)*: GUI node
- `[index]` *(number|nil)*: The item position. By default add as last item
- `[shift_policy]` *(number|nil)*: How shift nodes, if required. Default: const.SHIFT.RIGHT
- `[is_instant]` *(boolean|nil)*: If true, update node positions instantly
- **Returns:**
- `self` *(druid.grid)*: Current grid instance
### set_items
---
```lua
grid:set_items(nodes, [is_instant])
```
Set new items to the grid. All previous items will be removed
- **Parameters:**
- `nodes` *(node[])*: The new grid nodes
- `[is_instant]` *(boolean|nil)*: If true, update node positions instantly
- **Returns:**
- `self` *(druid.grid)*: Current grid instance
### remove
---
```lua
grid:remove(index, [shift_policy], [is_instant])
```
Remove the item from the grid. Note that gui node will be not deleted
- **Parameters:**
- `index` *(number)*: The grid node index to remove
- `[shift_policy]` *(number|nil)*: How shift nodes, if required. Default: const.SHIFT.RIGHT
- `[is_instant]` *(boolean|nil)*: If true, update node positions instantly
- **Returns:**
- `node` *(node)*: The deleted gui node from grid
### get_size
---
```lua
grid:get_size()
```
Return grid content size
- **Returns:**
- `size` *(vector3)*: The grid content size
### get_size_for
---
```lua
grid:get_size_for(count)
```
Return grid content size for given count of nodes
- **Parameters:**
- `count` *(number)*: The count of nodes
- **Returns:**
- `size` *(vector3)*: The grid content size
### get_borders
---
```lua
grid:get_borders()
```
Return grid content borders
- **Returns:**
- `borders` *(vector4)*: The grid content borders
### get_all_pos
---
```lua
grid:get_all_pos()
```
Return array of all node positions
- **Returns:**
- `positions` *(vector3[])*: All grid node positions
### set_position_function
---
```lua
grid:set_position_function(callback)
```
Change set position function for grid nodes. It will call on
update poses on grid elements. Default: gui.set_position
- **Parameters:**
- `callback` *(function)*: Function on node set position
- **Returns:**
- `self` *(druid.grid)*: Current grid instance
### clear
---
```lua
grid:clear()
```
Clear grid nodes array. GUI nodes will be not deleted!
If you want to delete GUI nodes, use static_grid.nodes array before grid:clear
- **Returns:**
- `self` *(druid.grid)*: Current grid instance
### get_offset
---
```lua
grid:get_offset()
```
Return StaticGrid offset, where StaticGrid content starts.
- **Returns:**
- `offset` *(vector3)*: The StaticGrid offset
### set_in_row
---
```lua
grid:set_in_row(in_row)
```
Set new in_row elements for grid
- **Parameters:**
- `in_row` *(number)*: The new in_row value
- **Returns:**
- `self` *(druid.grid)*: Current grid instance
### set_item_size
---
```lua
grid:set_item_size([width], [height])
```
Set new node size for grid
- **Parameters:**
- `[width]` *(number|nil)*: The new node width
- `[height]` *(number|nil)*: The new node height
- **Returns:**
- `self` *(druid.grid)*: Current grid instance
### sort_nodes
---
```lua
grid:sort_nodes(comparator)
```
Sort grid nodes by custom comparator function
- **Parameters:**
- `comparator` *(function)*: The comparator function. (a, b) -> boolean
- **Returns:**
- `self` *(druid.grid)*: Current grid instance
## Fields
<a name="on_add_item"></a>
- **on_add_item** (_event_): Trigger on add item event, fun(self, item, index)
<a name="on_remove_item"></a>
- **on_remove_item** (_event_): Trigger on remove item event, fun(self, index)
<a name="on_change_items"></a>
- **on_change_items** (_event_): Trigger on change items event, fun(self, index)
<a name="on_clear"></a>
- **on_clear** (_event_): Trigger on clear event, fun(self)
<a name="on_update_positions"></a>
- **on_update_positions** (_event_): Trigger on update positions event, fun(self)
- **on_update_positions** (_event_): fun(self: druid.grid) Trigger on update positions event
<a name="parent"></a>
- **parent** (_node_): Parent node

View File

@@ -46,6 +46,9 @@ Create text node with druid: `text = druid:new_text(node_name, [initial_value],
- [on_update_text_scale](#on_update_text_scale)
- [on_set_pivot](#on_set_pivot)
- [style](#style)
- [start_pivot](#start_pivot)
- [start_scale](#start_scale)
- [scale](#scale)
- [pos](#pos)
- [node_id](#node_id)
- [start_size](#start_size)
@@ -300,17 +303,26 @@ Return current text adjust type
- **node** (_node_): The text node
<a name="on_set_text"></a>
- **on_set_text** (_event_): fun(self, text) The event triggered when the text is set
- **on_set_text** (_event_): fun(self: druid.text, text: string) The event triggered when the text is set
<a name="on_update_text_scale"></a>
- **on_update_text_scale** (_event_): fun(self, scale, metrics) The event triggered when the text scale is updated
- **on_update_text_scale** (_event_): fun(self: druid.text, scale: vector3, metrics: table) The event triggered when the text scale is updated
<a name="on_set_pivot"></a>
- **on_set_pivot** (_event_): fun(self, pivot) The event triggered when the text pivot is set
- **on_set_pivot** (_event_): fun(self: druid.text, pivot: userdata) The event triggered when the text pivot is set
<a name="style"></a>
- **style** (_druid.text.style_): The style of the text
<a name="start_pivot"></a>
- **start_pivot** (_userdata_): The start pivot of the text
<a name="start_scale"></a>
- **start_scale** (_vector3_): The start scale of the text
<a name="scale"></a>
- **scale** (_vector3_): The current scale of the text
<a name="pos"></a>
- **pos** (_unknown_)