replace all tparam

This commit is contained in:
Insality 2024-11-07 18:34:27 +01:00
parent 999c6222a0
commit 620facbe1f
15 changed files with 281 additions and 281 deletions

View File

@ -471,7 +471,7 @@ end
--- Set button enabled state.
-- The style.on_set_enabled will be triggered.
-- Disabled button is not clickable.
-- @tparam boolean|nil state Enabled state
---@param state boolean|nil Enabled state
---@return druid.button self
function M:set_enabled(state)
self.disabled = not state
@ -495,7 +495,7 @@ end
-- Useful to restrict click outside out stencil node or scrollable content.
--
-- This functions calls automatically if you don't disable it in game.project: druid.no_stencil_check
-- @tparam node|string|nil zone Gui node
---@param zone node|string|nil Gui node
---@return druid.button self
function M:set_click_zone(zone)
self.click_zone = self:get_node(zone)
@ -523,8 +523,8 @@ end
--- Set function for additional check for button click availability
-- @tparam function|nil check_function Should return true or false. If true - button can be pressed.
-- @tparam function|nil failure_callback Function will be called on button click, if check function return false
---@param check_function function|nil Should return true or false. If true - button can be pressed.
---@param failure_callback function|nil Function will be called on button click, if check function return false
---@return druid.button self
function M:set_check_function(check_function, failure_callback)
self._check_function = check_function
@ -538,7 +538,7 @@ end
-- 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
-- @tparam boolean|nil is_web_mode If true - button will be called inside html5 callback
---@param is_web_mode boolean|nil If true - button will be called inside html5 callback
---@return druid.button self
function M:set_web_user_interaction(is_web_mode)
self._is_html5_mode = not not (is_web_mode and html5)

View File

@ -35,10 +35,10 @@ local M = component.create("hover")
--- The Hover constructor
-- @tparam Hover self Hover
-- @tparam node node Gui node
-- @tparam function on_hover_callback Hover callback
-- @tparam function on_mouse_hover On mouse hover callback
---@param self Hover Hover
---@param node node Gui node
---@param on_hover_callback function Hover callback
---@param on_mouse_hover function On mouse hover callback
function M:init(node, on_hover_callback, on_mouse_hover)
self.node = self:get_node(node)
@ -115,8 +115,8 @@ end
--- Set hover state
-- @tparam Hover self Hover
-- @tparam boolean|nil state The hover state
---@param self Hover Hover
---@param state boolean|nil The hover state
function M:set_hover(state)
if self._is_hovered == state then
return
@ -132,7 +132,7 @@ end
--- Return current hover state. True if touch action was on the node at current time
-- @tparam Hover self Hover
---@param self Hover Hover
-- @treturn boolean The current hovered state
function M:is_hovered()
return self._is_hovered
@ -140,8 +140,8 @@ end
--- Set mouse hover state
-- @tparam Hover self Hover
-- @tparam boolean|nil state The mouse hover state
---@param self Hover Hover
---@param state boolean|nil The mouse hover state
function M:set_mouse_hover(state)
if self._is_mouse_hovered == state then
return
@ -157,7 +157,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
---@param self Hover Hover
-- @treturn boolean The current hovered state
function M:is_mouse_hovered()
return self._is_mouse_hovered
@ -166,8 +166,8 @@ end
--- Strict hover click area. Useful for
-- no click events outside stencil node
-- @tparam Hover self Hover
-- @tparam node|string|nil zone Gui node
---@param self Hover Hover
---@param zone node|string|nil Gui node
function M:set_click_zone(zone)
self.click_zone = self:get_node(zone)
end
@ -176,8 +176,8 @@ end
--- Set enable state of hover component.
-- If hover is not enabled, it will not generate
-- any hover events
-- @tparam Hover self Hover
-- @tparam boolean|nil state The hover enabled state
---@param self Hover Hover
---@param state boolean|nil The hover enabled state
function M:set_enabled(state)
self._is_enabled = state
@ -193,7 +193,7 @@ end
--- Return current hover enabled state
-- @tparam Hover self Hover
---@param self Hover Hover
-- @treturn boolean The hover enabled state
function M:is_enabled()
return self._is_enabled

View File

