Update annotations, add set_repeat to hotkey component

This commit is contained in:
Insality
2023-12-05 14:49:56 +02:00
parent 97ff6154eb
commit 01d1445511
11 changed files with 88 additions and 55 deletions

View File

@@ -32,7 +32,7 @@
-- @usage
-- -- Replace params on runtime:
-- back_handler.params = { ... }
-- @tfield[opt] any params
-- @tfield any|nil params
---

View File

@@ -27,7 +27,7 @@
-- print("Also the button component is passed in callback params")
-- end
--
-- local custom_args = "any variable to pass inside callback"
-- local custom_args = "Any variable to pass inside callback"
-- local button = self.druid:new_button("button_name", on_button_click, custom_args)
--
-- @module Button
@@ -131,8 +131,8 @@
--- The @{Hover}: Button Hover component
-- @tfield Hover hover @{Hover}
--- Additional button click area, defined by another GUI Node
-- @tfield[opt] node click_zone
--- Additional button click area, defined by another GUI node
-- @tfield node|nil click_zone
---
@@ -257,6 +257,7 @@ end
--- Component style params.
-- You can override this component styles params in Druid styles table
-- or create your own style
-- @table style
-- @tfield[opt=0.4] number LONGTAP_TIME Minimum time to trigger on_hold_callback
-- @tfield[opt=0.8] number AUTOHOLD_TRIGGER Maximum hold time to trigger button release while holding
-- @tfield[opt=0.4] number DOUBLETAP_TIME Time between double taps
@@ -265,7 +266,6 @@ end
-- @tfield function on_hover function(self, node, hover_state)
-- @tfield function on_mouse_hover function(self, node, hover_state)
-- @tfield function on_set_enabled function(self, node, enabled_state)
-- @table style
function Button.on_style_change(self, style)
self.style = {}
self.style.LONGTAP_TIME = style.LONGTAP_TIME or 0.4
@@ -492,7 +492,7 @@ end
--- Set key name to trigger this button by keyboard.
-- @tparam Button self @{Button}
-- @tparam hash key The action_id of the input key
-- @tparam hash|string key The action_id of the input key
-- @treturn Button Current button instance
-- @usage
-- button:set_key_trigger("key_space")

View File

@@ -10,13 +10,16 @@
-- @within BaseComponent
-- @alias druid.drag
--- Drag node
-- @tfield node node
--- Event on touch start callback(self)
-- @tfield DruidEvent on_touch_start @{DruidEvent}
--- Event on touch end callback(self)
-- @tfield DruidEvent on_touch_end @{DruidEvent}
--- Event on drag start callback(self)
--- Event on drag start callback(self, touch)
-- @tfield DruidEvent on_drag_start @{DruidEvent}
--- on drag progress callback(self, dx, dy, total_x, total_y)
@@ -67,23 +70,24 @@ local function start_touch(self, touch)
self.y = touch.y
self._scene_scale = helper.get_scene_scale(self.node)
self.on_touch_start:trigger(self:get_context())
self.on_touch_start:trigger(self:get_context(), touch)
end
local function end_touch(self)
local function end_touch(self, touch)
if self.is_drag then
self.on_drag_end:trigger(
self:get_context(),
self.x - self.touch_start_pos.x,
self.y - self.touch_start_pos.y
self.y - self.touch_start_pos.y,
touch
)
end
self.is_drag = false
if self.is_touch then
self.is_touch = false
self.on_touch_end:trigger(self:get_context())
self.on_touch_end:trigger(self:get_context(), touch)
end
self:reset_input_priority()
self.touch_id = 0
@@ -102,7 +106,7 @@ local function process_touch(self, touch)
local distance = helper.distance(touch.x, touch.y, self.touch_start_pos.x, self.touch_start_pos.y)
if not self.is_drag and distance >= self.style.DRAG_DEADZONE then
self.is_drag = true
self.on_drag_start:trigger(self:get_context())
self.on_drag_start:trigger(self:get_context(), touch)
self:set_input_priority(const.PRIORITY_INPUT_MAX, true)
end
end
@@ -266,7 +270,7 @@ function Drag.on_input(self, action_id, action)
on_touch_release(self, action_id, action)
else
-- PC
end_touch(self)
end_touch(self, touch)
end
end
@@ -285,7 +289,7 @@ function Drag.on_input(self, action_id, action)
self.y = touch_modified.y
end
if self.is_drag then
if self.is_drag and (self.dx ~= 0 or self.dy ~= 0) then
local x_koef, y_koef = self._x_koef, self._y_koef
if self.style.NO_USE_SCREEN_KOEF then
x_koef, y_koef = 1, 1
@@ -295,7 +299,7 @@ function Drag.on_input(self, action_id, action)
self.dx * x_koef / self._scene_scale.x,
self.dy * y_koef / self._scene_scale.y,
(self.x - self.touch_start_pos.x) * x_koef / self._scene_scale.x,
(self.y - self.touch_start_pos.y) * y_koef / self._scene_scale.y)
(self.y - self.touch_start_pos.y) * y_koef / self._scene_scale.y, touch_modified)
end
return self.is_drag

View File

@@ -53,6 +53,9 @@
--- Scroll content node
-- @tfield node content_node
--- Flag, if scroll now moving by inertion
-- @tfield bool _is_inert
--- Current inert speed
-- @tfield vector3 inertion
@@ -72,7 +75,7 @@
-- @tfield Drag drag @{Drag}
--- Current index of points of interests
-- @tfield[opt] number selected
-- @tfield number|nil selected
--- Flag, if scroll now animating by gui.animate
-- @tfield boolean is_animate

View File

@@ -408,7 +408,7 @@ end
--- Set text adjust, refresh the current text visuals, if needed
-- @tparam Text self @{Text}
-- @tparam number|nil adjust_type See const.TEXT_ADJUST. If pass nil - use current adjust type
-- @tparam string|nil adjust_type See const.TEXT_ADJUST. If pass nil - use current adjust type
-- @tparam number|nil minimal_scale If pass nil - not use minimal scale
-- @treturn Text Current text instance
function Text.set_text_adjust(self, adjust_type, minimal_scale)