Skip to content

Instantly share code, notes, and snippets.

@tekkub
Created August 23, 2008 02:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tekkub/6889 to your computer and use it in GitHub Desktop.
Save tekkub/6889 to your computer and use it in GitHub Desktop.
for actionID=1,12 do
local mainbtn = factory("tekPopbar"..actionID, UIParent, "ActionBarButtonTemplate,SecureHandlerEnterLeaveTemplate,SecureHandlerStateTemplate")
mainbtn:SetPoint("LEFT", anch1, "RIGHT", (actionID == 4 or actionID == 9) and gap * 2.5 or gap, 0)
RegisterStateDriver(mainbtn, "bonusbar", "[bonusbar:1]1;[bonusbar:2]2;[bonusbar:3]3;[bonusbar:4]4;[bonusbar:5]5;0") -- See http://www.wowwiki.com/API_GetBonusBarOffset for details
mainbtn:SetAttribute('_onstate-bonusbar', [[
newaction = (not newstate or newstate == "0") and ]].. actionID..[[ or newstate == "5" and ]].. possbar[actionID]..[[ or (]].. actionID..[[ + (newstate+5)*12)
self:SetAttribute("*action*", newaction)
if not self:IsUnderMouse(true) then control:ChildUpdate("dohide") end
]])
mainbtn:SetAttribute("*action*", actionID)
mainbtn.action = actionID
mainbtn:RegisterEvent("UPDATE_BINDINGS")
mainbtn:SetAttribute("_onenter", [[ control:ChildUpdate("doshow") ]])
mainbtn:SetAttribute("_onleave", [[
elap = 0
control:SetAnimating(true)
]])
mainbtn:SetAttribute("_onupdate", [[
if self:IsUnderMouse(true) then
elap = 0
else
elap = elap + elapsed
if elap >= 2 then
control:ChildUpdate("dohide")
control:SetAnimating(false)
end
end
]])
local anch2 = mainbtn
for _,bar in ipairs(usebars) do
local btnID = actionID - 12 + bar*12
local btn = factory("tekPopbar"..btnID, mainbtn, "ActionBarButtonTemplate")
btn:SetAttribute("type", "action")
btn:SetAttribute("*action*", btnID)
btn:SetPoint("BOTTOM", anch2, "TOP", 0, gap)
anch2 = btn
btn:Hide()
mainbtn:SetAttribute("_adopt", btn)
btn:SetAttribute("_childupdate-doshow", [[ self:Show() ]])
btn:SetAttribute("_childupdate-dohide", [[ self:Hide() ]])
end
anch1 = mainbtn
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment