diff --git a/ActionBars.lua b/ActionBars.lua
index b5dcc11..fd5eb25 100644
--- a/ActionBars.lua
+++ b/ActionBars.lua
@@ -191,7 +191,7 @@ end
-- Creates a new bar object based on the id and the specified config
function BT4ActionBars:Create(id, config)
local id = tostring(id)
- local bar = setmetatable(Bartender4.ButtonBar:Create(id, "SecureStateHeaderTemplate", config), ActionBar_MT)
+ local bar = setmetatable(Bartender4.ButtonBar:Create(id, config), ActionBar_MT)
bar.module = self
self:CreateBarOption(id)
diff --git a/Bar.lua b/Bar.lua
index 28de4b8..4f83c27 100644
--- a/Bar.lua
+++ b/Bar.lua
@@ -14,7 +14,7 @@ local Bar_MT = {__index = Bar}
local defaults = {
scale = 1,
alpha = 1,
- show = true
+ show = "alwaysshow",
}
local barOnEnter, barOnLeave, barOnDragStart, barOnDragStop, barOnClick
@@ -53,11 +53,11 @@ Bartender4.Bar = {}
Bartender4.Bar.defaults = defaults
Bartender4.Bar.prototype = Bar
Bartender4.Bar.barregistry = barregistry
-function Bartender4.Bar:Create(id, template, config)
+function Bartender4.Bar:Create(id, config)
id = tostring(id)
assert(not barregistry[id], "duplicated entry in barregistry.")
- local bar = setmetatable(CreateFrame("Frame", ("BT4Bar%s"):format(id), UIParent, template), Bar_MT)
+ local bar = setmetatable(CreateFrame("Frame", ("BT4Bar%s"):format(id), UIParent, "SecureStateHeaderTemplate"), Bar_MT)
barregistry[id] = bar
bar.id = id
bar:SetMovable(true)
@@ -157,6 +157,8 @@ do
end
end
+local showOptions = { alwaysshow = "Always Show", alwayshide = "Always Hide", combatshow = "Show in Combat", combathide = "Hide in Combat" }
+
local options
function Bar:GetOptionObject()
local otbl = {
@@ -168,11 +170,12 @@ function Bar:GetOptionObject()
args = {
show = {
order = 5,
- type = "toggle",
- name = "Show",
- desc = "Show/Hide the bar.",
+ type = "select",
+ name = "Show/Hide",
+ desc = "Configure when to Show/Hide the bar.",
get = optGetter,
set = optSetter,
+ values = showOptions,
},
styleheader = {
order = 10,
@@ -235,9 +238,10 @@ end
function Bar:Unlock()
if self.disabled or self.unlocked then return end
self.unlocked = true
+ UnregisterStateDriver(self, "visibility")
self:Show()
self.overlay:Show()
- if not self.config.show then
+ if self.config.show == "alwayshide" then
self.overlay:SetBackdropColor(1, 0, 0, 0.5)
else
self.overlay:SetBackdropColor(0, 1, 0, 0.5)
@@ -249,9 +253,7 @@ function Bar:Lock()
self.unlocked = nil
barOnDragStop(self.overlay)
- if not self.config.show then
- self:Hide()
- end
+ self:ConfigureShowStates()
self.overlay:Hide()
end
@@ -289,10 +291,10 @@ function Bar:SetShow(show)
self.config.show = show
end
if not self.unlocked then
- self[self.config.show and "Show" or "Hide"](self)
+ self:ConfigureShowStates()
else
self:Show()
- if not self.config.show then
+ if self.config.show == "alwayshide" then
self.overlay:SetBackdropColor(1, 0, 0, 0.5)
else
self.overlay:SetBackdropColor(0, 1, 0, 0.5)
@@ -300,6 +302,20 @@ function Bar:SetShow(show)
end
end
+function Bar:ConfigureShowStates()
+ UnregisterStateDriver(self, 'visibility')
+ local conditions
+ if self.config.show == "alwaysshow" or self.config.show == true then
+ self:Show()
+ elseif self.config.show == "alwayshide" or self.config.show == false then
+ self:Hide()
+ elseif self.config.show == "combatshow" then
+ RegisterStateDriver(self, 'visibility', '[combat]show;hide')
+ elseif self.config.show == "combathide" then
+ RegisterStateDriver(self, 'visibility', '[combat]hide;show')
+ end
+end
+
function Bar:GetConfigAlpha()
return self.config.alpha
end
diff --git a/Bartender4.toc b/Bartender4.toc
index af857e1..2bdecb6 100644
--- a/Bartender4.toc
+++ b/Bartender4.toc
@@ -3,13 +3,12 @@
## Title: Bartender4
## Author: Nevcairiel
## SavedVariables: Bartender4DB
-## OptionalDeps: Ace3, ButtonFacade
-## X-Embeds: Ace3
+## OptionalDeps: Ace3, ButtonFacade, LibKeyBound-1.0
+## X-Embeds: Ace3, LibKeyBound-1.0
## X-Category: Action Bars
## Version: 4.0
embeds.xml
-keyBound\keyBound.xml
locale\locale.xml
diff --git a/Button.lua b/Button.lua
index 7591650..f3a7afb 100644
--- a/Button.lua
+++ b/Button.lua
@@ -16,6 +16,7 @@ local IsUsableAction = IsUsableAction
local IsActionInRange = IsActionInRange
local LBF = LibStub("LibButtonFacade", true)
+local KeyBound = LibStub("LibKeyBound-1.0")
Bartender4.Button = {}
Bartender4.Button.prototype = Button
diff --git a/ButtonBar.lua b/ButtonBar.lua
index c2c8f80..393eef8 100644
--- a/ButtonBar.lua
+++ b/ButtonBar.lua
@@ -23,8 +23,8 @@ 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)
+function Bartender4.ButtonBar:Create(id, config)
+ local bar = setmetatable(Bartender4.Bar:Create(id, config), ButtonBar_MT)
if LBF then
bar.LBFGroup = LBF:Group("Bartender4", tostring(id))
diff --git a/MicroMenu.lua b/MicroMenu.lua
index 96134c2..bec0e50 100644
--- a/MicroMenu.lua
+++ b/MicroMenu.lua
@@ -26,7 +26,7 @@ local noopFunc = function() end
function MicroMenuMod:OnEnable()
if not self.bar then
- self.bar = setmetatable(Bartender4.Bar:Create("MicroMenu", nil, self.db.profile), {__index = MicroMenuBar})
+ self.bar = setmetatable(Bartender4.Bar:Create("MicroMenu", self.db.profile), {__index = MicroMenuBar})
local buttons = {}
table_insert(buttons, CharacterMicroButton)
table_insert(buttons, SpellbookMicroButton)
diff --git a/PetBar.lua b/PetBar.lua
index 46b4d39..ff09839 100644
--- a/PetBar.lua
+++ b/PetBar.lua
@@ -13,6 +13,7 @@ local PetButtonPrototype = CreateFrame("CheckButton")
local PetButton_MT = {__index = PetButtonPrototype}
local LBF = LibStub("LibButtonFacade", true)
+local KeyBound = LibStub("LibKeyBound-1.0")
local defaults = { profile = Bartender4:Merge({
enabled = true,
@@ -26,7 +27,7 @@ end
function PetBarMod:OnEnable()
if not self.bar then
- self.bar = setmetatable(Bartender4.ButtonBar:Create("Pet", nil, self.db.profile), {__index = PetBar})
+ self.bar = setmetatable(Bartender4.ButtonBar:Create("Pet", self.db.profile), {__index = PetBar})
local buttons = {}
for i=1,10 do
diff --git a/StanceBar.lua b/StanceBar.lua
index 4b61aad..f9c217f 100644
--- a/StanceBar.lua
+++ b/StanceBar.lua
@@ -15,6 +15,7 @@ local StanceButton_MT = {__index = StanceButtonPrototype}
local format = string.format
local LBF = LibStub("LibButtonFacade", true)
+local KeyBound = LibStub("LibKeyBound-1.0")
local defaults = { profile = Bartender4:Merge({
enabled = true,
@@ -28,7 +29,7 @@ end
function StanceBarMod:OnEnable()
if not self.bar then
- self.bar = setmetatable(Bartender4.ButtonBar:Create("Stance", nil, self.db.profile), {__index = StanceBar})
+ self.bar = setmetatable(Bartender4.ButtonBar:Create("Stance", self.db.profile), {__index = StanceBar})
self.bar:ClearSetPoint("CENTER")
self.bar:SetScript("OnEvent", StanceBar.OnEvent)
diff --git a/embeds.xml b/embeds.xml
index 779957e..4d18942 100644
--- a/embeds.xml
+++ b/embeds.xml
@@ -10,4 +10,5 @@
+