Annotations update

This commit is contained in:
Insality
2023-10-17 21:09:45 +03:00
parent 7fc76ed8c0
commit 86b92f90a7
56 changed files with 540 additions and 574 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -45,7 +45,7 @@ local BackHandler = component.create("back_handler")
--- The @{BackHandler} constructor
-- @tparam BackHandler self @{BackHandler}
-- @tparam callback callback On back button
-- @tparam function callback @The callback(self, custom_args) to call on back event
-- @tparam[opt] any custom_args Button events custom arguments
-- @local
function BackHandler.init(self, callback, custom_args)

View File

@@ -30,7 +30,7 @@ local component = require("druid.component")
local Blocker = component.create("blocker")
--- @{Blocker} constructor
--- The @{Blocker} constructor
-- @tparam Blocker self @{Blocker}
-- @tparam node node Gui node
function Blocker.init(self, node)
@@ -71,7 +71,7 @@ end
--
-- Don't change node enabled state itself.
-- @tparam Blocker self @{Blocker}
-- @tparam bool state Enabled state
-- @tparam boolean state Enabled state
function Blocker.set_enabled(self, state)
self._is_enabled = state
end
@@ -79,7 +79,7 @@ end
--- Return blocker enabled state
-- @tparam Blocker self @{Blocker}
-- @treturn bool True, if blocker is enabled
-- @treturn boolean @True, if blocker is enabled
function Blocker.is_enabled(self)
return self._is_enabled
end

View File

@@ -27,7 +27,7 @@
-- print("Also the button component is passed in callback params")
-- end
--
-- local custom_args = "Any variable to pass inside callback"
-- local custom_args = "any variable to pass inside callback"
-- local button = self.druid:new_button("button_name", on_button_click, custom_args)
--
-- @module Button
@@ -114,7 +114,7 @@
-- @tfield DruidEvent on_pressed @{DruidEvent}
--- Button trigger node
-- @tfield Node node
-- @tfield node node
---The GUI node id from button node
-- @tfield hash node_id
@@ -257,15 +257,15 @@ end
--- Component style params.
-- You can override this component styles params in Druid styles table
-- or create your own style
-- @table style
-- @tfield[opt=0.4] number LONGTAP_TIME Minimum time to trigger on_hold_callback
-- @tfield[opt=0.8] number AUTOHOLD_TRIGGER Maximum hold time to trigger button release while holding
-- @tfield[opt=0.4] number DOUBLETAP_TIME Time between double taps
-- @tfield function on_click (self, node)
-- @tfield function on_click_disabled (self, node)
-- @tfield function on_hover (self, node, hover_state)
-- @tfield function on_mouse_hover (self, node, hover_state)
-- @tfield function on_set_enabled (self, node, enabled_state)
-- @tfield function on_click function(self, node)
-- @tfield function on_click_disabled function(self, node)
-- @tfield function on_hover function(self, node, hover_state)
-- @tfield function on_mouse_hover function(self, node, hover_state)
-- @tfield function on_set_enabled function(self, node, enabled_state)
-- @table style
function Button.on_style_change(self, style)
self.style = {}
self.style.LONGTAP_TIME = style.LONGTAP_TIME or 0.4
@@ -282,10 +282,10 @@ end
--- The @{Button} constructor
-- @tparam Button self @{Button}
-- @tparam string|Node node Node name or GUI Node itself
-- @tparam string|node node Node name or GUI Node itself
-- @tparam function callback On click button callback
-- @tparam[opt] any custom_args Button events custom arguments
-- @tparam[opt] string|Node anim_node Node to animate instead of trigger node.
-- @tparam[opt] string|node anim_node Node to animate instead of trigger node.
function Button.init(self, node, callback, custom_args, anim_node)
self.druid = self:get_druid()
self.node = self:get_node(node)
@@ -447,7 +447,7 @@ end
-- The style.on_set_enabled will be triggered.
-- Disabled button is not clickable.
-- @tparam Button self @{Button}
-- @tparam bool state Enabled state
-- @tparam boolean state Enabled state
-- @treturn Button Current button instance
-- @usage
-- button:set_enabled(false)
@@ -465,7 +465,7 @@ end
--
-- By default all Buttons is enabled on creating.
-- @tparam Button self @{Button}
-- @treturn bool True, if button is enabled now, False overwise
-- @treturn boolean @True, if button is enabled now, False overwise
-- @usage
-- local is_enabled = button:is_enabled()
function Button.is_enabled(self)

View File

@@ -26,16 +26,16 @@
-- @tfield DruidEvent on_drag_end @{DruidEvent}
--- Is component now touching
-- @tfield bool is_touch
-- @tfield boolean is_touch
--- Is component now dragging
-- @tfield bool is_drag
-- @tfield boolean is_drag
--- Is drag component process vertical dragging. Default - true
-- @tfield bool can_x
-- @tfield boolean can_x
--- Is drag component process horizontal. Default - true
-- @tfield bool can_y
-- @tfield boolean can_y
--- Current touch x position
-- @tfield number x
@@ -170,7 +170,7 @@ function Drag.on_style_change(self, style)
end
--- Drag component constructor
--- The @{Drag} constructor
-- @tparam Drag self @{Drag}
-- @tparam node node GUI node to detect dragging
-- @tparam function on_drag_callback Callback for on_drag_event(self, dx, dy)
@@ -313,7 +313,7 @@ end
--- Set Drag input enabled or disabled
-- @tparam Drag self @{Drag}
-- @tparam bool is_enabled
-- @tparam boolean is_enabled
function Drag.set_enabled(self, is_enabled)
self._is_enabled = is_enabled
end
@@ -321,7 +321,7 @@ end
--- Check if Drag component is enabled
-- @tparam Drag self @{Drag}
-- @treturn bool
-- @treturn boolean
function Drag.is_enabled(self)
return self._is_enabled
end

View File

