2026-11-21 12:10:42 -06:00
|
|
|
local _, P = ...
|
|
|
|
|
|
|
|
|
|
-- Notification space is reserved even when no toast is visible. Protected bars
|
|
|
|
|
-- never chase a popup during combat. Blizzard still owns every alert's content,
|
|
|
|
|
-- lifecycle, queue, click handler and bank transaction.
|
2026-11-21 16:24:58 -06:00
|
|
|
local gap = P.layoutPolicy.gap
|
2026-11-21 12:10:42 -06:00
|
|
|
local hudNames = {
|
|
|
|
|
"MainActionBar", "MultiBarBottomLeft", "MultiBarBottomRight", "MultiBar5",
|
|
|
|
|
"MultiBarLeft", "MultiBarRight", "MultiBar6", "MultiBar7", "BagsBar", "MicroMenuContainer",
|
|
|
|
|
"DamageMeter",
|
|
|
|
|
"BuffFrame", "DebuffFrame", "MirrorTimer1", "MirrorTimer2", "MirrorTimer3",
|
2026-11-21 16:24:58 -06:00
|
|
|
"ChatFrame1", "ChatFrame1EditBox", "ChatFrame1Tab", "MinimapCluster", "ObjectiveTrackerFrame", "PartyFrame", "CompactRaidFrameContainer",
|
2026-11-21 12:10:42 -06:00
|
|
|
"PlayerFrame", "PetFrame", "TargetFrame", "TargetFrameToT", "RuenTargetTargetTarget", "FocusFrame",
|
|
|
|
|
"StanceBar", "PetActionBar", "MultiCastActionBarFrame", "PossessActionBar",
|
|
|
|
|
"MainMenuBarVehicleLeaveButton", "PlayerCastingBarFrame", "RuenSwingTimers", "ExtraAbilityContainer",
|
|
|
|
|
"BossTargetFrameContainer", "ArenaEnemyFrames", "CompactArenaFrame",
|
|
|
|
|
"UIWidgetTopCenterContainerFrame", "UIWidgetBelowMinimapContainerFrame", "UIWidgetPowerBarContainerFrame",
|
|
|
|
|
"PlayerPowerBarAlt", "TotemFrame", "ClassNameplateBarRogueFrame", "ClassNameplateBarDruidFrame",
|
|
|
|
|
}
|
2026-11-21 16:24:58 -06:00
|
|
|
local blockMembers = P.controlFrameSet
|
|
|
|
|
local panels = P.layoutPolicy.panels
|
2026-11-21 12:10:42 -06:00
|
|
|
local hooked, queued, placing = {}, false, false
|
|
|
|
|
local place, edge, enabled, schedule
|
|
|
|
|
local alertHooks={}
|
|
|
|
|
|
|
|
|
|
local function rect(f, reserveHidden)
|
|
|
|
|
if not f then return end
|
|
|
|
|
if f.IsForbidden and f:IsForbidden() then return nil,true end
|
|
|
|
|
if not reserveHidden then
|
|
|
|
|
local shown=f:IsShown()
|
|
|
|
|
if issecretvalue and issecretvalue(shown) then return nil,true end
|
|
|
|
|
if not shown then return end
|
|
|
|
|
end
|
|
|
|
|
local l, r, b, t = edge(f,"GetLeft"), edge(f,"GetRight"), edge(f,"GetBottom"), edge(f,"GetTop")
|
|
|
|
|
if not l or not r or not b or not t then return nil,true end
|
|
|
|
|
if l and r and b and t and r>l and t>b then return {left=l,right=r,bottom=b,top=t,name=f.GetName and f:GetName()} end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local function overlaps(a,b,pad)
|
|
|
|
|
return a.left < b.right+pad and a.right > b.left-pad and a.bottom < b.top+pad and a.top > b.bottom-pad
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- Pure geometry: choose the nearest free rectangle, considering obstacle edges
|
|
|
|
|
-- rather than assuming that one fixed pixel offset works at every resolution.
|
|
|
|
|
function P.FindOverlayPosition(width,height,x,y,obstacles,screenWidth,screenHeight)
|
|
|
|
|
local maxX,maxY=screenWidth-gap-width,screenHeight-gap-height
|
|
|
|
|
if maxX<gap or maxY<gap then return end
|
|
|
|
|
local function clamp(v,a,b) return math.max(a,math.min(b,v)) end
|
|
|
|
|
x,y=clamp(x,gap,maxX),clamp(y,gap,maxY)
|
|
|
|
|
local xs,ys={x,gap,maxX},{y,gap,maxY}
|
|
|
|
|
local seenX,seenY={[x]=true,[gap]=true,[maxX]=true},{[y]=true,[gap]=true,[maxY]=true}
|
|
|
|
|
local function add(list,seen,value) if not seen[value] then seen[value]=true;list[#list+1]=value end end
|
|
|
|
|
for _,o in ipairs(obstacles) do
|
|
|
|
|
add(xs,seenX,clamp(o.right+gap,gap,maxX));add(xs,seenX,clamp(o.left-gap-width,gap,maxX))
|
|
|
|
|
add(ys,seenY,clamp(o.top+gap,gap,maxY));add(ys,seenY,clamp(o.bottom-gap-height,gap,maxY))
|
|
|
|
|
end
|
|
|
|
|
local best,score
|
|
|
|
|
for _,cx in ipairs(xs) do for _,cy in ipairs(ys) do
|
|
|
|
|
local d=(cx-x)^2+(cy-y)^2
|
|
|
|
|
if not score or d<score then
|
|
|
|
|
local candidate={left=cx,right=cx+width,bottom=cy,top=cy+height}
|
|
|
|
|
local free=true
|
|
|
|
|
for _,o in ipairs(obstacles) do if overlaps(candidate,o,gap-0.1) then free=false;break end end
|
|
|
|
|
if free then
|
|
|
|
|
if d==0 then return candidate end -- preferred position is already optimal
|
|
|
|
|
best,score=candidate,d
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end end
|
|
|
|
|
return best
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- Native attachments can extend well beyond their parent unit frame. Keep
|
|
|
|
|
-- their own secure layout; overlays must account for their visible footprint.
|
|
|
|
|
function P.AttachedHUDRegions()
|
|
|
|
|
local list={}
|
|
|
|
|
local function add(f,name)
|
|
|
|
|
local r=rect(f)
|
|
|
|
|
if r then r.name=name or r.name;list[#list+1]=r end
|
|
|
|
|
end
|
|
|
|
|
for _,name in ipairs({"TargetFrame","FocusFrame"}) do
|
|
|
|
|
local f=_G[name]
|
|
|
|
|
if f and f:IsShown() then
|
|
|
|
|
add(f.spellbar,name.." cast")
|
|
|
|
|
if name=="FocusFrame" then add(f.totFrame,"Focus target") end
|
|
|
|
|
if f.GetAuraContainer then
|
|
|
|
|
local aura=f:GetAuraContainer()
|
|
|
|
|
local r,restricted=rect(aura)
|
|
|
|
|
if restricted then
|
|
|
|
|
-- Reserve the public maximum footprint, never infer aura
|
|
|
|
|
-- counts from restricted values. 48 icons in constrained
|
|
|
|
|
-- five-icon rows plus native spacing fit in 264 units.
|
|
|
|
|
r=rect(f)
|
|
|
|
|
if r then
|
|
|
|
|
local height=264*f:GetEffectiveScale()/UIParent:GetEffectiveScale()
|
|
|
|
|
local below=f.buffsOnTop
|
|
|
|
|
below=not (issecretvalue and issecretvalue(below)) and below==false
|
|
|
|
|
if below then r.bottom=r.bottom-height else r.top=r.top+height end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
if r then r.name=name.." auras";list[#list+1]=r end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
if ComboFrame and ComboFrame:IsShown() then
|
|
|
|
|
for i,f in ipairs(ComboFrame.ComboPoints or {}) do add(f,"Combo point "..i) end
|
|
|
|
|
end
|
|
|
|
|
for i=11,12 do add(_G["RuenPetExtraButton"..i],"Pet extra "..i) end
|
|
|
|
|
return list
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function P.SocialNotificationSpace(frameEdge)
|
|
|
|
|
local function height(name,fallback)
|
|
|
|
|
local f=_G[name]
|
|
|
|
|
return f and math.max(fallback,f:GetHeight()*f:GetEffectiveScale()/UIParent:GetEffectiveScale()) or fallback
|
|
|
|
|
end
|
|
|
|
|
-- Quick Join expands horizontally; BN and time-limit notifications stack
|
|
|
|
|
-- above it. The shard-transfer notice and toast hover card need room too.
|
|
|
|
|
local base=(frameEdge(ChatFrame1,"GetTop") or 195)+27
|
|
|
|
|
local native=frameEdge(ChatAlertFrame,"GetBottom")
|
|
|
|
|
base=math.max(base,native or base)
|
|
|
|
|
local stack=height("QuickJoinToastButton",32)+height("BNToastFrame",63)+height("TimeAlertFrame",50)
|
|
|
|
|
return {left=0,right=math.max(340,(frameEdge(ChatFrame1,"GetLeft") or 20)+320),
|
|
|
|
|
bottom=base-5,top=base+math.max(160,stack+20),name="Social notifications"}
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- Reserve entire control blocks, including empty slots and gaps. Visibility
|
|
|
|
|
-- of individual buttons must never create a landing space for a bag or tooltip.
|
|
|
|
|
function P.ControlRegions()
|
|
|
|
|
local result={}
|
2026-11-21 16:24:58 -06:00
|
|
|
for _,group in ipairs(P.layoutPolicy.controls) do
|
2026-11-21 12:10:42 -06:00
|
|
|
local region
|
|
|
|
|
for _,name in ipairs(group) do
|
|
|
|
|
local r=rect(_G[name],true)
|
|
|
|
|
if r then
|
|
|
|
|
if not region then region=r;region.name=group.name
|
|
|
|
|
else
|
|
|
|
|
region.left=math.min(region.left,r.left);region.right=math.max(region.right,r.right)
|
|
|
|
|
region.bottom=math.min(region.bottom,r.bottom);region.top=math.max(region.top,r.top)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
if region then result[#result+1]=region end
|
|
|
|
|
end
|
|
|
|
|
return result
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function P.OverlayObstacles(includePanels)
|
|
|
|
|
local list=P.ControlRegions()
|
|
|
|
|
list[#list+1]=P.SocialNotificationSpace(edge)
|
|
|
|
|
for _,r in ipairs(P.classAssistReserved or {}) do list[#list+1]=r end
|
|
|
|
|
-- The three complete control rectangles already include their members.
|
|
|
|
|
-- Duplicating every button bar makes the placement search much more costly.
|
|
|
|
|
for _,name in ipairs(hudNames) do
|
|
|
|
|
if not blockMembers[name] then
|
|
|
|
|
local r=rect(_G[name],name=="PlayerCastingBarFrame" or name=="RuenSwingTimers")
|
|
|
|
|
if r then
|
|
|
|
|
if name=="PetActionBar" and P.PetExtraGeometry then r.right=r.right+select(3,P.PetExtraGeometry()) end
|
|
|
|
|
list[#list+1]=r
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
for _,r in ipairs(P.AttachedHUDRegions()) do list[#list+1]=r end
|
|
|
|
|
if DamageMeter and DamageMeter:IsShown() then
|
|
|
|
|
for i=2,3 do local r=rect(_G["DamageMeterSessionWindow"..i]);if r then list[#list+1]=r end end
|
|
|
|
|
end
|
|
|
|
|
if includePanels then
|
|
|
|
|
for _,name in ipairs(panels) do local r=rect(_G[name]);if r then list[#list+1]=r end end
|
|
|
|
|
end
|
|
|
|
|
return list
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local function collectAlerts()
|
|
|
|
|
local result,seen={},{}
|
|
|
|
|
-- Roll cards can wrap into a second column instead of reserving one tall
|
|
|
|
|
-- mostly-empty container over the combat HUD. Native roll actions stay intact.
|
|
|
|
|
local rolls=GroupLootContainer and GroupLootContainer.rollFrames
|
|
|
|
|
if rolls then
|
|
|
|
|
seen[GroupLootContainer]=true
|
|
|
|
|
for _,f in pairs(rolls) do
|
|
|
|
|
if f:IsShown() then seen[f]=true;result[#result+1]=f end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
local function add(f)
|
|
|
|
|
if f and not seen[f] and f:IsShown() then seen[f]=true;result[#result+1]=f end
|
|
|
|
|
end
|
|
|
|
|
add(GroupLootContainer);add(TalkingHeadFrame)
|
|
|
|
|
for _,system in ipairs(AlertFrame and AlertFrame.alertFrameSubSystems or {}) do
|
|
|
|
|
add(system.anchorFrame)
|
|
|
|
|
if system.alertFramePool and system.alertFramePool.EnumerateActive then
|
|
|
|
|
for f in system.alertFramePool:EnumerateActive() do add(f) end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return result
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local function alertPadding(f)
|
|
|
|
|
if f==GroupLootContainer then return 22 end
|
|
|
|
|
for _,roll in pairs(GroupLootContainer and GroupLootContainer.rollFrames or {}) do
|
|
|
|
|
if f==roll then return 6 end
|
|
|
|
|
end
|
|
|
|
|
return 0
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local alertScales=setmetatable({},{__mode="k"})
|
|
|
|
|
local function fitFrame(f,obstacles,x,y,padding)
|
|
|
|
|
if not f or not f:IsShown() or (f.IsProtected and f:IsProtected() and InCombatLockdown()) then return false end
|
|
|
|
|
local current=f:GetScale()
|
|
|
|
|
local saved=alertScales[f]
|
|
|
|
|
if not saved or math.abs(current-saved.applied)>.001 then saved={base=current,applied=current};alertScales[f]=saved end
|
|
|
|
|
local scale=f:GetEffectiveScale()/UIParent:GetEffectiveScale()*saved.base/current
|
|
|
|
|
padding=padding or 0
|
|
|
|
|
local w,h=f:GetWidth()*scale+padding*2,f:GetHeight()*scale
|
|
|
|
|
if w<=0 or h<=0 then return false end
|
|
|
|
|
local target,fit
|
|
|
|
|
for step=0,3 do
|
|
|
|
|
fit=1-step*.05
|
|
|
|
|
target=P.FindOverlayPosition(w*fit,h*fit,x-padding,y,obstacles,UIParent:GetWidth(),UIParent:GetHeight())
|
|
|
|
|
if target then break end
|
|
|
|
|
end
|
|
|
|
|
if not target then return false end
|
|
|
|
|
local nextScale=saved.base*fit
|
|
|
|
|
if math.abs(current-nextScale)>.001 then (f.SetScaleBase or f.SetScale)(f,nextScale) end
|
|
|
|
|
saved.applied=nextScale
|
|
|
|
|
local old=rect(f)
|
|
|
|
|
if not old or math.abs(old.left-target.left-padding*fit)>.5 or math.abs(old.bottom-target.bottom)>.5 then
|
|
|
|
|
place(f,"BOTTOMLEFT",UIParent,"BOTTOMLEFT",target.left+padding*fit,target.bottom)
|
|
|
|
|
end
|
|
|
|
|
target.name=f.GetName and f:GetName() or "Alert"
|
|
|
|
|
obstacles[#obstacles+1]=target
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function P.PositionOverlayFrames()
|
|
|
|
|
if placing or not enabled or not enabled() then return end
|
|
|
|
|
placing=true
|
|
|
|
|
local obstacles=P.OverlayObstacles(true)
|
|
|
|
|
local bag=rect(ContainerFrameCombinedBags);if bag then obstacles[#obstacles+1]=bag end
|
|
|
|
|
for _,name in ipairs({"GameTooltip","ShoppingTooltip1","ShoppingTooltip2"}) do
|
|
|
|
|
local r=rect(_G[name]);if r then obstacles[#obstacles+1]=r end
|
|
|
|
|
end
|
|
|
|
|
P.overlayUnplaced={}
|
|
|
|
|
P.overlayOverChat={}
|
|
|
|
|
P.overlayOverOptional={}
|
|
|
|
|
local alerts=collectAlerts()
|
|
|
|
|
-- Place wide/tall alerts first so small loot notices do not fragment the
|
|
|
|
|
-- remaining space. Stable names break ties between equal-size alerts.
|
|
|
|
|
table.sort(alerts,function(a,b)
|
|
|
|
|
local sa,sb=a:GetEffectiveScale(),b:GetEffectiveScale()
|
|
|
|
|
local aa,ab=a:GetWidth()*a:GetHeight()*sa*sa,b:GetWidth()*b:GetHeight()*sb*sb
|
|
|
|
|
if aa==ab then return (a:GetName() or tostring(a))<(b:GetName() or tostring(b)) end
|
|
|
|
|
return aa>ab
|
|
|
|
|
end)
|
|
|
|
|
for _,f in ipairs(alerts) do
|
|
|
|
|
if schedule and not alertHooks[f] then
|
|
|
|
|
alertHooks[f]=true
|
|
|
|
|
f:HookScript("OnHide",schedule)
|
|
|
|
|
f:HookScript("OnSizeChanged",schedule)
|
|
|
|
|
end
|
|
|
|
|
local scale=f:GetEffectiveScale()/UIParent:GetEffectiveScale()
|
|
|
|
|
-- Use the open upper field, clear of the combat HUD and minimap.
|
|
|
|
|
-- The left bars occupy the middle of the screen, not this upper row.
|
|
|
|
|
-- Let collision checks account for their actual height instead of
|
|
|
|
|
-- excluding a full-height column; four roll cards can then wrap cleanly.
|
|
|
|
|
local raidRight=CompactRaidFrameContainer and CompactRaidFrameContainer:IsShown()
|
|
|
|
|
and edge(CompactRaidFrameContainer,"GetRight") or 20
|
|
|
|
|
local x=math.max(20,raidRight or 20)+gap
|
|
|
|
|
local y=UIParent:GetHeight()-f:GetHeight()*scale-gap
|
|
|
|
|
if not fitFrame(f,obstacles,x,y,alertPadding(f)) then
|
|
|
|
|
-- Short-lived native notices may use chat's text area in a crowded
|
|
|
|
|
-- raid. They still avoid social toasts, controls and other notices.
|
|
|
|
|
local fallback={}
|
|
|
|
|
for _,r in ipairs(obstacles) do if r.name~="ChatFrame1" then fallback[#fallback+1]=r end end
|
|
|
|
|
if fitFrame(f,fallback,x,y,alertPadding(f)) then
|
|
|
|
|
P.overlayOverChat[f]=true
|
|
|
|
|
obstacles[#obstacles+1]=fallback[#fallback]
|
|
|
|
|
else
|
|
|
|
|
-- Interactive loot decisions outrank optional duplicate cooldown
|
|
|
|
|
-- displays/meters. Health, casts, actions and social remain clear.
|
|
|
|
|
local minimal={}
|
|
|
|
|
for _,r in ipairs(fallback) do
|
|
|
|
|
if not (r.name or ""):find("CooldownViewer") and not (r.name or ""):match("^DamageMeter") then minimal[#minimal+1]=r end
|
|
|
|
|
end
|
|
|
|
|
if fitFrame(f,minimal,x,y,alertPadding(f)) then
|
|
|
|
|
P.overlayOverChat[f]=true;P.overlayOverOptional[f]=true
|
|
|
|
|
obstacles[#obstacles+1]=minimal[#minimal]
|
|
|
|
|
else
|
|
|
|
|
P.overlayUnplaced[#P.overlayUnplaced+1]=f.GetName and f:GetName() or "Alert"
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
placing=false
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local tooltipPositions=setmetatable({},{__mode="k"})
|
|
|
|
|
|
2026-11-22 11:46:00 -06:00
|
|
|
function P.ResetOverlayLayoutState()
|
|
|
|
|
tooltipPositions = setmetatable({},{__mode="k"})
|
|
|
|
|
for _, state in pairs(alertScales) do state.base=1 end
|
|
|
|
|
P.tooltipUnplaced, P.tooltipOverInventory, P.tooltipOverSocial = nil, nil, nil
|
|
|
|
|
P.overlayRevision = (P.overlayRevision or 0) + 1
|
|
|
|
|
end
|
|
|
|
|
|
2026-11-21 12:10:42 -06:00
|
|
|
function P.ResetTooltipPosition(tooltip)
|
|
|
|
|
tooltipPositions[tooltip]=nil
|
|
|
|
|
P.tooltipUnplaced=nil
|
|
|
|
|
P.tooltipOverInventory=nil
|
|
|
|
|
P.tooltipOverSocial=nil
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function P.PositionTooltip(tooltip,settled)
|
|
|
|
|
if not edge or not enabled() then return false end
|
|
|
|
|
-- SetPoint alone does not release the tooltip engine's automatic owner-
|
|
|
|
|
-- relative anchor. Bag refreshes reinstate ANCHOR_LEFT/RIGHT repeatedly;
|
|
|
|
|
-- ANCHOR_NONE gives this tooltip one positioning authority without the
|
|
|
|
|
-- hide/content-reset side effects of calling SetOwner again.
|
|
|
|
|
if tooltip.GetAnchorType and tooltip.SetAnchorType and tooltip:GetAnchorType()~="ANCHOR_NONE" then
|
|
|
|
|
tooltip:SetAnchorType("ANCHOR_NONE")
|
|
|
|
|
end
|
|
|
|
|
local screenW,screenH=UIParent:GetWidth(),UIParent:GetHeight()
|
|
|
|
|
local uiScale=UIParent:GetEffectiveScale()
|
|
|
|
|
local scale=tooltip:GetEffectiveScale()/uiScale
|
|
|
|
|
local owner=tooltip:GetOwner()
|
|
|
|
|
local pos=tooltipPositions[tooltip]
|
|
|
|
|
if not pos or pos.owner~=owner or pos.screenW~=screenW or pos.screenH~=screenH
|
|
|
|
|
or pos.uiScale~=uiScale or pos.scale~=scale then
|
|
|
|
|
pos={owner=owner,screenW=screenW,screenH=screenH,uiScale=uiScale,scale=scale,
|
|
|
|
|
right=edge(P.UtilityTop(),"GetRight") or screenW-22,
|
|
|
|
|
bottom=(edge(P.UtilityTop(),"GetTop") or 250)+18,width=0,height=0,extraWidth=0}
|
|
|
|
|
tooltipPositions[tooltip]=pos
|
|
|
|
|
end
|
|
|
|
|
local comparisons={}
|
|
|
|
|
-- Fit comparison cards as one block; a correctly placed primary tooltip
|
|
|
|
|
-- alone does not protect the bars from its secondary equipment tooltips.
|
|
|
|
|
local extraWidth,extraHeight=0,0
|
|
|
|
|
if tooltip==GameTooltip and settled then
|
|
|
|
|
for _,name in ipairs({"ShoppingTooltip1","ShoppingTooltip2"}) do
|
|
|
|
|
local f=_G[name]
|
|
|
|
|
if f and f:IsShown() then
|
|
|
|
|
local ratio=f:GetEffectiveScale()/uiScale
|
|
|
|
|
local w,h=f:GetWidth()*ratio,f:GetHeight()*ratio
|
|
|
|
|
if w>0 and h>0 then
|
|
|
|
|
comparisons[#comparisons+1]={frame=f,width=w,height=h}
|
|
|
|
|
extraWidth=extraWidth+w+gap;extraHeight=math.max(extraHeight,h)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
-- DefaultAnchor runs before text is rebuilt. Only measure settled sizes and
|
|
|
|
|
-- retain the high-water footprint until the mouse leaves this owner.
|
|
|
|
|
if settled and tooltip:IsShown() then
|
|
|
|
|
local w,h=tooltip:GetWidth()*scale,tooltip:GetHeight()*scale
|
|
|
|
|
local needs=not pos.fitted or w>pos.width+1 or h>pos.height+1
|
|
|
|
|
or extraWidth>pos.extraWidth+1 or extraHeight>pos.height+1
|
|
|
|
|
or pos.revision~=(P.overlayRevision or 0)
|
|
|
|
|
if w>0 and h>0 and needs then
|
|
|
|
|
w,h=math.max(w,pos.width),math.max(h,pos.height,extraHeight)
|
|
|
|
|
extraWidth=math.max(extraWidth,pos.extraWidth)
|
|
|
|
|
local totalWidth=w+extraWidth
|
|
|
|
|
local obstacles=P.OverlayObstacles(true)
|
|
|
|
|
local bag=rect(ContainerFrameCombinedBags)
|
|
|
|
|
local withoutBag=CopyTable(obstacles)
|
|
|
|
|
-- In a packed small viewport, comparison cards may cover other bag
|
|
|
|
|
-- contents, but must keep the hovered item and all controls clear.
|
|
|
|
|
local hover=rect(owner);if hover then withoutBag[#withoutBag+1]=hover end
|
|
|
|
|
if bag then obstacles[#obstacles+1]=bag end
|
|
|
|
|
for _,f in ipairs(collectAlerts()) do local r=rect(f);if r then obstacles[#obstacles+1]=r end end
|
|
|
|
|
local candidate={left=pos.right-w,right=pos.right+extraWidth,bottom=pos.bottom,top=pos.bottom+h}
|
|
|
|
|
local free=candidate.left>=gap and candidate.right<=screenW-gap
|
|
|
|
|
and candidate.bottom>=gap and candidate.top<=screenH-gap
|
|
|
|
|
for _,o in ipairs(obstacles) do if overlaps(candidate,o,gap-0.1) then free=false;break end end
|
|
|
|
|
P.tooltipOverInventory=nil
|
|
|
|
|
P.tooltipOverSocial=nil
|
|
|
|
|
if not free then
|
|
|
|
|
local target=P.FindOverlayPosition(totalWidth,h,candidate.left,pos.bottom,obstacles,screenW,screenH)
|
|
|
|
|
if not target and bag and extraWidth>0 then
|
|
|
|
|
target=P.FindOverlayPosition(totalWidth,h,candidate.left,pos.bottom,withoutBag,screenW,screenH)
|
|
|
|
|
P.tooltipOverInventory=target and true or nil
|
|
|
|
|
end
|
|
|
|
|
if not target then
|
|
|
|
|
-- A full raid plus a long tooltip can saturate a laptop
|
|
|
|
|
-- viewport. Temporarily cover chat/notification space only
|
|
|
|
|
-- after proving no fully clear position exists. Never cover
|
|
|
|
|
-- controls, health/cast bars, objectives or the hovered item.
|
|
|
|
|
local fallback={}
|
|
|
|
|
for _,o in ipairs(obstacles) do
|
|
|
|
|
if o.name~="ChatFrame1" and o.name~="Social notifications" then fallback[#fallback+1]=o end
|
|
|
|
|
end
|
|
|
|
|
if hover then fallback[#fallback+1]=hover end
|
|
|
|
|
target=P.FindOverlayPosition(totalWidth,h,candidate.left,pos.bottom,fallback,screenW,screenH)
|
|
|
|
|
P.tooltipOverSocial=target and true or nil
|
|
|
|
|
end
|
|
|
|
|
if target then pos.right,pos.bottom=target.left+w,target.bottom;free=true end
|
|
|
|
|
end
|
|
|
|
|
P.tooltipUnplaced=not free
|
|
|
|
|
pos.width,pos.height,pos.extraWidth,pos.fitted=w,h,extraWidth,true
|
|
|
|
|
pos.revision=P.overlayRevision or 0
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
local point,relative,relativePoint,x,y
|
|
|
|
|
if tooltip.GetPoint then point,relative,relativePoint,x,y=tooltip:GetPoint(1) end
|
|
|
|
|
if point~="BOTTOMRIGHT" or relative~=UIParent or relativePoint~="BOTTOMLEFT"
|
|
|
|
|
or not x or not y or math.abs(x-pos.right/scale)>.01 or math.abs(y-pos.bottom/scale)>.01
|
|
|
|
|
or (tooltip.GetNumPoints and tooltip:GetNumPoints()~=1) then
|
|
|
|
|
place(tooltip,"BOTTOMRIGHT",UIParent,"BOTTOMLEFT",pos.right,pos.bottom)
|
|
|
|
|
end
|
|
|
|
|
local left=pos.right+gap
|
|
|
|
|
for _,card in ipairs(comparisons) do
|
|
|
|
|
if card.frame.GetAnchorType and card.frame.SetAnchorType and card.frame:GetAnchorType()~="ANCHOR_NONE" then
|
|
|
|
|
card.frame:SetAnchorType("ANCHOR_NONE")
|
|
|
|
|
end
|
|
|
|
|
local r=rect(card.frame)
|
|
|
|
|
if not r or math.abs(r.left-left)>.5 or math.abs(r.bottom-pos.bottom)>.5 then
|
|
|
|
|
place(card.frame,"BOTTOMLEFT",UIParent,"BOTTOMLEFT",left,pos.bottom)
|
|
|
|
|
end
|
|
|
|
|
left=left+card.width+gap
|
|
|
|
|
end
|
|
|
|
|
return not P.tooltipUnplaced
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function P.FindBagPosition(width,height,x,y)
|
|
|
|
|
if not edge then return end
|
|
|
|
|
local obstacles=P.OverlayObstacles(true)
|
|
|
|
|
P.bagOverHUD=nil
|
|
|
|
|
local screenW,screenH=UIParent:GetWidth(),UIParent:GetHeight()
|
|
|
|
|
-- Prefer full readability; reduce only if the complete inventory does not
|
|
|
|
|
-- fit. Never fall back to an anchor sitting on top of utility buttons.
|
|
|
|
|
for step=0,10 do
|
|
|
|
|
local scale=1-step*.035
|
|
|
|
|
local target=P.FindOverlayPosition(width*scale,height*scale,x,y,obstacles,screenW,screenH)
|
|
|
|
|
if target then return target,scale end
|
|
|
|
|
end
|
|
|
|
|
-- An unusually tall inventory is a modal panel. Keep it on screen and
|
|
|
|
|
-- preserve every action/chat/quest control; allow temporary HUD coverage
|
|
|
|
|
-- only after the fully clear placements are exhausted. Report this fallback.
|
|
|
|
|
local essential=P.ControlRegions()
|
|
|
|
|
for _,o in ipairs(obstacles) do
|
|
|
|
|
if o.name=="ChatFrame1" or o.name=="Social notifications" or o.name=="ObjectiveTrackerFrame"
|
|
|
|
|
or o.name=="MinimapCluster" then essential[#essential+1]=o end
|
|
|
|
|
end
|
|
|
|
|
for _,name in ipairs(panels) do local r=rect(_G[name]);if r then essential[#essential+1]=r end end
|
|
|
|
|
for step=0,10 do
|
|
|
|
|
local scale=1-step*.035
|
|
|
|
|
local target=P.FindOverlayPosition(width*scale,height*scale,x,y,essential,screenW,screenH)
|
|
|
|
|
if target then P.bagOverHUD=true;return target,scale end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function P.OverlayAudit()
|
|
|
|
|
local issues={}
|
|
|
|
|
if not edge then return issues end
|
|
|
|
|
for _,issue in ipairs(P.groupLayoutIssues or {}) do issues[#issues+1]=issue end
|
|
|
|
|
for _,name in ipairs(RuenUICharacter.classAssistUnplaced or {}) do
|
|
|
|
|
issues[#issues+1]=name.." has no free space"
|
|
|
|
|
end
|
|
|
|
|
if RuenUICharacter.classAssistError then issues[#issues+1]="Cooldown setup: "..RuenUICharacter.classAssistError end
|
|
|
|
|
local social=P.SocialNotificationSpace(edge)
|
|
|
|
|
for _,name in ipairs({"MultiBar6","MultiBar7","PartyFrame","CompactRaidFrameContainer"}) do
|
|
|
|
|
local r=rect(_G[name]);if r and overlaps(r,social,0) then issues[#issues+1]=name.."/social notifications" end
|
|
|
|
|
end
|
|
|
|
|
local controls=P.ControlRegions()
|
|
|
|
|
local chat=rect(ChatFrame1)
|
|
|
|
|
if chat then
|
|
|
|
|
for _,r in ipairs(controls) do
|
|
|
|
|
if overlaps(chat,r,0) then issues[#issues+1]="ChatFrame1/"..r.name end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
local obstacles=P.OverlayObstacles(false)
|
|
|
|
|
local bag=rect(ContainerFrameCombinedBags)
|
|
|
|
|
if P.bagUnplaced then issues[#issues+1]="Inventory has no clear space at readable scale" end
|
|
|
|
|
if P.tooltipUnplaced then issues[#issues+1]="Tooltip group has no clear space" end
|
|
|
|
|
if bag then
|
|
|
|
|
for _,o in ipairs(obstacles) do
|
|
|
|
|
if overlaps(bag,o,0) then issues[#issues+1]="ContainerFrameCombinedBags/"..(o.name or "HUD") end
|
|
|
|
|
end
|
|
|
|
|
obstacles[#obstacles+1]=bag
|
|
|
|
|
end
|
|
|
|
|
for _,name in ipairs({"GameTooltip","ShoppingTooltip1","ShoppingTooltip2"}) do
|
|
|
|
|
local t=rect(_G[name])
|
|
|
|
|
if t then
|
|
|
|
|
for _,o in ipairs(obstacles) do
|
|
|
|
|
if not (P.tooltipOverInventory and o.name=="ContainerFrameCombinedBags")
|
|
|
|
|
and not (P.tooltipOverSocial and (o.name=="ChatFrame1" or o.name=="Social notifications")) and overlaps(t,o,0) then
|
|
|
|
|
issues[#issues+1]=name.."/"..(o.name or "HUD")
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
for _,name in ipairs(P.overlayUnplaced or {}) do issues[#issues+1]=name.." has no free space" end
|
|
|
|
|
for _,f in ipairs(collectAlerts()) do
|
|
|
|
|
local r=rect(f)
|
|
|
|
|
if r then
|
|
|
|
|
if r.left<0 or r.bottom<0 or r.right>UIParent:GetWidth()+1 or r.top>UIParent:GetHeight()+1 then
|
|
|
|
|
issues[#issues+1]=(r.name or "Alert").." off screen"
|
|
|
|
|
end
|
|
|
|
|
for _,o in ipairs(obstacles) do
|
|
|
|
|
if not (P.overlayOverChat and P.overlayOverChat[f] and o.name=="ChatFrame1")
|
|
|
|
|
and not (P.overlayOverOptional and P.overlayOverOptional[f] and ((o.name or ""):find("CooldownViewer") or (o.name or ""):match("^DamageMeter"))) and overlaps(r,o,0) then
|
|
|
|
|
issues[#issues+1]=(r.name or "Alert").."/"..(o.name or "HUD")
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
obstacles[#obstacles+1]=r
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return issues
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function P.InitializeOverlayLayout(placeFrame,frameEdge,owns)
|
|
|
|
|
place,edge,enabled=placeFrame,frameEdge,owns
|
|
|
|
|
if P.overlayListener then return end
|
|
|
|
|
local listener=CreateFrame("Frame");P.overlayListener=listener
|
|
|
|
|
local function queue()
|
|
|
|
|
if placing or queued then return end
|
|
|
|
|
queued=true
|
|
|
|
|
C_Timer.After(0,function() queued=false;P.PositionOverlayFrames() end)
|
|
|
|
|
end
|
|
|
|
|
schedule=queue
|
|
|
|
|
local function watch()
|
2026-11-21 16:24:58 -06:00
|
|
|
for _,name in ipairs({"AlertFrame","GroupLootContainer","TalkingHeadFrame","ChatFrame1EditBox","ChatFrame1Tab"}) do
|
2026-11-21 12:10:42 -06:00
|
|
|
local f=_G[name]
|
|
|
|
|
if f and not hooked[f] then
|
|
|
|
|
hooked[f]=true
|
|
|
|
|
f:HookScript("OnShow",queue);f:HookScript("OnHide",queue);f:HookScript("OnSizeChanged",queue)
|
|
|
|
|
hooksecurefunc(f,"SetPoint",queue)
|
|
|
|
|
if f.UpdateAnchors then hooksecurefunc(f,"UpdateAnchors",queue) end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
for _,event in ipairs({"ADDON_LOADED","DISPLAY_SIZE_CHANGED","UI_SCALE_CHANGED","PLAYER_REGEN_ENABLED"}) do listener:RegisterEvent(event) end
|
|
|
|
|
listener:SetScript("OnEvent",function() watch();queue() end)
|
|
|
|
|
if GroupLootContainer_Update then hooksecurefunc("GroupLootContainer_Update",queue) end
|
|
|
|
|
watch();queue()
|
|
|
|
|
end
|