diff 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
line wrap: on
line diff
--- a/Veneer.lua	Sun Jan 29 09:57:09 2017 -0500
+++ b/Veneer.lua	Sat Feb 25 11:42:07 2017 -0500
@@ -211,7 +211,7 @@
 function VeneerCore:GetClusterFromArgs (...)
   local primaryAnchor
   local insertPosition
-
+  local insertPriority
 
 
   local clusterTable = self.FrameClusters
@@ -226,25 +226,57 @@
       clusterTable = clusterTable[arg]
       print(strrep(' ', i)..'anchor cluster', i, arg)
     elseif argType == 'boolean' then
-      insertPosition = 1
+      if arg == true then
+        print('force top position')
+        insertPosition = 1
+        insertPriority = nil
+      end
+    elseif argType == 'number' then
+      insertPriority = arg
     end
   end
+
+  if insertPriority then
+    for i = 1, #clusterTable do
+      if clusterTable[i].anchorPriority and (clusterTable[i].anchorPriority > insertPriority) then
+        print('prioritized insert position:', insertPriority, insertPosition)
+        break
+      else
+        print('passing lower priority frame:', clusterTable[i]:GetName())
+      end
+      insertPosition = i
+    end
+  end
+
+
   if not primaryAnchor then
     primaryAnchor = 'CENTER'
     clusterTable[primaryAnchor] = clusterTable[primaryAnchor] or {}
     clusterTable = clusterTable[primaryAnchor]
+    print('using default anchor')
   end
+
   if not insertPosition then
     insertPosition = #clusterTable + 1
+    print('using default position')
   end
   return primaryAnchor, clusterTable, insertPosition
 end
 
+-- args: frame object, list of anchor groups, true for forced top, number for priority layer
 function VeneerCore:AddHandler(handler, ...)
   print('|cFFFFFF00*** Adding handler:', handler.moduleName or handler:GetName())
 
+
+  for k,v in pairs(VeneerHandlerMixin) do
+    if not handler[k] then
+      print(' * from mixin:', k)
+      handler[k] = v
+    end
+  end
+
   if not handler.anchorFrame then
-    local anchorGroup, clusterTable, clusterIndex = self:GetClusterFromArgs(...)
+    local anchorGroup, clusterTable, clusterIndex, clusterPriority = self:GetClusterFromArgs(...)
     if clusterIndex == 1 then
       for i, frame in ipairs(clusterTable) do
         frame.clusterIndex = i + 1
@@ -263,13 +295,6 @@
     print(' free frame')
   end
 
-  for k,v in pairs(VeneerHandlerMixin) do
-    if not handler[k] then
-      print(' * from mixin:', k)
-      handler[k] = v
-    end
-  end
-
   if handler.addonTrigger and not IsAddOnLoaded(handler.addonTrigger) then
     print('|cFFFF4400  -- dependency:', handler.addonTrigger)
     self.AddOnCheck[handler.addonTrigger] = self.AddOnCheck[handler.addonTrigger] or {}
@@ -322,8 +347,8 @@
     if anchorPoint ~= LE_FREE_FRAMES_GROUP then
       local lastFrame
       for index, frame in ipairs(cluster) do
-        print('  |cFF00FF00'..index, frame:GetName(), frame:IsVisible(), (lastFrame and ('|cFFFFFF00'..lastFrame:GetName()..'|r') or '|cFF00FFFFUIParent'))
-        if frame:IsVisible() then
+        print('  |cFF00FF00'..index, frame:GetName(), frame:IsShown(), (lastFrame and ('|cFFFFFF00'..lastFrame:GetName()..'|r') or '|cFF00FFFFUIParent'))
+        if frame:IsShown() then
 
           if frame.anchorFrame then
             print(frame.anchorPoint)
@@ -364,7 +389,7 @@
   local nextFrame
   for index, frame in ipairs(handler.anchorCluster) do
     print('  |cFF00FF00'..index, frame:GetName(), frame:IsVisible())
-    if frame:IsVisible() then
+    if frame:IsShown() then
       if frame ~= handler then
         anchorParent = frame
         anchorTo = ANCHOR_OFFSET_POINT[anchorPoint]
@@ -384,7 +409,7 @@
     end
   end
 
-  if handler:IsVisible() then
+  if handler:IsShown() then
     handler:SetPoint(anchorPoint, anchorParent, anchorTo, 0, 0)
   else
     if anchorParent and nextFrame then