changeset 193:576c50e51fc5

LibShowGrid-1.0 external library --> LibShowActionGrid-1.0 internal library
author Flick <flickerstreak@gmail.com>
date Mon, 15 Nov 2010 10:22:45 -0800
parents 2c05008464e5
children 55af1ebbec65
files .pkgmeta ReAction.toc classes/Bar.lua lib/LibShowActionGrid-1.0/LibShowActionGrid-1.0.lua lib/LibShowActionGrid-1.0/LibShowActionGrid-1.0.xml lib/embeds.xml
diffstat 6 files changed, 105 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/.pkgmeta	Fri Nov 12 11:31:58 2010 -0800
+++ b/.pkgmeta	Mon Nov 15 10:22:45 2010 -0800
@@ -7,7 +7,6 @@
 optional-dependencies:
   - ace3
   - libkeybound-1-0
-  - libshowgrid-1-0
 
 externals:
   lib/AceAddon-3.0:
@@ -40,9 +39,6 @@
   lib/LibKeyBound-1.0:
     url: svn://svn.wowace.com/wow/libkeybound-1-0/mainline/trunk/LibKeyBound-1.0
     tag: latest
-  lib/LibShowGrid-1.0:
-    url: http://hg.wowace.com/wow/libshowgrid-1-0/mainline/LibShowGrid-1.0
-    tag: latest
   lib/LibStub:
     url: svn://svn.wowace.com/wow/libstub/mainline/trunk
     tag: latest
--- a/ReAction.toc	Fri Nov 12 11:31:58 2010 -0800
+++ b/ReAction.toc	Mon Nov 15 10:22:45 2010 -0800
@@ -6,8 +6,8 @@
 ## Author: Flick
 ## Version: 1.1
 ## SavedVariables: ReAction_DB
-## OptionalDeps: Ace3, LibKeyBound-1.0, LibShowGrid-1.0
-## X-Embeds: Ace3, LibKeyBound-1.0, LibShowGrid-1.0
+## OptionalDeps: Ace3, LibKeyBound-1.0
+## X-Embeds: Ace3, LibKeyBound-1.0
 ## X-Category: Action Bars
 ## X-License: MIT
 
--- a/classes/Bar.lua	Fri Nov 12 11:31:58 2010 -0800
+++ b/classes/Bar.lua	Mon Nov 15 10:22:45 2010 -0800
@@ -8,7 +8,7 @@
 local fmod = math.fmod
 local format = string.format
 
-local LSG = LibStub("LibShowGrid-1.0")
+local LSG = LibStub("ReAction-LibShowActionGrid-1.0")
 
 ---- Secure snippets ----
 local _reaction_init = 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/LibShowActionGrid-1.0/LibShowActionGrid-1.0.lua	Mon Nov 15 10:22:45 2010 -0800
@@ -0,0 +1,94 @@
+--
+-- A secure proxy for ACTIONBAR_SHOW/HIDEGRID events
+-- The events are transmitted via SetAttribute("state-showgrid",count) to frames registered with :AddFrame()
+-- and can be handled by an appropriate SecureHandlerStateTemplate or SecureHandlerAttributeTemplate.
+--
+
+-- This library is internal to ReAction. If an addon author finds another use for this library, PM me on wowace
+-- and I'll see about re-exporting it as a standalone library.
+
+local libName = "ReAction-LibShowActionGrid-1.0"
+local minor = 1
+assert(LibStub, libName.." requires LibStub")
+local lib = LibStub:NewLibrary(libName, minor)
+if not lib then return end
+
+-- this being v1, no upgrade actions necessary
+
+local f = CreateFrame("CheckButton","LibShowActionGridProxyFrame-1.0-"..minor,UIParent,"ActionBarButtonTemplate, SecureHandlerAttributeTemplate")
+
+f:UnregisterAllEvents()
+f:RegisterEvent("ACTIONBAR_SHOWGRID");
+f:RegisterEvent("ACTIONBAR_HIDEGRID");
+
+f:SetScript("OnEnter",nil)
+f:SetScript("OnLeave",nil)
+f:SetScript("PostClick",nil)
+f:SetScript("OnDragStart",nil)
+f:SetScript("OnReceiveDrag",nil)
+f:SetScript("OnUpdate",nil)
+-- leave OnEvent
+
+f:SetAttribute("showgrid",10) -- set to >0 to prevent a call to HasAction(nil) that will cause a lua error
+f:SetAttribute("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()
+
+f:Execute(
+  [[
+    frames = newtable()
+  ]])
+
+f:SetAttribute("_onattributechanged", 
+  -- function _onattributechanged(self,name,value)
+  [[
+    if name == "showgrid" then
+      for _, f in ipairs(frames) do
+        f:SetAttribute("state-showgrid",(tonumber(value) or 10) - 10)
+      end
+    end
+  ]])
+
+lib.frame = f
+lib.framelist = setmetatable({},{__mode="k"})
+
+---
+--- library interface
+---
+
+function lib:AddFrame(frame)
+  self.framelist[frame] = true
+  self.frame:SetFrameRef("add-frame",frame)
+  self.frame:Execute(
+    [[
+      local frame = self:GetFrameRef("add-frame")
+      for _, f in ipairs(frames) do
+        if f == frame then return end
+      end
+      table.insert(frames,frame)
+    ]])
+end
+
+function lib:RemoveFrame(frame)
+  self.frame:SetFrameRef("remove-frame",frame)
+  self.frame:Execute(
+    [[
+      local frame = self:GetFrameRef("remove-frame")
+      for idx, f in ipairs(frames) do
+        if f == frame then
+          table.remove(frames,idx)
+          return 
+        end
+      end
+    ]])
+  self.framelist[frame] = nil
+end
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/LibShowActionGrid-1.0/LibShowActionGrid-1.0.xml	Mon Nov 15 10:22:45 2010 -0800
@@ -0,0 +1,7 @@
+<Ui xmlns="http://www.blizzard.com/wow/ui/" 
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
+    xsi:schemaLocation="http://www.blizzard.com/wow/ui/..\FrameXML\UI.xsd">
+
+  <Script file="LibShowActionGrid-1.0.lua"/>
+
+</Ui>
--- a/lib/embeds.xml	Fri Nov 12 11:31:58 2010 -0800
+++ b/lib/embeds.xml	Mon Nov 15 10:22:45 2010 -0800
@@ -16,6 +16,6 @@
   <Include file="AceConfigDialog-3.0\AceConfigDialog-3.0.xml"/>
 
   <Include file="LibKeyBound-1.0\lib.xml"/>
-  <Include file="LibShowGrid-1.0\LibShowGrid-1.0.xml"/>
+  <Include file="LibShowActionGrid-1.0\LibShowActionGrid-1.0.xml"/>
 
 </Ui>