mirror of
https://github.com/Insality/druid
synced 2025-06-27 02:17:52 +02:00
Update
This commit is contained in:
parent
96ce3eee95
commit
7a6f529c82
@ -528,11 +528,12 @@ function M:bind_grid(grid)
|
||||
end
|
||||
|
||||
self._grid_on_change = grid.on_change_items
|
||||
self._grid_on_change_callback = self._grid_on_change:subscribe(function()
|
||||
self._grid_on_change_callback = function()
|
||||
local size = grid:get_size()
|
||||
local offset = grid:get_offset()
|
||||
self:set_size(size, offset)
|
||||
end)
|
||||
end
|
||||
self._grid_on_change:subscribe(self._grid_on_change_callback)
|
||||
self:set_size(grid:get_size(), grid:get_offset())
|
||||
|
||||
return self
|
||||
|
@ -201,7 +201,7 @@ end
|
||||
|
||||
--- Return grid index by node
|
||||
---@param node node The gui node in the grid
|
||||
---@return number The node index
|
||||
---@return number|nil index The node index
|
||||
function M:get_index_by_node(node)
|
||||
for index, grid_node in pairs(self.nodes) do
|
||||
if node == grid_node then
|
||||
@ -356,7 +356,7 @@ end
|
||||
|
||||
|
||||
--- Return grid content borders
|
||||
---@return vector3 The grid content borders
|
||||
---@return vector4 The grid content borders
|
||||
function M:get_borders()
|
||||
return self.border
|
||||
end
|
||||
@ -463,10 +463,12 @@ end
|
||||
|
||||
--- Sort grid nodes by custom comparator function
|
||||
---@param comparator function The comparator function. (a, b) -> boolean
|
||||
---@return druid.grid Current grid instance
|
||||
---@return druid.grid self Current grid instance
|
||||
function M:sort_nodes(comparator)
|
||||
table.sort(self.nodes, comparator)
|
||||
self:_update(true)
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
|
@ -25,7 +25,7 @@ local helper = require("druid.helper")
|
||||
---@field update fun(self:druid.base_component, dt:number)|nil
|
||||
---@field on_remove fun(self:druid.base_component)|nil
|
||||
---@field on_input fun(self:druid.base_component, action_id:number, action:table)|nil
|
||||
---@field on_message fun(self:druid.base_component, message_id:hash, message:table, sender:userdata)|nil
|
||||
---@field on_message fun(self:druid.base_component, message_id:hash, message:table, sender:url)|nil
|
||||
---@field on_late_init fun(self:druid.base_component)|nil
|
||||
---@field on_focus_lost fun(self:druid.base_component)|nil
|
||||
---@field on_focus_gained fun(self:druid.base_component)|nil
|
||||
|
@ -121,6 +121,13 @@ local rich_text = require("druid.custom.rich_text.module.rt")
|
||||
---@field width number
|
||||
---@field height number
|
||||
|
||||
---@class druid.rich_text.style
|
||||
---@field COLORS table<string, vector4>
|
||||
---@field ADJUST_STEPS number
|
||||
---@field ADJUST_SCALE_DELTA number
|
||||
---@field ADJUST_TYPE string
|
||||
---@field ADJUST_SCALE number
|
||||
|
||||
---@class druid.rich_text.lines_metrics
|
||||
---@field text_width number
|
||||
---@field text_height number
|
||||
|
@ -71,7 +71,7 @@ end
|
||||
---@param text string Text for text node
|
||||
---@return druid.lang_text Current instance
|
||||
function M:set_to(text)
|
||||
self.last_locale = false
|
||||
self.last_locale = nil
|
||||
self.text:set_text(text)
|
||||
self.on_change:trigger()
|
||||
|
||||
|
@ -474,14 +474,14 @@ end
|
||||
---@generic T: druid.base_component
|
||||
---@param widget T
|
||||
---@param template string|nil The template name used by widget
|
||||
---@param nodes table<string|hash, node>|node|nil The nodes table from gui.clone_tree or prefab node to use for clone
|
||||
---@param nodes table<hash, node>|node|nil The nodes table from gui.clone_tree or prefab node to use for clone
|
||||
---@vararg any
|
||||
---@return T
|
||||
function M:new_widget(widget, template, nodes, ...)
|
||||
local instance = create_widget(self, widget)
|
||||
|
||||
if type(nodes) == "userdata" then
|
||||
nodes = gui.clone_tree(nodes)
|
||||
nodes = gui.clone_tree(nodes) --[[@as table<hash, node>]]
|
||||
end
|
||||
|
||||
instance.druid = instance:get_druid(template, nodes)
|
||||
@ -543,10 +543,10 @@ local text = require("druid.base.text")
|
||||
---Create Text component
|
||||
---@param node string|node The node_id or gui.get_node(node_id)
|
||||
---@param value string|nil Initial text. Default value is node text from GUI scene.
|
||||
---@param no_adjust boolean|nil If true, text will be not auto-adjust size
|
||||
---@param adjust_type string|nil Adjust type for text. By default is DOWNSCALE. Look const.TEXT_ADJUST for reference
|
||||
---@return druid.text Text component
|
||||
function M:new_text(node, value, no_adjust)
|
||||
return self:new(text, node, value, no_adjust)
|
||||
function M:new_text(node, value, adjust_type)
|
||||
return self:new(text, node, value, adjust_type)
|
||||
end
|
||||
|
||||
|
||||
|
@ -136,7 +136,10 @@ function M:on_size_changed(new_size)
|
||||
|
||||
local width = self.layout:get_size().x - self.layout.padding.x - self.layout.padding.z
|
||||
for index = 1, #self.properties do
|
||||
self.properties[index].container:set_size(width)
|
||||
local property = self.properties[index]
|
||||
if property.container then
|
||||
property.container:set_size(width)
|
||||
end
|
||||
end
|
||||
self.paginator.container:set_size(width)
|
||||
end
|
||||
@ -216,7 +219,7 @@ end
|
||||
---@generic T: druid.widget
|
||||
---@param widget_class T
|
||||
---@param template string|nil
|
||||
---@param nodes table<string, node>|node|nil
|
||||
---@param nodes table<hash, node>|node|nil
|
||||
---@param on_create fun(widget: T)|nil
|
||||
---@return widget.properties_panel
|
||||
function M:add_inner_widget(widget_class, template, nodes, on_create)
|
||||
|
Loading…
x
Reference in New Issue
Block a user