From 0dd60330483e7be914797c5f8c79cbf806837c9c Mon Sep 17 00:00:00 2001 From: Antonio Lobato Date: Wed, 3 Jul 2024 22:23:46 -0700 Subject: [PATCH] Removed eyeball icon from category config. Right click menu is now used to hide or show categories. Dynamic categories always have the enabled backdrop. --- frames/contextmenu.lua | 5 ++- frames/sectionconfig.lua | 66 +++++++++++++++------------------------- 2 files changed, 27 insertions(+), 44 deletions(-) diff --git a/frames/contextmenu.lua b/frames/contextmenu.lua index cad83381..e82839b7 100644 --- a/frames/contextmenu.lua +++ b/frames/contextmenu.lua @@ -69,8 +69,7 @@ function contextMenu:Hide() events:SendMessage('context/hide') end ---[[ -local function addDivider(menuList) +function contextMenu:AddDivider(menuList) table.insert(menuList, { text = "", isTitle = true, @@ -90,7 +89,7 @@ local function addDivider(menuList) }, }) end -]]-- + ---@param menu MenuList[] local function enableTooltips(menu) for _, m in ipairs(menu) do diff --git a/frames/sectionconfig.lua b/frames/sectionconfig.lua index 5cdf574e..5a4a536e 100644 --- a/frames/sectionconfig.lua +++ b/frames/sectionconfig.lua @@ -97,12 +97,9 @@ function sectionConfigFrame:initSectionItem(button, elementData) button.Expand = CreateFrame("Button", nil, button) button.Expand:SetSize(24, 24) button.Expand:SetPoint("LEFT", button, "LEFT", 0, 0) - button.Visible = CreateFrame("Button", nil, button) - button.Visible:SetSize(20, 20) - button.Visible:SetPoint("LEFT", button.Expand, "RIGHT", 5, 0) button.Category = button:CreateFontString(nil, "OVERLAY") button.Category:SetHeight(30) - button.Category:SetPoint("LEFT", button.Visible, "RIGHT", 5, 0) + button.Category:SetPoint("LEFT", button.Expand, "RIGHT", 5, 0) button.Note = button:CreateFontString(nil, "OVERLAY") button.Note:SetHeight(30) button.Note:SetPoint("RIGHT", button, "RIGHT", -10, 0) @@ -116,27 +113,18 @@ function sectionConfigFrame:initSectionItem(button, elementData) button.Expand:SetNormalTexture("Interface\\glues\\common\\glue-leftarrow-button-up") button.Expand:SetPushedTexture("Interface\\glues\\common\\glue-leftarrow-button-down") button.Expand:SetHighlightTexture("Interface\\glues\\common\\glue-leftarrow-button-highlight", "ADD") - button.Visible:SetNormalTexture("Interface\\AddOns\\BetterBags\\textures\\visible.blp") - button.Visible:SetHighlightTexture("Interface\\Addons\\BetterBags\\textures\\visible.blp") - button.Visible:SetScript("OnEnter", function() - GameTooltip:SetOwner(button, "ANCHOR_LEFT") - GameTooltip:AddLine("Show or hide this category in the bags.", 1, .81960791349411, 0, true) - GameTooltip:Show() - end) end -- Set the category font info for the button depending on if it's a header or not. if elementData.header then button.Category:SetFontObject(fonts.UnitFrame12Yellow) button.Expand:Hide() - button.Visible:Hide() else button.Category:SetFontObject(fonts.UnitFrame12White) button.Expand:SetScript("OnClick", function() self.itemList:ShowCategory(elementData.title) end) button.Expand:Show() - button.Visible:Show() if not categories:DoesCategoryExist(elementData.title) then button.Expand:Disable() button.Expand:GetNormalTexture():SetDesaturated(true) @@ -146,29 +134,19 @@ function sectionConfigFrame:initSectionItem(button, elementData) end if categories:IsCategoryShown(elementData.title) then - button.Visible:GetNormalTexture():SetVertexColor(1, 1, 1, 1) + button.Note:SetText("") else - button.Visible:GetNormalTexture():SetVertexColor(0.6, 0.1, 0.1, 1) + button.Note:SetText("(hidden)") end - button.Visible:SetScript("OnClick", function() - categories:ToggleCategoryShown(elementData.title) - if categories:IsCategoryShown(elementData.title) then - button.Visible:GetNormalTexture():SetVertexColor(1, 1, 1, 1) - else - button.Visible:GetNormalTexture():SetVertexColor(0.6, 0.1, 0.1, 1) - end - end) end -- Set the backdrop initial state. - if categories:IsCategoryEnabled(self.kind, elementData.title) then + if not elementData.header and (categories:IsCategoryEnabled(self.kind, elementData.title) or not categories:DoesCategoryExist(elementData.title)) then button:SetBackdropColor(1, 1, 0, .2) + elseif elementData.header then + button:SetBackdropColor(0, 0, 0, .3) else - if elementData.header then - button:SetBackdropColor(0, 0, 0, .3) - else - button:SetBackdropColor(0, 0, 0, 0) - end + button:SetBackdropColor(0, 0, 0, 0) end if not elementData.header then @@ -193,14 +171,13 @@ function sectionConfigFrame:initSectionItem(button, elementData) GameTooltip:AddDoubleLine("Left Click", "Enable or Disable Category") GameTooltip:AddDoubleLine("Shift Left Click", format("Move %s to the top of your bags", elementData.title)) GameTooltip:AddDoubleLine("Right Click", "Open Menu") - GameTooltip:AddDoubleLine("Shift Right Click", "Hide or Show Category") else GameTooltip:AddLine([[ Dynamic categories can't be enabled or disabled (yet). Drag this category to Pinned to keep it at the top of your bags, or to Automatically Sorted to have it sorted with the rest of your items.]], 1, 1, 1, true) GameTooltip:AddLine("\n", 1, 1, 1, true) GameTooltip:AddDoubleLine("Shift Left Click", format("Move %s to the top of your bags", elementData.title)) - GameTooltip:AddDoubleLine("Shift Right Click", "Hide or Show Category") + GameTooltip:AddDoubleLine("Right Click", "Open Menu") end GameTooltip:Show() end) @@ -221,8 +198,25 @@ function sectionConfigFrame:initSectionItem(button, elementData) if elementData.header then return end + ---@type MenuList[] local menuOptions = {} + table.insert(menuOptions, { + text = L:G("Hide Category"), + hasArrow = false, + checked = function() + return not categories:IsCategoryShown(elementData.title) + end, + func = function() + categories:ToggleCategoryShown(elementData.title) + if categories:IsCategoryShown(elementData.title) then + button.Note:SetText("") + else + button.Note:SetText("(hidden)") + end + end + }) if categories:DoesCategoryExist(elementData.title) then + contextMenu:AddDivider(menuOptions) table.insert(menuOptions,{ text = L:G("Delete Category"), notCheckable = true, @@ -243,16 +237,6 @@ function sectionConfigFrame:initSectionItem(button, elementData) end }) end --- table.insert(menuOptions, { --- text = L:G("Hide Category"), --- hasArrow = false, --- checked = function() --- return not categories:IsCategoryShown(elementData.title) --- end, --- func = function() --- categories:ToggleCategoryShown(elementData.title) --- end --- }) contextMenu:Show(menuOptions) end)