comparison Veneer.lua @ 108:a41f6b74709a

- Handler number and boolean cluster arguments as positioning priority layer and "always top" respectively - Use SetShown and IsShown instead of IsVisible in doing full re-anchor checks
author Nick@Zahhak
date Sat, 25 Feb 2017 11:42:07 -0500
parents ff00679a7817
children 26938ae258b7
comparison
equal deleted inserted replaced
107:ff00679a7817 108:a41f6b74709a
209 209
210 210
211 function VeneerCore:GetClusterFromArgs (...) 211 function VeneerCore:GetClusterFromArgs (...)
212 local primaryAnchor 212 local primaryAnchor
213 local insertPosition 213 local insertPosition
214 214 local insertPriority
215 215
216 216
217 local clusterTable = self.FrameClusters 217 local clusterTable = self.FrameClusters
218 for i = 1, select('#', ...) do 218 for i = 1, select('#', ...) do
219 local arg = select(i, ...) 219 local arg = select(i, ...)
224 end 224 end
225 clusterTable[arg] = clusterTable[arg] or {} 225 clusterTable[arg] = clusterTable[arg] or {}
226 clusterTable = clusterTable[arg] 226 clusterTable = clusterTable[arg]
227 print(strrep(' ', i)..'anchor cluster', i, arg) 227 print(strrep(' ', i)..'anchor cluster', i, arg)
228 elseif argType == 'boolean' then 228 elseif argType == 'boolean' then
229 insertPosition = 1 229 if arg == true then
230 end 230 print('force top position')
231 end 231 insertPosition = 1
232 insertPriority = nil
233 end
234 elseif argType == 'number' then
235 insertPriority = arg
236 end
237 end
238
239 if insertPriority then
240 for i = 1, #clusterTable do
241 if clusterTable[i].anchorPriority and (clusterTable[i].anchorPriority > insertPriority) then
242 print('prioritized insert position:', insertPriority, insertPosition)
243 break
244 else
245 print('passing lower priority frame:', clusterTable[i]:GetName())
246 end
247 insertPosition = i
248 end
249 end
250
251
232 if not primaryAnchor then 252 if not primaryAnchor then
233 primaryAnchor = 'CENTER' 253 primaryAnchor = 'CENTER'
234 clusterTable[primaryAnchor] = clusterTable[primaryAnchor] or {} 254 clusterTable[primaryAnchor] = clusterTable[primaryAnchor] or {}
235 clusterTable = clusterTable[primaryAnchor] 255 clusterTable = clusterTable[primaryAnchor]
236 end 256 print('using default anchor')
257 end
258
237 if not insertPosition then 259 if not insertPosition then
238 insertPosition = #clusterTable + 1 260 insertPosition = #clusterTable + 1
261 print('using default position')
239 end 262 end
240 return primaryAnchor, clusterTable, insertPosition 263 return primaryAnchor, clusterTable, insertPosition
241 end 264 end
242 265
266 -- args: frame object, list of anchor groups, true for forced top, number for priority layer
243 function VeneerCore:AddHandler(handler, ...) 267 function VeneerCore:AddHandler(handler, ...)
244 print('|cFFFFFF00*** Adding handler:', handler.moduleName or handler:GetName()) 268 print('|cFFFFFF00*** Adding handler:', handler.moduleName or handler:GetName())
245 269
270
271 for k,v in pairs(VeneerHandlerMixin) do
272 if not handler[k] then
273 print(' * from mixin:', k)
274 handler[k] = v
275 end
276 end
277
246 if not handler.anchorFrame then 278 if not handler.anchorFrame then
247 local anchorGroup, clusterTable, clusterIndex = self:GetClusterFromArgs(...) 279 local anchorGroup, clusterTable, clusterIndex, clusterPriority = self:GetClusterFromArgs(...)
248 if clusterIndex == 1 then 280 if clusterIndex == 1 then
249 for i, frame in ipairs(clusterTable) do 281 for i, frame in ipairs(clusterTable) do
250 frame.clusterIndex = i + 1 282 frame.clusterIndex = i + 1
251 end 283 end
252 end 284 end
261 handler.anchorIndex = #clusterTable+1 293 handler.anchorIndex = #clusterTable+1
262 tinsert(clusterTable, handler.anchorIndex, handler) 294 tinsert(clusterTable, handler.anchorIndex, handler)
263 print(' free frame') 295 print(' free frame')
264 end 296 end
265 297
266 for k,v in pairs(VeneerHandlerMixin) do
267 if not handler[k] then
268 print(' * from mixin:', k)
269 handler[k] = v
270 end
271 end
272
273 if handler.addonTrigger and not IsAddOnLoaded(handler.addonTrigger) then 298 if handler.addonTrigger and not IsAddOnLoaded(handler.addonTrigger) then
274 print('|cFFFF4400 -- dependency:', handler.addonTrigger) 299 print('|cFFFF4400 -- dependency:', handler.addonTrigger)
275 self.AddOnCheck[handler.addonTrigger] = self.AddOnCheck[handler.addonTrigger] or {} 300 self.AddOnCheck[handler.addonTrigger] = self.AddOnCheck[handler.addonTrigger] or {}
276 tinsert(self.AddOnCheck[handler.addonTrigger], handler) 301 tinsert(self.AddOnCheck[handler.addonTrigger], handler)
277 end 302 end
320 print('|cFF88FF00DynamicReanchor()') 345 print('|cFF88FF00DynamicReanchor()')
321 for anchorPoint, cluster in pairs(parent.FrameClusters) do 346 for anchorPoint, cluster in pairs(parent.FrameClusters) do
322 if anchorPoint ~= LE_FREE_FRAMES_GROUP then 347 if anchorPoint ~= LE_FREE_FRAMES_GROUP then
323 local lastFrame 348 local lastFrame
324 for index, frame in ipairs(cluster) do 349 for index, frame in ipairs(cluster) do
325 print(' |cFF00FF00'..index, frame:GetName(), frame:IsVisible(), (lastFrame and ('|cFFFFFF00'..lastFrame:GetName()..'|r') or '|cFF00FFFFUIParent')) 350 print(' |cFF00FF00'..index, frame:GetName(), frame:IsShown(), (lastFrame and ('|cFFFFFF00'..lastFrame:GetName()..'|r') or '|cFF00FFFFUIParent'))
326 if frame:IsVisible() then 351 if frame:IsShown() then
327 352
328 if frame.anchorFrame then 353 if frame.anchorFrame then
329 print(frame.anchorPoint) 354 print(frame.anchorPoint)
330 frame:SetPoint(frame.anchorPoint, frame.anchorFrame, frame.anchorFrom, frame.anchorX, frame.anchorY) 355 frame:SetPoint(frame.anchorPoint, frame.anchorFrame, frame.anchorFrom, frame.anchorX, frame.anchorY)
331 print(frame:GetTop(), frame:GetRight()) 356 print(frame:GetTop(), frame:GetRight())
362 local anchorParent, anchorTo = UIParent, anchorPoint 387 local anchorParent, anchorTo = UIParent, anchorPoint
363 local subPoint, subTo 388 local subPoint, subTo
364 local nextFrame 389 local nextFrame
365 for index, frame in ipairs(handler.anchorCluster) do 390 for index, frame in ipairs(handler.anchorCluster) do
366 print(' |cFF00FF00'..index, frame:GetName(), frame:IsVisible()) 391 print(' |cFF00FF00'..index, frame:GetName(), frame:IsVisible())
367 if frame:IsVisible() then 392 if frame:IsShown() then
368 if frame ~= handler then 393 if frame ~= handler then
369 anchorParent = frame 394 anchorParent = frame
370 anchorTo = ANCHOR_OFFSET_POINT[anchorPoint] 395 anchorTo = ANCHOR_OFFSET_POINT[anchorPoint]
371 396
372 else 397 else
382 break 407 break
383 end 408 end
384 end 409 end
385 end 410 end
386 411
387 if handler:IsVisible() then 412 if handler:IsShown() then
388 handler:SetPoint(anchorPoint, anchorParent, anchorTo, 0, 0) 413 handler:SetPoint(anchorPoint, anchorParent, anchorTo, 0, 0)
389 else 414 else
390 if anchorParent and nextFrame then 415 if anchorParent and nextFrame then
391 nextFrame:SetPoint(subPoint, handler, subTo, 0, 0) 416 nextFrame:SetPoint(subPoint, handler, subTo, 0, 0)
392 end 417 end