Skip to content

Commit

Permalink
Fix loaded/unloaded if groups or sections weren't expanded
Browse files Browse the repository at this point in the history
  • Loading branch information
InfusOnWoW committed Jan 22, 2024
1 parent 21eb8eb commit 0f999f2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
13 changes: 7 additions & 6 deletions WeakAurasOptions/OptionsFrames/OptionsFrame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -747,13 +747,14 @@ function OptionsPrivate.CreateFrame()
loadedButton:SetCollapseDescription(L["Collapse all loaded displays"])
loadedButton:SetViewClick(function()
local suspended = OptionsPrivate.Private.PauseAllDynamicGroups()

if loadedButton.view.visibility == 2 then
for _, child in pairs(loadedButton.childButtons) do
for _, child in ipairs(loadedButton.childButtons) do
child:PriorityHide(2)
end
loadedButton:PriorityHide(2)
else
for _, child in pairs(loadedButton.childButtons) do
for _, child in ipairs(loadedButton.childButtons) do
child:PriorityShow(2)
end
loadedButton:PriorityShow(2)
Expand All @@ -762,7 +763,7 @@ function OptionsPrivate.CreateFrame()
end)
loadedButton.RecheckVisibility = function(self)
local none, all = true, true
for _, child in pairs(loadedButton.childButtons) do
for _, child in ipairs(loadedButton.childButtons) do
if child:GetVisibility() ~= 2 then
all = false
end
Expand Down Expand Up @@ -810,12 +811,12 @@ function OptionsPrivate.CreateFrame()
unloadedButton:SetViewClick(function()
local suspended = OptionsPrivate.Private.PauseAllDynamicGroups()
if unloadedButton.view.visibility == 2 then
for _, child in pairs(unloadedButton.childButtons) do
for _, child in ipairs(unloadedButton.childButtons) do
child:PriorityHide(2)
end
unloadedButton:PriorityHide(2)
else
for _, child in pairs(unloadedButton.childButtons) do
for _, child in ipairs(unloadedButton.childButtons) do
child:PriorityShow(2)
end
unloadedButton:PriorityShow(2)
Expand All @@ -824,7 +825,7 @@ function OptionsPrivate.CreateFrame()
end)
unloadedButton.RecheckVisibility = function(self)
local none, all = true, true
for _, child in pairs(unloadedButton.childButtons) do
for _, child in ipairs(unloadedButton.childButtons) do
if child:GetVisibility() ~= 2 then
all = false
end
Expand Down
21 changes: 16 additions & 5 deletions WeakAurasOptions/WeakAurasOptions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -971,19 +971,18 @@ function OptionsPrivate.UpdateButtonsScroll()
frame.buttonsScroll:DoLayout()
end

local function addButton(button, aurasMatchingFilter, visible, list)
local function addButton(button, aurasMatchingFilter, visible)
button.frame:Show();
if button.AcquireThumbnail then
button:AcquireThumbnail()
end
tinsert(frame.buttonsScroll.children, button);
tinsert(list, button)
visible[button] = true

if button.data.controlledChildren and button:GetExpanded() then
for _, childId in ipairs(button.data.controlledChildren) do
if aurasMatchingFilter[childId] then
addButton(displayButtons[childId], aurasMatchingFilter, visible, list)
addButton(displayButtons[childId], aurasMatchingFilter, visible)
end
end
end
Expand Down Expand Up @@ -1167,23 +1166,35 @@ function OptionsPrivate.SortDisplayButtons(filter, overrideReset, id)
table.sort(topLevelLoadedAuras, function(a, b) return a:lower() < b:lower() end)
for _, id in ipairs(topLevelLoadedAuras) do
if aurasMatchingFilter[id] then
addButton(displayButtons[id], aurasMatchingFilter, visible, frame.loadedButton.childButtons)
addButton(displayButtons[id], aurasMatchingFilter, visible)
end
end
end

for _, id in ipairs(topLevelLoadedAuras) do
for child in OptionsPrivate.Private.TraverseAllChildren(WeakAuras.GetData(id)) do
tinsert(frame.loadedButton.childButtons, displayButtons[child.id])
end
end

tinsert(frame.buttonsScroll.children, frame.unloadedButton);

wipe(frame.unloadedButton.childButtons)
if frame.unloadedButton:GetExpanded() then
table.sort(topLevelUnloadedAuras, function(a, b) return a:lower() < b:lower() end)
for _, id in ipairs(topLevelUnloadedAuras) do
if aurasMatchingFilter[id] then
addButton(displayButtons[id], aurasMatchingFilter, visible, frame.unloadedButton.childButtons)
addButton(displayButtons[id], aurasMatchingFilter, visible)
end
end
end

for _, id in ipairs(topLevelUnloadedAuras) do
for child in OptionsPrivate.Private.TraverseAllChildren(WeakAuras.GetData(id)) do
tinsert(frame.unloadedButton.childButtons, displayButtons[child.id])
end
end

for _, child in pairs(displayButtons) do
if(not visible[child]) then
child.frame:Hide();
Expand Down

0 comments on commit 0f999f2

Please sign in to comment.