mirror of
https://github.com/Insality/druid.git
synced 2025-09-27 18:12:19 +02:00
Update
This commit is contained in:
@@ -373,7 +373,7 @@ function M:set_text(input_text)
|
||||
self.is_empty = #value == 0 and #marked_value == 0
|
||||
|
||||
local final_text = value .. marked_value
|
||||
self.text:set_to(final_text)
|
||||
self.text:set_text(final_text)
|
||||
|
||||
-- measure it
|
||||
self.text_width = self.text:get_text_size(value)
|
||||
|
@@ -72,13 +72,21 @@ end
|
||||
---@return druid.lang_text Current instance
|
||||
function M:set_to(text)
|
||||
self.last_locale = false
|
||||
self.text:set_to(text)
|
||||
self.text:set_text(text)
|
||||
self.on_change:trigger()
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- Setup raw text to lang_text component
|
||||
---@param text string Text for text node
|
||||
---@return druid.lang_text Current instance
|
||||
function M:set_text(text)
|
||||
return self:set_to(text)
|
||||
end
|
||||
|
||||
|
||||
--- Translate the text by locale_id
|
||||
---@param locale_id string Locale id
|
||||
---@param a string|nil Optional param to string.format
|
||||
@@ -92,7 +100,7 @@ end
|
||||
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
|
||||
self.text:set_to(settings.get_text(self.last_locale, a, b, c, d, e, f, g) or "")
|
||||
self.text:set_text(settings.get_text(self.last_locale, a, b, c, d, e, f, g) or "")
|
||||
|
||||
return self
|
||||
end
|
||||
@@ -109,7 +117,7 @@ end
|
||||
---@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 "")
|
||||
self.text:set_text(settings.get_text(self.last_locale, a, b, c, d, e, f, g) or "")
|
||||
|
||||
return self
|
||||
end
|
||||
|
@@ -45,7 +45,9 @@ function M:init(node_or_node_id, layout_type)
|
||||
self.size = gui.get_size(self.node)
|
||||
|
||||
self.padding = gui.get_slice9(self.node)
|
||||
-- Grab default margins from slice9 z/w values
|
||||
self.margin = { x = self.padding.z, y = self.padding.w }
|
||||
-- Use symmetrical padding from x/z
|
||||
self.padding.z = self.padding.x
|
||||
self.padding.w = self.padding.y
|
||||
|
||||
@@ -199,10 +201,11 @@ function M:get_size()
|
||||
end
|
||||
|
||||
|
||||
---@return vector3
|
||||
---@return number, number
|
||||
function M:get_content_size()
|
||||
local rows_data = self:calculate_rows_data()
|
||||
return vmath.vector3(rows_data.total_width, rows_data.total_height, 0)
|
||||
local width = self.size.x - self.padding.x - self.padding.z
|
||||
local height = self.size.y - self.padding.y - self.padding.w
|
||||
return width, height
|
||||
end
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user