@@ -21,7 +21,7 @@ local component = require("druid.component")
local Hover = component.create("hover")
--- Component init function
--- The @{Hover} constructor
-- @tparam Hover self @{Hover}
-- @tparam node node Gui node
-- @tparam function on_hover_callback Hover callback
@@ -89,7 +89,7 @@ end
--- Set hover state
-- @tparam Hover self @{Hover}
-- @tparam bool state The hover state
-- @tparam boolean state The hover state
function Hover.set_hover(self, state)
if self._is_hovered ~= state then
self._is_hovered = state
@@ -100,7 +100,7 @@ end
--- Return current hover state. True if touch action was on the node at current time
-- @tparam Hover self @{Hover}
-- @treturn bool The current hovered state
-- @treturn boolean The current hovered state
function Hover.is_hovered(self)
return self._is_hovered
end
@@ -108,7 +108,7 @@ end
--- Set mouse hover state
-- @tparam Hover self @{Hover}
-- @tparam bool state The mouse hover state
-- @tparam boolean state The mouse hover state
function Hover.set_mouse_hover(self, state)
if self._is_mouse_hovered ~= state then
self._is_mouse_hovered = state
@@ -119,7 +119,7 @@ end
--- Return current hover state. True if nil action_id (usually desktop mouse) was on the node at current time
-- @tparam Hover self @{Hover}
-- @treturn bool The current hovered state
-- @treturn boolean The current hovered state
function Hover.is_mouse_hovered(self)
return self._is_mouse_hovered
end
@@ -138,7 +138,7 @@ end
-- If hover is not enabled, it will not generate
-- any hover events
-- @tparam Hover self @{Hover}
-- @tparam bool state The hover enabled state
-- @tparam boolean state The hover enabled state
function Hover.set_enabled(self, state)
self._is_enabled = state
@@ -155,7 +155,7 @@ end
--- Return current hover enabled state
-- @tparam Hover self @{Hover}
-- @treturn bool The hover enabled state
-- @treturn boolean The hover enabled state
function Hover.is_enabled(self)
return self._is_enabled
end

View File

@@ -53,9 +53,6 @@
--- Scroll content node
-- @tfield node content_node
--- Flag, if scroll now moving by inertion
-- @tfield bool is_inert
--- Current inert speed
-- @tfield vector3 inertion
@@ -78,7 +75,7 @@
-- @tfield[opt] number selected
--- Flag, if scroll now animating by gui.animate
-- @tfield bool is_animate
-- @tfield boolean is_animate
---
@@ -131,10 +128,10 @@ end
-- @tfield[opt=0.35] number BACK_SPEED Scroll back returning lerp speed
-- @tfield[opt=0.2] number ANIM_SPEED Scroll gui.animation speed for scroll_to function
-- @tfield[opt=0] number EXTRA_STRETCH_SIZE extra size in pixels outside of scroll (stretch effect)
-- @tfield[opt=false] bool SMALL_CONTENT_SCROLL If true, content node with size less than view node size can be scrolled
-- @tfield[opt=0] bool WHEEL_SCROLL_SPEED The scroll speed via mouse wheel scroll or touchpad. Set to 0 to disable wheel scrolling
-- @tfield[opt=false] bool WHEEL_SCROLL_INVERTED If true, invert direction for touchpad and mouse wheel scroll
-- @tfield[opt=false] bool WHEEL_SCROLL_BY_INERTION If true, wheel will add inertion to scroll. Direct set position otherwise.
-- @tfield[opt=false] boolean SMALL_CONTENT_SCROLL If true, content node with size less than view node size can be scrolled
-- @tfield[opt=0] boolean WHEEL_SCROLL_SPEED The scroll speed via mouse wheel scroll or touchpad. Set to 0 to disable wheel scrolling
-- @tfield[opt=false] boolean WHEEL_SCROLL_INVERTED If true, invert direction for touchpad and mouse wheel scroll
-- @tfield[opt=false] boolean WHEEL_SCROLL_BY_INERTION If true, wheel will add inertion to scroll. Direct set position otherwise.
function Scroll.on_style_change(self, style)
self.style = {}
self.style.EXTRA_STRETCH_SIZE = style.EXTRA_STRETCH_SIZE or 0
@@ -158,7 +155,7 @@ function Scroll.on_style_change(self, style)
end
--- @{Scroll} constructor
--- The @{Scroll} constructor
-- @tparam Scroll self @{Scroll}
-- @tparam string|node view_node GUI view scroll node
-- @tparam string|node content_node GUI content scroll node
@@ -237,7 +234,7 @@ end
--- Start scroll to target point.
-- @tparam Scroll self @{Scroll}
-- @tparam vector3 point Target point
-- @tparam[opt] bool is_instant Instant scroll flag
-- @tparam[opt] boolean is_instant Instant scroll flag
-- @usage scroll:scroll_to(vmath.vector3(0, 50, 0))
-- @usage scroll:scroll_to(vmath.vector3(0), true)
function Scroll.scroll_to(self, point, is_instant)
@@ -271,7 +268,7 @@ end
--- Scroll to item in scroll by point index.
-- @tparam Scroll self @{Scroll}
-- @tparam number index Point index
-- @tparam[opt] bool skip_cb If true, skip the point callback
-- @tparam[opt] boolean skip_cb If true, skip the point callback
function Scroll.scroll_to_index(self, index, skip_cb)
if not self.points then
return
@@ -294,7 +291,7 @@ end
--- Start scroll to target scroll percent
-- @tparam Scroll self @{Scroll}
-- @tparam vector3 percent target percent
-- @tparam[opt] bool is_instant instant scroll flag
-- @tparam[opt] boolean is_instant instant scroll flag
-- @usage scroll:scroll_to_percent(vmath.vector3(0.5, 0, 0))
function Scroll.scroll_to_percent(self, percent, is_instant)
local border = self.available_pos
@@ -342,7 +339,7 @@ end
-- If disabled, scroll through points (if exist)
-- If no points, just simple drag without inertion
-- @tparam Scroll self @{Scroll}
-- @tparam bool state Inert scroll state
-- @tparam boolean state Inert scroll state
-- @treturn druid.scroll Current scroll instance
function Scroll.set_inert(self, state)
self._is_inert = state
@@ -353,7 +350,7 @@ end
--- Return if scroll have inertion.
-- @tparam Scroll self @{Scroll}
-- @treturn bool If scroll have inertion
-- @treturn boolean @If scroll have inertion
function Scroll.is_inert(self)
return self._is_inert
end
@@ -400,7 +397,7 @@ end
--- Lock or unlock horizontal scroll
-- @tparam Scroll self @{Scroll}
-- @tparam bool state True, if horizontal scroll is enabled
-- @tparam boolean state True, if horizontal scroll is enabled
-- @treturn druid.scroll Current scroll instance
function Scroll.set_horizontal_scroll(self, state)
self._is_horizontal_scroll = state
@@ -411,7 +408,7 @@ end
--- Lock or unlock vertical scroll
-- @tparam Scroll self @{Scroll}
-- @tparam bool state True, if vertical scroll is enabled
-- @tparam boolean state True, if vertical scroll is enabled
-- @treturn druid.scroll Current scroll instance
function Scroll.set_vertical_scroll(self, state)
self._is_vertical_scroll = state

