diff ObjectiveTracker/Frame.lua @ 37:e84d645c8ab8

- revised the tracker update function to build its complete data list up front and use the values as points of comparison for determining possible out of place blocks, which will be iterated over afterward to remove what wasn't re-used - also entailed revising the exact role of global event handlers and function hooks, limiting their directions of communication so one doesn't end up calling the other multiple or inifinity times - schema handling polish
author Nenue
date Mon, 18 Apr 2016 07:56:23 -0400
parents a487841050be
children 1f8f9cc3d956
line wrap: on
line diff
--- a/ObjectiveTracker/Frame.lua	Sun Apr 17 13:00:31 2016 -0400
+++ b/ObjectiveTracker/Frame.lua	Mon Apr 18 07:56:23 2016 -0400
@@ -30,7 +30,7 @@
 local orderedNames = T.orderedNames
 
 --- FRAME TEMP VARIABLES
-local wrapperWidth, wrapperHeight
+local wrapperWidth, wrapperHeight = 0, 0
 local scrollWidth, scrollHeight
 
 --- SCHEMA VARIABLES
@@ -80,26 +80,27 @@
     headerHeight, headerSpacing = c.headerHeight, c.headerSpacing
     headerColor = c.headerColor
     headerbg = c.headerbg
-    headerFont, headerSize, headerOutline = c.headerFont, c.headerSize, c.headerOutline
+    headerFont, headerSize, headerOutline = unpack(c.headerFont)
     trackerSchema = newSchema
   elseif layer == 'block' then
     titlebg = c.titlebg
-    titleFont, titleSize, titleOutline = c.titleFont, c.titleSize, c.titleOutline
+    titleFont, titleSize, titleOutline = unpack(c.titleFont)
     selectionbg = c.selectionbg
     titleSpacing, textSpacing, blockSpacing = c.titleSpacing, c.textSpacing, c.blockSpacing
-    titleIndent, textIndent,selectionIndent = 2, 5, 50
+    titleIndent, textIndent,selectionIndent = c.titleIndex, c.textIndex, c.selectionIndent
     titleColor = c.titleColor
+    print(unpack(c.titleColor))
     rewardSize = 24
-    blockSchema = newSchema
-    textFont, textSize, textOutline = c.textFont, c.textSize, c.textOutline
+    textFont, textSize, textOutline = unpack(c.textFont)
     textbg =  c.textbg
     textIndent = c.textIndent
     rewardSize = c.rewardSize
+    blockSchema = newSchema
   elseif layer == 'line' then
     textColor = c.textColor
     lineSchema = newSchema
   end
-  print('|cFFFF0088UpdateSchema:|r', layer, lastSchema[layer], '->', newSchema)
+  tprint('|cFFFF0088UpdateSchema:|r', layer, lastSchema[layer], '->', newSchema)
 end
 -- todo: figure out why objectives go invisible
 local anchorPoint, anchorFrame
@@ -146,7 +147,7 @@
 
     end)
   else
-    print('  |cFF00BBFFpinning to', anchorFrame:GetName(), anchorPoint, '|rcurrent frame height:', frame.height)
+    print('  |cFF00BBFFpinning '..handler.name..' to', anchorFrame:GetName(), anchorPoint, '|rcurrent frame height:', frame.height)
     print('  |cFFFF0088total height:', wrapperHeight)
     frame:ClearAllPoints()
     frame:SetParent(Scroll)
@@ -183,37 +184,40 @@
 
   block.index = blockIndex
 
+  print('blockschema', blockSchema, block.schema)
   if blockSchema ~= block.schema then
+    T.UpdateSchema('block', block.schema)
     print('new schema detected, applicating...')
-    block.schema = blockSchema
-    block:SetWidth(T.Conf.Wrapper.Width)
-    block.title:SetSpacing(titleSpacing)
-    block.title:SetPoint('TOP', block, 'TOP', 0, -titleSpacing)
-    block.title:SetPoint('LEFT', block, 'LEFT', titleIndent, 0)
-    block.titlebg:SetTexture(1,1,1,1)
-    block.titlebg:SetGradientAlpha(unpack(titlebg))
-    block.titlebg:SetPoint('TOP', block, 'TOP', 0, 0)
-    block.titlebg:SetPoint('BOTTOM', block.title, 'BOTTOM', 0, -titleSpacing)
-    block.status:SetSpacing(textSpacing)
-    block.status:SetPoint('TOP', block.titlebg, 'BOTTOM', 0, -textSpacing)
-    block.status:SetPoint('LEFT', block.titlebg, 'LEFT', textIndent, 0)
-    block.statusbg:SetPoint('TOP', block.titlebg, 'BOTTOM', 0, 0)
-    block.statusbg:SetPoint('BOTTOM', block, 'BOTTOM', 0, 0)
-    block.statusbg:SetTexture(1,1,1,1)
-    block.statusbg:SetGradientAlpha(unpack(textbg))
-    block.SelectionOverlay:SetGradientAlpha(unpack(selectionbg))
-    block.SelectionOverlay:SetPoint('TOPLEFT', selectionIndent, 0)
-    block.SelectionOverlay:SetPoint('BOTTOMRIGHT')
+  end
 
