diff classes/Overlay.lua @ 155:806a61b331a0

Pushed the state implementation into Bar
author Flick <flickerstreak@gmail.com>
date Fri, 15 May 2009 22:38:19 +0000
parents df67685b340e
children 8cc187143acd
line wrap: on
line diff
--- a/classes/Overlay.lua	Fri May 08 17:30:22 2009 +0000
+++ b/classes/Overlay.lua	Fri May 15 22:38:19 2009 +0000
@@ -27,7 +27,7 @@
 -- Wrap some of the bar manipulators to make them state-aware
 --
 local function SetAnchor( bar, point, frame, relPoint, x, y )
-  local state = bar:GetState()
+  local state = bar:GetSecureState()
   if state then
     local anchorstate = bar:GetStateProperty(state, "anchorEnable")
     if anchorstate then
@@ -44,14 +44,14 @@
 end
 
 local function GetStateScale( bar )
-  local state = bar:GetState()
+  local state = bar:GetSecureState()
   if state and bar:GetStateProperty(state, "enableScale") then
     return bar:GetStateProperty(state, "scale")
   end
 end
 
 local function SetStateScale( bar, scale )
-  local state = bar:GetState()
+  local state = bar:GetSecureState()
   if state and bar:GetStateProperty(state, "enableScale") then
     bar:SetStateProperty(state, "scale", scale)
   end
@@ -557,7 +557,6 @@
     GameTooltipTextRight2:SetText(format("%d x %d",r,c))
 
     local ss = GetStateScale(bar)
-    local state = bar:GetState()
     if ss then
       GameTooltipTextRight4:SetText(format("%d%%", scale*100))
     else
@@ -592,7 +591,6 @@
       function()
         local ss = GetStateScale(bar)
         if ss then
-          local state = bar:GetState()
           SetStateScale(bar, ComputeBarScale(bar, overlay))
         end
         StopResize()
@@ -603,7 +601,7 @@
         local r, c, s = bar:GetButtonGrid()
         local size = (bw == bh) and tostring(bw) or format("%d x %d",bw,bh)
         local ss = GetStateScale(bar)
-        local state = bar:GetState()
+        local state = bar:GetSecureState()
         GameTooltip:SetOwner(f, "ANCHOR_"..point)
         if ss then
           GameTooltip:AddLine(format("%s (%s: %s)", bar:GetName(), L["State"], state))
@@ -652,7 +650,7 @@
   local function UpdateDragTooltip()
     GameTooltip:SetOwner(f, "ANCHOR_TOPRIGHT")
     local ss = GetStateScale(bar)
-    local state = bar:GetState()
+    local state = bar:GetSecureState()
     if ss then
       GameTooltip:AddLine(format("%s (%s: %s)", bar:GetName(), L["State"], state))
     else
@@ -760,3 +758,11 @@
 function Bar.Overlay:Hide()
   self.frame:Hide()
 end
+
+function Bar.Overlay:IsShown()
+  return self.frame:IsShown()
+end
+
+function Bar.Overlay:RefreshControls()
+  self.frame:RefreshControls()
+end
\ No newline at end of file