annotate 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
rev   line source
flickerstreak@122 1 --
flickerstreak@122 2 -- A hack for a ShowGrid secure handler, using a bastardized Blizzard ActionBarButton.
flickerstreak@122 3 --
flickerstreak@122 4 local gridProxy = { }
flickerstreak@122 5 ReAction.gridProxy = gridProxy
flickerstreak@122 6
flickerstreak@122 7 local f = CreateFrame("CheckButton",nil,UIParent,"ActionBarButtonTemplate, SecureHandlerAttributeTemplate")
flickerstreak@122 8 -- SecureHandlerAttributeTemplate overwrites the onAttributeChanged handler, as it's last in the list
flickerstreak@122 9 f:UnregisterAllEvents()
flickerstreak@122 10 f:SetScript("OnEnter",nil)
flickerstreak@122 11 f:SetScript("OnLeave",nil)
flickerstreak@122 12 f:SetScript("PostClick",nil)
flickerstreak@122 13 f:SetScript("OnDragStart",nil)
flickerstreak@122 14 f:SetScript("OnReceiveDrag",nil)
flickerstreak@122 15 f:SetScript("OnUpdate",nil)
flickerstreak@122 16 f:EnableMouse(false)
flickerstreak@122 17 for _, child in ipairs({f:GetChildren()}) do
flickerstreak@122 18 child:Hide()
flickerstreak@122 19 end
flickerstreak@122 20 for _, region in ipairs({f:GetRegions()}) do
flickerstreak@122 21 region:Hide()
flickerstreak@122 22 end
flickerstreak@122 23 f:SetPoint("TOPLEFT")
flickerstreak@122 24 f:Hide()
flickerstreak@122 25
flickerstreak@122 26 -- The existing onEvent handler will set the 'showgrid' attribute
flickerstreak@122 27 -- on this frame. Re-register for those events, but don't touch the
flickerstreak@122 28 -- onEvent handler, to keep it secure.
flickerstreak@122 29 f:RegisterEvent("ACTIONBAR_SHOWGRID");
flickerstreak@122 30 f:RegisterEvent("ACTIONBAR_HIDEGRID");
flickerstreak@122 31
flickerstreak@122 32 f:Execute(
flickerstreak@122 33 [[
flickerstreak@122 34 frames = newtable()
flickerstreak@122 35 ]])
flickerstreak@122 36
flickerstreak@122 37 -- shuttle 'showgrid' to the registered frames via state-showgrid attribute
flickerstreak@122 38 f:SetAttribute("_onattributechanged",
flickerstreak@122 39 -- function _onattributechanged(self,name,value)
flickerstreak@122 40 [[
flickerstreak@122 41 if name == "showgrid" then
flickerstreak@122 42 for _, f in pairs(frames) do
flickerstreak@122 43 f:SetAttribute("state-showgrid",value)
flickerstreak@122 44 end
flickerstreak@122 45 end
flickerstreak@122 46 ]])
flickerstreak@122 47
flickerstreak@122 48 function gridProxy:AddFrame(frame)
flickerstreak@122 49 f:SetFrameRef("add",frame)
flickerstreak@122 50 f:SetAttribute("frame-add-id",frame:GetName())
flickerstreak@122 51 f:Execute(
flickerstreak@122 52 [[
flickerstreak@122 53 frames[self:GetAttribute("frame-add-id")] = self:GetFrameRef("add")
flickerstreak@122 54 ]])
flickerstreak@122 55 end
flickerstreak@122 56
flickerstreak@122 57 function gridProxy:RemoveFrame(frame)
flickerstreak@122 58 f:SetAttribute("frame-remove-id",frame:GetName())
flickerstreak@122 59 f:Execute(
flickerstreak@122 60 [[
flickerstreak@122 61 frames[self:GetAttribute("frame-remove-id")] = nil
flickerstreak@122 62 ]])
flickerstreak@122 63 end
flickerstreak@122 64
flickerstreak@122 65