From cfa49f4a3593895fe666bfbe10b33617f6283886 Mon Sep 17 00:00:00 2001 From: Vati Date: Wed, 18 Mar 2026 01:33:57 +0400 Subject: [PATCH] fix: UI simetry optimized --- Core/Theme.lua | 123 ++++++++++++++++++++++++++++++++++++++++++++ UI/BagFrame.lua | 14 +++-- UI/BankFrame.lua | 44 ++++++++++------ UI/FrameHelpers.lua | 20 ++++--- 4 files changed, 175 insertions(+), 26 deletions(-) diff --git a/Core/Theme.lua b/Core/Theme.lua index b75495a..b003dfa 100644 --- a/Core/Theme.lua +++ b/Core/Theme.lua @@ -144,6 +144,34 @@ function Theme:GetQualityBorderStyle() return self:GetValue("qualityBorderStyle") or "rounded" end +-- Get frame padding values (reduced for pfUI borderless style) +function Theme:GetFramePadding() + local style = self:GetSlotStyle() + if style == "square" then + return { + containerExtra = 10, -- added to columns*size for container width + frameExtra = 10, -- added to containerWidth for frame width + titleHeight = 28, + searchBarHeight = 28, + footerHeight = 35, + footerHiddenHeight = 5, + startX = 10, + startY = -2, + } + else + return { + containerExtra = 20, + frameExtra = 20, + titleHeight = 40, + searchBarHeight = 30, + footerHeight = 45, + footerHiddenHeight = 10, + startX = 10, + startY = -2, + } + end +end + -- Get border config based on hideBorders setting local function GetBorderConfig(t) local hideBorders = false @@ -498,6 +526,12 @@ function Theme:ApplyToAllFrames() -- Update header button backgrounds self:ApplyHeaderButtonBackgrounds() + -- Update search box styling + self:ApplySearchBoxStyle() + + -- Adjust frame padding for borderless/pfUI themes + self:ApplyFramePadding() + ThemeDebug("=== ApplyToAllFrames done ===") end @@ -595,6 +629,95 @@ function Theme:ApplyHeaderButtonBackgrounds() end end +-- Apply square/rounded styling to search boxes +function Theme:ApplySearchBoxStyle() + local slotStyle = self:GetSlotStyle() + local searchBoxNames = { + "Guda_BagFrame_SearchBar_SearchBox", + "Guda_BankFrame_SearchBar_SearchBox", + } + for _, name in ipairs(searchBoxNames) do + local box = getglobal(name) + if box then + -- Hide InputBoxTemplate border textures (Left, Right, Middle) + local left = getglobal(name .. "Left") + local right = getglobal(name .. "Right") + local mid = getglobal(name .. "Middle") + if slotStyle == "square" then + if left then left:Hide() end + if right then right:Hide() end + if mid then mid:Hide() end + -- Apply pfUI-style backdrop + box:SetBackdrop({ + bgFile = "Interface\\Buttons\\WHITE8x8", + edgeFile = "Interface\\Buttons\\WHITE8x8", + edgeSize = 1, + insets = { left = -1, right = -1, top = -1, bottom = -1 }, + }) + box:SetBackdropColor(0, 0, 0, 1) + box:SetBackdropBorderColor(0.2, 0.2, 0.2, 1) + -- Reposition flush left at x=10 + box:ClearAllPoints() + box:SetPoint("LEFT", box:GetParent(), "LEFT", 8, 0) + box:SetPoint("RIGHT", box:GetParent(), "RIGHT", -7, 0) + -- Add text padding inside the field + box:SetTextInsets(5, 5, 0, 0) + else + if left then left:Show() end + if right then right:Show() end + if mid then mid:Show() end + box:SetBackdrop(nil) + -- Restore default anchors + box:ClearAllPoints() + box:SetPoint("LEFT", box:GetParent(), "LEFT", 15, 0) + box:SetPoint("RIGHT", box:GetParent(), "RIGHT", -12, 0) + -- Restore default text insets + box:SetTextInsets(3, 3, 0, 0) + end + end + end +end + +-- Adjust header/footer padding to match theme border style +function Theme:ApplyFramePadding() + local slotStyle = self:GetSlotStyle() + -- Only adjust for pfUI/square style; otherwise restore defaults + local isPfui = (slotStyle == "square") + + -- BagFrame adjustments + local bagFrameElements = { + { name = "Guda_BagFrame_Title", pfui = { "TOP", nil, "TOP", 0, -8 }, default = { "TOP", nil, "TOP", 0, -12 } }, + { name = "Guda_BagFrame_CloseButton", pfui = { "TOPRIGHT", nil, "TOPRIGHT", -5, -5 }, default = { "TOPRIGHT", nil, "TOPRIGHT", -13, -10 } }, + { name = "Guda_BagFrame_CharsButton", pfui = { "TOPLEFT", nil, "TOPLEFT", 10, -8 }, default = { "TOPLEFT", nil, "TOPLEFT", 21, -15 } }, + { name = "Guda_BagFrame_SearchBar", pfui = { "TOP", nil, "TOP", 0, -28 }, default = { "TOP", nil, "TOP", 0, -40 } }, + { name = "Guda_BagFrame_Toolbar", pfui = { "BOTTOMLEFT", nil, "BOTTOMLEFT", 5, 5 }, default = { "BOTTOMLEFT", nil, "BOTTOMLEFT", 10, 5 } }, + } + for _, elem in ipairs(bagFrameElements) do + local frame = getglobal(elem.name) + if frame then + local pos = isPfui and elem.pfui or elem.default + local parent = frame:GetParent() + frame:ClearAllPoints() + frame:SetPoint(pos[1], parent, pos[3], pos[4], pos[5]) + end + end + + -- BankFrame adjustments (similar structure) + local bankFrameElements = { + { name = "Guda_BankFrame_Title", pfui = { "TOP", nil, "TOP", 0, -8 }, default = { "TOP", nil, "TOP", 0, -12 } }, + { name = "Guda_BankFrame_CloseButton", pfui = { "TOPRIGHT", nil, "TOPRIGHT", -5, -5 }, default = { "TOPRIGHT", nil, "TOPRIGHT", -13, -10 } }, + } + for _, elem in ipairs(bankFrameElements) do + local frame = getglobal(elem.name) + if frame then + local pos = isPfui and elem.pfui or elem.default + local parent = frame:GetParent() + frame:ClearAllPoints() + frame:SetPoint(pos[1], parent, pos[3], pos[4], pos[5]) + end + end +end + -- Clear cache (call when theme setting changes) function Theme:ClearCache() cachedTheme = nil diff --git a/UI/BagFrame.lua b/UI/BagFrame.lua index c960608..dd56b3f 100644 --- a/UI/BagFrame.lua +++ b/UI/BagFrame.lua @@ -1033,8 +1033,12 @@ function BagFrame:DisplayItemsByCategory(bagData, isOtherChar, charName) end end - -- Layout - local startX, startY = 10, -10 + -- Layout (theme-aware padding) + local _pad = { startX = 10, startY = -10 } + if addon.Modules and addon.Modules.Theme and addon.Modules.Theme.GetFramePadding then + _pad = addon.Modules.Theme:GetFramePadding() + end + local startX, startY = _pad.startX, _pad.startY local currentX, currentY = 0, 0 local rowMaxHeight = 0 local headerIdx = 1 @@ -1347,7 +1351,11 @@ end -- Display items function BagFrame:DisplayItems(bagData, isOtherChar, charName) - local x, y = 10, -10 + local _pad = { startX = 10, startY = -10 } + if addon.Modules and addon.Modules.Theme and addon.Modules.Theme.GetFramePadding then + _pad = addon.Modules.Theme:GetFramePadding() + end + local x, y = _pad.startX, _pad.startY local row = 0 local col = 0 local buttonSize = addon.Modules.DB:GetSetting("iconSize") or addon.Constants.BUTTON_SIZE diff --git a/UI/BankFrame.lua b/UI/BankFrame.lua index 41e6b3a..953b297 100644 --- a/UI/BankFrame.lua +++ b/UI/BankFrame.lua @@ -834,8 +834,12 @@ function BankFrame:DisplayItemsByCategory(bankData, isOtherChar, charName) end end - -- Layout - local startX, startY = 5, -10 + -- Layout (theme-aware padding) + local _pad = { startX = 5, startY = -10 } + if addon.Modules and addon.Modules.Theme and addon.Modules.Theme.GetFramePadding then + _pad = addon.Modules.Theme:GetFramePadding() + end + local startX, startY = _pad.startX, _pad.startY local currentX, currentY = 0, 0 local rowMaxHeight = 0 local headerIdx = 1 @@ -1108,7 +1112,11 @@ end -- Display items function BankFrame:DisplayItems(bankData, isOtherChar, charName) - local x, y = 5, -10 + local _pad = { startX = 5, startY = -10 } + if addon.Modules and addon.Modules.Theme and addon.Modules.Theme.GetFramePadding then + _pad = addon.Modules.Theme:GetFramePadding() + end + local x, y = _pad.startX, _pad.startY local row = 0 local col = 0 local buttonSize = addon.Modules.DB:GetSetting("iconSize") or addon.Constants.BUTTON_SIZE @@ -1270,10 +1278,16 @@ function BankFrame:ResizeFrame(currentRow, currentCol, columns, overrideHeight) columns = 1 end - -- Calculate required dimensions - local containerWidth = (columns * (buttonSize + spacing)) + 10 - local containerHeight = overrideHeight or ((totalRows * (buttonSize + spacing)) + 20) - local frameWidth = containerWidth + 30 + -- Get theme-aware padding + local pad = { containerExtra = 20, frameExtra = 20, titleHeight = 40, searchBarHeight = 30, footerHeight = 45, footerHiddenHeight = 10 } + if addon.Modules and addon.Modules.Theme and addon.Modules.Theme.GetFramePadding then + pad = addon.Modules.Theme:GetFramePadding() + end + + -- Calculate required dimensions (symmetric: startX padding on both sides, no trailing spacing) + local containerWidth = columns * (buttonSize + spacing) - spacing + 2 * pad.startX + local containerHeight = overrideHeight or (totalRows * (buttonSize + spacing) - spacing + 2 * math.abs(pad.startY)) + local frameWidth = containerWidth + pad.frameExtra -- Check if search bar is visible local showSearchBar = addon.Modules.DB:GetSetting("showSearchBar") @@ -1281,28 +1295,26 @@ function BankFrame:ResizeFrame(currentRow, currentCol, columns, overrideHeight) showSearchBar = true end - -- Adjust frame height based on search bar visibility - -- Footer height varies: less space when search bar is hidden - local titleHeight = 40 - local searchBarHeight = 30 - local footerHeight = 40 + local titleHeight = pad.titleHeight + local searchBarHeight = pad.searchBarHeight + local footerHeight = pad.footerHeight local frameHeight local hideFooter = addon.Modules.DB:GetSetting("hideFooter") if hideFooter then - footerHeight = 10 -- Small padding at bottom + footerHeight = pad.footerHiddenHeight frameHeight = containerHeight + titleHeight + (showSearchBar and searchBarHeight or 0) + footerHeight elseif showSearchBar then - frameHeight = containerHeight + titleHeight + searchBarHeight + footerHeight -- 125 total + frameHeight = containerHeight + titleHeight + searchBarHeight + footerHeight else - frameHeight = containerHeight + titleHeight + footerHeight -- 80 total + frameHeight = containerHeight + titleHeight + footerHeight end -- Minimum sizes if containerWidth < 200 then containerWidth = 200 - frameWidth = 230 + frameWidth = 200 + pad.frameExtra end if containerHeight < 150 then containerHeight = 150 diff --git a/UI/FrameHelpers.lua b/UI/FrameHelpers.lua index 3a0c884..09560e3 100644 --- a/UI/FrameHelpers.lua +++ b/UI/FrameHelpers.lua @@ -425,21 +425,27 @@ function Guda_ResizeFrame(frameName, containerName, currentRow, currentCol, colu local totalRows = (currentRow or 0) + 1 if totalRows < 1 then totalRows = 1 end - local containerWidth = (columns * (buttonSize + spacing)) + 20 - local containerHeight = overrideHeight or ((totalRows * (buttonSize + spacing)) + 20) - local frameWidth = containerWidth + 20 + -- Get theme-aware padding + local pad = { containerExtra = 20, frameExtra = 20, titleHeight = 40, searchBarHeight = 30, footerHeight = 45, footerHiddenHeight = 10 } + if addon.Modules and addon.Modules.Theme and addon.Modules.Theme.GetFramePadding then + pad = addon.Modules.Theme:GetFramePadding() + end + + local containerWidth = columns * (buttonSize + spacing) - spacing + 2 * pad.startX + local containerHeight = overrideHeight or (totalRows * (buttonSize + spacing) - spacing + 2 * math.abs(pad.startY)) + local frameWidth = containerWidth + pad.frameExtra local showSearchBar = addon.Modules.DB:GetSetting("showSearchBar") if showSearchBar == nil then showSearchBar = true end - local titleHeight = 40 - local searchBarHeight = 30 - local footerHeight = 45 + local titleHeight = pad.titleHeight + local searchBarHeight = pad.searchBarHeight + local footerHeight = pad.footerHeight local frameHeight local hideFooter = addon.Modules.DB:GetSetting("hideFooter") if hideFooter then - footerHeight = 10 + footerHeight = pad.footerHiddenHeight frameHeight = containerHeight + titleHeight + (showSearchBar and searchBarHeight or 0) + footerHeight elseif showSearchBar then frameHeight = containerHeight + titleHeight + searchBarHeight + footerHeight