diff modules/ReAction_Action/ReAction_Action.lua @ 49:dcf8116560a1

added hide empty buttons
author Flick <flickerstreak@gmail.com>
date Mon, 14 Apr 2008 23:03:19 +0000
parents 7b7d178dec52
children c3c64e2def50
line wrap: on
line diff
--- a/modules/ReAction_Action/ReAction_Action.lua	Sat Apr 12 00:15:09 2008 +0000
+++ b/modules/ReAction_Action/ReAction_Action.lua	Mon Apr 14 23:03:19 2008 +0000
@@ -28,6 +28,15 @@
     }
   )
   self.buttons = { }
+
+  ReAction:RegisterOptions("global", self, {
+    hideEmpty = {
+      type = "toggle",
+      name = L["Hide Empty Buttons"],
+      get  = function() return self.db.profile.hideEmptyButtons end,
+      set  = function(info, val) module:SetHideEmptyButtons(val) end,
+    }
+  })
 end
 
 function module:OnEnable()
@@ -99,12 +108,28 @@
   b[newname], b[oldname] = b[oldname], nil
 end
 
+function module:SetHideEmptyButtons(hide)
+  if hide ~= self.db.profile.hideEmptyButtons then
+    for _, bar in pairs(self.buttons) do
+      for _, b in pairs(bar) do
+        if hide then
+          ActionButton_HideGrid(b.frame)
+        else
+          ActionButton_ShowGrid(b.frame)
+        end
+      end
+    end
+    self.db.profile.hideEmptyButtons = hide
+  end
+end
+
 function module:ApplyConfigMode(mode,bars)
-  for _, btns in pairs(self.buttons) do
-    if btn then
-      for _, b in pairs(btns) do
+  for _, bar in pairs(bars) do
+    if bar and self.buttons[bar] then
+      for _, b in pairs(self.buttons[bar]) do
         if b then
           if mode then
+            ActionButton_ShowGrid(b.frame)
             if not b.actionIDLabel then
               local label = b:GetFrame():CreateFontString(nil,"OVERLAY","GameFontNormalLarge")
               label:SetAllPoints()
@@ -115,9 +140,13 @@
               b.actionIDLabel = label
             end
             b.actionIDLabel:Show()
-          elseif b.actionIDLabel then
-            b.actionIDLabel:Hide()
+          else
+            if b.actionIDLabel then
+              b.actionIDLabel:Hide()
+            end
+            ActionButton_HideGrid(b.frame)
           end
+
         end
       end
     end
@@ -164,18 +193,26 @@
 
   local barFrame = bar:GetFrame()
 
-  self.name = config.name or "ReAction_"..bar:GetName().."_"..idx
+  config.name = config.name or "ReAction_"..bar:GetName().."_"..idx
+  self.name = config.name
   config.actionID = ActionIDList[config.actionID] -- gets a free one if none configured
   
   local f = CreateFrame("CheckButton", self.name, barFrame, "ActionBarButtonTemplate")
+
   -- TODO: re-implement ActionButton event handlers that don't do secure stuff
 
   -- this will probably cause taint, using right now for display/debugging purposes
   f:SetScript("OnAttributeChanged", ActionButton_UpdateAction)
   f:SetAttribute("action", config.actionID)
+
   barFrame:SetAttribute("addchild",f)
+
   self.frame = f
   self:Refresh(bar,idx)
+
+  if not module.db.profile.hideEmptyButtons then
+    ActionButton_ShowGrid(self.frame)
+  end
 end
 
 function Button:Destroy()