From 350770ba9ec313fb797cfe6d08afde320359447f Mon Sep 17 00:00:00 2001 From: Insality Date: Wed, 28 May 2025 23:20:48 +0300 Subject: [PATCH] Fix for Druid containers mode --- druid/const.lua | 6 ++---- druid/custom/rich_text/module/rt_tags.lua | 3 --- druid/extended/container.lua | 8 +++++--- druid/system/druid_instance.lua | 2 +- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/druid/const.lua b/druid/const.lua index 0363871..8af8faa 100755 --- a/druid/const.lua +++ b/druid/const.lua @@ -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 diff --git a/druid/custom/rich_text/module/rt_tags.lua b/druid/custom/rich_text/module/rt_tags.lua index 595b171..21c486a 100644 --- a/druid/custom/rich_text/module/rt_tags.lua +++ b/druid/custom/rich_text/module/rt_tags.lua @@ -44,19 +44,16 @@ end -- Format: {Text} -- Example: Rich Text 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) diff --git a/druid/extended/container.lua b/druid/extended/container.lua index 6769990..e79dbb0 100755 --- a/druid/extended/container.lua +++ b/druid/extended/container.lua @@ -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 diff --git a/druid/system/druid_instance.lua b/druid/system/druid_instance.lua index 08c8f33..20174a2 100755 --- a/druid/system/druid_instance.lua +++ b/druid/system/druid_instance.lua @@ -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)