Skip to content
Permalink
Browse files

Updated anchors for UIWidget.

  • Loading branch information
Wetxius committed Aug 12, 2019
1 parent e5dc545 commit 73850c78f8b0b3cd4b22fdd219a9ca24bda3e73d
Showing with 25 additions and 20 deletions.
  1. +25 −20 ShestakUI/Modules/Blizzard/UIWidget.lua
@@ -3,34 +3,39 @@ local T, C, L, _ = unpack(select(2, ...))
----------------------------------------------------------------------------------------
-- UIWidget frame
----------------------------------------------------------------------------------------
local top = _G["UIWidgetTopCenterContainerFrame"]
top:ClearAllPoints()
top:SetPoint(unpack(C.position.uiwidget))
local top, below = _G["UIWidgetTopCenterContainerFrame"], _G["UIWidgetBelowMinimapContainerFrame"]
local topAnchor = CreateFrame("Frame", "UIWidgetTopAnchor", UIParent)
topAnchor:SetSize(200, 30)
topAnchor:SetPoint(unpack(C.position.uiwidget))
_G["UIWidgetTopCenterContainerFrame"]:ClearAllPoints()
_G["UIWidgetTopCenterContainerFrame"]:SetPoint("CENTER", topAnchor)

local below = _G["UIWidgetBelowMinimapContainerFrame"]
local function RepositionBelowFrame(_, _, parent)
if parent == "MinimapCluster" or parent == _G["MinimapCluster"] then
below:ClearAllPoints()
below:SetPoint(unpack(C.position.uiwidget))
end
end
local belowAnchor = CreateFrame("Frame", "UIWidgetBelowAnchor", UIParent)
belowAnchor:SetSize(100, 30)
belowAnchor:SetPoint(unpack(C.position.uiwidget))

hooksecurefunc(below, "SetPoint", RepositionBelowFrame)
hooksecurefunc(below, "SetPoint", function(self, _, anchor)
if anchor and anchor ~= belowAnchor then
self:ClearAllPoints()
self:SetPoint("CENTER", belowAnchor)
end
end)

for _, frame in pairs({top, below}) do
frame:EnableMouse(true)
frame:SetMovable(true)
frame:SetUserPlaced(true)
frame:SetScript("OnMouseDown", function(self, button)
local anchor = frame == top and topAnchor or belowAnchor
anchor:EnableMouse(true)
anchor:SetMovable(true)
anchor:SetUserPlaced(true)
frame:SetScript("OnMouseDown", function(_, button)
if IsAltKeyDown() or IsShiftKeyDown() then
frame:ClearAllPoints()
frame:StartMoving()
anchor:ClearAllPoints()
anchor:StartMoving()
elseif IsControlKeyDown() and button == "RightButton" then
frame:ClearAllPoints()
frame:SetPoint(unpack(C.position.uiwidget))
anchor:ClearAllPoints()
anchor:SetPoint(unpack(C.position.uiwidget))
end
end)
frame:SetScript("OnMouseUp", function()
frame:StopMovingOrSizing()
anchor:StopMovingOrSizing()
end)
end

0 comments on commit 73850c7

Please sign in to comment.
You can’t perform that action at this time.