fixed autosizing
This commit is contained in:
17
FlexLove.lua
17
FlexLove.lua
@@ -228,6 +228,7 @@ end
|
|||||||
-- Window Object
|
-- Window Object
|
||||||
-- ====================
|
-- ====================
|
||||||
---@class Window
|
---@class Window
|
||||||
|
---@field autosizing boolean
|
||||||
---@field x number
|
---@field x number
|
||||||
---@field y number
|
---@field y number
|
||||||
---@field z number -- default: 0
|
---@field z number -- default: 0
|
||||||
@@ -285,6 +286,11 @@ function Window.new(props)
|
|||||||
local self = setmetatable({}, Window)
|
local self = setmetatable({}, Window)
|
||||||
self.x = props.x or 0
|
self.x = props.x or 0
|
||||||
self.y = props.y 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.width = props.w or 0
|
||||||
self.height = props.h or 0
|
self.height = props.h or 0
|
||||||
self.parent = props.parent
|
self.parent = props.parent
|
||||||
@@ -378,6 +384,7 @@ function Window:layoutChildren()
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
self:calculateAutoWidth()
|
self:calculateAutoWidth()
|
||||||
|
self:calculateAutoHeight()
|
||||||
|
|
||||||
local totalSize = 0
|
local totalSize = 0
|
||||||
local childCount = #self.children
|
local childCount = #self.children
|
||||||
@@ -602,8 +609,11 @@ end
|
|||||||
|
|
||||||
--- Calculate auto width based on children
|
--- Calculate auto width based on children
|
||||||
function Window:calculateAutoWidth()
|
function Window:calculateAutoWidth()
|
||||||
|
if self.autosizing == false then
|
||||||
|
return
|
||||||
|
end
|
||||||
if not self.children or #self.children == 0 then
|
if not self.children or #self.children == 0 then
|
||||||
return 0
|
self.width = 0
|
||||||
end
|
end
|
||||||
Logger:debug("children count: " .. #self.children)
|
Logger:debug("children count: " .. #self.children)
|
||||||
|
|
||||||
@@ -624,8 +634,11 @@ end
|
|||||||
|
|
||||||
--- Calculate auto height based on children
|
--- Calculate auto height based on children
|
||||||
function Window:calculateAutoHeight()
|
function Window:calculateAutoHeight()
|
||||||
|
if self.autosizing == false then
|
||||||
|
return
|
||||||
|
end
|
||||||
if not self.children or #self.children == 0 then
|
if not self.children or #self.children == 0 then
|
||||||
return 0
|
self.height = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
local maxHeight = 0
|
local maxHeight = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user