mirror of
https://github.com/Insality/druid.git
synced 2025-06-27 18:37:44 +02:00
replace all tparam
This commit is contained in:
parent
999c6222a0
commit
620facbe1f
@ -471,7 +471,7 @@ end
|
|||||||
--- Set button enabled state.
|
--- Set button enabled state.
|
||||||
-- The style.on_set_enabled will be triggered.
|
-- The style.on_set_enabled will be triggered.
|
||||||
-- Disabled button is not clickable.
|
-- Disabled button is not clickable.
|
||||||
-- @tparam boolean|nil state Enabled state
|
---@param state boolean|nil Enabled state
|
||||||
---@return druid.button self
|
---@return druid.button self
|
||||||
function M:set_enabled(state)
|
function M:set_enabled(state)
|
||||||
self.disabled = not state
|
self.disabled = not state
|
||||||
@ -495,7 +495,7 @@ end
|
|||||||
-- Useful to restrict click outside out stencil node or scrollable content.
|
-- 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
|
-- 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
|
---@return druid.button self
|
||||||
function M:set_click_zone(zone)
|
function M:set_click_zone(zone)
|
||||||
self.click_zone = self:get_node(zone)
|
self.click_zone = self:get_node(zone)
|
||||||
@ -523,8 +523,8 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Set function for additional check for button click availability
|
--- 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.
|
---@param check_function function|nil 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 failure_callback function|nil Function will be called on button click, if check function return false
|
||||||
---@return druid.button self
|
---@return druid.button self
|
||||||
function M:set_check_function(check_function, failure_callback)
|
function M:set_check_function(check_function, failure_callback)
|
||||||
self._check_function = check_function
|
self._check_function = check_function
|
||||||
@ -538,7 +538,7 @@ end
|
|||||||
-- The HTML5 button's doesn't call any events except on_click event.
|
-- 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
|
-- 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
|
---@return druid.button self
|
||||||
function M:set_web_user_interaction(is_web_mode)
|
function M:set_web_user_interaction(is_web_mode)
|
||||||
self._is_html5_mode = not not (is_web_mode and html5)
|
self._is_html5_mode = not not (is_web_mode and html5)
|
||||||
|
@ -35,10 +35,10 @@ local M = component.create("hover")
|
|||||||
|
|
||||||
|
|
||||||
--- The Hover constructor
|
--- The Hover constructor
|
||||||
-- @tparam Hover self Hover
|
---@param self Hover Hover
|
||||||
-- @tparam node node Gui node
|
---@param node node Gui node
|
||||||
-- @tparam function on_hover_callback Hover callback
|
---@param on_hover_callback function Hover callback
|
||||||
-- @tparam function on_mouse_hover On mouse hover callback
|
---@param on_mouse_hover function On mouse hover callback
|
||||||
function M:init(node, on_hover_callback, on_mouse_hover)
|
function M:init(node, on_hover_callback, on_mouse_hover)
|
||||||
self.node = self:get_node(node)
|
self.node = self:get_node(node)
|
||||||
|
|
||||||
@ -115,8 +115,8 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Set hover state
|
--- Set hover state
|
||||||
-- @tparam Hover self Hover
|
---@param self Hover Hover
|
||||||
-- @tparam boolean|nil state The hover state
|
---@param state boolean|nil The hover state
|
||||||
function M:set_hover(state)
|
function M:set_hover(state)
|
||||||
if self._is_hovered == state then
|
if self._is_hovered == state then
|
||||||
return
|
return
|
||||||
@ -132,7 +132,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Return current hover state. True if touch action was on the node at current time
|
--- 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
|
-- @treturn boolean The current hovered state
|
||||||
function M:is_hovered()
|
function M:is_hovered()
|
||||||
return self._is_hovered
|
return self._is_hovered
|
||||||
@ -140,8 +140,8 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Set mouse hover state
|
--- Set mouse hover state
|
||||||
-- @tparam Hover self Hover
|
---@param self Hover Hover
|
||||||
-- @tparam boolean|nil state The mouse hover state
|
---@param state boolean|nil The mouse hover state
|
||||||
function M:set_mouse_hover(state)
|
function M:set_mouse_hover(state)
|
||||||
if self._is_mouse_hovered == state then
|
if self._is_mouse_hovered == state then
|
||||||
return
|
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
|
--- 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
|
-- @treturn boolean The current hovered state
|
||||||
function M:is_mouse_hovered()
|
function M:is_mouse_hovered()
|
||||||
return self._is_mouse_hovered
|
return self._is_mouse_hovered
|
||||||
@ -166,8 +166,8 @@ end
|
|||||||
|
|
||||||
--- Strict hover click area. Useful for
|
--- Strict hover click area. Useful for
|
||||||
-- no click events outside stencil node
|
-- no click events outside stencil node
|
||||||
-- @tparam Hover self Hover
|
---@param self Hover Hover
|
||||||
-- @tparam node|string|nil zone Gui node
|
---@param zone node|string|nil Gui node
|
||||||
function M:set_click_zone(zone)
|
function M:set_click_zone(zone)
|
||||||
self.click_zone = self:get_node(zone)
|
self.click_zone = self:get_node(zone)
|
||||||
end
|
end
|
||||||
@ -176,8 +176,8 @@ end
|
|||||||
--- Set enable state of hover component.
|
--- Set enable state of hover component.
|
||||||
-- If hover is not enabled, it will not generate
|
-- If hover is not enabled, it will not generate
|
||||||
-- any hover events
|
-- any hover events
|
||||||
-- @tparam Hover self Hover
|
---@param self Hover Hover
|
||||||
-- @tparam boolean|nil state The hover enabled state
|
---@param state boolean|nil The hover enabled state
|
||||||
function M:set_enabled(state)
|
function M:set_enabled(state)
|
||||||
self._is_enabled = state
|
self._is_enabled = state
|
||||||
|
|
||||||
@ -193,7 +193,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Return current hover enabled state
|
--- Return current hover enabled state
|
||||||
-- @tparam Hover self Hover
|
---@param self Hover Hover
|
||||||
-- @treturn boolean The hover enabled state
|
-- @treturn boolean The hover enabled state
|
||||||
function M:is_enabled()
|
function M:is_enabled()
|
||||||
return self._is_enabled
|
return self._is_enabled
|
||||||
|
@ -171,9 +171,9 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- The Scroll constructor
|
--- The Scroll constructor
|
||||||
-- @tparam Scroll self Scroll
|
---@param self Scroll Scroll
|
||||||
-- @tparam string|node view_node GUI view scroll node
|
---@param view_node string|node GUI view scroll node
|
||||||
-- @tparam string|node content_node GUI content scroll node
|
---@param content_node string|node GUI content scroll node
|
||||||
function M:init(view_node, content_node)
|
function M:init(view_node, content_node)
|
||||||
self.druid = self:get_druid()
|
self.druid = self:get_druid()
|
||||||
|
|
||||||
@ -253,9 +253,9 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Start scroll to target point.
|
--- Start scroll to target point.
|
||||||
-- @tparam Scroll self Scroll
|
---@param self Scroll Scroll
|
||||||
-- @tparam vector3 point Target point
|
---@param point vector3 Target point
|
||||||
-- @tparam boolean|nil is_instant Instant scroll flag
|
---@param is_instant boolean|nil Instant scroll flag
|
||||||
-- @usage scroll:scroll_to(vmath.vector3(0, 50, 0))
|
-- @usage scroll:scroll_to(vmath.vector3(0, 50, 0))
|
||||||
-- @usage scroll:scroll_to(vmath.vector3(0), true)
|
-- @usage scroll:scroll_to(vmath.vector3(0), true)
|
||||||
function M:scroll_to(point, is_instant)
|
function M:scroll_to(point, is_instant)
|
||||||
@ -287,9 +287,9 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Scroll to item in scroll by point index.
|
--- Scroll to item in scroll by point index.
|
||||||
-- @tparam Scroll self Scroll
|
---@param self Scroll Scroll
|
||||||
-- @tparam number index Point index
|
---@param index number Point index
|
||||||
-- @tparam boolean|nil skip_cb If true, skip the point callback
|
---@param skip_cb boolean|nil If true, skip the point callback
|
||||||
function M:scroll_to_index(index, skip_cb)
|
function M:scroll_to_index(index, skip_cb)
|
||||||
if not self.points then
|
if not self.points then
|
||||||
return
|
return
|
||||||
@ -310,9 +310,9 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Start scroll to target scroll percent
|
--- Start scroll to target scroll percent
|
||||||
-- @tparam Scroll self Scroll
|
---@param self Scroll Scroll
|
||||||
-- @tparam vector3 percent target percent
|
---@param percent vector3 target percent
|
||||||
-- @tparam boolean|nil is_instant instant scroll flag
|
---@param is_instant boolean|nil instant scroll flag
|
||||||
-- @usage scroll:scroll_to_percent(vmath.vector3(0.5, 0, 0))
|
-- @usage scroll:scroll_to_percent(vmath.vector3(0.5, 0, 0))
|
||||||
function M:scroll_to_percent(percent, is_instant)
|
function M:scroll_to_percent(percent, is_instant)
|
||||||
local border = self.available_pos
|
local border = self.available_pos
|
||||||
@ -336,7 +336,7 @@ end
|
|||||||
|
|
||||||
--- Return current scroll progress status.
|
--- Return current scroll progress status.
|
||||||
-- Values will be in [0..1] interval
|
-- Values will be in [0..1] interval
|
||||||
-- @tparam Scroll self Scroll
|
---@param self Scroll Scroll
|
||||||
-- @treturn vector3 New vector with scroll progress values
|
-- @treturn vector3 New vector with scroll progress values
|
||||||
function M:get_percent()
|
function M:get_percent()
|
||||||
local x_perc = 1 - inverse_lerp(self.available_pos.x, self.available_pos.z, self.position.x)
|
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.
|
--- Set scroll content size.
|
||||||
-- It will change content gui node size
|
-- It will change content gui node size
|
||||||
-- @tparam Scroll self Scroll
|
---@param self Scroll Scroll
|
||||||
-- @tparam vector3 size The new size for content node
|
---@param size vector3 The new size for content node
|
||||||
-- @tparam vector3|nil offset Offset value to set, where content is starts
|
---@param offset vector3|nil Offset value to set, where content is starts
|
||||||
-- @treturn druid.scroll Current scroll instance
|
-- @treturn druid.scroll Current scroll instance
|
||||||
function M:set_size(size, offset)
|
function M:set_size(size, offset)
|
||||||
if offset then
|
if offset then
|
||||||
@ -364,8 +364,8 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Set new scroll view size in case the node size was changed.
|
--- Set new scroll view size in case the node size was changed.
|
||||||
-- @tparam Scroll self Scroll
|
---@param self Scroll Scroll
|
||||||
-- @tparam vector3 size The new size for view node
|
---@param size vector3 The new size for view node
|
||||||
-- @treturn druid.scroll Current scroll instance
|
-- @treturn druid.scroll Current scroll instance
|
||||||
function M:set_view_size(size)
|
function M:set_view_size(size)
|
||||||
gui.set_size(self.view_node, size)
|
gui.set_size(self.view_node, size)
|
||||||
@ -378,7 +378,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Refresh scroll view size
|
--- Refresh scroll view size
|
||||||
-- @tparam Scroll self Scroll
|
---@param self Scroll Scroll
|
||||||
function M:update_view_size()
|
function M:update_view_size()
|
||||||
self.view_size = helper.get_scaled_size(self.view_node)
|
self.view_size = helper.get_scaled_size(self.view_node)
|
||||||
self.view_border = helper.get_border(self.view_node)
|
self.view_border = helper.get_border(self.view_node)
|
||||||
@ -391,8 +391,8 @@ end
|
|||||||
--- Enable or disable scroll inert.
|
--- Enable or disable scroll inert.
|
||||||
-- If disabled, scroll through points (if exist)
|
-- If disabled, scroll through points (if exist)
|
||||||
-- If no points, just simple drag without inertion
|
-- If no points, just simple drag without inertion
|
||||||
-- @tparam Scroll self Scroll
|
---@param self Scroll Scroll
|
||||||
-- @tparam boolean|nil state Inert scroll state
|
---@param state boolean|nil Inert scroll state
|
||||||
-- @treturn druid.scroll Current scroll instance
|
-- @treturn druid.scroll Current scroll instance
|
||||||
function M:set_inert(state)
|
function M:set_inert(state)
|
||||||
self._is_inert = state
|
self._is_inert = state
|
||||||
@ -402,7 +402,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Return if scroll have inertion.
|
--- Return if scroll have inertion.
|
||||||
-- @tparam Scroll self Scroll
|
---@param self Scroll Scroll
|
||||||
-- @treturn boolean @If scroll have inertion
|
-- @treturn boolean @If scroll have inertion
|
||||||
function M:is_inert()
|
function M:is_inert()
|
||||||
return self._is_inert
|
return self._is_inert
|
||||||
@ -411,8 +411,8 @@ end
|
|||||||
|
|
||||||
--- Set extra size for scroll stretching.
|
--- Set extra size for scroll stretching.
|
||||||
-- Set 0 to disable stretching effect
|
-- Set 0 to disable stretching effect
|
||||||
-- @tparam Scroll self Scroll
|
---@param self Scroll Scroll
|
||||||
-- @tparam number|nil stretch_size Size in pixels of additional scroll area
|
---@param stretch_size number|nil Size in pixels of additional scroll area
|
||||||
-- @treturn druid.scroll Current scroll instance
|
-- @treturn druid.scroll Current scroll instance
|
||||||
function M:set_extra_stretch_size(stretch_size)
|
function M:set_extra_stretch_size(stretch_size)
|
||||||
self.style.EXTRA_STRETCH_SIZE = stretch_size or 0
|
self.style.EXTRA_STRETCH_SIZE = stretch_size or 0
|
||||||
@ -423,7 +423,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Return vector of scroll size with width and height.
|
--- Return vector of scroll size with width and height.
|
||||||
-- @tparam Scroll self Scroll
|
---@param self Scroll Scroll
|
||||||
-- @treturn vector3 Available scroll size
|
-- @treturn vector3 Available scroll size
|
||||||
function M:get_scroll_size()
|
function M:get_scroll_size()
|
||||||
return self.available_size
|
return self.available_size
|
||||||
@ -432,8 +432,8 @@ end
|
|||||||
|
|
||||||
--- Set points of interest.
|
--- Set points of interest.
|
||||||
-- Scroll will always centered on closer points
|
-- Scroll will always centered on closer points
|
||||||
-- @tparam Scroll self Scroll
|
---@param self Scroll Scroll
|
||||||
-- @tparam table points Array of vector3 points
|
---@param points table Array of vector3 points
|
||||||
-- @treturn druid.scroll Current scroll instance
|
-- @treturn druid.scroll Current scroll instance
|
||||||
function M:set_points(points)
|
function M:set_points(points)
|
||||||
self.points = points
|
self.points = points
|
||||||
@ -449,8 +449,8 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Lock or unlock horizontal scroll
|
--- Lock or unlock horizontal scroll
|
||||||
-- @tparam Scroll self Scroll
|
---@param self Scroll Scroll
|
||||||
-- @tparam boolean|nil state True, if horizontal scroll is enabled
|
---@param state boolean|nil True, if horizontal scroll is enabled
|
||||||
-- @treturn druid.scroll Current scroll instance
|
-- @treturn druid.scroll Current scroll instance
|
||||||
function M:set_horizontal_scroll(state)
|
function M:set_horizontal_scroll(state)
|
||||||
self._is_horizontal_scroll = state
|
self._is_horizontal_scroll = state
|
||||||
@ -460,8 +460,8 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Lock or unlock vertical scroll
|
--- Lock or unlock vertical scroll
|
||||||
-- @tparam Scroll self Scroll
|
---@param self Scroll Scroll
|
||||||
-- @tparam boolean|nil state True, if vertical scroll is enabled
|
---@param state boolean|nil True, if vertical scroll is enabled
|
||||||
-- @treturn druid.scroll Current scroll instance
|
-- @treturn druid.scroll Current scroll instance
|
||||||
function M:set_vertical_scroll(state)
|
function M:set_vertical_scroll(state)
|
||||||
self._is_vertical_scroll = state
|
self._is_vertical_scroll = state
|
||||||
@ -472,8 +472,8 @@ end
|
|||||||
|
|
||||||
--- Check node if it visible now on scroll.
|
--- Check node if it visible now on scroll.
|
||||||
-- Extra border is not affected. Return true for elements in extra scroll zone
|
-- Extra border is not affected. Return true for elements in extra scroll zone
|
||||||
-- @tparam Scroll self Scroll
|
---@param self Scroll Scroll
|
||||||
-- @tparam node node The node to check
|
---@param node node The node to check
|
||||||
-- @treturn boolean True if node in visible scroll area
|
-- @treturn boolean True if node in visible scroll area
|
||||||
function M:is_node_in_view(node)
|
function M:is_node_in_view(node)
|
||||||
local node_offset_for_view = gui.get_position(node)
|
local node_offset_for_view = gui.get_position(node)
|
||||||
@ -513,8 +513,8 @@ end
|
|||||||
|
|
||||||
--- Bind the grid component (Static or Dynamic) to recalculate
|
--- Bind the grid component (Static or Dynamic) to recalculate
|
||||||
-- scroll size on grid changes
|
-- scroll size on grid changes
|
||||||
-- @tparam Scroll self Scroll
|
---@param self Scroll Scroll
|
||||||
-- @tparam StaticGrid grid Druid grid component
|
---@param grid StaticGrid Druid grid component
|
||||||
-- @treturn druid.scroll Current scroll instance
|
-- @treturn druid.scroll Current scroll instance
|
||||||
function M:bind_grid(grid)
|
function M:bind_grid(grid)
|
||||||
if self._grid_on_change then
|
if self._grid_on_change then
|
||||||
@ -542,8 +542,8 @@ end
|
|||||||
|
|
||||||
--- Strict drag scroll area. Useful for
|
--- Strict drag scroll area. Useful for
|
||||||
-- restrict events outside stencil node
|
-- restrict events outside stencil node
|
||||||
-- @tparam Drag self
|
---@param self Drag
|
||||||
-- @tparam node|string node Gui node
|
---@param node node|string Gui node
|
||||||
function M:set_click_zone(node)
|
function M:set_click_zone(node)
|
||||||
self.drag:set_click_zone(node)
|
self.drag:set_click_zone(node)
|
||||||
end
|
end
|
||||||
|
@ -128,10 +128,10 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- The StaticGrid constructor
|
--- The StaticGrid constructor
|
||||||
-- @tparam StaticGrid self StaticGrid
|
---@param self StaticGrid StaticGrid
|
||||||
-- @tparam string|node parent The GUI Node container, where grid's items will be placed
|
---@param parent string|node The GUI Node container, where grid's items will be placed
|
||||||
-- @tparam node element Element prefab. Need to get it size
|
---@param element node Element prefab. Need to get it size
|
||||||
-- @tparam number|nil in_row How many nodes in row can be placed. By default 1
|
---@param in_row number|nil How many nodes in row can be placed. By default 1
|
||||||
function M:init(parent, element, in_row)
|
function M:init(parent, element, in_row)
|
||||||
self.parent = self:get_node(parent)
|
self.parent = self:get_node(parent)
|
||||||
self.nodes = {}
|
self.nodes = {}
|
||||||
@ -165,8 +165,8 @@ end
|
|||||||
|
|
||||||
local _temp_pos = vmath.vector3(0)
|
local _temp_pos = vmath.vector3(0)
|
||||||
--- Return pos for grid node index
|
--- Return pos for grid node index
|
||||||
-- @tparam StaticGrid self StaticGrid
|
---@param self StaticGrid StaticGrid
|
||||||
-- @tparam number index The grid element index
|
---@param index number The grid element index
|
||||||
-- @treturn vector3 @Node position
|
-- @treturn vector3 @Node position
|
||||||
function M:get_pos(index)
|
function M:get_pos(index)
|
||||||
local row = math.ceil(index / self.in_row) - 1
|
local row = math.ceil(index / self.in_row) - 1
|
||||||
@ -183,8 +183,8 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Return index for grid pos
|
--- Return index for grid pos
|
||||||
-- @tparam StaticGrid self StaticGrid
|
---@param self StaticGrid StaticGrid
|
||||||
-- @tparam vector3 pos The node position in the grid
|
---@param pos vector3 The node position in the grid
|
||||||
-- @treturn number The node index
|
-- @treturn number The node index
|
||||||
function M:get_index(pos)
|
function M:get_index(pos)
|
||||||
-- Offset to left-top corner from node pivot
|
-- Offset to left-top corner from node pivot
|
||||||
@ -203,8 +203,8 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Return grid index by node
|
--- Return grid index by node
|
||||||
-- @tparam StaticGrid self StaticGrid
|
---@param self StaticGrid StaticGrid
|
||||||
-- @tparam node node The gui node in the grid
|
---@param node node The gui node in the grid
|
||||||
-- @treturn number The node index
|
-- @treturn number The node index
|
||||||
function M:get_index_by_node(node)
|
function M:get_index_by_node(node)
|
||||||
for index, grid_node in pairs(self.nodes) do
|
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
|
--- Set grid anchor. Default anchor is equal to anchor of grid parent node
|
||||||
-- @tparam StaticGrid self StaticGrid
|
---@param self StaticGrid StaticGrid
|
||||||
-- @tparam vector3 anchor Anchor
|
---@param anchor vector3 Anchor
|
||||||
function M:set_anchor(anchor)
|
function M:set_anchor(anchor)
|
||||||
self.anchor = anchor
|
self.anchor = anchor
|
||||||
self:_update()
|
self:_update()
|
||||||
@ -232,7 +232,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Update grid content
|
--- Update grid content
|
||||||
-- @tparam StaticGrid self StaticGrid
|
---@param self StaticGrid StaticGrid
|
||||||
function M:refresh()
|
function M:refresh()
|
||||||
self:_update(true)
|
self:_update(true)
|
||||||
end
|
end
|
||||||
@ -270,11 +270,11 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Add new item to the grid
|
--- Add new item to the grid
|
||||||
-- @tparam StaticGrid self StaticGrid
|
---@param self StaticGrid StaticGrid
|
||||||
-- @tparam node item GUI node
|
---@param item node GUI node
|
||||||
-- @tparam number|nil index The item position. By default add as last item
|
---@param index number|nil The item position. By default add as last item
|
||||||
-- @tparam number|nil shift_policy How shift nodes, if required. Default: const.SHIFT.RIGHT
|
---@param shift_policy number|nil How shift nodes, if required. Default: const.SHIFT.RIGHT
|
||||||
-- @tparam boolean|nil is_instant If true, update node positions instantly
|
---@param is_instant boolean|nil If true, update node positions instantly
|
||||||
function M:add(item, index, shift_policy, is_instant)
|
function M:add(item, index, shift_policy, is_instant)
|
||||||
index = index or ((self.last_index or 0) + 1)
|
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
|
--- Set new items to the grid. All previous items will be removed
|
||||||
-- @tparam StaticGrid self StaticGrid
|
---@param self StaticGrid StaticGrid
|
||||||
-- @tparam node[] nodes The new grid nodes
|
---@param nodes node[] The new grid nodes
|
||||||
-- @tparam[opt=false] boolean is_instant If true, update node positions instantly
|
-- @tparam[opt=false] boolean is_instant If true, update node positions instantly
|
||||||
function M:set_items(nodes, is_instant)
|
function M:set_items(nodes, is_instant)
|
||||||
self.nodes = nodes
|
self.nodes = nodes
|
||||||
@ -312,10 +312,10 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Remove the item from the grid. Note that gui node will be not deleted
|
--- Remove the item from the grid. Note that gui node will be not deleted
|
||||||
-- @tparam StaticGrid self StaticGrid
|
---@param self StaticGrid StaticGrid
|
||||||
-- @tparam number index The grid node index to remove
|
---@param index number The grid node index to remove
|
||||||
-- @tparam number|nil shift_policy How shift nodes, if required. Default: const.SHIFT.RIGHT
|
---@param shift_policy number|nil How shift nodes, if required. Default: const.SHIFT.RIGHT
|
||||||
-- @tparam boolean|nil is_instant If true, update node positions instantly
|
---@param is_instant boolean|nil If true, update node positions instantly
|
||||||
-- @treturn node The deleted gui node from grid
|
-- @treturn node The deleted gui node from grid
|
||||||
function M:remove(index, shift_policy, is_instant)
|
function M:remove(index, shift_policy, is_instant)
|
||||||
assert(self.nodes[index], "No grid item at given index " .. index)
|
assert(self.nodes[index], "No grid item at given index " .. index)
|
||||||
@ -333,7 +333,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Return grid content size
|
--- Return grid content size
|
||||||
-- @tparam StaticGrid self StaticGrid
|
---@param self StaticGrid StaticGrid
|
||||||
-- @treturn vector3 The grid content size
|
-- @treturn vector3 The grid content size
|
||||||
function M:get_size()
|
function M:get_size()
|
||||||
return vmath.vector3(
|
return vmath.vector3(
|
||||||
@ -366,7 +366,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Return grid content borders
|
--- Return grid content borders
|
||||||
-- @tparam StaticGrid self StaticGrid
|
---@param self StaticGrid StaticGrid
|
||||||
-- @treturn vector3 The grid content borders
|
-- @treturn vector3 The grid content borders
|
||||||
function M:get_borders()
|
function M:get_borders()
|
||||||
return self.border
|
return self.border
|
||||||
@ -374,7 +374,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Return array of all node positions
|
--- Return array of all node positions
|
||||||
-- @tparam StaticGrid self StaticGrid
|
---@param self StaticGrid StaticGrid
|
||||||
-- @treturn vector3[] All grid node positions
|
-- @treturn vector3[] All grid node positions
|
||||||
function M:get_all_pos()
|
function M:get_all_pos()
|
||||||
local result = {}
|
local result = {}
|
||||||
@ -388,8 +388,8 @@ end
|
|||||||
|
|
||||||
--- Change set position function for grid nodes. It will call on
|
--- Change set position function for grid nodes. It will call on
|
||||||
-- update poses on grid elements. Default: gui.set_position
|
-- update poses on grid elements. Default: gui.set_position
|
||||||
-- @tparam StaticGrid self StaticGrid
|
---@param self StaticGrid StaticGrid
|
||||||
-- @tparam function callback Function on node set position
|
---@param callback function Function on node set position
|
||||||
-- @treturn druid.static_grid Current grid instance
|
-- @treturn druid.static_grid Current grid instance
|
||||||
function M:set_position_function(callback)
|
function M:set_position_function(callback)
|
||||||
self._set_position_function = callback or gui.set_position
|
self._set_position_function = callback or gui.set_position
|
||||||
@ -400,7 +400,7 @@ end
|
|||||||
|
|
||||||
--- Clear grid nodes array. GUI nodes will be not deleted!
|
--- 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
|
-- 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
|
-- @treturn druid.static_grid Current grid instance
|
||||||
function M:clear()
|
function M:clear()
|
||||||
self.border.x = 0
|
self.border.x = 0
|
||||||
@ -419,7 +419,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Return StaticGrid offset, where StaticGrid content starts.
|
--- 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
|
-- @treturn vector3 The StaticGrid offset
|
||||||
function M:get_offset()
|
function M:get_offset()
|
||||||
local borders = self:get_borders()
|
local borders = self:get_borders()
|
||||||
@ -435,8 +435,8 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Set new in_row elements for grid
|
--- Set new in_row elements for grid
|
||||||
-- @tparam StaticGrid self StaticGrid
|
---@param self StaticGrid StaticGrid
|
||||||
-- @tparam number in_row The new in_row value
|
---@param in_row number The new in_row value
|
||||||
-- @treturn druid.static_grid Current grid instance
|
-- @treturn druid.static_grid Current grid instance
|
||||||
function M:set_in_row(in_row)
|
function M:set_in_row(in_row)
|
||||||
self.in_row = in_row
|
self.in_row = in_row
|
||||||
@ -454,7 +454,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Set new node size for grid
|
--- 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 width The new node width
|
||||||
-- @tparam[opt] number height The new node height
|
-- @tparam[opt] number height The new node height
|
||||||
-- @treturn druid.static_grid Current grid instance
|
-- @treturn druid.static_grid Current grid instance
|
||||||
@ -479,8 +479,8 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Sort grid nodes by custom comparator function
|
--- Sort grid nodes by custom comparator function
|
||||||
-- @tparam StaticGrid self StaticGrid
|
---@param self StaticGrid StaticGrid
|
||||||
-- @tparam function comparator The comparator function. (a, b) -> boolean
|
---@param comparator function The comparator function. (a, b) -> boolean
|
||||||
-- @treturn druid.static_grid Current grid instance
|
-- @treturn druid.static_grid Current grid instance
|
||||||
function M:sort_nodes(comparator)
|
function M:sort_nodes(comparator)
|
||||||
table.sort(self.nodes, comparator)
|
table.sort(self.nodes, comparator)
|
||||||
@ -489,8 +489,8 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Update grid inner state
|
--- Update grid inner state
|
||||||
-- @tparam StaticGrid self StaticGrid
|
---@param self StaticGrid StaticGrid
|
||||||
-- @tparam boolean|nil is_instant If true, node position update instantly, otherwise with set_position_function callback
|
---@param is_instant boolean|nil If true, node position update instantly, otherwise with set_position_function callback
|
||||||
---@private
|
---@private
|
||||||
function M:_update(is_instant)
|
function M:_update(is_instant)
|
||||||
self:_update_indexes()
|
self:_update_indexes()
|
||||||
@ -500,7 +500,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Update first and last indexes of grid nodes
|
--- Update first and last indexes of grid nodes
|
||||||
-- @tparam StaticGrid self StaticGrid
|
---@param self StaticGrid StaticGrid
|
||||||
---@private
|
---@private
|
||||||
function M:_update_indexes()
|
function M:_update_indexes()
|
||||||
self.first_index = nil
|
self.first_index = nil
|
||||||
@ -516,7 +516,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Update grid content borders, recalculate min and max values
|
--- Update grid content borders, recalculate min and max values
|
||||||
-- @tparam StaticGrid self StaticGrid
|
---@param self StaticGrid StaticGrid
|
||||||
---@private
|
---@private
|
||||||
function M:_update_borders()
|
function M:_update_borders()
|
||||||
if not self.first_index then
|
if not self.first_index then
|
||||||
@ -535,8 +535,8 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Update grid nodes position
|
--- Update grid nodes position
|
||||||
-- @tparam StaticGrid self StaticGrid
|
---@param self StaticGrid StaticGrid
|
||||||
-- @tparam boolean|nil is_instant If true, node position update instantly, otherwise with set_position_function callback
|
---@param is_instant boolean|nil If true, node position update instantly, otherwise with set_position_function callback
|
||||||
---@private
|
---@private
|
||||||
function M:_update_pos(is_instant)
|
function M:_update_pos(is_instant)
|
||||||
local zero_offset = self:_get_zero_offset()
|
local zero_offset = self:_get_zero_offset()
|
||||||
|
@ -288,10 +288,10 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- The Text constructor
|
--- The Text constructor
|
||||||
-- @tparam Text self Text
|
---@param self Text Text
|
||||||
-- @tparam string|node node Node name or GUI Text Node itself
|
---@param node string|node Node name or GUI Text Node itself
|
||||||
-- @tparam string|nil value Initial text. Default value is node text from GUI scene. Default: nil
|
---@param value string|nil 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 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)
|
function M:init(node, value, adjust_type)
|
||||||
self.node = self:get_node(node)
|
self.node = self:get_node(node)
|
||||||
self.pos = gui.get_position(self.node)
|
self.pos = gui.get_position(self.node)
|
||||||
@ -335,8 +335,8 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Calculate text width with font with respect to trailing space
|
--- Calculate text width with font with respect to trailing space
|
||||||
-- @tparam Text self Text
|
---@param self Text Text
|
||||||
-- @tparam string text|nil
|
---@param text|nil string
|
||||||
-- @treturn number Width
|
-- @treturn number Width
|
||||||
-- @treturn number Height
|
-- @treturn number Height
|
||||||
function M:get_text_size(text)
|
function M:get_text_size(text)
|
||||||
@ -360,8 +360,8 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Get chars count by width
|
--- Get chars count by width
|
||||||
-- @tparam Text self Text
|
---@param self Text Text
|
||||||
-- @tparam number width
|
---@param width number
|
||||||
-- @treturn number Chars count
|
-- @treturn number Chars count
|
||||||
function M:get_text_index_by_width(width)
|
function M:get_text_index_by_width(width)
|
||||||
local text = self.last_value
|
local text = self.last_value
|
||||||
@ -394,8 +394,8 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Set text to text field
|
--- Set text to text field
|
||||||
-- @tparam Text self Text
|
---@param self Text Text
|
||||||
-- @tparam string set_to Text for node
|
---@param set_to string Text for node
|
||||||
-- @treturn Text Current text instance
|
-- @treturn Text Current text instance
|
||||||
function M:set_to(set_to)
|
function M:set_to(set_to)
|
||||||
set_to = set_to or ""
|
set_to = set_to or ""
|
||||||
@ -412,8 +412,8 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Set text area size
|
--- Set text area size
|
||||||
-- @tparam Text self Text
|
---@param self Text Text
|
||||||
-- @tparam vector3 size The new text area size
|
---@param size vector3 The new text area size
|
||||||
-- @treturn Text Current text instance
|
-- @treturn Text Current text instance
|
||||||
function M:set_size(size)
|
function M:set_size(size)
|
||||||
self.start_size = size
|
self.start_size = size
|
||||||
@ -425,8 +425,8 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Set color
|
--- Set color
|
||||||
-- @tparam Text self Text
|
---@param self Text Text
|
||||||
-- @tparam vector4 color Color for node
|
---@param color vector4 Color for node
|
||||||
-- @treturn Text Current text instance
|
-- @treturn Text Current text instance
|
||||||
function M:set_color(color)
|
function M:set_color(color)
|
||||||
self.color = color
|
self.color = color
|
||||||
@ -437,8 +437,8 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Set alpha
|
--- Set alpha
|
||||||
-- @tparam Text self Text
|
---@param self Text Text
|
||||||
-- @tparam number alpha Alpha for node
|
---@param alpha number Alpha for node
|
||||||
-- @treturn Text Current text instance
|
-- @treturn Text Current text instance
|
||||||
function M:set_alpha(alpha)
|
function M:set_alpha(alpha)
|
||||||
self.color.w = alpha
|
self.color.w = alpha
|
||||||
@ -449,8 +449,8 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Set scale
|
--- Set scale
|
||||||
-- @tparam Text self Text
|
---@param self Text Text
|
||||||
-- @tparam vector3 scale Scale for node
|
---@param scale vector3 Scale for node
|
||||||
-- @treturn Text Current text instance
|
-- @treturn Text Current text instance
|
||||||
function M:set_scale(scale)
|
function M:set_scale(scale)
|
||||||
self.last_scale = scale
|
self.last_scale = scale
|
||||||
@ -461,8 +461,8 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Set text pivot. Text will re-anchor inside text area
|
--- Set text pivot. Text will re-anchor inside text area
|
||||||
-- @tparam Text self Text
|
---@param self Text Text
|
||||||
-- @tparam number pivot The gui.PIVOT_* constant
|
---@param pivot number The gui.PIVOT_* constant
|
||||||
-- @treturn Text Current text instance
|
-- @treturn Text Current text instance
|
||||||
function M:set_pivot(pivot)
|
function M:set_pivot(pivot)
|
||||||
local prev_pivot = gui.get_pivot(self.node)
|
local prev_pivot = gui.get_pivot(self.node)
|
||||||
@ -487,7 +487,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Return true, if text with line break
|
--- Return true, if text with line break
|
||||||
-- @tparam Text self Text
|
---@param self Text Text
|
||||||
-- @treturn boolean Is text node with line break
|
-- @treturn boolean Is text node with line break
|
||||||
function M:is_multiline()
|
function M:is_multiline()
|
||||||
return gui.get_line_break(self.node)
|
return gui.get_line_break(self.node)
|
||||||
@ -495,9 +495,9 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Set text adjust, refresh the current text visuals, if needed
|
--- Set text adjust, refresh the current text visuals, if needed
|
||||||
-- @tparam Text self Text
|
---@param self Text Text
|
||||||
-- @tparam string|nil adjust_type See const.TEXT_ADJUST. If pass nil - use current adjust type
|
---@param adjust_type string|nil See const.TEXT_ADJUST. If pass nil - use current adjust type
|
||||||
-- @tparam number|nil minimal_scale If pass nil - not use minimal scale
|
---@param minimal_scale number|nil If pass nil - not use minimal scale
|
||||||
-- @treturn Text Current text instance
|
-- @treturn Text Current text instance
|
||||||
function M:set_text_adjust(adjust_type, minimal_scale)
|
function M:set_text_adjust(adjust_type, minimal_scale)
|
||||||
self.adjust_type = adjust_type
|
self.adjust_type = adjust_type
|
||||||
@ -509,8 +509,8 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Set minimal scale for DOWNSCALE_LIMITED or SCALE_THEN_SCROLL adjust types
|
--- Set minimal scale for DOWNSCALE_LIMITED or SCALE_THEN_SCROLL adjust types
|
||||||
-- @tparam Text self Text
|
---@param self Text Text
|
||||||
-- @tparam number minimal_scale If pass nil - not use minimal scale
|
---@param minimal_scale number If pass nil - not use minimal scale
|
||||||
-- @treturn Text Current text instance
|
-- @treturn Text Current text instance
|
||||||
function M:set_minimal_scale(minimal_scale)
|
function M:set_minimal_scale(minimal_scale)
|
||||||
self._minimal_scale = minimal_scale
|
self._minimal_scale = minimal_scale
|
||||||
|
@ -278,11 +278,11 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Setup component context and his style table
|
--- Setup component context and his style table
|
||||||
-- @tparam BaseComponent self BaseComponent
|
---@param self BaseComponent BaseComponent
|
||||||
-- @tparam table druid_instance The parent druid instance
|
---@param druid_instance table The parent druid instance
|
||||||
-- @tparam table context Druid context. Usually it is self of script
|
---@param context table Druid context. Usually it is self of script
|
||||||
-- @tparam table style Druid style module
|
---@param style table Druid style module
|
||||||
-- @tparam table instance_class The component instance class
|
---@param instance_class table The component instance class
|
||||||
-- @treturn component BaseComponent itself
|
-- @treturn component BaseComponent itself
|
||||||
---@private
|
---@private
|
||||||
function M:setup_component(druid_instance, context, style, instance_class)
|
function M:setup_component(druid_instance, context, style, instance_class)
|
||||||
@ -310,7 +310,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Return true, if input priority was changed
|
--- Return true, if input priority was changed
|
||||||
-- @tparam BaseComponent self BaseComponent
|
---@param self BaseComponent BaseComponent
|
||||||
---@private
|
---@private
|
||||||
function M._is_input_priority_changed(self)
|
function M._is_input_priority_changed(self)
|
||||||
return self._component._is_input_priority_changed
|
return self._component._is_input_priority_changed
|
||||||
@ -318,7 +318,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Reset is_input_priority_changed field
|
--- Reset is_input_priority_changed field
|
||||||
-- @tparam BaseComponent self BaseComponent
|
---@param self BaseComponent BaseComponent
|
||||||
---@private
|
---@private
|
||||||
function M._reset_input_priority_changed(self)
|
function M._reset_input_priority_changed(self)
|
||||||
self._component._is_input_priority_changed = false
|
self._component._is_input_priority_changed = false
|
||||||
@ -326,7 +326,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Get current component interests
|
--- Get current component interests
|
||||||
-- @tparam BaseComponent self BaseComponent
|
---@param self BaseComponent BaseComponent
|
||||||
-- @treturn table List of component interests
|
-- @treturn table List of component interests
|
||||||
---@private
|
---@private
|
||||||
function M.__get_interests(self)
|
function M.__get_interests(self)
|
||||||
@ -369,8 +369,8 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Remove child from component children list
|
--- Remove child from component children list
|
||||||
-- @tparam BaseComponent self BaseComponent
|
---@param self BaseComponent BaseComponent
|
||||||
-- @tparam component child The druid component instance
|
---@param child component The druid component instance
|
||||||
---@private
|
---@private
|
||||||
function M.__remove_child(self, child)
|
function M.__remove_child(self, child)
|
||||||
for i = #self._meta.children, 1, -1 do
|
for i = #self._meta.children, 1, -1 do
|
||||||
@ -383,7 +383,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Return all children components, recursive
|
--- Return all children components, recursive
|
||||||
-- @tparam BaseComponent self BaseComponent
|
---@param self BaseComponent BaseComponent
|
||||||
-- @treturn table Array of childrens if the Druid component instance
|
-- @treturn table Array of childrens if the Druid component instance
|
||||||
function M.get_childrens(self)
|
function M.get_childrens(self)
|
||||||
local childrens = {}
|
local childrens = {}
|
||||||
|
@ -263,8 +263,8 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Set placeholder text
|
--- Set placeholder text
|
||||||
-- @tparam RichInput self RichInput
|
---@param self RichInput RichInput
|
||||||
-- @tparam string placeholder_text The placeholder text
|
---@param placeholder_text string The placeholder text
|
||||||
function M:set_placeholder(placeholder_text)
|
function M:set_placeholder(placeholder_text)
|
||||||
self.placeholder:set_to(placeholder_text)
|
self.placeholder:set_to(placeholder_text)
|
||||||
return self
|
return self
|
||||||
@ -272,16 +272,16 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Select input field
|
--- Select input field
|
||||||
-- @tparam RichInput self RichInput
|
---@param self RichInput RichInput
|
||||||
function M:select()
|
function M:select()
|
||||||
self.input:select()
|
self.input:select()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Set input field text
|
--- Set input field text
|
||||||
-- @tparam RichInput self RichInput
|
---@param self RichInput RichInput
|
||||||
-- @treturn druid.input Current input instance
|
-- @treturn druid.input Current input instance
|
||||||
-- @tparam string text The input text
|
---@param text string The input text
|
||||||
function M:set_text(text)
|
function M:set_text(text)
|
||||||
self.input:set_text(text)
|
self.input:set_text(text)
|
||||||
gui.set_enabled(self.placeholder.node, true and #self.input:get_text() == 0)
|
gui.set_enabled(self.placeholder.node, true and #self.input:get_text() == 0)
|
||||||
@ -291,8 +291,8 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Set input field font
|
--- Set input field font
|
||||||
-- @tparam RichInput self RichInput
|
---@param self RichInput RichInput
|
||||||
-- @tparam hash font The font hash
|
---@param font hash The font hash
|
||||||
-- @treturn druid.input Current input instance
|
-- @treturn druid.input Current input instance
|
||||||
function M:set_font(font)
|
function M:set_font(font)
|
||||||
gui.set_font(self.input.text.node, font)
|
gui.set_font(self.input.text.node, font)
|
||||||
@ -303,7 +303,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Set input field text
|
--- Set input field text
|
||||||
-- @tparam RichInput self RichInput
|
---@param self RichInput RichInput
|
||||||
function M:get_text()
|
function M:get_text()
|
||||||
return self.input:get_text()
|
return self.input:get_text()
|
||||||
end
|
end
|
||||||
@ -312,8 +312,8 @@ end
|
|||||||
--- Set allowed charaters for input field.
|
--- Set allowed charaters for input field.
|
||||||
-- See: https://defold.com/ref/stable/string/
|
-- See: https://defold.com/ref/stable/string/
|
||||||
-- ex: [%a%d] for alpha and numeric
|
-- ex: [%a%d] for alpha and numeric
|
||||||
-- @tparam RichInput self RichInput
|
---@param self RichInput RichInput
|
||||||
-- @tparam string characters Regulax exp. for validate user input
|
---@param characters string Regulax exp. for validate user input
|
||||||
-- @treturn RichInput Current instance
|
-- @treturn RichInput Current instance
|
||||||
function M:set_allowed_characters(characters)
|
function M:set_allowed_characters(characters)
|
||||||
self.input:set_allowed_characters(characters)
|
self.input:set_allowed_characters(characters)
|
||||||
|
@ -85,9 +85,9 @@ local M = component.create("rich_text")
|
|||||||
|
|
||||||
|
|
||||||
--- The RichText constructor
|
--- The RichText constructor
|
||||||
-- @tparam RichText self RichText
|
---@param self RichText RichText
|
||||||
-- @tparam node|string text_node The text node to make Rich Text
|
---@param text_node node|string The text node to make Rich Text
|
||||||
-- @tparam string|nil value The initial text value. Default will be gui.get_text(text_node)
|
---@param value string|nil The initial text value. Default will be gui.get_text(text_node)
|
||||||
function M:init(text_node, value)
|
function M:init(text_node, value)
|
||||||
self.root = self:get_node(text_node)
|
self.root = self:get_node(text_node)
|
||||||
self.text_prefab = self.root
|
self.text_prefab = self.root
|
||||||
@ -126,8 +126,8 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Set text for Rich Text
|
--- Set text for Rich Text
|
||||||
-- @tparam RichText self RichText
|
---@param self RichText RichText
|
||||||
-- @tparam string|nil text The text to set
|
---@param text string|nil The text to set
|
||||||
-- @treturn druid.rich_text.word[] words
|
-- @treturn druid.rich_text.word[] words
|
||||||
-- @treturn druid.rich_text.lines_metrics line_metrics
|
-- @treturn druid.rich_text.lines_metrics line_metrics
|
||||||
-- @usage
|
-- @usage
|
||||||
@ -189,7 +189,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Get current text
|
--- Get current text
|
||||||
-- @tparam RichText self RichText
|
---@param self RichText RichText
|
||||||
-- @treturn string text
|
-- @treturn string text
|
||||||
function M:get_text()
|
function M:get_text()
|
||||||
return self._last_value
|
return self._last_value
|
||||||
@ -214,8 +214,8 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Get all words, which has a passed tag.
|
--- Get all words, which has a passed tag.
|
||||||
-- @tparam RichText self RichText
|
---@param self RichText RichText
|
||||||
-- @tparam string tag
|
---@param tag string
|
||||||
-- @treturn druid.rich_text.word[] words
|
-- @treturn druid.rich_text.word[] words
|
||||||
function M:tagged(tag)
|
function M:tagged(tag)
|
||||||
if not self._words then
|
if not self._words then
|
||||||
@ -227,8 +227,8 @@ end
|
|||||||
|
|
||||||
|
|
||||||
---Split a word into it's characters
|
---Split a word into it's characters
|
||||||
-- @tparam RichText self RichText
|
---@param self RichText RichText
|
||||||
-- @tparam druid.rich_text.word word
|
---@param word druid.rich_text.word
|
||||||
-- @treturn druid.rich_text.word[] characters
|
-- @treturn druid.rich_text.word[] characters
|
||||||
function M:characters(word)
|
function M:characters(word)
|
||||||
return rich_text.characters(word)
|
return rich_text.characters(word)
|
||||||
|
@ -56,10 +56,10 @@ local M = component.create("data_list")
|
|||||||
|
|
||||||
|
|
||||||
--- The DataList constructor
|
--- The DataList constructor
|
||||||
-- @tparam DataList self DataList
|
---@param self DataList DataList
|
||||||
-- @tparam Scroll scroll The Scroll instance for Data List component
|
---@param scroll Scroll The Scroll instance for Data List component
|
||||||
-- @tparam StaticGrid grid The StaticGrid} or @{DynamicGrid instance for Data List component
|
---@param grid StaticGrid 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 create_function function The create function callback(self, data, index, data_list). Function should return (node, [component])
|
||||||
function M:init(scroll, grid, create_function)
|
function M:init(scroll, grid, create_function)
|
||||||
self.scroll = scroll
|
self.scroll = scroll
|
||||||
self.grid = grid
|
self.grid = grid
|
||||||
@ -87,7 +87,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Druid System on_remove function
|
--- Druid System on_remove function
|
||||||
-- @tparam DataList self DataList
|
---@param self DataList DataList
|
||||||
function M:on_remove()
|
function M:on_remove()
|
||||||
self:clear()
|
self:clear()
|
||||||
self.scroll.on_scroll:unsubscribe(self._refresh, self)
|
self.scroll.on_scroll:unsubscribe(self._refresh, self)
|
||||||
@ -95,8 +95,8 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Set refresh function for DataList component
|
--- Set refresh function for DataList component
|
||||||
-- @tparam DataList self DataList
|
---@param self DataList 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 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
|
-- @treturn druid.data_list Current DataList instance
|
||||||
function M:set_use_cache(is_use_cache)
|
function M:set_use_cache(is_use_cache)
|
||||||
self._is_use_cache = is_use_cache
|
self._is_use_cache = is_use_cache
|
||||||
@ -105,8 +105,8 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Set new data set for DataList component
|
--- Set new data set for DataList component
|
||||||
-- @tparam DataList self DataList
|
---@param self DataList DataList
|
||||||
-- @tparam table data The new data array
|
---@param data table The new data array
|
||||||
-- @treturn druid.data_list Current DataList instance
|
-- @treturn druid.data_list Current DataList instance
|
||||||
function M:set_data(data)
|
function M:set_data(data)
|
||||||
self._data = data or {}
|
self._data = data or {}
|
||||||
@ -117,7 +117,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Return current data from DataList component
|
--- Return current data from DataList component
|
||||||
-- @tparam DataList self DataList
|
---@param self DataList DataList
|
||||||
-- @treturn table The current data array
|
-- @treturn table The current data array
|
||||||
function M:get_data()
|
function M:get_data()
|
||||||
return self._data
|
return self._data
|
||||||
@ -125,10 +125,10 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Add element to DataList. Currenly untested
|
--- Add element to DataList. Currenly untested
|
||||||
-- @tparam DataList self DataList
|
---@param self DataList DataList
|
||||||
-- @tparam table data
|
---@param data table
|
||||||
-- @tparam number|nil index
|
---@param index number|nil
|
||||||
-- @tparam number|nil shift_policy The constant from const.SHIFT.*
|
---@param shift_policy number|nil The constant from const.SHIFT.*
|
||||||
function M:add(data, index, shift_policy)
|
function M:add(data, index, shift_policy)
|
||||||
index = index or #self._data + 1
|
index = index or #self._data + 1
|
||||||
shift_policy = shift_policy or const.SHIFT.RIGHT
|
shift_policy = shift_policy or const.SHIFT.RIGHT
|
||||||
@ -139,9 +139,9 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Remove element from DataList. Currenly untested
|
--- Remove element from DataList. Currenly untested
|
||||||
-- @tparam DataList self DataList
|
---@param self DataList DataList
|
||||||
-- @tparam number|nil index
|
---@param index number|nil
|
||||||
-- @tparam number|nil shift_policy The constant from const.SHIFT.*
|
---@param shift_policy number|nil The constant from const.SHIFT.*
|
||||||
function M:remove(index, shift_policy)
|
function M:remove(index, shift_policy)
|
||||||
helper.remove_with_shift(self._data, index, shift_policy)
|
helper.remove_with_shift(self._data, index, shift_policy)
|
||||||
self:_refresh()
|
self:_refresh()
|
||||||
@ -149,9 +149,9 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Remove element from DataList by data value. Currenly untested
|
--- Remove element from DataList by data value. Currenly untested
|
||||||
-- @tparam DataList self DataList
|
---@param self DataList DataList
|
||||||
-- @tparam table data
|
---@param data table
|
||||||
-- @tparam number|nil shift_policy The constant from const.SHIFT.*
|
---@param shift_policy number|nil The constant from const.SHIFT.*
|
||||||
function M:remove_by_data(data, shift_policy)
|
function M:remove_by_data(data, shift_policy)
|
||||||
local index = helper.contains(self._data, data)
|
local index = helper.contains(self._data, data)
|
||||||
if index then
|
if index then
|
||||||
@ -162,7 +162,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Clear the DataList and refresh visuals
|
--- Clear the DataList and refresh visuals
|
||||||
-- @tparam DataList self DataList
|
---@param self DataList DataList
|
||||||
function M:clear()
|
function M:clear()
|
||||||
self._data = {}
|
self._data = {}
|
||||||
self:_refresh()
|
self:_refresh()
|
||||||
@ -170,8 +170,8 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Return index for data value
|
--- Return index for data value
|
||||||
-- @tparam DataList self DataList
|
---@param self DataList DataList
|
||||||
-- @tparam table data
|
---@param data table
|
||||||
function M:get_index(data)
|
function M:get_index(data)
|
||||||
for index, value in pairs(self._data) do
|
for index, value in pairs(self._data) do
|
||||||
if value == data then
|
if value == data then
|
||||||
@ -184,7 +184,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Return all currenly created nodes in DataList
|
--- Return all currenly created nodes in DataList
|
||||||
-- @tparam DataList self DataList
|
---@param self DataList DataList
|
||||||
-- @treturn node[] List of created nodes
|
-- @treturn node[] List of created nodes
|
||||||
function M:get_created_nodes()
|
function M:get_created_nodes()
|
||||||
local nodes = {}
|
local nodes = {}
|
||||||
@ -198,7 +198,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Return all currenly created components in DataList
|
--- Return all currenly created components in DataList
|
||||||
-- @tparam DataList self DataList
|
---@param self DataList DataList
|
||||||
-- @treturn druid.base_component[] List of created nodes
|
-- @treturn druid.base_component[] List of created nodes
|
||||||
function M:get_created_components()
|
function M:get_created_components()
|
||||||
local components = {}
|
local components = {}
|
||||||
@ -212,8 +212,8 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Instant scroll to element with passed index
|
--- Instant scroll to element with passed index
|
||||||
-- @tparam DataList self DataList
|
---@param self DataList DataList
|
||||||
-- @tparam number index
|
---@param index number
|
||||||
function M:scroll_to_index(index)
|
function M:scroll_to_index(index)
|
||||||
local pos = self.grid:get_pos(index)
|
local pos = self.grid:get_pos(index)
|
||||||
self.scroll:scroll_to(pos)
|
self.scroll:scroll_to(pos)
|
||||||
@ -221,8 +221,8 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Add element at passed index using cache or create new
|
--- Add element at passed index using cache or create new
|
||||||
-- @tparam DataList self DataList
|
---@param self DataList DataList
|
||||||
-- @tparam number index
|
---@param index number
|
||||||
---@private
|
---@private
|
||||||
function M:_add_at(index)
|
function M:_add_at(index)
|
||||||
if self._data_visual[index] then
|
if self._data_visual[index] then
|
||||||
@ -255,8 +255,8 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Remove element from passed index and add it to cache if applicable
|
--- Remove element from passed index and add it to cache if applicable
|
||||||
-- @tparam DataList self DataList
|
---@param self DataList DataList
|
||||||
-- @tparam number index
|
---@param index number
|
||||||
---@private
|
---@private
|
||||||
function M:_remove_at(index)
|
function M:_remove_at(index)
|
||||||
self.grid:remove(index, const.SHIFT.NO_SHIFT)
|
self.grid:remove(index, const.SHIFT.NO_SHIFT)
|
||||||
@ -286,7 +286,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Refresh all elements in DataList
|
--- Refresh all elements in DataList
|
||||||
-- @tparam DataList self DataList
|
---@param self DataList DataList
|
||||||
---@private
|
---@private
|
||||||
function M:_refresh()
|
function M:_refresh()
|
||||||
self.scroll:set_size(self.grid:get_size_for(#self._data))
|
self.scroll:set_size(self.grid:get_size_for(#self._data))
|
||||||
|
@ -38,10 +38,10 @@ local M = component.create("hotkey")
|
|||||||
|
|
||||||
|
|
||||||
--- The Hotkey constructor
|
--- The Hotkey constructor
|
||||||
-- @tparam Hotkey self Hotkey
|
---@param self Hotkey Hotkey
|
||||||
-- @tparam string[]|string keys The keys to be pressed for trigger callback. Should contains one key and any modificator keys
|
---@param keys string[]|string The keys to be pressed for trigger callback. Should contains one key and any modificator keys
|
||||||
-- @tparam function callback The callback function
|
---@param callback function The callback function
|
||||||
-- @tparam any|nil callback_argument The argument to pass into the callback function
|
---@param callback_argument any|nil The argument to pass into the callback function
|
||||||
function M:init(keys, callback, callback_argument)
|
function M:init(keys, callback, callback_argument)
|
||||||
self.druid = self:get_druid()
|
self.druid = self:get_druid()
|
||||||
|
|
||||||
@ -73,9 +73,9 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Add hotkey for component callback
|
--- Add hotkey for component callback
|
||||||
-- @tparam Hotkey self Hotkey
|
---@param self Hotkey Hotkey
|
||||||
-- @tparam string[]|hash[]|string|hash keys that have to be pressed before key pressed to activate
|
---@param keys string[]|hash[]|string|hash that have to be pressed before key pressed to activate
|
||||||
-- @tparam any|nil callback_argument The argument to pass into the callback function
|
---@param callback_argument any|nil The argument to pass into the callback function
|
||||||
-- @treturn Hotkey Current instance
|
-- @treturn Hotkey Current instance
|
||||||
function M:add_hotkey(keys, callback_argument)
|
function M:add_hotkey(keys, callback_argument)
|
||||||
keys = keys or {}
|
keys = keys or {}
|
||||||
@ -174,8 +174,8 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- If true, the callback will be triggered on action.repeated
|
--- If true, the callback will be triggered on action.repeated
|
||||||
-- @tparam Hotkey self Hotkey
|
---@param self Hotkey Hotkey
|
||||||
-- @tparam bool is_enabled_repeated The flag value
|
---@param is_enabled_repeated bool The flag value
|
||||||
-- @treturn Hotkey
|
-- @treturn Hotkey
|
||||||
function M:set_repeat(is_enabled_repeated)
|
function M:set_repeat(is_enabled_repeated)
|
||||||
self._is_process_repeated = is_enabled_repeated
|
self._is_process_repeated = is_enabled_repeated
|
||||||
|
@ -109,8 +109,8 @@ M.ALLOWED_ACTIONS = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
--- Mask text by replacing every character with a mask character
|
--- Mask text by replacing every character with a mask character
|
||||||
-- @tparam string text
|
---@param text string
|
||||||
-- @tparam string mask
|
---@param mask string
|
||||||
-- @treturn string Masked text
|
-- @treturn string Masked text
|
||||||
local function mask_text(text, mask)
|
local function mask_text(text, mask)
|
||||||
mask = mask or "*"
|
mask = mask or "*"
|
||||||
@ -156,10 +156,10 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- The Input constructor
|
--- The Input constructor
|
||||||
-- @tparam Input self Input
|
---@param self Input Input
|
||||||
-- @tparam node click_node Node to enabled input component
|
---@param click_node 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
|
---@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
|
||||||
-- @tparam number|nil keyboard_type Gui keyboard type for input field
|
---@param keyboard_type number|nil Gui keyboard type for input field
|
||||||
function M:init(click_node, text_node, keyboard_type)
|
function M:init(click_node, text_node, keyboard_type)
|
||||||
self.druid = self:get_druid()
|
self.druid = self:get_druid()
|
||||||
|
|
||||||
@ -328,8 +328,8 @@ function M:get_text_selected()
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- Replace selected text with new text
|
--- Replace selected text with new text
|
||||||
-- @tparam Input self Input
|
---@param self Input Input
|
||||||
-- @tparam string text The text to replace selected text
|
---@param text string The text to replace selected text
|
||||||
-- @treturn string New input text
|
-- @treturn string New input text
|
||||||
function M:get_text_selected_replaced(text)
|
function M:get_text_selected_replaced(text)
|
||||||
local left_part = utf8.sub(self.value, 1, self.start_index)
|
local left_part = utf8.sub(self.value, 1, self.start_index)
|
||||||
@ -346,8 +346,8 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Set text for input field
|
--- Set text for input field
|
||||||
-- @tparam Input self Input
|
---@param self Input Input
|
||||||
-- @tparam string input_text The string to apply for input field
|
---@param input_text string The string to apply for input field
|
||||||
function M:set_text(input_text)
|
function M:set_text(input_text)
|
||||||
input_text = tostring(input_text or "")
|
input_text = tostring(input_text or "")
|
||||||
|
|
||||||
@ -395,7 +395,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Select input field. It will show the keyboard and trigger on_select events
|
--- Select input field. It will show the keyboard and trigger on_select events
|
||||||
-- @tparam Input self Input
|
---@param self Input Input
|
||||||
function M:select()
|
function M:select()
|
||||||
gui.reset_keyboard()
|
gui.reset_keyboard()
|
||||||
self.marked_value = ""
|
self.marked_value = ""
|
||||||
@ -420,7 +420,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Remove selection from input. It will hide the keyboard and trigger on_unselect events
|
--- 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()
|
function M:unselect()
|
||||||
gui.reset_keyboard()
|
gui.reset_keyboard()
|
||||||
self.marked_value = ""
|
self.marked_value = ""
|
||||||
@ -439,7 +439,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Return current input field text
|
--- Return current input field text
|
||||||
-- @tparam Input self Input
|
---@param self Input Input
|
||||||
-- @treturn string The current input field text
|
-- @treturn string The current input field text
|
||||||
function M:get_text()
|
function M:get_text()
|
||||||
if self.marked_value ~= "" then
|
if self.marked_value ~= "" then
|
||||||
@ -452,8 +452,8 @@ end
|
|||||||
|
|
||||||
--- Set maximum length for input field.
|
--- Set maximum length for input field.
|
||||||
-- Pass nil to make input field unliminted (by default)
|
-- Pass nil to make input field unliminted (by default)
|
||||||
-- @tparam Input self Input
|
---@param self Input Input
|
||||||
-- @tparam number max_length Maximum length for input text field
|
---@param max_length number Maximum length for input text field
|
||||||
-- @treturn druid.input Current input instance
|
-- @treturn druid.input Current input instance
|
||||||
function M:set_max_length(max_length)
|
function M:set_max_length(max_length)
|
||||||
self.max_length = max_length
|
self.max_length = max_length
|
||||||
@ -464,8 +464,8 @@ end
|
|||||||
--- Set allowed charaters for input field.
|
--- Set allowed charaters for input field.
|
||||||
-- See: https://defold.com/ref/stable/string/
|
-- See: https://defold.com/ref/stable/string/
|
||||||
-- ex: [%a%d] for alpha and numeric
|
-- ex: [%a%d] for alpha and numeric
|
||||||
-- @tparam Input self Input
|
---@param self Input Input
|
||||||
-- @tparam string characters Regulax exp. for validate user input
|
---@param characters string Regulax exp. for validate user input
|
||||||
-- @treturn druid.input Current input instance
|
-- @treturn druid.input Current input instance
|
||||||
function M:set_allowed_characters(characters)
|
function M:set_allowed_characters(characters)
|
||||||
self.allowed_characters = characters
|
self.allowed_characters = characters
|
||||||
@ -474,7 +474,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Reset current input selection and return previous value
|
--- Reset current input selection and return previous value
|
||||||
-- @tparam Input self Input
|
---@param self Input Input
|
||||||
-- @treturn druid.input Current input instance
|
-- @treturn druid.input Current input instance
|
||||||
function M:reset_changes()
|
function M:reset_changes()
|
||||||
self:set_text(self.previous_value)
|
self:set_text(self.previous_value)
|
||||||
@ -484,10 +484,10 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Set cursor position in input field
|
--- Set cursor position in input field
|
||||||
-- @tparam Input self Input
|
---@param self Input Input
|
||||||
-- @tparam number|nil cursor_index Cursor index for cursor position, if nil - will be set to the end of the text
|
---@param cursor_index number|nil 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
|
---@param start_index number|nil 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 end_index number|nil End index for cursor position, if nil - will be set to the start_index
|
||||||
-- @treturn druid.input Current input instance
|
-- @treturn druid.input Current input instance
|
||||||
function M:select_cursor(cursor_index, start_index, end_index)
|
function M:select_cursor(cursor_index, start_index, end_index)
|
||||||
local len = utf8.len(self.value)
|
local len = utf8.len(self.value)
|
||||||
@ -507,10 +507,10 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Change cursor position by delta
|
--- Change cursor position by delta
|
||||||
-- @tparam Input self Input
|
---@param self Input Input
|
||||||
-- @tparam number delta side for cursor position, -1 for left, 1 for right
|
---@param delta number side for cursor position, -1 for left, 1 for right
|
||||||
-- @tparam boolean is_add_to_selection (Shift key)
|
---@param is_add_to_selection boolean (Shift key)
|
||||||
-- @tparam boolean is_move_to_end (Ctrl key)
|
---@param is_move_to_end boolean (Ctrl key)
|
||||||
function M:move_selection(delta, is_add_to_selection, is_move_to_end)
|
function M:move_selection(delta, is_add_to_selection, is_move_to_end)
|
||||||
local len = utf8.len(self.value)
|
local len = utf8.len(self.value)
|
||||||
local cursor_index = self.cursor_index
|
local cursor_index = self.cursor_index
|
||||||
|
@ -42,10 +42,10 @@ local M = component.create("lang_text")
|
|||||||
|
|
||||||
|
|
||||||
--- The LangText constructor
|
--- The LangText constructor
|
||||||
-- @tparam LangText self LangText
|
---@param self LangText LangText
|
||||||
-- @tparam string|node node The node_id or gui.get_node(node_id)
|
---@param node string|node The node_id or gui.get_node(node_id)
|
||||||
-- @tparam string|nil locale_id Default locale id or text from node as default
|
---@param locale_id string|nil 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 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)
|
function M:init(node, locale_id, adjust_type)
|
||||||
self.druid = self:get_druid()
|
self.druid = self:get_druid()
|
||||||
self.text = self.druid:new_text(node, locale_id, adjust_type)
|
self.text = self.druid:new_text(node, locale_id, adjust_type)
|
||||||
@ -69,8 +69,8 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Setup raw text to lang_text component
|
--- Setup raw text to lang_text component
|
||||||
-- @tparam LangText self LangText
|
---@param self LangText LangText
|
||||||
-- @tparam string text Text for text node
|
---@param text string Text for text node
|
||||||
-- @treturn LangText Current instance
|
-- @treturn LangText Current instance
|
||||||
function M:set_to(text)
|
function M:set_to(text)
|
||||||
self.last_locale = false
|
self.last_locale = false
|
||||||
@ -82,15 +82,15 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Translate the text by locale_id
|
--- Translate the text by locale_id
|
||||||
-- @tparam LangText self LangText
|
---@param self LangText LangText
|
||||||
-- @tparam string locale_id Locale id
|
---@param locale_id string Locale id
|
||||||
-- @tparam string|nil a Optional param to string.format
|
---@param a string|nil Optional param to string.format
|
||||||
-- @tparam string|nil b Optional param to string.format
|
---@param b string|nil Optional param to string.format
|
||||||
-- @tparam string|nil c Optional param to string.format
|
---@param c string|nil Optional param to string.format
|
||||||
-- @tparam string|nil d Optional param to string.format
|
---@param d string|nil Optional param to string.format
|
||||||
-- @tparam string|nil e Optional param to string.format
|
---@param e string|nil Optional param to string.format
|
||||||
-- @tparam string|nil f Optional param to string.format
|
---@param f string|nil Optional param to string.format
|
||||||
-- @tparam string|nil g Optional param to string.format
|
---@param g string|nil Optional param to string.format
|
||||||
-- @treturn LangText Current instance
|
-- @treturn LangText Current instance
|
||||||
function M:translate(locale_id, a, b, c, d, e, f, g)
|
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_args = { a, b, c, d, e, f, g }
|
||||||
@ -102,14 +102,14 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Format string with new text params on localized text
|
--- Format string with new text params on localized text
|
||||||
-- @tparam LangText self LangText
|
---@param self LangText LangText
|
||||||
-- @tparam string|nil a Optional param to string.format
|
---@param a string|nil Optional param to string.format
|
||||||
-- @tparam string|nil b Optional param to string.format
|
---@param b string|nil Optional param to string.format
|
||||||
-- @tparam string|nil c Optional param to string.format
|
---@param c string|nil Optional param to string.format
|
||||||
-- @tparam string|nil d Optional param to string.format
|
---@param d string|nil Optional param to string.format
|
||||||
-- @tparam string|nil e Optional param to string.format
|
---@param e string|nil Optional param to string.format
|
||||||
-- @tparam string|nil f Optional param to string.format
|
---@param f string|nil Optional param to string.format
|
||||||
-- @tparam string|nil g Optional param to string.format
|
---@param g string|nil Optional param to string.format
|
||||||
-- @treturn LangText Current instance
|
-- @treturn LangText Current instance
|
||||||
function M:format(a, b, c, d, e, f, g)
|
function M:format(a, b, c, d, e, f, g)
|
||||||
self.last_locale_args = { a, b, c, d, e, f, g }
|
self.last_locale_args = { a, b, c, d, e, f, g }
|
||||||
|
@ -131,10 +131,10 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- The Progress constructor
|
--- The Progress constructor
|
||||||
-- @tparam Progress self Progress
|
---@param self Progress Progress
|
||||||
-- @tparam string|node node Node name or GUI Node itself.
|
---@param node string|node Node name or GUI Node itself.
|
||||||
-- @tparam string key Progress bar direction: const.SIDE.X or const.SIDE.Y
|
---@param key string Progress bar direction: const.SIDE.X or const.SIDE.Y
|
||||||
-- @tparam number|nil init_value Initial value of progress bar. Default: 1
|
---@param init_value number|nil Initial value of progress bar. Default: 1
|
||||||
function M:init(node, key, init_value)
|
function M:init(node, key, init_value)
|
||||||
assert(key == const.SIDE.X or const.SIDE.Y, "Progress bar key should be 'x' or 'y'")
|
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
|
--- Fill a progress bar and stop progress animation
|
||||||
-- @tparam Progress self Progress
|
---@param self Progress Progress
|
||||||
function M:fill()
|
function M:fill()
|
||||||
set_bar_to(self, 1, true)
|
set_bar_to(self, 1, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Empty a progress bar
|
--- Empty a progress bar
|
||||||
-- @tparam Progress self Progress
|
---@param self Progress Progress
|
||||||
function M:empty()
|
function M:empty()
|
||||||
set_bar_to(self, 0, true)
|
set_bar_to(self, 0, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Instant fill progress bar to value
|
--- Instant fill progress bar to value
|
||||||
-- @tparam Progress self Progress
|
---@param self Progress Progress
|
||||||
-- @tparam number to Progress bar value, from 0 to 1
|
---@param to number Progress bar value, from 0 to 1
|
||||||
function M:set_to(to)
|
function M:set_to(to)
|
||||||
to = helper.clamp(to, 0, 1)
|
to = helper.clamp(to, 0, 1)
|
||||||
set_bar_to(self, to)
|
set_bar_to(self, to)
|
||||||
@ -216,16 +216,16 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Return current progress bar value
|
--- Return current progress bar value
|
||||||
-- @tparam Progress self Progress
|
---@param self Progress Progress
|
||||||
function M:get()
|
function M:get()
|
||||||
return self.last_value
|
return self.last_value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Set points on progress bar to fire the callback
|
--- Set points on progress bar to fire the callback
|
||||||
-- @tparam Progress self Progress
|
---@param self Progress Progress
|
||||||
-- @tparam number[] steps Array of progress bar values
|
---@param steps number[] Array of progress bar values
|
||||||
-- @tparam function callback Callback on intersect step value
|
---@param callback function Callback on intersect step value
|
||||||
-- @usage progress:set_steps({0, 0.3, 0.6, 1}, function(self, step) end)
|
-- @usage progress:set_steps({0, 0.3, 0.6, 1}, function(self, step) end)
|
||||||
function M:set_steps(steps, callback)
|
function M:set_steps(steps, callback)
|
||||||
self.steps = steps
|
self.steps = steps
|
||||||
@ -234,9 +234,9 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Start animation of a progress bar
|
--- Start animation of a progress bar
|
||||||
-- @tparam Progress self Progress
|
---@param self Progress Progress
|
||||||
-- @tparam number to value between 0..1
|
---@param to number value between 0..1
|
||||||
-- @tparam function|nil callback Callback on animation ends
|
---@param callback function|nil Callback on animation ends
|
||||||
function M:to(to, callback)
|
function M:to(to, callback)
|
||||||
to = helper.clamp(to, 0, 1)
|
to = helper.clamp(to, 0, 1)
|
||||||
-- cause of float error
|
-- cause of float error
|
||||||
@ -253,8 +253,8 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Set progress bar max node size
|
--- Set progress bar max node size
|
||||||
-- @tparam Progress self Progress
|
---@param self Progress Progress
|
||||||
-- @tparam vector3 max_size The new node maximum (full) size
|
---@param max_size vector3 The new node maximum (full) size
|
||||||
-- @treturn Progress Progress
|
-- @treturn Progress Progress
|
||||||
function M:set_max_size(max_size)
|
function M:set_max_size(max_size)
|
||||||
self.max_size[self.key] = max_size[self.key]
|
self.max_size[self.key] = max_size[self.key]
|
||||||
|
@ -69,10 +69,10 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- The Slider constructor
|
--- The Slider constructor
|
||||||
-- @tparam Slider self Slider
|
---@param self Slider Slider
|
||||||
-- @tparam node node Gui pin node
|
---@param node node Gui pin node
|
||||||
-- @tparam vector3 end_pos The end position of slider
|
---@param end_pos vector3 The end position of slider
|
||||||
-- @tparam function|nil callback On slider change callback
|
---@param callback function|nil On slider change callback
|
||||||
function M:init(node, end_pos, callback)
|
function M:init(node, end_pos, callback)
|
||||||
self.node = self:get_node(node)
|
self.node = self:get_node(node)
|
||||||
|
|
||||||
@ -197,9 +197,9 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Set value for slider
|
--- Set value for slider
|
||||||
-- @tparam Slider self Slider
|
---@param self Slider Slider
|
||||||
-- @tparam number value Value from 0 to 1
|
---@param value number Value from 0 to 1
|
||||||
-- @tparam boolean|nil is_silent Don't trigger event if true
|
---@param is_silent boolean|nil Don't trigger event if true
|
||||||
function M:set(value, is_silent)
|
function M:set(value, is_silent)
|
||||||
value = helper.clamp(value, 0, 1)
|
value = helper.clamp(value, 0, 1)
|
||||||
set_position(self, value)
|
set_position(self, value)
|
||||||
@ -212,8 +212,8 @@ end
|
|||||||
|
|
||||||
--- Set slider steps. Pin node will
|
--- Set slider steps. Pin node will
|
||||||
-- apply closest step position
|
-- apply closest step position
|
||||||
-- @tparam Slider self Slider
|
---@param self Slider Slider
|
||||||
-- @tparam number[] steps Array of steps
|
---@param steps number[] Array of steps
|
||||||
-- @usage slider:set_steps({0, 0.2, 0.6, 1})
|
-- @usage slider:set_steps({0, 0.2, 0.6, 1})
|
||||||
-- @treturn Slider Slider
|
-- @treturn Slider Slider
|
||||||
function M:set_steps(steps)
|
function M:set_steps(steps)
|
||||||
@ -226,8 +226,8 @@ end
|
|||||||
-- User can touch any place of node, pin instantly will
|
-- User can touch any place of node, pin instantly will
|
||||||
-- move at this position and node drag will start.
|
-- move at this position and node drag will start.
|
||||||
-- This function require the Defold version 1.3.0+
|
-- This function require the Defold version 1.3.0+
|
||||||
-- @tparam Slider self Slider
|
---@param self Slider Slider
|
||||||
-- @tparam node|string|nil input_node
|
---@param input_node node|string|nil
|
||||||
-- @treturn Slider Slider
|
-- @treturn Slider Slider
|
||||||
function M:set_input_node(input_node)
|
function M:set_input_node(input_node)
|
||||||
self._input_node = self:get_node(input_node)
|
self._input_node = self:get_node(input_node)
|
||||||
@ -236,15 +236,15 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Set Slider input enabled or disabled
|
--- Set Slider input enabled or disabled
|
||||||
-- @tparam Slider self Slider
|
---@param self Slider Slider
|
||||||
-- @tparam boolean is_enabled
|
---@param is_enabled boolean
|
||||||
function M:set_enabled(is_enabled)
|
function M:set_enabled(is_enabled)
|
||||||
self._is_enabled = is_enabled
|
self._is_enabled = is_enabled
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Check if Slider component is enabled
|
--- Check if Slider component is enabled
|
||||||
-- @tparam Slider self Slider
|
---@param self Slider Slider
|
||||||
-- @treturn boolean
|
-- @treturn boolean
|
||||||
function M:is_enabled()
|
function M:is_enabled()
|
||||||
return self._is_enabled
|
return self._is_enabled
|
||||||
|
@ -10,10 +10,10 @@
|
|||||||
-- @alias druid.swipe
|
-- @alias druid.swipe
|
||||||
|
|
||||||
--- Swipe node
|
--- Swipe node
|
||||||
-- @tparam node node
|
---@param node node
|
||||||
|
|
||||||
--- Restriction zone
|
--- Restriction zone
|
||||||
-- @tparam node|nil click_zone
|
---@param click_zone node|nil
|
||||||
|
|
||||||
--- Trigger on swipe event(self, swipe_side, dist, delta_time)
|
--- Trigger on swipe event(self, swipe_side, dist, delta_time)
|
||||||
-- @tfield druid.event on_swipe) druid.event
|
-- @tfield druid.event on_swipe) druid.event
|
||||||
@ -160,8 +160,8 @@ end
|
|||||||
|
|
||||||
--- Strict swipe click area. Useful for
|
--- Strict swipe click area. Useful for
|
||||||
-- restrict events outside stencil node
|
-- restrict events outside stencil node
|
||||||
-- @tparam Swipe self Swipe
|
---@param self Swipe Swipe
|
||||||
-- @tparam node|string|nil zone Gui node
|
---@param zone node|string|nil Gui node
|
||||||
function M:set_click_zone(zone)
|
function M:set_click_zone(zone)
|
||||||
self.click_zone = self:get_node(zone)
|
self.click_zone = self:get_node(zone)
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user