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:
@@ -21,6 +21,8 @@ local defaults = {
|
|||||||
},
|
},
|
||||||
position = {
|
position = {
|
||||||
scale = 1,
|
scale = 1,
|
||||||
|
growVertical = "DOWN",
|
||||||
|
growHorizontal = "RIGHT",
|
||||||
},
|
},
|
||||||
clickthrough = false,
|
clickthrough = false,
|
||||||
}
|
}
|
||||||
@@ -109,9 +111,13 @@ function Bartender4.Bar:Create(id, config, name)
|
|||||||
|
|
||||||
bar.id = id
|
bar.id = id
|
||||||
bar.name = name or id
|
bar.name = name or id
|
||||||
|
bar.config = config
|
||||||
bar:SetMovable(true)
|
bar:SetMovable(true)
|
||||||
bar:HookScript("OnAttributeChanged", barOnAttributeChanged)
|
bar:HookScript("OnAttributeChanged", barOnAttributeChanged)
|
||||||
|
|
||||||
|
bar:SetWidth(1)
|
||||||
|
bar:SetHeight(1)
|
||||||
|
|
||||||
local overlay = CreateFrame("Button", bar:GetName() .. "Overlay", bar)
|
local overlay = CreateFrame("Button", bar:GetName() .. "Overlay", bar)
|
||||||
bar.overlay = overlay
|
bar.overlay = overlay
|
||||||
overlay:EnableMouse(true)
|
overlay:EnableMouse(true)
|
||||||
@@ -142,10 +148,10 @@ function Bartender4.Bar:Create(id, config, name)
|
|||||||
|
|
||||||
overlay:SetFrameLevel(bar:GetFrameLevel() + 10)
|
overlay:SetFrameLevel(bar:GetFrameLevel() + 10)
|
||||||
overlay:ClearAllPoints()
|
overlay:ClearAllPoints()
|
||||||
overlay:SetAllPoints(bar)
|
local anchor = bar:GetAnchor()
|
||||||
|
overlay:SetPoint(anchor, bar, anchor)
|
||||||
overlay:Hide()
|
overlay:Hide()
|
||||||
|
|
||||||
bar.config = config
|
|
||||||
bar.elapsed = 0
|
bar.elapsed = 0
|
||||||
bar.hidedriver = {}
|
bar.hidedriver = {}
|
||||||
|
|
||||||
@@ -190,6 +196,10 @@ function Bar:ApplyConfig(config)
|
|||||||
self:InitVisibilityDriver()
|
self:InitVisibilityDriver()
|
||||||
end
|
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()
|
function Bar:UpgradeConfig()
|
||||||
local version = self.config.version or 1
|
local version = self.config.version or 1
|
||||||
if version < 2 then
|
if version < 2 then
|
||||||
@@ -244,8 +254,8 @@ function Bar:SavePosition()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Bar:SetSize(width, height)
|
function Bar:SetSize(width, height)
|
||||||
self:SetWidth(width)
|
self.overlay:SetWidth(width)
|
||||||
self:SetHeight(height or width)
|
self.overlay:SetHeight(height or width)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Bar:GetConfigAlpha()
|
function Bar:GetConfigAlpha()
|
||||||
|
|||||||
+10
-4
@@ -155,16 +155,22 @@ function ButtonBar:UpdateButtonLayout()
|
|||||||
|
|
||||||
self:SetSize((self.button_width + hpad) * ButtonPerRow - pad + 8, (self.button_height + vpad) * Rows - pad + 8)
|
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
|
local anchor = self:GetAnchor()
|
||||||
buttons[1]:ClearSetPoint("TOPLEFT", self, "TOPLEFT", 5 - (self.hpad_offset or 0), -3 - (self.vpad_offset or 0))
|
-- 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
|
-- and anchor all other buttons relative to our button 1
|
||||||
for i = 2, numbuttons do
|
for i = 2, numbuttons do
|
||||||
-- jump into a new row
|
-- jump into a new row
|
||||||
if ((i-1) % ButtonPerRow) == 0 then
|
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
|
-- align to the previous button
|
||||||
else
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user