View File

@@ -102,8 +102,8 @@ end
-- You can override this component styles params in druid styles table
-- or create your own style
-- @table style
-- @tfield[opt=false] bool IS_DYNAMIC_NODE_POSES If true, always center grid content as grid pivot sets
-- @tfield[opt=false] bool IS_ALIGN_LAST_ROW If true, always align last row of the grid as grid pivot sets
-- @tfield[opt=false] boolean IS_DYNAMIC_NODE_POSES If true, always center grid content as grid pivot sets
-- @tfield[opt=false] boolean IS_ALIGN_LAST_ROW If true, always align last row of the grid as grid pivot sets
function StaticGrid.on_style_change(self, style)
self.style = {}
self.style.IS_DYNAMIC_NODE_POSES = style.IS_DYNAMIC_NODE_POSES or false
@@ -113,7 +113,7 @@ end
--- The @{StaticGrid} constructor
-- @tparam StaticGrid self @{StaticGrid}
-- @tparam string|Node parent The GUI Node container, where grid's items will be placed
-- @tparam string|node parent The GUI Node container, where grid's items will be placed
-- @tparam node element Element prefab. Need to get it size
-- @tparam[opt=1] number in_row How many nodes in row can be placed
function StaticGrid.init(self, parent, element, in_row)
@@ -151,7 +151,7 @@ local _temp_pos = vmath.vector3(0)
--- Return pos for grid node index
-- @tparam StaticGrid self @{StaticGrid}
-- @tparam number index The grid element index
-- @treturn vector3 Node position
-- @treturn vector3 @Node position
function StaticGrid.get_pos(self, index)
local row = math.ceil(index / self.in_row) - 1
local col = (index - row * self.in_row) - 1
@@ -241,7 +241,7 @@ end
-- @tparam number index The grid node index to remove
-- @tparam[opt=SHIFT.RIGHT] number shift_policy How shift nodes, if required. See const.SHIFT
-- @tparam[opt=false] boolean is_instant If true, update node positions instantly
-- @treturn Node The deleted gui node from grid
-- @treturn node The deleted gui node from grid
function StaticGrid.remove(self, index, shift_policy, is_instant)
assert(self.nodes[index], "No grid item at given index " .. index)
@@ -379,7 +379,7 @@ end
--- Update grid inner state
-- @tparam StaticGrid self @{StaticGrid}
-- @tparam bool is_instant If true, node position update instantly, otherwise with set_position_function callback
-- @tparam boolean is_instant If true, node position update instantly, otherwise with set_position_function callback
-- @local
function StaticGrid._update(self, is_instant)
self:_update_indexes()
@@ -425,7 +425,7 @@ end
--- Update grid nodes position
-- @tparam StaticGrid self @{StaticGrid}
-- @tparam bool is_instant If true, node position update instantly, otherwise with set_position_function callback
-- @tparam boolean is_instant If true, node position update instantly, otherwise with set_position_function callback
-- @local
function StaticGrid._update_pos(self, is_instant)
local zero_offset = self:_get_zero_offset()

View File

@@ -222,7 +222,7 @@ function Text.on_style_change(self, style)
end
--- @{Text} constructor
--- The @{Text} constructor
-- @tparam Text self @{Text}
-- @tparam string|node node Node name or GUI Text Node itself
-- @tparam[opt] string value Initial text. Default value is node text from GUI scene.
@@ -358,7 +358,7 @@ end
--- Set text pivot. Text will re-anchor inside text area
-- @tparam Text self @{Text}
-- @tparam gui.pivot pivot Gui pivot constant
-- @tparam number pivot The gui.PIVOT_* constant
-- @treturn Text Current text instance
function Text.set_pivot(self, pivot)
local prev_pivot = gui.get_pivot(self.node)
@@ -384,7 +384,7 @@ end
--- Return true, if text with line break
-- @tparam Text self @{Text}
-- @treturn bool Is text node with line break
-- @treturn boolean Is text node with line break
function Text.is_multiline(self)
return gui.get_line_break(self.node)
end

View File

