mirror of
https://github.com/Insality/druid
synced 2025-09-27 10:02:19 +02:00
Test new markdown api generator
This commit is contained in:
6
api/components/base/back_handler_api.md
Normal file
6
api/components/base/back_handler_api.md
Normal file
@@ -0,0 +1,6 @@
|
||||
# Back Handler Quick API reference
|
||||
|
||||
```lua
|
||||
back_handler:init([callback], [params])
|
||||
back_handler:on_input([action_id], [action])
|
||||
```
|
73
api/components/base/blocker_api.md
Normal file
73
api/components/base/blocker_api.md
Normal file
@@ -0,0 +1,73 @@
|
||||
# druid.blocker API
|
||||
|
||||
> at /druid/base/blocker.lua
|
||||
|
||||
|
||||
## Functions
|
||||
- [init](#init)
|
||||
- [on_input](#on_input)
|
||||
- [set_enabled](#set_enabled)
|
||||
- [is_enabled](#is_enabled)
|
||||
|
||||
|
||||
## Fields
|
||||
- [node](#node)
|
||||
|
||||
|
||||
|
||||
### init
|
||||
|
||||
---
|
||||
```lua
|
||||
blocker:init(node)
|
||||
```
|
||||
|
||||
- **Parameters:**
|
||||
- `node` *(node)*:
|
||||
|
||||
### on_input
|
||||
|
||||
---
|
||||
```lua
|
||||
blocker:on_input(action_id, action)
|
||||
```
|
||||
|
||||
- **Parameters:**
|
||||
- `action_id` *(string)*:
|
||||
- `action` *(table)*:
|
||||
|
||||
- **Returns:**
|
||||
- `` *(boolean)*:
|
||||
|
||||
### set_enabled
|
||||
|
||||
---
|
||||
```lua
|
||||
blocker:set_enabled(state)
|
||||
```
|
||||
|
||||
Set blocker enabled state
|
||||
|
||||
- **Parameters:**
|
||||
- `state` *(boolean)*:
|
||||
|
||||
- **Returns:**
|
||||
- `self` *(druid.blocker)*:
|
||||
|
||||
### is_enabled
|
||||
|
||||
---
|
||||
```lua
|
||||
blocker:is_enabled()
|
||||
```
|
||||
|
||||
Get blocker enabled state
|
||||
|
||||
- **Returns:**
|
||||
- `` *(boolean)*:
|
||||
|
||||
|
||||
## Fields
|
||||
<a name="node"></a>
|
||||
- **node** (_node_)
|
||||
|
284
api/components/base/button_api.md
Normal file
284
api/components/base/button_api.md
Normal file
@@ -0,0 +1,284 @@
|
||||
# druid.button API
|
||||
|
||||
> at /druid/base/button.lua
|
||||
|
||||
Druid component to make clickable node with various interaction callbacks
|
||||
|
||||
|
||||
## Functions
|
||||
- [init](#init)
|
||||
- [on_style_change](#on_style_change)
|
||||
- [on_late_init](#on_late_init)
|
||||
- [on_input](#on_input)
|
||||
- [on_input_interrupt](#on_input_interrupt)
|
||||
- [set_enabled](#set_enabled)
|
||||
- [is_enabled](#is_enabled)
|
||||
- [set_click_zone](#set_click_zone)
|
||||
- [set_key_trigger](#set_key_trigger)
|
||||
- [get_key_trigger](#get_key_trigger)
|
||||
- [set_check_function](#set_check_function)
|
||||
- [set_web_user_interaction](#set_web_user_interaction)
|
||||
|
||||
|
||||
## Fields
|
||||
- [on_click](#on_click)
|
||||
- [on_pressed](#on_pressed)
|
||||
- [on_repeated_click](#on_repeated_click)
|
||||
- [on_long_click](#on_long_click)
|
||||
- [on_double_click](#on_double_click)
|
||||
- [on_hold_callback](#on_hold_callback)
|
||||
- [on_click_outside](#on_click_outside)
|
||||
- [node](#node)
|
||||
- [node_id](#node_id)
|
||||
- [anim_node](#anim_node)
|
||||
- [params](#params)
|
||||
- [hover](#hover)
|
||||
- [click_zone](#click_zone)
|
||||
- [start_scale](#start_scale)
|
||||
- [start_pos](#start_pos)
|
||||
- [disabled](#disabled)
|
||||
- [key_trigger](#key_trigger)
|
||||
- [style](#style)
|
||||
- [druid](#druid)
|
||||
- [is_repeated_started](#is_repeated_started)
|
||||
- [last_pressed_time](#last_pressed_time)
|
||||
- [last_released_time](#last_released_time)
|
||||
- [click_in_row](#click_in_row)
|
||||
- [can_action](#can_action)
|
||||
|
||||
|
||||
|
||||
### init
|
||||
|
||||
---
|
||||
```lua
|
||||
button:init(node_or_node_id, [callback], [custom_args], [anim_node])
|
||||
```
|
||||
|
||||
- **Parameters:**
|
||||
- `node_or_node_id` *(string|node)*: Node name or GUI Node itself
|
||||
- `[callback]` *(fun()|nil)*: Callback on button click
|
||||
- `[custom_args]` *(any)*: Custom args for any Button event
|
||||
- `[anim_node]` *(string|node|nil)*: Node to animate instead of trigger node
|
||||
|
||||
### on_style_change
|
||||
|
||||
---
|
||||
```lua
|
||||
button:on_style_change(style)
|
||||
```
|
||||
|
||||
- **Parameters:**
|
||||
- `style` *(druid.button.style)*: Button style params.
|
||||
You can override this component styles params in Druid styles table or create your own style
|
||||
|
||||
### on_late_init
|
||||
|
||||
---
|
||||
```lua
|
||||
button:on_late_init()
|
||||
```
|
||||
|
||||
### on_input
|
||||
|
||||
---
|
||||
```lua
|
||||
button:on_input(action_id, action)
|
||||
```
|
||||
|
||||
- **Parameters:**
|
||||
- `action_id` *(hash)*:
|
||||
- `action` *(table)*:
|
||||
|
||||
- **Returns:**
|
||||
- `` *(boolean)*:
|
||||
|
||||
### on_input_interrupt
|
||||
|
||||
---
|
||||
```lua
|
||||
button:on_input_interrupt()
|
||||
```
|
||||
|
||||
### set_enabled
|
||||
|
||||
---
|
||||
```lua
|
||||
button:set_enabled([state])
|
||||
```
|
||||
|
||||
Set button enabled state.
|
||||
The style.on_set_enabled will be triggered.
|
||||
Disabled button is not clickable.
|
||||
|
||||
- **Parameters:**
|
||||
- `[state]` *(boolean|nil)*: Enabled state
|
||||
|
||||
- **Returns:**
|
||||
- `self` *(druid.button)*:
|
||||
|
||||
### is_enabled
|
||||
|
||||
---
|
||||
```lua
|
||||
button:is_enabled()
|
||||
```
|
||||
|
||||
Get button enabled state.
|
||||
By default all Buttons is enabled on creating.
|
||||
|
||||
- **Returns:**
|
||||
- `is_enabled` *(boolean)*: True, if button is enabled now, False overwise
|
||||
|
||||
### set_click_zone
|
||||
|
||||
---
|
||||
```lua
|
||||
button:set_click_zone([zone])
|
||||
```
|
||||
|
||||
Set additional button click area.
|
||||
Useful to restrict click outside out stencil node or scrollable content.
|
||||
If button node placed inside stencil node, it will be automatically set to this stencil node.
|
||||
|
||||
- **Parameters:**
|
||||
- `[zone]` *(string|node|nil)*: Gui node
|
||||
|
||||
- **Returns:**
|
||||
- `self` *(druid.button)*:
|
||||
|
||||
### set_key_trigger
|
||||
|
||||
---
|
||||
```lua
|
||||
button:set_key_trigger(key)
|
||||
```
|
||||
|
||||
Set key name to trigger this button by keyboard.
|
||||
|
||||
- **Parameters:**
|
||||
- `key` *(string|hash)*: The action_id of the input key. Example: "key_space"
|
||||
|
||||
- **Returns:**
|
||||
- `self` *(druid.button)*:
|
||||
|
||||
### get_key_trigger
|
||||
|
||||
---
|
||||
```lua
|
||||
button:get_key_trigger()
|
||||
```
|
||||
|
||||
Get current key name to trigger this button.
|
||||
|
||||
- **Returns:**
|
||||
- `key_trigger` *(hash)*: The action_id of the input key
|
||||
|
||||
### set_check_function
|
||||
|
||||
---
|
||||
```lua
|
||||
button:set_check_function([check_function], [failure_callback])
|
||||
```
|
||||
|
||||
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
|
||||
|
||||
- **Returns:**
|
||||
- `self` *(druid.button)*:
|
||||
|
||||
### set_web_user_interaction
|
||||
|
||||
---
|
||||
```lua
|
||||
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.
|
||||
If the game is not HTML, html mode will be not enabled
|
||||
|
||||
- **Parameters:**
|
||||
- `[is_web_mode]` *(boolean|nil)*: If true - button will be called inside html5 callback
|
||||
|
||||
- **Returns:**
|
||||
- `self` *(druid.button)*:
|
||||
|
||||
|
||||
## Fields
|
||||
<a name="on_click"></a>
|
||||
- **on_click** (_event_): function(self, custom_args, button_instance)
|
||||
|
||||
<a name="on_pressed"></a>
|
||||
- **on_pressed** (_event_): function(self, custom_args, button_instance)
|
||||
|
||||
<a name="on_repeated_click"></a>
|
||||
- **on_repeated_click** (_event_): function(self, custom_args, button_instance, click_count)
|
||||
|
||||
<a name="on_long_click"></a>
|
||||
- **on_long_click** (_event_): function(self, custom_args, button_instance, hold_time)
|
||||
|
||||
<a name="on_double_click"></a>
|
||||
- **on_double_click** (_event_): function(self, custom_args, button_instance, click_amount)
|
||||
|
||||
<a name="on_hold_callback"></a>
|
||||
- **on_hold_callback** (_event_): function(self, custom_args, button_instance, press_time)
|
||||
|
||||
<a name="on_click_outside"></a>
|
||||
- **on_click_outside** (_event_): function(self, custom_args, button_instance)
|
||||
|
||||
<a name="node"></a>
|
||||
- **node** (_node_): Clickable node
|
||||
|
||||
<a name="node_id"></a>
|
||||
- **node_id** (_hash_): Node id
|
||||
|
||||
<a name="anim_node"></a>
|
||||
- **anim_node** (_node_): Animation node. In default case equals to clickable node
|
||||
|
||||
<a name="params"></a>
|
||||
- **params** (_any_): Custom arguments for any Button event
|
||||
|
||||
<a name="hover"></a>
|
||||
- **hover** (_druid.hover_): Hover component for this button
|
||||
|
||||
<a name="click_zone"></a>
|
||||
- **click_zone** (_node_): Click zone node to restrict click area
|
||||
|
||||
<a name="start_scale"></a>
|
||||
- **start_scale** (_vector3_): Start scale of the button
|
||||
|
||||
<a name="start_pos"></a>
|
||||
- **start_pos** (_vector3_): Start position of the button
|
||||
|
||||
<a name="disabled"></a>
|
||||
- **disabled** (_boolean_): Is button disabled
|
||||
|
||||
<a name="key_trigger"></a>
|
||||
- **key_trigger** (_hash_): Key trigger for this button
|
||||
|
||||
<a name="style"></a>
|
||||
- **style** (_table_): Style for this button
|
||||
|
||||
<a name="druid"></a>
|
||||
- **druid** (_druid.instance_)
|
||||
|
||||
<a name="is_repeated_started"></a>
|
||||
- **is_repeated_started** (_boolean_)
|
||||
|
||||
<a name="last_pressed_time"></a>
|
||||
- **last_pressed_time** (_integer_)
|
||||
|
||||
<a name="last_released_time"></a>
|
||||
- **last_released_time** (_integer_)
|
||||
|
||||
<a name="click_in_row"></a>
|
||||
- **click_in_row** (_integer_)
|
||||
|
||||
<a name="can_action"></a>
|
||||
- **can_action** (_boolean_): Can't interact, if touch outside of button
|
||||
|
222
api/components/base/drag_api.md
Normal file
222
api/components/base/drag_api.md
Normal file
@@ -0,0 +1,222 @@
|
||||
# druid.drag API
|
||||
|
||||
> at /druid/base/drag.lua
|
||||
|
||||
|
||||
## Functions
|
||||
- [init](#init)
|
||||
- [on_style_change](#on_style_change)
|
||||
- [set_drag_cursors](#set_drag_cursors)
|
||||
- [on_late_init](#on_late_init)
|
||||
- [on_window_resized](#on_window_resized)
|
||||
- [on_input_interrupt](#on_input_interrupt)
|
||||
- [on_input](#on_input)
|
||||
- [set_click_zone](#set_click_zone)
|
||||
- [set_enabled](#set_enabled)
|
||||
- [is_enabled](#is_enabled)
|
||||
|
||||
|
||||
## Fields
|
||||
- [node](#node)
|
||||
- [on_touch_start](#on_touch_start)
|
||||
- [on_touch_end](#on_touch_end)
|
||||
- [on_drag_start](#on_drag_start)
|
||||
- [on_drag](#on_drag)
|
||||
- [on_drag_end](#on_drag_end)
|
||||
- [style](#style)
|
||||
- [click_zone](#click_zone)
|
||||
- [is_touch](#is_touch)
|
||||
- [is_drag](#is_drag)
|
||||
- [can_x](#can_x)
|
||||
- [can_y](#can_y)
|
||||
- [dx](#dx)
|
||||
- [dy](#dy)
|
||||
- [touch_id](#touch_id)
|
||||
- [x](#x)
|
||||
- [y](#y)
|
||||
- [screen_x](#screen_x)
|
||||
- [screen_y](#screen_y)
|
||||
- [touch_start_pos](#touch_start_pos)
|
||||
- [druid](#druid)
|
||||
- [hover](#hover)
|
||||
|
||||
|
||||
|
||||
### init
|
||||
|
||||
---
|
||||
```lua
|
||||
drag:init(node_or_node_id, on_drag_callback)
|
||||
```
|
||||
|
||||
- **Parameters:**
|
||||
- `node_or_node_id` *(string|node)*:
|
||||
- `on_drag_callback` *(function)*:
|
||||
|
||||
### on_style_change
|
||||
|
||||
---
|
||||
```lua
|
||||
drag:on_style_change(style)
|
||||
```
|
||||
|
||||
- **Parameters:**
|
||||
- `style` *(druid.drag.style)*:
|
||||
|
||||
### set_drag_cursors
|
||||
|
||||
---
|
||||
```lua
|
||||
drag:set_drag_cursors(is_enabled)
|
||||
```
|
||||
|
||||
Set Drag component enabled state.
|
||||
|
||||
- **Parameters:**
|
||||
- `is_enabled` *(boolean)*:
|
||||
|
||||
### on_late_init
|
||||
|
||||
---
|
||||
```lua
|
||||
drag:on_late_init()
|
||||
```
|
||||
|
||||
### on_window_resized
|
||||
|
||||
---
|
||||
```lua
|
||||
drag:on_window_resized()
|
||||
```
|
||||
|
||||
### on_input_interrupt
|
||||
|
||||
---
|
||||
```lua
|
||||
drag:on_input_interrupt()
|
||||
```
|
||||
|
||||
### on_input
|
||||
|
||||
---
|
||||
```lua
|
||||
drag:on_input(action_id, action)
|
||||
```
|
||||
|
||||
- **Parameters:**
|
||||
- `action_id` *(hash)*:
|
||||
- `action` *(table)*:
|
||||
|
||||
- **Returns:**
|
||||
- `` *(boolean)*:
|
||||
|
||||
### set_click_zone
|
||||
|
||||
---
|
||||
```lua
|
||||
drag:set_click_zone([node])
|
||||
```
|
||||
|
||||
Set Drag click zone
|
||||
|
||||
- **Parameters:**
|
||||
- `[node]` *(string|node|nil)*:
|
||||
|
||||
- **Returns:**
|
||||
- `self` *(druid.drag)*: Current instance
|
||||
|
||||
### set_enabled
|
||||
|
||||
---
|
||||
```lua
|
||||
drag:set_enabled(is_enabled)
|
||||
```
|
||||
|
||||
Set Drag component enabled state.
|
||||
|
||||
- **Parameters:**
|
||||
- `is_enabled` *(boolean)*:
|
||||
|
||||
- **Returns:**
|
||||
- `self` *(druid.drag)*: Current instance
|
||||
|
||||
### is_enabled
|
||||
|
||||
---
|
||||
```lua
|
||||
drag:is_enabled()
|
||||
```
|
||||
|
||||
Check if Drag component is capture input
|
||||
|
||||
- **Returns:**
|
||||
- `` *(boolean)*:
|
||||
|
||||
|
||||
## Fields
|
||||
<a name="node"></a>
|
||||
- **node** (_node_)
|
||||
|
||||
<a name="on_touch_start"></a>
|
||||
- **on_touch_start** (_event_)
|
||||
|
||||
<a name="on_touch_end"></a>
|
||||
- **on_touch_end** (_event_)
|
||||
|
||||
<a name="on_drag_start"></a>
|
||||
- **on_drag_start** (_event_)
|
||||
|
||||
<a name="on_drag"></a>
|
||||
- **on_drag** (_event_)
|
||||
|
||||
<a name="on_drag_end"></a>
|
||||
- **on_drag_end** (_event_)
|
||||
|
||||
<a name="style"></a>
|
||||
- **style** (_druid.drag.style_)
|
||||
|
||||
<a name="click_zone"></a>
|
||||
- **click_zone** (_node_)
|
||||
|
||||
<a name="is_touch"></a>
|
||||
- **is_touch** (_boolean_)
|
||||
|
||||
<a name="is_drag"></a>
|
||||
- **is_drag** (_boolean_)
|
||||
|
||||
<a name="can_x"></a>
|
||||
- **can_x** (_boolean_)
|
||||
|
||||
<a name="can_y"></a>
|
||||
- **can_y** (_boolean_)
|
||||
|
||||
<a name="dx"></a>
|
||||
- **dx** (_number_)
|
||||
|
||||
<a name="dy"></a>
|
||||
- **dy** (_number_)
|
||||
|
||||
<a name="touch_id"></a>
|
||||
- **touch_id** (_number_)
|
||||
|
||||
<a name="x"></a>
|
||||
- **x** (_number_)
|
||||
|
||||
<a name="y"></a>
|
||||
- **y** (_number_)
|
||||
|
||||
<a name="screen_x"></a>
|
||||
- **screen_x** (_number_)
|
||||
|
||||
<a name="screen_y"></a>
|
||||
- **screen_y** (_number_)
|
||||
|
||||
<a name="touch_start_pos"></a>
|
||||
- **touch_start_pos** (_vector3_)
|
||||
|
||||
<a name="druid"></a>
|
||||
- **druid** (_druid.instance_)
|
||||
|
||||
<a name="hover"></a>
|
||||
- **hover** (_druid.hover_)
|
||||
|
182
api/components/base/hover_api.md
Normal file
182
api/components/base/hover_api.md
Normal file
@@ -0,0 +1,182 @@
|
||||
# druid.hover API
|
||||
|
||||
> at /druid/base/hover.lua
|
||||
|
||||
|
||||
## Functions
|
||||
- [init](#init)
|
||||
- [on_late_init](#on_late_init)
|
||||
- [on_style_change](#on_style_change)
|
||||
- [on_input](#on_input)
|
||||
- [on_input_interrupt](#on_input_interrupt)
|
||||
- [set_hover](#set_hover)
|
||||
- [is_hovered](#is_hovered)
|
||||
- [set_mouse_hover](#set_mouse_hover)
|
||||
- [is_mouse_hovered](#is_mouse_hovered)
|
||||
- [set_click_zone](#set_click_zone)
|
||||
- [set_enabled](#set_enabled)
|
||||
- [is_enabled](#is_enabled)
|
||||
|
||||
|
||||
## Fields
|
||||
- [node](#node)
|
||||
- [on_hover](#on_hover)
|
||||
- [on_mouse_hover](#on_mouse_hover)
|
||||
- [style](#style)
|
||||
- [click_zone](#click_zone)
|
||||
|
||||
|
||||
|
||||
### init
|
||||
|
||||
---
|
||||
```lua
|
||||
hover:init(node, on_hover_callback, on_mouse_hover)
|
||||
```
|
||||
|
||||
- **Parameters:**
|
||||
- `node` *(node)*: Gui node
|
||||
- `on_hover_callback` *(function)*: Hover callback
|
||||
- `on_mouse_hover` *(function)*: On mouse hover callback
|
||||
|
||||
### on_late_init
|
||||
|
||||
---
|
||||
```lua
|
||||
hover:on_late_init()
|
||||
```
|
||||
|
||||
### on_style_change
|
||||
|
||||
---
|
||||
```lua
|
||||
hover:on_style_change(style)
|
||||
```
|
||||
|
||||
- **Parameters:**
|
||||
- `style` *(druid.hover.style)*:
|
||||
|
||||
### on_input
|
||||
|
||||
---
|
||||
```lua
|
||||
hover:on_input(action_id, action)
|
||||
```
|
||||
|
||||
- **Parameters:**
|
||||
- `action_id` *(hash)*:
|
||||
- `action` *(table)*:
|
||||
|
||||
- **Returns:**
|
||||
- `` *(boolean)*:
|
||||
|
||||
### on_input_interrupt
|
||||
|
||||
---
|
||||
```lua
|
||||
hover:on_input_interrupt()
|
||||
```
|
||||
|
||||
### set_hover
|
||||
|
||||
---
|
||||
```lua
|
||||
hover:set_hover([state])
|
||||
```
|
||||
|
||||
Set hover state
|
||||
|
||||
- **Parameters:**
|
||||
- `[state]` *(boolean|nil)*: The hover state
|
||||
|
||||
### is_hovered
|
||||
|
||||
---
|
||||
```lua
|
||||
hover:is_hovered()
|
||||
```
|
||||
|
||||
Return current hover state. True if touch action was on the node at current time
|
||||
|
||||
- **Returns:**
|
||||
- `is_hovered` *(boolean)*: The current hovered state
|
||||
|
||||
### set_mouse_hover
|
||||
|
||||
---
|
||||
```lua
|
||||
hover:set_mouse_hover([state])
|
||||
```
|
||||
|
||||
Set mouse hover state
|
||||
|
||||
- **Parameters:**
|
||||
- `[state]` *(boolean|nil)*: The mouse hover state
|
||||
|
||||
### is_mouse_hovered
|
||||
|
||||
---
|
||||
```lua
|
||||
hover:is_mouse_hovered()
|
||||
```
|
||||
|
||||
Return current hover state. True if nil action_id (usually desktop mouse) was on the node at current time
|
||||
|
||||
- **Returns:**
|
||||
- `The` *(boolean)*: current hovered state
|
||||
|
||||
### set_click_zone
|
||||
|
||||
---
|
||||
```lua
|
||||
hover:set_click_zone([zone])
|
||||
```
|
||||
|
||||
Strict hover click area. Useful for no click events outside stencil node
|
||||
|
||||
- **Parameters:**
|
||||
- `[zone]` *(string|node|nil)*: Gui node
|
||||
|
||||
### set_enabled
|
||||
|
||||
---
|
||||
```lua
|
||||
hover:set_enabled([state])
|
||||
```
|
||||
|
||||
Set enable state of hover component.
|
||||
If hover is not enabled, it will not generate
|
||||
any hover events
|
||||
|
||||
- **Parameters:**
|
||||
- `[state]` *(boolean|nil)*: The hover enabled state
|
||||
|
||||
### is_enabled
|
||||
|
||||
---
|
||||
```lua
|
||||
hover:is_enabled()
|
||||
```
|
||||
|
||||
Return current hover enabled state
|
||||
|
||||
- **Returns:**
|
||||
- `The` *(boolean)*: hover enabled state
|
||||
|
||||
|
||||
## Fields
|
||||
<a name="node"></a>
|
||||
- **node** (_node_)
|
||||
|
||||
<a name="on_hover"></a>
|
||||
- **on_hover** (_event_)
|
||||
|
||||
<a name="on_mouse_hover"></a>
|
||||
- **on_mouse_hover** (_event_)
|
||||
|
||||
<a name="style"></a>
|
||||
- **style** (_druid.hover.style_)
|
||||
|
||||
<a name="click_zone"></a>
|
||||
- **click_zone** (_node_)
|
||||
|
438
api/components/base/scroll_api.md
Normal file
438
api/components/base/scroll_api.md
Normal file
@@ -0,0 +1,438 @@
|
||||
# druid.scroll API
|
||||
|
||||
> at /druid/base/scroll.lua
|
||||
|
||||
|
||||
## Functions
|
||||
- [init](#init)
|
||||
- [on_style_change](#on_style_change)
|
||||
- [on_late_init](#on_late_init)
|
||||
- [on_layout_change](#on_layout_change)
|
||||
- [update](#update)
|
||||
- [on_input](#on_input)
|
||||
- [on_remove](#on_remove)
|
||||
- [scroll_to](#scroll_to)
|
||||
- [scroll_to_index](#scroll_to_index)
|
||||
- [scroll_to_percent](#scroll_to_percent)
|
||||
- [get_percent](#get_percent)
|
||||
- [set_size](#set_size)
|
||||
- [set_view_size](#set_view_size)
|
||||
- [update_view_size](#update_view_size)
|
||||
- [set_inert](#set_inert)
|
||||
- [is_inert](#is_inert)
|
||||
- [set_extra_stretch_size](#set_extra_stretch_size)
|
||||
- [get_scroll_size](#get_scroll_size)
|
||||
- [set_points](#set_points)
|
||||
- [set_horizontal_scroll](#set_horizontal_scroll)
|
||||
- [set_vertical_scroll](#set_vertical_scroll)
|
||||
- [is_node_in_view](#is_node_in_view)
|
||||
- [bind_grid](#bind_grid)
|
||||
- [set_click_zone](#set_click_zone)
|
||||
|
||||
|
||||
## Fields
|
||||
- [node](#node)
|
||||
- [click_zone](#click_zone)
|
||||
- [on_scroll](#on_scroll)
|
||||
- [on_scroll_to](#on_scroll_to)
|
||||
- [on_point_scroll](#on_point_scroll)
|
||||
- [view_node](#view_node)
|
||||
- [view_border](#view_border)
|
||||
- [content_node](#content_node)
|
||||
- [view_size](#view_size)
|
||||
- [position](#position)
|
||||
- [target_position](#target_position)
|
||||
- [available_pos](#available_pos)
|
||||
- [available_size](#available_size)
|
||||
- [drag](#drag)
|
||||
- [selected](#selected)
|
||||
- [is_animate](#is_animate)
|
||||
- [style](#style)
|
||||
- [druid](#druid)
|
||||
- [hover](#hover)
|
||||
- [points](#points)
|
||||
- [available_pos_extra](#available_pos_extra)
|
||||
- [available_size_extra](#available_size_extra)
|
||||
|
||||
|
||||
|
||||
### init
|
||||
|
||||
---
|
||||
```lua
|
||||
scroll:init(view_node, content_node)
|
||||
```
|
||||
|
||||
The Scroll constructor
|
||||
|
||||
- **Parameters:**
|
||||
- `view_node` *(string|node)*: GUI view scroll node
|
||||
- `content_node` *(string|node)*: GUI content scroll node
|
||||
|
||||
### on_style_change
|
||||
|
||||
---
|
||||
```lua
|
||||
scroll:on_style_change(style)
|
||||
```
|
||||
|
||||
- **Parameters:**
|
||||
- `style` *(druid.scroll.style)*: Scroll style parameters
|
||||
|
||||
### on_late_init
|
||||
|
||||
---
|
||||
```lua
|
||||
scroll:on_late_init()
|
||||
```
|
||||
|
||||
### on_layout_change
|
||||
|
||||
---
|
||||
```lua
|
||||
scroll:on_layout_change()
|
||||
```
|
||||
|
||||
### update
|
||||
|
||||
---
|
||||
```lua
|
||||
scroll:update([dt])
|
||||
```
|
||||
|
||||
- **Parameters:**
|
||||
- `[dt]` *(any)*:
|
||||
|
||||
### on_input
|
||||
|
||||
---
|
||||
```lua
|
||||
scroll:on_input([action_id], [action])
|
||||
```
|
||||
|
||||
- **Parameters:**
|
||||
- `[action_id]` *(any)*:
|
||||
- `[action]` *(any)*:
|
||||
|
||||
- **Returns:**
|
||||
- `` *(boolean)*:
|
||||
|
||||
### on_remove
|
||||
|
||||
---
|
||||
```lua
|
||||
scroll:on_remove()
|
||||
```
|
||||
|
||||
### scroll_to
|
||||
|
||||
---
|
||||
```lua
|
||||
scroll:scroll_to(point, [is_instant])
|
||||
```
|
||||
|
||||
Start scroll to target point.
|
||||
|
||||
- **Parameters:**
|
||||
- `point` *(vector3)*: Target point
|
||||
- `[is_instant]` *(boolean|nil)*: Instant scroll flag
|
||||
|
||||
### scroll_to_index
|
||||
|
||||
---
|
||||
```lua
|
||||
scroll:scroll_to_index(index, [skip_cb])
|
||||
```
|
||||
|
||||
Scroll to item in scroll by point index.
|
||||
|
||||
- **Parameters:**
|
||||
- `index` *(number)*: Point index
|
||||
- `[skip_cb]` *(boolean|nil)*: If true, skip the point callback
|
||||
|
||||
### scroll_to_percent
|
||||
|
||||
---
|
||||
```lua
|
||||
scroll:scroll_to_percent(percent, [is_instant])
|
||||
```
|
||||
|
||||
Start scroll to target scroll percent
|
||||
|
||||
- **Parameters:**
|
||||
- `percent` *(vector3)*: target percent
|
||||
- `[is_instant]` *(boolean|nil)*: instant scroll flag
|
||||
|
||||
### get_percent
|
||||
|
||||
---
|
||||
```lua
|
||||
scroll:get_percent()
|
||||
```
|
||||
|
||||
Return current scroll progress status.
|
||||
Values will be in [0..1] interval
|
||||
|
||||
- **Returns:**
|
||||
- `New` *(vector3)*: vector with scroll progress values
|
||||
|
||||
### set_size
|
||||
|
||||
---
|
||||
```lua
|
||||
scroll:set_size(size, [offset])
|
||||
```
|
||||
|
||||
Set scroll content size.
|
||||
It will change content gui node size
|
||||
|
||||
- **Parameters:**
|
||||
- `size` *(vector3)*: The new size for content node
|
||||
- `[offset]` *(vector3|nil)*: Offset value to set, where content is starts
|
||||
|
||||
- **Returns:**
|
||||
- `Current` *(druid.scroll)*: scroll instance
|
||||
|
||||
### set_view_size
|
||||
|
||||
---
|
||||
```lua
|
||||
scroll:set_view_size(size)
|
||||
```
|
||||
|
||||
Set new scroll view size in case the node size was changed.
|
||||
|
||||
- **Parameters:**
|
||||
- `size` *(vector3)*: The new size for view node
|
||||
|
||||
- **Returns:**
|
||||
- `Current` *(druid.scroll)*: scroll instance
|
||||
|
||||
### update_view_size
|
||||
|
||||
---
|
||||
```lua
|
||||
scroll:update_view_size()
|
||||
```
|
||||
|
||||
Refresh scroll view size
|
||||
|
||||
- **Returns:**
|
||||
- `` *(druid.scroll)*:
|
||||
|
||||
### set_inert
|
||||
|
||||
---
|
||||
```lua
|
||||
scroll:set_inert(state)
|
||||
```
|
||||
|
||||
Enable or disable scroll inert
|
||||
If disabled, scroll through points (if exist)
|
||||
If no points, just simple drag without inertion
|
||||
|
||||
- **Parameters:**
|
||||
- `state` *(boolean)*: Inert scroll state
|
||||
|
||||
- **Returns:**
|
||||
- `Current` *(druid.scroll)*: scroll instance
|
||||
|
||||
### is_inert
|
||||
|
||||
---
|
||||
```lua
|
||||
scroll:is_inert()
|
||||
```
|
||||
|
||||
Return if scroll have inertion
|
||||
|
||||
- **Returns:**
|
||||
- `is_inert` *(boolean)*: If scroll have inertion
|
||||
|
||||
### set_extra_stretch_size
|
||||
|
||||
---
|
||||
```lua
|
||||
scroll:set_extra_stretch_size([stretch_size])
|
||||
```
|
||||
|
||||
Set extra size for scroll stretching
|
||||
Set 0 to disable stretching effect
|
||||
|
||||
- **Parameters:**
|
||||
- `[stretch_size]` *(number|nil)*: Size in pixels of additional scroll area
|
||||
|
||||
- **Returns:**
|
||||
- `Current` *(druid.scroll)*: scroll instance
|
||||
|
||||
### get_scroll_size
|
||||
|
||||
---
|
||||
```lua
|
||||
scroll:get_scroll_size()
|
||||
```
|
||||
|
||||
Return vector of scroll size with width and height.
|
||||
|
||||
- **Returns:**
|
||||
- `Available` *(vector3)*: scroll size
|
||||
|
||||
### set_points
|
||||
|
||||
---
|
||||
```lua
|
||||
scroll:set_points(points)
|
||||
```
|
||||
|
||||
Set points of interest.
|
||||
Scroll will always centered on closer points
|
||||
|
||||
- **Parameters:**
|
||||
- `points` *(table)*: Array of vector3 points
|
||||
|
||||
- **Returns:**
|
||||
- `Current` *(druid.scroll)*: scroll instance
|
||||
|
||||
### set_horizontal_scroll
|
||||
|
||||
---
|
||||
```lua
|
||||
scroll:set_horizontal_scroll(state)
|
||||
```
|
||||
|
||||
Lock or unlock horizontal scroll
|
||||
|
||||
- **Parameters:**
|
||||
- `state` *(boolean)*: True, if horizontal scroll is enabled
|
||||
|
||||
- **Returns:**
|
||||
- `Current` *(druid.scroll)*: scroll instance
|
||||
|
||||
### set_vertical_scroll
|
||||
|
||||
---
|
||||
```lua
|
||||
scroll:set_vertical_scroll(state)
|
||||
```
|
||||
|
||||
Lock or unlock vertical scroll
|
||||
|
||||
- **Parameters:**
|
||||
- `state` *(boolean)*: True, if vertical scroll is enabled
|
||||
|
||||
- **Returns:**
|
||||
- `Current` *(druid.scroll)*: scroll instance
|
||||
|
||||
### is_node_in_view
|
||||
|
||||
---
|
||||
```lua
|
||||
scroll:is_node_in_view(node)
|
||||
```
|
||||
|
||||
Check node if it visible now on scroll.
|
||||
Extra border is not affected. Return true for elements in extra scroll zone
|
||||
|
||||
- **Parameters:**
|
||||
- `node` *(node)*: The node to check
|
||||
|
||||
- **Returns:**
|
||||
- `True` *(boolean)*: if node in visible scroll area
|
||||
|
||||
### bind_grid
|
||||
|
||||
---
|
||||
```lua
|
||||
scroll:bind_grid([grid])
|
||||
```
|
||||
|
||||
Bind the grid component (Static or Dynamic) to recalculate
|
||||
scroll size on grid changes
|
||||
|
||||
- **Parameters:**
|
||||
- `[grid]` *(druid.grid|nil)*: Druid grid component
|
||||
|
||||
- **Returns:**
|
||||
- `Current` *(druid.scroll)*: scroll instance
|
||||
|
||||
### set_click_zone
|
||||
|
||||
---
|
||||
```lua
|
||||
scroll:set_click_zone(node)
|
||||
```
|
||||
|
||||
Strict drag scroll area. Useful for
|
||||
restrict events outside stencil node
|
||||
|
||||
- **Parameters:**
|
||||
- `node` *(string|node)*: Gui node
|
||||
|
||||
|
||||
## Fields
|
||||
<a name="node"></a>
|
||||
- **node** (_node_): The root node
|
||||
|
||||
<a name="click_zone"></a>
|
||||
- **click_zone** (_node_): Optional click zone to restrict scroll area
|
||||
|
||||
<a name="on_scroll"></a>
|
||||
- **on_scroll** (_event_): Triggered on scroll move with (self, position)
|
||||
|
||||
<a name="on_scroll_to"></a>
|
||||
- **on_scroll_to** (_event_): Triggered on scroll_to with (self, target, is_instant)
|
||||
|
||||
<a name="on_point_scroll"></a>
|
||||
- **on_point_scroll** (_event_): Triggered on scroll_to_index with (self, index, point)
|
||||
|
||||
<a name="view_node"></a>
|
||||
- **view_node** (_node_): The scroll view node (static part)
|
||||
|
||||
<a name="view_border"></a>
|
||||
- **view_border** (_vector4_): The scroll view borders
|
||||
|
||||
<a name="content_node"></a>
|
||||
- **content_node** (_node_): The scroll content node (moving part)
|
||||
|
||||
<a name="view_size"></a>
|
||||
- **view_size** (_vector3_): Size of the view node
|
||||
|
||||
<a name="position"></a>
|
||||
- **position** (_vector3_): Current scroll position
|
||||
|
||||
<a name="target_position"></a>
|
||||
- **target_position** (_vector3_): Target scroll position for animations
|
||||
|
||||
<a name="available_pos"></a>
|
||||
- **available_pos** (_vector4_): Available content position (min_x, max_y, max_x, min_y)
|
||||
|
||||
<a name="available_size"></a>
|
||||
- **available_size** (_vector3_): Size of available positions (width, height, 0)
|
||||
|
||||
<a name="drag"></a>
|
||||
- **drag** (_druid.drag_): The drag component instance
|
||||
|
||||
<a name="selected"></a>
|
||||
- **selected** (_number_): Current selected point of interest index
|
||||
|
||||
<a name="is_animate"></a>
|
||||
- **is_animate** (_boolean_): True if scroll is animating
|
||||
|
||||
<a name="style"></a>
|
||||
- **style** (_druid.scroll.style_): Component style parameters
|
||||
|
||||
<a name="druid"></a>
|
||||
- **druid** (_druid.instance_)
|
||||
|
||||
<a name="hover"></a>
|
||||
- **hover** (_druid.hover_)
|
||||
|
||||
<a name="points"></a>
|
||||
- **points** (_table_)
|
||||
|
||||
<a name="available_pos_extra"></a>
|
||||
- **available_pos_extra** (_unknown_)
|
||||
|
||||
<a name="available_size_extra"></a>
|
||||
- **available_size_extra** (_vector3_)
|
||||
|
383
api/components/base/static_grid_api.md
Normal file
383
api/components/base/static_grid_api.md
Normal file
@@ -0,0 +1,383 @@
|
||||
# druid.grid API
|
||||
|
||||
> at /druid/base/static_grid.lua
|
||||
|
||||
|
||||
## Functions
|
||||
- [init](#init)
|
||||
- [on_style_change](#on_style_change)
|
||||
- [get_pos](#get_pos)
|
||||
- [get_index](#get_index)
|
||||
- [get_index_by_node](#get_index_by_node)
|
||||
- [on_layout_change](#on_layout_change)
|
||||
- [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])
|
||||
```
|
||||
|
||||
- **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
|
||||
|
||||
### on_style_change
|
||||
|
||||
---
|
||||
```lua
|
||||
grid:on_style_change(style)
|
||||
```
|
||||
|
||||
- **Parameters:**
|
||||
- `style` *(druid.grid.style)*:
|
||||
|
||||
### 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 index for grid pos
|
||||
|
||||
- **Parameters:**
|
||||
- `pos` *(vector3)*: The node position in the grid
|
||||
|
||||
- **Returns:**
|
||||
- `The` *(number)*: 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
|
||||
|
||||
### on_layout_change
|
||||
|
||||
---
|
||||
```lua
|
||||
grid:on_layout_change()
|
||||
```
|
||||
|
||||
### 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()
|
||||
```
|
||||
|
||||
Update grid content
|
||||
|
||||
### set_pivot
|
||||
|
||||
---
|
||||
```lua
|
||||
grid:set_pivot([pivot])
|
||||
```
|
||||
|
||||
- **Parameters:**
|
||||
- `[pivot]` *(any)*:
|
||||
|
||||
### 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
|
||||
|
||||
### 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
|
||||
|
||||
### 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:**
|
||||
- `The` *(node)*: deleted gui node from grid
|
||||
|
||||
### get_size
|
||||
|
||||
---
|
||||
```lua
|
||||
grid:get_size()
|
||||
```
|
||||
|
||||
Return grid content size
|
||||
|
||||
- **Returns:**
|
||||
- `The` *(vector3)*: grid content size
|
||||
|
||||
### get_size_for
|
||||
|
||||
---
|
||||
```lua
|
||||
grid:get_size_for([count])
|
||||
```
|
||||
|
||||
- **Parameters:**
|
||||
- `[count]` *(any)*:
|
||||
|
||||
### get_borders
|
||||
|
||||
---
|
||||
```lua
|
||||
grid:get_borders()
|
||||
```
|
||||
|
||||
Return grid content borders
|
||||
|
||||
- **Returns:**
|
||||
- `The` *(vector4)*: grid content borders
|
||||
|
||||
### get_all_pos
|
||||
|
||||
---
|
||||
```lua
|
||||
grid:get_all_pos()
|
||||
```
|
||||
|
||||
Return array of all node positions
|
||||
|
||||
- **Returns:**
|
||||
- `All` *(vector3[])*: 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:**
|
||||
- `Current` *(druid.grid)*: 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:**
|
||||
- `Current` *(druid.grid)*: grid instance
|
||||
|
||||
### get_offset
|
||||
|
||||
---
|
||||
```lua
|
||||
grid:get_offset()
|
||||
```
|
||||
|
||||
Return StaticGrid offset, where StaticGrid content starts.
|
||||
|
||||
- **Returns:**
|
||||
- `The` *(vector3)*: 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:**
|
||||
- `Current` *(druid.grid)*: 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:**
|
||||
- `Current` *(druid.grid)*: 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_)
|
||||
|
||||
<a name="on_remove_item"></a>
|
||||
- **on_remove_item** (_event_)
|
||||
|
||||
<a name="on_change_items"></a>
|
||||
- **on_change_items** (_event_)
|
||||
|
||||
<a name="on_clear"></a>
|
||||
- **on_clear** (_event_)
|
||||
|
||||
<a name="on_update_positions"></a>
|
||||
- **on_update_positions** (_event_)
|
||||
|
||||
<a name="parent"></a>
|
||||
- **parent** (_node_)
|
||||
|
||||
<a name="nodes"></a>
|
||||
- **nodes** (_node[]_)
|
||||
|
||||
<a name="first_index"></a>
|
||||
- **first_index** (_number_)
|
||||
|
||||
<a name="last_index"></a>
|
||||
- **last_index** (_number_)
|
||||
|
||||
<a name="anchor"></a>
|
||||
- **anchor** (_vector3_)
|
||||
|
||||
<a name="pivot"></a>
|
||||
- **pivot** (_vector3_)
|
||||
|
||||
<a name="node_size"></a>
|
||||
- **node_size** (_vector3_)
|
||||
|
||||
<a name="border"></a>
|
||||
- **border** (_vector4_)
|
||||
|
||||
<a name="in_row"></a>
|
||||
- **in_row** (_number_)
|
||||
|
||||
<a name="style"></a>
|
||||
- **style** (_table_)
|
||||
|
||||
<a name="node_pivot"></a>
|
||||
- **node_pivot** (_unknown_)
|
||||
|
318
api/components/base/text_api.md
Normal file
318
api/components/base/text_api.md
Normal file
@@ -0,0 +1,318 @@
|
||||
# druid.text API
|
||||
|
||||
> at /druid/base/text.lua
|
||||
|
||||
|
||||
## Functions
|
||||
- [init](#init)
|
||||
- [on_style_change](#on_style_change)
|
||||
- [on_layout_change](#on_layout_change)
|
||||
- [get_text_size](#get_text_size)
|
||||
- [get_text_index_by_width](#get_text_index_by_width)
|
||||
- [set_to](#set_to)
|
||||
- [set_text](#set_text)
|
||||
- [get_text](#get_text)
|
||||
- [set_size](#set_size)
|
||||
- [set_color](#set_color)
|
||||
- [set_alpha](#set_alpha)
|
||||
- [set_scale](#set_scale)
|
||||
- [set_pivot](#set_pivot)
|
||||
- [is_multiline](#is_multiline)
|
||||
- [set_text_adjust](#set_text_adjust)
|
||||
- [set_minimal_scale](#set_minimal_scale)
|
||||
- [get_text_adjust](#get_text_adjust)
|
||||
|
||||
|
||||
## Fields
|
||||
- [node](#node)
|
||||
- [on_set_text](#on_set_text)
|
||||
- [on_update_text_scale](#on_update_text_scale)
|
||||
- [on_set_pivot](#on_set_pivot)
|
||||
- [style](#style)
|
||||
- [pos](#pos)
|
||||
- [node_id](#node_id)
|
||||
- [start_size](#start_size)
|
||||
- [text_area](#text_area)
|
||||
- [adjust_type](#adjust_type)
|
||||
- [color](#color)
|
||||
- [last_value](#last_value)
|
||||
- [last_scale](#last_scale)
|
||||
|
||||
|
||||
|
||||
### init
|
||||
|
||||
---
|
||||
```lua
|
||||
text:init(node, [value], [adjust_type])
|
||||
```
|
||||
|
||||
The Text constructor
|
||||
|
||||
- **Parameters:**
|
||||
- `node` *(string|node)*: Node name or GUI Text Node itself
|
||||
- `[value]` *(string|nil)*: Initial text. Default value is node text from GUI scene. Default: nil
|
||||
- `[adjust_type]` *(string|nil)*: Adjust type for text. By default is DOWNSCALE. Look const.TEXT_ADJUST for reference. Default: DOWNSCALE
|
||||
|
||||
- **Returns:**
|
||||
- `` *(druid.text)*:
|
||||
|
||||
### on_style_change
|
||||
|
||||
---
|
||||
```lua
|
||||
text:on_style_change(style)
|
||||
```
|
||||
|
||||
- **Parameters:**
|
||||
- `style` *(druid.text.style)*:
|
||||
|
||||
### on_layout_change
|
||||
|
||||
---
|
||||
```lua
|
||||
text:on_layout_change()
|
||||
```
|
||||
|
||||
### get_text_size
|
||||
|
||||
---
|
||||
```lua
|
||||
text:get_text_size([text])
|
||||
```
|
||||
|
||||
Calculate text width with font with respect to trailing space
|
||||
|
||||
- **Parameters:**
|
||||
- `[text]` *(string|nil)*:
|
||||
|
||||
- **Returns:**
|
||||
- `Width` *(number)*:
|
||||
- `Height` *(number)*:
|
||||
|
||||
### get_text_index_by_width
|
||||
|
||||
---
|
||||
```lua
|
||||
text:get_text_index_by_width(width)
|
||||
```
|
||||
|
||||
Get chars count by width
|
||||
|
||||
- **Parameters:**
|
||||
- `width` *(number)*:
|
||||
|
||||
- **Returns:**
|
||||
- `Chars` *(number)*: count
|
||||
|
||||
### set_to
|
||||
|
||||
---
|
||||
```lua
|
||||
text:set_to(set_to)
|
||||
```
|
||||
|
||||
Set text to text field
|
||||
|
||||
- **Parameters:**
|
||||
- `set_to` *(string)*: Text for node
|
||||
|
||||
- **Returns:**
|
||||
- `Current` *(druid.text)*: text instance
|
||||
|
||||
### set_text
|
||||
|
||||
---
|
||||
```lua
|
||||
text:set_text([new_text])
|
||||
```
|
||||
|
||||
- **Parameters:**
|
||||
- `[new_text]` *(any)*:
|
||||
|
||||
- **Returns:**
|
||||
- `` *(druid.text)*:
|
||||
|
||||
### get_text
|
||||
|
||||
---
|
||||
```lua
|
||||
text:get_text()
|
||||
```
|
||||
|
||||
- **Returns:**
|
||||
- `` *(unknown)*:
|
||||
|
||||
### set_size
|
||||
|
||||
---
|
||||
```lua
|
||||
text:set_size(size)
|
||||
```
|
||||
|
||||
Set text area size
|
||||
|
||||
- **Parameters:**
|
||||
- `size` *(vector3)*: The new text area size
|
||||
|
||||
- **Returns:**
|
||||
- `self` *(druid.text)*: Current text instance
|
||||
|
||||
### set_color
|
||||
|
||||
---
|
||||
```lua
|
||||
text:set_color(color)
|
||||
```
|
||||
|
||||
Set color
|
||||
|
||||
- **Parameters:**
|
||||
- `color` *(vector4)*: Color for node
|
||||
|
||||
- **Returns:**
|
||||
- `Current` *(druid.text)*: text instance
|
||||
|
||||
### set_alpha
|
||||
|
||||
---
|
||||
```lua
|
||||
text:set_alpha(alpha)
|
||||
```
|
||||
|
||||
Set alpha
|
||||
|
||||
- **Parameters:**
|
||||
- `alpha` *(number)*: Alpha for node
|
||||
|
||||
- **Returns:**
|
||||
- `Current` *(druid.text)*: text instance
|
||||
|
||||
### set_scale
|
||||
|
||||
---
|
||||
```lua
|
||||
text:set_scale(scale)
|
||||
```
|
||||
|
||||
Set scale
|
||||
|
||||
- **Parameters:**
|
||||
- `scale` *(vector3)*: Scale for node
|
||||
|
||||
- **Returns:**
|
||||
- `Current` *(druid.text)*: text instance
|
||||
|
||||
### set_pivot
|
||||
|
||||
---
|
||||
```lua
|
||||
text:set_pivot(pivot)
|
||||
```
|
||||
|
||||
Set text pivot. Text will re-anchor inside text area
|
||||
|
||||
- **Parameters:**
|
||||
- `pivot` *(userdata)*: The gui.PIVOT_* constant
|
||||
|
||||
- **Returns:**
|
||||
- `Current` *(druid.text)*: text instance
|
||||
|
||||
### is_multiline
|
||||
|
||||
---
|
||||
```lua
|
||||
text:is_multiline()
|
||||
```
|
||||
|
||||
Return true, if text with line break
|
||||
|
||||
- **Returns:**
|
||||
- `Is` *(boolean)*: text node with line break
|
||||
|
||||
### set_text_adjust
|
||||
|
||||
---
|
||||
```lua
|
||||
text:set_text_adjust([adjust_type], [minimal_scale])
|
||||
```
|
||||
|
||||
Set text adjust, refresh the current text visuals, if needed
|
||||
Values are: "downscale", "trim", "no_adjust", "downscale_limited",
|
||||
"scroll", "scale_then_scroll", "trim_left", "scale_then_trim", "scale_then_trim_left"
|
||||
|
||||
- **Parameters:**
|
||||
- `[adjust_type]` *(string|nil)*: See const.TEXT_ADJUST. If pass nil - use current adjust type
|
||||
- `[minimal_scale]` *(number|nil)*: To remove minimal scale, use `text:set_minimal_scale(nil)`, if pass nil - not change minimal scale
|
||||
|
||||
- **Returns:**
|
||||
- `self` *(druid.text)*: Current text instance
|
||||
|
||||
### set_minimal_scale
|
||||
|
||||
---
|
||||
```lua
|
||||
text:set_minimal_scale(minimal_scale)
|
||||
```
|
||||
|
||||
Set minimal scale for DOWNSCALE_LIMITED or SCALE_THEN_SCROLL adjust types
|
||||
|
||||
- **Parameters:**
|
||||
- `minimal_scale` *(number)*: If pass nil - not use minimal scale
|
||||
|
||||
- **Returns:**
|
||||
- `Current` *(druid.text)*: text instance
|
||||
|
||||
### get_text_adjust
|
||||
|
||||
---
|
||||
```lua
|
||||
text:get_text_adjust()
|
||||
```
|
||||
|
||||
Return current text adjust type
|
||||
|
||||
- **Returns:**
|
||||
- `adjust_type` *(string)*: The current text adjust type
|
||||
|
||||
|
||||
## Fields
|
||||
<a name="node"></a>
|
||||
- **node** (_node_): The text node
|
||||
|
||||
<a name="on_set_text"></a>
|
||||
- **on_set_text** (_event_): The event triggered when the text is set, fun(self, text)
|
||||
|
||||
<a name="on_update_text_scale"></a>
|
||||
- **on_update_text_scale** (_event_): The event triggered when the text scale is updated, fun(self, scale, metrics)
|
||||
|
||||
<a name="on_set_pivot"></a>
|
||||
- **on_set_pivot** (_event_): The event triggered when the text pivot is set, fun(self, pivot)
|
||||
|
||||
<a name="style"></a>
|
||||
- **style** (_druid.text.style_): The style of the text
|
||||
|
||||
<a name="pos"></a>
|
||||
- **pos** (_unknown_)
|
||||
|
||||
<a name="node_id"></a>
|
||||
- **node_id** (_unknown_)
|
||||
|
||||
<a name="start_size"></a>
|
||||
- **start_size** (_unknown_)
|
||||
|
||||
<a name="text_area"></a>
|
||||
- **text_area** (_unknown_)
|
||||
|
||||
<a name="adjust_type"></a>
|
||||
- **adjust_type** (_string|nil_)
|
||||
|
||||
<a name="color"></a>
|
||||
- **color** (_unknown_)
|
||||
|
||||
<a name="last_value"></a>
|
||||
- **last_value** (_unknown_)
|
||||
|
||||
<a name="last_scale"></a>
|
||||
- **last_scale** (_vector3_)
|
||||
|
Reference in New Issue
Block a user