Begin reworking old approach to gridframe

This commit is contained in:
2025-01-06 17:16:48 +01:00
parent 4652c60e64
commit fc3732fd0c

View File

@@ -70,6 +70,8 @@ GridFrame = {
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
print(string.format("frame:SetWidth(%d)", self.cellWidth * colspan))
print(string.format("frame:SetHeight(%d)", self.cellHeight * rowspan))
frame:SetWidth(self.cellWidth * colspan) frame:SetWidth(self.cellWidth * colspan)
frame:SetHeight(self.cellHeight * rowspan) frame:SetHeight(self.cellHeight * rowspan)
frame:SetPoint("TOPLEFT", self.frame, "TOPLEFT", x, y) frame:SetPoint("TOPLEFT", self.frame, "TOPLEFT", x, y)
@@ -89,51 +91,26 @@ GridFrame = {
} }
local configFrame = CreateFrame("Frame", "HeimdallConfig", UIParent) local configFrame = GridFrame.new("HeimdallConfig", UIParent, 60, 12, { w = 512, h = 512 + 256 })
---@diagnostic disable-next-line: missing-fields ---@diagnostic disable-next-line: missing-fields
shared.Config = {} shared.Config = {}
function shared.Config.Init() function shared.Config.Init()
--local function PutBelow(a, b, offset) ---@param name string
-- local x = 0 ---@param parent Frame
-- local y = -24 ---@param text string
-- if offset and offset.x then ---@param onClick fun(state: boolean)
-- x = x + offset.x local function BasicButton(name, parent, text, onClick)
-- end local button = CreateFrame("CheckButton", name, parent, "UICheckButtonTemplate")
-- if offset and offset.y then button.text = button:CreateFontString(nil, "OVERLAY", "GameFontNormal")
-- y = y + offset.y button.text:SetText(text)
-- end button.text:SetPoint("LEFT", button, "RIGHT", 0, 0)
-- a:SetPoint("LEFT", b, "LEFT", x, y) button:SetSize(24, 24)
--end button:SetScript("OnClick", function()
--local function PutRight(a, b, offset) onClick(button:GetChecked())
-- local x = 128 end)
-- local y = 0 return button
-- if offset and offset.x then end
-- x = x + offset.x
-- end
-- if offset and offset.y then
-- y = y + offset.y
-- end
-- a:SetPoint("LEFT", b, "LEFT", x, y)
--end
-----@param name string
-----@param parent Frame
-----@param text string
-----@param onClick fun(state: boolean)
--local function BasicButton(name, parent, text, onClick)
-- local button = CreateFrame("CheckButton", name, parent, "UICheckButtonTemplate")
-- button.text = button:CreateFontString(nil, "OVERLAY", "GameFontNormal")
-- button.text:SetText(text)
-- button.text:SetPoint("LEFT", button, "RIGHT", 0, 0)
-- button:SetSize(24, 24)
-- button:SetScript("OnClick", function()
-- onClick(button:GetChecked())
-- end)
-- button.PutBelow = PutBelow
-- button.PutRight = PutRight
-- return button
--end
-----@param name string -----@param name string
-----@param parent Frame -----@param parent Frame
-----@param text string -----@param text string
@@ -210,41 +187,41 @@ function shared.Config.Init()
--configFrame:SetBackdropColor(0, 0, 0, 0.8) --configFrame:SetBackdropColor(0, 0, 0, 0.8)
--configFrame:SetBackdropBorderColor(0.5, 0.5, 0.5, 1) --configFrame:SetBackdropBorderColor(0.5, 0.5, 0.5, 1)
--configFrame:SetMovable(true) configFrame.frame:SetMovable(true)
--configFrame:EnableMouse(true) configFrame.frame:EnableMouse(true)
--configFrame:RegisterForDrag("LeftButton") configFrame.frame:RegisterForDrag("LeftButton")
--configFrame:SetScript("OnDragStart", function(self) configFrame.frame:SetScript("OnDragStart", function(self)
-- self:StartMoving() self:StartMoving()
--end) end)
--configFrame:SetScript("OnDragStop", function(self) configFrame.frame:SetScript("OnDragStop", function(self)
-- self:StopMovingOrSizing() self:StopMovingOrSizing()
--end) end)
--configFrame:SetScript("OnShow", function(self) configFrame.frame:SetScript("OnShow", function(self)
-- self:SetScale(1) self:SetScale(1)
--end) end)
--local title = configFrame:CreateFontString(nil, "ARTWORK", "GameFontNormal") local title = configFrame.frame:CreateFontString(nil, "ARTWORK", "GameFontNormal")
--title:SetText("Heimdall Config") title:SetText("Heimdall Config")
--title:SetPoint("TOP", configFrame, "TOP", 0, -8) configFrame:Add(title, 1, 12)
--local spotterConfigFrame = CreateFrame("Frame", "HeimdallSpotterConfig", configFrame) local spotterConfigFrame = GridFrame.new("HeimdallSpotterConfig", configFrame.frame, 12, 12)
--spotterConfigFrame:SetSize(256, 128) configFrame:Add(spotterConfigFrame.frame, 12, 6)
--spotterConfigFrame:SetPoint("TOPLEFT", configFrame, "TOPLEFT", 8, -24) spotterConfigFrame:SetPoint("TOPLEFT", configFrame, "TOPLEFT", 8, -24)
--spotterConfigFrame:SetBackdrop({ spotterConfigFrame:SetBackdrop({
-- bgFile = "Interface/Tooltips/UI-Tooltip-Background", bgFile = "Interface/Tooltips/UI-Tooltip-Background",
-- edgeFile = "Interface/Tooltips/UI-Tooltip-Border", edgeFile = "Interface/Tooltips/UI-Tooltip-Border",
-- tile = true, tile = true,
-- tileSize = 4, tileSize = 4,
-- edgeSize = 4, edgeSize = 4,
-- insets = { insets = {
-- left = 4, left = 4,
-- right = 4, right = 4,
-- top = 4, top = 4,
-- bottom = 4 bottom = 4
-- } }
--}) })
--spotterConfigFrame:SetBackdropColor(0, 0, 0, 0.8) spotterConfigFrame:SetBackdropColor(0, 0, 0, 0.8)
--spotterConfigFrame:SetBackdropBorderColor(0.5, 0.5, 0.5, 1) spotterConfigFrame:SetBackdropBorderColor(0.5, 0.5, 0.5, 1)
--local spotterEnableButton = BasicButton("HeimdallSpotterEnable", spotterConfigFrame, "Enable Spotter", --local spotterEnableButton = BasicButton("HeimdallSpotterEnable", spotterConfigFrame, "Enable Spotter",
-- function(state) -- function(state)