diff ObjectiveTracker/Widgets.lua @ 38:1f8f9cc3d956

- module integration brought up to speed with current frame management structure
author Nenue
date Thu, 21 Apr 2016 11:36:41 -0400
parents e84d645c8ab8
children 92534dc793f2
line wrap: on
line diff
--- a/ObjectiveTracker/Widgets.lua	Mon Apr 18 07:56:23 2016 -0400
+++ b/ObjectiveTracker/Widgets.lua	Thu Apr 21 11:36:41 2016 -0400
@@ -101,7 +101,7 @@
 
 local OnClick = {}
 OnClick.CloseButton = function(self)
-  T:SetEnabled()
+  T:Enable()
   if T.Conf.enabled then
     T:Update()
   end
@@ -275,7 +275,7 @@
 
 --- Get a usable widget for the given achievement criteria set.
 -- Returns a frame object with dimensioning parameters needed to size the receiving tracker block
-T.SetWidget = function(line, data, objectiveType, objectiveKey)
+T.GetWidget = function(data, objectiveType, objectiveKey)
   local print = B.print('ObjectiveWidgets')
   local widgetType = objectiveType
   local widget
@@ -283,8 +283,7 @@
     widget = wr[widgetType].used[objectiveKey]
     print('|cFF00FF00Updating ('..objectiveKey..')', widget)
   elseif not wr[widgetType] or #wr[widgetType].free == 0 then
-    widget = CreateFrame('Frame', 'VeneerObjective' .. widgetType .. (wr[widgetType] and (wr[widgetType].lastn+1) or (1)), VeneerObjectiveScroll, 'VeneerObjectiveCriteria' .. widgetType)
-
+    widget = CreateFrame(widgetType, 'VeneerObjective' .. widgetType .. (wr[widgetType] and (wr[widgetType].lastn+1) or (1)), VeneerObjectiveScroll, 'VeneerObjectiveCriteria' .. widgetType)
     print('|cFFFF0088Creating `'..widget:GetName()..'` id', wr[widgetType].lastn)
   else
     widget = tremove(wr[widgetType].free)
@@ -293,7 +292,6 @@
 
 
   wr[widgetType].used[objectiveKey] = widget
-  widget.line = line
   widget.objective = data
   widget.key = objectiveKey
   T.InitializeWidget(widget)
@@ -397,7 +395,7 @@
 local progressFont = _G.VeneerCriteriaFontNormal
 
 local lprint = B.print('Line')
-T.InitializeWidget.ProgressBar = function(self)
+T.InitializeWidget.StatusBar = function(self)
   local print = lprint
   local c = T.Conf.Wrapper
   self.height = progressHeight + c.TextSpacing
@@ -406,35 +404,27 @@
   self.maxValue = self.maxValue or 1
 
   self:SetHeight(progressHeight)
-  self.bg:SetHeight(progressHeight)
-  self.bg:SetWidth(self.width)
-  self.fg:ClearAllPoints()
-  self.fg:SetPoint('BOTTOMLEFT', self, 'BOTTOMLEFT', progressBorder, progressBorder)
-  self.fg:SetHeight(progressHeight - progressBorder *  2)
+  self:SetMinMaxValues(0, self.maxValue)
+  self:SetValue(self.value)
 
   --self.status:SetFontObject(progressFont)
   self.status:SetText(self.objective.quantityString)
 end
 
-T.UpdateWidget.ProgressBar = function (self)
-  local quantity, requiredQuantity = self.value, self.maxValue
+T.UpdateWidget.StatusBar = function (self)
+  local value, maxValue = self.value, self.maxValue
   print('update vals:')
-  for k,v in pairs(self.line) do
+  for k,v in pairs(self) do
     print(k, v)
   end
-
-  local progress = (quantity / requiredQuantity)
-  if progress >= 1 then
-    self.fg:Show()
-    self.fg:SetWidth(self.width  - progressBorder * 2)
-  elseif progress > 0 then
-    self.fg:Show()
+  self:SetValue(self.value)
+  local format = self.format or '%d/%d'
+  self.status:SetFormattedText(format, value, maxValue)
+  local progress = (value / maxValue)
+  if progress > 0 then
     print('color:', 1-progress*2 , progress*2 - 1,0,1)
     print('width:', (self.width  -progressBorder * 2) * progress)
-    self.fg:SetTexture(1-progress*2 , progress*2,0,1)
-    self.fg:SetWidth((self.width  -progressBorder * 2) * progress)
-  else
-    self.fg:Hide()
+    self:SetStatusBarColor(1-progress*2 , progress*2,0,1)
   end
 end