From a7b9ca4c1f867fcdef2826eb81ded33dfb5b044d Mon Sep 17 00:00:00 2001 From: Hendrik Leppkes Date: Mon, 11 Feb 2008 18:12:12 +0000 Subject: [PATCH] implement different layouts --- ActionBarPrototype.lua | 1 + ActionBars.lua | 1 + Bartender4.toc | 1 + Button.lua | 2 ++ ButtonStyle.lua | 66 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 71 insertions(+) create mode 100644 ButtonStyle.lua diff --git a/ActionBarPrototype.lua b/ActionBarPrototype.lua index a459a6d..1901993 100644 --- a/ActionBarPrototype.lua +++ b/ActionBarPrototype.lua @@ -155,6 +155,7 @@ function ActionBar:ApplyConfig(config) self:UpdateButtons() self:UpdateStates() + self:ForAll("ApplyStyle", self.config.style) end -- Update the number of buttons in our bar, creating new ones if necessary diff --git a/ActionBars.lua b/ActionBars.lua index f72133a..ac63f50 100644 --- a/ActionBars.lua +++ b/ActionBars.lua @@ -12,6 +12,7 @@ local abdefaults = Bartender4:Merge({ rows = 1, hidemacrotext = false, showgrid = false, + style = "dream", states = { enabled = false, stance = { diff --git a/Bartender4.toc b/Bartender4.toc index 7afca75..563cfed 100644 --- a/Bartender4.toc +++ b/Bartender4.toc @@ -17,6 +17,7 @@ Bartender4.lua Options.lua ## Prototypes ## +ButtonStyle.lua Bar.lua Button.lua diff --git a/Button.lua b/Button.lua index 351c85c..9854265 100644 --- a/Button.lua +++ b/Button.lua @@ -137,6 +137,8 @@ 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/ButtonStyle.lua b/ButtonStyle.lua new file mode 100644 index 0000000..32c0ab9 --- /dev/null +++ b/ButtonStyle.lua @@ -0,0 +1,66 @@ +--[[ + Button Style Template +]] + +--[[ $Id: Button.lua 60943 2008-02-11 14:24:21Z nevcairiel $ ]] + +Bartender4.ButtonStyle = {} + +local styles = { + ["default"] = "Default", + ["bongos"] = "Bongos Style", + ["zoom"] = "Full Zoom", + ["dream"] = "Dreamlayout", +} + +local styledata = { + --["default"] = {}, + ["bongos"] = { texCoord = {0.06, 0.94, 0.06, 0.94} }, + ["zoom"] = { texCoord = {0.08,0.92,0.08,0.92} }, + ["dream"] = { + texCoord = {0.08,0.92,0.08,0.92}, + padding = 3, + customframe = true, + FrameFunc = function(button) + local frame = CreateFrame("Frame", button:GetName().."DreamLayout", 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(0) + return frame + end, + }, +} + +function Bartender4.ButtonStyle.ApplyStyle(button, style) + if not button.icon then return end + local style = styledata[style] + + if style.customframe and style.FrameFunc and not button.overlay then + if not button.customframe then button.customframe = style.FrameFunc(button) end + else + if button.customframe then + button.customframe:Hide() + button.customframe = nil + end + 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 +end + +function Bartender4.ButtonStyle:GetStyles() + return styles +end