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