Grid CalculateSize() fix #21

This commit is contained in:
João Lopes 2023-02-03 17:30:39 +00:00
parent bb5a21b39b
commit 09f1b941ca
2 changed files with 13 additions and 4 deletions

View File

@ -412,6 +412,7 @@ function newobject:Center()
local base = loveframes.base
local parent = self.parent
if self.CalculateSize then self:CalculateSize() end
if parent == base then
local width = love.graphics.getWidth()
local height = love.graphics.getHeight()

View File

@ -69,10 +69,9 @@ function newobject:update(dt)
local prevwidth = self.prevwidth
local prevheight = self.prevheight
self.width = (self.columns * self.cellwidth) + (self.columns * (self.cellpadding * 2))
self.height = (self.rows * self.cellheight) + (self.rows * (self.cellpadding * 2))
self:CalculateSize()
if self.width ~= prevwidth or self.height ~= prevheight then
local onsizechanged = self.OnSizeChanged
self.prevwidth = self.width
@ -92,6 +91,15 @@ function newobject:update(dt)
end
--[[---------------------------------------------------------
- func: CalculateSize()
- desc: calculate the object size
--]]---------------------------------------------------------
function newobject:CalculateSize()
self.width = (self.columns * self.cellwidth) + (self.columns * (self.cellpadding * 2))
self.height = (self.rows * self.cellheight) + (self.rows * (self.cellpadding * 2))
end
function newobject:_update_children_position()
for k, v in ipairs(self.children) do
local rs, cs = self:GetCellSpanSize(v.gridrow, v.gridcolumn)