@ -171,9 +171,9 @@ end
--- 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
---@param self Scroll Scroll
---@param view_node string|node GUI view scroll node
---@param content_node string|node GUI content scroll node
function M:init(view_node, content_node)
self.druid = self:get_druid()
@ -253,9 +253,9 @@ end
--- Start scroll to target point.
-- @tparam Scroll self Scroll
-- @tparam vector3 point Target point
-- @tparam boolean|nil is_instant Instant scroll flag
---@param self Scroll Scroll
---@param point vector3 Target point
---@param is_instant boolean|nil Instant scroll flag
-- @usage scroll:scroll_to(vmath.vector3(0, 50, 0))
-- @usage scroll:scroll_to(vmath.vector3(0), true)
function M:scroll_to(point, is_instant)
@ -287,9 +287,9 @@ end
--- Scroll to item in scroll by point index.
-- @tparam Scroll self Scroll
-- @tparam number index Point index
-- @tparam boolean|nil skip_cb If true, skip the point callback
---@param self Scroll Scroll
---@param index number Point index
---@param skip_cb boolean|nil If true, skip the point callback
function M:scroll_to_index(index, skip_cb)
if not self.points then
return
@ -310,9 +310,9 @@ end
--- Start scroll to target scroll percent
-- @tparam Scroll self Scroll
-- @tparam vector3 percent target percent
-- @tparam boolean|nil is_instant instant scroll flag
---@param self Scroll Scroll
---@param percent vector3 target percent
---@param is_instant boolean|nil instant scroll flag
-- @usage scroll:scroll_to_percent(vmath.vector3(0.5, 0, 0))
function M:scroll_to_percent(percent, is_instant)
local border = self.available_pos
@ -336,7 +336,7 @@ end
--- Return current scroll progress status.
-- Values will be in [0..1] interval
-- @tparam Scroll self Scroll
---@param self Scroll Scroll
-- @treturn vector3 New vector with scroll progress values
function M:get_percent()
local x_perc = 1 - inverse_lerp(self.available_pos.x, self.available_pos.z, self.position.x)
@ -348,9 +348,9 @@ end
--- Set scroll content size.
-- It will change content gui node size
-- @tparam Scroll self Scroll
-- @tparam vector3 size The new size for content node
-- @tparam vector3|nil offset Offset value to set, where content is starts
---@param self Scroll Scroll
---@param size vector3 The new size for content node
---@param offset vector3|nil Offset value to set, where content is starts
-- @treturn druid.scroll Current scroll instance
function M:set_size(size, offset)
if offset then
@ -364,8 +364,8 @@ end
--- Set new scroll view size in case the node size was changed.
-- @tparam Scroll self Scroll
-- @tparam vector3 size The new size for view node
---@param self Scroll Scroll
---@param size vector3 The new size for view node
-- @treturn druid.scroll Current scroll instance
function M:set_view_size(size)
gui.set_size(self.view_node, size)
@ -378,7 +378,7 @@ end
--- Refresh scroll view size
-- @tparam Scroll self Scroll
---@param self Scroll Scroll
function M:update_view_size()
self.view_size = helper.get_scaled_size(self.view_node)
self.view_border = helper.get_border(self.view_node)
@ -391,8 +391,8 @@ end
--- Enable or disable scroll inert.
-- If disabled, scroll through points (if exist)
-- If no points, just simple drag without inertion
-- @tparam Scroll self Scroll
-- @tparam boolean|nil state Inert scroll state
---@param self Scroll Scroll
---@param state boolean|nil Inert scroll state
-- @treturn druid.scroll Current scroll instance
function M:set_inert(state)
self._is_inert = state
@ -402,7 +402,7 @@ end
--- Return if scroll have inertion.
-- @tparam Scroll self Scroll
---@param self Scroll Scroll
-- @treturn boolean @If scroll have inertion
function M:is_inert()
return self._is_inert
@ -411,8 +411,8 @@ end
--- Set extra size for scroll stretching.
-- Set 0 to disable stretching effect
-- @tparam Scroll self Scroll
-- @tparam number|nil stretch_size Size in pixels of additional scroll area
---@param self Scroll Scroll
---@param stretch_size number|nil Size in pixels of additional scroll area
-- @treturn druid.scroll Current scroll instance
function M:set_extra_stretch_size(stretch_size)
self.style.EXTRA_STRETCH_SIZE = stretch_size or 0
@ -423,7 +423,7 @@ end
--- Return vector of scroll size with width and height.
-- @tparam Scroll self Scroll
---@param self Scroll Scroll
-- @treturn vector3 Available scroll size
function M:get_scroll_size()
return self.available_size
@ -432,8 +432,8 @@ end
--- Set points of interest.
-- Scroll will always centered on closer points
-- @tparam Scroll self Scroll
-- @tparam table points Array of vector3 points
---@param self Scroll Scroll
---@param points table Array of vector3 points
-- @treturn druid.scroll Current scroll instance
function M:set_points(points)
self.points = points
@ -449,8 +449,8 @@ end
--- Lock or unlock horizontal scroll
-- @tparam Scroll self Scroll
-- @tparam boolean|nil state True, if horizontal scroll is enabled
---@param self Scroll Scroll
---@param state boolean|nil True, if horizontal scroll is enabled
-- @treturn druid.scroll Current scroll instance
function M:set_horizontal_scroll(state)
self._is_horizontal_scroll = state
@ -460,8 +460,8 @@ end
--- Lock or unlock vertical scroll
-- @tparam Scroll self Scroll
-- @tparam boolean|nil state True, if vertical scroll is enabled
---@param self Scroll Scroll
---@param state boolean|nil True, if vertical scroll is enabled
-- @treturn druid.scroll Current scroll instance
function M:set_vertical_scroll(state)
self._is_vertical_scroll = state
@ -472,8 +472,8 @@ end
--- Check node if it visible now on scroll.
-- Extra border is not affected. Return true for elements in extra scroll zone
-- @tparam Scroll self Scroll
-- @tparam node node The node to check
---@param self Scroll Scroll
---@param node node The node to check
-- @treturn boolean True if node in visible scroll area
function M:is_node_in_view(node)
local node_offset_for_view = gui.get_position(node)
@ -513,8 +513,8 @@ end
--- Bind the grid component (Static or Dynamic) to recalculate
-- scroll size on grid changes
-- @tparam Scroll self Scroll
-- @tparam StaticGrid grid Druid grid component
---@param self Scroll Scroll
---@param grid StaticGrid Druid grid component
-- @treturn druid.scroll Current scroll instance
function M:bind_grid(grid)
if self._grid_on_change then
@ -542,8 +542,8 @@ end
--- Strict drag scroll area. Useful for
-- restrict events outside stencil node
-- @tparam Drag self
-- @tparam node|string node Gui node
---@param self Drag
---@param node node|string Gui node
function M:set_click_zone(node)
self.drag:set_click_zone(node)
end

View File

