-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathWindowOrder.lua
172 lines (142 loc) · 3.77 KB
/
WindowOrder.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
local Recount = _G.Recount
local revision = tonumber(string.sub("$Revision: 1532 $", 12, -3))
if Recount.Version < revision then
Recount.Version = revision
end
local pairs = pairs
local select = select
local strsub = strsub
local UIParent = UIParent
-- Code for organizing the frame order
local TopWindow
local AddToScale = { }
local AllWindows = { }
function Recount:SetLevel(frame, level)
frame:SetFrameLevel(level)
end
function Recount:InitOrder()
TopWindow = nil
Recount:AddWindow(Recount.MainWindow)
Recount:AddWindow(Recount.DetailWindow)
Recount:AddWindow(Recount.GraphWindow)
end
function Recount:SetWindowTop(window)
local Check = window.Above
while Check ~= nil do
window.Above = Check.Above
Check.Above = window
Check.Below = window.Below
window.Below = Check
if Check.Below then
Check.Below.Above = Check
Recount:SetLevel(Check, Check.Below:GetFrameLevel() + 10)
else
Recount:SetLevel(Check, UIParent:GetFrameLevel() + 10)
end
Check = window.Above
end
Recount:SetLevel(window, window.Below:GetFrameLevel() + 10)
TopWindow = window
end
function Recount:AddWindow(window)
window.Below = TopWindow
local toplevel
if TopWindow then
TopWindow.Above = window
toplevel = TopWindow:GetFrameLevel()
else
toplevel = UIParent:GetFrameLevel()
end
window.Above = nil
Recount:SetLevel(window, toplevel + 10)
TopWindow = window
if window:GetName() ~= "Recount_ConfigWindow" then
AddToScale[#AddToScale + 1] = window
end
AllWindows[#AllWindows + 1] = window
window.isLocked = Recount.db.profile.Locked
end
function Recount:ScaleWindows(scale, first)
-- Reuses some of my code from IMBA to scale without moving the windows
for _, v in pairs(AddToScale) do
if not first then
local pointNum = v:GetNumPoints()
local curScale = v:GetScale()
local points = Recount:GetTable()
for i = 1, pointNum do
points[i] = Recount:GetTable()
points[i][1], points[i][2], points[i][3], points[i][4], points[i][5] = v:GetPoint(i)
points[i][4] = points[i][4] * curScale / scale
points[i][5] = points[i][5] * curScale / scale
end
v:ClearAllPoints()
for i = 1, pointNum do
v:SetPoint(points[i][1],points[i][2],points[i][3],points[i][4],points[i][5])
Recount:FreeTable(points[i])
end
Recount:FreeTable(points)
if v:GetScript("OnMouseUp") then
v.isMoving = true
v:GetScript("OnMouseUp")
v.isMoving = false
end
end
v:SetScale(scale)
if v.SavePosition then -- Elsia, need to save position if the function exists to prevent problems with Realtime window when scaled.
v:SavePosition()
end
end
end
function Recount:ResetPositionAllWindows()
for _, v in pairs(AllWindows) do
v:ClearAllPoints()
v:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
end
end
function Recount:LockWindows(lock)
for _, v in pairs(AllWindows) do
if v.DragBottomRight then
v.isLocked = lock -- Only lock windows whose position is stored.
v:EnableMouse(not lock)
if lock then
v.DragBottomRight:Hide()
v.DragBottomLeft:Hide()
else
v.DragBottomRight:Show()
v.DragBottomLeft:Show()
end
else
v.isLocked = false
v:EnableMouse(true)
end
end
end
function Recount:HideRealtimeWindows()
for _, v in pairs(AllWindows) do
if v.tracking then
v:Hide()
end
end
end
function Recount:SetStrataAndClamp()
local strata
if Recount.db.profile.FrameStrata then
strata = strsub(Recount.db.profile.FrameStrata, 3)
end
for _, v in pairs(AllWindows) do
if strata then
v:SetFrameStrata(strata)
end
v:SetClampedToScreen(Recount.db.profile.ClampToScreen)
end
end
--[[function Recount:ShowGrips(state)
local theFrame = Recount.MainWindow
if state then
theFrame.DragBottomRight:Show()
theFrame.DragBottomLeft:Show()
else
theFrame.DragBottomRight:Hide()
theFrame.DragBottomLeft:Hide()
end
end]]