This commit is contained in:
Insality
2024-11-21 22:00:05 +02:00
parent 69ebb252e1
commit 5a1668a8af
22 changed files with 174 additions and 205 deletions

View File

@@ -69,7 +69,7 @@ end
--- Setup raw text to lang_text component
---@param text string Text for text node
---@return LangText Current instance
---@return druid.lang_text Current instance
function M:set_to(text)
self.last_locale = false
self.text:set_to(text)
@@ -88,7 +88,7 @@ end
---@param e string|nil Optional param to string.format
---@param f string|nil Optional param to string.format
---@param g string|nil Optional param to string.format
---@return LangText Current instance
---@return druid.lang_text Current instance
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 = locale_id or self.last_locale
@@ -106,7 +106,7 @@ end
---@param e string|nil Optional param to string.format
---@param f string|nil Optional param to string.format
---@param g string|nil Optional param to string.format
---@return LangText Current instance
---@return druid.lang_text Current instance
function M:format(a, b, c, d, e, f, g)
self.last_locale_args = { a, b, c, d, e, f, g }
self.text:set_to(settings.get_text(self.last_locale, a, b, c, d, e, f, g) or "")

View File

@@ -221,6 +221,7 @@ function M:refresh_layout()
local layout_pivot_offset = helper.get_pivot_offset(gui.get_pivot(layout_node)) -- {x: -0.5, y: -0.5} - is left bot, {x: 0.5, y: 0.5} - is right top
local rows_data = self:calculate_rows_data()
self.rows_data = rows_data
local rows = rows_data.rows
local row_index = 1
local row = rows[row_index]

View File

@@ -247,7 +247,7 @@ end
--- Set progress bar max node size
---@param max_size vector3 The new node maximum (full) size
---@return Progress Progress
---@return druid.progress Progress
function M:set_max_size(max_size)
self.max_size[self.key] = max_size[self.key]
self:set_to(self.last_value)

View File

@@ -212,7 +212,7 @@ end
-- apply closest step position
---@param steps number[] Array of steps
-- @usage slider:set_steps({0, 0.2, 0.6, 1})
---@return Slider Slider
---@return druid.slider Slider
function M:set_steps(steps)
self.steps = steps
return self
@@ -224,8 +224,13 @@ end
-- move at this position and node drag will start.
-- This function require the Defold version 1.3.0+
---@param input_node node|string|nil
---@return Slider Slider
---@return druid.slider Slider
function M:set_input_node(input_node)
if not input_node then
self._input_node = nil
return self
end
self._input_node = self:get_node(input_node)
return self
end

View File

@@ -16,7 +16,7 @@
---@param click_zone node|nil
--- Trigger on swipe event(self, swipe_side, dist, delta_time)
-- @tfield event on_swipe) event
---@param event event on_swipe
---
@@ -27,7 +27,7 @@ local component = require("druid.component")
---@class druid.swipe: druid.base_component
---@field node node
---@field on_swipe event
---@field on_swipe event function(side, dist, dt), side - "left", "right", "up", "down"
---@field style table
---@field click_zone node
---@field private _trigger_on_move boolean
@@ -62,16 +62,16 @@ local function check_swipe(self, action)
local swipe_side = false
if is_x_swipe and dx > 0 then
swipe_side = const.SWIPE.RIGHT
swipe_side = "right"
end
if is_x_swipe and dx < 0 then
swipe_side = const.SWIPE.LEFT
swipe_side = "left"
end
if not is_x_swipe and dy > 0 then
swipe_side = const.SWIPE.UP
swipe_side = "up"
end
if not is_x_swipe and dy < 0 then
swipe_side = const.SWIPE.DOWN
swipe_side = "down"
end
self.on_swipe:trigger(self:get_context(), swipe_side, dist, delta_time)
@@ -83,10 +83,12 @@ end
--- Component style params.
-- You can override this component styles params in druid styles table
-- or create your own style
-- @table style
-- @tfield number|nil SWIPE_TIME Maximum time for swipe trigger. Default: 0.4
-- @tfield number|nil SWIPE_THRESHOLD Minimum distance for swipe trigger. Default: 50
-- @tfield boolean|nil SWIPE_TRIGGER_ON_MOVE If true, trigger on swipe moving, not only release action. Default: false
---@class druid.swipe.style
---@field SWIPE_TIME number|nil Maximum time for swipe trigger. Default: 0.4
---@field SWIPE_THRESHOLD number|nil Minimum distance for swipe trigger. Default: 50
---@field SWIPE_TRIGGER_ON_MOVE boolean|nil If true, trigger on swipe moving, not only release action. Default: false
---@param style druid.swipe.style
function M:on_style_change(style)
self.style = {}
self.style.SWIPE_TIME = style.SWIPE_TIME or 0.4