diff --git a/UI/ItemButton.lua b/UI/ItemButton.lua index e545718..2d2af4f 100644 --- a/UI/ItemButton.lua +++ b/UI/ItemButton.lua @@ -57,6 +57,16 @@ function Guda_ResetButtonPool() nextButtonID = 1 end +-- Mark all buttons as available for reuse (called when switching view types) +-- This allows buttons from one frame to be reused by another +function Guda_ReleaseAllButtons() + for _, button in pairs(buttonPool) do + if not button.isBagSlot then + button.inUse = false + end + end +end + -- Use shared tooltip from Utils module (retrieved on-demand to ensure Utils is loaded) -- Helper function to check if an item is a quest item diff --git a/UI/SettingsPopup.lua b/UI/SettingsPopup.lua index 601b4b8..21125bc 100644 --- a/UI/SettingsPopup.lua +++ b/UI/SettingsPopup.lua @@ -1147,16 +1147,24 @@ function Guda_SettingsPopup_BagViewTypeButton_OnClick() local current = Guda.Modules.DB:GetSetting("bagViewType") or "single" local newValue = (current == "single") and "category" or "single" Guda.Modules.DB:SetSetting("bagViewType", newValue) - + local btn = getglobal("Guda_SettingsPopup_BagViewTypeButton") if btn then btn:SetText(newValue == "single" and "Bag View: Single" or "Bag View: Category") end - - -- Refresh bag frame if it's open + + -- Release all buttons so they can be reused when switching views + if Guda_ReleaseAllButtons then + Guda_ReleaseAllButtons() + end + + -- Refresh BOTH frames to ensure buttons are properly distributed if Guda_BagFrame:IsShown() then Guda.Modules.BagFrame:Update() end + if Guda_BankFrame and Guda_BankFrame:IsShown() then + Guda.Modules.BankFrame:Update() + end end -- Bank View Type Button OnClick @@ -1164,16 +1172,24 @@ function Guda_SettingsPopup_BankViewTypeButton_OnClick() local current = Guda.Modules.DB:GetSetting("bankViewType") or "single" local newValue = (current == "single") and "category" or "single" Guda.Modules.DB:SetSetting("bankViewType", newValue) - + local btn = getglobal("Guda_SettingsPopup_BankViewTypeButton") if btn then btn:SetText(newValue == "single" and "Bank View: Single" or "Bank View: Category") end - - -- Refresh bank frame if it's open - if Guda_BankFrame:IsShown() then + + -- Release all buttons so they can be reused when switching views + if Guda_ReleaseAllButtons then + Guda_ReleaseAllButtons() + end + + -- Refresh BOTH frames to ensure buttons are properly distributed + if Guda_BankFrame and Guda_BankFrame:IsShown() then Guda.Modules.BankFrame:Update() end + if Guda_BagFrame:IsShown() then + Guda.Modules.BagFrame:Update() + end end -- Reverse Stack Sort Checkbox OnLoad