From 5701cfa8341999a59089473615e60b7efdf3506f Mon Sep 17 00:00:00 2001 From: Cyb10101 Date: Fri, 22 Jan 2021 02:40:09 +0100 Subject: [PATCH 1/3] Toggle hidden bag to foreground --- widgets/ContainerFrame.lua | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/widgets/ContainerFrame.lua b/widgets/ContainerFrame.lua index 558fb535..a63b984d 100644 --- a/widgets/ContainerFrame.lua +++ b/widgets/ContainerFrame.lua @@ -92,6 +92,10 @@ function addon:CreateContainerFrame(...) return containerClass:Create(...) end local SimpleLayeredRegion = addon:GetClass("SimpleLayeredRegion") +local frameLevelBag = 0 +local frameLevelBank = 5 +local frameLevelIncrement = 10 + local bagSlots = {} function containerProto:OnCreate(name, isBank, bagObject) self:SetParent(UIParent) @@ -100,7 +104,7 @@ function containerProto:OnCreate(name, isBank, bagObject) --self:EnableMouse(true) self:SetFrameStrata("HIGH") - local frameLevel = 2 + (isBank and 5 or 0) + local frameLevel = 2 + (isBank and frameLevelBank or frameLevelBag) self:SetFrameLevel(frameLevel - 2) self:SetScript('OnShow', self.OnShow) @@ -135,7 +139,30 @@ function containerProto:OnCreate(name, isBank, bagObject) local button = CreateFrame("Button", nil, self) button:SetAllPoints(self) button:RegisterForClicks("AnyUp") - button:SetScript('OnClick', function(_, ...) return self:OnClick(...) end) + button:SetScript('OnClick', function(_, ...) + local setForeground = false + if isBank and frameLevelBank < frameLevelBag then + frameLevelBank = frameLevelBank + frameLevelIncrement + setForeground = true + elseif not isBank and frameLevelBank > frameLevelBag then + frameLevelBag = frameLevelBag + frameLevelIncrement + setForeground = true + end + if setForeground then + frameLevel = 2 + (self:GetFrameLevel() + frameLevelIncrement) + self:SetFrameLevel(frameLevel - 2) + button:SetFrameLevel(frameLevel - 1) + headerLeftRegion:SetFrameLevel(frameLevel) + headerRightRegion:SetFrameLevel(frameLevel) + bottomLeftRegion:SetFrameLevel(frameLevel) + bottomRightRegion:SetFrameLevel(frameLevel) + closeButton:SetFrameLevel(frameLevel) + searchBox:SetFrameLevel(frameLevel) + anchor:SetFrameLevel(self:GetFrameLevel() + 10) + end + + return self:OnClick(...) + end) button:SetScript('OnReceiveDrag', function() return self:OnClick("LeftButton") end) button:SetFrameLevel(frameLevel - 1) From f7d1abf9b6050190b70b00b05b7b38b3ccc437fc Mon Sep 17 00:00:00 2001 From: Cyb10101 Date: Mon, 25 Jan 2021 21:15:12 +0100 Subject: [PATCH 2/3] Simpler method for foreground toggle --- widgets/ContainerFrame.lua | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/widgets/ContainerFrame.lua b/widgets/ContainerFrame.lua index a63b984d..47fc6456 100644 --- a/widgets/ContainerFrame.lua +++ b/widgets/ContainerFrame.lua @@ -140,25 +140,13 @@ function containerProto:OnCreate(name, isBank, bagObject) button:SetAllPoints(self) button:RegisterForClicks("AnyUp") button:SetScript('OnClick', function(_, ...) - local setForeground = false + -- Toggle foreground by container click if isBank and frameLevelBank < frameLevelBag then frameLevelBank = frameLevelBank + frameLevelIncrement - setForeground = true + self:SetFrameLevel(self:GetFrameLevel() + frameLevelIncrement) elseif not isBank and frameLevelBank > frameLevelBag then frameLevelBag = frameLevelBag + frameLevelIncrement - setForeground = true - end - if setForeground then - frameLevel = 2 + (self:GetFrameLevel() + frameLevelIncrement) - self:SetFrameLevel(frameLevel - 2) - button:SetFrameLevel(frameLevel - 1) - headerLeftRegion:SetFrameLevel(frameLevel) - headerRightRegion:SetFrameLevel(frameLevel) - bottomLeftRegion:SetFrameLevel(frameLevel) - bottomRightRegion:SetFrameLevel(frameLevel) - closeButton:SetFrameLevel(frameLevel) - searchBox:SetFrameLevel(frameLevel) - anchor:SetFrameLevel(self:GetFrameLevel() + 10) + self:SetFrameLevel(self:GetFrameLevel() + frameLevelIncrement) end return self:OnClick(...) From c4a7cda2313bbea4fc10d090e4ee620f9bdabb1e Mon Sep 17 00:00:00 2001 From: Cyb10101 Date: Tue, 26 Jan 2021 23:09:32 +0100 Subject: [PATCH 3/3] Search and buttons readded --- widgets/ContainerFrame.lua | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/widgets/ContainerFrame.lua b/widgets/ContainerFrame.lua index 47fc6456..2fe6d660 100644 --- a/widgets/ContainerFrame.lua +++ b/widgets/ContainerFrame.lua @@ -141,12 +141,27 @@ function containerProto:OnCreate(name, isBank, bagObject) button:RegisterForClicks("AnyUp") button:SetScript('OnClick', function(_, ...) -- Toggle foreground by container click + local setForeground = false if isBank and frameLevelBank < frameLevelBag then + setForeground = true frameLevelBank = frameLevelBank + frameLevelIncrement - self:SetFrameLevel(self:GetFrameLevel() + frameLevelIncrement) elseif not isBank and frameLevelBank > frameLevelBag then + setForeground = true frameLevelBag = frameLevelBag + frameLevelIncrement - self:SetFrameLevel(self:GetFrameLevel() + frameLevelIncrement) + end + + if setForeground then + frameLevel = 2 + (self:GetFrameLevel() + frameLevelIncrement) + self:SetFrameLevel(frameLevel - 2) + if button ~= nil then + button:SetFrameLevel(frameLevel - 1) + end + if closeButton ~= nil then + closeButton:SetFrameLevel(frameLevel) + end + if searchBox ~= nil then + searchBox:SetFrameLevel(frameLevel) + end end return self:OnClick(...)