Skip to content

Commit

Permalink
Removed eyeball icon from category config.
Browse files Browse the repository at this point in the history
Right click menu is now used to hide or show categories.

Dynamic categories always have the enabled backdrop.
  • Loading branch information
Cidan committed Jul 4, 2024
1 parent a073452 commit 0dd6033
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 44 deletions.
5 changes: 2 additions & 3 deletions frames/contextmenu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -90,7 +89,7 @@ local function addDivider(menuList)
},
})
end
]]--

---@param menu MenuList[]
local function enableTooltips(menu)
for _, m in ipairs(menu) do
Expand Down
66 changes: 25 additions & 41 deletions frames/sectionconfig.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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,
Expand All @@ -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)

Expand Down

0 comments on commit 0dd6033

Please sign in to comment.