Test new markdown api generator

This commit is contained in:
Insality
2025-03-14 20:29:05 +02:00
parent 11aeb377c2
commit b30cf9109e
74 changed files with 5581 additions and 2656 deletions

View File

@@ -0,0 +1,6 @@
# Back Handler Quick API reference
```lua
back_handler:init([callback], [params])
back_handler:on_input([action_id], [action])
```

View 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_)

View 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

View 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_)

View 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_)

View 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_)

View 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_)

View 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_)

View File

@@ -0,0 +1,178 @@
# druid.rich_input API
> at /druid/custom/rich_input/rich_input.lua
## Functions
- [init](#init)
- [on_input](#on_input)
- [set_placeholder](#set_placeholder)
- [select](#select)
- [set_text](#set_text)
- [set_font](#set_font)
- [get_text](#get_text)
- [set_allowed_characters](#set_allowed_characters)
## Fields
- [root](#root)
- [input](#input)
- [cursor](#cursor)
- [cursor_text](#cursor_text)
- [cursor_position](#cursor_position)
- [druid](#druid)
- [is_lshift](#is_lshift)
- [is_lctrl](#is_lctrl)
- [is_button_input_enabled](#is_button_input_enabled)
- [drag](#drag)
- [placeholder](#placeholder)
- [text_position](#text_position)
### init
---
```lua
rich_input:init(template, nodes)
```
- **Parameters:**
- `template` *(string)*: The template string name
- `nodes` *(table)*: Nodes table from gui.clone_tree
### on_input
---
```lua
rich_input:on_input([action_id], [action])
```
- **Parameters:**
- `[action_id]` *(any)*:
- `[action]` *(any)*:
- **Returns:**
- `` *(boolean)*:
### set_placeholder
---
```lua
rich_input:set_placeholder(placeholder_text)
```
Set placeholder text
- **Parameters:**
- `placeholder_text` *(string)*: The placeholder text
- **Returns:**
- `` *(druid.rich_input)*:
### select
---
```lua
rich_input:select()
```
Select input field
### set_text
---
```lua
rich_input:set_text(text)
```
Set input field text
- **Parameters:**
- `text` *(string)*: The input text
- **Returns:**
- `self` *(druid.rich_input)*: Current instance
### set_font
---
```lua
rich_input:set_font(font)
```
Set input field font
- **Parameters:**
- `font` *(hash)*: The font hash
- **Returns:**
- `self` *(druid.rich_input)*: Current instance
### get_text
---
```lua
rich_input:get_text()
```
Set input field text
- **Returns:**
- `` *(string)*:
### set_allowed_characters
---
```lua
rich_input:set_allowed_characters(characters)
```
Set allowed charaters for input field.
See: https://defold.com/ref/stable/string/
ex: [%a%d] for alpha and numeric
- **Parameters:**
- `characters` *(string)*: Regulax exp. for validate user input
- **Returns:**
- `Current` *(druid.rich_input)*: instance
## Fields
<a name="root"></a>
- **root** (_node_)
<a name="input"></a>
- **input** (_druid.input_)
<a name="cursor"></a>
- **cursor** (_node_)
<a name="cursor_text"></a>
- **cursor_text** (_node_)
<a name="cursor_position"></a>
- **cursor_position** (_vector3_)
<a name="druid"></a>
- **druid** (_druid.instance_)
<a name="is_lshift"></a>
- **is_lshift** (_boolean_)
<a name="is_lctrl"></a>
- **is_lctrl** (_boolean_)
<a name="is_button_input_enabled"></a>
- **is_button_input_enabled** (_unknown_)
<a name="drag"></a>
- **drag** (_druid.drag_)
<a name="placeholder"></a>
- **placeholder** (_druid.text_)
<a name="text_position"></a>
- **text_position** (_unknown_)

View File

@@ -0,0 +1,187 @@
# druid.rich_text API
> at /druid/custom/rich_text/rich_text.lua
## Functions
- [init](#init)
- [on_layout_change](#on_layout_change)
- [on_style_change](#on_style_change)
- [set_text](#set_text)
- [get_text](#get_text)
- [on_remove](#on_remove)
- [clear](#clear)
- [tagged](#tagged)
- [characters](#characters)
- [get_words](#get_words)
- [get_line_metric](#get_line_metric)
## Fields
- [root](#root)
- [text_prefab](#text_prefab)
- [style](#style)
### init
---
```lua
rich_text:init(text_node, [value])
```
- **Parameters:**
- `text_node` *(string|node)*: The text node to make Rich Text
- `[value]` *(string|nil)*: The initial text value. Default will be gui.get_text(text_node)
### on_layout_change
---
```lua
rich_text:on_layout_change()
```
### on_style_change
---
```lua
rich_text:on_style_change(style)
```
- **Parameters:**
- `style` *(druid.rich_text.style)*:
### set_text
---
```lua
rich_text:set_text([text])
```
Set text for Rich Text
- **Parameters:**
- `[text]` *(string|nil)*: The text to set
- **Returns:**
- `words` *(druid.rich_text.word[])*:
- `line_metrics` *(druid.rich_text.lines_metrics)*:
- **Example Usage:**
```lua
rich_text:set_text("color=redFoobar/color")
rich_text:set_text("color=1.0,0,0,1.0Foobar/color")
rich_text:set_text("color=#ff0000Foobar/color")
rich_text:set_text("color=#ff0000ffFoobar/color")
rich_text:set_text("shadow=redFoobar/shadow")
rich_text:set_text("shadow=1.0,0,0,1.0Foobar/shadow")
rich_text:set_text("shadow=#ff0000Foobar/shadow")
rich_text:set_text("shadow=#ff0000ffFoobar/shadow")
rich_text:set_text("outline=redFoobar/outline")
rich_text:set_text("outline=1.0,0,0,1.0Foobar/outline")
rich_text:set_text("outline=#ff0000Foobar/outline")
rich_text:set_text("outline=#ff0000ffFoobar/outline")
rich_text:set_text("font=MyCoolFontFoobar/font")
rich_text:set_text("size=2Twice as large/size")
rich_text:set_text("br/Insert a line break")
rich_text:set_text("nobrPrevent the text from breaking")
rich_text:set_text("img=texture:imageDisplay image")
rich_text:set_text("img=texture:image,sizeDisplay image with size")
rich_text:set_text("img=texture:image,width,heightDisplay image with width and height")
```
### get_text
---
```lua
rich_text:get_text()
```
Get current text
- **Returns:**
- `text` *(string)*:
### on_remove
---
```lua
rich_text:on_remove()
```
### clear
---
```lua
rich_text:clear()
```
Clear all created words.
### tagged
---
```lua
rich_text:tagged(tag)
```
Get all words, which has a passed tag.
- **Parameters:**
- `tag` *(string)*:
- **Returns:**
- `words` *(druid.rich_text.word[])*:
### characters
---
```lua
rich_text:characters(word)
```
Split a word into it's characters
- **Parameters:**
- `word` *(druid.rich_text.word)*:
- **Returns:**
- `characters` *(druid.rich_text.word[])*:
### get_words
---
```lua
rich_text:get_words()
```
Get all current words.
- **Returns:**
- `` *(druid.rich_text.word[])*:
### get_line_metric
---
```lua
rich_text:get_line_metric()
```
Get current line metrics
-@return druid.rich_text.lines_metrics
- **Returns:**
- `` *(druid.rich_text.lines_metrics)*:
## Fields
<a name="root"></a>
- **root** (_node_)
<a name="text_prefab"></a>
- **text_prefab** (_node_)
<a name="style"></a>
- **style** (_table_)

View File

@@ -0,0 +1,382 @@
# druid.container API
> at /druid/extended/container.lua
## Functions
- [init](#init)
- [on_late_init](#on_late_init)
- [on_remove](#on_remove)
- [refresh_origins](#refresh_origins)
- [set_pivot](#set_pivot)
- [on_style_change](#on_style_change)
- [set_size](#set_size)
- [get_position](#get_position)
- [set_position](#set_position)
- [get_size](#get_size)
- [get_scale](#get_scale)
- [fit_into_size](#fit_into_size)
- [fit_into_window](#fit_into_window)
- [on_window_resized](#on_window_resized)
- [add_container](#add_container)
- [remove_container_by_node](#remove_container_by_node)
- [set_parent_container](#set_parent_container)
- [refresh](#refresh)
- [refresh_scale](#refresh_scale)
- [update_child_containers](#update_child_containers)
- [create_draggable_corners](#create_draggable_corners)
- [clear_draggable_corners](#clear_draggable_corners)
- [fit_into_node](#fit_into_node)
- [set_min_size](#set_min_size)
## Fields
- [node](#node)
- [druid](#druid)
- [node_offset](#node_offset)
- [origin_size](#origin_size)
- [size](#size)
- [origin_position](#origin_position)
- [position](#position)
- [pivot_offset](#pivot_offset)
- [center_offset](#center_offset)
- [mode](#mode)
- [fit_size](#fit_size)
- [min_size_x](#min_size_x)
- [min_size_y](#min_size_y)
- [on_size_changed](#on_size_changed)
- [node_fill_x](#node_fill_x)
- [node_fill_y](#node_fill_y)
- [x_koef](#x_koef)
- [y_koef](#y_koef)
- [x_anchor](#x_anchor)
- [y_anchor](#y_anchor)
- [style](#style)
### init
---
```lua
container:init(node, mode, [callback])
```
- **Parameters:**
- `node` *(node)*: Gui node
- `mode` *(string)*: Layout mode
- `[callback]` *(fun(self: druid.container, size: vector3)|nil)*: Callback on size changed
### on_late_init
---
```lua
container:on_late_init()
```
### on_remove
---
```lua
container:on_remove()
```
### refresh_origins
---
```lua
container:refresh_origins()
```
### set_pivot
---
```lua
container:set_pivot(pivot)
```
- **Parameters:**
- `pivot` *(constant)*:
### on_style_change
---
```lua
container:on_style_change(style)
```
- **Parameters:**
- `style` *(druid.container.style)*:
### set_size
---
```lua
container:set_size([width], [height], [anchor_pivot])
```
Set new size of layout node
- **Parameters:**
- `[width]` *(number|nil)*:
- `[height]` *(number|nil)*:
- `[anchor_pivot]` *(constant|nil)*: If set will keep the corner possition relative to the new size
- **Returns:**
- `Container` *(druid.container)*:
### get_position
---
```lua
container:get_position()
```
- **Returns:**
- `` *(unknown)*:
### set_position
---
```lua
container:set_position(pos_x, pos_y)
```
- **Parameters:**
- `pos_x` *(number)*:
- `pos_y` *(number)*:
### get_size
---
```lua
container:get_size()
```
Get current size of layout node
- **Returns:**
- `size` *(vector3)*:
### get_scale
---
```lua
container:get_scale()
```
Get current scale of layout node
- **Returns:**
- `scale` *(vector3)*:
### fit_into_size
---
```lua
container:fit_into_size(target_size)
```
Set size for layout node to fit inside it
- **Parameters:**
- `target_size` *(vector3)*:
- **Returns:**
- `Container` *(druid.container)*:
### fit_into_window
---
```lua
container:fit_into_window()
```
Set current size for layout node to fit inside it
- **Returns:**
- `Container` *(druid.container)*:
### on_window_resized
---
```lua
container:on_window_resized()
```
### add_container
---
```lua
container:add_container(node_or_container, [mode], [on_resize_callback])
```
- **Parameters:**
- `node_or_container` *(string|table|druid.container|node)*:
- `[mode]` *(string|nil)*: stretch, fit, stretch_x, stretch_y. Default: Pick from node, "fit" or "stretch"
- `[on_resize_callback]` *(fun(self: userdata, size: vector3)|nil)*:
- **Returns:**
- `Container` *(druid.container)*: New created layout instance
### remove_container_by_node
---
```lua
container:remove_container_by_node([node])
```
- **Parameters:**
- `[node]` *(any)*:
- **Returns:**
- `` *(druid.container|nil)*:
### set_parent_container
---
```lua
container:set_parent_container([parent_container])
```
- **Parameters:**
- `[parent_container]` *(druid.container|nil)*:
### refresh
---
```lua
container:refresh()
```
Glossary
Center Offset - vector from node position to visual center of node
### refresh_scale
---
```lua
container:refresh_scale()
```
### update_child_containers
---
```lua
container:update_child_containers()
```
### create_draggable_corners
---
```lua
container:create_draggable_corners()
```
- **Returns:**
- `Container` *(druid.container)*:
### clear_draggable_corners
---
```lua
container:clear_draggable_corners()
```
- **Returns:**
- `Container` *(druid.container)*:
### fit_into_node
---
```lua
container:fit_into_node(node)
```
Set node for layout node to fit inside it. Pass nil to reset
- **Parameters:**
- `node` *(string|node)*: The node_id or gui.get_node(node_id)
- **Returns:**
- `Layout` *(druid.container)*:
### set_min_size
---
```lua
container:set_min_size([min_size_x], [min_size_y])
```
- **Parameters:**
- `[min_size_x]` *(number|nil)*:
- `[min_size_y]` *(number|nil)*:
- **Returns:**
- `` *(druid.container)*:
## Fields
<a name="node"></a>
- **node** (_node_)
<a name="druid"></a>
- **druid** (_druid.instance_)
<a name="node_offset"></a>
- **node_offset** (_vector4_)
<a name="origin_size"></a>
- **origin_size** (_vector3_)
<a name="size"></a>
- **size** (_vector3_)
<a name="origin_position"></a>
- **origin_position** (_vector3_)
<a name="position"></a>
- **position** (_vector3_)
<a name="pivot_offset"></a>
- **pivot_offset** (_vector3_)
<a name="center_offset"></a>
- **center_offset** (_vector3_)
<a name="mode"></a>
- **mode** (_string_)
<a name="fit_size"></a>
- **fit_size** (_vector3_)
<a name="min_size_x"></a>
- **min_size_x** (_number_)
<a name="min_size_y"></a>
- **min_size_y** (_number_)
<a name="on_size_changed"></a>
- **on_size_changed** (_event_): fun(self: druid.container, size: vector3)
<a name="node_fill_x"></a>
- **node_fill_x** (_nil_)
<a name="node_fill_y"></a>
- **node_fill_y** (_nil_)
<a name="x_koef"></a>
- **x_koef** (_number_)
<a name="y_koef"></a>
- **y_koef** (_number_)
<a name="x_anchor"></a>
- **x_anchor** (_unknown_)
<a name="y_anchor"></a>
- **y_anchor** (_unknown_)
<a name="style"></a>
- **style** (_table_)

View File

@@ -0,0 +1,222 @@
# druid.data_list API
> at /druid/extended/data_list.lua
## Functions
- [init](#init)
- [on_remove](#on_remove)
- [set_use_cache](#set_use_cache)
- [set_data](#set_data)
- [get_data](#get_data)
- [add](#add)
- [remove](#remove)
- [remove_by_data](#remove_by_data)
- [clear](#clear)
- [get_index](#get_index)
- [get_created_nodes](#get_created_nodes)
- [get_created_components](#get_created_components)
- [scroll_to_index](#scroll_to_index)
## Fields
- [scroll](#scroll)
- [grid](#grid)
- [on_scroll_progress_change](#on_scroll_progress_change)
- [on_element_add](#on_element_add)
- [on_element_remove](#on_element_remove)
- [top_index](#top_index)
- [last_index](#last_index)
- [scroll_progress](#scroll_progress)
### init
---
```lua
data_list:init(scroll, grid, create_function)
```
- **Parameters:**
- `scroll` *(druid.scroll)*: The Scroll instance for Data List component
- `grid` *(druid.grid)*: The StaticGrid} or @{DynamicGrid instance for Data List component
- `create_function` *(function)*: The create function callback(self, data, index, data_list). Function should return (node, [component])
### on_remove
---
```lua
data_list:on_remove()
```
Druid System on_remove function
### set_use_cache
---
```lua
data_list:set_use_cache(is_use_cache)
```
Set refresh function for DataList component
- **Parameters:**
- `is_use_cache` *(boolean)*: Use cache version of DataList. Requires make setup of components in on_element_add callback and clean in on_element_remove
- **Returns:**
- `Current` *(druid.data_list)*: DataList instance
### set_data
---
```lua
data_list:set_data(data)
```
Set new data set for DataList component
- **Parameters:**
- `data` *(table)*: The new data array
- **Returns:**
- `Current` *(druid.data_list)*: DataList instance
### get_data
---
```lua
data_list:get_data()
```
Return current data from DataList component
- **Returns:**
- `The` *(table)*: current data array
### add
---
```lua
data_list:add(data, [index], [shift_policy])
```
Add element to DataList. Currenly untested
- **Parameters:**
- `data` *(table)*:
- `[index]` *(number|nil)*:
- `[shift_policy]` *(number|nil)*: The constant from const.SHIFT.*
### remove
---
```lua
data_list:remove([index], [shift_policy])
```
Remove element from DataList. Currenly untested
- **Parameters:**
- `[index]` *(number|nil)*:
- `[shift_policy]` *(number|nil)*: The constant from const.SHIFT.*
### remove_by_data
---
```lua
data_list:remove_by_data(data, [shift_policy])
```
Remove element from DataList by data value. Currenly untested
- **Parameters:**
- `data` *(table)*:
- `[shift_policy]` *(number|nil)*: The constant from const.SHIFT.*
### clear
---
```lua
data_list:clear()
```
Clear the DataList and refresh visuals
### get_index
---
```lua
data_list:get_index(data)
```
Return index for data value
- **Parameters:**
- `data` *(table)*:
- **Returns:**
- `` *(unknown|nil)*:
### get_created_nodes
---
```lua
data_list:get_created_nodes()
```
Return all currenly created nodes in DataList
- **Returns:**
- `List` *(node[])*: of created nodes
### get_created_components
---
```lua
data_list:get_created_components()
```
Return all currenly created components in DataList
- **Returns:**
- `List` *(druid.component[])*: of created nodes
### scroll_to_index
---
```lua
data_list:scroll_to_index(index)
```
Instant scroll to element with passed index
- **Parameters:**
- `index` *(number)*:
## Fields
<a name="scroll"></a>
- **scroll** (_druid.scroll_)
<a name="grid"></a>
- **grid** (_druid.grid_)
<a name="on_scroll_progress_change"></a>
- **on_scroll_progress_change** (_event_)
<a name="on_element_add"></a>
- **on_element_add** (_event_)
<a name="on_element_remove"></a>
- **on_element_remove** (_event_)
<a name="top_index"></a>
- **top_index** (_number_)
<a name="last_index"></a>
- **last_index** (_number_)
<a name="scroll_progress"></a>
- **scroll_progress** (_number_)

View File

@@ -0,0 +1,123 @@
# druid.hotkey API
> at /druid/extended/hotkey.lua
## Functions
- [init](#init)
- [on_style_change](#on_style_change)
- [add_hotkey](#add_hotkey)
- [is_processing](#is_processing)
- [on_focus_gained](#on_focus_gained)
- [on_input](#on_input)
- [set_repeat](#set_repeat)
## Fields
- [on_hotkey_pressed](#on_hotkey_pressed)
- [on_hotkey_released](#on_hotkey_released)
- [style](#style)
- [druid](#druid)
### init
---
```lua
hotkey:init(keys, callback, [callback_argument])
```
The Hotkey constructor
- **Parameters:**
- `keys` *(string|string[])*: The keys to be pressed for trigger callback. Should contains one key and any modificator keys
- `callback` *(function)*: The callback function
- `[callback_argument]` *(any)*: The argument to pass into the callback function
### on_style_change
---
```lua
hotkey:on_style_change(style)
```
- **Parameters:**
- `style` *(druid.hotkey.style)*:
### add_hotkey
---
```lua
hotkey:add_hotkey(keys, [callback_argument])
```
Add hotkey for component callback
- **Parameters:**
- `keys` *(string|hash|hash[]|string[])*: that have to be pressed before key pressed to activate
- `[callback_argument]` *(any)*: The argument to pass into the callback function
- **Returns:**
- `Current` *(druid.hotkey)*: instance
### is_processing
---
```lua
hotkey:is_processing()
```
- **Returns:**
- `` *(boolean)*:
### on_focus_gained
---
```lua
hotkey:on_focus_gained()
```
### on_input
---
```lua
hotkey:on_input([action_id], action)
```
- **Parameters:**
- `[action_id]` *(hash|nil)*:
- `action` *(action)*:
- **Returns:**
- `` *(boolean)*:
### set_repeat
---
```lua
hotkey:set_repeat(is_enabled_repeated)
```
If true, the callback will be triggered on action.repeated
- **Parameters:**
- `is_enabled_repeated` *(bool)*: The flag value
- **Returns:**
- `` *(druid.hotkey)*:
## Fields
<a name="on_hotkey_pressed"></a>
- **on_hotkey_pressed** (_event_)
<a name="on_hotkey_released"></a>
- **on_hotkey_released** (_event_)
<a name="style"></a>
- **style** (_druid.hotkey.style_)
<a name="druid"></a>
- **druid** (_druid.instance_)

View File

@@ -0,0 +1,335 @@
# druid.input API
> at /druid/extended/input.lua
## Functions
- [init](#init)
- [on_style_change](#on_style_change)
- [on_input](#on_input)
- [on_focus_lost](#on_focus_lost)
- [on_input_interrupt](#on_input_interrupt)
- [get_text_selected](#get_text_selected)
- [get_text_selected_replaced](#get_text_selected_replaced)
- [set_text](#set_text)
- [select](#select)
- [unselect](#unselect)
- [get_text](#get_text)
- [set_max_length](#set_max_length)
- [set_allowed_characters](#set_allowed_characters)
- [reset_changes](#reset_changes)
- [select_cursor](#select_cursor)
- [move_selection](#move_selection)
## Fields
- [on_input_select](#on_input_select)
- [on_input_unselect](#on_input_unselect)
- [on_input_text](#on_input_text)
- [on_input_empty](#on_input_empty)
- [on_input_full](#on_input_full)
- [on_input_wrong](#on_input_wrong)
- [on_select_cursor_change](#on_select_cursor_change)
- [style](#style)
- [text](#text)
- [ALLOWED_ACTIONS](#ALLOWED_ACTIONS)
- [druid](#druid)
- [is_selected](#is_selected)
- [value](#value)
- [previous_value](#previous_value)
- [current_value](#current_value)
- [marked_value](#marked_value)
- [is_empty](#is_empty)
- [text_width](#text_width)
- [market_text_width](#market_text_width)
- [total_width](#total_width)
- [cursor_index](#cursor_index)
- [start_index](#start_index)
- [end_index](#end_index)
- [max_length](#max_length)
- [allowed_characters](#allowed_characters)
- [keyboard_type](#keyboard_type)
- [button](#button)
- [marked_text_width](#marked_text_width)
### init
---
```lua
input:init(click_node, text_node, [keyboard_type])
```
- **Parameters:**
- `click_node` *(node)*: Node to enabled input component
- `text_node` *(druid.text|node)*: Text node what will be changed on user input. You can pass text component instead of text node name Text
- `[keyboard_type]` *(number|nil)*: Gui keyboard type for input field
### on_style_change
---
```lua
input:on_style_change(style)
```
- **Parameters:**
- `style` *(druid.input.style)*:
### on_input
---
```lua
input:on_input([action_id], [action])
```
- **Parameters:**
- `[action_id]` *(any)*:
- `[action]` *(any)*:
- **Returns:**
- `` *(boolean)*:
### on_focus_lost
---
```lua
input:on_focus_lost()
```
### on_input_interrupt
---
```lua
input:on_input_interrupt()
```
### get_text_selected
---
```lua
input:get_text_selected()
```
- **Returns:**
- `` *(string|unknown)*:
### get_text_selected_replaced
---
```lua
input:get_text_selected_replaced(text)
```
Replace selected text with new text
- **Parameters:**
- `text` *(string)*: The text to replace selected text
- **Returns:**
- `New` *(string)*: input text
### set_text
---
```lua
input:set_text(input_text)
```
Set text for input field
- **Parameters:**
- `input_text` *(string)*: The string to apply for input field
### select
---
```lua
input:select()
```
Select input field. It will show the keyboard and trigger on_select events
### unselect
---
```lua
input:unselect()
```
Remove selection from input. It will hide the keyboard and trigger on_unselect events
### get_text
---
```lua
input:get_text()
```
Return current input field text
- **Returns:**
- `The` *(string)*: current input field text
### set_max_length
---
```lua
input:set_max_length(max_length)
```
Set maximum length for input field.
Pass nil to make input field unliminted (by default)
- **Parameters:**
- `max_length` *(number)*: Maximum length for input text field
- **Returns:**
- `Current` *(druid.input)*: input instance
### set_allowed_characters
---
```lua
input:set_allowed_characters(characters)
```
Set allowed charaters for input field.
See: https://defold.com/ref/stable/string/
ex: [%a%d] for alpha and numeric
- **Parameters:**
- `characters` *(string)*: Regulax exp. for validate user input
- **Returns:**
- `Current` *(druid.input)*: input instance
### reset_changes
---
```lua
input:reset_changes()
```
Reset current input selection and return previous value
- **Returns:**
- `Current` *(druid.input)*: input instance
### select_cursor
---
```lua
input:select_cursor([cursor_index], [start_index], [end_index])
```
Set cursor position in input field
- **Parameters:**
- `[cursor_index]` *(number|nil)*: Cursor index for cursor position, if nil - will be set to the end of the text
- `[start_index]` *(number|nil)*: Start index for cursor position, if nil - will be set to the end of the text
- `[end_index]` *(number|nil)*: End index for cursor position, if nil - will be set to the start_index
- **Returns:**
- `Current` *(druid.input)*: input instance
### move_selection
---
```lua
input:move_selection(delta, is_add_to_selection, is_move_to_end)
```
Change cursor position by delta
- **Parameters:**
- `delta` *(number)*: side for cursor position, -1 for left, 1 for right
- `is_add_to_selection` *(boolean)*: (Shift key)
- `is_move_to_end` *(boolean)*: (Ctrl key)
## Fields
<a name="on_input_select"></a>
- **on_input_select** (_event_)
<a name="on_input_unselect"></a>
- **on_input_unselect** (_event_)
<a name="on_input_text"></a>
- **on_input_text** (_event_)
<a name="on_input_empty"></a>
- **on_input_empty** (_event_)
<a name="on_input_full"></a>
- **on_input_full** (_event_)
<a name="on_input_wrong"></a>
- **on_input_wrong** (_event_)
<a name="on_select_cursor_change"></a>
- **on_select_cursor_change** (_event_)
<a name="style"></a>
- **style** (_table_)
<a name="text"></a>
- **text** (_druid.text_)
<a name="ALLOWED_ACTIONS"></a>
- **ALLOWED_ACTIONS** (_table_)
<a name="druid"></a>
- **druid** (_druid.instance_)
<a name="is_selected"></a>
- **is_selected** (_boolean_)
<a name="value"></a>
- **value** (_unknown_)
<a name="previous_value"></a>
- **previous_value** (_unknown_)
<a name="current_value"></a>
- **current_value** (_unknown_)
<a name="marked_value"></a>
- **marked_value** (_string_)
<a name="is_empty"></a>
- **is_empty** (_boolean_)
<a name="text_width"></a>
- **text_width** (_integer_)
<a name="market_text_width"></a>
- **market_text_width** (_integer_)
<a name="total_width"></a>
- **total_width** (_integer_)
<a name="cursor_index"></a>
- **cursor_index** (_integer_)
<a name="start_index"></a>
- **start_index** (_number_)
<a name="end_index"></a>
- **end_index** (_number_)
<a name="max_length"></a>
- **max_length** (_nil_)
<a name="allowed_characters"></a>
- **allowed_characters** (_nil_)
<a name="keyboard_type"></a>
- **keyboard_type** (_number_)
<a name="button"></a>
- **button** (_druid.button_): Druid component to make clickable node with various interaction callbacks
<a name="marked_text_width"></a>
- **marked_text_width** (_number_)

View File

@@ -0,0 +1,119 @@
# druid.lang_text API
> at /druid/extended/lang_text.lua
## Functions
- [init](#init)
- [on_language_change](#on_language_change)
- [set_to](#set_to)
- [set_text](#set_text)
- [translate](#translate)
- [format](#format)
## Fields
- [text](#text)
- [node](#node)
- [on_change](#on_change)
- [druid](#druid)
### init
---
```lua
lang_text:init(node, [locale_id], [adjust_type])
```
- **Parameters:**
- `node` *(string|node)*: The node_id or gui.get_node(node_id)
- `[locale_id]` *(string|nil)*: Default locale id or text from node as default
- `[adjust_type]` *(string|nil)*: Adjust type for text. By default is DOWNSCALE. Look const.TEXT_ADJUST for reference
- **Returns:**
- `` *(druid.lang_text)*:
### on_language_change
---
```lua
lang_text:on_language_change()
```
### set_to
---
```lua
lang_text:set_to(text)
```
Setup raw text to lang_text component
- **Parameters:**
- `text` *(string)*: Text for text node
- **Returns:**
- `Current` *(druid.lang_text)*: instance
### set_text
---
```lua
lang_text:set_text(text)
```
Setup raw text to lang_text component
- **Parameters:**
- `text` *(string)*: Text for text node
- **Returns:**
- `Current` *(druid.lang_text)*: instance
### translate
---
```lua
lang_text:translate(locale_id, ...)
```
Translate the text by locale_id
- **Parameters:**
- `locale_id` *(string)*: Locale id
- `...` *(...)*: vararg
- **Returns:**
- `Current` *(druid.lang_text)*: instance
### format
---
```lua
lang_text:format(...)
```
Format string with new text params on localized text
- **Parameters:**
- `...` *(...)*: vararg
- **Returns:**
- `Current` *(druid.lang_text)*: instance
## Fields
<a name="text"></a>
- **text** (_druid.text_)
<a name="node"></a>
- **node** (_node_)
<a name="on_change"></a>
- **on_change** (_event_)
<a name="druid"></a>
- **druid** (_druid.instance_)

View File

@@ -0,0 +1,319 @@
# druid.layout API
> at /druid/extended/layout.lua
## Functions
- [init](#init)
- [update](#update)
- [get_entities](#get_entities)
- [set_node_index](#set_node_index)
- [set_margin](#set_margin)
- [set_padding](#set_padding)
- [set_dirty](#set_dirty)
- [set_justify](#set_justify)
- [set_type](#set_type)
- [set_hug_content](#set_hug_content)
- [add](#add)
- [remove](#remove)
- [get_size](#get_size)
- [get_content_size](#get_content_size)
- [refresh_layout](#refresh_layout)
- [clear_layout](#clear_layout)
- [get_node_size](#get_node_size)
- [calculate_rows_data](#calculate_rows_data)
- [set_node_position](#set_node_position)
## Fields
- [node](#node)
- [rows_data](#rows_data)
- [is_dirty](#is_dirty)
- [entities](#entities)
- [margin](#margin)
- [padding](#padding)
- [type](#type)
- [is_resize_width](#is_resize_width)
- [is_resize_height](#is_resize_height)
- [is_justify](#is_justify)
- [on_size_changed](#on_size_changed)
- [size](#size)
### init
---
```lua
layout:init(node_or_node_id, layout_type)
```
```lua
layout_type:
| "horizontal"
| "vertical"
| "horizontal_wrap"
```
- **Parameters:**
- `node_or_node_id` *(string|node)*:
- `layout_type` *(druid.layout.mode)*:
### update
---
```lua
layout:update()
```
### get_entities
---
```lua
layout:get_entities()
```
- **Returns:**
- `` *(node[])*:
### set_node_index
---
```lua
layout:set_node_index([node], [index])
```
- **Parameters:**
- `[node]` *(any)*:
- `[index]` *(any)*:
### set_margin
---
```lua
layout:set_margin([margin_x], [margin_y])
```
- **Parameters:**
- `[margin_x]` *(number|nil)*:
- `[margin_y]` *(number|nil)*:
- **Returns:**
- `` *(druid.layout)*:
### set_padding
---
```lua
layout:set_padding([padding_x], [padding_y], [padding_z], [padding_w])
```
- **Parameters:**
- `[padding_x]` *(number|nil)*:
- `[padding_y]` *(number|nil)*:
- `[padding_z]` *(number|nil)*:
- `[padding_w]` *(number|nil)*:
- **Returns:**
- `` *(druid.layout)*:
### set_dirty
---
```lua
layout:set_dirty()
```
- **Returns:**
- `` *(druid.layout)*:
### set_justify
---
```lua
layout:set_justify(is_justify)
```
- **Parameters:**
- `is_justify` *(boolean)*:
- **Returns:**
- `` *(druid.layout)*:
### set_type
---
```lua
layout:set_type(type)
```
- **Parameters:**
- `type` *(string)*: The layout type: "horizontal", "vertical", "horizontal_wrap"
- **Returns:**
- `` *(druid.layout)*:
### set_hug_content
---
```lua
layout:set_hug_content(is_hug_width, is_hug_height)
```
- **Parameters:**
- `is_hug_width` *(boolean)*:
- `is_hug_height` *(boolean)*:
- **Returns:**
- `` *(druid.layout)*:
### add
---
```lua
layout:add(node_or_node_id)
```
Add node to layout
- **Parameters:**
- `node_or_node_id` *(string|node)*: node_or_node_id
- **Returns:**
- `` *(druid.layout)*:
### remove
---
```lua
layout:remove(node_or_node_id)
```
Remove node from layout
- **Parameters:**
- `node_or_node_id` *(string|node)*: node_or_node_id
- **Returns:**
- `self` *(druid.layout)*: for chaining
### get_size
---
```lua
layout:get_size()
```
- **Returns:**
- `` *(vector3)*:
### get_content_size
---
```lua
layout:get_content_size()
```
- **Returns:**
- `` *(number)*:
- `` *(number)*:
### refresh_layout
---
```lua
layout:refresh_layout()
```
- **Returns:**
- `` *(druid.layout)*:
### clear_layout
---
```lua
layout:clear_layout()
```
- **Returns:**
- `` *(druid.layout)*:
### get_node_size
---
```lua
layout:get_node_size(node)
```
- **Parameters:**
- `node` *(node)*:
- **Returns:**
- `` *(number)*:
- `` *(number)*:
### calculate_rows_data
---
```lua
layout:calculate_rows_data()
```
Calculate rows data for layout. Contains total width, height and rows info (width, height, count of elements in row)
- **Returns:**
- `` *(druid.layout.rows_data)*:
### set_node_position
---
```lua
layout:set_node_position(node, x, y)
```
- **Parameters:**
- `node` *(node)*:
- `x` *(number)*:
- `y` *(number)*:
- **Returns:**
- `` *(node)*:
## Fields
<a name="node"></a>
- **node** (_node_)
<a name="rows_data"></a>
- **rows_data** (_druid.layout.rows_data_): Last calculated rows data
<a name="is_dirty"></a>
- **is_dirty** (_boolean_)
<a name="entities"></a>
- **entities** (_node[]_)
<a name="margin"></a>
- **margin** (_{ x: number, y: number }_)
<a name="padding"></a>
- **padding** (_vector4_)
<a name="type"></a>
- **type** (_string_)
<a name="is_resize_width"></a>
- **is_resize_width** (_boolean_)
<a name="is_resize_height"></a>
- **is_resize_height** (_boolean_)
<a name="is_justify"></a>
- **is_justify** (_boolean_)
<a name="on_size_changed"></a>
- **on_size_changed** (_event.on_size_changed_)
<a name="size"></a>
- **size** (_unknown_)

View File

@@ -0,0 +1,215 @@
# druid.progress API
> at /druid/extended/progress.lua
## Functions
- [init](#init)
- [on_style_change](#on_style_change)
- [on_layout_change](#on_layout_change)
- [on_remove](#on_remove)
- [update](#update)
- [fill](#fill)
- [empty](#empty)
- [set_to](#set_to)
- [get](#get)
- [set_steps](#set_steps)
- [to](#to)
- [set_max_size](#set_max_size)
## Fields
- [node](#node)
- [on_change](#on_change)
- [style](#style)
- [key](#key)
- [prop](#prop)
- [scale](#scale)
- [size](#size)
- [max_size](#max_size)
- [slice](#slice)
- [last_value](#last_value)
- [slice_size](#slice_size)
- [target](#target)
- [steps](#steps)
- [step_callback](#step_callback)
- [target_callback](#target_callback)
### init
---
```lua
progress:init(node, key, [init_value])
```
- **Parameters:**
- `node` *(string|node)*: Node name or GUI Node itself.
- `key` *(string)*: Progress bar direction: const.SIDE.X or const.SIDE.Y
- `[init_value]` *(number|nil)*: Initial value of progress bar. Default: 1
### on_style_change
---
```lua
progress:on_style_change(style)
```
- **Parameters:**
- `style` *(druid.progress.style)*:
### on_layout_change
---
```lua
progress:on_layout_change()
```
### on_remove
---
```lua
progress:on_remove()
```
### update
---
```lua
progress:update(dt)
```
- **Parameters:**
- `dt` *(number)*: Delta time
### fill
---
```lua
progress:fill()
```
Fill a progress bar and stop progress animation
### empty
---
```lua
progress:empty()
```
Empty a progress bar
### set_to
---
```lua
progress:set_to(to)
```
Instant fill progress bar to value
- **Parameters:**
- `to` *(number)*: Progress bar value, from 0 to 1
### get
---
```lua
progress:get()
```
Return current progress bar value
- **Returns:**
- `` *(number)*:
### set_steps
---
```lua
progress:set_steps(steps, callback)
```
Set points on progress bar to fire the callback
- **Parameters:**
- `steps` *(number[])*: Array of progress bar values
- `callback` *(function)*: Callback on intersect step value
### to
---
```lua
progress:to(to, [callback])
```
Start animation of a progress bar
- **Parameters:**
- `to` *(number)*: value between 0..1
- `[callback]` *(function|nil)*: Callback on animation ends
### set_max_size
---
```lua
progress:set_max_size(max_size)
```
Set progress bar max node size
- **Parameters:**
- `max_size` *(vector3)*: The new node maximum (full) size
- **Returns:**
- `Progress` *(druid.progress)*:
## Fields
<a name="node"></a>
- **node** (_node_)
<a name="on_change"></a>
- **on_change** (_event_)
<a name="style"></a>
- **style** (_druid.progress.style_)
<a name="key"></a>
- **key** (_string_)
<a name="prop"></a>
- **prop** (_hash_)
<a name="scale"></a>
- **scale** (_unknown_)
<a name="size"></a>
- **size** (_unknown_)
<a name="max_size"></a>
- **max_size** (_unknown_)
<a name="slice"></a>
- **slice** (_unknown_)
<a name="last_value"></a>
- **last_value** (_number_)
<a name="slice_size"></a>
- **slice_size** (_unknown_)
<a name="target"></a>
- **target** (_nil_)
<a name="steps"></a>
- **steps** (_number[]_)
<a name="step_callback"></a>
- **step_callback** (_function_)
<a name="target_callback"></a>
- **target_callback** (_function|nil_)

View File

@@ -0,0 +1,215 @@
# druid.progress API
> at /druid/extended/progress.lua
## Functions
- [init](#init)
- [on_style_change](#on_style_change)
- [on_layout_change](#on_layout_change)
- [on_remove](#on_remove)
- [update](#update)
- [fill](#fill)
- [empty](#empty)
- [set_to](#set_to)
- [get](#get)
- [set_steps](#set_steps)
- [to](#to)
- [set_max_size](#set_max_size)
## Fields
- [node](#node)
- [on_change](#on_change)
- [style](#style)
- [key](#key)
- [prop](#prop)
- [scale](#scale)
- [size](#size)
- [max_size](#max_size)
- [slice](#slice)
- [last_value](#last_value)
- [slice_size](#slice_size)
- [target](#target)
- [steps](#steps)
- [step_callback](#step_callback)
- [target_callback](#target_callback)
### init
---
```lua
progress:init(node, key, [init_value])
```
- **Parameters:**
- `node` *(string|node)*: Node name or GUI Node itself.
- `key` *(string)*: Progress bar direction: const.SIDE.X or const.SIDE.Y
- `[init_value]` *(number|nil)*: Initial value of progress bar. Default: 1
### on_style_change
---
```lua
progress:on_style_change(style)
```
- **Parameters:**
- `style` *(druid.progress.style)*:
### on_layout_change
---
```lua
progress:on_layout_change()
```
### on_remove
---
```lua
progress:on_remove()
```
### update
---
```lua
progress:update(dt)
```
- **Parameters:**
- `dt` *(number)*: Delta time
### fill
---
```lua
progress:fill()
```
Fill a progress bar and stop progress animation
### empty
---
```lua
progress:empty()
```
Empty a progress bar
### set_to
---
```lua
progress:set_to(to)
```
Instant fill progress bar to value
- **Parameters:**
- `to` *(number)*: Progress bar value, from 0 to 1
### get
---
```lua
progress:get()
```
Return current progress bar value
- **Returns:**
- `` *(number)*:
### set_steps
---
```lua
progress:set_steps(steps, callback)
```
Set points on progress bar to fire the callback
- **Parameters:**
- `steps` *(number[])*: Array of progress bar values
- `callback` *(function)*: Callback on intersect step value
### to
---
```lua
progress:to(to, [callback])
```
Start animation of a progress bar
- **Parameters:**
- `to` *(number)*: value between 0..1
- `[callback]` *(function|nil)*: Callback on animation ends
### set_max_size
---
```lua
progress:set_max_size(max_size)
```
Set progress bar max node size
- **Parameters:**
- `max_size` *(vector3)*: The new node maximum (full) size
- **Returns:**
- `Progress` *(druid.progress)*:
## Fields
<a name="node"></a>
- **node** (_node_)
<a name="on_change"></a>
- **on_change** (_event_)
<a name="style"></a>
- **style** (_druid.progress.style_)
<a name="key"></a>
- **key** (_string_)
<a name="prop"></a>
- **prop** (_hash_)
<a name="scale"></a>
- **scale** (_unknown_)
<a name="size"></a>
- **size** (_unknown_)
<a name="max_size"></a>
- **max_size** (_unknown_)
<a name="slice"></a>
- **slice** (_unknown_)
<a name="last_value"></a>
- **last_value** (_number_)
<a name="slice_size"></a>
- **slice_size** (_unknown_)
<a name="target"></a>
- **target** (_nil_)
<a name="steps"></a>
- **steps** (_number[]_)
<a name="step_callback"></a>
- **step_callback** (_function_)
<a name="target_callback"></a>
- **target_callback** (_function|nil_)

View File

@@ -0,0 +1,98 @@
# druid.swipe API
> at /druid/extended/swipe.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_click_zone](#set_click_zone)
## Fields
- [node](#node)
- [on_swipe](#on_swipe)
- [style](#style)
- [click_zone](#click_zone)
### init
---
```lua
swipe:init(node_or_node_id, on_swipe_callback)
```
- **Parameters:**
- `node_or_node_id` *(string|node)*:
- `on_swipe_callback` *(function)*:
### on_late_init
---
```lua
swipe:on_late_init()
```
### on_style_change
---
```lua
swipe:on_style_change(style)
```
- **Parameters:**
- `style` *(druid.swipe.style)*:
### on_input
---
```lua
swipe:on_input(action_id, action)
```
- **Parameters:**
- `action_id` *(hash)*:
- `action` *(action)*:
- **Returns:**
- `` *(boolean)*:
### on_input_interrupt
---
```lua
swipe:on_input_interrupt()
```
### set_click_zone
---
```lua
swipe:set_click_zone([zone])
```
Strict swipe click area. Useful for
restrict events outside stencil node
- **Parameters:**
- `[zone]` *(string|node|nil)*: Gui node
## Fields
<a name="node"></a>
- **node** (_node_)
<a name="on_swipe"></a>
- **on_swipe** (_event_): function(side, dist, dt), side - "left", "right", "up", "down"
<a name="style"></a>
- **style** (_table_)
<a name="click_zone"></a>
- **click_zone** (_node_)

View File

@@ -0,0 +1,133 @@
# druid.timer API
> at /druid/extended/timer.lua
## Functions
- [init](#init)
- [update](#update)
- [on_layout_change](#on_layout_change)
- [set_to](#set_to)
- [set_state](#set_state)
- [set_interval](#set_interval)
## Fields
- [on_tick](#on_tick)
- [on_set_enabled](#on_set_enabled)
- [on_timer_end](#on_timer_end)
- [node](#node)
- [from](#from)
- [target](#target)
- [value](#value)
- [is_on](#is_on)
- [temp](#temp)
- [last_value](#last_value)
### init
---
```lua
timer:init(node, [seconds_from], [seconds_to], [callback])
```
- **Parameters:**
- `node` *(node)*: Gui text node
- `[seconds_from]` *(number|nil)*: Start timer value in seconds
- `[seconds_to]` *(number|nil)*: End timer value in seconds
- `[callback]` *(function|nil)*: Function on timer end
- **Returns:**
- `` *(druid.timer)*:
### update
---
```lua
timer:update([dt])
```
- **Parameters:**
- `[dt]` *(any)*:
### on_layout_change
---
```lua
timer:on_layout_change()
```
### set_to
---
```lua
timer:set_to(set_to)
```
- **Parameters:**
- `set_to` *(number)*: Value in seconds
- **Returns:**
- `self` *(druid.timer)*:
### set_state
---
```lua
timer:set_state([is_on])
```
- **Parameters:**
- `[is_on]` *(boolean|nil)*: Timer enable state
- **Returns:**
- `self` *(druid.timer)*:
### set_interval
---
```lua
timer:set_interval(from, to)
```
- **Parameters:**
- `from` *(number)*: Start time in seconds
- `to` *(number)*: Target time in seconds
- **Returns:**
- `self` *(druid.timer)*:
## Fields
<a name="on_tick"></a>
- **on_tick** (_event_)
<a name="on_set_enabled"></a>
- **on_set_enabled** (_event_)
<a name="on_timer_end"></a>
- **on_timer_end** (_event_)
<a name="node"></a>
- **node** (_node_)
<a name="from"></a>
- **from** (_number_)
<a name="target"></a>
- **target** (_number_)
<a name="value"></a>
- **value** (_number_)
<a name="is_on"></a>
- **is_on** (_boolean_)
<a name="temp"></a>
- **temp** (_unknown_)
<a name="last_value"></a>
- **last_value** (_number_)

View File

View File

@@ -0,0 +1,235 @@
# widget.mini_graph API
> at /druid/widget/mini_graph/mini_graph.lua
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)
## Table of Contents
## Functions
- [init](#init)
- [on_remove](#on_remove)
- [clear](#clear)
- [set_samples](#set_samples)
- [get_samples](#get_samples)
- [set_line_value](#set_line_value)
- [get_line_value](#get_line_value)
- [push_line_value](#push_line_value)
- [set_max_value](#set_max_value)
- [set_line_height](#set_line_height)
- [get_lowest_value](#get_lowest_value)
- [get_highest_value](#get_highest_value)
- [on_drag_widget](#on_drag_widget)
- [toggle_hide](#toggle_hide)
## Fields
- [root](#root)
- [text_header](#text_header)
- [icon_drag](#icon_drag)
- [content](#content)
- [layout](#layout)
- [prefab_line](#prefab_line)
- [color_zero](#color_zero)
- [color_one](#color_one)
- [is_hidden](#is_hidden)
- [max_value](#max_value)
- [lines](#lines)
- [values](#values)
- [container](#container)
- [default_size](#default_size)
- [samples](#samples)
### init
---
```lua
mini_graph:init()
```
### on_remove
---
```lua
mini_graph:on_remove()
```
### clear
---
```lua
mini_graph:clear()
```
### set_samples
---
```lua
mini_graph:set_samples([samples])
```
- **Parameters:**
- `[samples]` *(any)*:
### get_samples
---
```lua
mini_graph:get_samples()
```
- **Returns:**
- `` *(unknown)*:
### set_line_value
---
```lua
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)*:
- `value` *(number)*: The normalized value from 0 to 1
- **Example Usage:**
```lua
mini_graph:set_line_value(index, math.random())
```
### get_line_value
---
```lua
mini_graph:get_line_value([index])
```
- **Parameters:**
- `[index]` *(any)*:
- **Returns:**
- `` *(number)*:
### push_line_value
---
```lua
mini_graph:push_line_value([value])
```
- **Parameters:**
- `[value]` *(any)*:
### set_max_value
---
```lua
mini_graph:set_max_value([max_value])
```
- **Parameters:**
- `[max_value]` *(any)*:
### set_line_height
---
```lua
mini_graph:set_line_height([index])
```
- **Parameters:**
- `[index]` *(any)*:
### get_lowest_value
---
```lua
mini_graph:get_lowest_value()
```
### get_highest_value
---
```lua
mini_graph:get_highest_value()
```
### on_drag_widget
---
```lua
mini_graph:on_drag_widget([dx], [dy])
```
- **Parameters:**
- `[dx]` *(any)*:
- `[dy]` *(any)*:
### toggle_hide
---
```lua
mini_graph:toggle_hide()
```
- **Returns:**
- `` *(widget.mini_graph)*:
## Fields
<a name="root"></a>
- **root** (_node_)
<a name="text_header"></a>
- **text_header** (_druid.text_)
<a name="icon_drag"></a>
- **icon_drag** (_node_)
<a name="content"></a>
- **content** (_node_)
<a name="layout"></a>
- **layout** (_druid.layout_)
<a name="prefab_line"></a>
- **prefab_line** (_node_)
<a name="color_zero"></a>
- **color_zero** (_unknown_)
<a name="color_one"></a>
- **color_one** (_unknown_)
<a name="is_hidden"></a>
- **is_hidden** (_boolean_)
<a name="max_value"></a>
- **max_value** (_integer_): in this value line will be at max height
<a name="lines"></a>
- **lines** (_table_)
<a name="values"></a>
- **values** (_table_)
<a name="container"></a>
- **container** (_druid.container_)
<a name="default_size"></a>
- **default_size** (_vector3_)
<a name="samples"></a>
- **samples** (_any_)