Replace treturn

This commit is contained in:
Insality 2024-11-07 18:35:06 +01:00
parent 620facbe1f
commit b5ccd80215
13 changed files with 77 additions and 77 deletions

View File

@ -133,7 +133,7 @@ end
--- Return current hover state. True if touch action was on the node at current time
---@param self Hover Hover
-- @treturn boolean The current hovered state
---@return boolean The current hovered state
function M:is_hovered()
return self._is_hovered
end
@ -158,7 +158,7 @@ end
--- Return current hover state. True if nil action_id (usually desktop mouse) was on the node at current time
---@param self Hover Hover
-- @treturn boolean The current hovered state
---@return boolean The current hovered state
function M:is_mouse_hovered()
return self._is_mouse_hovered
end
@ -194,7 +194,7 @@ end
--- Return current hover enabled state
---@param self Hover Hover
-- @treturn boolean The hover enabled state
---@return boolean The hover enabled state
function M:is_enabled()
return self._is_enabled
end

View File

@ -337,7 +337,7 @@ end
--- Return current scroll progress status.
-- Values will be in [0..1] interval
---@param self Scroll Scroll
-- @treturn vector3 New vector with scroll progress values
---@return 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)
local y_perc = inverse_lerp(self.available_pos.w, self.available_pos.y, self.position.y)
@ -351,7 +351,7 @@ end
---@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
---@return druid.scroll Current scroll instance
function M:set_size(size, offset)
if offset then
self._offset = offset
@ -366,7 +366,7 @@ end
--- Set new scroll view size in case the node size was changed.
---@param self Scroll Scroll
---@param size vector3 The new size for view node
-- @treturn druid.scroll Current scroll instance
---@return druid.scroll Current scroll instance
function M:set_view_size(size)
gui.set_size(self.view_node, size)
self.view_size = size
@ -393,7 +393,7 @@ end
-- If no points, just simple drag without inertion
---@param self Scroll Scroll
---@param state boolean|nil Inert scroll state
-- @treturn druid.scroll Current scroll instance
---@return druid.scroll Current scroll instance
function M:set_inert(state)
self._is_inert = state
@ -403,7 +403,7 @@ end
--- Return if scroll have inertion.
---@param self Scroll Scroll
-- @treturn boolean @If scroll have inertion
---@return boolean @If scroll have inertion
function M:is_inert()
return self._is_inert
end
@ -413,7 +413,7 @@ end
-- Set 0 to disable stretching effect
---@param self Scroll Scroll
---@param stretch_size number|nil Size in pixels of additional scroll area
-- @treturn druid.scroll Current scroll instance
---@return druid.scroll Current scroll instance
function M:set_extra_stretch_size(stretch_size)
self.style.EXTRA_STRETCH_SIZE = stretch_size or 0
self:_update_size()
@ -424,7 +424,7 @@ end
--- Return vector of scroll size with width and height.
---@param self Scroll Scroll
-- @treturn vector3 Available scroll size
---@return vector3 Available scroll size
function M:get_scroll_size()
return self.available_size
end
@ -434,7 +434,7 @@ end
-- Scroll will always centered on closer points
---@param self Scroll Scroll
---@param points table Array of vector3 points
-- @treturn druid.scroll Current scroll instance
---@return druid.scroll Current scroll instance
function M:set_points(points)
self.points = points
@ -451,7 +451,7 @@ end
--- Lock or unlock horizontal scroll
---@param self Scroll Scroll
---@param state boolean|nil True, if horizontal scroll is enabled
-- @treturn druid.scroll Current scroll instance
---@return druid.scroll Current scroll instance
function M:set_horizontal_scroll(state)
self._is_horizontal_scroll = state
self.drag.can_x = self.available_size.x > 0 and state
@ -462,7 +462,7 @@ end
--- Lock or unlock vertical scroll
---@param self Scroll Scroll
---@param state boolean|nil True, if vertical scroll is enabled
-- @treturn druid.scroll Current scroll instance
---@return druid.scroll Current scroll instance
function M:set_vertical_scroll(state)
self._is_vertical_scroll = state
self.drag.can_y = self.available_size.y > 0 and state
@ -474,7 +474,7 @@ end
-- Extra border is not affected. Return true for elements in extra scroll zone
---@param self Scroll Scroll
---@param node node The node to check
-- @treturn boolean True if node in visible scroll area
---@return boolean True if node in visible scroll area
function M:is_node_in_view(node)
local node_offset_for_view = gui.get_position(node)
local parent = gui.get_parent(node)
@ -515,7 +515,7 @@ end
-- scroll size on grid changes
---@param self Scroll Scroll
---@param grid StaticGrid Druid grid component
-- @treturn druid.scroll Current scroll instance
---@return druid.scroll Current scroll instance
function M:bind_grid(grid)
if self._grid_on_change then
self._grid_on_change:unsubscribe(self._grid_on_change_callback)

