From 3a9da1a2a0eb55c996b03c075162285dbe699694 Mon Sep 17 00:00:00 2001 From: Antonio Lobato Date: Sat, 6 Apr 2024 09:49:03 -0700 Subject: [PATCH] Improved the new category drop text -- items can now be clicked into a new category, added a new tooltip, and disabled the items tooltip drop zone. --- annotations.lua | 1 + config/itemlist.lua | 14 ++++++++++++++ frames/section.lua | 23 +++++++++++++++++++++-- 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/annotations.lua b/annotations.lua index f8048f2e..c53fd393 100644 --- a/annotations.lua +++ b/annotations.lua @@ -262,6 +262,7 @@ local OptionsTable = {} ---@field frame Frame ---@field section Section ---@field parent AceGUIFrame +---@field label AceGUILabel local AceItemList = {} ---@param values CustomCategoryFilter diff --git a/config/itemlist.lua b/config/itemlist.lua index 2eb4b9a9..67c4cd7f 100644 --- a/config/itemlist.lua +++ b/config/itemlist.lua @@ -51,6 +51,9 @@ local function SetList(self, values) for k, _ in pairs(values.itemList) do table.insert(itemList, k) end + if self.label then + self.label = nil + end self:ReleaseChildren() self:SetFullWidth(true) self:SetRelativeWidth(1) @@ -82,9 +85,19 @@ local function SetList(self, values) items:RefreshAll() label.frame:EnableMouse(true) label.frame:SetScript("OnReceiveDrag", rec) + label.frame:SetScript("OnMouseDown", rec) + label.frame:SetScript("OnEnter", function() + GameTooltip:SetOwner(label.frame, "ANCHOR_TOP") + GameTooltip:SetText(L:G("Drag an item here to add it to this category.")) + GameTooltip:Show() + end) + label.frame:SetScript("OnLeave", function() + GameTooltip:Hide() + end) if self.parent then self.parent:DoLayout() end + self.label = label return end @@ -159,6 +172,7 @@ function config:CreateItemListWidget() widget.frame:EnableMouse(true) local section = sectionFrame:Create() + section:DisableHeader() section:SetFillWidth(true) section:SetTitle("Items") section.frame:SetParent(widget.frame) diff --git a/frames/section.lua b/frames/section.lua index 00fe4b8e..8ca30538 100644 --- a/frames/section.lua +++ b/frames/section.lua @@ -40,6 +40,7 @@ local grid = addon:GetModule('Grid') ---@field overlay Frame The overlay frame of the section, used as a drop zone. ---@field private content Grid The main content frame of the section. ---@field private fillWidth boolean +---@field private headerDisabled boolean local sectionProto = {} ---@param kind BagKind @@ -116,6 +117,14 @@ function sectionProto:SetAlpha(alpha) self.frame:SetAlpha(alpha) end +function sectionProto:DisableHeader() + self.headerDisabled = true +end + +function sectionProto:EnableHeader() + self.headerDisabled = false +end + ---@param item Item|ItemRow ---@return boolean function sectionProto:HasItem(item) @@ -195,6 +204,7 @@ end ---@param f Section function sectionFrame:_DoReset(f) + f:EnableHeader() f:Wipe() end @@ -253,17 +263,26 @@ function sectionFrame:_DoCreate() title:SetPoint("TOPLEFT", s.frame, "TOPLEFT", 6, 0) title:SetPoint("TOPRIGHT", s.frame, "TOPRIGHT", -6, 0) title:SetScript("OnEnter", function() + if s.headerDisabled then return end sectionFrame.currentTooltip = s s:onTitleMouseEnter() end) title:SetScript("OnLeave", function() + if s.headerDisabled then return end sectionFrame.currentTooltip = nil GameTooltip:Hide() end) - title:SetScript("OnClick", function() onTitleClickOrDrop(s) end) - title:SetScript("OnReceiveDrag", function() onTitleClickOrDrop(s) end) + title:SetScript("OnClick", function() + if s.headerDisabled then return end + onTitleClickOrDrop(s) + end) + + title:SetScript("OnReceiveDrag", function() + if s.headerDisabled then return end + onTitleClickOrDrop(s) + end) s.title = title