# HG changeset patch # User Flick # Date 1231289822 0 # Node ID b2fb8f7dc780ae8f964acab3d6a61fb318c6416f # Parent 110ec60c7a6699ac490b3421273e18c1973f60db ButtonFacade support diff -r 110ec60c7a66 -r b2fb8f7dc780 Bar.lua --- a/Bar.lua Tue Jan 06 21:10:03 2009 +0000 +++ b/Bar.lua Wed Jan 07 00:57:02 2009 +0000 @@ -240,3 +240,6 @@ end end +function Bar:SkinButton() + -- does nothing by default +end \ No newline at end of file diff -r 110ec60c7a66 -r b2fb8f7dc780 modules/ReAction_Action/ReAction_Action.lua --- a/modules/ReAction_Action/ReAction_Action.lua Tue Jan 06 21:10:03 2009 +0000 +++ b/modules/ReAction_Action/ReAction_Action.lua Wed Jan 07 00:57:02 2009 +0000 @@ -20,6 +20,7 @@ -- libraries local KB = LibStub("LibKeyBound-1.0") +local LBF -- initialized later -- module declaration local moduleID = "Action" @@ -50,6 +51,8 @@ ReAction.RegisterCallback(self, "OnRenameBar") ReAction.RegisterCallback(self, "OnConfigModeChanged") + LBF = LibStub("LibButtonFacade",true) + KB.RegisterCallback(self, "LIBKEYBOUND_ENABLED") KB.RegisterCallback(self, "LIBKEYBOUND_DISABLED") KB.RegisterCallback(self, "LIBKEYBOUND_MODE_COLOR_CHANGED","LIBKEYBOUND_ENABLED") @@ -962,7 +965,7 @@ ]]) self.frame = f - self.normalTexture = getglobal(format("%sNormalTexture",f:GetName())) + -- initialize the hide state f:SetAttribute("showgrid",0) @@ -977,6 +980,13 @@ -- attach the keybinder KBAttach(self) + -- attach to skinner + bar:SkinButton(self, + { + HotKey = self.hotkey, + } + ) + self:Refresh() return self end @@ -1103,7 +1113,11 @@ f:SetAttribute("showgrid",count) if count >= 1 and not f:GetAttribute("statehidden") then - self.normalTexture:SetVertexColor(1.0, 1.0, 1.0, 0.5); + if LBF then + LBF:SetNormalVertexColor(self.frame, 1.0, 1.0, 1.0, 0.5) + else + self.frame:GetNormalTexture():SetVertexColor(1.0, 1.0, 1.0, 0.5); + end f:Show() elseif count < 1 and not HasAction(self:GetActionID()) then f:Hide() diff -r 110ec60c7a66 -r b2fb8f7dc780 modules/ReAction_ButtonFacade/ReAction_ButtonFacade.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/modules/ReAction_ButtonFacade/ReAction_ButtonFacade.lua Wed Jan 07 00:57:02 2009 +0000 @@ -0,0 +1,115 @@ +-- local imports +local ReAction = ReAction +local L = ReAction.L +local _G = _G + +-- module declaration +local moduleID = "ButtonFacade" +local module = ReAction:NewModule( moduleID ) + +-- handlers +function module:OnInitialize() + self.db = ReAction.db:RegisterNamespace( moduleID, + { + profile = { + -- default profile goes here + } + } + ) + + local LBF = LibStub("LibButtonFacade",true) + + if not LBF then -- no more initialization + return + end + + self.LBF = LBF + self.groups = { } + + -- override a method of ReAction.Bar + -- note that 'self' in this context refers to the bar + function ReAction.Bar:SkinButton( button, data ) + module:GetGroup(self:GetName()):AddButton(button:GetFrame(), data) + end + + -- register some common events + ReAction.RegisterCallback(self, "OnCreateBar") + ReAction.RegisterCallback(self, "OnDestroyBar") + ReAction.RegisterCallback(self, "OnRefreshBar") + ReAction.RegisterCallback(self, "OnEraseBar") + ReAction.RegisterCallback(self, "OnRenameBar") + + self.LBF:RegisterSkinCallback("ReAction", self.OnSkinChanged, self) +end + +function module:OnEnable() + +end + +function module:OnDisable() + +end + +function module:OnCreateBar(event, bar, name) + local c = self.db.profile[name] + if not c then + c = { + skinID = "Blizzard", + backdrop = true, + gloss = 0, + colors = {}, + } + self.db.profile[name] = c + end + + local g = self:GetGroup(name) + g.SkinID = c.skinID or "Blizzard" + g.Backdrop = c.backdrop + g.Gloss = c.gloss + g.Colors = c.colors +end + +function module:OnDestroyBar(event, bar, name) + if self.groups[name] then + self.groups[name]:Delete() + self.groups[name] = nil + end +end + +function module:OnRefreshBar(event, bar, name) + local c = self.db.profile[name] + local g = self.groups[name] + if c and g then + g:Skin(c.skinID, c.gloss, c.backdrop, c.colors) + end +end + +function module:OnEraseBar(event, bar, name) + self:OnDestroyBar(event, bar, name) + self.db.profile[name] = nil +end + +function module:OnRenameBar(event, bar, oldName, newName) + if self.groups[name] then + self.groups[name]:Delete(true) + self.db.profile[oldName], self.db.profile[newName] = nil, self.db.profile[oldName] + self:OnCreateBar(event, bar, newName) + end +end + +function module:OnSkinChanged( skinID, gloss, backdrop, group, button, colors ) + local c = self.db.profile[group] + if c then + c.skinID = skinID + c.gloss = gloss + c.backdrop = backdrop + c.colors = colors + end +end + +function module:GetGroup( name ) + if not self.groups[name] then + self.groups[name] = self.LBF:Group("ReAction", name) + end + return self.groups[name] +end diff -r 110ec60c7a66 -r b2fb8f7dc780 modules/ReAction_ButtonFacade/ReAction_ButtonFacade.toc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/modules/ReAction_ButtonFacade/ReAction_ButtonFacade.toc Wed Jan 07 00:57:02 2009 +0000 @@ -0,0 +1,11 @@ +## Interface: 30000 +## Title: ReAction: ButtonFacade +## Notes: ButtonFacade support for ReAction +## DefaultState: enabled +## LoadOnDemand: 1 +## Author: Flick +## Version: 1.0 +## X-Category: Action Bars +## Dependencies: ReAction + +ReAction_ButtonFacade.xml diff -r 110ec60c7a66 -r b2fb8f7dc780 modules/ReAction_ButtonFacade/ReAction_ButtonFacade.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/modules/ReAction_ButtonFacade/ReAction_ButtonFacade.xml Wed Jan 07 00:57:02 2009 +0000 @@ -0,0 +1,7 @@ + + +