mirror of
https://github.com/Insality/druid.git
synced 2025-06-27 02:17:52 +02:00
Fix for Druid containers mode
This commit is contained in:
parent
97942965cd
commit
350770ba9e
@ -73,10 +73,8 @@ M.REVERSE_PIVOTS = {
|
||||
M.LAYOUT_MODE = {
|
||||
STRETCH_X = "stretch_x",
|
||||
STRETCH_Y = "stretch_y",
|
||||
ZOOM_MIN = "zoom_min",
|
||||
ZOOM_MAX = "zoom_max",
|
||||
FIT = gui.ADJUST_FIT,
|
||||
STRETCH = gui.ADJUST_STRETCH,
|
||||
FIT = "fit",
|
||||
STRETCH = "stretch",
|
||||
}
|
||||
|
||||
M.CURRENT_SYSTEM_NAME = sys.get_sys_info().system_name
|
||||
|
@ -44,19 +44,16 @@ end
|
||||
-- Format: <color={COLOR_NAME}>{Text}</color>
|
||||
-- Example: <color=FF0000>Rich Text</color>
|
||||
M.register("color", function(params, settings, style)
|
||||
params = style.COLORS[params] or params
|
||||
settings.color = color.get_color(params)
|
||||
end)
|
||||
|
||||
|
||||
M.register("shadow", function(params, settings, style)
|
||||
params = style.COLORS[params] or params
|
||||
settings.shadow = color.get_color(params)
|
||||
end)
|
||||
|
||||
|
||||
M.register("outline", function(params, settings, style)
|
||||
params = style.COLORS[params] or params
|
||||
settings.outline = color.get_color(params)
|
||||
end)
|
||||
|
||||
|
@ -31,6 +31,8 @@ local CORNER_PIVOTS = {
|
||||
---@field DRAGGABLE_CORNER_SIZE vector3 Size of box node for debug draggable corners
|
||||
---@field DRAGGABLE_CORNER_COLOR vector4 Color of debug draggable corners
|
||||
|
||||
---@alias druid.container.mode "stretch" | "fit" | "stretch_x" | "stretch_y"
|
||||
|
||||
---Druid component to manage the size and positions with other containers relations to create a adaptable layouts.
|
||||
---
|
||||
---### Setup
|
||||
@ -54,7 +56,7 @@ local CORNER_PIVOTS = {
|
||||
---@field position vector3 The current position
|
||||
---@field pivot_offset vector3 The pivot offset
|
||||
---@field center_offset vector3 The center offset
|
||||
---@field mode string The layout mode
|
||||
---@field mode druid.container.mode The layout mode
|
||||
---@field fit_size vector3 The fit size
|
||||
---@field min_size_x number|nil The minimum size x
|
||||
---@field min_size_y number|nil The minimum size y
|
||||
@ -176,7 +178,7 @@ function M:set_size(width, height, anchor_pivot)
|
||||
if self.max_size_y then
|
||||
height = min(height, self.max_size_y)
|
||||
end
|
||||
|
||||
|
||||
if (width and width ~= self.size.x) or (height and height ~= self.size.y) then
|
||||
self.center_offset.x = -width * self.pivot_offset.x
|
||||
self.center_offset.y = -height * self.pivot_offset.y
|
||||
@ -537,7 +539,7 @@ function M:_on_corner_drag(x, y, corner_offset)
|
||||
end
|
||||
if self.max_size_y and size.y + y > self.max_size_y then
|
||||
y = self.max_size_y - size.y
|
||||
end
|
||||
end
|
||||
|
||||
if corner_offset.x < 0 then
|
||||
self.node_offset.x = self.node_offset.x - x
|
||||
|
@ -681,7 +681,7 @@ end
|
||||
local container = require("druid.extended.container")
|
||||
---Create Container component
|
||||
---@param node string|node The node_id or gui.get_node(node_id).
|
||||
---@param mode string|nil Layout mode
|
||||
---@param mode druid.container.mode|nil Layout mode. Default Fit or Stretch depends from node adjust mode from GUI scene
|
||||
---@param callback fun(self: druid.container, size: vector3)|nil Callback on size changed
|
||||
---@return druid.container container The new container component
|
||||
function M:new_container(node, mode, callback)
|
||||
|
Loading…
x
Reference in New Issue
Block a user