From 54e468588c7a02f3834993bb1f8565899f13aa7f Mon Sep 17 00:00:00 2001 From: Michael Freno Date: Mon, 15 Sep 2025 00:22:15 -0400 Subject: [PATCH] fixed autosizing --- FlexLove.lua | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/FlexLove.lua b/FlexLove.lua index 0da49e9..1a43e17 100644 --- a/FlexLove.lua +++ b/FlexLove.lua @@ -228,6 +228,7 @@ end -- Window Object -- ==================== ---@class Window +---@field autosizing boolean ---@field x number ---@field y number ---@field z number -- default: 0 @@ -285,6 +286,11 @@ function Window.new(props) local self = setmetatable({}, Window) self.x = props.x or 0 self.y = props.y or 0 + if props.w == nil and props.h == nil then + self.autosizing = true + else + self.autosizing = false + end self.width = props.w or 0 self.height = props.h or 0 self.parent = props.parent @@ -378,6 +384,7 @@ function Window:layoutChildren() return end self:calculateAutoWidth() + self:calculateAutoHeight() local totalSize = 0 local childCount = #self.children @@ -602,8 +609,11 @@ end --- Calculate auto width based on children function Window:calculateAutoWidth() + if self.autosizing == false then + return + end if not self.children or #self.children == 0 then - return 0 + self.width = 0 end Logger:debug("children count: " .. #self.children) @@ -624,8 +634,11 @@ end --- Calculate auto height based on children function Window:calculateAutoHeight() + if self.autosizing == false then + return + end if not self.children or #self.children == 0 then - return 0 + self.height = 0 end local maxHeight = 0