diff --git a/ActionBarPrototype.lua b/ActionBarPrototype.lua index ce41bc3..87bfb83 100644 --- a/ActionBarPrototype.lua +++ b/ActionBarPrototype.lua @@ -153,7 +153,6 @@ function ActionBar:UpdateButtons(numbuttons) -- show active buttons for i = 1, numbuttons do buttons[i]:Show() - buttons[i]:ApplyStyle(self.config.style) buttons[i]:UpdateAction(true) end diff --git a/ActionBars.lua b/ActionBars.lua index f86244f..14e1192 100644 --- a/ActionBars.lua +++ b/ActionBars.lua @@ -61,6 +61,9 @@ function BT4ActionBars:OnInitialize() ActionBar_MT = {__index = ActionBar} end + +local LBF = LibStub("LibButtonFacade", true) + -- setup the 10 actionbars local first = true function BT4ActionBars:OnEnable() @@ -77,6 +80,10 @@ function BT4ActionBars:OnEnable() end end + if LBF then + LBF:RegisterSkinCallback("Bartender4", self.UpdateSkin, self) + end + first = nil end @@ -132,6 +139,13 @@ function BT4ActionBars:ApplyConfig() end end +function BT4ActionBars:UpdateSkin(SkinID, Gloss, Backdrop, Group, Button) + local id = tonumber(Group) + if id and self.actionbars[id] then + self.actionbars[id]:ForAll("Update") + end +end + -- we do not allow to disable the actionbars module function BT4ActionBars:ToggleModule() return diff --git a/Bartender4.lua b/Bartender4.lua index 5e4cb78..66f9dc7 100644 --- a/Bartender4.lua +++ b/Bartender4.lua @@ -25,11 +25,10 @@ function Bartender4:OnInitialize() MainMenuBar:Hide() end -function Bartender4:OnEnable() - if IsAddOnLoaded("cyCircled") then - self:SecureHook(cyCircled, "LoadPlugins", "cyLoaded") - end +--[[ function Bartender4:OnEnable() + -- end +--]] function Bartender4:RegisterDefaultsKey(key, subdefaults) defaults.profile[key] = subdefaults diff --git a/Bartender4.toc b/Bartender4.toc index 679ca72..2525450 100644 --- a/Bartender4.toc +++ b/Bartender4.toc @@ -3,7 +3,7 @@ ## Title: Bartender4 ## Author: Nevcairiel ## SavedVariables: Bartender4DB -## OptionalDeps: Ace3 +## OptionalDeps: Ace3, ButtonFacade ## X-Embeds: Ace3 ## X-Category: Action Bars ## Version: 4.0 diff --git a/Button.lua b/Button.lua index 877721e..4ed9ab3 100644 --- a/Button.lua +++ b/Button.lua @@ -15,6 +15,8 @@ local format = string.format local IsUsableAction = IsUsableAction local IsActionInRange = IsActionInRange +local LBF = LibStub("LibButtonFacade", true) + Bartender4.Button = {} Bartender4.Button.prototype = Button function Bartender4.Button:Create(id, parent) @@ -100,6 +102,17 @@ function Bartender4.Button:Create(id, parent) --button:Show() --button:UpdateAction(true) + if LBF and parent.LBFGroup then + local group = parent.LBFGroup + button.LBFButtonData = { + Button = button.Proxy, + Highlight = button:GetHighlightTexture(), + Pushed = button:GetPushedTexture(), + Checked = button:GetCheckedTexture(), + } + group:AddButton(button.Proxy, button.LBFButtonData) + end + return button end @@ -167,8 +180,6 @@ function onUpdate(self, elapsed) end end -Button.ApplyStyle = Bartender4.ButtonStyle.ApplyStyle - function Button:SetStateAction(state, action) for i=1,2 do self:SetAttribute(("*action-S%d%d"):format(state, i), action) diff --git a/ButtonBar.lua b/ButtonBar.lua index 0def297..1e6cfc2 100644 --- a/ButtonBar.lua +++ b/ButtonBar.lua @@ -9,16 +9,21 @@ local ButtonBar_MT = {__index = ButtonBar} local defaults = Bartender4:Merge({ padding = 2, rows = 1, - style = "dream", }, Bartender4.Bar.defaults) Bartender4.ButtonBar = {} Bartender4.ButtonBar.prototype = ButtonBar Bartender4.ButtonBar.defaults = defaults +local LBF = LibStub("LibButtonFacade", true) + function Bartender4.ButtonBar:Create(id, template, config) local bar = setmetatable(Bartender4.Bar:Create(id, template, config), ButtonBar_MT) + if LBF then + bar.LBFGroup = LBF:Group("Bartender4", tostring(id)) + end + return bar end @@ -35,7 +40,6 @@ do optionMap = { rows = "Rows", padding = "Padding", - style = "Style", } -- retrieves a valid bar object from the barregistry table @@ -80,15 +84,6 @@ function ButtonBar:GetOptionObject() set = optSetter, get = optGetter, }, - style = { - order = 59, - name = "Style", - type = "select", - desc = "Button Style", - values = Bartender4.ButtonStyle:GetStyles(), - set = optSetter, - get = optGetter, - }, rows = { order = 70, name = "Rows", @@ -171,18 +166,6 @@ function ButtonBar:UpdateButtonLayout() end end -function ButtonBar:GetStyle() - return self.config.style -end - -function ButtonBar:SetStyle(style) - if style then - self.config.style = style - end - self:ForAll("ApplyStyle", self.config.style) -end - - --[[=================================================================================== Utility function ===================================================================================]]-- diff --git a/ButtonStyle.lua b/ButtonStyle.lua index f316d21..e204467 100644 --- a/ButtonStyle.lua +++ b/ButtonStyle.lua @@ -4,89 +4,3 @@ --[[ $Id$ ]] -Bartender4.ButtonStyle = {} - -local styles = { - ["default"] = "Default", - ["zoom"] = "Full Zoom", - ["dream"] = "Dreamlayout", -} - -local styledata = { - ["default"] = {}, - ["zoom"] = { texCoord = {0.07, 0.93, 0.07, 0.93} }, - ["dream"] = { - texCoord = {0.08,0.92,0.08,0.92}, - padding = 3, - overlay = true, - FrameFunc = function(button) - button = button.Proxy or button - local name = button:GetName().."DreamLayout" - local frame = _G[name] or CreateFrame("Frame", name, button) - frame:ClearAllPoints() - frame:SetBackdrop({bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 1, edgeFile = "", edgeSize = 0, insets = {left = 0, right = 0, top = 0, bottom = 0},}) - frame:SetBackdropColor(0, 0, 0, 0.6) - frame:SetAllPoints(button) - frame:SetFrameLevel(button:GetFrameLevel() - 2) - frame:Show() - frame.type = "dream" - frame.hidegrid = true - return frame - end, - }, -} - -local cydb - -function Bartender4.ButtonStyle.ApplyStyle(button, styleName) - if not button.icon then return end - local style = styledata[styleName] - - local cy = cydb and cydb.profile[button:GetParent().id] - --DevTools_Dump(cydb and cydb.profile) - - if cy then - style = styledata.default - end - - if style.overlay and style.FrameFunc then - if not button.overlay or button.overlay.type ~= styleName then - if button.overlay then button.overlay:Hide() end - button.overlay = style.FrameFunc(button) - end - else - if button.overlay then - button.overlay:Hide() - button.overlay = nil - end - end - - if cy then return end - - if style.texCoord then - button.icon:SetTexCoord(unpack(style.texCoord)) - else - button.icon:SetTexCoord(0,1,0,1) - end - - button.icon:ClearAllPoints() - if style.padding then - button.icon:SetPoint("TOPLEFT", button, "TOPLEFT", style.padding, -style.padding) - button.icon:SetPoint("BOTTOMRIGHT",button, "BOTTOMRIGHT", -style.padding, style.padding) - else - button.icon:SetAllPoints(button) - end - - if type(button.Update) == "function" then - button:Update() - end -end - -function Bartender4.ButtonStyle:GetStyles() - return styles -end - -function Bartender4:cyLoaded() - cydb = cyCircled_Bartender4 and cyCircled_Bartender4.db - Bartender4.Bar:ForAll("SetStyle") -end diff --git a/PetBar.lua b/PetBar.lua index 9d2bbb7..69bdc99 100644 --- a/PetBar.lua +++ b/PetBar.lua @@ -266,9 +266,6 @@ function PetButtonPrototype:UpdateCooldown() CooldownFrame_SetTimer(self.cooldown, start, duration, enable) end --- import style function -PetButtonPrototype.ApplyStyle = Bartender4.ButtonStyle.ApplyStyle - function PetButtonPrototype:GetHotkey() local key = GetBindingKey(format("BONUSACTIONBUTTON%d", self:GetID())) or GetBindingKey("CLICK "..self:GetName()..":LeftButton") return key and KeyBound:ToShortKey(key) diff --git a/StanceBar.lua b/StanceBar.lua index 59e520e..d338426 100644 --- a/StanceBar.lua +++ b/StanceBar.lua @@ -14,6 +14,8 @@ local StanceButton_MT = {__index = StanceButtonPrototype} local format = string.format +local LBF = LibStub("LibButtonFacade", true) + local defaults = { profile = Bartender4:Merge({ enabled = true, scale = 1.5, @@ -143,8 +145,6 @@ function StanceButtonPrototype:Update() end end -StanceButtonPrototype.ApplyStyle = Bartender4.ButtonStyle.ApplyStyle - function StanceButtonPrototype:GetHotkey() local key = GetBindingKey(format("SHAPESHIFTBUTTON%d", self:GetID())) or GetBindingKey("CLICK "..self:GetName()..":LeftButton") return key and KeyBound:ToShortKey(key) @@ -208,6 +208,14 @@ function StanceBarMod:CreateStanceButton(id) button.OnEnter = button:GetScript("OnEnter") button:SetScript("OnEnter", onEnter) + if LBF then + local group = self.bar.LBFGroup + button.LBFButtonData = { + Button = button + } + group:AddButton(button, button.LBFButtonData) + end + return button end