diff Overlay.lua @ 90:7cabc8ac6c16

Updates for wow 3.0 - TOC update - updated changed APIs/frame names - rewrote state code per new SecureHandlers API - cleaned up Bar, ActionButton code - removed AceLibrary/Dewdrop, menu from bar right-click - fixed various small bugs Updated WowAce external locations Updated README.html
author Flick <flickerstreak@gmail.com>
date Wed, 15 Oct 2008 16:29:41 +0000
parents 42ec2938d65a
children 5f1d7a81317c
line wrap: on
line diff
--- a/Overlay.lua	Mon Oct 13 23:32:33 2008 +0000
+++ b/Overlay.lua	Wed Oct 15 16:29:41 2008 +0000
@@ -1,96 +1,36 @@
-local ReAction = ReAction
-local L = ReAction.L
-local CreateFrame = CreateFrame
+local ReAction         = ReAction
+local L                = ReAction.L
+local CreateFrame      = CreateFrame
 local InCombatLockdown = InCombatLockdown
-local floor = math.floor
-local min = math.min
-local format = string.format
-local GameTooltip = GameTooltip
+local floor            = math.floor
+local min              = math.min
+local format           = string.format
+local GameTooltip      = GameTooltip
+local Bar              = ReAction.Bar
+local GetSize          = Bar.GetSize
+local GetButtonSize    = Bar.GetButtonSize
+local GetButtonGrid    = Bar.GetButtonGrid
+local SetSize          = Bar.SetSize
+local SetAnchor        = Bar.SetAnchor
+local SetButtonSize    = Bar.SetButtonSize
+local SetButtonGrid    = Bar.SetButtonGrid
+local ApplyAnchor      = Bar.ApplyAnchor
 
 ReAction:UpdateRevision("$Revision$")
 
--- Looking for a lightweight AceConfig3-struct-compatible 
--- replacement for Dewdrop (e.g. forthcoming AceConfigDropdown-3.0?).
--- Considering Blizzard's EasyMenu/UIDropDownMenu, but that's
--- a bit tricky to convert from AceConfig3-struct
-local Dewdrop = AceLibrary("Dewdrop-2.0")
-
-local function OpenMenu (frame, opts)
-  Dewdrop:Open(frame, "children", opts, "cursorX", true, "cursorY", true)
-end
-
-local function CloseMenu(frame)
-  if Dewdrop:GetOpenedParent() == frame then
-    Dewdrop:Close()
-  end
-end
-
-local function ShowMenu(bar)
-  if not bar.menuOpts then
-    bar.menuOpts = {
-      type = "group",
-      args = {
-        openConfig = {
-          type = "execute",
-          name = L["Settings..."],
-          desc = L["Open the editor for this bar"],
-          func = function() CloseMenu(bar.controlFrame); ReAction:ShowEditor(bar) end,
-          disabled = InCombatLockdown,
-          order = 1
-        },
-        delete = {
-          type = "execute",
-          name = L["Delete Bar"],
-          desc = L["Remove the bar from the current profile"],
-          confirm = L["Are you sure you want to remove this bar?"],
-          func = function() ReAction:EraseBar(bar) end,
-          order = 2
-        },
-      }
-    }
-  end
-  OpenMenu(bar.controlFrame, bar.menuOpts)
-end
-
-
 --
 -- Bar config overlay
 --
--- localize some of these for small OnUpdate performance boost
-local Bar           = ReAction.Bar
-local GetSize       = Bar.GetSize
-local GetButtonSize = Bar.GetButtonSize
-local GetButtonGrid = Bar.GetButtonGrid
-local SetSize       = Bar.SetSize
-local SetButtonSize = Bar.SetButtonSize
-local SetButtonGrid = Bar.SetButtonGrid
-local ApplyAnchor   = Bar.ApplyAnchor
+
+local function StoreSize(bar)
+  local f = bar:GetFrame()
+  SetSize( bar, f:GetWidth(), f:GetHeight() )
+end
 
 local function StoreExtents(bar)
   local f = bar:GetFrame()
-  local point, relativeTo, relativePoint, x, y = f:GetPoint(1)
-  relativeTo = relativeTo or f:GetParent()
-  local anchorTo
-  for name, b in ReAction:IterateBars() do
-    if b and b:GetFrame() == relativeTo then
-      anchorTo = name
-      break
-    end
-  end
-  anchorTo = anchorTo or relativeTo:GetName()
-  local c = bar.config
-  c.anchor = point
-  c.anchorTo = anchorTo
-  c.relativePoint = relativePoint
-  c.x = x
-  c.y = y
-  c.width, c.height = f:GetWidth(), f:GetHeight()
-end
-
-local function StoreSize(bar)
-  local f = bar:GetFrame()
-  local c = bar.config
-  c.width, c.height = f:GetWidth(), f:GetHeight()
+  SetAnchor( bar, f:GetPoint(1) )
+  SetSize( bar, f:GetWidth(), f:GetHeight() )
 end
 
 local function RecomputeButtonSize(bar)
@@ -449,7 +389,7 @@
   label:SetTextColor(1,1,1,1)
   label:SetText(bar:GetName())
   label:Show()
-  bar.controlLabelString = label  -- so that bar:SetName() can update it
+  bar.controlLabelString = label  -- so that bar:SetLabel() can update it
 
   local function StopResize()
     f:StopMovingOrSizing()
@@ -457,7 +397,7 @@
     f:SetScript("OnUpdate",nil)
     StoreSize(bar)
     ClampToButtons(bar)
-    ApplyAnchor(bar)
+    --ApplyAnchor(bar)
     ReAction:RefreshOptions()
   end
 
@@ -648,15 +588,17 @@
 
   control:SetScript("OnClick",
     function()
-      ShowMenu(bar)
+      ReAction:ShowEditor(bar)
     end
   )
 
+  control:Raise()
+
   return control
 end
 
 
--- export the ShowControls method to the Bar prototype
+-- export methods to the Bar prototype
 
 function Bar:ShowControls(show)
   if show then
@@ -666,9 +608,12 @@
     self.controlFrame:Show()
     self.controlFrame:Raise()
   elseif self.controlFrame then
-    CloseMenu(self.controlFrame)
     self.controlFrame:Hide()
   end
 end
 
-
+function Bar:SetLabel(name)
+  if self.controlLabelString then
+    self.controlLabelString:SetText(self.name)
+  end
+end