mirror of
https://github.com/Insality/druid
synced 2025-06-27 10:27:48 +02:00
Update annotations
This commit is contained in:
parent
60ef641276
commit
999c6222a0
@ -185,7 +185,7 @@ For a complete overview, see: **_[components.md](docs_md/01-components.md)_**.
|
|||||||
|
|
||||||
## Druid Events
|
## Druid Events
|
||||||
|
|
||||||
Any **Druid** components as callbacks use [Druid Events](https://insality.github.io/druid/modules/DruidEvent.html). In component API ([button example](https://insality.github.io/druid/modules/Button.html#on_click)) pointed list of component events. You can manually subscribe to these events with the following API:
|
Any **Druid** components as callbacks use [Druid Events](https://insality.github.io/druid/modules/druid.event.html). In component API ([button example](https://insality.github.io/druid/modules/Button.html#on_click)) pointed list of component events. You can manually subscribe to these events with the following API:
|
||||||
|
|
||||||
- **event:subscribe**(callback)
|
- **event:subscribe**(callback)
|
||||||
|
|
||||||
|
@ -35,16 +35,16 @@
|
|||||||
-- @alias druid.button
|
-- @alias druid.button
|
||||||
|
|
||||||
|
|
||||||
--- The DruidEvent: Event on successful release action over button.
|
--- The druid.event: Event on successful release action over button.
|
||||||
-- @usage
|
-- @usage
|
||||||
-- -- Custom args passed in Button constructor
|
-- -- Custom args passed in Button constructor
|
||||||
-- button.on_click:subscribe(function(self, custom_args, button_instance)
|
-- button.on_click:subscribe(function(self, custom_args, button_instance)
|
||||||
-- print("On button click!")
|
-- print("On button click!")
|
||||||
-- end)
|
-- end)
|
||||||
-- @tfield DruidEvent on_click DruidEvent
|
-- @tfield druid.event on_click druid.event
|
||||||
|
|
||||||
|
|
||||||
--- The DruidEvent: Event on repeated action over button.
|
--- The druid.event: Event on repeated action over button.
|
||||||
--
|
--
|
||||||
-- This callback will be triggered if user hold the button. The repeat rate pick from `input.repeat_interval` in game.project
|
-- This callback will be triggered if user hold the button. The repeat rate pick from `input.repeat_interval` in game.project
|
||||||
-- @usage
|
-- @usage
|
||||||
@ -52,10 +52,10 @@
|
|||||||
-- button.on_repeated_click:subscribe(function(self, custom_args, button_instance, click_count)
|
-- button.on_repeated_click:subscribe(function(self, custom_args, button_instance, click_count)
|
||||||
-- print("On repeated Button click!")
|
-- print("On repeated Button click!")
|
||||||
-- end)
|
-- end)
|
||||||
-- @tfield DruidEvent on_repeated_click DruidEvent
|
-- @tfield druid.event on_repeated_click druid.event
|
||||||
|
|
||||||
|
|
||||||
--- The DruidEvent: Event on long tap action over button.
|
--- The druid.event: Event on long tap action over button.
|
||||||
--
|
--
|
||||||
-- This callback will be triggered if user pressed the button and hold the some amount of time.
|
-- This callback will be triggered if user pressed the button and hold the some amount of time.
|
||||||
-- The amount of time picked from button style param: LONGTAP_TIME
|
-- The amount of time picked from button style param: LONGTAP_TIME
|
||||||
@ -64,10 +64,10 @@
|
|||||||
-- button.on_long_click:subscribe(function(self, custom_args, button_instance, hold_time)
|
-- button.on_long_click:subscribe(function(self, custom_args, button_instance, hold_time)
|
||||||
-- print("On long Button click!")
|
-- print("On long Button click!")
|
||||||
-- end)
|
-- end)
|
||||||
-- @tfield DruidEvent on_long_click DruidEvent
|
-- @tfield druid.event on_long_click druid.event
|
||||||
|
|
||||||
|
|
||||||
--- The DruidEvent: Event on double tap action over button.
|
--- The druid.event: Event on double tap action over button.
|
||||||
--
|
--
|
||||||
-- If secondary click was too fast after previous one, the double
|
-- If secondary click was too fast after previous one, the double
|
||||||
-- click will be called instead usual click (if on_double_click subscriber exists)
|
-- click will be called instead usual click (if on_double_click subscriber exists)
|
||||||
@ -76,10 +76,10 @@
|
|||||||
-- button.on_double_click:subscribe(function(self, custom_args, button_instance, click_amount)
|
-- button.on_double_click:subscribe(function(self, custom_args, button_instance, click_amount)
|
||||||
-- print("On double Button click!")
|
-- print("On double Button click!")
|
||||||
-- end)
|
-- end)
|
||||||
-- @tfield DruidEvent on_double_click DruidEvent
|
-- @tfield druid.event on_double_click druid.event
|
||||||
|
|
||||||
|
|
||||||
--- The DruidEvent: Event calls every frame before on_long_click event.
|
--- The druid.event: Event calls every frame before on_long_click event.
|
||||||
--
|
--
|
||||||
-- If long_click subscriber exists, the on_hold_callback will be called before long_click trigger.
|
-- If long_click subscriber exists, the on_hold_callback will be called before long_click trigger.
|
||||||
--
|
--
|
||||||
@ -89,10 +89,10 @@
|
|||||||
-- button.on_double_click:subscribe(function(self, custom_args, button_instance, time)
|
-- button.on_double_click:subscribe(function(self, custom_args, button_instance, time)
|
||||||
-- print("On hold Button callback!")
|
-- print("On hold Button callback!")
|
||||||
-- end)
|
-- end)
|
||||||
-- @tfield DruidEvent on_hold_callback DruidEvent
|
-- @tfield druid.event on_hold_callback druid.event
|
||||||
|
|
||||||
|
|
||||||
--- The DruidEvent: Event calls if click event was outside of button.
|
--- The druid.event: Event calls if click event was outside of button.
|
||||||
--
|
--
|
||||||
-- This event will be triggered for each button what was not clicked on user click action
|
-- This event will be triggered for each button what was not clicked on user click action
|
||||||
--
|
--
|
||||||
@ -102,16 +102,16 @@
|
|||||||
-- button.on_click_outside:subscribe(function(self, custom_args, button_instance)
|
-- button.on_click_outside:subscribe(function(self, custom_args, button_instance)
|
||||||
-- print("On click Button outside!")
|
-- print("On click Button outside!")
|
||||||
-- end)
|
-- end)
|
||||||
-- @tfield DruidEvent on_click_outside DruidEvent
|
-- @tfield druid.event on_click_outside druid.event
|
||||||
|
|
||||||
|
|
||||||
--- The DruidEvent: Event triggered if button was pressed by user.
|
--- The druid.event: Event triggered if button was pressed by user.
|
||||||
-- @usage
|
-- @usage
|
||||||
-- -- Custom args passed in Button constructor
|
-- -- Custom args passed in Button constructor
|
||||||
-- button.on_pressed:subscribe(function(self, custom_args, button_instance)
|
-- button.on_pressed:subscribe(function(self, custom_args, button_instance)
|
||||||
-- print("On Button pressed!")
|
-- print("On Button pressed!")
|
||||||
-- end)
|
-- end)
|
||||||
-- @tfield DruidEvent on_pressed DruidEvent
|
-- @tfield druid.event on_pressed druid.event
|
||||||
|
|
||||||
--- Button trigger node
|
--- Button trigger node
|
||||||
-- @tfield node node
|
-- @tfield node node
|
||||||
@ -279,17 +279,19 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Component style params.
|
--- Component style params.
|
||||||
-- You can override this component styles params in Druid styles table
|
---You can override this component styles params in Druid styles table
|
||||||
-- or create your own style
|
---or create your own style
|
||||||
-- @table style
|
---@class druid.button.style
|
||||||
-- @tfield number|nil LONGTAP_TIME Minimum time to trigger on_hold_callback. Default: 0.4
|
---@field LONGTAP_TIME number|nil Minimum time to trigger on_hold_callback. Default: 0.4
|
||||||
-- @tfield number|nil AUTOHOLD_TRIGGER Maximum hold time to trigger button release while holding. Default: 0.8
|
---@field AUTOHOLD_TRIGGER number|nil Maximum hold time to trigger button release while holding. Default: 0.8
|
||||||
-- @tfield number|nil DOUBLETAP_TIME Time between double taps. Default: 0.4
|
---@field DOUBLETAP_TIME number|nil Time between double taps. Default: 0.4
|
||||||
-- @tfield function on_click function(self, node)
|
---@field on_click fun(self, node)|nil
|
||||||
-- @tfield function on_click_disabled function(self, node)
|
---@field on_click_disabled fun(self, node)|nil
|
||||||
-- @tfield function on_hover function(self, node, hover_state)
|
---@field on_hover fun(self, node, hover_state)|nil
|
||||||
-- @tfield function on_mouse_hover function(self, node, hover_state)
|
---@field on_mouse_hover fun(self, node, hover_state)|nil
|
||||||
-- @tfield function on_set_enabled function(self, node, enabled_state)
|
---@field on_set_enabled fun(self, node, enabled_state)|nil
|
||||||
|
|
||||||
|
---@param style druid.button.style
|
||||||
function M:on_style_change(style)
|
function M:on_style_change(style)
|
||||||
self.style = {}
|
self.style = {}
|
||||||
self.style.LONGTAP_TIME = style.LONGTAP_TIME or 0.4
|
self.style.LONGTAP_TIME = style.LONGTAP_TIME or 0.4
|
||||||
@ -469,12 +471,8 @@ 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 Button self Button
|
|
||||||
-- @tparam boolean|nil state Enabled state
|
-- @tparam boolean|nil state Enabled state
|
||||||
-- @treturn Button Current button instance
|
---@return druid.button self
|
||||||
-- @usage
|
|
||||||
-- button:set_enabled(false)
|
|
||||||
-- button:set_enabled(true)
|
|
||||||
function M:set_enabled(state)
|
function M:set_enabled(state)
|
||||||
self.disabled = not state
|
self.disabled = not state
|
||||||
self.hover:set_enabled(state)
|
self.hover:set_enabled(state)
|
||||||
@ -487,10 +485,7 @@ end
|
|||||||
--- Get button enabled state.
|
--- Get button enabled state.
|
||||||
--
|
--
|
||||||
-- By default all Buttons is enabled on creating.
|
-- By default all Buttons is enabled on creating.
|
||||||
-- @tparam Button self Button
|
---@return boolean @True, if button is enabled now, False overwise
|
||||||
-- @treturn boolean @True, if button is enabled now, False overwise
|
|
||||||
-- @usage
|
|
||||||
-- local is_enabled = button:is_enabled()
|
|
||||||
function M:is_enabled()
|
function M:is_enabled()
|
||||||
return not self.disabled
|
return not self.disabled
|
||||||
end
|
end
|
||||||
@ -500,11 +495,8 @@ 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 Button self Button
|
|
||||||
-- @tparam node|string|nil zone Gui node
|
-- @tparam node|string|nil zone Gui node
|
||||||
-- @treturn Button Current button instance
|
---@return druid.button self
|
||||||
-- @usage
|
|
||||||
-- button:set_click_zone("stencil_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)
|
||||||
self.hover:set_click_zone(zone)
|
self.hover:set_click_zone(zone)
|
||||||
@ -514,11 +506,8 @@ end
|
|||||||
|
|
||||||
|
|
||||||
---Set key name to trigger this button by keyboard.
|
---Set key name to trigger this button by keyboard.
|
||||||
-- @tparam Button self Button
|
---@param key hash|string The action_id of the input key. Example: "key_space"
|
||||||
-- @tparam hash|string key The action_id of the input key
|
---@return druid.button self
|
||||||
-- @treturn Button Current button instance
|
|
||||||
-- @usage
|
|
||||||
-- button:set_key_trigger("key_space")
|
|
||||||
function M:set_key_trigger(key)
|
function M:set_key_trigger(key)
|
||||||
self.key_trigger = hash(key)
|
self.key_trigger = hash(key)
|
||||||
|
|
||||||
@ -527,20 +516,16 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Get current key name to trigger this button.
|
--- Get current key name to trigger this button.
|
||||||
-- @tparam Button self
|
---@return hash key_trigger The action_id of the input key
|
||||||
-- @treturn hash The action_id of the input key
|
|
||||||
-- @usage
|
|
||||||
-- local key_hash = button:get_key_trigger()
|
|
||||||
function M:get_key_trigger()
|
function M:get_key_trigger()
|
||||||
return self.key_trigger
|
return self.key_trigger
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Set function for additional check for button click availability
|
--- Set function for additional check for button click availability
|
||||||
-- @tparam Button self
|
|
||||||
-- @tparam function|nil check_function Should return true or false. If true - button can be pressed.
|
-- @tparam function|nil check_function 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
|
-- @tparam function|nil failure_callback Function will be called on button click, if check function return false
|
||||||
-- @treturn Button Current button instance
|
---@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
|
||||||
self._failure_callback = failure_callback
|
self._failure_callback = failure_callback
|
||||||
@ -553,11 +538,8 @@ 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 Button self
|
|
||||||
-- @tparam boolean|nil is_web_mode If true - button will be called inside html5 callback
|
-- @tparam boolean|nil is_web_mode If true - button will be called inside html5 callback
|
||||||
-- @treturn Button Current button instance
|
---@return druid.button self
|
||||||
-- @usage
|
|
||||||
-- button:set_web_user_interaction(true)
|
|
||||||
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)
|
||||||
return self
|
return self
|
||||||
|
@ -14,19 +14,19 @@
|
|||||||
-- @tfield node node
|
-- @tfield node node
|
||||||
|
|
||||||
--- Event on touch start callback(self)
|
--- Event on touch start callback(self)
|
||||||
-- @tfield DruidEvent on_touch_start DruidEvent
|
-- @tfield druid.event on_touch_start druid.event
|
||||||
|
|
||||||
--- Event on touch end callback(self)
|
--- Event on touch end callback(self)
|
||||||
-- @tfield DruidEvent on_touch_end DruidEvent
|
-- @tfield druid.event on_touch_end druid.event
|
||||||
|
|
||||||
--- Event on drag start callback(self, touch)
|
--- Event on drag start callback(self, touch)
|
||||||
-- @tfield DruidEvent on_drag_start DruidEvent
|
-- @tfield druid.event on_drag_start druid.event
|
||||||
|
|
||||||
--- on drag progress callback(self, dx, dy, total_x, total_y, touch)
|
--- on drag progress callback(self, dx, dy, total_x, total_y, touch)
|
||||||
-- @tfield DruidEvent on_drag Event DruidEvent
|
-- @tfield druid.event on_drag Event druid.event
|
||||||
|
|
||||||
--- Event on drag end callback(self, total_x, total_y, touch)
|
--- Event on drag end callback(self, total_x, total_y, touch)
|
||||||
-- @tfield DruidEvent on_drag_end DruidEvent
|
-- @tfield druid.event on_drag_end druid.event
|
||||||
|
|
||||||
--- Is component now touching
|
--- Is component now touching
|
||||||
-- @tfield boolean is_touch
|
-- @tfield boolean is_touch
|
||||||
|
@ -9,10 +9,10 @@
|
|||||||
-- @tfield node node
|
-- @tfield node node
|
||||||
|
|
||||||
--- On hover callback(self, state, hover_instance)
|
--- On hover callback(self, state, hover_instance)
|
||||||
-- @tfield DruidEvent on_hover DruidEvent
|
-- @tfield druid.event on_hover druid.event
|
||||||
|
|
||||||
--- On mouse hover callback(self, state, hover_instance)
|
--- On mouse hover callback(self, state, hover_instance)
|
||||||
-- @tfield DruidEvent on_mouse_hover DruidEvent
|
-- @tfield druid.event on_mouse_hover druid.event
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@ -39,13 +39,13 @@
|
|||||||
|
|
||||||
|
|
||||||
--- On scroll move callback(self, position)
|
--- On scroll move callback(self, position)
|
||||||
-- @tfield DruidEvent on_scroll DruidEvent
|
-- @tfield druid.event on_scroll druid.event
|
||||||
|
|
||||||
--- On scroll_to function callback(self, target, is_instant)
|
--- On scroll_to function callback(self, target, is_instant)
|
||||||
-- @tfield DruidEvent on_scroll_to DruidEvent
|
-- @tfield druid.event on_scroll_to druid.event
|
||||||
|
|
||||||
--- On scroll_to_index function callback(self, index, point)
|
--- On scroll_to_index function callback(self, index, point)
|
||||||
-- @tfield DruidEvent on_point_scroll DruidEvent
|
-- @tfield druid.event on_point_scroll druid.event
|
||||||
|
|
||||||
--- Scroll view node
|
--- Scroll view node
|
||||||
-- @tfield node view_node
|
-- @tfield node view_node
|
||||||
@ -651,7 +651,7 @@ end
|
|||||||
--- Find closer point of interest
|
--- Find closer point of interest
|
||||||
-- if no inert, scroll to next point by scroll direction
|
-- if no inert, scroll to next point by scroll direction
|
||||||
-- if inert, find next point by scroll director
|
-- if inert, find next point by scroll director
|
||||||
-- @local
|
---@private
|
||||||
function M:_check_points()
|
function M:_check_points()
|
||||||
if not self.points then
|
if not self.points then
|
||||||
return
|
return
|
||||||
|
@ -37,19 +37,19 @@
|
|||||||
-- @alias druid.static_grid
|
-- @alias druid.static_grid
|
||||||
|
|
||||||
--- On item add callback(self, node, index)
|
--- On item add callback(self, node, index)
|
||||||
-- @tfield DruidEvent on_add_item DruidEvent
|
-- @tfield druid.event on_add_item druid.event
|
||||||
|
|
||||||
--- On item remove callback(self, index)
|
--- On item remove callback(self, index)
|
||||||
-- @tfield DruidEvent on_remove_item DruidEvent
|
-- @tfield druid.event on_remove_item druid.event
|
||||||
|
|
||||||
--- On item add, remove or change in_row callback(self, index|nil)
|
--- On item add, remove or change in_row callback(self, index|nil)
|
||||||
-- @tfield DruidEvent on_change_items DruidEvent
|
-- @tfield druid.event on_change_items druid.event
|
||||||
|
|
||||||
--- On grid clear callback(self)
|
--- On grid clear callback(self)
|
||||||
-- @tfield DruidEvent on_clear DruidEvent
|
-- @tfield druid.event on_clear druid.event
|
||||||
|
|
||||||
--- On update item positions callback(self)
|
--- On update item positions callback(self)
|
||||||
-- @tfield DruidEvent on_update_positions DruidEvent
|
-- @tfield druid.event on_update_positions druid.event
|
||||||
|
|
||||||
--- Parent gui node
|
--- Parent gui node
|
||||||
-- @tfield node parent
|
-- @tfield node parent
|
||||||
@ -491,7 +491,7 @@ end
|
|||||||
--- Update grid inner state
|
--- Update grid inner state
|
||||||
-- @tparam StaticGrid self StaticGrid
|
-- @tparam StaticGrid self StaticGrid
|
||||||
-- @tparam boolean|nil is_instant If true, node position update instantly, otherwise with set_position_function callback
|
-- @tparam boolean|nil is_instant If true, node position update instantly, otherwise with set_position_function callback
|
||||||
-- @local
|
---@private
|
||||||
function M:_update(is_instant)
|
function M:_update(is_instant)
|
||||||
self:_update_indexes()
|
self:_update_indexes()
|
||||||
self:_update_borders()
|
self:_update_borders()
|
||||||
@ -501,7 +501,7 @@ end
|
|||||||
|
|
||||||
--- Update first and last indexes of grid nodes
|
--- Update first and last indexes of grid nodes
|
||||||
-- @tparam StaticGrid self StaticGrid
|
-- @tparam StaticGrid self StaticGrid
|
||||||
-- @local
|
---@private
|
||||||
function M:_update_indexes()
|
function M:_update_indexes()
|
||||||
self.first_index = nil
|
self.first_index = nil
|
||||||
self.last_index = nil
|
self.last_index = nil
|
||||||
@ -517,7 +517,7 @@ end
|
|||||||
|
|
||||||
--- Update grid content borders, recalculate min and max values
|
--- Update grid content borders, recalculate min and max values
|
||||||
-- @tparam StaticGrid self StaticGrid
|
-- @tparam StaticGrid self StaticGrid
|
||||||
-- @local
|
---@private
|
||||||
function M:_update_borders()
|
function M:_update_borders()
|
||||||
if not self.first_index then
|
if not self.first_index then
|
||||||
self.border = vmath.vector4(0)
|
self.border = vmath.vector4(0)
|
||||||
@ -537,7 +537,7 @@ end
|
|||||||
--- Update grid nodes position
|
--- Update grid nodes position
|
||||||
-- @tparam StaticGrid self StaticGrid
|
-- @tparam StaticGrid self StaticGrid
|
||||||
-- @tparam boolean|nil is_instant If true, node position update instantly, otherwise with set_position_function callback
|
-- @tparam boolean|nil is_instant If true, node position update instantly, otherwise with set_position_function callback
|
||||||
-- @local
|
---@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()
|
||||||
|
|
||||||
@ -560,7 +560,7 @@ end
|
|||||||
--- Return elements offset for correct posing nodes. Correct posing at
|
--- Return elements offset for correct posing nodes. Correct posing at
|
||||||
-- parent pivot node (0:0) with adjusting of node sizes and anchoring
|
-- parent pivot node (0:0) with adjusting of node sizes and anchoring
|
||||||
-- @treturn vector3 The offset vector
|
-- @treturn vector3 The offset vector
|
||||||
-- @local
|
---@private
|
||||||
function M:_get_zero_offset()
|
function M:_get_zero_offset()
|
||||||
if not self.style.IS_DYNAMIC_NODE_POSES then
|
if not self.style.IS_DYNAMIC_NODE_POSES then
|
||||||
return const.VECTOR_ZERO
|
return const.VECTOR_ZERO
|
||||||
@ -577,7 +577,7 @@ end
|
|||||||
|
|
||||||
--- Return offset x for last row in grid. Used to align this row accorting to grid's anchor
|
--- Return offset x for last row in grid. Used to align this row accorting to grid's anchor
|
||||||
-- @treturn number The offset x value
|
-- @treturn number The offset x value
|
||||||
-- @local
|
---@private
|
||||||
function M:_get_zero_offset_x(row_index)
|
function M:_get_zero_offset_x(row_index)
|
||||||
if not self.style.IS_DYNAMIC_NODE_POSES or not self.style.IS_ALIGN_LAST_ROW then
|
if not self.style.IS_DYNAMIC_NODE_POSES or not self.style.IS_ALIGN_LAST_ROW then
|
||||||
return self._zero_offset.x
|
return self._zero_offset.x
|
||||||
|
@ -36,13 +36,13 @@
|
|||||||
-- @alias druid.text
|
-- @alias druid.text
|
||||||
|
|
||||||
--- On set text callback(self, text)
|
--- On set text callback(self, text)
|
||||||
-- @tfield DruidEvent on_set_text DruidEvent
|
-- @tfield druid.event on_set_text druid.event
|
||||||
|
|
||||||
--- On adjust text size callback(self, new_scale, text_metrics)
|
--- On adjust text size callback(self, new_scale, text_metrics)
|
||||||
-- @tfield DruidEvent on_update_text_scale DruidEvent
|
-- @tfield druid.event on_update_text_scale druid.event
|
||||||
|
|
||||||
--- On change pivot callback(self, pivot)
|
--- On change pivot callback(self, pivot)
|
||||||
-- @tfield DruidEvent on_set_pivot DruidEvent
|
-- @tfield druid.event on_set_pivot druid.event
|
||||||
|
|
||||||
--- Text node
|
--- Text node
|
||||||
-- @tfield node node
|
-- @tfield node node
|
||||||
|
@ -2,10 +2,6 @@
|
|||||||
-- Author: Britzl
|
-- Author: Britzl
|
||||||
-- Modified by: Insality
|
-- Modified by: Insality
|
||||||
|
|
||||||
--- RT
|
|
||||||
-- @module rich_text.rt
|
|
||||||
-- @local
|
|
||||||
|
|
||||||
local helper = require("druid.helper")
|
local helper = require("druid.helper")
|
||||||
local parser = require("druid.custom.rich_text.module.rt_parse")
|
local parser = require("druid.custom.rich_text.module.rt_parse")
|
||||||
local utf8_lua = require("druid.system.utf8")
|
local utf8_lua = require("druid.system.utf8")
|
||||||
|
@ -29,6 +29,7 @@ end
|
|||||||
---Register component just makes the druid:new_{name} function.
|
---Register component just makes the druid:new_{name} function.
|
||||||
---For example, if you register a component called "my_component", you can create it using druid:new_my_component(...).
|
---For example, if you register a component called "my_component", you can create it using druid:new_my_component(...).
|
||||||
---This can be useful if you have your own "basic" components that you don't want to require in every file.
|
---This can be useful if you have your own "basic" components that you don't want to require in every file.
|
||||||
|
---The default way to create component is `druid_instance:new(component_class, ...)`.
|
||||||
---@param name string Module name
|
---@param name string Module name
|
||||||
---@param module table Lua table with component
|
---@param module table Lua table with component
|
||||||
function M.register(name, module)
|
function M.register(name, module)
|
||||||
@ -101,6 +102,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
---Call this function when the game language changes.
|
---Call this function when the game language changes.
|
||||||
|
---It will notify all Druid instances to update the lang text components.
|
||||||
function M.on_language_change()
|
function M.on_language_change()
|
||||||
local instances = get_druid_instances()
|
local instances = get_druid_instances()
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
---Event system for Druid
|
||||||
---@class druid.event
|
---@class druid.event
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
@ -31,7 +32,7 @@ end
|
|||||||
--- Check is event subscribed.
|
--- Check is event subscribed.
|
||||||
---@param callback fun() Callback itself
|
---@param callback fun() Callback itself
|
||||||
---@param callback_context any|nil Additional context as first param to callback call
|
---@param callback_context any|nil Additional context as first param to callback call
|
||||||
-- @treturn boolean, number|nil @Is event subscribed, return index of callback in event as second param
|
---@return boolean, number|nil Is event subscribed, return index of callback in event as second param
|
||||||
function M:is_subscribed(callback, callback_context)
|
function M:is_subscribed(callback, callback_context)
|
||||||
if #self == 0 then
|
if #self == 0 then
|
||||||
return false, nil
|
return false, nil
|
||||||
|
@ -25,13 +25,13 @@
|
|||||||
-- @tfield number last_index
|
-- @tfield number last_index
|
||||||
|
|
||||||
--- Event triggered when scroll progress is changed; event(self, progress_value)
|
--- Event triggered when scroll progress is changed; event(self, progress_value)
|
||||||
-- @tfield DruidEvent on_scroll_progress_change DruidEvent
|
-- @tfield druid.event on_scroll_progress_change druid.event
|
||||||
|
|
||||||
---On DataList visual element created Event callback(self, index, node, instance)
|
---On DataList visual element created Event callback(self, index, node, instance)
|
||||||
-- @tfield DruidEvent on_element_add DruidEvent
|
-- @tfield druid.event on_element_add druid.event
|
||||||
|
|
||||||
---On DataList visual element created Event callback(self, index)
|
---On DataList visual element created Event callback(self, index)
|
||||||
-- @tfield DruidEvent on_element_remove DruidEvent
|
-- @tfield druid.event on_element_remove druid.event
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@ -223,7 +223,7 @@ 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
|
-- @tparam DataList self DataList
|
||||||
-- @tparam number index
|
-- @tparam number index
|
||||||
-- @local
|
---@private
|
||||||
function M:_add_at(index)
|
function M:_add_at(index)
|
||||||
if self._data_visual[index] then
|
if self._data_visual[index] then
|
||||||
self:_remove_at(index)
|
self:_remove_at(index)
|
||||||
@ -257,7 +257,7 @@ 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
|
-- @tparam DataList self DataList
|
||||||
-- @tparam number index
|
-- @tparam number index
|
||||||
-- @local
|
---@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)
|
||||||
|
|
||||||
@ -287,7 +287,7 @@ end
|
|||||||
|
|
||||||
--- Refresh all elements in DataList
|
--- Refresh all elements in DataList
|
||||||
-- @tparam DataList self DataList
|
-- @tparam DataList self DataList
|
||||||
-- @local
|
---@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))
|
||||||
|
|
||||||
|
@ -8,10 +8,10 @@
|
|||||||
-- @alias druid.hotkey
|
-- @alias druid.hotkey
|
||||||
|
|
||||||
--- On hotkey released callback(self, argument)
|
--- On hotkey released callback(self, argument)
|
||||||
-- @tfield DruidEvent on_hotkey_pressed DruidEvent
|
-- @tfield druid.event on_hotkey_pressed druid.event
|
||||||
|
|
||||||
--- On hotkey released callback(self, argument)
|
--- On hotkey released callback(self, argument)
|
||||||
-- @tfield DruidEvent on_hotkey_released DruidEvent
|
-- @tfield druid.event on_hotkey_released druid.event
|
||||||
|
|
||||||
--- Visual node
|
--- Visual node
|
||||||
-- @tfield node node
|
-- @tfield node node
|
||||||
|
@ -10,25 +10,25 @@
|
|||||||
-- @alias druid.input
|
-- @alias druid.input
|
||||||
|
|
||||||
--- On input field select callback(self, input_instance)
|
--- On input field select callback(self, input_instance)
|
||||||
-- @tfield DruidEvent on_input_select DruidEvent
|
-- @tfield druid.event on_input_select druid.event
|
||||||
|
|
||||||
--- On input field unselect callback(self, input_text, input_instance)
|
--- On input field unselect callback(self, input_text, input_instance)
|
||||||
-- @tfield DruidEvent on_input_unselect DruidEvent
|
-- @tfield druid.event on_input_unselect druid.event
|
||||||
|
|
||||||
--- On input field text change callback(self, input_text)
|
--- On input field text change callback(self, input_text)
|
||||||
-- @tfield DruidEvent on_input_text DruidEvent
|
-- @tfield druid.event on_input_text druid.event
|
||||||
|
|
||||||
--- On input field text change to empty string callback(self, input_text)
|
--- On input field text change to empty string callback(self, input_text)
|
||||||
-- @tfield DruidEvent on_input_empty DruidEvent
|
-- @tfield druid.event on_input_empty druid.event
|
||||||
|
|
||||||
--- On input field text change to max length string callback(self, input_text)
|
--- On input field text change to max length string callback(self, input_text)
|
||||||
-- @tfield DruidEvent on_input_full DruidEvent
|
-- @tfield druid.event on_input_full druid.event
|
||||||
|
|
||||||
--- On trying user input with not allowed character callback(self, params, input_text)
|
--- On trying user input with not allowed character callback(self, params, input_text)
|
||||||
-- @tfield DruidEvent on_input_wrong DruidEvent
|
-- @tfield druid.event on_input_wrong druid.event
|
||||||
|
|
||||||
--- On cursor position change callback(self, cursor_index, start_index, end_index)
|
--- On cursor position change callback(self, cursor_index, start_index, end_index)
|
||||||
-- @tfield DruidEvent on_select_cursor_change DruidEvent
|
-- @tfield druid.event on_select_cursor_change druid.event
|
||||||
|
|
||||||
--- The cursor index. The index of letter cursor after. Leftmost cursor - 0
|
--- The cursor index. The index of letter cursor after. Leftmost cursor - 0
|
||||||
-- @tfield number cursor_index
|
-- @tfield number cursor_index
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
-- @alias druid.lang_text
|
-- @alias druid.lang_text
|
||||||
|
|
||||||
--- On change text callback
|
--- On change text callback
|
||||||
-- @tfield DruidEvent on_change DruidEvent
|
-- @tfield druid.event on_change druid.event
|
||||||
|
|
||||||
--- The text component
|
--- The text component
|
||||||
-- @tfield Text text Text
|
-- @tfield Text text Text
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
-- @alias druid.progress
|
-- @alias druid.progress
|
||||||
|
|
||||||
--- On progress bar change callback(self, new_value)
|
--- On progress bar change callback(self, new_value)
|
||||||
-- @tfield DruidEvent on_change DruidEvent
|
-- @tfield druid.event on_change druid.event
|
||||||
|
|
||||||
--- Progress bar fill node
|
--- Progress bar fill node
|
||||||
-- @tfield node node
|
-- @tfield node node
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
-- @alias druid.slider
|
-- @alias druid.slider
|
||||||
|
|
||||||
--- On change value callback(self, value)
|
--- On change value callback(self, value)
|
||||||
-- @tfield DruidEvent on_change_value DruidEvent
|
-- @tfield druid.event on_change_value druid.event
|
||||||
|
|
||||||
--- Slider pin node
|
--- Slider pin node
|
||||||
-- @tfield node node
|
-- @tfield node node
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
-- @tparam node|nil click_zone
|
-- @tparam node|nil click_zone
|
||||||
|
|
||||||
--- Trigger on swipe event(self, swipe_side, dist, delta_time)
|
--- Trigger on swipe event(self, swipe_side, dist, delta_time)
|
||||||
-- @tfield DruidEvent on_swipe) DruidEvent
|
-- @tfield druid.event on_swipe) druid.event
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -13,7 +13,6 @@ local POSITION_X = hash("position.x")
|
|||||||
local SCALE_X = hash("scale.x")
|
local SCALE_X = hash("scale.x")
|
||||||
local SIZE_X = hash("size.x")
|
local SIZE_X = hash("size.x")
|
||||||
|
|
||||||
|
|
||||||
local function get_text_width(text_node)
|
local function get_text_width(text_node)
|
||||||
if text_node then
|
if text_node then
|
||||||
local text_metrics = M.get_text_metrics_from_node(text_node)
|
local text_metrics = M.get_text_metrics_from_node(text_node)
|
||||||
@ -138,10 +137,15 @@ end
|
|||||||
---@return number stretch_y
|
---@return number stretch_y
|
||||||
function M.get_screen_aspect_koef()
|
function M.get_screen_aspect_koef()
|
||||||
local window_x, window_y = window.get_size()
|
local window_x, window_y = window.get_size()
|
||||||
|
|
||||||
local stretch_x = window_x / gui.get_width()
|
local stretch_x = window_x / gui.get_width()
|
||||||
local stretch_y = window_y / gui.get_height()
|
local stretch_y = window_y / gui.get_height()
|
||||||
return stretch_x / math.min(stretch_x, stretch_y),
|
local stretch_koef = math.min(stretch_x, stretch_y)
|
||||||
stretch_y / math.min(stretch_x, stretch_y)
|
|
||||||
|
local koef_x = window_x / (stretch_koef * sys.get_config_int("display.width"))
|
||||||
|
local koef_y = window_y / (stretch_koef * sys.get_config_int("display.height"))
|
||||||
|
|
||||||
|
return koef_x, koef_y
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -534,7 +538,7 @@ end
|
|||||||
|
|
||||||
---Show message to require component
|
---Show message to require component
|
||||||
---@param component_name string
|
---@param component_name string
|
||||||
---@param component_type string
|
---@param component_type string|nil
|
||||||
function M.require_component_message(component_name, component_type)
|
function M.require_component_message(component_name, component_type)
|
||||||
component_type = component_type or "extended"
|
component_type = component_type or "extended"
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
--
|
--
|
||||||
-- Helper - A useful set of functions for working with GUI nodes, such as centering nodes, get GUI scale ratio, etc
|
-- Helper - A useful set of functions for working with GUI nodes, such as centering nodes, get GUI scale ratio, etc
|
||||||
--
|
--
|
||||||
-- DruidEvent - The core event system in Druid. Learn how to subscribe to any event in every Druid component.
|
-- druid.event - The core event system in Druid. Learn how to subscribe to any event in every Druid component.
|
||||||
--
|
--
|
||||||
-- BaseComponent - The parent class of all Druid components. You can find all default component methods there.
|
-- BaseComponent - The parent class of all Druid components. You can find all default component methods there.
|
||||||
--
|
--
|
||||||
@ -49,7 +49,7 @@ local back_handler = require("druid.base.back_handler")
|
|||||||
---@field private _late_remove druid.base_component[]
|
---@field private _late_remove druid.base_component[]
|
||||||
---@field private _input_blacklist druid.base_component[]|nil
|
---@field private _input_blacklist druid.base_component[]|nil
|
||||||
---@field private _input_whitelist druid.base_component[]|nil
|
---@field private _input_whitelist druid.base_component[]|nil
|
||||||
---@field private _input_inited boolean
|
---@field private input_inited boolean
|
||||||
---@field private _late_init_timer_id number
|
---@field private _late_init_timer_id number
|
||||||
---@field private _input_components druid.base_component[]
|
---@field private _input_components druid.base_component[]
|
||||||
local M = {}
|
local M = {}
|
||||||
@ -69,7 +69,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
-- The a and b - two Druid components
|
-- The a and b - two Druid components
|
||||||
-- @local
|
---@private
|
||||||
local function sort_input_comparator(a, b)
|
local function sort_input_comparator(a, b)
|
||||||
local a_priority = a:get_input_priority()
|
local a_priority = a:get_input_priority()
|
||||||
local b_priority = b:get_input_priority()
|
local b_priority = b:get_input_priority()
|
||||||
@ -231,9 +231,9 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Druid class constructor
|
--- Druid class constructor
|
||||||
---@param table context Druid context. Usually it is self of gui script
|
---@param context table Druid context. Usually it is self of gui script
|
||||||
---@param table style Druid style table
|
---@param style table Druid style table
|
||||||
-- @local
|
---@private
|
||||||
function M:initialize(context, style)
|
function M:initialize(context, style)
|
||||||
self._context = context
|
self._context = context
|
||||||
self._style = style or settings.default_style
|
self._style = style or settings.default_style
|
||||||
@ -291,7 +291,8 @@ end
|
|||||||
--- Remove created component from Druid instance.
|
--- Remove created component from Druid instance.
|
||||||
--
|
--
|
||||||
-- Component `on_remove` function will be invoked, if exist.
|
-- Component `on_remove` function will be invoked, if exist.
|
||||||
---@param BaseComponent component Component instance
|
---@generic T: druid.base_component
|
||||||
|
---@param component T Component instance
|
||||||
---@return boolean True if component was removed
|
---@return boolean True if component was removed
|
||||||
function M:remove(component)
|
function M:remove(component)
|
||||||
if self._is_late_remove_enabled then
|
if self._is_late_remove_enabled then
|
||||||
@ -342,7 +343,7 @@ end
|
|||||||
--- Druid late update function called after initialization and before the regular update step
|
--- Druid late update function called after initialization and before the regular update step
|
||||||
-- This function is used to check the GUI state and perform actions after all components and nodes have been created.
|
-- This function is used to check the GUI state and perform actions after all components and nodes have been created.
|
||||||
-- An example use case is performing an auto stencil check in the GUI hierarchy for input components.
|
-- An example use case is performing an auto stencil check in the GUI hierarchy for input components.
|
||||||
-- @local
|
---@private
|
||||||
function M:late_init()
|
function M:late_init()
|
||||||
local late_init_components = self.components_interest[base_component.ON_LATE_INIT]
|
local late_init_components = self.components_interest[base_component.ON_LATE_INIT]
|
||||||
while late_init_components[1] do
|
while late_init_components[1] do
|
||||||
@ -435,7 +436,7 @@ end
|
|||||||
|
|
||||||
--- Calls the on_focus_lost function in all related components
|
--- Calls the on_focus_lost function in all related components
|
||||||
-- This one called by on_window_callback by global window listener
|
-- This one called by on_window_callback by global window listener
|
||||||
-- @local
|
---@private
|
||||||
function M:on_focus_lost()
|
function M:on_focus_lost()
|
||||||
local components = self.components_interest[base_component.ON_FOCUS_LOST]
|
local components = self.components_interest[base_component.ON_FOCUS_LOST]
|
||||||
for i = 1, #components do
|
for i = 1, #components do
|
||||||
@ -446,7 +447,7 @@ end
|
|||||||
|
|
||||||
--- Calls the on_focus_gained function in all related components
|
--- Calls the on_focus_gained function in all related components
|
||||||
-- This one called by on_window_callback by global window listener
|
-- This one called by on_window_callback by global window listener
|
||||||
-- @local
|
---@private
|
||||||
function M:on_focus_gained()
|
function M:on_focus_gained()
|
||||||
local components = self.components_interest[base_component.ON_FOCUS_GAINED]
|
local components = self.components_interest[base_component.ON_FOCUS_GAINED]
|
||||||
for i = 1, #components do
|
for i = 1, #components do
|
||||||
@ -458,7 +459,7 @@ end
|
|||||||
--- Calls the on_language_change function in all related components
|
--- Calls the on_language_change function in all related components
|
||||||
-- This one called by global druid.on_language_change, but can be
|
-- This one called by global druid.on_language_change, but can be
|
||||||
-- call manualy to update all translations
|
-- call manualy to update all translations
|
||||||
-- @local
|
---@private
|
||||||
function M:on_language_change()
|
function M:on_language_change()
|
||||||
local components = self.components_interest[base_component.ON_LANGUAGE_CHANGE]
|
local components = self.components_interest[base_component.ON_LANGUAGE_CHANGE]
|
||||||
for i = 1, #components do
|
for i = 1, #components do
|
||||||
@ -508,7 +509,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Remove all components on late remove step DruidInstance
|
--- Remove all components on late remove step DruidInstance
|
||||||
-- @local
|
---@private
|
||||||
function M:_clear_late_remove()
|
function M:_clear_late_remove()
|
||||||
if #self._late_remove == 0 then
|
if #self._late_remove == 0 then
|
||||||
return
|
return
|
||||||
@ -647,6 +648,7 @@ function M:new_lang_text(node, locale_id, adjust_type)
|
|||||||
return helper.require_component_message("lang_text") --[[@as druid.lang_text]]
|
return helper.require_component_message("lang_text") --[[@as druid.lang_text]]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
---Create Slider component
|
---Create Slider component
|
||||||
---@param pin_node string|node The_node id or gui.get_node(node_id).
|
---@param pin_node string|node The_node id or gui.get_node(node_id).
|
||||||
---@param end_pos vector3 The end position of slider
|
---@param end_pos vector3 The end position of slider
|
||||||
@ -665,6 +667,7 @@ function M:new_input(click_node, text_node, keyboard_type)
|
|||||||
return helper.require_component_message("input") --[[@as druid.input]]
|
return helper.require_component_message("input") --[[@as druid.input]]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
---Create DataList component
|
---Create DataList component
|
||||||
---@param druid_scroll druid.scroll The Scroll instance for Data List component
|
---@param druid_scroll druid.scroll The Scroll instance for Data List component
|
||||||
---@param druid_grid druid.grid The StaticGrid} or @{DynamicGrid instance for Data List component
|
---@param druid_grid druid.grid The StaticGrid} or @{DynamicGrid instance for Data List component
|
||||||
@ -674,6 +677,7 @@ function M:new_data_list(druid_scroll, druid_grid, create_function)
|
|||||||
return helper.require_component_message("data_list") --[[@as druid.data_list]]
|
return helper.require_component_message("data_list") --[[@as druid.data_list]]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
---Create Timer component
|
---Create Timer component
|
||||||
---@param node string|node Gui text node
|
---@param node string|node Gui text node
|
||||||
---@param seconds_from number Start timer value in seconds
|
---@param seconds_from number Start timer value in seconds
|
||||||
@ -684,6 +688,8 @@ function M:new_timer(node, seconds_from, seconds_to, callback)
|
|||||||
return helper.require_component_message("timer") --[[@as druid.timer]]
|
return helper.require_component_message("timer") --[[@as druid.timer]]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
---Create Progress component
|
---Create Progress component
|
||||||
---@param node string|node Progress bar fill node or node name
|
---@param node string|node Progress bar fill node or node name
|
||||||
---@param key string Progress bar direction: const.SIDE.X or const.SIDE.Y
|
---@param key string Progress bar direction: const.SIDE.X or const.SIDE.Y
|
||||||
@ -693,6 +699,7 @@ function M:new_progress(node, key, init_value)
|
|||||||
return helper.require_component_message("progress") --[[@as druid.progress]]
|
return helper.require_component_message("progress") --[[@as druid.progress]]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
---Create Layout component
|
---Create Layout component
|
||||||
---@param node string|node The_node id or gui.get_node(node_id).
|
---@param node string|node The_node id or gui.get_node(node_id).
|
||||||
---@param mode string The layout mode
|
---@param mode string The layout mode
|
||||||
@ -701,6 +708,7 @@ function M:new_layout(node, mode)
|
|||||||
return helper.require_component_message("layout") --[[@as druid.layout]]
|
return helper.require_component_message("layout") --[[@as druid.layout]]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
---Create Hotkey component
|
---Create Hotkey component
|
||||||
---@param keys_array string|string[] Keys for trigger action. Should contains one action key and any amount of modificator keys
|
---@param keys_array string|string[] Keys for trigger action. Should contains one action key and any amount of modificator keys
|
||||||
---@param callback function The callback function
|
---@param callback function The callback function
|
||||||
@ -710,6 +718,7 @@ function M:new_hotkey(keys_array, callback, callback_argument)
|
|||||||
return helper.require_component_message("hotkey") --[[@as druid.hotkey]]
|
return helper.require_component_message("hotkey") --[[@as druid.hotkey]]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
---Create RichText component.
|
---Create RichText component.
|
||||||
---@param text_node string|node The text node to make Rich Text
|
---@param text_node string|node The text node to make Rich Text
|
||||||
---@param value string|nil 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)
|
||||||
@ -718,6 +727,7 @@ function M:new_rich_text(text_node, value)
|
|||||||
return helper.require_component_message("rich_text", "custom") --[[@as druid.rich_text]]
|
return helper.require_component_message("rich_text", "custom") --[[@as druid.rich_text]]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
---Create RichInput component.
|
---Create RichInput component.
|
||||||
-- As a template please check rich_input.gui layout.
|
-- As a template please check rich_input.gui layout.
|
||||||
---@param template string The template string name
|
---@param template string The template string name
|
||||||
@ -727,4 +737,5 @@ function M:new_rich_input(template, nodes)
|
|||||||
return helper.require_component_message("rich_input", "custom") --[[@as druid.rich_input]]
|
return helper.require_component_message("rich_input", "custom") --[[@as druid.rich_input]]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
@ -15,7 +15,7 @@ function M:init(template, nodes)
|
|||||||
gui.set_text(self.text_counter, self.counter)
|
gui.set_text(self.text_counter, self.counter)
|
||||||
|
|
||||||
-- Init drag and move the drag node on drag callback
|
-- Init drag and move the drag node on drag callback
|
||||||
self.drag = self.druid:new_drag("drag/root", self.on_drag_start)
|
self.drag = self.druid:new_drag("drag/root", self.on_drag)
|
||||||
self.drag.on_drag_end:subscribe(self.on_drag_end)
|
self.drag.on_drag_end:subscribe(self.on_drag_end)
|
||||||
|
|
||||||
-- Save start position for animation
|
-- Save start position for animation
|
||||||
@ -23,7 +23,7 @@ function M:init(template, nodes)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function M:on_drag_start(dx, dy, x, y, touch)
|
function M:on_drag(dx, dy, x, y, touch)
|
||||||
local position_x = gui.get(self.drag.node, "position.x")
|
local position_x = gui.get(self.drag.node, "position.x")
|
||||||
local position_y = gui.get(self.drag.node, "position.y")
|
local position_y = gui.get(self.drag.node, "position.y")
|
||||||
gui.set(self.drag.node, "position.x", position_x + dx)
|
gui.set(self.drag.node, "position.x", position_x + dx)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user