@ -128,10 +128,10 @@ end
--- The StaticGrid constructor
-- @tparam StaticGrid self StaticGrid
-- @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 number|nil in_row How many nodes in row can be placed. By default 1
---@param self StaticGrid StaticGrid
---@param parent string|node The GUI Node container, where grid's items will be placed
---@param element node Element prefab. Need to get it size
---@param in_row number|nil How many nodes in row can be placed. By default 1
function M:init(parent, element, in_row)
self.parent = self:get_node(parent)
self.nodes = {}
@ -165,8 +165,8 @@ end
local _temp_pos = vmath.vector3(0)
--- Return pos for grid node index
-- @tparam StaticGrid self StaticGrid
-- @tparam number index The grid element index
---@param self StaticGrid StaticGrid
---@param index number The grid element index
-- @treturn vector3 @Node position
function M:get_pos(index)
local row = math.ceil(index / self.in_row) - 1
@ -183,8 +183,8 @@ end
--- Return index for grid pos
-- @tparam StaticGrid self StaticGrid
-- @tparam vector3 pos The node position in the grid
---@param self StaticGrid StaticGrid
---@param pos vector3 The node position in the grid
-- @treturn number The node index
function M:get_index(pos)
-- Offset to left-top corner from node pivot
@ -203,8 +203,8 @@ end
--- Return grid index by node
-- @tparam StaticGrid self StaticGrid
-- @tparam node node The gui node in the grid
---@param self StaticGrid StaticGrid
---@param node node The gui node in the grid
-- @treturn number The node index
function M:get_index_by_node(node)
for index, grid_node in pairs(self.nodes) do
@ -223,8 +223,8 @@ end
--- Set grid anchor. Default anchor is equal to anchor of grid parent node
-- @tparam StaticGrid self StaticGrid
-- @tparam vector3 anchor Anchor
---@param self StaticGrid StaticGrid
---@param anchor vector3 Anchor
function M:set_anchor(anchor)
self.anchor = anchor
self:_update()
@ -232,7 +232,7 @@ end
--- Update grid content
-- @tparam StaticGrid self StaticGrid
---@param self StaticGrid StaticGrid
function M:refresh()
self:_update(true)
end
@ -270,11 +270,11 @@ end
--- Add new item to the grid
-- @tparam StaticGrid self StaticGrid
-- @tparam node item GUI node
-- @tparam number|nil index The item position. By default add as last item
-- @tparam number|nil shift_policy How shift nodes, if required. Default: const.SHIFT.RIGHT
-- @tparam boolean|nil is_instant If true, update node positions instantly
---@param self StaticGrid StaticGrid
---@param item node GUI node
---@param index number|nil The item position. By default add as last item
---@param shift_policy number|nil How shift nodes, if required. Default: const.SHIFT.RIGHT
---@param is_instant boolean|nil If true, update node positions instantly
function M:add(item, index, shift_policy, is_instant)
index = index or ((self.last_index or 0) + 1)
@ -295,8 +295,8 @@ end
--- Set new items to the grid. All previous items will be removed
-- @tparam StaticGrid self StaticGrid
-- @tparam node[] nodes The new grid nodes
---@param self StaticGrid StaticGrid
---@param nodes node[] The new grid nodes
-- @tparam[opt=false] boolean is_instant If true, update node positions instantly
function M:set_items(nodes, is_instant)
self.nodes = nodes
@ -312,10 +312,10 @@ end
--- Remove the item from the grid. Note that gui node will be not deleted
-- @tparam StaticGrid self StaticGrid
-- @tparam number index The grid node index to remove
-- @tparam number|nil shift_policy How shift nodes, if required. Default: const.SHIFT.RIGHT
-- @tparam boolean|nil is_instant If true, update node positions instantly
---@param self StaticGrid StaticGrid
---@param index number The grid node index to remove
---@param shift_policy number|nil How shift nodes, if required. Default: const.SHIFT.RIGHT
---@param is_instant boolean|nil If true, update node positions instantly
-- @treturn node The deleted gui node from grid
function M:remove(index, shift_policy, is_instant)
assert(self.nodes[index], "No grid item at given index " .. index)
@ -333,7 +333,7 @@ end
--- Return grid content size
-- @tparam StaticGrid self StaticGrid
---@param self StaticGrid StaticGrid
-- @treturn vector3 The grid content size
function M:get_size()
return vmath.vector3(
@ -366,7 +366,7 @@ end
--- Return grid content borders
-- @tparam StaticGrid self StaticGrid
---@param self StaticGrid StaticGrid
-- @treturn vector3 The grid content borders
function M:get_borders()
return self.border
@ -374,7 +374,7 @@ end
--- Return array of all node positions
-- @tparam StaticGrid self StaticGrid
---@param self StaticGrid StaticGrid
-- @treturn vector3[] All grid node positions
function M:get_all_pos()
local result = {}
@ -388,8 +388,8 @@ end
--- Change set position function for grid nodes. It will call on
-- update poses on grid elements. Default: gui.set_position
-- @tparam StaticGrid self StaticGrid
-- @tparam function callback Function on node set position
---@param self StaticGrid StaticGrid
---@param callback function Function on node set position
-- @treturn druid.static_grid Current grid instance
function M:set_position_function(callback)
self._set_position_function = callback or gui.set_position
@ -400,7 +400,7 @@ end
--- 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
-- @tparam StaticGrid self StaticGrid
---@param self StaticGrid StaticGrid
-- @treturn druid.static_grid Current grid instance
function M:clear()
self.border.x = 0
@ -419,7 +419,7 @@ end
--- Return StaticGrid offset, where StaticGrid content starts.
-- @tparam StaticGrid self StaticGrid The StaticGrid instance
---@param self StaticGrid StaticGrid The StaticGrid instance
-- @treturn vector3 The StaticGrid offset
function M:get_offset()
local borders = self:get_borders()
@ -435,8 +435,8 @@ end
--- Set new in_row elements for grid
-- @tparam StaticGrid self StaticGrid
-- @tparam number in_row The new in_row value
---@param self StaticGrid StaticGrid
---@param in_row number The new in_row value
-- @treturn druid.static_grid Current grid instance
function M:set_in_row(in_row)
self.in_row = in_row
@ -454,7 +454,7 @@ end
--- Set new node size for grid
-- @tparam StaticGrid self StaticGrid
---@param self StaticGrid StaticGrid
-- @tparam[opt] number width The new node width
-- @tparam[opt] number height The new node height
-- @treturn druid.static_grid Current grid instance
@ -479,8 +479,8 @@ end
--- Sort grid nodes by custom comparator function
-- @tparam StaticGrid self StaticGrid
-- @tparam function comparator The comparator function. (a, b) -> boolean
---@param self StaticGrid StaticGrid
---@param comparator function The comparator function. (a, b) -> boolean
-- @treturn druid.static_grid Current grid instance
function M:sort_nodes(comparator)
table.sort(self.nodes, comparator)
@ -489,8 +489,8 @@ end
--- Update grid inner state
-- @tparam StaticGrid self StaticGrid
-- @tparam boolean|nil is_instant If true, node position update instantly, otherwise with set_position_function callback
---@param self StaticGrid StaticGrid
---@param is_instant boolean|nil If true, node position update instantly, otherwise with set_position_function callback
---@private
function M:_update(is_instant)
self:_update_indexes()
@ -500,7 +500,7 @@ end
--- Update first and last indexes of grid nodes
-- @tparam StaticGrid self StaticGrid
---@param self StaticGrid StaticGrid
---@private
function M:_update_indexes()
self.first_index = nil
@ -516,7 +516,7 @@ end
--- Update grid content borders, recalculate min and max values
-- @tparam StaticGrid self StaticGrid
---@param self StaticGrid StaticGrid
---@private
function M:_update_borders()
if not self.first_index then
@ -535,8 +535,8 @@ end
--- Update grid nodes position
-- @tparam StaticGrid self StaticGrid
-- @tparam boolean|nil is_instant If true, node position update instantly, otherwise with set_position_function callback
---@param self StaticGrid StaticGrid
---@param is_instant boolean|nil If true, node position update instantly, otherwise with set_position_function callback
---@private
function M:_update_pos(is_instant)
local zero_offset = self:_get_zero_offset()

View File

@ -288,10 +288,10 @@ end
--- The Text constructor
-- @tparam Text self Text
-- @tparam string|node node Node name or GUI Text Node itself
-- @tparam string|nil value Initial text. Default value is node text from GUI scene. Default: nil
-- @tparam string|nil adjust_type Adjust type for text. By default is DOWNSCALE. Look const.TEXT_ADJUST for reference. Default: DOWNSCALE
---@param self Text Text
---@param node string|node Node name or GUI Text Node itself
---@param value string|nil Initial text. Default value is node text from GUI scene. Default: nil
---@param adjust_type string|nil Adjust type for text. By default is DOWNSCALE. Look const.TEXT_ADJUST for reference. Default: DOWNSCALE
function M:init(node, value, adjust_type)
self.node = self:get_node(node)
self.pos = gui.get_position(self.node)
@ -335,8 +335,8 @@ end
--- Calculate text width with font with respect to trailing space
-- @tparam Text self Text
-- @tparam string text|nil
---@param self Text Text
---@param text|nil string
-- @treturn number Width
-- @treturn number Height
function M:get_text_size(text)
@ -360,8 +360,8 @@ end
--- Get chars count by width
-- @tparam Text self Text
-- @tparam number width
---@param self Text Text
---@param width number
-- @treturn number Chars count
function M:get_text_index_by_width(width)
local text = self.last_value
@ -394,8 +394,8 @@ end
--- Set text to text field
-- @tparam Text self Text
-- @tparam string set_to Text for node
---@param self Text Text
---@param set_to string Text for node
-- @treturn Text Current text instance
function M:set_to(set_to)
set_to = set_to or ""
@ -412,8 +412,8 @@ end
--- Set text area size
-- @tparam Text self Text
-- @tparam vector3 size The new text area size
---@param self Text Text
---@param size vector3 The new text area size
-- @treturn Text Current text instance
function M:set_size(size)
self.start_size = size
@ -425,8 +425,8 @@ end
--- Set color
-- @tparam Text self Text
-- @tparam vector4 color Color for node
---@param self Text Text
---@param color vector4 Color for node
-- @treturn Text Current text instance
function M:set_color(color)
self.color = color
@ -437,8 +437,8 @@ end
--- Set alpha
-- @tparam Text self Text
-- @tparam number alpha Alpha for node
---@param self Text Text
---@param alpha number Alpha for node
-- @treturn Text Current text instance
function M:set_alpha(alpha)
self.color.w = alpha
@ -449,8 +449,8 @@ end
--- Set scale
-- @tparam Text self Text
-- @tparam vector3 scale Scale for node
---@param self Text Text
---@param scale vector3 Scale for node
-- @treturn Text Current text instance
function M:set_scale(scale)
self.last_scale = scale
@ -461,8 +461,8 @@ end
--- Set text pivot. Text will re-anchor inside text area
-- @tparam Text self Text
-- @tparam number pivot The gui.PIVOT_* constant
---@param self Text Text
---@param pivot number The gui.PIVOT_* constant
-- @treturn Text Current text instance
function M:set_pivot(pivot)
local prev_pivot = gui.get_pivot(self.node)
@ -487,7 +487,7 @@ end
--- Return true, if text with line break
-- @tparam Text self Text
---@param self Text Text
-- @treturn boolean Is text node with line break
function M:is_multiline()
return gui.get_line_break(self.node)
@ -495,9 +495,9 @@ end
--- Set text adjust, refresh the current text visuals, if needed
-- @tparam Text self Text
-- @tparam string|nil adjust_type See const.TEXT_ADJUST. If pass nil - use current adjust type
-- @tparam number|nil minimal_scale If pass nil - not use minimal scale
---@param self Text Text
---@param adjust_type string|nil See const.TEXT_ADJUST. If pass nil - use current adjust type
---@param minimal_scale number|nil If pass nil - not use minimal scale
-- @treturn Text Current text instance
function M:set_text_adjust(adjust_type, minimal_scale)
self.adjust_type = adjust_type
@ -509,8 +509,8 @@ end
--- Set minimal scale for DOWNSCALE_LIMITED or SCALE_THEN_SCROLL adjust types
-- @tparam Text self Text
-- @tparam number minimal_scale If pass nil - not use minimal scale
---@param self Text Text
---@param minimal_scale number If pass nil - not use minimal scale
-- @treturn Text Current text instance
function M:set_minimal_scale(minimal_scale)
self._minimal_scale = minimal_scale

View File

@ -278,11 +278,11 @@ end
--- Setup component context and his style table
-- @tparam BaseComponent self BaseComponent
-- @tparam table druid_instance The parent druid instance
-- @tparam table context Druid context. Usually it is self of script
-- @tparam table style Druid style module
-- @tparam table instance_class The component instance class
---@param self BaseComponent BaseComponent
---@param druid_instance table The parent druid instance
---@param context table Druid context. Usually it is self of script
---@param style table Druid style module
---@param instance_class table The component instance class
-- @treturn component BaseComponent itself
---@private
function M:setup_component(druid_instance, context, style, instance_class)
@ -310,7 +310,7 @@ end
--- Return true, if input priority was changed
-- @tparam BaseComponent self BaseComponent
---@param self BaseComponent BaseComponent
---@private
function M._is_input_priority_changed(self)
return self._component._is_input_priority_changed
@ -318,7 +318,7 @@ end
--- Reset is_input_priority_changed field
-- @tparam BaseComponent self BaseComponent
---@param self BaseComponent BaseComponent
---@private
function M._reset_input_priority_changed(self)
self._component._is_input_priority_changed = false
@ -326,7 +326,7 @@ end
--- Get current component interests
-- @tparam BaseComponent self BaseComponent
---@param self BaseComponent BaseComponent
-- @treturn table List of component interests
---@private
function M.__get_interests(self)
@ -369,8 +369,8 @@ end
--- Remove child from component children list
-- @tparam BaseComponent self BaseComponent
-- @tparam component child The druid component instance
---@param self BaseComponent BaseComponent
---@param child component The druid component instance
---@private
function M.__remove_child(self, child)
for i = #self._meta.children, 1, -1 do
@ -383,7 +383,7 @@ end
--- Return all children components, recursive
-- @tparam BaseComponent self BaseComponent
---@param self BaseComponent BaseComponent
-- @treturn table Array of childrens if the Druid component instance
function M.get_childrens(self)
local childrens = {}

View File

@ -263,8 +263,8 @@ end
--- Set placeholder text
-- @tparam RichInput self RichInput
-- @tparam string placeholder_text The placeholder text
---@param self RichInput RichInput
---@param placeholder_text string The placeholder text
function M:set_placeholder(placeholder_text)
self.placeholder:set_to(placeholder_text)
return self
@ -272,16 +272,16 @@ end
--- Select input field
-- @tparam RichInput self RichInput
---@param self RichInput RichInput
function M:select()
self.input:select()
end
--- Set input field text
-- @tparam RichInput self RichInput
---@param self RichInput RichInput
-- @treturn druid.input Current input instance
-- @tparam string text The input text
---@param text string The input text
function M:set_text(text)
self.input:set_text(text)
gui.set_enabled(self.placeholder.node, true and #self.input:get_text() == 0)
@ -291,8 +291,8 @@ end
--- Set input field font
-- @tparam RichInput self RichInput
-- @tparam hash font The font hash
---@param self RichInput RichInput
---@param font hash The font hash
-- @treturn druid.input Current input instance
function M:set_font(font)
gui.set_font(self.input.text.node, font)
@ -303,7 +303,7 @@ end
--- Set input field text
-- @tparam RichInput self RichInput
---@param self RichInput RichInput
function M:get_text()
return self.input:get_text()
end
@ -312,8 +312,8 @@ end
--- Set allowed charaters for input field.
-- See: https://defold.com/ref/stable/string/
-- ex: [%a%d] for alpha and numeric
-- @tparam RichInput self RichInput
-- @tparam string characters Regulax exp. for validate user input
---@param self RichInput RichInput
---@param characters string Regulax exp. for validate user input
-- @treturn RichInput Current instance
function M:set_allowed_characters(characters)
self.input:set_allowed_characters(characters)

View File

@ -85,9 +85,9 @@ local M = component.create("rich_text")
--- The RichText constructor
-- @tparam RichText self RichText
-- @tparam node|string text_node The text node to make Rich Text
-- @tparam string|nil value The initial text value. Default will be gui.get_text(text_node)
---@param self RichText RichText
---@param text_node node|string The text node to make Rich Text
---@param value string|nil The initial text value. Default will be gui.get_text(text_node)
function M:init(text_node, value)
self.root = self:get_node(text_node)
self.text_prefab = self.root
@ -126,8 +126,8 @@ end
--- Set text for Rich Text
-- @tparam RichText self RichText
-- @tparam string|nil text The text to set
---@param self RichText RichText
---@param text string|nil The text to set
-- @treturn druid.rich_text.word[] words
-- @treturn druid.rich_text.lines_metrics line_metrics
-- @usage
@ -189,7 +189,7 @@ end
--- Get current text
-- @tparam RichText self RichText
---@param self RichText RichText
-- @treturn string text
function M:get_text()
return self._last_value
@ -214,8 +214,8 @@ end
--- Get all words, which has a passed tag.
-- @tparam RichText self RichText
-- @tparam string tag
---@param self RichText RichText
---@param tag string
-- @treturn druid.rich_text.word[] words
function M:tagged(tag)
if not self._words then
@ -227,8 +227,8 @@ end
---Split a word into it's characters
-- @tparam RichText self RichText
-- @tparam druid.rich_text.word word
---@param self RichText RichText
---@param word druid.rich_text.word
-- @treturn druid.rich_text.word[] characters
function M:characters(word)
return rich_text.characters(word)

View File

@ -56,10 +56,10 @@ local M = component.create("data_list")
--- The DataList constructor
-- @tparam DataList self DataList
-- @tparam Scroll scroll The Scroll instance for Data List component
-- @tparam StaticGrid 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])
---@param self DataList DataList
---@param scroll Scroll The Scroll instance for Data List component
---@param grid StaticGrid The StaticGrid} or @{DynamicGrid instance for Data List component
---@param create_function function The create function callback(self, data, index, data_list). Function should return (node, [component])
function M:init(scroll, grid, create_function)
self.scroll = scroll
self.grid = grid
@ -87,7 +87,7 @@ end
--- Druid System on_remove function
-- @tparam DataList self DataList
---@param self DataList DataList
function M:on_remove()
self:clear()
self.scroll.on_scroll:unsubscribe(self._refresh, self)
@ -95,8 +95,8 @@ end
--- Set refresh function for DataList component
-- @tparam DataList self DataList
-- @tparam boolean is_use_cache Use cache version of DataList. Requires make setup of components in on_element_add callback and clean in on_element_remove
---@param self DataList DataList
---@param 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
-- @treturn druid.data_list Current DataList instance
function M:set_use_cache(is_use_cache)
self._is_use_cache = is_use_cache
@ -105,8 +105,8 @@ end
--- Set new data set for DataList component
-- @tparam DataList self DataList
-- @tparam table data The new data array
---@param self DataList DataList
---@param data table The new data array
-- @treturn druid.data_list Current DataList instance
function M:set_data(data)
self._data = data or {}
@ -117,7 +117,7 @@ end
--- Return current data from DataList component
-- @tparam DataList self DataList
---@param self DataList DataList
-- @treturn table The current data array
function M:get_data()
return self._data
@ -125,10 +125,10 @@ end
--- Add element to DataList. Currenly untested
-- @tparam DataList self DataList
-- @tparam table data
-- @tparam number|nil index
-- @tparam number|nil shift_policy The constant from const.SHIFT.*
---@param self DataList DataList
---@param data table
---@param index number|nil
---@param shift_policy number|nil The constant from const.SHIFT.*
function M:add(data, index, shift_policy)
index = index or #self._data + 1
shift_policy = shift_policy or const.SHIFT.RIGHT
@ -139,9 +139,9 @@ end
--- Remove element from DataList. Currenly untested
-- @tparam DataList self DataList
-- @tparam number|nil index
-- @tparam number|nil shift_policy The constant from const.SHIFT.*
---@param self DataList DataList
---@param index number|nil
---@param shift_policy number|nil The constant from const.SHIFT.*
function M:remove(index, shift_policy)
helper.remove_with_shift(self._data, index, shift_policy)
self:_refresh()
@ -149,9 +149,9 @@ end
--- Remove element from DataList by data value. Currenly untested
-- @tparam DataList self DataList
-- @tparam table data
-- @tparam number|nil shift_policy The constant from const.SHIFT.*
---@param self DataList DataList
---@param data table
---@param shift_policy number|nil The constant from const.SHIFT.*
function M:remove_by_data(data, shift_policy)
local index = helper.contains(self._data, data)
if index then
@ -162,7 +162,7 @@ end
--- Clear the DataList and refresh visuals
-- @tparam DataList self DataList
---@param self DataList DataList
function M:clear()
self._data = {}
self:_refresh()
@ -170,8 +170,8 @@ end
--- Return index for data value
-- @tparam DataList self DataList
-- @tparam table data
---@param self DataList DataList
---@param data table
function M:get_index(data)
for index, value in pairs(self._data) do
if value == data then
@ -184,7 +184,7 @@ end
--- Return all currenly created nodes in DataList
-- @tparam DataList self DataList
---@param self DataList DataList
-- @treturn node[] List of created nodes
function M:get_created_nodes()
local nodes = {}
@ -198,7 +198,7 @@ end
--- Return all currenly created components in DataList
-- @tparam DataList self DataList
---@param self DataList DataList
-- @treturn druid.base_component[] List of created nodes
function M:get_created_components()
local components = {}
@ -212,8 +212,8 @@ end
--- Instant scroll to element with passed index
-- @tparam DataList self DataList
-- @tparam number index
---@param self DataList DataList
---@param index number
function M:scroll_to_index(index)
local pos = self.grid:get_pos(index)
self.scroll:scroll_to(pos)
@ -221,8 +221,8 @@ end
--- Add element at passed index using cache or create new
-- @tparam DataList self DataList
-- @tparam number index
---@param self DataList DataList
---@param index number
---@private
function M:_add_at(index)
if self._data_visual[index] then
@ -255,8 +255,8 @@ end
--- Remove element from passed index and add it to cache if applicable
-- @tparam DataList self DataList
-- @tparam number index
---@param self DataList DataList
---@param index number
---@private
function M:_remove_at(index)
self.grid:remove(index, const.SHIFT.NO_SHIFT)
@ -286,7 +286,7 @@ end
--- Refresh all elements in DataList
-- @tparam DataList self DataList
---@param self DataList DataList
---@private
function M:_refresh()
self.scroll:set_size(self.grid:get_size_for(#self._data))

View File

@ -38,10 +38,10 @@ local M = component.create("hotkey")
--- 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 any|nil callback_argument The argument to pass into the callback function
---@param self Hotkey Hotkey
---@param keys string[]|string The keys to be pressed for trigger callback. Should contains one key and any modificator keys
---@param callback function The callback function
---@param callback_argument any|nil The argument to pass into the callback function
function M:init(keys, callback, callback_argument)
self.druid = self:get_druid()
@ -73,9 +73,9 @@ 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 any|nil callback_argument The argument to pass into the callback function
---@param self Hotkey Hotkey
---@param keys string[]|hash[]|string|hash that have to be pressed before key pressed to activate
---@param callback_argument any|nil The argument to pass into the callback function
-- @treturn Hotkey Current instance
function M:add_hotkey(keys, callback_argument)
keys = keys or {}
@ -174,8 +174,8 @@ end
--- If true, the callback will be triggered on action.repeated
-- @tparam Hotkey self Hotkey
-- @tparam bool is_enabled_repeated The flag value
---@param self Hotkey Hotkey
---@param is_enabled_repeated bool The flag value
-- @treturn Hotkey
function M:set_repeat(is_enabled_repeated)
self._is_process_repeated = is_enabled_repeated

View File

@ -109,8 +109,8 @@ M.ALLOWED_ACTIONS = {
}
--- Mask text by replacing every character with a mask character
-- @tparam string text
-- @tparam string mask
---@param text string
---@param mask string
-- @treturn string Masked text
local function mask_text(text, mask)
mask = mask or "*"
@ -156,10 +156,10 @@ end
--- 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
-- @tparam number|nil keyboard_type Gui keyboard type for input field
---@param self Input Input
---@param click_node node Node to enabled input component
---@param text_node node|Text Text node what will be changed on user input. You can pass text component instead of text node name Text
---@param keyboard_type number|nil Gui keyboard type for input field
function M:init(click_node, text_node, keyboard_type)
self.druid = self:get_druid()
@ -328,8 +328,8 @@ function M:get_text_selected()
end
--- Replace selected text with new text
-- @tparam Input self Input
-- @tparam string text The text to replace selected text
---@param self Input Input
---@param text string The text to replace selected text
-- @treturn string New input text
function M:get_text_selected_replaced(text)
local left_part = utf8.sub(self.value, 1, self.start_index)
@ -346,8 +346,8 @@ end
--- Set text for input field
-- @tparam Input self Input
-- @tparam string input_text The string to apply for input field
---@param self Input Input
---@param input_text string The string to apply for input field
function M:set_text(input_text)
input_text = tostring(input_text or "")
@ -395,7 +395,7 @@ end
--- Select input field. It will show the keyboard and trigger on_select events
-- @tparam Input self Input
---@param self Input Input
function M:select()
gui.reset_keyboard()
self.marked_value = ""
@ -420,7 +420,7 @@ end
--- Remove selection from input. It will hide the keyboard and trigger on_unselect events
-- @tparam Input self Input
---@param self Input Input
function M:unselect()
gui.reset_keyboard()
self.marked_value = ""
@ -439,7 +439,7 @@ end
--- Return current input field text
-- @tparam Input self Input
---@param self Input Input
-- @treturn string The current input field text
function M:get_text()
if self.marked_value ~= "" then
@ -452,8 +452,8 @@ end
--- Set maximum length for input field.
-- Pass nil to make input field unliminted (by default)
-- @tparam Input self Input
-- @tparam number max_length Maximum length for input text field
---@param self Input Input
---@param max_length number Maximum length for input text field
-- @treturn druid.input Current input instance
function M:set_max_length(max_length)
self.max_length = max_length
@ -464,8 +464,8 @@ end
--- Set allowed charaters for input field.
-- See: https://defold.com/ref/stable/string/
-- ex: [%a%d] for alpha and numeric
-- @tparam Input self Input
-- @tparam string characters Regulax exp. for validate user input
---@param self Input Input
---@param characters string Regulax exp. for validate user input
-- @treturn druid.input Current input instance
function M:set_allowed_characters(characters)
self.allowed_characters = characters
@ -474,7 +474,7 @@ end
--- Reset current input selection and return previous value
-- @tparam Input self Input
---@param self Input Input
-- @treturn druid.input Current input instance
function M:reset_changes()
self:set_text(self.previous_value)
@ -484,10 +484,10 @@ end
--- Set cursor position in input field
-- @tparam Input self Input
-- @tparam number|nil cursor_index Cursor index for cursor position, if nil - will be set to the end of the text
-- @tparam number|nil start_index Start index for cursor position, if nil - will be set to the end of the text
-- @tparam number|nil end_index End index for cursor position, if nil - will be set to the start_index
---@param self Input Input
---@param cursor_index number|nil Cursor index for cursor position, if nil - will be set to the end of the text
---@param start_index number|nil Start index for cursor position, if nil - will be set to the end of the text
---@param end_index number|nil End index for cursor position, if nil - will be set to the start_index
-- @treturn druid.input Current input instance
function M:select_cursor(cursor_index, start_index, end_index)
local len = utf8.len(self.value)
@ -507,10 +507,10 @@ end
--- Change cursor position by delta
-- @tparam Input self Input
-- @tparam number delta side for cursor position, -1 for left, 1 for right
-- @tparam boolean is_add_to_selection (Shift key)
-- @tparam boolean is_move_to_end (Ctrl key)
---@param self Input Input
---@param delta number side for cursor position, -1 for left, 1 for right
---@param is_add_to_selection boolean (Shift key)
---@param is_move_to_end boolean (Ctrl key)
function M:move_selection(delta, is_add_to_selection, is_move_to_end)
local len = utf8.len(self.value)
local cursor_index = self.cursor_index

View File

@ -42,10 +42,10 @@ local M = component.create("lang_text")
--- The LangText constructor
-- @tparam LangText self LangText
-- @tparam string|node node The node_id or gui.get_node(node_id)
-- @tparam string|nil locale_id Default locale id or text from node as default
-- @tparam string|nil adjust_type Adjust type for text. By default is DOWNSCALE. Look const.TEXT_ADJUST for reference
---@param self LangText LangText
---@param node string|node The node_id or gui.get_node(node_id)
---@param locale_id string|nil Default locale id or text from node as default
---@param adjust_type string|nil Adjust type for text. By default is DOWNSCALE. Look const.TEXT_ADJUST for reference
function M:init(node, locale_id, adjust_type)
self.druid = self:get_druid()
self.text = self.druid:new_text(node, locale_id, adjust_type)
@ -69,8 +69,8 @@ end
--- Setup raw text to lang_text component
-- @tparam LangText self LangText
-- @tparam string text Text for text node
---@param self LangText LangText
---@param text string Text for text node
-- @treturn LangText Current instance
function M:set_to(text)
self.last_locale = false
@ -82,15 +82,15 @@ end
--- Translate the text by locale_id
-- @tparam LangText self LangText
-- @tparam string locale_id Locale id
-- @tparam string|nil a Optional param to string.format
-- @tparam string|nil b Optional param to string.format
-- @tparam string|nil c Optional param to string.format
-- @tparam string|nil d Optional param to string.format
-- @tparam string|nil e Optional param to string.format
-- @tparam string|nil f Optional param to string.format
-- @tparam string|nil g Optional param to string.format
---@param self LangText LangText
---@param locale_id string Locale id
---@param a string|nil Optional param to string.format
---@param b string|nil Optional param to string.format
---@param c string|nil Optional param to string.format
---@param d string|nil Optional param to string.format
---@param e string|nil Optional param to string.format
---@param f string|nil Optional param to string.format
---@param g string|nil Optional param to string.format
-- @treturn LangText Current instance
function M:translate(locale_id, a, b, c, d, e, f, g)
self.last_locale_args = { a, b, c, d, e, f, g }
@ -102,14 +102,14 @@ end
--- Format string with new text params on localized text
-- @tparam LangText self LangText
-- @tparam string|nil a Optional param to string.format
-- @tparam string|nil b Optional param to string.format
-- @tparam string|nil c Optional param to string.format
-- @tparam string|nil d Optional param to string.format
-- @tparam string|nil e Optional param to string.format
-- @tparam string|nil f Optional param to string.format
-- @tparam string|nil g Optional param to string.format
---@param self LangText LangText
---@param a string|nil Optional param to string.format
---@param b string|nil Optional param to string.format
---@param c string|nil Optional param to string.format
---@param d string|nil Optional param to string.format
---@param e string|nil Optional param to string.format
---@param f string|nil Optional param to string.format
---@param g string|nil Optional param to string.format
-- @treturn LangText Current instance
function M:format(a, b, c, d, e, f, g)
self.last_locale_args = { a, b, c, d, e, f, g }

View File

@ -131,10 +131,10 @@ end
--- 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
-- @tparam number|nil init_value Initial value of progress bar. Default: 1
---@param self Progress Progress
---@param node string|node Node name or GUI Node itself.
---@param key string Progress bar direction: const.SIDE.X or const.SIDE.Y
---@param init_value number|nil Initial value of progress bar. Default: 1
function M:init(node, key, init_value)
assert(key == const.SIDE.X or const.SIDE.Y, "Progress bar key should be 'x' or 'y'")
@ -193,22 +193,22 @@ end
--- Fill a progress bar and stop progress animation
-- @tparam Progress self Progress
---@param self Progress Progress
function M:fill()
set_bar_to(self, 1, true)
end
--- Empty a progress bar
-- @tparam Progress self Progress
---@param self Progress Progress
function M:empty()
set_bar_to(self, 0, true)
end
--- Instant fill progress bar to value
-- @tparam Progress self Progress
-- @tparam number to Progress bar value, from 0 to 1
---@param self Progress Progress
---@param to number Progress bar value, from 0 to 1
function M:set_to(to)
to = helper.clamp(to, 0, 1)
set_bar_to(self, to)
@ -216,16 +216,16 @@ end
--- Return current progress bar value
-- @tparam Progress self Progress
---@param self Progress Progress
function M:get()
return self.last_value
end
--- Set points on progress bar to fire the callback
-- @tparam Progress self Progress
-- @tparam number[] steps Array of progress bar values
-- @tparam function callback Callback on intersect step value
---@param self Progress Progress
---@param steps number[] Array of progress bar values
---@param callback function Callback on intersect step value
-- @usage progress:set_steps({0, 0.3, 0.6, 1}, function(self, step) end)
function M:set_steps(steps, callback)
self.steps = steps
@ -234,9 +234,9 @@ end
--- Start animation of a progress bar
-- @tparam Progress self Progress
-- @tparam number to value between 0..1
-- @tparam function|nil callback Callback on animation ends
---@param self Progress Progress
---@param to number value between 0..1
---@param callback function|nil Callback on animation ends
function M:to(to, callback)
to = helper.clamp(to, 0, 1)
-- cause of float error
@ -253,8 +253,8 @@ end
--- Set progress bar max node size
-- @tparam Progress self Progress
-- @tparam vector3 max_size The new node maximum (full) size
---@param self Progress Progress
---@param max_size vector3 The new node maximum (full) size
-- @treturn Progress Progress
function M:set_max_size(max_size)
self.max_size[self.key] = max_size[self.key]

View File

@ -69,10 +69,10 @@ end
--- The Slider constructor
-- @tparam Slider self Slider
-- @tparam node node Gui pin node
-- @tparam vector3 end_pos The end position of slider
-- @tparam function|nil callback On slider change callback
---@param self Slider Slider
---@param node node Gui pin node
---@param end_pos vector3 The end position of slider
---@param callback function|nil On slider change callback
function M:init(node, end_pos, callback)
self.node = self:get_node(node)
@ -197,9 +197,9 @@ end
--- Set value for slider
-- @tparam Slider self Slider
-- @tparam number value Value from 0 to 1
-- @tparam boolean|nil is_silent Don't trigger event if true
---@param self Slider Slider
---@param value number Value from 0 to 1
---@param is_silent boolean|nil Don't trigger event if true
function M:set(value, is_silent)
value = helper.clamp(value, 0, 1)
set_position(self, value)
@ -212,8 +212,8 @@ end
--- Set slider steps. Pin node will
-- apply closest step position
-- @tparam Slider self Slider
-- @tparam number[] steps Array of steps
---@param self Slider Slider
---@param steps number[] Array of steps
-- @usage slider:set_steps({0, 0.2, 0.6, 1})
-- @treturn Slider Slider
function M:set_steps(steps)
@ -226,8 +226,8 @@ end
-- User can touch any place of node, pin instantly will
-- move at this position and node drag will start.
-- This function require the Defold version 1.3.0+
-- @tparam Slider self Slider
-- @tparam node|string|nil input_node
---@param self Slider Slider
---@param input_node node|string|nil
-- @treturn Slider Slider
function M:set_input_node(input_node)
self._input_node = self:get_node(input_node)
@ -236,15 +236,15 @@ end
--- Set Slider input enabled or disabled
-- @tparam Slider self Slider
-- @tparam boolean is_enabled
---@param self Slider Slider
---@param is_enabled boolean
function M:set_enabled(is_enabled)
self._is_enabled = is_enabled
end
--- Check if Slider component is enabled
-- @tparam Slider self Slider
---@param self Slider Slider
-- @treturn boolean
function M:is_enabled()
return self._is_enabled

View File

@ -10,10 +10,10 @@
-- @alias druid.swipe
--- Swipe node
-- @tparam node node
---@param node node
--- Restriction zone
-- @tparam node|nil click_zone
---@param click_zone node|nil
--- Trigger on swipe event(self, swipe_side, dist, delta_time)
-- @tfield druid.event on_swipe) druid.event
@ -160,8 +160,8 @@ end
--- Strict swipe click area. Useful for
-- restrict events outside stencil node
-- @tparam Swipe self Swipe
-- @tparam node|string|nil zone Gui node
---@param self Swipe Swipe
---@param zone node|string|nil Gui node
function M:set_click_zone(zone)
self.click_zone = self:get_node(zone)
end