-    local anchor, target, point, x, y = 'TOPRIGHT', block, 'TOPRIGHT', -2, -2
-    for i, tile in ipairs(block.rewardTile)  do
-      print(rewardSize)
-      tile:SetSize(rewardSize, rewardSize)
-      tile:ClearAllPoints()
-      tile:SetPoint(anchor, target, point, x, y)
-      block.rewardLabel[i]:SetPoint('TOP', tile, 'TOP', 0, 0)
-      anchor, target, point, x, y = 'TOPRIGHT', tile, 'TOPLEFT', -2, 0
-    end
+  block:SetWidth(T.Conf.Wrapper.Width)
+  block.title:SetSpacing(titleSpacing)
+  block.title:SetPoint('TOP', block, 'TOP', 0, -titleSpacing)
+  block.title:SetPoint('LEFT', block, 'LEFT', titleIndent, 0)
+  block.title:SetTextColor(unpack(titleColor))
+  block.titlebg:SetTexture(1,1,1,1)
+  block.titlebg:SetGradientAlpha(unpack(titlebg))
+  block.titlebg:SetPoint('TOP', block, 'TOP', 0, 0)
+  block.titlebg:SetPoint('BOTTOM', block.title, 'BOTTOM', 0, -titleSpacing)
+  block.status:SetSpacing(textSpacing)
+  block.status:SetPoint('TOP', block.titlebg, 'BOTTOM', 0, -textSpacing)
+  block.status:SetPoint('LEFT', block.titlebg, 'LEFT', textIndent, 0)
+  block.statusbg:SetPoint('TOP', block.titlebg, 'BOTTOM', 0, 0)
+  block.statusbg:SetPoint('BOTTOM', block, 'BOTTOM', 0, 0)
+  block.statusbg:SetTexture(1,1,1,1)
+  block.statusbg:SetGradientAlpha(unpack(textbg))
+  block.SelectionOverlay:SetGradientAlpha(unpack(selectionbg))
+  block.SelectionOverlay:SetPoint('TOPLEFT', selectionIndent, 0)
+  block.SelectionOverlay:SetPoint('BOTTOMRIGHT')
+
+  local anchor, target, point, x, y = 'TOPRIGHT', block, 'TOPRIGHT', -2, -2
+  for i, tile in ipairs(block.rewardTile)  do
+    --print(rewardSize)
+    tile:SetSize(rewardSize, rewardSize)
+    tile:ClearAllPoints()
+    tile:SetPoint(anchor, target, point, x, y)
+    block.rewardLabel[i]:SetPoint('TOP', tile, 'TOP', 0, 0)
+    anchor, target, point, x, y = 'TOPRIGHT', tile, 'TOPLEFT', -2, 0
   end
 
 
@@ -302,6 +306,9 @@
     end
   end
   line:SetPoint('TOP', block.endPoint, 'BOTTOM', 0, -textSpacing)
+  line.status:SetPoint('LEFT', line, 'LEFT', textIndent, 0)
+  line:SetPoint('LEFT', block, 'LEFT')
+  line:SetPoint('RIGHT', block, 'RIGHT')
   line:Show()
 
 
@@ -360,7 +367,7 @@
     local line = lines[lineIndex]
     line.index = lineIndex
     line.height = 0
-    line.schema = 'default'
+    line.schema = ''
     B.SetConfigLayers(line)
 
     if debug then
@@ -377,10 +384,10 @@
 
 --- Creates or retrieves a complete block frame object
 --- todo: make it use data index to avoid re-coloring every block
-Default.GetBlock = function(handler, logIndex)
+Default.GetBlock = function(handler, index)
   local print = bprint
-  print('|cFF0088FFgetting a block for logID', logIndex ..',', #handler.usedBlocks,'used', #handler.freeBlocks, 'free')
-  local block = handler.LogBlock[logIndex]
+  print('|cFF0088FFgetting a block for index', index ..',', #handler.usedBlocks,'used', #handler.freeBlocks, 'free')
+  local block = handler.InfoBlock[index]
   local used = handler.usedBlocks
 
   if not block then
@@ -394,6 +401,7 @@
       local blockIndex = (#handler.usedBlocks + #handler.freeBlocks) + 1
       block = CreateFrame('Frame', 'Veneer'..tostring(handler)..'Block'..blockIndex, handler.frame, 'VeneerTrackerBlock')
       --block:SetParent()
+      block.schema = ''
       block.lines = {}
       block.numLines = 0
       block.currentLine = 0
@@ -412,7 +420,7 @@
       block.index = blockIndex
       print('  |cFF00FFBBcreating new|r', block:GetName())
     end
-    handler.LogBlock[logIndex] = block
+    handler.InfoBlock[index] = block
     tinsert(handler.usedBlocks, block)
     block.posIndex = #handler.usedBlocks
   else