Quantcast

More visibility state. This closes #287 again

Darthpred [08-20-16 - 16:38]
More visibility state. This closes #287 again
Filename
CHANGELOG.txt
ElvUI_SLE/defaults/profile.lua
ElvUI_SLE/modules/backgrounds.lua
ElvUI_SLE/options/backgrounds_c.lua
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index de60344..0963e7c 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -6,7 +6,7 @@ Additions:
 - Quick action option for UI Buttons' addon section received some love = more variants
 - Added an option to show only numbers in instance indicator
 - Location panel menu now contains challenge mode teleports
-- UI BUttons now have visibility state option. Works like actionbar visibility.
+- UI BUttons and Background panels now have visibility state option. Works like actionbar visibility.
 - Added an option to select background template for vehicle bar.
 Fixes:
 - Attempted to fix error with S&L guild dt when one of guild members happen to be in the middle of actual nowhere
diff --git a/ElvUI_SLE/defaults/profile.lua b/ElvUI_SLE/defaults/profile.lua
index 6c7ea34..75ea8a4 100644
--- a/ElvUI_SLE/defaults/profile.lua
+++ b/ElvUI_SLE/defaults/profile.lua
@@ -28,6 +28,7 @@ P["sle"] = {
 			["template"] = "Default",
 			["alpha"] = 1,
 			["clickthrough"] = true,
+			["visibility"] = "show",
 		},
 		["bg2"] = {
 			["enabled"] = false,
@@ -41,6 +42,7 @@ P["sle"] = {
 			["template"] = "Default",
 			["alpha"] = 1,
 			["clickthrough"] = false,
+			["visibility"] = "show",
 		},
 		["bg3"] = {
 			["enabled"] = false,
@@ -54,6 +56,7 @@ P["sle"] = {
 			["template"] = "Default",
 			["alpha"] = 1,
 			["clickthrough"] = false,
+			["visibility"] = "show",
 		},
 		["bg4"] = {
 			["enabled"] = false,
@@ -67,6 +70,7 @@ P["sle"] = {
 			["template"] = "Default",
 			["alpha"] = 1,
 			["clickthrough"] = true,
+			["visibility"] = "show",
 		},
 	},
 		--Bags
diff --git a/ElvUI_SLE/modules/backgrounds.lua b/ElvUI_SLE/modules/backgrounds.lua
index 4c95999..5d74ff3 100644
--- a/ElvUI_SLE/modules/backgrounds.lua
+++ b/ElvUI_SLE/modules/backgrounds.lua
@@ -53,9 +53,11 @@ function BG:FramesVisibility(i)
 	if BG.db["bg"..i].enabled then
 		BG["Frame_"..i]:Show()
 		E:EnableMover(BG["Frame_"..i].mover:GetName())
+		RegisterStateDriver(BG["Frame_"..i], "visibility", BG.db["bg"..i].visibility)
 	else
 		BG["Frame_"..i]:Hide()
 		E:DisableMover(BG["Frame_"..i].mover:GetName())
+		UnregisterStateDriver(BG["Frame_"..i], "visibility")
 	end
 end

diff --git a/ElvUI_SLE/options/backgrounds_c.lua b/ElvUI_SLE/options/backgrounds_c.lua
index fc0dd78..df04015 100644
--- a/ElvUI_SLE/options/backgrounds_c.lua
+++ b/ElvUI_SLE/options/backgrounds_c.lua
@@ -90,6 +90,14 @@ local function configTable()
 					get = function(info) return E.db.sle.backgrounds["bg"..i].alpha end,
 					set = function(info, value) E.db.sle.backgrounds["bg"..i].alpha = value; BG:Alpha(i) end,
 				},
+				visibility = {
+					order = 13,
+					type = 'input',
+					width = 'full',
+					name = L["Visibility State"],
+					get = function(info) return E.db.sle.backgrounds["bg"..i].visibility end,
+					set = function(info, value) E.db.sle.backgrounds["bg"..i].visibility = value; BG:FramesVisibility(i) end,
+				},
 			},
 		}
 		return config