Skip to content

Commit

Permalink
Update annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
Insality committed Nov 10, 2024
1 parent b5ccd80 commit 56ef92a
Show file tree
Hide file tree
Showing 16 changed files with 21 additions and 158 deletions.
8 changes: 0 additions & 8 deletions druid/base/hover.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -132,15 +130,13 @@ 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
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
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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
Expand Down
20 changes: 1 addition & 19 deletions druid/base/scroll.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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)
Expand All @@ -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))
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
22 changes: 0 additions & 22 deletions druid/base/static_grid.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -232,7 +227,6 @@ end


--- Update grid content
---@param self StaticGrid StaticGrid
function M:refresh()
self:_update(true)
end
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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(
Expand Down Expand Up @@ -366,15 +356,13 @@ end


--- Return grid content borders
---@param self StaticGrid StaticGrid
---@return vector3 The grid content borders
function M:get_borders()
return self.border
end


--- Return array of all node positions
---@param self StaticGrid StaticGrid
---@return vector3[] All grid node positions
function M:get_all_pos()
local result = {}
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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()
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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)
Expand Down
Loading

0 comments on commit 56ef92a

Please sign in to comment.