Add mover, drag-disable, and reset-position filter for LayerPickerFrame

Adds the button to ElvUI's anchor/mover system, disables native dragging so it doesn't conflict, filters the now-broken "Reset Position" dropdown entry (scoped to this menu only), and raises the mover overlay above the minimap so it's grabbable in config mode.
This commit is contained in:
2026-07-13 15:42:37 +02:00
parent 619c913d1e
commit 64a310bc80
+59 -1
View File
@@ -3,6 +3,59 @@ local CoA = E:GetModule("CoA")
local BUTTON_NAME = "LayerPickerFrame"
do
local orig_AddButton = UIDropDownMenu_AddButton
UIDropDownMenu_AddButton = function(info, level)
if info and info.text == "Reset Position" and UIDROPDOWNMENU_INIT_MENU == LayerPickerFrameDropDown then
return
end
return orig_AddButton(info, level)
end
end
local function DisableDrag(button)
if button.CoADragDisabled then return end
button.CoADragDisabled = true
button:SetScript("OnDragStart", nil)
button:SetScript("OnDragStop", nil)
end
local function SetupMover(button)
if CoA.layerPickerMoverCreated then return end
local width, height = button:GetSize()
if width == 0 or height == 0 then return end
local left, bottom = button:GetLeft(), button:GetBottom()
if not left or not bottom then return end
CoA.layerPickerMoverCreated = true
local holder = CreateFrame("Frame", "CoA_LayerPickerHolder", E.UIParent)
holder:Size(width, height)
holder:Point("BOTTOMLEFT", E.UIParent, "BOTTOMLEFT", left, bottom)
E:CreateMover(holder, "CoA_LayerPickerMover", "Instance", nil, nil, nil, nil, nil, "CoA,skin,instance")
holder:SetAllPoints(_G["CoA_LayerPickerMover"])
_G["CoA_LayerPickerMover"]:SetFrameStrata("FULLSCREEN")
local function Anchor()
button:ClearAllPoints()
button:SetPoint("CENTER", holder, "CENTER")
end
if InCombatLockdown() then
CoA:RegisterEvent("PLAYER_REGEN_ENABLED", function()
Anchor()
CoA:UnregisterEvent("PLAYER_REGEN_ENABLED")
end)
else
Anchor()
end
end
local function SkinButton(button)
if button.CoASkinned then return end
button.CoASkinned = true
@@ -22,9 +75,14 @@ end
local function TryHook()
local button = _G[BUTTON_NAME]
if button and E.private.CoA.instance then
if button then
DisableDrag(button)
SetupMover(button)
if E.private.CoA.instance then
SkinButton(button)
end
end
return button ~= nil
end