flickerstreak@175
|
1 local addonName, addonTable = ...
|
flickerstreak@175
|
2 local ReAction = addonTable.ReAction
|
flickerstreak@122
|
3 local L = ReAction.L
|
flickerstreak@122
|
4 local CreateFrame = CreateFrame
|
flickerstreak@122
|
5 local InCombatLockdown = InCombatLockdown
|
flickerstreak@122
|
6 local floor = math.floor
|
flickerstreak@122
|
7 local min = math.min
|
flickerstreak@122
|
8 local format = string.format
|
flickerstreak@122
|
9 local GameTooltip = GameTooltip
|
flickerstreak@122
|
10 local Bar = ReAction.Bar
|
flickerstreak@122
|
11 local GetSize = Bar.GetSize
|
flickerstreak@122
|
12 local SetSize = Bar.SetSize
|
flickerstreak@122
|
13 local GetButtonSize = Bar.GetButtonSize
|
flickerstreak@122
|
14 local GetButtonGrid = Bar.GetButtonGrid
|
flickerstreak@122
|
15 local SetButtonSize = Bar.SetButtonSize
|
flickerstreak@122
|
16 local SetButtonGrid = Bar.SetButtonGrid
|
flickerstreak@122
|
17 local ApplyAnchor = Bar.ApplyAnchor
|
flickerstreak@122
|
18 local GameTooltipTextRight1 = GameTooltipTextRight1
|
flickerstreak@122
|
19 local GameTooltipTextRight2 = GameTooltipTextRight2
|
flickerstreak@122
|
20 local GameTooltipTextRight3 = GameTooltipTextRight3
|
flickerstreak@122
|
21
|
flickerstreak@122
|
22 local KB = LibStub("LibKeyBound-1.0")
|
flickerstreak@122
|
23
|
flickerstreak@122
|
24 --
|
flickerstreak@122
|
25 -- Wrap some of the bar manipulators to make them state-aware
|
flickerstreak@122
|
26 --
|
flickerstreak@122
|
27 local function SetAnchor( bar, point, frame, relPoint, x, y )
|
flickerstreak@155
|
28 local state = bar:GetSecureState()
|
flickerstreak@122
|
29 if state then
|
flickerstreak@122
|
30 local anchorstate = bar:GetStateProperty(state, "anchorEnable")
|
flickerstreak@122
|
31 if anchorstate then
|
flickerstreak@122
|
32 bar:SetStateProperty(state, "anchorFrame", frame)
|
flickerstreak@122
|
33 bar:SetStateProperty(state, "anchorPoint", point)
|
flickerstreak@122
|
34 bar:SetStateProperty(state, "anchorRelPoint", relPoint)
|
flickerstreak@122
|
35 bar:SetStateProperty(state, "anchorX", x or 0)
|
flickerstreak@122
|
36 bar:SetStateProperty(state, "anchorY", y or 0)
|
flickerstreak@122
|
37 bar:SetAnchor(bar:GetAnchor())
|
flickerstreak@122
|
38 return
|
flickerstreak@122
|
39 end
|
flickerstreak@122
|
40 end
|
flickerstreak@122
|
41 bar:SetAnchor(point, frame, relPoint, x, y)
|
flickerstreak@122
|
42 end
|
flickerstreak@122
|
43
|
flickerstreak@122
|
44 local function GetStateScale( bar )
|
flickerstreak@155
|
45 local state = bar:GetSecureState()
|
flickerstreak@122
|
46 if state and bar:GetStateProperty(state, "enableScale") then
|
flickerstreak@122
|
47 return bar:GetStateProperty(state, "scale")
|
flickerstreak@122
|
48 end
|
flickerstreak@122
|
49 end
|
flickerstreak@122
|
50
|
flickerstreak@122
|
51 local function SetStateScale( bar, scale )
|
flickerstreak@155
|
52 local state = bar:GetSecureState()
|
flickerstreak@122
|
53 if state and bar:GetStateProperty(state, "enableScale") then
|
flickerstreak@122
|
54 bar:SetStateProperty(state, "scale", scale)
|
flickerstreak@122
|
55 end
|
flickerstreak@122
|
56 end
|
flickerstreak@122
|
57
|
flickerstreak@122
|
58
|
flickerstreak@122
|
59 --
|
flickerstreak@122
|
60 -- Bar config overlay
|
flickerstreak@122
|
61 --
|
flickerstreak@122
|
62
|
flickerstreak@122
|
63 local function GetNormalTextColor()
|
flickerstreak@122
|
64 return 1.0, 1.0, 1.0, 1.0
|
flickerstreak@122
|
65 end
|
flickerstreak@122
|
66
|
flickerstreak@122
|
67 local function GetAnchoredTextColor()
|
flickerstreak@122
|
68 return 1.0, 1.0, 1.0, 1.0
|
flickerstreak@122
|
69 end
|
flickerstreak@122
|
70
|
flickerstreak@122
|
71 local function GetNormalBgColor()
|
flickerstreak@122
|
72 return 0.7, 0.7, 1.0, 0.3
|
flickerstreak@122
|
73 end
|
flickerstreak@122
|
74
|
flickerstreak@122
|
75 local function GetAnchoredBgColor()
|
flickerstreak@122
|
76 return 0.9, 0.2, 0.7, 0.3
|
flickerstreak@122
|
77 end
|
flickerstreak@122
|
78
|
flickerstreak@122
|
79 local function StoreSize(bar)
|
flickerstreak@122
|
80 local f = bar:GetFrame()
|
flickerstreak@122
|
81 SetSize( bar, f:GetWidth(), f:GetHeight() )
|
flickerstreak@122
|
82 end
|
flickerstreak@122
|
83
|
flickerstreak@122
|
84 local function StoreExtents(bar)
|
flickerstreak@122
|
85 local f = bar:GetFrame()
|
flickerstreak@122
|
86 local p, fr, rp, x, y = f:GetPoint(1)
|
flickerstreak@122
|
87 fr = fr and fr:GetName() or "UIParent"
|
flickerstreak@122
|
88 SetAnchor( bar, p, fr, rp, x, y )
|
flickerstreak@122
|
89 SetSize( bar, f:GetWidth(), f:GetHeight() )
|
flickerstreak@122
|
90 end
|
flickerstreak@122
|
91
|
flickerstreak@122
|
92 local function RecomputeButtonSize(bar)
|
flickerstreak@122
|
93 local w, h = GetSize(bar)
|
flickerstreak@122
|
94 local bw, bh = GetButtonSize(bar)
|
flickerstreak@122
|
95 local r, c, s = GetButtonGrid(bar)
|
flickerstreak@122
|
96
|
flickerstreak@122
|
97 local scaleW = (floor(w/c) - s) / bw
|
flickerstreak@122
|
98 local scaleH = (floor(h/r) - s) / bh
|
flickerstreak@122
|
99 local scale = min(scaleW, scaleH)
|
flickerstreak@122
|
100
|
flickerstreak@122
|
101 SetButtonSize(bar, scale * bw, scale * bh, s)
|
flickerstreak@122
|
102 end
|
flickerstreak@122
|
103
|
flickerstreak@154
|
104 local function ComputeBarScale(bar, overlay)
|
flickerstreak@154
|
105 local w, h = overlay:GetWidth() - 8, overlay:GetHeight() - 8
|
flickerstreak@122
|
106 local bw, bh = GetButtonSize(bar)
|
flickerstreak@122
|
107 local r, c, s = GetButtonGrid(bar)
|
flickerstreak@122
|
108
|
flickerstreak@122
|
109 local scaleW = w / (c*(bw+s))
|
flickerstreak@122
|
110 local scaleH = h / (r*(bh+s))
|
flickerstreak@122
|
111 local scale = min(scaleW, scaleH)
|
flickerstreak@122
|
112
|
flickerstreak@122
|
113 if scale > 2.5 then
|
flickerstreak@122
|
114 scale = 2.5
|
flickerstreak@122
|
115 elseif scale < 0.25 then
|
flickerstreak@122
|
116 scale = 0.25
|
flickerstreak@122
|
117 end
|
flickerstreak@122
|
118
|
flickerstreak@122
|
119 return scale
|
flickerstreak@122
|
120 end
|
flickerstreak@122
|
121
|
flickerstreak@122
|
122 local function RecomputeButtonSpacing(bar)
|
flickerstreak@122
|
123 local w, h = GetSize(bar)
|
flickerstreak@122
|
124 local bw, bh = GetButtonSize(bar)
|
flickerstreak@122
|
125 local r, c, s = GetButtonGrid(bar)
|
flickerstreak@122
|
126
|
flickerstreak@122
|
127 SetButtonGrid(bar,r,c,min(floor(w/c) - bw, floor(h/r) - bh))
|
flickerstreak@122
|
128 end
|
flickerstreak@122
|
129
|
flickerstreak@122
|
130 local function RecomputeGrid(bar)
|
flickerstreak@122
|
131 local w, h = GetSize(bar)
|
flickerstreak@122
|
132 local bw, bh = GetButtonSize(bar)
|
flickerstreak@122
|
133 local r, c, s = GetButtonGrid(bar)
|
flickerstreak@122
|
134
|
flickerstreak@122
|
135 SetButtonGrid(bar, floor(h/(bh+s)), floor(w/(bw+s)), s)
|
flickerstreak@122
|
136 end
|
flickerstreak@122
|
137
|
flickerstreak@122
|
138 local function ClampToButtons(bar)
|
flickerstreak@122
|
139 local bw, bh = GetButtonSize(bar)
|
flickerstreak@122
|
140 local r, c, s = GetButtonGrid(bar)
|
flickerstreak@122
|
141 SetSize(bar, (bw+s)*c + 1, (bh+s)*r + 1)
|
flickerstreak@122
|
142 end
|
flickerstreak@122
|
143
|
flickerstreak@122
|
144 local function HideGameTooltip()
|
flickerstreak@122
|
145 GameTooltip:Hide()
|
flickerstreak@122
|
146 end
|
flickerstreak@122
|
147
|
flickerstreak@122
|
148 local anchorInside = { inside = true }
|
flickerstreak@122
|
149 local anchorOutside = { outside = true }
|
flickerstreak@122
|
150 local edges = { "BOTTOM", "TOP", "LEFT", "RIGHT" }
|
flickerstreak@122
|
151 local oppositeEdges = {
|
flickerstreak@122
|
152 TOP = "BOTTOM",
|
flickerstreak@122
|
153 BOTTOM = "TOP",
|
flickerstreak@122
|
154 LEFT = "RIGHT",
|
flickerstreak@122
|
155 RIGHT = "LEFT"
|
flickerstreak@122
|
156 }
|
flickerstreak@122
|
157 local pointsOnEdge = {
|
flickerstreak@122
|
158 BOTTOM = { "BOTTOM", "BOTTOMLEFT", "BOTTOMRIGHT", },
|
flickerstreak@122
|
159 TOP = { "TOP", "TOPLEFT", "TOPRIGHT", },
|
flickerstreak@122
|
160 RIGHT = { "RIGHT", "BOTTOMRIGHT", "TOPRIGHT", },
|
flickerstreak@122
|
161 LEFT = { "LEFT", "BOTTOMLEFT", "TOPLEFT", },
|
flickerstreak@122
|
162 }
|
flickerstreak@122
|
163 local edgeSelector = {
|
flickerstreak@122
|
164 BOTTOM = 1, -- select x of x,y
|
flickerstreak@122
|
165 TOP = 1, -- select x of x,y
|
flickerstreak@122
|
166 LEFT = 2, -- select y of x,y
|
flickerstreak@122
|
167 RIGHT = 2, -- select y of x,y
|
flickerstreak@122
|
168 }
|
flickerstreak@122
|
169 local snapPoints = {
|
flickerstreak@122
|
170 [anchorOutside] = {
|
flickerstreak@122
|
171 BOTTOMLEFT = {"BOTTOMRIGHT","TOPLEFT","TOPRIGHT"},
|
flickerstreak@122
|
172 BOTTOM = {"TOP"},
|
flickerstreak@122
|
173 BOTTOMRIGHT = {"BOTTOMLEFT","TOPRIGHT","TOPLEFT"},
|
flickerstreak@122
|
174 RIGHT = {"LEFT"},
|
flickerstreak@122
|
175 TOPRIGHT = {"TOPLEFT","BOTTOMRIGHT","BOTTOMLEFT"},
|
flickerstreak@122
|
176 TOP = {"BOTTOM"},
|
flickerstreak@122
|
177 TOPLEFT = {"TOPRIGHT","BOTTOMLEFT","BOTTOMRIGHT"},
|
flickerstreak@122
|
178 LEFT = {"RIGHT"},
|
flickerstreak@122
|
179 CENTER = {"CENTER"}
|
flickerstreak@122
|
180 },
|
flickerstreak@122
|
181 [anchorInside] = {
|
flickerstreak@122
|
182 BOTTOMLEFT = {"BOTTOMLEFT"},
|
flickerstreak@122
|
183 BOTTOM = {"BOTTOM"},
|
flickerstreak@122
|
184 BOTTOMRIGHT = {"BOTTOMRIGHT"},
|
flickerstreak@122
|
185 RIGHT = {"RIGHT"},
|
flickerstreak@122
|
186 TOPRIGHT = {"TOPRIGHT"},
|
flickerstreak@122
|
187 TOP = {"TOP"},
|
flickerstreak@122
|
188 TOPLEFT = {"TOPLEFT"},
|
flickerstreak@122
|
189 LEFT = {"LEFT"},
|
flickerstreak@122
|
190 CENTER = {"CENTER"}
|
flickerstreak@122
|
191 }
|
flickerstreak@122
|
192 }
|
flickerstreak@122
|
193 local insidePointOffsetFuncs = {
|
flickerstreak@122
|
194 BOTTOMLEFT = function(x, y) return x, y end,
|
flickerstreak@122
|
195 BOTTOM = function(x, y) return 0, y end,
|
flickerstreak@122
|
196 BOTTOMRIGHT = function(x, y) return -x, y end,
|
flickerstreak@122
|
197 RIGHT = function(x, y) return -x, 0 end,
|
flickerstreak@122
|
198 TOPRIGHT = function(x, y) return -x, -y end,
|
flickerstreak@122
|
199 TOP = function(x, y) return 0, -y end,
|
flickerstreak@122
|
200 TOPLEFT = function(x, y) return x, -y end,
|
flickerstreak@122
|
201 LEFT = function(x, y) return x, 0 end,
|
flickerstreak@122
|
202 CENTER = function(x, y) return x, y end,
|
flickerstreak@122
|
203 }
|
flickerstreak@122
|
204 local pointCoordFuncs = {
|
flickerstreak@122
|
205 BOTTOMLEFT = function(f) return f:GetLeft(), f:GetBottom() end,
|
flickerstreak@122
|
206 BOTTOM = function(f) return nil, f:GetBottom() end,
|
flickerstreak@122
|
207 BOTTOMRIGHT = function(f) return f:GetRight(), f:GetBottom() end,
|
flickerstreak@122
|
208 RIGHT = function(f) return f:GetRight(), nil end,
|
flickerstreak@122
|
209 TOPRIGHT = function(f) return f:GetRight(), f:GetTop() end,
|
flickerstreak@122
|
210 TOP = function(f) return nil, f:GetTop() end,
|
flickerstreak@122
|
211 TOPLEFT = function(f) return f:GetLeft(), f:GetTop() end,
|
flickerstreak@122
|
212 LEFT = function(f) return f:GetLeft(), nil end,
|
flickerstreak@122
|
213 CENTER = function(f) return f:GetCenter() end,
|
flickerstreak@122
|
214 }
|
flickerstreak@122
|
215 local edgeBoundsFuncs = {
|
flickerstreak@122
|
216 BOTTOM = function(f) return f:GetLeft(), f:GetRight() end,
|
flickerstreak@122
|
217 LEFT = function(f) return f:GetBottom(), f:GetTop() end
|
flickerstreak@122
|
218 }
|
flickerstreak@122
|
219 edgeBoundsFuncs.TOP = edgeBoundsFuncs.BOTTOM
|
flickerstreak@122
|
220 edgeBoundsFuncs.RIGHT = edgeBoundsFuncs.LEFT
|
flickerstreak@122
|
221 local cornerTexCoords = {
|
flickerstreak@122
|
222 -- ULx, ULy, LLx, LLy, URx, URy, LRx, LRy
|
flickerstreak@122
|
223 TOPLEFT = { 1, 1, 1, 0, 0, 1, 0, 0 },
|
flickerstreak@122
|
224 TOPRIGHT = { 1, 0, 0, 0, 1, 1, 0, 1 },
|
flickerstreak@122
|
225 BOTTOMLEFT = { 0, 1, 1, 1, 0, 0, 1, 0 },
|
flickerstreak@122
|
226 BOTTOMRIGHT = { 0, 0, 0, 1, 1, 0, 1, 1 },
|
flickerstreak@122
|
227 }
|
flickerstreak@122
|
228
|
flickerstreak@122
|
229 -- Returns absolute coordinates x,y of the named point 'p' of frame 'f'
|
flickerstreak@122
|
230 local function GetPointCoords( f, p )
|
flickerstreak@122
|
231 local x, y = pointCoordFuncs[p](f)
|
flickerstreak@122
|
232 if not(x and y) then
|
flickerstreak@122
|
233 local cx, cy = f:GetCenter()
|
flickerstreak@122
|
234 x = x or cx
|
flickerstreak@122
|
235 y = y or cy
|
flickerstreak@122
|
236 end
|
flickerstreak@122
|
237 return x, y
|
flickerstreak@122
|
238 end
|
flickerstreak@122
|
239
|
flickerstreak@122
|
240
|
flickerstreak@122
|
241 -- Returns true if frame 'f1' can be anchored to frame 'f2'
|
flickerstreak@122
|
242 local function CheckAnchorable( f1, f2 )
|
flickerstreak@122
|
243 -- can't anchor a frame to itself or to nil
|
flickerstreak@122
|
244 if f1 == f2 or f2 == nil then
|
flickerstreak@122
|
245 return false
|
flickerstreak@122
|
246 end
|
flickerstreak@122
|
247
|
flickerstreak@122
|
248 -- can always anchor to UIParent
|
flickerstreak@122
|
249 if f2 == UIParent then
|
flickerstreak@122
|
250 return true
|
flickerstreak@122
|
251 end
|
flickerstreak@122
|
252
|
flickerstreak@122
|
253 -- also can't do circular anchoring of frames
|
flickerstreak@122
|
254 -- walk the anchor chain, which generally shouldn't be that expensive
|
flickerstreak@122
|
255 -- (who nests draggables that deep anyway?)
|
flickerstreak@122
|
256 for i = 1, f2:GetNumPoints() do
|
flickerstreak@122
|
257 local _, f = f2:GetPoint(i)
|
flickerstreak@122
|
258 if not f then f = f2:GetParent() end
|
flickerstreak@122
|
259 return CheckAnchorable(f1,f)
|
flickerstreak@122
|
260 end
|
flickerstreak@122
|
261
|
flickerstreak@122
|
262 return true
|
flickerstreak@122
|
263 end
|
flickerstreak@122
|
264
|
flickerstreak@122
|
265 -- Returns true if frames f1 and f2 specified edges overlap
|
flickerstreak@122
|
266 local function CheckEdgeOverlap( f1, f2, e )
|
flickerstreak@122
|
267 local l1, u1 = edgeBoundsFuncs[e](f1)
|
flickerstreak@122
|
268 local l2, u2 = edgeBoundsFuncs[e](f2)
|
flickerstreak@122
|
269 return l1 <= l2 and l2 <= u1 or l2 <= l1 and l1 <= u2
|
flickerstreak@122
|
270 end
|
flickerstreak@122
|
271
|
flickerstreak@122
|
272 -- Returns true if point p1 on frame f1 overlaps edge e2 on frame f2
|
flickerstreak@122
|
273 local function CheckPointEdgeOverlap( f1, p1, f2, e2 )
|
flickerstreak@122
|
274 local l, u = edgeBoundsFuncs[e2](f2)
|
flickerstreak@122
|
275 local x, y = GetPointCoords(f1,p1)
|
flickerstreak@122
|
276 x = select(edgeSelector[e2], x, y)
|
flickerstreak@122
|
277 return l <= x and x <= u
|
flickerstreak@122
|
278 end
|
flickerstreak@122
|
279
|
flickerstreak@122
|
280 -- Returns the distance between corresponding edges. It is
|
flickerstreak@122
|
281 -- assumed that the passed in edges e1 and e2 are the same or opposites
|
flickerstreak@122
|
282 local function GetEdgeDistance( f1, f2, e1, e2 )
|
flickerstreak@122
|
283 local x1, y1 = pointCoordFuncs[e1](f1)
|
flickerstreak@122
|
284 local x2, y2 = pointCoordFuncs[e2](f2)
|
flickerstreak@122
|
285 return math.abs((x1 or y1) - (x2 or y2))
|
flickerstreak@122
|
286 end
|
flickerstreak@122
|
287
|
flickerstreak@122
|
288 local globalSnapTargets = { [UIParent] = anchorInside }
|
flickerstreak@122
|
289
|
flickerstreak@122
|
290 local function GetClosestFrameEdge(f1,f2,a)
|
flickerstreak@122
|
291 local dist, edge, opp
|
flickerstreak@122
|
292 if f2:IsVisible() and CheckAnchorable(f1,f2) then
|
flickerstreak@122
|
293 for _, e in pairs(edges) do
|
flickerstreak@122
|
294 local o = a.inside and e or oppositeEdges[e]
|
flickerstreak@122
|
295 if CheckEdgeOverlap(f1,f2,e) then
|
flickerstreak@122
|
296 local d = GetEdgeDistance(f1, f2, e, o)
|
flickerstreak@122
|
297 if not dist or (d < dist) then
|
flickerstreak@122
|
298 dist, edge, opp = d, e, o
|
flickerstreak@122
|
299 end
|
flickerstreak@122
|
300 end
|
flickerstreak@122
|
301 end
|
flickerstreak@122
|
302 end
|
flickerstreak@122
|
303 return dist, edge, opp
|
flickerstreak@122
|
304 end
|
flickerstreak@122
|
305
|
flickerstreak@122
|
306 local function GetClosestVisibleEdge( f )
|
flickerstreak@122
|
307 local r, o, e1, e2
|
flickerstreak@122
|
308 local a = anchorOutside
|
flickerstreak@122
|
309 for _, b in ReAction:IterateBars() do
|
flickerstreak@122
|
310 local d, e, opp = GetClosestFrameEdge(f,b:GetFrame(),a)
|
flickerstreak@122
|
311 if d and (not r or d < r) then
|
flickerstreak@122
|
312 r, o, e1, e2 = d, b:GetFrame(), e, opp
|
flickerstreak@122
|
313 end
|
flickerstreak@122
|
314 end
|
flickerstreak@122
|
315 for f2, a2 in pairs(globalSnapTargets) do
|
flickerstreak@122
|
316 local d, e, opp = GetClosestFrameEdge(f,f2,a2)
|
flickerstreak@122
|
317 if d and (not r or d < r) then
|
flickerstreak@122
|
318 r, o, e1, e2, a = d, f2, e, opp, a2
|
flickerstreak@122
|
319 end
|
flickerstreak@122
|
320 end
|
flickerstreak@122
|
321 return o, e1, e2, a
|
flickerstreak@122
|
322 end
|
flickerstreak@122
|
323
|
flickerstreak@122
|
324 local function GetClosestVisiblePoint(f1)
|
flickerstreak@122
|
325 local f2, e1, e2, a = GetClosestVisibleEdge(f1)
|
flickerstreak@122
|
326 if f2 then
|
flickerstreak@122
|
327 local rsq, p, rp, x, y
|
flickerstreak@122
|
328 -- iterate pointsOnEdge in order and use < to prefer edge centers to corners
|
flickerstreak@122
|
329 for _, p1 in ipairs(pointsOnEdge[e1]) do
|
flickerstreak@122
|
330 if CheckPointEdgeOverlap(f1,p1,f2,e2) then
|
flickerstreak@122
|
331 for _, p2 in pairs(snapPoints[a][p1]) do
|
flickerstreak@122
|
332 local x1, y1 = GetPointCoords(f1,p1)
|
flickerstreak@122
|
333 local x2, y2 = GetPointCoords(f2,p2)
|
flickerstreak@122
|
334 local dx = x1 - x2
|
flickerstreak@122
|
335 local dy = y1 - y2
|
flickerstreak@122
|
336 local rsq2 = dx*dx + dy*dy
|
flickerstreak@122
|
337 if not rsq or rsq2 < rsq then
|
flickerstreak@122
|
338 rsq, p, rp, x, y = rsq2, p1, p2, dx, dy
|
flickerstreak@122
|
339 end
|
flickerstreak@122
|
340 end
|
flickerstreak@122
|
341 end
|
flickerstreak@122
|
342 end
|
flickerstreak@122
|
343 return f2, p, rp, x, y
|
flickerstreak@122
|
344 end
|
flickerstreak@122
|
345 end
|
flickerstreak@122
|
346
|
flickerstreak@122
|
347 local function GetClosestPointSnapped(f1, rx, ry, xOff, yOff)
|
flickerstreak@122
|
348 local o, p, rp, x, y = GetClosestVisiblePoint(f1)
|
flickerstreak@122
|
349 local s = false
|
flickerstreak@122
|
350
|
flickerstreak@122
|
351 local insideOffsetFunc = p and insidePointOffsetFuncs[p]
|
flickerstreak@122
|
352 local coordFunc = p and pointCoordFuncs[p]
|
flickerstreak@122
|
353 if not insideOffsetFunc or not coordFunc then
|
flickerstreak@122
|
354 return
|
flickerstreak@122
|
355 end
|
flickerstreak@122
|
356
|
flickerstreak@122
|
357 local sx, sy = insideOffsetFunc(xOff or 0, yOff or 0)
|
flickerstreak@122
|
358 local xx, yy = coordFunc(f1)
|
flickerstreak@122
|
359 if xx and yy then
|
flickerstreak@122
|
360 if math.abs(x) <= rx then
|
flickerstreak@122
|
361 if math.abs(y) <= ry then
|
flickerstreak@122
|
362 x = sx
|
flickerstreak@122
|
363 y = sy
|
flickerstreak@122
|
364 s = true
|
flickerstreak@122
|
365 elseif CheckEdgeOverlap(f1,o,"LEFT") then
|
flickerstreak@122
|
366 x = sx
|
flickerstreak@122
|
367 s = true
|
flickerstreak@122
|
368 end
|
flickerstreak@122
|
369 elseif math.abs(y) <= ry and CheckEdgeOverlap(f1,o,"TOP") then
|
flickerstreak@122
|
370 y = sy
|
flickerstreak@122
|
371 s = true
|
flickerstreak@122
|
372 end
|
flickerstreak@122
|
373 elseif xx then
|
flickerstreak@122
|
374 if math.abs(x) <= rx then
|
flickerstreak@122
|
375 x = sx
|
flickerstreak@122
|
376 s = true
|
flickerstreak@122
|
377 if math.abs(y) <= ry then
|
flickerstreak@122
|
378 y = sy
|
flickerstreak@122
|
379 end
|
flickerstreak@122
|
380 end
|
flickerstreak@122
|
381 elseif yy then
|
flickerstreak@122
|
382 if math.abs(y) <= ry then
|
flickerstreak@122
|
383 y = sy
|
flickerstreak@122
|
384 s = true
|
flickerstreak@122
|
385 if math.abs(x) <= rx then
|
flickerstreak@122
|
386 x = sx
|
flickerstreak@122
|
387 end
|
flickerstreak@122
|
388 end
|
flickerstreak@122
|
389 end
|
flickerstreak@122
|
390
|
flickerstreak@122
|
391 -- correct for some Lua oddities with doubles
|
flickerstreak@122
|
392 if x == -0 then x = 0 end
|
flickerstreak@122
|
393 if y == -0 then y = 0 end
|
flickerstreak@122
|
394
|
flickerstreak@122
|
395 if s then
|
flickerstreak@122
|
396 return o, p, rp, math.floor(x), math.floor(y)
|
flickerstreak@122
|
397 end
|
flickerstreak@122
|
398 end
|
flickerstreak@122
|
399
|
flickerstreak@122
|
400 local function CreateSnapIndicator()
|
flickerstreak@122
|
401 local si = CreateFrame("Frame",nil,UIParent)
|
flickerstreak@122
|
402 si:SetFrameStrata("HIGH")
|
flickerstreak@122
|
403 si:SetHeight(16)
|
flickerstreak@122
|
404 si:SetWidth(16)
|
flickerstreak@122
|
405 local tex = si:CreateTexture()
|
flickerstreak@122
|
406 tex:SetAllPoints()
|
flickerstreak@122
|
407 tex:SetTexture("Interface\\AddOns\\ReAction\\img\\lock")
|
flickerstreak@122
|
408 tex:SetBlendMode("ADD")
|
flickerstreak@122
|
409 tex:SetDrawLayer("OVERLAY")
|
flickerstreak@122
|
410 return si
|
flickerstreak@122
|
411 end
|
flickerstreak@122
|
412
|
flickerstreak@122
|
413 local si1 = CreateSnapIndicator()
|
flickerstreak@122
|
414 local si2 = CreateSnapIndicator()
|
flickerstreak@122
|
415
|
flickerstreak@122
|
416 local function DisplaySnapIndicator( f, rx, ry, xOff, yOff )
|
flickerstreak@122
|
417 local o, p, rp, x, y, snap = GetClosestPointSnapped(f, rx, ry, xOff, yOff)
|
flickerstreak@122
|
418 if o then
|
flickerstreak@122
|
419 si1:ClearAllPoints()
|
flickerstreak@122
|
420 si2:ClearAllPoints()
|
flickerstreak@122
|
421 si1:SetPoint("CENTER", f, p, 0, 0)
|
flickerstreak@122
|
422 local xx, yy = pointCoordFuncs[rp](o)
|
flickerstreak@122
|
423 x = math.abs(x) <=rx and xx and 0 or x
|
flickerstreak@122
|
424 y = math.abs(y) <=ry and yy and 0 or y
|
flickerstreak@122
|
425 si2:SetPoint("CENTER", o, rp, x, y)
|
flickerstreak@122
|
426 si1:Show()
|
flickerstreak@122
|
427 si2:Show()
|
flickerstreak@122
|
428 else
|
flickerstreak@122
|
429 if si1:IsVisible() then
|
flickerstreak@122
|
430 si1:Hide()
|
flickerstreak@122
|
431 si2:Hide()
|
flickerstreak@122
|
432 end
|
flickerstreak@122
|
433 end
|
flickerstreak@122
|
434 return o, p
|
flickerstreak@122
|
435 end
|
flickerstreak@122
|
436
|
flickerstreak@122
|
437 local function HideSnapIndicator()
|
flickerstreak@122
|
438 if si1:IsVisible() then
|
flickerstreak@122
|
439 si1:Hide()
|
flickerstreak@122
|
440 si2:Hide()
|
flickerstreak@122
|
441 end
|
flickerstreak@122
|
442 end
|
flickerstreak@122
|
443
|
flickerstreak@154
|
444 local function UpdateLabelString(overlay)
|
flickerstreak@154
|
445 local label = overlay.labelString
|
flickerstreak@122
|
446 if label then
|
flickerstreak@154
|
447 local name = overlay.labelName
|
flickerstreak@154
|
448 if name and overlay.labelSubtext then
|
flickerstreak@154
|
449 name = format("%s (%s)", name, overlay.labelSubtext)
|
flickerstreak@122
|
450 end
|
flickerstreak@122
|
451 label:SetText(name or "")
|
flickerstreak@122
|
452 end
|
flickerstreak@122
|
453 end
|
flickerstreak@122
|
454
|
flickerstreak@122
|
455 local function CreateControls(bar)
|
flickerstreak@122
|
456 local f = bar:GetFrame()
|
flickerstreak@122
|
457
|
flickerstreak@122
|
458 f:SetMovable(true)
|
flickerstreak@122
|
459 f:SetResizable(true)
|
flickerstreak@122
|
460
|
flickerstreak@122
|
461 -- child of UIParent so that alpha and scale doesn't propagate to it
|
flickerstreak@122
|
462 local overlay = CreateFrame("Button", nil, UIParent)
|
flickerstreak@122
|
463 overlay:EnableMouse(true)
|
flickerstreak@135
|
464 overlay:SetFrameLevel(10) -- set it above the buttons
|
flickerstreak@122
|
465 overlay:SetPoint("TOPLEFT", f, "TOPLEFT", -4, 4)
|
flickerstreak@122
|
466 overlay:SetPoint("BOTTOMRIGHT", f, "BOTTOMRIGHT", 4, -4)
|
flickerstreak@122
|
467 overlay:SetBackdrop({
|
flickerstreak@122
|
468 edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
|
flickerstreak@122
|
469 tile = true,
|
flickerstreak@122
|
470 tileSize = 16,
|
flickerstreak@122
|
471 edgeSize = 16,
|
flickerstreak@122
|
472 insets = { left = 0, right = 0, top = 0, bottom = 0 },
|
flickerstreak@122
|
473 })
|
flickerstreak@122
|
474
|
flickerstreak@122
|
475 -- textures
|
flickerstreak@122
|
476 local bgTex = overlay:CreateTexture(nil,"BACKGROUND")
|
flickerstreak@122
|
477 bgTex:SetTexture(0.7,0.7,1.0,0.2)
|
flickerstreak@122
|
478 bgTex:SetPoint("TOPLEFT",4,-4)
|
flickerstreak@122
|
479 bgTex:SetPoint("BOTTOMRIGHT",-4,4)
|
flickerstreak@122
|
480 local hTex = overlay:CreateTexture(nil,"HIGHLIGHT")
|
flickerstreak@122
|
481 hTex:SetTexture(0.7,0.7,1.0,0.2)
|
flickerstreak@122
|
482 hTex:SetPoint("TOPLEFT",4,-4)
|
flickerstreak@122
|
483 hTex:SetPoint("BOTTOMRIGHT",-4,4)
|
flickerstreak@122
|
484 hTex:SetBlendMode("ADD")
|
flickerstreak@122
|
485 local aTex = overlay:CreateTexture(nil,"ARTWORK")
|
flickerstreak@122
|
486 aTex:SetTexture("Interface\\AddOns\\ReAction\\img\\lock")
|
flickerstreak@122
|
487 aTex:SetWidth(16)
|
flickerstreak@122
|
488 aTex:SetHeight(16)
|
flickerstreak@122
|
489 aTex:Hide()
|
flickerstreak@122
|
490
|
flickerstreak@122
|
491 -- label
|
flickerstreak@122
|
492 local label = overlay:CreateFontString(nil,"OVERLAY","GameFontNormalLarge")
|
flickerstreak@122
|
493 label:SetAllPoints()
|
flickerstreak@122
|
494 label:SetJustifyH("CENTER")
|
flickerstreak@122
|
495 label:SetShadowColor(0,0,0,1)
|
flickerstreak@122
|
496 label:SetShadowOffset(3,-3)
|
flickerstreak@122
|
497 label:SetTextColor(GetNormalTextColor())
|
flickerstreak@122
|
498 label:SetText(bar:GetName())
|
flickerstreak@122
|
499 label:Show()
|
flickerstreak@154
|
500 overlay.labelString = label
|
flickerstreak@154
|
501 overlay.labelName = bar:GetName()
|
flickerstreak@122
|
502
|
flickerstreak@122
|
503 local function UpdateAnchorDecoration()
|
flickerstreak@122
|
504 local point, anchor, relPoint, x, y = f:GetPoint(1)
|
flickerstreak@122
|
505 if point then
|
flickerstreak@122
|
506 local ofsx, ofsy = insidePointOffsetFuncs[point](x,y)
|
flickerstreak@122
|
507 if (anchor and anchor ~= UIParent) or (ofsx == 0 and ofsy == 0) then
|
flickerstreak@122
|
508 bgTex:SetTexture( GetAnchoredBgColor() )
|
flickerstreak@122
|
509 hTex:SetTexture( GetAnchoredBgColor() )
|
flickerstreak@122
|
510 label:SetTextColor( GetAnchoredTextColor() )
|
flickerstreak@122
|
511 aTex:ClearAllPoints()
|
flickerstreak@122
|
512 aTex:SetPoint(point)
|
flickerstreak@122
|
513 aTex:Show()
|
flickerstreak@122
|
514 return
|
flickerstreak@122
|
515 end
|
flickerstreak@122
|
516 end
|
flickerstreak@122
|
517 bgTex:SetTexture( GetNormalBgColor() )
|
flickerstreak@122
|
518 hTex:SetTexture( GetNormalBgColor() )
|
flickerstreak@122
|
519 label:SetTextColor( GetNormalTextColor() )
|
flickerstreak@122
|
520 aTex:Hide()
|
flickerstreak@122
|
521 end
|
flickerstreak@122
|
522
|
flickerstreak@122
|
523 local function StopResize()
|
flickerstreak@122
|
524 f:StopMovingOrSizing()
|
flickerstreak@122
|
525 f.isMoving = false
|
flickerstreak@122
|
526 f:SetScript("OnUpdate",nil)
|
flickerstreak@122
|
527 StoreSize(bar)
|
flickerstreak@122
|
528 ClampToButtons(bar)
|
flickerstreak@122
|
529 ReAction:RefreshOptions()
|
flickerstreak@122
|
530 end
|
flickerstreak@122
|
531
|
flickerstreak@122
|
532 local function CornerUpdate()
|
flickerstreak@122
|
533 local bw, bh = GetButtonSize(bar)
|
flickerstreak@122
|
534 local r, c, s = GetButtonGrid(bar)
|
flickerstreak@122
|
535 local ss = GetStateScale(bar)
|
flickerstreak@122
|
536 if IsShiftKeyDown() then
|
flickerstreak@122
|
537 if ss then
|
flickerstreak@122
|
538 f:SetMinResize( ((s+bw)*c*0.25)/ss, ((s+bh)*r*0.25)/ss )
|
flickerstreak@122
|
539 f:SetMaxResize( ((s+bw)*c*2.5 + 1)/ss, ((s+bh)*r*2.5 + 1)/ss )
|
flickerstreak@154
|
540 scale = ComputeBarScale(bar, overlay)
|
flickerstreak@122
|
541 else
|
flickerstreak@122
|
542 f:SetMinResize( (s+12)*c+1, (s+12)*r+1 )
|
flickerstreak@122
|
543 f:SetMaxResize( (s+128)*c+1, (s+128)*r+1 )
|
flickerstreak@122
|
544 RecomputeButtonSize(bar)
|
flickerstreak@122
|
545 end
|
flickerstreak@122
|
546 elseif not ss and IsAltKeyDown() then
|
flickerstreak@122
|
547 f:SetMinResize( bw*c, bh*r )
|
flickerstreak@122
|
548 f:SetMaxResize( 2*bw*c, 2*bh*r )
|
flickerstreak@122
|
549 RecomputeButtonSpacing(bar)
|
flickerstreak@122
|
550 else
|
flickerstreak@122
|
551 f:SetMinResize( bw+s+1, bh+s+1 )
|
flickerstreak@122
|
552 f:SetMaxResize( 50*(bw+s)+1, 50*(bh+s)+1 )
|
flickerstreak@122
|
553 RecomputeGrid(bar)
|
flickerstreak@122
|
554 end
|
flickerstreak@122
|
555 GameTooltipTextRight2:SetText(format("%d x %d",r,c))
|
flickerstreak@122
|
556
|
flickerstreak@122
|
557 local ss = GetStateScale(bar)
|
flickerstreak@122
|
558 if ss then
|
flickerstreak@122
|
559 GameTooltipTextRight4:SetText(format("%d%%", scale*100))
|
flickerstreak@122
|
560 else
|
flickerstreak@122
|
561 local size = (bw == bh) and tostring(bw) or format("%d x %d",bw,bh)
|
flickerstreak@122
|
562 GameTooltipTextRight3:SetText(size)
|
flickerstreak@122
|
563 GameTooltipTextRight4:SetText(tostring(s))
|
flickerstreak@122
|
564 end
|
flickerstreak@122
|
565 end
|
flickerstreak@122
|
566
|
flickerstreak@122
|
567 -- corner drag handles
|
flickerstreak@122
|
568 for _, point in pairs({"BOTTOMLEFT","TOPLEFT","BOTTOMRIGHT","TOPRIGHT"}) do
|
flickerstreak@122
|
569 local corner = CreateFrame("Frame",nil,overlay)
|
flickerstreak@122
|
570 corner:EnableMouse(true)
|
flickerstreak@122
|
571 corner:SetWidth(16)
|
flickerstreak@122
|
572 corner:SetHeight(16)
|
flickerstreak@122
|
573 corner:SetPoint(point)
|
flickerstreak@122
|
574
|
flickerstreak@122
|
575 local tex = corner:CreateTexture(nil,"HIGHLIGHT")
|
flickerstreak@122
|
576 tex:SetTexture("Interface\\AddOns\\ReAction\\img\\corner")
|
flickerstreak@122
|
577 tex:SetTexCoord(unpack(cornerTexCoords[point]))
|
flickerstreak@122
|
578 tex:SetBlendMode("ADD")
|
flickerstreak@122
|
579 tex:SetAlpha(0.6)
|
flickerstreak@122
|
580 tex:SetAllPoints()
|
flickerstreak@122
|
581
|
flickerstreak@122
|
582 corner:SetScript("OnMouseDown",
|
flickerstreak@122
|
583 function(_,btn)
|
flickerstreak@122
|
584 f:SetScript("OnUpdate", CornerUpdate)
|
flickerstreak@122
|
585 f:StartSizing(point)
|
flickerstreak@122
|
586 end
|
flickerstreak@122
|
587 )
|
flickerstreak@122
|
588 corner:SetScript("OnMouseUp",
|
flickerstreak@122
|
589 function()
|
flickerstreak@122
|
590 local ss = GetStateScale(bar)
|
flickerstreak@122
|
591 if ss then
|
flickerstreak@154
|
592 SetStateScale(bar, ComputeBarScale(bar, overlay))
|
flickerstreak@122
|
593 end
|
flickerstreak@122
|
594 StopResize()
|
flickerstreak@122
|
595 end)
|
flickerstreak@122
|
596 corner:SetScript("OnEnter",
|
flickerstreak@122
|
597 function()
|
flickerstreak@122
|
598 local bw, bh = GetButtonSize(bar)
|
flickerstreak@122
|
599 local r, c, s = bar:GetButtonGrid()
|
flickerstreak@122
|
600 local size = (bw == bh) and tostring(bw) or format("%d x %d",bw,bh)
|
flickerstreak@122
|
601 local ss = GetStateScale(bar)
|
flickerstreak@155
|
602 local state = bar:GetSecureState()
|
flickerstreak@122
|
603 GameTooltip:SetOwner(f, "ANCHOR_"..point)
|
flickerstreak@122
|
604 if ss then
|
flickerstreak@122
|
605 GameTooltip:AddLine(format("%s (%s: %s)", bar:GetName(), L["State"], state))
|
flickerstreak@122
|
606 else
|
flickerstreak@122
|
607 GameTooltip:AddLine(bar:GetName())
|
flickerstreak@122
|
608 end
|
flickerstreak@122
|
609 GameTooltip:AddDoubleLine(format("|cffcccccc%s|r %s",L["Drag"],L["to add/remove buttons:"]), format("%d x %d",r,c))
|
flickerstreak@122
|
610 if ss then
|
flickerstreak@122
|
611 GameTooltip:AddLine(L["State Scale Override"])
|
flickerstreak@122
|
612 GameTooltip:AddDoubleLine(format("|cff00ff00%s|r %s",L["Hold Shift"],L["to change scale:"]), format("%d%%", bar:GetStateProperty(state,"scale")*100))
|
flickerstreak@122
|
613 else
|
flickerstreak@122
|
614 GameTooltip:AddDoubleLine(format("|cff00ff00%s|r %s",L["Hold Shift"],L["to resize buttons:"]), tostring(floor(size)))
|
flickerstreak@122
|
615 GameTooltip:AddDoubleLine(format("|cff0033cc%s|r %s",L["Hold Alt"], L["to change spacing:"]), tostring(floor(s)))
|
flickerstreak@122
|
616 end
|
flickerstreak@122
|
617 GameTooltip:Show()
|
flickerstreak@122
|
618 end
|
flickerstreak@122
|
619 )
|
flickerstreak@122
|
620 corner:SetScript("OnLeave",
|
flickerstreak@122
|
621 function()
|
flickerstreak@122
|
622 GameTooltip:Hide()
|
flickerstreak@122
|
623 f:SetScript("OnUpdate",nil)
|
flickerstreak@122
|
624 end
|
flickerstreak@122
|
625 )
|
flickerstreak@122
|
626 end
|
flickerstreak@122
|
627
|
flickerstreak@122
|
628 overlay:RegisterForDrag("LeftButton")
|
flickerstreak@122
|
629 overlay:RegisterForClicks("RightButtonUp")
|
flickerstreak@122
|
630
|
flickerstreak@122
|
631 overlay:SetScript("OnDragStart",
|
flickerstreak@122
|
632 function()
|
flickerstreak@122
|
633 f:StartMoving()
|
flickerstreak@122
|
634 f.isMoving = true
|
flickerstreak@122
|
635 local w,h = bar:GetButtonSize()
|
flickerstreak@122
|
636 f:ClearAllPoints()
|
flickerstreak@122
|
637 UpdateAnchorDecoration()
|
flickerstreak@122
|
638 f:SetScript("OnUpdate", function()
|
flickerstreak@122
|
639 if IsShiftKeyDown() then
|
flickerstreak@122
|
640 local f, p = DisplaySnapIndicator(f,w,h)
|
flickerstreak@122
|
641 else
|
flickerstreak@122
|
642 HideSnapIndicator()
|
flickerstreak@122
|
643 end
|
flickerstreak@122
|
644 end)
|
flickerstreak@122
|
645 end
|
flickerstreak@122
|
646 )
|
flickerstreak@122
|
647
|
flickerstreak@122
|
648 local function UpdateDragTooltip()
|
flickerstreak@122
|
649 GameTooltip:SetOwner(f, "ANCHOR_TOPRIGHT")
|
flickerstreak@122
|
650 local ss = GetStateScale(bar)
|
flickerstreak@155
|
651 local state = bar:GetSecureState()
|
flickerstreak@122
|
652 if ss then
|
flickerstreak@122
|
653 GameTooltip:AddLine(format("%s (%s: %s)", bar:GetName(), L["State"], state))
|
flickerstreak@122
|
654 else
|
flickerstreak@122
|
655 GameTooltip:AddLine(bar:GetName())
|
flickerstreak@122
|
656 end
|
flickerstreak@122
|
657 GameTooltip:AddLine(format("|cffcccccc%s|r %s",L["Drag"],L["to move"]))
|
flickerstreak@122
|
658 GameTooltip:AddLine(format("|cff00ff00%s|r %s",L["Hold Shift"],L["to anchor to nearby frames"]))
|
flickerstreak@122
|
659 GameTooltip:AddLine(format("|cff00cccc%s|r %s",L["Right-click"],L["for options..."]))
|
flickerstreak@122
|
660 local point, frame, relpoint, x, y = bar:GetFrame():GetPoint(1)
|
flickerstreak@122
|
661 if point then
|
flickerstreak@122
|
662 local ofsx, ofsy = insidePointOffsetFuncs[point](x,y)
|
flickerstreak@122
|
663 if (frame and frame ~= UIParent) or (ofsx == 0 and ofsy == 0) then
|
flickerstreak@122
|
664 frame = frame or UIParent
|
flickerstreak@122
|
665 GameTooltip:AddLine(format("%s <%s>",L["Currently anchored to"],frame:GetName()))
|
flickerstreak@122
|
666 end
|
flickerstreak@122
|
667 end
|
flickerstreak@122
|
668 GameTooltip:Show()
|
flickerstreak@122
|
669 end
|
flickerstreak@122
|
670
|
flickerstreak@122
|
671 overlay:SetScript("OnDragStop",
|
flickerstreak@122
|
672 function()
|
flickerstreak@122
|
673 f:StopMovingOrSizing()
|
flickerstreak@122
|
674 f.isMoving = false
|
flickerstreak@122
|
675 f:SetScript("OnUpdate",nil)
|
flickerstreak@122
|
676
|
flickerstreak@122
|
677 if IsShiftKeyDown() then
|
flickerstreak@122
|
678 local w, h = bar:GetButtonSize()
|
flickerstreak@122
|
679 local a, p, rp, x, y = GetClosestPointSnapped(f,w,h)
|
flickerstreak@122
|
680 if a then
|
flickerstreak@122
|
681 f:ClearAllPoints()
|
flickerstreak@122
|
682 f:SetPoint(p,a,rp,x,y)
|
flickerstreak@122
|
683 end
|
flickerstreak@122
|
684 HideSnapIndicator()
|
flickerstreak@122
|
685 end
|
flickerstreak@122
|
686
|
flickerstreak@122
|
687 StoreExtents(bar)
|
flickerstreak@122
|
688 ReAction:RefreshOptions()
|
flickerstreak@122
|
689 UpdateDragTooltip()
|
flickerstreak@122
|
690 UpdateAnchorDecoration()
|
flickerstreak@122
|
691 end
|
flickerstreak@122
|
692 )
|
flickerstreak@122
|
693
|
flickerstreak@122
|
694 overlay:SetScript("OnEnter",
|
flickerstreak@122
|
695 function()
|
flickerstreak@122
|
696 UpdateDragTooltip()
|
flickerstreak@122
|
697 end
|
flickerstreak@122
|
698 )
|
flickerstreak@122
|
699
|
flickerstreak@122
|
700 overlay:SetScript("OnLeave", HideGameTooltip)
|
flickerstreak@122
|
701
|
flickerstreak@122
|
702 overlay:SetScript("OnClick",
|
flickerstreak@122
|
703 function()
|
flickerstreak@122
|
704 ReAction:ShowEditor(bar)
|
flickerstreak@122
|
705 end
|
flickerstreak@122
|
706 )
|
flickerstreak@122
|
707
|
flickerstreak@122
|
708 function overlay:LIBKEYBOUND_ENABLED(evt)
|
flickerstreak@122
|
709 self:SetFrameLevel(1)
|
flickerstreak@122
|
710 end
|
flickerstreak@122
|
711
|
flickerstreak@122
|
712 function overlay:LIBKEYBOUND_DISABLED(evt)
|
flickerstreak@135
|
713 self:SetFrameLevel(10)
|
flickerstreak@122
|
714 end
|
flickerstreak@122
|
715
|
flickerstreak@122
|
716 function overlay:RefreshControls()
|
flickerstreak@122
|
717 UpdateAnchorDecoration()
|
flickerstreak@122
|
718 end
|
flickerstreak@122
|
719
|
flickerstreak@122
|
720 overlay:SetScript("OnShow", overlay.RefreshControls)
|
flickerstreak@122
|
721
|
flickerstreak@122
|
722 KB.RegisterCallback(overlay,"LIBKEYBOUND_ENABLED")
|
flickerstreak@122
|
723 KB.RegisterCallback(overlay,"LIBKEYBOUND_DISABLED")
|
flickerstreak@122
|
724
|
flickerstreak@122
|
725 if ReAction:GetKeybindMode() then
|
flickerstreak@122
|
726 overlay:SetFrameLevel(1)
|
flickerstreak@122
|
727 end
|
flickerstreak@122
|
728
|
flickerstreak@154
|
729 UpdateLabelString(overlay)
|
flickerstreak@122
|
730 UpdateAnchorDecoration()
|
flickerstreak@122
|
731
|
flickerstreak@122
|
732 return overlay
|
flickerstreak@122
|
733 end
|
flickerstreak@122
|
734
|
flickerstreak@122
|
735
|
flickerstreak@122
|
736 -- export methods to the Bar prototype
|
flickerstreak@154
|
737 Bar.Overlay = { }
|
flickerstreak@154
|
738 function Bar.Overlay:New( bar )
|
flickerstreak@154
|
739 return setmetatable( {frame = CreateControls(bar)}, {__index=self} )
|
flickerstreak@122
|
740 end
|
flickerstreak@122
|
741
|
flickerstreak@154
|
742 function Bar.Overlay:SetLabel(name)
|
flickerstreak@154
|
743 self.frame.labelName = name
|
flickerstreak@154
|
744 UpdateLabelString(self.frame)
|
flickerstreak@122
|
745 end
|
flickerstreak@122
|
746
|
flickerstreak@154
|
747 function Bar.Overlay:SetLabelSubtext(text)
|
flickerstreak@154
|
748 self.frame.labelSubtext = text
|
flickerstreak@154
|
749 UpdateLabelString(self.frame)
|
flickerstreak@122
|
750 end
|
flickerstreak@122
|
751
|
flickerstreak@154
|
752 function Bar.Overlay:Show()
|
flickerstreak@154
|
753 self.frame:Show()
|
flickerstreak@122
|
754 end
|
flickerstreak@154
|
755
|
flickerstreak@154
|
756 function Bar.Overlay:Hide()
|
flickerstreak@154
|
757 self.frame:Hide()
|
flickerstreak@154
|
758 end
|
flickerstreak@155
|
759
|
flickerstreak@155
|
760 function Bar.Overlay:IsShown()
|
flickerstreak@155
|
761 return self.frame:IsShown()
|
flickerstreak@155
|
762 end
|
flickerstreak@155
|
763
|
flickerstreak@155
|
764 function Bar.Overlay:RefreshControls()
|
flickerstreak@155
|
765 self.frame:RefreshControls()
|
flickerstreak@155
|
766 end |