changeset 171:fe0c7be6f6ef

Convert GridProxy to LibShowGrid
author Flick <flickerstreak@gmail.com>
date Tue, 19 Oct 2010 20:22:59 +0000
parents 0030201b5fc2
children de594ad0e26e
files classes/Bar.lua classes/GridProxy.lua classes/classes.xml lib/embeds.xml
diffstat 4 files changed, 9 insertions(+), 71 deletions(-) [+]
line wrap: on
line diff
--- a/classes/Bar.lua	Tue Oct 19 20:07:55 2010 +0000
+++ b/classes/Bar.lua	Tue Oct 19 20:22:59 2010 +0000
@@ -6,7 +6,8 @@
 local fmod = math.fmod
 local format = string.format
 
-local KB = LibStub("LibKeyBound-1.0")
+local LKB = LibStub("LibKeyBound-1.0")
+local LSG = LibStub("LibShowGrid-1.0")
 
 ---- Secure snippets ----
 local _reaction_init = 
@@ -221,7 +222,7 @@
   f:Show()
   f:EnableMouse(false)
   f:SetClampedToScreen(true)
-  ReAction.gridProxy:AddFrame(f)
+  LSG:AddFrame(f)
 
   -- secure handlers
   f:Execute(_reaction_init)
@@ -245,9 +246,9 @@
   self:SetKeybindMode(ReAction:GetKeybindMode())
 
   ReAction.RegisterCallback(self, "OnConfigModeChanged")
-  KB.RegisterCallback(self, "LIBKEYBOUND_ENABLED")
-  KB.RegisterCallback(self, "LIBKEYBOUND_DISABLED")
-  KB.RegisterCallback(self, "LIBKEYBOUND_MODE_COLOR_CHANGED","LIBKEYBOUND_ENABLED")
+  LKB.RegisterCallback(self, "LIBKEYBOUND_ENABLED")
+  LKB.RegisterCallback(self, "LIBKEYBOUND_DISABLED")
+  LKB.RegisterCallback(self, "LIBKEYBOUND_MODE_COLOR_CHANGED","LIBKEYBOUND_ENABLED")
 
   return self
 end
@@ -257,8 +258,8 @@
   f:UnregisterAllEvents()
   self:ShowControls(false)
   ReAction.UnregisterAllCallbacks(self)
-  KB.UnregisterAllCallbacks(self)
-  ReAction.gridProxy:RemoveFrame(f)
+  LKB.UnregisterAllCallbacks(self)
+  LSG:RemoveFrame(f)
   f:SetParent(UIParent)
   f:ClearAllPoints()
   f:Hide()
--- a/classes/GridProxy.lua	Tue Oct 19 20:07:55 2010 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
---
--- A hack for a ShowGrid secure handler, using a bastardized Blizzard ActionBarButton.
---
-local gridProxy = { }
-ReAction.gridProxy = gridProxy
-
-local f = CreateFrame("CheckButton","ReActionShowGridProxy",UIParent,"ActionBarButtonTemplate, SecureHandlerAttributeTemplate")
-  -- SecureHandlerAttributeTemplate overwrites the onAttributeChanged handler, as it's last in the list
-f:UnregisterAllEvents()
-f:SetScript("OnEnter",nil)
-f:SetScript("OnLeave",nil)
-f:SetScript("PostClick",nil)
-f:SetScript("OnDragStart",nil)
-f:SetScript("OnReceiveDrag",nil)
-f:SetScript("OnUpdate",nil)
-f:SetAttribute("showgrid",0)
-f:SetAttribute("action",0)
-f.action = 0
-f:EnableMouse(false)
-for _, child in ipairs({f:GetChildren()}) do
-  child:Hide()
-end
-for _, region in ipairs({f:GetRegions()}) do
-  region:Hide()
-end
-f:SetPoint("TOPLEFT")
-f:Hide()
-
--- The existing onEvent handler will set the 'showgrid' attribute
--- on this frame. Re-register for those events, but don't touch the
--- onEvent handler, to keep it secure.
-f:RegisterEvent("ACTIONBAR_SHOWGRID");
-f:RegisterEvent("ACTIONBAR_HIDEGRID");
-
-f:Execute(
-  [[
-    frames = newtable()
-  ]])
-
--- shuttle 'showgrid' to the registered frames via state-showgrid attribute
-f:SetAttribute("_onattributechanged", 
-  -- function _onattributechanged(self,name,value)
-  [[
-    if name == "showgrid" then
-      for _, f in pairs(frames) do
-        f:SetAttribute("state-showgrid",value)
-      end
-    end
-  ]])
-
-function gridProxy:AddFrame(frame)
-  f:SetFrameRef("add",frame)
-  f:SetAttribute("frame-add-id",frame:GetName())
-  f:Execute(
-    [[
-      frames[self:GetAttribute("frame-add-id")] = self:GetFrameRef("add")
-    ]])
-end
-
-function gridProxy:RemoveFrame(frame)
-  f:SetAttribute("frame-remove-id",frame:GetName())
-  f:Execute(
-    [[
-      frames[self:GetAttribute("frame-remove-id")] = nil
-    ]])
-end
-
-
--- a/classes/classes.xml	Tue Oct 19 20:07:55 2010 +0000
+++ b/classes/classes.xml	Tue Oct 19 20:22:59 2010 +0000
@@ -2,7 +2,6 @@
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://www.blizzard.com/wow/ui/..\FrameXML\UI.xsd">
 
-<Script file="GridProxy.lua"/>
 <Script file="Bar.lua"/>
 <Script file="Overlay.lua"/>
 <Script file="Button.lua"/>
--- a/lib/embeds.xml	Tue Oct 19 20:07:55 2010 +0000
+++ b/lib/embeds.xml	Tue Oct 19 20:22:59 2010 +0000
@@ -18,5 +18,6 @@
   <Include file="AceConfigDialog-3.0\AceConfigDialog-3.0.xml"/>
 
   <Include file="LibKeyBound-1.0\lib.xml"/>
+  <Include file="LibShowGrid-1.0\lib.xml"/>
 
 </Ui>