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@128
|
7 local f = CreateFrame("CheckButton","ReActionShowGridProxy",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@128
|
16 f:SetAttribute("showgrid",0)
|
flickerstreak@128
|
17 f:SetAttribute("action",0)
|
flickerstreak@128
|
18 f.action = 0
|
flickerstreak@122
|
19 f:EnableMouse(false)
|
flickerstreak@122
|
20 for _, child in ipairs({f:GetChildren()}) do
|
flickerstreak@122
|
21 child:Hide()
|
flickerstreak@122
|
22 end
|
flickerstreak@122
|
23 for _, region in ipairs({f:GetRegions()}) do
|
flickerstreak@122
|
24 region:Hide()
|
flickerstreak@122
|
25 end
|
flickerstreak@122
|
26 f:SetPoint("TOPLEFT")
|
flickerstreak@122
|
27 f:Hide()
|
flickerstreak@122
|
28
|
flickerstreak@122
|
29 -- The existing onEvent handler will set the 'showgrid' attribute
|
flickerstreak@122
|
30 -- on this frame. Re-register for those events, but don't touch the
|
flickerstreak@122
|
31 -- onEvent handler, to keep it secure.
|
flickerstreak@122
|
32 f:RegisterEvent("ACTIONBAR_SHOWGRID");
|
flickerstreak@122
|
33 f:RegisterEvent("ACTIONBAR_HIDEGRID");
|
flickerstreak@122
|
34
|
flickerstreak@122
|
35 f:Execute(
|
flickerstreak@122
|
36 [[
|
flickerstreak@122
|
37 frames = newtable()
|
flickerstreak@122
|
38 ]])
|
flickerstreak@122
|
39
|
flickerstreak@122
|
40 -- shuttle 'showgrid' to the registered frames via state-showgrid attribute
|
flickerstreak@122
|
41 f:SetAttribute("_onattributechanged",
|
flickerstreak@122
|
42 -- function _onattributechanged(self,name,value)
|
flickerstreak@122
|
43 [[
|
flickerstreak@122
|
44 if name == "showgrid" then
|
flickerstreak@122
|
45 for _, f in pairs(frames) do
|
flickerstreak@122
|
46 f:SetAttribute("state-showgrid",value)
|
flickerstreak@122
|
47 end
|
flickerstreak@122
|
48 end
|
flickerstreak@122
|
49 ]])
|
flickerstreak@122
|
50
|
flickerstreak@122
|
51 function gridProxy:AddFrame(frame)
|
flickerstreak@122
|
52 f:SetFrameRef("add",frame)
|
flickerstreak@122
|
53 f:SetAttribute("frame-add-id",frame:GetName())
|
flickerstreak@122
|
54 f:Execute(
|
flickerstreak@122
|
55 [[
|
flickerstreak@122
|
56 frames[self:GetAttribute("frame-add-id")] = self:GetFrameRef("add")
|
flickerstreak@122
|
57 ]])
|
flickerstreak@122
|
58 end
|
flickerstreak@122
|
59
|
flickerstreak@122
|
60 function gridProxy:RemoveFrame(frame)
|
flickerstreak@122
|
61 f:SetAttribute("frame-remove-id",frame:GetName())
|
flickerstreak@122
|
62 f:Execute(
|
flickerstreak@122
|
63 [[
|
flickerstreak@122
|
64 frames[self:GetAttribute("frame-remove-id")] = nil
|
flickerstreak@122
|
65 ]])
|
flickerstreak@122
|
66 end
|
flickerstreak@122
|
67
|
flickerstreak@122
|
68
|