changeset 277:4e325f1ea6e1

Construct the button name in the base class
author Flick
date Wed, 11 May 2011 11:27:36 -0700
parents 36a29870bf34
children 3dcfc0aad875 5b9c0164a491
files ActionButton.lua BagButton.lua Button.lua MultiCastButton.lua PetActionButton.lua StanceButton.lua VehicleExitButton.lua
diffstat 7 files changed, 11 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/ActionButton.lua	Wed May 11 11:11:59 2011 -0700
+++ b/ActionButton.lua	Wed May 11 11:27:36 2011 -0700
@@ -194,9 +194,7 @@
 ReAction:RegisterBarType(Action, true)
 
 function Action:New( config, bar, idx, idHint )
-  local name = format("ReAction_%s_Action_%d",bar:GetName(),idx)
- 
-  self = Super.New(self, name, config, bar, idx, "SecureActionButtonTemplate, ActionButtonTemplate" )
+  self = Super.New(self, config, bar, idx, "SecureActionButtonTemplate, ActionButtonTemplate" )
   self.barConfig = bar:GetConfig()
 
   local f = self:GetFrame()
--- a/BagButton.lua	Wed May 11 11:11:59 2011 -0700
+++ b/BagButton.lua	Wed May 11 11:27:36 2011 -0700
@@ -49,8 +49,6 @@
 --
 
 function BagBase:New( btnCfg, bar, idx, idHint )
-  local name = format("ReAction_%s_Bag_%d",bar:GetName(),idx)
-
   -- use a variable private leaf implementation class
   -- unlike traditional OO programming, we can initialize the leaf
   -- class before initializing its parent
@@ -60,7 +58,7 @@
   elseif idx == 6 then
     class = Keyring
   end
-  self = class:New(name, btnCfg, bar, idx)
+  self = class:New(btnCfg, bar, idx)
 
   local f = self:GetFrame()
   local config = self:GetConfig()
--- a/Button.lua	Wed May 11 11:11:59 2011 -0700
+++ b/Button.lua	Wed May 11 11:27:36 2011 -0700
@@ -27,14 +27,17 @@
     btnColumns = 12,
     spacing = 3
   },
-  barType = L["Button Bar"]
+  -- barType = L["Button Bar"],  -- derived classes must declare
+  -- buttonTypeID = "Button"     -- derived classes must declare
 } 
 
 ReAction.Button = Button -- export to ReAction
 
-function Button:New( name, config, bar, idx, inherits, buttonType )
+function Button:New( config, bar, idx, inherits, buttonType )
   buttonType = buttonType or "CheckButton"
 
+  local name = format("ReAction_%s_%s_%d",bar:GetName(), self.buttonTypeID, idx)
+
   -- create new self
   self = setmetatable( 
     { 
--- a/MultiCastButton.lua	Wed May 11 11:11:59 2011 -0700
+++ b/MultiCastButton.lua	Wed May 11 11:27:36 2011 -0700
@@ -341,9 +341,7 @@
     error("invalid index")
   end
 
-  local name = format("ReAction_%s_Totem_%d",bar:GetName(),idx)
- 
-  self = Super.New(self, name, btnConfig, bar, idx, "SecureActionButtonTemplate, ActionButtonTemplate" )
+  self = Super.New(self, btnConfig, bar, idx, "SecureActionButtonTemplate, ActionButtonTemplate" )
 
   local barFrame = bar:GetFrame()
   local f = self:GetFrame()
--- a/PetActionButton.lua	Wed May 11 11:11:59 2011 -0700
+++ b/PetActionButton.lua	Wed May 11 11:27:36 2011 -0700
@@ -79,9 +79,7 @@
 ReAction:RegisterBarType(Pet)
 
 function Pet:New( config, bar, idx, idHint )
-  local name = format("ReAction_%s_PetAction_%d",bar:GetName(),idx)
- 
-  self = Super.New(self, name, config, bar, idx, "SecureActionButtonTemplate, ActionButtonTemplate" )
+  self = Super.New(self, config, bar, idx, "SecureActionButtonTemplate, ActionButtonTemplate" )
 
   local f = self:GetFrame()
   if not f.autoCastTexture then
--- a/StanceButton.lua	Wed May 11 11:11:59 2011 -0700
+++ b/StanceButton.lua	Wed May 11 11:27:36 2011 -0700
@@ -53,9 +53,7 @@
 ReAction:RegisterBarType(Stance)
 
 function Stance:New( config, bar, idx, idHint )
-  local name = format("ReAction_%s_Stance_%d",bar:GetName(),idx)
- 
-  self = Super.New(self, name, config, bar, idx, "SecureActionButtonTemplate, ActionButtonTemplate" )
+  self = Super.New(self, config, bar, idx, "SecureActionButtonTemplate, ActionButtonTemplate" )
 
   local f = self:GetFrame()
   local barFrame = bar:GetFrame()
--- a/VehicleExitButton.lua	Wed May 11 11:11:59 2011 -0700
+++ b/VehicleExitButton.lua	Wed May 11 11:27:36 2011 -0700
@@ -29,9 +29,7 @@
 ReAction:RegisterBarType(VExitButton)
 
 function VExitButton:New( config, bar, idx )
-  local name = format("ReAction_%s_VehicleExit_%d",bar:GetName(),idx)
- 
-  self = Super.New(self, name, config, bar, idx, "SecureFrameTemplate, ActionButtonTemplate", "Button")
+  self = Super.New(self, config, bar, idx, "SecureFrameTemplate, ActionButtonTemplate", "Button")
 
   -- frame setup
   local f = self:GetFrame()