Last active
August 12, 2019 16:08
-
-
Save Wetxius/859aaef26a29071017eb38d7807e8dc9 to your computer and use it in GitHub Desktop.
ShestakUI\Modules\Blizzard\UIWidget.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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