Skip to content

Commit

Permalink
Improved the new category drop text -- items can now be clicked into …
Browse files Browse the repository at this point in the history
…a new category, added a new tooltip, and disabled the items tooltip drop zone.
  • Loading branch information
Cidan committed Apr 6, 2024
1 parent b5576f2 commit 3a9da1a
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
1 change: 1 addition & 0 deletions annotations.lua
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ local OptionsTable = {}
---@field frame Frame
---@field section Section
---@field parent AceGUIFrame
---@field label AceGUILabel
local AceItemList = {}

---@param values CustomCategoryFilter
Expand Down
14 changes: 14 additions & 0 deletions config/itemlist.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down
23 changes: 21 additions & 2 deletions frames/section.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -195,6 +204,7 @@ end

---@param f Section
function sectionFrame:_DoReset(f)
f:EnableHeader()
f:Wipe()
end

Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 3a9da1a

Please sign in to comment.