@@ -74,7 +74,6 @@ end
--
-- Invoke `on_style_change` on component, if exist. Component should handle
-- their style changing and store all style params
-- @function component:set_style
-- @tparam BaseComponent self @{BaseComponent}
-- @tparam table druid_style Druid style module
-- @treturn BaseComponent @{BaseComponent}
@@ -94,7 +93,6 @@ end
--
-- Use on all your custom components with GUI layouts used as templates.
-- It will check parent template name to build full template name in self:get_node()
-- @function component:set_template
-- @tparam BaseComponent self @{BaseComponent}
-- @tparam string template BaseComponent template name
-- @treturn BaseComponent @{BaseComponent}
@@ -118,7 +116,6 @@ end
--- Get current component template name.
-- @function component:get_template
-- @tparam BaseComponent self @{BaseComponent}
-- @treturn string Component full template name
function BaseComponent.get_template(self)
@@ -128,7 +125,6 @@ end
--- Set current component nodes.
-- Use if your component nodes was cloned with `gui.clone_tree` and you got the node tree.
-- @function component:set_nodes
-- @tparam BaseComponent self @{BaseComponent}
-- @tparam table nodes BaseComponent nodes table
-- @treturn BaseComponent @{BaseComponent}
@@ -155,7 +151,6 @@ end
--- Context used as first arg in all Druid events
--
-- Context is usually self of gui_script.
-- @function component:get_context
-- @tparam BaseComponent self @{BaseComponent}
-- @treturn table BaseComponent context
function BaseComponent.get_context(self)
@@ -164,7 +159,6 @@ end
--- Increase input priority in input stack
-- @function component:increase_input_priority
-- @tparam BaseComponent self @{BaseComponent}
-- @local
function BaseComponent.increase_input_priority(self)
@@ -178,7 +172,6 @@ end
-- It autopick node by template name or from nodes by gui.clone_tree
-- if they was setup via component:set_nodes, component:set_template.
-- If node is not found, the exception will fired
-- @function component:get_node
-- @tparam BaseComponent self @{BaseComponent}
-- @tparam string|node node_or_name Node name or node itself
-- @treturn node Gui node
@@ -211,9 +204,8 @@ end
--- Get Druid instance for inner component creation.
-- @function component:get_druid
-- @tparam BaseComponent self @{BaseComponent}
-- @treturn Druid Druid instance with component context
-- @treturn DruidInstance Druid instance with component context
function BaseComponent.get_druid(self)
local context = { _context = self }
return setmetatable(context, { __index = self._meta.druid })
@@ -221,7 +213,6 @@ end
--- Return component name
-- @function component:get_name
-- @tparam BaseComponent self @{BaseComponent}
-- @treturn string The component name
function BaseComponent.get_name(self)
@@ -230,7 +221,6 @@ end
--- Return parent component name
-- @function component:get_parent_name
-- @tparam BaseComponent self @{BaseComponent}
-- @treturn string|nil The parent component name if exist or bil
function BaseComponent.get_parent_name(self)
@@ -240,7 +230,6 @@ end
--- Return component input priority
-- @function component:get_input_priority
-- @tparam BaseComponent self @{BaseComponent}
-- @treturn number The component input priority
function BaseComponent.get_input_priority(self)
@@ -251,7 +240,6 @@ end
--- Set component input priority
--
-- Default value: 10
-- @function component:set_input_priority
-- @tparam BaseComponent self @{BaseComponent}
-- @tparam number value The new input priority value
-- @tparam boolean is_temporary If true, the reset input priority will return to previous value
@@ -280,7 +268,6 @@ end
--- Reset component input priority to default value
-- @function component:reset_input_priority
-- @tparam BaseComponent self @{BaseComponent}
-- @treturn number The component input priority
function BaseComponent.reset_input_priority(self)
@@ -292,7 +279,6 @@ end
--- Return component UID.
--
-- UID generated in component creation order.
-- @function component:get_uid
-- @tparam BaseComponent self @{BaseComponent}
-- @treturn number The component uid
function BaseComponent.get_uid(self)
@@ -303,9 +289,8 @@ end
--- Set component input state. By default it enabled
--
-- If input is disabled, the component will not receive input events
-- @function component:set_input_enabled
-- @tparam BaseComponent self @{BaseComponent}
-- @tparam bool state The component input state
-- @tparam boolean state The component input state
-- @treturn BaseComponent BaseComponent itself
function BaseComponent.set_input_enabled(self, state)
self._meta.input_enabled = state
@@ -319,7 +304,6 @@ end
--- Return the parent component if exist
-- @function component:get_parent_component
-- @tparam BaseComponent self @{BaseComponent}
-- @treturn BaseComponent|nil The druid component instance or nil
function BaseComponent.get_parent_component(self)
@@ -328,7 +312,6 @@ end
--- Setup component context and his style table
-- @function component:setup_component
-- @tparam BaseComponent self @{BaseComponent}
-- @tparam table druid_instance The parent druid instance
-- @tparam table context Druid context. Usually it is self of script
@@ -362,7 +345,6 @@ end
--- Basic constructor of component. It will call automaticaly
-- by `BaseComponent.create`
-- @function component:initialize
-- @tparam BaseComponent self @{BaseComponent}
-- @tparam string name BaseComponent name
-- @tparam[opt=DEFAULT] number input_priority The input priority. The bigger number processed first
@@ -380,7 +362,6 @@ end
--- Print log information if debug mode is enabled
-- @function component:log_message
-- @tparam BaseComponent self @{BaseComponent}
-- @tparam string message
-- @tparam table context
@@ -394,9 +375,8 @@ end
--- Set debug logs for component enabled or disabled
-- @function component:set_debug
-- @tparam BaseComponent self @{BaseComponent}
-- @tparam bool is_debug
-- @tparam boolean is_debug
-- @local
function BaseComponent.set_debug(self, is_debug)
self._component.is_debug = is_debug
@@ -404,7 +384,6 @@ end
--- Return true, if input priority was changed
-- @function component:_is_input_priority_changed
-- @tparam BaseComponent self @{BaseComponent}
-- @local
function BaseComponent._is_input_priority_changed(self)
@@ -413,7 +392,6 @@ end
--- Reset is_input_priority_changed field
-- @function component:_reset_input_priority_changed
-- @tparam BaseComponent self @{BaseComponent}
-- @local
function BaseComponent._reset_input_priority_changed(self)
@@ -427,7 +405,6 @@ end
--- Get current component interests
-- @function component:__get_interests
-- @tparam BaseComponent self @{BaseComponent}
-- @treturn table List of component interests
-- @local
@@ -451,7 +428,6 @@ end
--- Get current component nodes
-- @function component:__get_nodes
-- @tparam BaseComponent self @{BaseComponent}
-- @treturn table BaseComponent nodes table
-- @local
@@ -466,7 +442,6 @@ end
--- Add child to component children list
-- @function component:__add_children
-- @tparam BaseComponent self @{BaseComponent}
-- @tparam component children The druid component instance
-- @local
@@ -476,7 +451,6 @@ end
--- Remove child from component children list
-- @function component:__remove_children
-- @tparam BaseComponent self @{BaseComponent}
-- @tparam component children The druid component instance
-- @local
@@ -490,7 +464,6 @@ end
--- Return all children components, recursive
-- @function component:get_childrens
-- @tparam BaseComponent self @{BaseComponent}
-- @treturn table Array of childrens if the Druid component instance
function BaseComponent.get_childrens(self)

