mirror of
https://github.com/brues-code/pfUI.git
synced 2026-10-26 05:50:50 +00:00
unlock: reset frame position on middle click
This commit is contained in:
+16
-1
@@ -479,6 +479,14 @@ function pfUI.api.UpdateMovable(frame)
|
|||||||
table.insert(pfUI.movables, name)
|
table.insert(pfUI.movables, name)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if not frame.posdata then
|
||||||
|
frame.posdata = { scale = frame:GetScale(), pos = {} }
|
||||||
|
|
||||||
|
for i=1,frame:GetNumPoints() do
|
||||||
|
frame.posdata.pos[i] = { frame:GetPoint(i) }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if pfUI_config["position"][frame:GetName()] then
|
if pfUI_config["position"][frame:GetName()] then
|
||||||
if pfUI_config["position"][frame:GetName()]["scale"] then
|
if pfUI_config["position"][frame:GetName()]["scale"] then
|
||||||
frame:SetScale(pfUI_config["position"][frame:GetName()].scale)
|
frame:SetScale(pfUI_config["position"][frame:GetName()].scale)
|
||||||
@@ -488,6 +496,13 @@ function pfUI.api.UpdateMovable(frame)
|
|||||||
frame:ClearAllPoints()
|
frame:ClearAllPoints()
|
||||||
frame:SetPoint("TOPLEFT", pfUI_config["position"][frame:GetName()].xpos, pfUI_config["position"][frame:GetName()].ypos)
|
frame:SetPoint("TOPLEFT", pfUI_config["position"][frame:GetName()].xpos, pfUI_config["position"][frame:GetName()].ypos)
|
||||||
end
|
end
|
||||||
|
elseif frame.posdata and frame.posdata.pos[1] then
|
||||||
|
frame:ClearAllPoints()
|
||||||
|
frame:SetScale(frame.posdata.scale)
|
||||||
|
|
||||||
|
for id, point in pairs(frame.posdata.pos) do
|
||||||
|
frame:SetPoint(unpack(point))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -862,4 +877,4 @@ function pfUI.api.GetColorGradient(perc, ...)
|
|||||||
end
|
end
|
||||||
return pfUI.api.GetColorGradient(perc,unpack(color_tuples))
|
return pfUI.api.GetColorGradient(perc,unpack(color_tuples))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
+10
-1
@@ -74,7 +74,8 @@ pfUI:RegisterModule("unlock", function ()
|
|||||||
end
|
end
|
||||||
|
|
||||||
if not frame.drag then
|
if not frame.drag then
|
||||||
frame.drag = CreateFrame("Frame", nil, frame)
|
frame.drag = CreateFrame("Button", nil, frame)
|
||||||
|
frame.drag:RegisterForClicks("MiddleButtonUp")
|
||||||
frame.drag:SetAllPoints(frame)
|
frame.drag:SetAllPoints(frame)
|
||||||
frame.drag:SetFrameStrata("DIALOG")
|
frame.drag:SetFrameStrata("DIALOG")
|
||||||
CreateBackdrop(frame.drag, nil, nil, .8)
|
CreateBackdrop(frame.drag, nil, nil, .8)
|
||||||
@@ -142,6 +143,7 @@ pfUI:RegisterModule("unlock", function ()
|
|||||||
|
|
||||||
|
|
||||||
frame.drag:SetScript("OnMouseDown",function()
|
frame.drag:SetScript("OnMouseDown",function()
|
||||||
|
if arg1 == "MiddleButton" then return end
|
||||||
if IsShiftKeyDown() then
|
if IsShiftKeyDown() then
|
||||||
if strsub(frame:GetName(),0,7) == "pfCombo" then
|
if strsub(frame:GetName(),0,7) == "pfCombo" then
|
||||||
for i=1,5 do
|
for i=1,5 do
|
||||||
@@ -201,6 +203,7 @@ pfUI:RegisterModule("unlock", function ()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
frame.drag:SetScript("OnMouseUp",function()
|
frame.drag:SetScript("OnMouseUp",function()
|
||||||
|
if arg1 == "MiddleButton" then return end
|
||||||
frame:StopMovingOrSizing()
|
frame:StopMovingOrSizing()
|
||||||
_, _, _, xpos, ypos = frame:GetPoint()
|
_, _, _, xpos, ypos = frame:GetPoint()
|
||||||
frame.drag.backdrop:SetBackdropBorderColor(.2,1,.8,1)
|
frame.drag.backdrop:SetBackdropBorderColor(.2,1,.8,1)
|
||||||
@@ -258,6 +261,11 @@ pfUI:RegisterModule("unlock", function ()
|
|||||||
pfUI.unlock:SavePosition(frame)
|
pfUI.unlock:SavePosition(frame)
|
||||||
pfUI.unlock.settingChanged = true
|
pfUI.unlock.settingChanged = true
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
frame.drag:SetScript("OnClick", function()
|
||||||
|
pfUI_config["position"][frame:GetName()] = nil
|
||||||
|
UpdateMovable(frame)
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
frame:SetMovable(true)
|
frame:SetMovable(true)
|
||||||
@@ -280,6 +288,7 @@ pfUI:RegisterModule("unlock", function ()
|
|||||||
if frame.hideLater == true then
|
if frame.hideLater == true then
|
||||||
frame:Hide()
|
frame:Hide()
|
||||||
end
|
end
|
||||||
|
UpdateMovable(frame)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user