Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toggle hidden bag to foreground #549

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 32 additions & 2 deletions widgets/ContainerFrame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -135,7 +139,33 @@ 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(_, ...)
-- Toggle foreground by container click
local setForeground = false
if isBank and frameLevelBank < frameLevelBag then
setForeground = true
frameLevelBank = frameLevelBank + frameLevelIncrement
elseif not isBank and frameLevelBank > frameLevelBag then
setForeground = true
frameLevelBag = frameLevelBag + 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(...)
end)
button:SetScript('OnReceiveDrag', function() return self:OnClick("LeftButton") end)
button:SetFrameLevel(frameLevel - 1)

Expand Down