mirror of
https://github.com/Insality/druid.git
synced 2025-09-27 18:12:19 +02:00
Update annotations
This commit is contained in:
@@ -35,7 +35,6 @@ local M = component.create("hover")
|
||||
|
||||
|
||||
--- The Hover constructor
|
||||
---@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
|
||||
@@ -115,7 +114,6 @@ end
|
||||
|
||||
|
||||
--- Set hover state
|
||||
---@param self Hover Hover
|
||||
---@param state boolean|nil The hover state
|
||||
function M:set_hover(state)
|
||||
if self._is_hovered == state then
|
||||
@@ -132,7 +130,6 @@ end
|
||||
|
||||
|
||||
--- Return current hover state. True if touch action was on the node at current time
|
||||
---@param self Hover Hover
|
||||
---@return boolean The current hovered state
|
||||
function M:is_hovered()
|
||||
return self._is_hovered
|
||||
@@ -140,7 +137,6 @@ end
|
||||
|
||||
|
||||
--- Set 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
|
||||
@@ -157,7 +153,6 @@ end
|
||||
|
||||
|
||||
--- Return current hover state. True if nil action_id (usually desktop mouse) was on the node at current time
|
||||
---@param self Hover Hover
|
||||
---@return boolean The current hovered state
|
||||
function M:is_mouse_hovered()
|
||||
return self._is_mouse_hovered
|
||||
@@ -166,7 +161,6 @@ end
|
||||
|
||||
--- Strict hover click area. Useful for
|
||||
-- no click events outside stencil 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)
|
||||
@@ -176,7 +170,6 @@ end
|
||||
--- Set enable state of hover component.
|
||||
-- If hover is not enabled, it will not generate
|
||||
-- any hover events
|
||||
---@param self Hover Hover
|
||||
---@param state boolean|nil The hover enabled state
|
||||
function M:set_enabled(state)
|
||||
self._is_enabled = state
|
||||
@@ -193,7 +186,6 @@ end
|
||||
|
||||
|
||||
--- Return current hover enabled state
|
||||
---@param self Hover Hover
|
||||
---@return boolean The hover enabled state
|
||||
function M:is_enabled()
|
||||
return self._is_enabled
|
||||
|
@@ -171,7 +171,6 @@ end
|
||||
|
||||
|
||||
--- The Scroll constructor
|
||||
---@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)
|
||||
@@ -253,7 +252,6 @@ end
|
||||
|
||||
|
||||
--- Start scroll to target point.
|
||||
---@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))
|
||||
@@ -287,7 +285,6 @@ end
|
||||
|
||||
|
||||
--- Scroll to item in scroll by point index.
|
||||
---@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)
|
||||
@@ -310,7 +307,6 @@ end
|
||||
|
||||
|
||||
--- Start scroll to target scroll percent
|
||||
---@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))
|
||||
@@ -336,7 +332,6 @@ end
|
||||
|
||||
--- Return current scroll progress status.
|
||||
-- Values will be in [0..1] interval
|
||||
---@param self Scroll Scroll
|
||||
---@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)
|
||||
@@ -348,7 +343,6 @@ end
|
||||
|
||||
--- Set scroll content size.
|
||||
-- It will change content gui node size
|
||||
---@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
|
||||
---@return druid.scroll Current scroll instance
|
||||
@@ -364,7 +358,6 @@ 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
|
||||
---@return druid.scroll Current scroll instance
|
||||
function M:set_view_size(size)
|
||||
@@ -378,7 +371,6 @@ end
|
||||
|
||||
|
||||
--- Refresh scroll view size
|
||||
---@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,7 +383,6 @@ end
|
||||
--- Enable or disable scroll inert.
|
||||
-- If disabled, scroll through points (if exist)
|
||||
-- If no points, just simple drag without inertion
|
||||
---@param self Scroll Scroll
|
||||
---@param state boolean|nil Inert scroll state
|
||||
---@return druid.scroll Current scroll instance
|
||||
function M:set_inert(state)
|
||||
@@ -402,7 +393,6 @@ end
|
||||
|
||||
|
||||
--- Return if scroll have inertion.
|
||||
---@param self Scroll Scroll
|
||||
---@return boolean @If scroll have inertion
|
||||
function M:is_inert()
|
||||
return self._is_inert
|
||||
@@ -411,7 +401,6 @@ end
|
||||
|
||||
--- Set extra size for scroll stretching.
|
||||
-- Set 0 to disable stretching effect
|
||||
---@param self Scroll Scroll
|
||||
---@param stretch_size number|nil Size in pixels of additional scroll area
|
||||
---@return druid.scroll Current scroll instance
|
||||
function M:set_extra_stretch_size(stretch_size)
|
||||
@@ -423,7 +412,6 @@ end
|
||||
|
||||
|
||||
--- Return vector of scroll size with width and height.
|
||||
---@param self Scroll Scroll
|
||||
---@return vector3 Available scroll size
|
||||
function M:get_scroll_size()
|
||||
return self.available_size
|
||||
@@ -432,7 +420,6 @@ end
|
||||
|
||||
--- Set points of interest.
|
||||
-- Scroll will always centered on closer points
|
||||
---@param self Scroll Scroll
|
||||
---@param points table Array of vector3 points
|
||||
---@return druid.scroll Current scroll instance
|
||||
function M:set_points(points)
|
||||
@@ -449,7 +436,6 @@ end
|
||||
|
||||
|
||||
--- Lock or unlock horizontal scroll
|
||||
---@param self Scroll Scroll
|
||||
---@param state boolean|nil True, if horizontal scroll is enabled
|
||||
---@return druid.scroll Current scroll instance
|
||||
function M:set_horizontal_scroll(state)
|
||||
@@ -460,7 +446,6 @@ end
|
||||
|
||||
|
||||
--- Lock or unlock vertical scroll
|
||||
---@param self Scroll Scroll
|
||||
---@param state boolean|nil True, if vertical scroll is enabled
|
||||
---@return druid.scroll Current scroll instance
|
||||
function M:set_vertical_scroll(state)
|
||||
@@ -472,7 +457,6 @@ end
|
||||
|
||||
--- Check node if it visible now on scroll.
|
||||
-- Extra border is not affected. Return true for elements in extra scroll zone
|
||||
---@param self Scroll Scroll
|
||||
---@param node node The node to check
|
||||
---@return boolean True if node in visible scroll area
|
||||
function M:is_node_in_view(node)
|
||||
@@ -513,8 +497,7 @@ end
|
||||
|
||||
--- Bind the grid component (Static or Dynamic) to recalculate
|
||||
-- scroll size on grid changes
|
||||
---@param self Scroll Scroll
|
||||
---@param grid StaticGrid Druid grid component
|
||||
---@param grid druid.grid Druid grid component
|
||||
---@return druid.scroll Current scroll instance
|
||||
function M:bind_grid(grid)
|
||||
if self._grid_on_change then
|
||||
@@ -542,7 +525,6 @@ end
|
||||
|
||||
--- Strict drag scroll area. Useful for
|
||||
-- restrict events outside stencil node
|
||||
---@param self Drag
|
||||
---@param node node|string Gui node
|
||||
function M:set_click_zone(node)
|
||||
self.drag:set_click_zone(node)
|
||||
|
@@ -128,7 +128,6 @@ end
|
||||
|
||||
|
||||
--- The StaticGrid constructor
|
||||
---@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
|
||||
@@ -165,7 +164,6 @@ end
|
||||
|
||||
local _temp_pos = vmath.vector3(0)
|
||||
--- Return pos for grid node index
|
||||
---@param self StaticGrid StaticGrid
|
||||
---@param index number The grid element index
|
||||
---@return vector3 @Node position
|
||||
function M:get_pos(index)
|
||||
@@ -183,7 +181,6 @@ end
|
||||
|
||||
|
||||
--- Return index for grid pos
|
||||
---@param self StaticGrid StaticGrid
|
||||
---@param pos vector3 The node position in the grid
|
||||
---@return number The node index
|
||||
function M:get_index(pos)
|
||||
@@ -203,7 +200,6 @@ end
|
||||
|
||||
|
||||
--- Return grid index by node
|
||||
---@param self StaticGrid StaticGrid
|
||||
---@param node node The gui node in the grid
|
||||
---@return number The node index
|
||||
function M:get_index_by_node(node)
|
||||
@@ -223,7 +219,6 @@ end
|
||||
|
||||
|
||||
--- Set grid anchor. Default anchor is equal to anchor of grid parent node
|
||||
---@param self StaticGrid StaticGrid
|
||||
---@param anchor vector3 Anchor
|
||||
function M:set_anchor(anchor)
|
||||
self.anchor = anchor
|
||||
@@ -232,7 +227,6 @@ end
|
||||
|
||||
|
||||
--- Update grid content
|
||||
---@param self StaticGrid StaticGrid
|
||||
function M:refresh()
|
||||
self:_update(true)
|
||||
end
|
||||
@@ -270,7 +264,6 @@ end
|
||||
|
||||
|
||||
--- Add new item to the grid
|
||||
---@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
|
||||
@@ -295,7 +288,6 @@ end
|
||||
|
||||
|
||||
--- Set new items to the grid. All previous items will be removed
|
||||
---@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)
|
||||
@@ -312,7 +304,6 @@ end
|
||||
|
||||
|
||||
--- Remove the item from the grid. Note that gui node will be not deleted
|
||||
---@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
|
||||
@@ -333,7 +324,6 @@ end
|
||||
|
||||
|
||||
--- Return grid content size
|
||||
---@param self StaticGrid StaticGrid
|
||||
---@return vector3 The grid content size
|
||||
function M:get_size()
|
||||
return vmath.vector3(
|
||||
@@ -366,7 +356,6 @@ end
|
||||
|
||||
|
||||
--- Return grid content borders
|
||||
---@param self StaticGrid StaticGrid
|
||||
---@return vector3 The grid content borders
|
||||
function M:get_borders()
|
||||
return self.border
|
||||
@@ -374,7 +363,6 @@ end
|
||||
|
||||
|
||||
--- Return array of all node positions
|
||||
---@param self StaticGrid StaticGrid
|
||||
---@return vector3[] All grid node positions
|
||||
function M:get_all_pos()
|
||||
local result = {}
|
||||
@@ -388,7 +376,6 @@ end
|
||||
|
||||
--- Change set position function for grid nodes. It will call on
|
||||
-- update poses on grid elements. Default: gui.set_position
|
||||
---@param self StaticGrid StaticGrid
|
||||
---@param callback function Function on node set position
|
||||
---@return druid.static_grid Current grid instance
|
||||
function M:set_position_function(callback)
|
||||
@@ -400,7 +387,6 @@ 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
|
||||
---@return druid.static_grid Current grid instance
|
||||
function M:clear()
|
||||
self.border.x = 0
|
||||
@@ -419,7 +405,6 @@ end
|
||||
|
||||
|
||||
--- Return StaticGrid offset, where StaticGrid content starts.
|
||||
---@param self StaticGrid StaticGrid The StaticGrid instance
|
||||
---@return vector3 The StaticGrid offset
|
||||
function M:get_offset()
|
||||
local borders = self:get_borders()
|
||||
@@ -435,7 +420,6 @@ end
|
||||
|
||||
|
||||
--- Set new in_row elements for grid
|
||||
---@param self StaticGrid StaticGrid
|
||||
---@param in_row number The new in_row value
|
||||
---@return druid.static_grid Current grid instance
|
||||
function M:set_in_row(in_row)
|
||||
@@ -454,7 +438,6 @@ end
|
||||
|
||||
|
||||
--- Set new node size for grid
|
||||
---@param self StaticGrid StaticGrid
|
||||
-- @tparam[opt] number width The new node width
|
||||
-- @tparam[opt] number height The new node height
|
||||
---@return druid.static_grid Current grid instance
|
||||
@@ -479,7 +462,6 @@ end
|
||||
|
||||
|
||||
--- Sort grid nodes by custom comparator function
|
||||
---@param self StaticGrid StaticGrid
|
||||
---@param comparator function The comparator function. (a, b) -> boolean
|
||||
---@return druid.static_grid Current grid instance
|
||||
function M:sort_nodes(comparator)
|
||||
@@ -489,7 +471,6 @@ end
|
||||
|
||||
|
||||
--- Update grid inner state
|
||||
---@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)
|
||||
@@ -500,7 +481,6 @@ end
|
||||
|
||||
|
||||
--- Update first and last indexes of grid nodes
|
||||
---@param self StaticGrid StaticGrid
|
||||
---@private
|
||||
function M:_update_indexes()
|
||||
self.first_index = nil
|
||||
@@ -516,7 +496,6 @@ end
|
||||
|
||||
|
||||
--- Update grid content borders, recalculate min and max values
|
||||
---@param self StaticGrid StaticGrid
|
||||
---@private
|
||||
function M:_update_borders()
|
||||
if not self.first_index then
|
||||
@@ -535,7 +514,6 @@ end
|
||||
|
||||
|
||||
--- Update grid nodes position
|
||||
---@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)
|
||||
|
@@ -288,7 +288,6 @@ end
|
||||
|
||||
|
||||
--- The Text constructor
|
||||
---@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
|
||||
@@ -335,7 +334,6 @@ end
|
||||
|
||||
|
||||
--- Calculate text width with font with respect to trailing space
|
||||
---@param self Text Text
|
||||
---@param text|nil string
|
||||
---@return number Width
|
||||
---@return number Height
|
||||
@@ -360,7 +358,6 @@ end
|
||||
|
||||
|
||||
--- Get chars count by width
|
||||
---@param self Text Text
|
||||
---@param width number
|
||||
---@return number Chars count
|
||||
function M:get_text_index_by_width(width)
|
||||
@@ -394,7 +391,6 @@ end
|
||||
|
||||
|
||||
--- Set text to text field
|
||||
---@param self Text Text
|
||||
---@param set_to string Text for node
|
||||
---@return Text Current text instance
|
||||
function M:set_to(set_to)
|
||||
@@ -412,7 +408,6 @@ end
|
||||
|
||||
|
||||
--- Set text area size
|
||||
---@param self Text Text
|
||||
---@param size vector3 The new text area size
|
||||
---@return Text Current text instance
|
||||
function M:set_size(size)
|
||||
@@ -425,7 +420,6 @@ end
|
||||
|
||||
|
||||
--- Set color
|
||||
---@param self Text Text
|
||||
---@param color vector4 Color for node
|
||||
---@return Text Current text instance
|
||||
function M:set_color(color)
|
||||
@@ -437,7 +431,6 @@ end
|
||||
|
||||
|
||||
--- Set alpha
|
||||
---@param self Text Text
|
||||
---@param alpha number Alpha for node
|
||||
---@return Text Current text instance
|
||||
function M:set_alpha(alpha)
|
||||
@@ -449,7 +442,6 @@ end
|
||||
|
||||
|
||||
--- Set scale
|
||||
---@param self Text Text
|
||||
---@param scale vector3 Scale for node
|
||||
---@return Text Current text instance
|
||||
function M:set_scale(scale)
|
||||
@@ -461,7 +453,6 @@ end
|
||||
|
||||
|
||||
--- Set text pivot. Text will re-anchor inside text area
|
||||
---@param self Text Text
|
||||
---@param pivot number The gui.PIVOT_* constant
|
||||
---@return Text Current text instance
|
||||
function M:set_pivot(pivot)
|
||||
@@ -487,7 +478,6 @@ end
|
||||
|
||||
|
||||
--- Return true, if text with line break
|
||||
---@param self Text Text
|
||||
---@return boolean Is text node with line break
|
||||
function M:is_multiline()
|
||||
return gui.get_line_break(self.node)
|
||||
@@ -495,7 +485,6 @@ end
|
||||
|
||||
|
||||
--- Set text adjust, refresh the current text visuals, if needed
|
||||
---@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
|
||||
---@return Text Current text instance
|
||||
@@ -509,7 +498,6 @@ 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
|
||||
---@return Text Current text instance
|
||||
function M:set_minimal_scale(minimal_scale)
|
||||
|
Reference in New Issue
Block a user