Skip to content

Instantly share code, notes, and snippets.

@Wetxius
Last active August 12, 2019 16:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Wetxius/859aaef26a29071017eb38d7807e8dc9 to your computer and use it in GitHub Desktop.
Save Wetxius/859aaef26a29071017eb38d7807e8dc9 to your computer and use it in GitHub Desktop.
ShestakUI\Modules\Blizzard\UIWidget.lua
local T, C, L, _ = unpack(select(2, ...))
----------------------------------------------------------------------------------------
-- UIWidget frame
----------------------------------------------------------------------------------------
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 belowAnchor = CreateFrame("Frame", "UIWidgetBelowAnchor", UIParent)
belowAnchor:SetSize(100, 30)
belowAnchor:SetPoint(unpack(C.position.uiwidget))
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
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
anchor:ClearAllPoints()
anchor:StartMoving()
elseif IsControlKeyDown() and button == "RightButton" then
anchor:ClearAllPoints()
anchor:SetPoint(unpack(C.position.uiwidget))
end
end)
frame:SetScript("OnMouseUp", function()
anchor:StopMovingOrSizing()
end)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment