nothing to see here, just storing progress before errors sneak in!

This commit is contained in:
Hendrik Leppkes
2007-11-30 17:43:02 +00:00
parent cd9e02cd5b
commit 75deac4e1e
4 changed files with 97 additions and 4 deletions
+53 -2
View File
@@ -13,6 +13,8 @@ local defaults = {
['**'] = {
Scale = 1,
Alpha = 1,
Buttons = 12,
Padding = 2,
}
}
}
@@ -41,7 +43,7 @@ end
local initialPosition
do
function initialPosition(bar)
bar:SetPoint("CENTER", 0, -250 + (bar.id-1) * 38)
bar:ClearSetPoint("CENTER", 0, -250 + (bar.id-1) * 38)
bar:SavePosition()
end
end
@@ -59,5 +61,54 @@ end
function ActionBar:ApplyConfig(config)
Bar.ApplyConfig(self, config)
if not self.config.Position then initialPosition(self) end
config = self.config
if not config.Position then initialPosition(self) end
self:UpdateButtons(config.Buttons)
end
function ActionBar:UpdateButtons(numbuttons)
local oldbuttons = self.config.Buttons
if numbuttons then
self.config.Buttons = numbuttons
else
numbuttons = self.config.Buttons
end
local buttons = self.buttons or {}
-- create more buttons if needed
if #buttons < numbuttons then
for i = (#buttons+1), numbuttons do
buttons[i] = Bartender4.Button:Create(i, self)
end
end
-- show active buttons
for i = 1, numbuttons do
buttons[i]:Show()
end
-- hide inactive buttons
for i = (numbuttons + 1), #buttons do
buttons[i]:Hide()
end
self.buttons = buttons
self:UpdateButtonLayout()
end
function ActionBar:UpdateButtonLayout()
local numbuttons = self.config.Buttons
local buttons = self.buttons
local pad = self.config.Padding
self:SetSize((36 + pad) * numbuttons + 8, 36 + 8)
buttons[1]:ClearSetPoint("TOPLEFT", self, "TOPLEFT", 5, -3)
for i = 2, numbuttons do
buttons[i]:ClearSetPoint("TOPLEFT", buttons[i-1], "TOPRIGHT", pad, 0)
end
end
+9 -2
View File
@@ -118,8 +118,7 @@ function Bar:LoadPosition()
local x, y, s = pos.x, pos.y, UIParent:GetEffectiveScale()
local point, relPoint = pos.point, pos.relPoint
x, y = x/s, y/s
self:ClearAllPoints()
self:SetPoint(point, UIParent, relPoint, x, y)
self:ClearSetPoint(point, UIParent, relPoint, x, y)
end
function Bar:SavePosition()
@@ -136,3 +135,11 @@ function Bar:SetSize(width, height)
self:SetWidth(width)
self:SetHeight(height or width)
end
--[[
Lazyness functions
]]
function Bar:ClearSetPoint(...)
self:ClearAllPoints()
self:SetPoint(...)
end
+1
View File
@@ -13,6 +13,7 @@ Bartender4.lua
## Prototypes ##
Bar.lua
Button.lua
## Modules ##
ActionBars.lua
+34
View File
@@ -0,0 +1,34 @@
--[[
Action Button Template
]]
--[[ $Id: Bar.lua 56326 2007-11-30 15:11:00Z nevcairiel $ ]]
local Button = CreateFrame("CheckButton")
local Button_MT = {__index = Button}
Bartender4.Button = {}
Bartender4.Button.prototype = Button
function Bartender4.Button:Create(id, parent)
local absid = (parent.id - 1) * 12 + id
local button = setmetatable(CreateFrame("CheckButton", ("BT4Button%d"):format(absid), parent, "ActionBarButtonTemplate"), Button_MT)
button:SetAttribute("type", "action")
button:SetAttribute("useparent-unit", true)
button:SetAttribute("useparent-statebutton", true)
button:SetAttribute("useparent-actionpage", nil)
button:SetAttribute("action", absid)
this = button
ActionButton_UpdateAction()
button:Show()
return button
end
function Button:ClearSetPoint(...)
self:ClearAllPoints()
self:SetPoint(...)
end