View File

@ -167,7 +167,7 @@ local _temp_pos = vmath.vector3(0)
--- Return pos for grid node index
---@param self StaticGrid StaticGrid
---@param index number The grid element index
-- @treturn vector3 @Node position
---@return vector3 @Node position
function M:get_pos(index)
local row = math.ceil(index / self.in_row) - 1
local col = (index - row * self.in_row) - 1
@ -185,7 +185,7 @@ end
--- Return index for grid pos
---@param self StaticGrid StaticGrid
---@param pos vector3 The node position in the grid
-- @treturn number The node index
---@return number The node index
function M:get_index(pos)
-- Offset to left-top corner from node pivot
local node_offset_x = self.node_size.x * (-0.5 + self.node_pivot.x)
@ -205,7 +205,7 @@ end
--- Return grid index by node
---@param self StaticGrid StaticGrid
---@param node node The gui node in the grid
-- @treturn number The node index
---@return number The node index
function M:get_index_by_node(node)
for index, grid_node in pairs(self.nodes) do
if node == grid_node then
@ -316,7 +316,7 @@ end
---@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
---@return 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)
@ -334,7 +334,7 @@ end
--- Return grid content size
---@param self StaticGrid StaticGrid
-- @treturn vector3 The grid content size
---@return vector3 The grid content size
function M:get_size()
return vmath.vector3(
self.border.z - self.border.x,
@ -367,7 +367,7 @@ end
--- Return grid content borders
---@param self StaticGrid StaticGrid
-- @treturn vector3 The grid content borders
---@return vector3 The grid content borders
function M:get_borders()
return self.border
end
@ -375,7 +375,7 @@ end
--- Return array of all node positions
---@param self StaticGrid StaticGrid
-- @treturn vector3[] All grid node positions
---@return vector3[] All grid node positions
function M:get_all_pos()
local result = {}
for i, node in pairs(self.nodes) do
@ -390,7 +390,7 @@ end
-- update poses on grid elements. Default: gui.set_position
---@param self StaticGrid StaticGrid
---@param callback function Function on node set position
-- @treturn druid.static_grid Current grid instance
---@return druid.static_grid Current grid instance
function M:set_position_function(callback)
self._set_position_function = callback or gui.set_position
@ -401,7 +401,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
---@param self StaticGrid StaticGrid
-- @treturn druid.static_grid Current grid instance
---@return druid.static_grid Current grid instance
function M:clear()
self.border.x = 0
self.border.y = 0
@ -420,7 +420,7 @@ end
--- Return StaticGrid offset, where StaticGrid content starts.
---@param self StaticGrid StaticGrid The StaticGrid instance
-- @treturn vector3 The StaticGrid offset
---@return vector3 The StaticGrid offset
function M:get_offset()
local borders = self:get_borders()
local size = self:get_size()
@ -437,7 +437,7 @@ end
--- Set new in_row elements for grid
---@param self StaticGrid StaticGrid
---@param in_row number The new in_row value
-- @treturn druid.static_grid Current grid instance
---@return druid.static_grid Current grid instance
function M:set_in_row(in_row)
self.in_row = in_row
self._grid_horizonal_offset = self.node_size.x * (self.in_row - 1) * self.anchor.x
@ -457,7 +457,7 @@ end
---@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
---@return druid.static_grid Current grid instance
function M:set_item_size(width, height)
if width then
self.node_size.x = width
@ -481,7 +481,7 @@ end
--- Sort grid nodes by custom comparator function
---@param self StaticGrid StaticGrid
---@param comparator function The comparator function. (a, b) -> boolean
-- @treturn druid.static_grid Current grid instance
---@return druid.static_grid Current grid instance
function M:sort_nodes(comparator)
table.sort(self.nodes, comparator)
self:_update(true)
@ -559,7 +559,7 @@ end
--- Return elements offset for correct posing nodes. Correct posing at
-- parent pivot node (0:0) with adjusting of node sizes and anchoring
-- @treturn vector3 The offset vector
---@return vector3 The offset vector
---@private
function M:_get_zero_offset()
if not self.style.IS_DYNAMIC_NODE_POSES then
@ -576,7 +576,7 @@ end
--- Return offset x for last row in grid. Used to align this row accorting to grid's anchor
-- @treturn number The offset x value
---@return number The offset x value
---@private
function M:_get_zero_offset_x(row_index)
if not self.style.IS_DYNAMIC_NODE_POSES or not self.style.IS_ALIGN_LAST_ROW then

View File

@ -337,8 +337,8 @@ end
--- Calculate text width with font with respect to trailing space
---@param self Text Text
---@param text|nil string
-- @treturn number Width
-- @treturn number Height
---@return number Width
---@return number Height
function M:get_text_size(text)
text = text or self.last_value
local font_name = gui.get_font(self.node)
@ -362,7 +362,7 @@ end
--- Get chars count by width
---@param self Text Text
---@param width number
-- @treturn number Chars count
---@return number Chars count
function M:get_text_index_by_width(width)
local text = self.last_value
local font_name = gui.get_font(self.node)
@ -396,7 +396,7 @@ end
--- Set text to text field
---@param self Text Text
---@param set_to string Text for node
-- @treturn Text Current text instance
---@return Text Current text instance
function M:set_to(set_to)
set_to = set_to or ""
@ -414,7 +414,7 @@ end
--- Set text area size
---@param self Text Text
---@param size vector3 The new text area size
-- @treturn Text Current text instance
---@return Text Current text instance
function M:set_size(size)
self.start_size = size
self.text_area = vmath.vector3(size)
@ -427,7 +427,7 @@ end
--- Set color
---@param self Text Text
---@param color vector4 Color for node
-- @treturn Text Current text instance
---@return Text Current text instance
function M:set_color(color)
self.color = color
gui.set_color(self.node, color)
@ -439,7 +439,7 @@ end
--- Set alpha
---@param self Text Text
---@param alpha number Alpha for node
-- @treturn Text Current text instance
---@return Text Current text instance
function M:set_alpha(alpha)
self.color.w = alpha
gui.set_color(self.node, self.color)
@ -451,7 +451,7 @@ end
--- Set scale
---@param self Text Text
---@param scale vector3 Scale for node
-- @treturn Text Current text instance
---@return Text Current text instance
function M:set_scale(scale)
self.last_scale = scale
gui.set_scale(self.node, scale)
@ -463,7 +463,7 @@ end
--- Set text pivot. Text will re-anchor inside text area
---@param self Text Text
---@param pivot number The gui.PIVOT_* constant
-- @treturn Text Current text instance
---@return Text Current text instance
function M:set_pivot(pivot)
local prev_pivot = gui.get_pivot(self.node)
local prev_offset = const.PIVOTS[prev_pivot]
@ -488,7 +488,7 @@ end
--- Return true, if text with line break
---@param self Text Text
-- @treturn boolean Is text node with line break
---@return boolean Is text node with line break
function M:is_multiline()
return gui.get_line_break(self.node)
end
@ -498,7 +498,7 @@ end
---@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
---@return Text Current text instance
function M:set_text_adjust(adjust_type, minimal_scale)
self.adjust_type = adjust_type
self._minimal_scale = minimal_scale
@ -511,7 +511,7 @@ end
--- Set minimal scale for DOWNSCALE_LIMITED or SCALE_THEN_SCROLL adjust types
---@param self Text Text
---@param minimal_scale number If pass nil - not use minimal scale
-- @treturn Text Current text instance
---@return Text Current text instance
function M:set_minimal_scale(minimal_scale)
self._minimal_scale = minimal_scale
@ -520,7 +520,7 @@ end
--- Return current text adjust type
-- @treturn number The current text adjust type
---@return number The current text adjust type
function M:get_text_adjust(adjust_type)
return self.adjust_type
end

View File

@ -283,7 +283,7 @@ end
---@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
---@return component BaseComponent itself
---@private
function M:setup_component(druid_instance, context, style, instance_class)
self._meta = {
@ -327,7 +327,7 @@ end
--- Get current component interests
---@param self BaseComponent BaseComponent
-- @treturn table List of component interests
---@return table List of component interests
---@private
function M.__get_interests(self)
local instance_class = self._meta.instance_class
@ -384,7 +384,7 @@ end
--- Return all children components, recursive
---@param self BaseComponent BaseComponent
-- @treturn table Array of childrens if the Druid component instance
---@return table Array of childrens if the Druid component instance
function M.get_childrens(self)
local childrens = {}

View File

@ -280,7 +280,7 @@ end
--- Set input field text
---@param self RichInput RichInput
-- @treturn druid.input Current input instance
---@return druid.input Current input instance
---@param text string The input text
function M:set_text(text)
self.input:set_text(text)
@ -293,7 +293,7 @@ end
--- Set input field font
---@param self RichInput RichInput
---@param font hash The font hash
-- @treturn druid.input Current input instance
---@return druid.input Current input instance
function M:set_font(font)
gui.set_font(self.input.text.node, font)
gui.set_font(self.placeholder.node, font)
@ -314,7 +314,7 @@ end
-- ex: [%a%d] for alpha and numeric
---@param self RichInput RichInput
---@param characters string Regulax exp. for validate user input
-- @treturn RichInput Current instance
---@return RichInput Current instance
function M:set_allowed_characters(characters)
self.input:set_allowed_characters(characters)

View File

@ -128,8 +128,8 @@ end
--- Set text for Rich Text
---@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
---@return druid.rich_text.word[] words
---@return druid.rich_text.lines_metrics line_metrics
-- @usage
-- • color: Change text color
--
@ -190,7 +190,7 @@ end
--- Get current text
---@param self RichText RichText
-- @treturn string text
---@return string text
function M:get_text()
return self._last_value
end
@ -216,7 +216,7 @@ end
--- Get all words, which has a passed tag.
---@param self RichText RichText
---@param tag string
-- @treturn druid.rich_text.word[] words
---@return druid.rich_text.word[] words
function M:tagged(tag)
if not self._words then
return
@ -229,21 +229,21 @@ end
---Split a word into it's characters
---@param self RichText RichText
---@param word druid.rich_text.word
-- @treturn druid.rich_text.word[] characters
---@return druid.rich_text.word[] characters
function M:characters(word)
return rich_text.characters(word)
end
--- Get all current words.
-- @treturn table druid.rich_text.word[]
---@return table druid.rich_text.word[]
function M:get_words()
return self._words
end
--- Get current line metrics
--- @treturn druid.rich_text.lines_metrics
----@return druid.rich_text.lines_metrics
function M:get_line_metric()
return self._line_metrics
end

View File

@ -97,7 +97,7 @@ end
--- Set refresh function for DataList component
---@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
---@return druid.data_list Current DataList instance
function M:set_use_cache(is_use_cache)
self._is_use_cache = is_use_cache
return self
@ -107,7 +107,7 @@ end
--- Set new data set for DataList component
---@param self DataList DataList
---@param data table The new data array
-- @treturn druid.data_list Current DataList instance
---@return druid.data_list Current DataList instance
function M:set_data(data)
self._data = data or {}
self:_refresh()
@ -118,7 +118,7 @@ end
--- Return current data from DataList component
---@param self DataList DataList
-- @treturn table The current data array
---@return table The current data array
function M:get_data()
return self._data
end
@ -185,7 +185,7 @@ end
--- Return all currenly created nodes in DataList
---@param self DataList DataList
-- @treturn node[] List of created nodes
---@return node[] List of created nodes
function M:get_created_nodes()
local nodes = {}
@ -199,7 +199,7 @@ end
--- Return all currenly created components in DataList
---@param self DataList DataList
-- @treturn druid.base_component[] List of created nodes
---@return druid.base_component[] List of created nodes
function M:get_created_components()
local components = {}

View File

@ -76,7 +76,7 @@ end
---@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
---@return Hotkey Current instance
function M:add_hotkey(keys, callback_argument)
keys = keys or {}
if type(keys) == "string" then
@ -176,7 +176,7 @@ end
--- If true, the callback will be triggered on action.repeated
---@param self Hotkey Hotkey
---@param is_enabled_repeated bool The flag value
-- @treturn Hotkey
---@return Hotkey
function M:set_repeat(is_enabled_repeated)
self._is_process_repeated = is_enabled_repeated
return self

View File

@ -111,7 +111,7 @@ M.ALLOWED_ACTIONS = {
--- Mask text by replacing every character with a mask character
---@param text string
---@param mask string
-- @treturn string Masked text
---@return string Masked text
local function mask_text(text, mask)
mask = mask or "*"
local masked_text = ""
@ -330,7 +330,7 @@ end
--- Replace selected text with new text
---@param self Input Input
---@param text string The text to replace selected text
-- @treturn string New input text
---@return string New input text
function M:get_text_selected_replaced(text)
local left_part = utf8.sub(self.value, 1, self.start_index)
local right_part = utf8.sub(self.value, self.end_index + 1, utf8.len(self.value))
@ -440,7 +440,7 @@ end
--- Return current input field text
---@param self Input Input
-- @treturn string The current input field text
---@return string The current input field text
function M:get_text()
if self.marked_value ~= "" then
return self.value .. self.marked_value
@ -454,7 +454,7 @@ end
-- Pass nil to make input field unliminted (by default)
---@param self Input Input
---@param max_length number Maximum length for input text field
-- @treturn druid.input Current input instance
---@return druid.input Current input instance
function M:set_max_length(max_length)
self.max_length = max_length
return self
@ -466,7 +466,7 @@ end
-- ex: [%a%d] for alpha and numeric
---@param self Input Input
---@param characters string Regulax exp. for validate user input
-- @treturn druid.input Current input instance
---@return druid.input Current input instance
function M:set_allowed_characters(characters)
self.allowed_characters = characters
return self
@ -475,7 +475,7 @@ end
--- Reset current input selection and return previous value
---@param self Input Input
-- @treturn druid.input Current input instance
---@return druid.input Current input instance
function M:reset_changes()
self:set_text(self.previous_value)
self:unselect()
@ -488,7 +488,7 @@ end
---@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
---@return druid.input Current input instance
function M:select_cursor(cursor_index, start_index, end_index)
local len = utf8.len(self.value)

View File

@ -71,7 +71,7 @@ end
--- Setup raw text to lang_text component
---@param self LangText LangText
---@param text string Text for text node
-- @treturn LangText Current instance
---@return LangText Current instance
function M:set_to(text)
self.last_locale = false
self.text:set_to(text)
@ -91,7 +91,7 @@ end
---@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
---@return 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 }
self.last_locale = locale_id or self.last_locale
@ -110,7 +110,7 @@ end
---@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
---@return LangText Current instance
function M:format(a, b, c, d, e, f, g)
self.last_locale_args = { a, b, c, d, e, f, g }
self.text:set_to(settings.get_text(self.last_locale, a, b, c, d, e, f, g) or "")

View File

@ -255,7 +255,7 @@ end
--- Set progress bar max node size
---@param self Progress Progress
---@param max_size vector3 The new node maximum (full) size
-- @treturn Progress Progress
---@return Progress Progress
function M:set_max_size(max_size)
self.max_size[self.key] = max_size[self.key]
self:set_to(self.last_value)

View File

@ -215,7 +215,7 @@ end
---@param self Slider Slider
---@param steps number[] Array of steps
-- @usage slider:set_steps({0, 0.2, 0.6, 1})
-- @treturn Slider Slider
---@return Slider Slider
function M:set_steps(steps)
self.steps = steps
return self
@ -228,7 +228,7 @@ end
-- This function require the Defold version 1.3.0+
---@param self Slider Slider
---@param input_node node|string|nil
-- @treturn Slider Slider
---@return Slider Slider
function M:set_input_node(input_node)
self._input_node = self:get_node(input_node)
return self
@ -245,7 +245,7 @@ end
--- Check if Slider component is enabled
---@param self Slider Slider
-- @treturn boolean
---@return boolean
function M:is_enabled()
return self._is_enabled
end