View File

@@ -20,7 +20,7 @@ M.ACTION_SCROLL_DOWN = hash(sys.get_config("druid.input_scroll_down", "mouse_whe
M.IS_STENCIL_CHECK = not (sys.get_config("druid.no_stencil_check") == "1")
--- Component Interests
M.ON_INPUT = "on_input"
M.ON_UPDATE = "update"
M.ON_MESSAGE = "on_message"

View File

@@ -10,7 +10,7 @@
-- @tfield DruidInstance druid @{DruidInstance}
--- Is currently under user control
-- @tfield bool is_drag
-- @tfield boolean is_drag
--- The pin node
-- @tfield node node
@@ -52,7 +52,7 @@ local function set_angle(self, value)
end
--- Component init function
--- The @{PinKnob} constructor
-- @tparam PinKnob self @{PinKnob}
-- @tparam function callback Callback(self, value) on value changed
-- @tparam string template The template string name

View File

@@ -61,7 +61,7 @@ local function on_unselect(self)
end
--- Component init function
--- The @{RichInput} constructor
-- @tparam RichInput self @{RichInput}
-- @tparam string template The template string name
-- @tparam table nodes Nodes table from gui.clone_tree

View File

@@ -90,6 +90,7 @@
--- The component druid instance
-- @tfield DruidInstance druid @{DruidInstance}
--
local component = require("druid.component")
local rich_text = require("druid.custom.rich_text.module.rt")
@@ -103,7 +104,7 @@ local SCHEME = {
}
--- Rich Text component constructor
--- The @{RichText} constructor
-- @tparam RichText self @{RichText}
-- @tparam string template The Rich Text template name
-- @tparam table nodes The node table, if prefab was copied by gui.clone_tree()

View File

@@ -32,7 +32,7 @@ end
--- Subscribe callback on event
-- @tparam DruidEvent self @{DruidEvent}
-- @tparam function callback Callback itself
-- @tparam[opt] Any context Additional context as first param to callback call, usually it's self
-- @tparam[opt] any context Additional context as first param to callback call, usually it's self
-- @usage
-- local function on_long_callback(self)
-- print("Long click!")
@@ -57,7 +57,7 @@ end
--- Unsubscribe callback on event
-- @tparam DruidEvent self @{DruidEvent}
-- @tparam function callback Callback itself
-- @tparam[opt] Any context Additional context as first param to callback call
-- @tparam[opt] any context Additional context as first param to callback call
-- @usage
-- local function on_long_callback(self)
-- print("Long click!")
@@ -80,7 +80,7 @@ end
--- Return true, if event have at lease one handler
-- @tparam DruidEvent self @{DruidEvent}
-- @treturn bool True if event have handlers
-- @treturn boolean True if event have handlers
-- @usage
-- local is_long_click_handler_exists = button.on_long_click:is_exist()
function DruidEvent.is_exist(self)
@@ -102,7 +102,7 @@ end
--- Trigger the event and call all subscribed callbacks
-- @tparam DruidEvent self @{DruidEvent}
-- @tparam Any ... All event params
-- @tparam any ... All event params
-- @usage
-- local Event = require("druid.event")
-- ...

View File

@@ -46,7 +46,7 @@ function Checkbox.on_style_change(self, style)
end
--- Component init function
--- The @{Checkbox} constructor
-- @tparam Checkbox self @{Checkbox}
-- @tparam node node Gui node
-- @tparam function callback Checkbox callback
@@ -71,9 +71,9 @@ end
--- Set checkbox state
-- @tparam Checkbox self @{Checkbox}
-- @tparam bool state Checkbox state
-- @tparam bool is_silent Don't trigger on_change_state if true
-- @tparam bool is_instant If instant checkbox change
-- @tparam boolean state Checkbox state
-- @tparam boolean is_silent Don't trigger on_change_state if true
-- @tparam boolean is_instant If instant checkbox change
function Checkbox.set_state(self, state, is_silent, is_instant)
self.state = state
self.style.on_change_state(self, self.node, state, is_instant)
@@ -88,7 +88,7 @@ end
--- Return checkbox state
-- @tparam Checkbox self @{Checkbox}
-- @treturn bool Checkbox state
-- @treturn boolean Checkbox state
function Checkbox.get_state(self)
return self.state
end

View File

@@ -21,7 +21,7 @@ local component = require("druid.component")
local CheckboxGroup = component.create("checkbox_group")
--- Component init function
--- The @{CheckboxGroup} constructor
-- @tparam CheckboxGroup self @{CheckboxGroup}
-- @tparam node[] nodes Array of gui node
-- @tparam function callback Checkbox callback
@@ -45,7 +45,7 @@ end
--- Set checkbox group state
-- @tparam CheckboxGroup self @{CheckboxGroup}
-- @tparam bool[] indexes Array of checkbox state
-- @tparam boolean[] indexes Array of checkbox state
-- @tparam boolean is_instant If instant state change
function CheckboxGroup.set_state(self, indexes, is_instant)
for i = 1, #indexes do
@@ -58,7 +58,7 @@ end
--- Return checkbox group state
-- @tparam CheckboxGroup self @{CheckboxGroup}
-- @treturn bool[] Array if checkboxes state
-- @treturn boolean[] Array if checkboxes state
function CheckboxGroup.get_state(self)
local result = {}

View File

@@ -43,7 +43,7 @@ local Event = require("druid.event")
local DataList = component.create("data_list")
--- Data list constructor
--- The @{DataList} constructor
-- @tparam DataList self @{DataList}
-- @tparam Scroll scroll The @{Scroll} instance for Data List component
-- @tparam StaticGrid|DynamicGrid grid The @{StaticGrid} or @{DynamicGrid} instance for Data List component
@@ -197,7 +197,7 @@ end
--- Return all currenly created nodes in DataList
-- @tparam DataList self @{DataList}
-- @treturn Node[] List of created nodes
-- @treturn node[] List of created nodes
function DataList.get_created_nodes(self)
local nodes = {}

View File

@@ -65,7 +65,7 @@ local AVAILABLE_PIVOTS = {
}
--- Component init function
--- The @{DynamicGrid} constructor
-- @tparam DynamicGrid self @{DynamicGrid}
-- @tparam node parent The gui node parent, where items will be placed
function DynamicGrid.init(self, parent)
@@ -322,7 +322,7 @@ end
--- Update grid inner state
-- @tparam DynamicGrid self @{DynamicGrid}
-- @tparam bool is_instant If true, node position update instantly, otherwise with set_position_function callback
-- @tparam boolean is_instant If true, node position update instantly, otherwise with set_position_function callback
-- @local
function DynamicGrid._update(self, is_instant)
self:_update_indexes()
@@ -378,7 +378,7 @@ end
--- Update grid nodes position
-- @tparam DynamicGrid self @{DynamicGrid}
-- @tparam bool is_instant If true, node position update instantly, otherwise with set_position_function callback
-- @tparam boolean is_instant If true, node position update instantly, otherwise with set_position_function callback
-- @local
function DynamicGrid._update_pos(self, is_instant)
for index, node in pairs(self.nodes) do

View File

@@ -27,11 +27,11 @@ local component = require("druid.component")
local Hotkey = component.create("hotkey")
--- Component init function
--- The @{Hotkey} constructor
-- @tparam Hotkey self @{Hotkey}
-- @tparam string[]|string keys The keys to be pressed for trigger callback. Should contains one key and any modificator keys
-- @tparam function callback The callback function
-- @tparam[opt] value callback_argument The argument to pass into the callback function
-- @tparam[opt] any callback_argument The argument to pass into the callback function
function Hotkey.init(self, keys, callback, callback_argument)
self.druid = self:get_druid()
@@ -63,7 +63,7 @@ end
--- Add hotkey for component callback
-- @tparam Hotkey self @{Hotkey}
-- @tparam string[]|hash[]|string|hash keys that have to be pressed before key pressed to activate
-- @tparam[opt] value callback_argument The argument to pass into the callback function
-- @tparam[opt] any callback_argument The argument to pass into the callback function
function Hotkey.add_hotkey(self, keys, callback_argument)
keys = keys or {}
if type(keys) == "string" then

View File

@@ -34,10 +34,10 @@
-- @tfield Button button @{Button}
--- Is current input selected now
-- @tfield bool is_selected
-- @tfield boolean is_selected
--- Is current input is empty now
-- @tfield bool is_empty
-- @tfield boolean is_empty
--- Max length for input text
-- @tfield[opt] number max_length
@@ -87,10 +87,10 @@ end
-- You can override this component styles params in druid styles table
-- or create your own style
-- @table style
-- @tfield[opt=false] bool IS_LONGTAP_ERASE Is long tap will erase current input data
-- @tfield[opt=false] boolean IS_LONGTAP_ERASE Is long tap will erase current input data
-- @tfield[opt=*] string MASK_DEFAULT_CHAR Default character mask for password input
-- @tfield[opt=false] bool IS_UNSELECT_ON_RESELECT If true, call unselect on select selected input
-- @tfield[opt=false] bool NO_CONSUME_INPUT_WHILE_SELECTED If true, will not consume input while input is selected. It's allow to interact with other components while input is selected (text input still captured)
-- @tfield[opt=false] boolean IS_UNSELECT_ON_RESELECT If true, call unselect on select selected input
-- @tfield[opt=false] boolean NO_CONSUME_INPUT_WHILE_SELECTED If true, will not consume input while input is selected. It's allow to interact with other components while input is selected (text input still captured)
-- @tfield function on_select (self, button_node) Callback on input field selecting
-- @tfield function on_unselect (self, button_node) Callback on input field unselecting
-- @tfield function on_input_wrong (self, button_node) Callback on wrong user input
@@ -115,7 +115,7 @@ function Input.on_style_change(self, style)
end
--- Component init function
--- The @{Input} constructor
-- @tparam Input self @{Input}
-- @tparam node click_node Node to enabled input component
-- @tparam node|Text text_node Text node what will be changed on user input. You can pass text component instead of text node name @{Text}

View File

@@ -28,7 +28,7 @@ local Event = require("druid.event")
local Layout = component.create("layout")
--- Component init function
--- The @{Layout} constructor
-- @tparam Layout self @{Layout}
-- @tparam node node Gui node
-- @tparam string mode The layout mode (from const.LAYOUT_MODE)
@@ -194,7 +194,7 @@ end
--- Set node for layout node to fit inside it. Pass nil to reset
-- @tparam Layout self @{Layout}
-- @tparam[opt] Node node
-- @tparam[opt] node node
-- @treturn Layout @{Layout}
function Layout.fit_into_node(self, node)
self._fit_node = node

View File

@@ -110,7 +110,7 @@ function Progress.on_style_change(self, style)
end
--- @{Progress} constructor
--- The @{Progress} constructor
-- @tparam Progress self @{Progress}
-- @tparam string|node node Node name or GUI Node itself.
-- @tparam string key Progress bar direction: const.SIDE.X or const.SIDE.Y

View File

@@ -30,7 +30,7 @@ local function on_checkbox_click(self, index, is_instant)
end
--- Component init function
--- The @{RadioGroup} constructor
-- @tparam RadioGroup self @{RadioGroup}
-- @tparam node[] nodes Array of gui node
-- @tparam function callback Radio callback

View File

@@ -29,7 +29,7 @@
-- @tfield number dist
--- Current drag state
-- @tfield bool is_drag
-- @tfield boolean is_drag
--- Current slider value
-- @tfield number value
@@ -56,7 +56,7 @@ local function set_position(self, value)
end
--- Component init function
--- The @{Slider} constructor
-- @tparam Slider self @{Slider}
-- @tparam node node Gui pin node
-- @tparam vector3 end_pos The end position of slider
@@ -174,7 +174,7 @@ end
--- Set value for slider
-- @tparam Slider self @{Slider}
-- @tparam number value Value from 0 to 1
-- @tparam[opt] bool is_silent Don't trigger event if true
-- @tparam[opt] boolean is_silent Don't trigger event if true
function Slider.set(self, value, is_silent)
value = helper.clamp(value, 0, 1)
set_position(self, value)
@@ -202,7 +202,7 @@ end
-- move at this position and node drag will start.
-- This function require the Defold version 1.3.0+
-- @tparam Slider self @{Slider}
-- @tparam Node input_node
-- @tparam node input_node
-- @treturn Slider @{Slider}
function Slider.set_input_node(self, input_node)
self._input_node = self:get_node(input_node)

View File

@@ -76,7 +76,7 @@ end
-- @table style
-- @tfield[opt=0.4] number SWIPE_TIME Maximum time for swipe trigger
-- @tfield[opt=50] number SWIPE_THRESHOLD Minimum distance for swipe trigger
-- @tfield[opt=false] bool SWIPE_TRIGGER_ON_MOVE If true, trigger on swipe moving, not only release action
-- @tfield[opt=false] boolean SWIPE_TRIGGER_ON_MOVE If true, trigger on swipe moving, not only release action
function Swipe.on_style_change(self, style)
self.style = {}
self.style.SWIPE_TIME = style.SWIPE_TIME or 0.4
@@ -85,7 +85,7 @@ function Swipe.on_style_change(self, style)
end
--- Component init function
--- The @{Swipe} constructor
-- @tparam Swipe self @{Swipe}
-- @tparam node node Gui node
-- @tparam function on_swipe_callback Swipe callback for on_swipe_end event

View File

@@ -44,7 +44,7 @@ local function second_string_min(sec)
end
--- Component init function
--- The @{Timer} constructor
-- @tparam Timer self @{Timer}
-- @tparam node node Gui text node
-- @tparam number seconds_from Start timer value in seconds
@@ -110,7 +110,7 @@ end
--- Called when update
-- @tparam Timer self @{Timer}
-- @tparam bool is_on Timer enable state
-- @tparam boolean is_on Timer enable state
function Timer.set_state(self, is_on)
self.is_on = is_on

View File

@@ -255,9 +255,9 @@ end
--- Add all elements from source array to the target array
-- @function helper.add_array
-- @tparam table target Array to put elements from source
-- @tparam[opt] table source The source array to get elements from
-- @treturn array The target array
-- @tparam any[] target Array to put elements from source
-- @tparam[opt] any[] source The source array to get elements from
-- @treturn any[] The target array
function M.add_array(target, source)
assert(target)
@@ -275,7 +275,7 @@ end
--- Make a check with gui.pick_node, but with additional node_click_area check.
-- @function helper.pick_node
-- @tparam Node node
-- @tparam node node
-- @tparam number x
-- @tparam number y
-- @tparam[opt] Node node_click_area
@@ -302,7 +302,7 @@ end
--- Get cumulative parent's node scale
-- @function helper.get_scene_scale
-- @tparam node node Gui node
-- @tparam bool include_passed_node_scale True if add current node scale to result
-- @tparam boolean include_passed_node_scale True if add current node scale to result
-- @treturn vector3 The scene node scale
function M.get_scene_scale(node, include_passed_node_scale)
local scale = include_passed_node_scale and gui.get_scale(node) or vmath.vector3(1)
@@ -345,7 +345,7 @@ end
--
-- Offset shown in [-0.5 .. 0.5] range, where -0.5 is left or bottom, 0.5 is right or top.
-- @function helper.get_pivot_offset
-- @tparam gui.pivot pivot The node pivot
-- @tparam number pivot The gui.PIVOT_* constant
-- @treturn vector3 Vector offset with [-0.5..0.5] values
function M.get_pivot_offset(pivot)
return const.PIVOTS[pivot]
@@ -354,7 +354,7 @@ end
--- Check if device is native mobile (Android or iOS)
-- @function helper.is_mobile
-- @treturn bool Is mobile
-- @treturn boolean Is mobile
function M.is_mobile()
return const.CURRENT_SYSTEM_NAME == const.OS.IOS or
const.CURRENT_SYSTEM_NAME == const.OS.ANDROID
@@ -363,7 +363,7 @@ end
--- Check if device is HTML5
-- @function helper.is_web
-- @treturn bool Is web
-- @treturn boolean Is web
function M.is_web()
return const.CURRENT_SYSTEM_NAME == const.OS.BROWSER
end
@@ -420,7 +420,7 @@ end
--- Get text metric from GUI node.
-- @function helper.get_text_metrics_from_node
-- @tparam Node text_node
-- @tparam node text_node
-- @treturn GUITextMetrics
-- @usage
-- type GUITextMetrics = {
@@ -451,10 +451,10 @@ end
-- Shift policy can be: left, right, no_shift
-- @function helper.insert_with_shift
-- @tparam table array Array
-- @param item Item to insert
-- @param any Item to insert
-- @tparam[opt] number index Index to insert. If nil, item will be inserted at the end of array
-- @tparam[opt] const.SHIFT shift_policy Shift policy
-- @treturn item Inserted item
-- @tparam[opt] number shift_policy The druid_const.SHIFT.* constant
-- @treturn any Inserted item
function M.insert_with_shift(array, item, index, shift_policy)
shift_policy = shift_policy or const.SHIFT.RIGHT
@@ -484,8 +484,8 @@ end
-- @function helper.remove_with_shift
-- @tparam table array Array
-- @tparam[opt] number index Index to remove. If nil, item will be removed from the end of array
-- @tparam[opt] const.SHIFT shift_policy Shift policy
-- @treturn item Removed item
-- @tparam[opt] number shift_policy The druid_const.SHIFT.* constant
-- @treturn any Removed item
function M.remove_with_shift(array, index, shift_policy)
shift_policy = shift_policy or const.SHIFT.RIGHT

View File

@@ -259,8 +259,8 @@ end
--- Create new component.
-- @tparam DruidInstance self
-- @tparam Component component Component module
-- @tparam args ... Other component params to pass it to component:init function
-- @tparam BaseComponent component Component module
-- @tparam any ... Other component params to pass it to component:init function
function DruidInstance.new(self, component, ...)
local instance = create(self, component)
@@ -296,7 +296,7 @@ end
--
-- Component `on_remove` function will be invoked, if exist.
-- @tparam DruidInstance self
-- @tparam Component component Component instance
-- @tparam BaseComponent component Component instance
function DruidInstance.remove(self, component)
if self._is_late_remove_enabled then
table.insert(self._late_remove, component)
@@ -380,7 +380,7 @@ end
-- @tparam DruidInstance self
-- @tparam hash action_id Action_id from on_input
-- @tparam table action Action from on_input
-- @treturn bool The boolean value is input was consumed
-- @treturn boolean The boolean value is input was consumed
function DruidInstance.on_input(self, action_id, action)
self._is_late_remove_enabled = true
@@ -477,7 +477,7 @@ end
-- If whitelist is not empty and component not contains in this list,
-- component will be not processed on input step
-- @tparam DruidInstance self
-- @tparam[opt=nil] table|Component whitelist_components The array of component to whitelist
-- @tparam[opt=nil] table|BaseComponent whitelist_components The array of component to whitelist
-- @treturn self @{DruidInstance}
function DruidInstance.set_whitelist(self, whitelist_components)
if whitelist_components and whitelist_components.isInstanceOf then
@@ -499,7 +499,7 @@ end
-- If blacklist is not empty and component contains in this list,
-- component will be not processed on input step
-- @tparam DruidInstance self @{DruidInstance}
-- @tparam[opt=nil] table|Component blacklist_components The array of component to blacklist
-- @tparam[opt=nil] table|BaseComponent blacklist_components The array of component to blacklist
-- @treturn self @{DruidInstance}
function DruidInstance.set_blacklist(self, blacklist_components)
if blacklist_components and blacklist_components.isInstanceOf then
@@ -518,7 +518,7 @@ end
--- Set debug mode for current Druid instance. It's enable debug log messages
-- @tparam DruidInstance self @{DruidInstance}
-- @tparam bool is_debug
-- @tparam boolean is_debug
-- @treturn self @{DruidInstance}
-- @local
function DruidInstance.set_debug(self, is_debug)
@@ -579,7 +579,7 @@ end
--- Create @{BackHandler} component
-- @tparam DruidInstance self
-- @tparam callback callback On back button
-- @tparam function callback @The callback(self, custom_args) to call on back event
-- @tparam[opt] any params Callback argument
-- @treturn BackHandler @{BackHandler} component
function DruidInstance.new_back_handler(self, callback, params)
@@ -601,7 +601,7 @@ end
-- @tparam DruidInstance self
-- @tparam node node Gui text node
-- @tparam[opt] string value Initial text. Default value is node text from GUI scene.
-- @tparam[opt] bool no_adjust If true, text will be not auto-adjust size
-- @tparam[opt] boolean no_adjust If true, text will be not auto-adjust size
-- @treturn Text @{Text} component
function DruidInstance.new_text(self, node, value, no_adjust)
return DruidInstance.new(self, text, node, value, no_adjust)
@@ -676,7 +676,7 @@ end
-- @tparam DruidInstance self
-- @tparam node node The text node
-- @tparam string locale_id Default locale id
-- @tparam bool no_adjust If true, will not correct text size
-- @tparam boolean no_adjust If true, will not correct text size
-- @treturn LangText @{LangText} component
function DruidInstance.new_lang_text(self, node, locale_id, no_adjust)
return helper.require_component_message("lang_text")
@@ -731,7 +731,7 @@ end
--- Create @{DataList} component
-- @tparam DruidInstance self
-- @tparam Scroll druid_scroll The Scroll instance for Data List component
-- @tparam Grid druid_grid The Grid instance for Data List component
-- @tparam StaticGrid|DynamicGrid druid_grid The @{StaticGrid} or @{DynamicGrid} instance for Data List component
-- @tparam function create_function The create function callback(self, data, index, data_list). Function should return (node, [component])
-- @treturn DataList @{DataList} component
function DruidInstance.new_data_list(self, druid_scroll, druid_grid, create_function)
@@ -786,10 +786,10 @@ end
--- Create @{Hotkey} component
-- @tparam DruidInstance self
-- @tparam string|string[] keys_array Keys for trigger action. Should contains one action key and any amount of modificator keys
-- @tparam function callback Button callback
-- @tparam[opt] value params Button callback params
-- @tparam function callback The callback function
-- @tparam[opt] any callback_argument The argument to pass into the callback function
-- @treturn Hotkey @{Hotkey} component
function DruidInstance.new_hotkey(self, keys_array, callback, params)
function DruidInstance.new_hotkey(self, keys_array, callback, callback_argument)
return helper.require_component_message("hotkey")
end