Skip to content

Commit

Permalink
Replace treturn
Browse files Browse the repository at this point in the history
  • Loading branch information
Insality committed Nov 7, 2024
1 parent 620facb commit b5ccd80
Show file tree
Hide file tree
Showing 13 changed files with 77 additions and 77 deletions.
6 changes: 3 additions & 3 deletions druid/base/hover.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
24 changes: 12 additions & 12 deletions druid/base/scroll.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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

Expand All @@ -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
Expand All @@ -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()
Expand All @@ -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
Expand All @@ -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

Expand All @@ -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
Expand All @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
30 changes: 15 additions & 15 deletions druid/base/static_grid.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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)

Expand All @@ -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,
Expand Down Expand Up @@ -367,15 +367,15 @@ 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


--- 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
Expand All @@ -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

Expand All @@ -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
Expand All @@ -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()
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
26 changes: 13 additions & 13 deletions druid/base/text.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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 ""

Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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]
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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

Expand All @@ -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
Expand Down
Loading

0 comments on commit b5ccd80

Please sign in to comment.