Added plumbing to change the growth direction of the bars. Currently always defaults to DOWN and RIGHT, as that is the "old" behaviour.

This commit is contained in:
Hendrik Leppkes
2009-02-21 14:12:49 +01:00
parent acc67ba2a0
commit 6f5086adc8
2 changed files with 24 additions and 8 deletions
+14 -4
View File
@@ -21,6 +21,8 @@ local defaults = {
},
position = {
scale = 1,
growVertical = "DOWN",
growHorizontal = "RIGHT",
},
clickthrough = false,
}
@@ -109,9 +111,13 @@ function Bartender4.Bar:Create(id, config, name)
bar.id = id
bar.name = name or id
bar.config = config
bar:SetMovable(true)
bar:HookScript("OnAttributeChanged", barOnAttributeChanged)
bar:SetWidth(1)
bar:SetHeight(1)
local overlay = CreateFrame("Button", bar:GetName() .. "Overlay", bar)
bar.overlay = overlay
overlay:EnableMouse(true)
@@ -142,10 +148,10 @@ function Bartender4.Bar:Create(id, config, name)
overlay:SetFrameLevel(bar:GetFrameLevel() + 10)
overlay:ClearAllPoints()
overlay:SetAllPoints(bar)
local anchor = bar:GetAnchor()
overlay:SetPoint(anchor, bar, anchor)
overlay:Hide()
bar.config = config
bar.elapsed = 0
bar.hidedriver = {}
@@ -190,6 +196,10 @@ function Bar:ApplyConfig(config)
self:InitVisibilityDriver()
end
function Bar:GetAnchor()
return ((self.config.position.growVertical == "DOWN") and "TOP" or "BOTTOM") .. ((self.config.position.growHorizontal == "RIGHT") and "LEFT" or "RIGHT")
end
function Bar:UpgradeConfig()
local version = self.config.version or 1
if version < 2 then
@@ -244,8 +254,8 @@ function Bar:SavePosition()
end
function Bar:SetSize(width, height)
self:SetWidth(width)
self:SetHeight(height or width)
self.overlay:SetWidth(width)
self.overlay:SetHeight(height or width)
end
function Bar:GetConfigAlpha()
+10 -4
View File
@@ -155,16 +155,22 @@ function ButtonBar:UpdateButtonLayout()
self:SetSize((self.button_width + hpad) * ButtonPerRow - pad + 8, (self.button_height + vpad) * Rows - pad + 8)
-- anchor button 1 to the topleft corner of the bar
buttons[1]:ClearSetPoint("TOPLEFT", self, "TOPLEFT", 5 - (self.hpad_offset or 0), -3 - (self.vpad_offset or 0))
local anchor = self:GetAnchor()
-- anchor button 1
buttons[1]:ClearSetPoint(anchor, self, anchor, 5 - (self.hpad_offset or 0), -3 - (self.vpad_offset or 0))
local h1 = (self.config.position.growHorizontal == "RIGHT") and "LEFT" or "RIGHT"
local h2 = (self.config.position.growHorizontal == "RIGHT") and "RIGHT" or "LEFT"
local v1 = (self.config.position.growVertical == "DOWN") and "TOP" or "BOTTOM"
local v2 = (self.config.position.growVertical == "DOWN") and "BOTTOM" or "TOP"
-- and anchor all other buttons relative to our button 1
for i = 2, numbuttons do
-- jump into a new row
if ((i-1) % ButtonPerRow) == 0 then
buttons[i]:ClearSetPoint("TOPLEFT", buttons[i-ButtonPerRow], "BOTTOMLEFT", 0, -vpad)
buttons[i]:ClearSetPoint(v1 .. h1, buttons[i-ButtonPerRow], v2 .. h1, 0, -vpad)
-- align to the previous button
else
buttons[i]:ClearSetPoint("TOPLEFT", buttons[i-1], "TOPRIGHT", hpad, 0)
buttons[i]:ClearSetPoint("TOP" .. h1, buttons[i-1], "TOP" .. h2, hpad, 0)
end
end