This commit is contained in:
2025-05-04 21:38:01 +02:00
parent c8f9d81b3e
commit f05156b257
2 changed files with 19 additions and 3 deletions

2
Meta

Submodule Meta updated: ba3bf263d6...e5f4ad0cbc

View File

@@ -141,6 +141,7 @@ GridFrame = {
if bestColumn then if bestColumn then
frame:SetParent(self.frame) frame:SetParent(self.frame)
---@diagnostic disable-next-line: inject-field
frame.gridData = { frame.gridData = {
row = bestRow, row = bestRow,
column = bestColumn, column = bestColumn,
@@ -148,6 +149,7 @@ GridFrame = {
rowspan = rowspan, rowspan = rowspan,
parent = self, parent = self,
} }
---@diagnostic disable-next-line: inject-field, redefined-local
frame.SetPos = function(self) frame.SetPos = function(self)
if not self.gridData then return end if not self.gridData then return end
local parent = self.gridData.parent local parent = self.gridData.parent
@@ -176,24 +178,36 @@ GridFrame = {
end end
end end
end, end,
---@param self GridFrame
---@param width number
SetWidth = function(self, width) SetWidth = function(self, width)
self.frame:SetWidth(width) self.frame:SetWidth(width)
self.cellWidth = width / self.columns self.cellWidth = width / self.columns
self:Recalculate() self:Recalculate()
end, end,
---@param self GridFrame
---@param height number
SetHeight = function(self, height) SetHeight = function(self, height)
self.frame:SetHeight(height) self.frame:SetHeight(height)
local tallestRow = 0 local tallestRow = 0
for _, height in pairs(self.columnHeights) do for _, columnHeight in pairs(self.columnHeights) do
tallestRow = math.max(tallestRow, height) tallestRow = math.max(tallestRow, columnHeight)
end end
if tallestRow > 0 then self.cellHeight = height / tallestRow end if tallestRow > 0 then self.cellHeight = height / tallestRow end
self:Recalculate() self:Recalculate()
end, end,
---@param self GridFrame
---@param point string
---@param relativeTo Frame
---@param relativePoint string
---@param offsetX number
---@param offsetY number
SetPoint = function(self, point, relativeTo, relativePoint, offsetX, offsetY) SetPoint = function(self, point, relativeTo, relativePoint, offsetX, offsetY)
self.frame:SetPoint(point, relativeTo, relativePoint, offsetX, offsetY) self.frame:SetPoint(point, relativeTo, relativePoint, offsetX, offsetY)
self:Recalculate() self:Recalculate()
end, end,
---@param self GridFrame
---@param parent Frame
SetParent = function(self, parent) SetParent = function(self, parent)
self.frame:SetParent(parent) self.frame:SetParent(parent)
self:Recalculate() self:Recalculate()
@@ -274,7 +288,9 @@ StaticGridFrame = {
if canPlace then if canPlace then
local x = (col - 1) * self.cellWidth local x = (col - 1) * self.cellWidth
local y = -(row - 1) * self.cellHeight local y = -(row - 1) * self.cellHeight
---@diagnostic disable-next-line: inject-field
frame.colspan = colspan frame.colspan = colspan
---@diagnostic disable-next-line: inject-field
frame.rowspan = rowspan frame.rowspan = rowspan
frame:SetWidth(self.cellWidth * colspan) frame:SetWidth(self.cellWidth * colspan)
frame:SetHeight(self.cellHeight * rowspan) frame:SetHeight(self.cellHeight * rowspan)