diff classes/GridProxy.lua @ 122:a2d2f23137c8

- Rearranged and consolidated some files in modules directory - Added 'classes' directory, moved Bar and Overlay there - Added Button, ActionButton, and GridProxy classes, not in use yet
author Flick <flickerstreak@gmail.com>
date Mon, 23 Feb 2009 18:56:57 +0000
parents
children 729232aeeb5e
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/classes/GridProxy.lua	Mon Feb 23 18:56:57 2009 +0000
@@ -0,0 +1,65 @@
+--
+-- A hack for a ShowGrid secure handler, using a bastardized Blizzard ActionBarButton.
+--
+local gridProxy = { }
+ReAction.gridProxy = gridProxy
+
+local f = CreateFrame("CheckButton",nil,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: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
+
+