From fc3732fd0ce2e5955ca0712ff45aad61a78e5465 Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Mon, 6 Jan 2025 17:16:48 +0100 Subject: [PATCH] Begin reworking old approach to gridframe --- Modules/Config.lua | 125 ++++++++++++++++++--------------------------- 1 file changed, 51 insertions(+), 74 deletions(-) diff --git a/Modules/Config.lua b/Modules/Config.lua index cd9c918..b8a59ff 100644 --- a/Modules/Config.lua +++ b/Modules/Config.lua @@ -70,6 +70,8 @@ GridFrame = { if canPlace then local x = (col - 1) * self.cellWidth 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:SetHeight(self.cellHeight * rowspan) 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 shared.Config = {} function shared.Config.Init() - --local function PutBelow(a, b, offset) - -- local x = 0 - -- local y = -24 - -- if offset and offset.x then - -- x = x + offset.x - -- end - -- if offset and offset.y then - -- y = y + offset.y - -- end - -- a:SetPoint("LEFT", b, "LEFT", x, y) - --end - --local function PutRight(a, b, offset) - -- local x = 128 - -- local y = 0 - -- if offset and offset.x then - -- 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 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) + return button + end -----@param name string -----@param parent Frame -----@param text string @@ -210,41 +187,41 @@ function shared.Config.Init() --configFrame:SetBackdropColor(0, 0, 0, 0.8) --configFrame:SetBackdropBorderColor(0.5, 0.5, 0.5, 1) - --configFrame:SetMovable(true) - --configFrame:EnableMouse(true) - --configFrame:RegisterForDrag("LeftButton") - --configFrame:SetScript("OnDragStart", function(self) - -- self:StartMoving() - --end) - --configFrame:SetScript("OnDragStop", function(self) - -- self:StopMovingOrSizing() - --end) - --configFrame:SetScript("OnShow", function(self) - -- self:SetScale(1) - --end) + configFrame.frame:SetMovable(true) + configFrame.frame:EnableMouse(true) + configFrame.frame:RegisterForDrag("LeftButton") + configFrame.frame:SetScript("OnDragStart", function(self) + self:StartMoving() + end) + configFrame.frame:SetScript("OnDragStop", function(self) + self:StopMovingOrSizing() + end) + configFrame.frame:SetScript("OnShow", function(self) + self:SetScale(1) + end) - --local title = configFrame:CreateFontString(nil, "ARTWORK", "GameFontNormal") - --title:SetText("Heimdall Config") - --title:SetPoint("TOP", configFrame, "TOP", 0, -8) + local title = configFrame.frame:CreateFontString(nil, "ARTWORK", "GameFontNormal") + title:SetText("Heimdall Config") + configFrame:Add(title, 1, 12) - --local spotterConfigFrame = CreateFrame("Frame", "HeimdallSpotterConfig", configFrame) - --spotterConfigFrame:SetSize(256, 128) - --spotterConfigFrame:SetPoint("TOPLEFT", configFrame, "TOPLEFT", 8, -24) - --spotterConfigFrame:SetBackdrop({ - -- bgFile = "Interface/Tooltips/UI-Tooltip-Background", - -- edgeFile = "Interface/Tooltips/UI-Tooltip-Border", - -- tile = true, - -- tileSize = 4, - -- edgeSize = 4, - -- insets = { - -- left = 4, - -- right = 4, - -- top = 4, - -- bottom = 4 - -- } - --}) - --spotterConfigFrame:SetBackdropColor(0, 0, 0, 0.8) - --spotterConfigFrame:SetBackdropBorderColor(0.5, 0.5, 0.5, 1) + local spotterConfigFrame = GridFrame.new("HeimdallSpotterConfig", configFrame.frame, 12, 12) + configFrame:Add(spotterConfigFrame.frame, 12, 6) + spotterConfigFrame:SetPoint("TOPLEFT", configFrame, "TOPLEFT", 8, -24) + spotterConfigFrame:SetBackdrop({ + bgFile = "Interface/Tooltips/UI-Tooltip-Background", + edgeFile = "Interface/Tooltips/UI-Tooltip-Border", + tile = true, + tileSize = 4, + edgeSize = 4, + insets = { + left = 4, + right = 4, + top = 4, + bottom = 4 + } + }) + spotterConfigFrame:SetBackdropColor(0, 0, 0, 0.8) + spotterConfigFrame:SetBackdropBorderColor(0.5, 0.5, 0.5, 1) --local spotterEnableButton = BasicButton("HeimdallSpotterEnable", spotterConfigFrame, "Enable Spotter", -- function(state)