Skip to content

Commit eed5b48

Browse files
committed
Add support for anchoring to TSM mail frame.
1 parent 7093ae9 commit eed5b48

4 files changed

Lines changed: 54 additions & 9 deletions

File tree

.pkgmeta

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ externals:
1818
Libs/AceGUI-3.0-SharedMediaWidgets: https://repos.wowace.com/wow/ace-gui-3-0-shared-media-widgets/trunk/AceGUI-3.0-SharedMediaWidgets
1919
Libs/LibSharedMedia-3.0: https://repos.wowace.com/wow/libsharedmedia-3-0/trunk/LibSharedMedia-3.0
2020
Libs/LibDropdown-1.0: https://github.com/neotron/WoW-LibDropDown.git
21+
Libs/LibMagicUtil-1.0: https://github.com/neotron/WoW-libMagicUtil.git

BulkMail2Inbox.toc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
## X-eMail: neotron@gmail.com
1414
## X-Website: http://wowace.com/wiki/BulkMail2Inbox
1515
## SavedVariables: BulkMail2InboxDB, BulkMail3InboxDB
16-
## OptionalDeps: Ace3, LibSharedMedia-3.0, AceGUI-3.0-SharedMediaWidgets, LibQTip-1.0, LibAbacus-3.0, LibDataBroker-1.1, LibDropdown-1.0, BulkMail2
16+
## OptionalDeps: Ace3, LibSharedMedia-3.0, AceGUI-3.0-SharedMediaWidgets, LibQTip-1.0, LibAbacus-3.0, LibDataBroker-1.1, LibDropdown-1.0, LibMagicUtil-1.0, BulkMail2
1717
## LoadManagers: SupplyAndDemand, ForkliftGnome, AddonLoader
1818
## X-S&D-AtMail: true
1919
## X-LoadOn-Mailbox: true

BulkMailInbox.lua

Lines changed: 51 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ local QTIP = LibStub("LibQTip-1.0")
1616
local AC = LibStub("AceConfig-3.0")
1717
local ACD = LibStub("AceConfigDialog-3.0")
1818
local DB = LibStub("AceDB-3.0")
19-
local LDB = LibStub("LibDataBroker-1.1", true)
20-
local LD = LibStub("LibDropdown-1.0")
19+
local LDB = LibStub("LibDataBroker-1.1", true)
20+
local LD = LibStub("LibDropdown-1.0")
21+
local MagicUtil = LibStub("LibMagicUtil-1.0")
2122

2223

2324
local _G = _G
@@ -373,6 +374,33 @@ function mod:MAIL_SHOW()
373374
end
374375

375376
self:ShowInboxGUI()
377+
-- Watch for mail frame changes (e.g. TSM toggling between its UI and the default)
378+
mod._lastMailFrame = nil
379+
if not mod._mailFrameWatcher then
380+
mod._mailFrameWatcher = self:ScheduleRepeatingTimer("CheckMailFrameChanged", 0.2)
381+
end
382+
end
383+
384+
function mod:CheckMailFrameChanged()
385+
local mailFrame, isTSM = MagicUtil:GetMailFrame()
386+
if mailFrame ~= mod._lastMailFrame then
387+
mod._lastMailFrame = mailFrame
388+
if isTSM then
389+
-- TSM active: always show inbox alongside send queue
390+
self:ShowInboxGUI()
391+
-- Tell BulkMail2 to reposition send queue now that inbox is shown
392+
if BulkMail and BulkMail.sendQueueTooltip then
393+
BulkMail:ShowSendQueueGUI()
394+
end
395+
else
396+
-- Switching to normal UI: show inbox only if on Inbox tab
397+
if SendMailFrame and SendMailFrame:IsShown() then
398+
self:HideInboxGUI()
399+
else
400+
self:ShowInboxGUI()
401+
end
402+
end
403+
end
376404
end
377405

378406
function mod:PLAYER_INTERACTION_MANAGER_FRAME_HIDE(_, type)
@@ -383,6 +411,11 @@ end
383411

384412
function mod:MAIL_CLOSED()
385413
takeAllInProgress = false
414+
if mod._mailFrameWatcher then
415+
self:CancelTimer(mod._mailFrameWatcher)
416+
mod._mailFrameWatcher = nil
417+
end
418+
mod._lastMailFrame = nil
386419
self:HideInboxGUI()
387420
GameTooltip:Hide()
388421
self:UnhookAll()
@@ -1017,12 +1050,22 @@ function mod:AdjustSizeAndPosition(tooltip)
10171050

10181051
-- Only adjust point if user hasn't moved manually. This puts it lined up with the mail window
10191052
-- or in the middle of the screen it's too large to fit from the top of the mail window and down
1020-
if not tooltip.moved and MailFrame ~= nil and MailFrame:GetTop() ~= nil then
1021-
local tipHeight = tooltip:GetHeight() * scale
1022-
tooltip:ClearAllPoints()
1023-
-- Calculate a good offset
1024-
local offx = math.min((uiHeight - tipHeight - barHeight)/2, uiHeight + 12 - MailFrame:GetTop()*MailFrame:GetScale())+barHeight
1025-
tooltip:SetPoint("TOPLEFT", UIParent, "TOPLEFT", MailFrame:GetRight()*MailFrame:GetScale()/scale, -offx/scale)
1053+
mod:RepositionTooltip(tooltip, scale, barHeight)
1054+
end
1055+
1056+
function mod:RepositionTooltip(tooltip, scale, barHeight)
1057+
if not tooltip or tooltip.moved then return end
1058+
local mailFrame, isTSM = MagicUtil:GetMailFrame()
1059+
-- Offset down by toolbar height so the toolbar (anchored above the tooltip)
1060+
-- aligns with the top of the mail frame
1061+
local toolbarOffset = mod._toolbar and mod._toolbar:GetHeight() or 0
1062+
tooltip:ClearAllPoints()
1063+
if isTSM then
1064+
tooltip:SetPoint("TOPLEFT", mailFrame, "TOPRIGHT", 5, -toolbarOffset)
1065+
elseif MailFrame and MailFrame:GetRight() then
1066+
tooltip:SetPoint("TOPLEFT", MailFrame, "TOPRIGHT", 5, -toolbarOffset)
1067+
else
1068+
tooltip:SetPoint("TOP", UIParent, "TOP", 0, -toolbarOffset)
10261069
end
10271070
end
10281071

embeds.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@
1818
<Script file="Libs\LibDataBroker-1.1\LibDataBroker-1.1.lua"/>
1919
<Include file="Libs\LibAbacus-3.0\lib.xml"/>
2020
<Include file="Libs\LibQTip-1.0\lib.xml"/>
21+
<Include file="Libs\LibMagicUtil-1.0\LibMagicUtil-1.0\lib.xml"/>
2122
</Ui>

0 commit comments

Comments
 (0)