Quantcast

Using lib for UIButtons module

Darthpred [05-07-15 - 23:53]
Using lib for UIButtons module
Filename
ElvUI_SLE/modules/uibuttons.lua
ElvUI_SLE/options/uibuttons_c.lua
diff --git a/ElvUI_SLE/modules/uibuttons.lua b/ElvUI_SLE/modules/uibuttons.lua
index f94eaa6..e0aa32e 100644
--- a/ElvUI_SLE/modules/uibuttons.lua
+++ b/ElvUI_SLE/modules/uibuttons.lua
@@ -1,16 +1,9 @@
 local E, L, V, P, G = unpack(ElvUI);
 local UB = E:GetModule('SLE_UIButtons');
 local ACD = LibStub("AceConfigDialog-3.0")
+local lib = LibStub("LibUIButtons-1.0")
 local SLE = E:GetModule("SLE")
-local Sk = E:GetModule("Skins")
-
-local BorderColor = E['media'].bordercolor
-UB.NumBut = 4
-UB.ToggleTable = {}
-UB.ConfigTable = {}
-UB.AddonTable = {}
-UB.StatusTable = {}
-UB.RollTable = {}
+local S = E:GetModule("Skins")

 local function CustomRollCall()
 	local min, max = tonumber(E.db.sle.uibuttons.roll.min), tonumber(E.db.sle.uibuttons.roll.max)
@@ -21,558 +14,153 @@ local function CustomRollCall()
 	end
 end

-function UB:OnEnter(self)
-	UB.menuHolder:SetAlpha(1)
-end
-
-function UB:OnLeave(self)
-	if E.db.sle.uibuttons.mouse then
-		UB.menuHolder:SetAlpha(0)
-	end
-end
-
-function UB:UpdateMouseOverSetting()
-	if E.db.sle.uibuttons.mouse then
-		UB.menuHolder:SetAlpha(0)
-	else
-		UB.menuHolder:SetAlpha(1)
-	end
-end
-
-function UB:CreateFrame()
-	UB.menuHolder = CreateFrame("Frame", "SLEUIButtonHolder", E.UIParent)
-	UB.menuHolder:SetFrameStrata("HIGH")
-	UB.menuHolder:SetFrameLevel(5)
-	UB.menuHolder:SetClampedToScreen(true)
-	UB.menuHolder:Point("LEFT", E.UIParent, "LEFT", -2, 0);
-	UB.menuHolder:HookScript('OnEnter', UB.OnEnter)
-	UB.menuHolder:HookScript('OnLeave', UB.OnLeave)
-
-	if E.private.sle.uiButtonStyle == "classic" then
-		UB:CreateCoreButton("Config", "C")
-		UB:CreateCoreButton("Reload", "R")
-		UB:CreateCoreButton("MoveUI", "M")
-		UB:CreateCoreButton("Boss", "B")
-		UB:CreateCoreButton("Addon", "A")
-		UB.NumBut = 5
-
-		UB:ClassicSetup()
-
-		UB.ToggleTable = {
-			UB.menuHolder.Config,
-			UB.menuHolder.Reload,
-			UB.menuHolder.MoveUI,
-			UB.menuHolder.Boss,
-			UB.menuHolder.Addon,
-		}
-	else
-		UB.menuHolder.Config = CreateFrame("Frame", "SLEUIConfigHolder", UB.menuHolder)
-		UB.menuHolder.Config:CreateBackdrop("Transparent")
-		UB:CreateCoreButton("Config", "C")
-		UB:ConfigSetup()
-
-		UB.menuHolder.Addon = CreateFrame("Frame", "SLEUIAddonHolder", UB.menuHolder)
-		UB.menuHolder.Addon:CreateBackdrop("Transparent")
-		UB:CreateCoreButton("Addon", "A")
-		UB:AddonSetup()
-
-		UB.menuHolder.Status = CreateFrame("Frame", "SLEUIStatusHolder", UB.menuHolder)
-		UB.menuHolder.Status:CreateBackdrop("Transparent")
-		UB:CreateCoreButton("Status", "S")
-		UB:StatusSetup()
-
-		UB.menuHolder.Roll = CreateFrame("Frame", "SLEUIRollHolder", UB.menuHolder)
-		UB.menuHolder.Roll:CreateBackdrop("Transparent")
-		UB:CreateCoreButton("Roll", "R")
-		UB:RollSetup()
-
-		UB.ToggleTable = {
-			UB.menuHolder.Config.Toggle,
-			UB.menuHolder.Addon.Toggle,
-			UB.menuHolder.Status.Toggle,
-			UB.menuHolder.Roll.Toggle,
-		}
-	end
-end
-
-function UB:CreateCoreButton(name, text)
-	local button
-	if E.private.sle.uiButtonStyle == "classic" then
-		UB.menuHolder[name] = CreateFrame("Button", "SLEUI"..name, UB.menuHolder)
-		button = UB.menuHolder[name]
-	else
-		UB.menuHolder[name].Toggle = CreateFrame("Button", "SLEUI"..name.."Toggle", UB.menuHolder)
-		button = UB.menuHolder[name].Toggle
-	end
-	button.text = button:CreateFontString(nil, "OVERLAY")
-	button.text:SetPoint("CENTER", button, "CENTER", 0, 0)
-	UB.menuHolder[name]:HookScript('OnEnter', UB.OnEnter)
-	UB.menuHolder[name]:HookScript('OnLeave', UB.OnLeave)
-	Sk:HandleButton(button)
-
-	if text then
-		local t = button:CreateFontString(nil,"OVERLAY",button)
-		t:FontTemplate()
-		t:SetPoint("CENTER", button, 'CENTER', 0, -1)
-		t:SetJustifyH("CENTER")
-		t:SetText(text)
-		button:SetFontString(t)
-	end
-end
-
---[[
-A function to create a dropdown button for pretty much anything in any UB's dropdown.
-UB:CreateDropdownButton(always, parent, name, text, tooltip1, tooltip2, click, addon)
-
-always - (boolean) true if the button should be shown no matter what
-parent - (string) a group the button will be in: Config, Addon, Status, Roll
-name - (string) unique button's name used for table reference and actual name creation
-text - (string) a string that will be shown on button
-tooltip1 (string) - upper line of button's tooltip shown in yellow-ish color. Mandatory for creating a tooltip. If tooltip is not needed set to nil
-tooltip2 (string) - lower line of the tooltip shown in white color. If not needed set to nil
-click - (function) a function executed on button click. Preferably in the form of function() <your stuff here> end
-addon (string) - if button's function requires an addon to function should be addon's name for IsAddOnLoaded check. the button will not be shown if check is failed.
-
-To hook your button into UB dropdown use this method:
-
-local E = ElvUI[1]
-local UB = E:GetModule('SLE_UIButtons');
-local function MyButtonInsert()
-	UB:CreateDropdownButton(always, parent, name, text, tooltip1, tooltip2, click, addon)
-end
-hooksecurefunc(UB, "InsertButtons", MyButtonInsert)
-
-You can have as many buttons created inside your function as you want.
-]]
-
-function UB:CreateDropdownButton(always, parent, name, text, tooltip1, tooltip2, click, addon)
-	if type(always) ~= "boolean" then
-		SLE:Print(format("You function contains unappropriate type for 1st argument \""..E["media"].hexvaluecolor.."always|r\" in function "..E["media"].hexvaluecolor.."UB:CreateDropdownButton|r. Your type is "..E["media"].hexvaluecolor.."%s|r (should be \"boolean\"). Parent: "..E["media"].hexvaluecolor.."%s|r. Name: "..E["media"].hexvaluecolor.."%s|r", type(always), parent, name))
-		return
-	elseif not UB.menuHolder[parent] then
-		SLE:Print(format("You function contains unappropriate type for 2nd argument \""..E["media"].hexvaluecolor.."parent|r\" in function "..E["media"].hexvaluecolor.."UB:CreateDropdownButton|r. Parent frame: "..E["media"].hexvaluecolor.."UB.menuHolder.%s|r doesn't exist.", parent))
-		return
-	elseif not name or type(name) ~= "string" then
-		SLE:Print(format("You function contains unappropriate type for 3rd argument \""..E["media"].hexvaluecolor.."name|r\" in function "..E["media"].hexvaluecolor.."UB:CreateDropdownButton|r. Your type is "..E["media"].hexvaluecolor.."%s|r (should be \"strigh\"). Parent: "..E["media"].hexvaluecolor.."%s|r.", type(name), parent))
-		return
-	elseif type(click) ~= "function" then
-		SLE:Print(format("You function contains unappropriate type for 7th argument \""..E["media"].hexvaluecolor.."click|r\" in function "..E["media"].hexvaluecolor.."UB:CreateDropdownButton|r. Your type is "..E["media"].hexvaluecolor.."%s|r (should be \"function\"). Parent: "..E["media"].hexvaluecolor.."%s|r. Name: "..E["media"].hexvaluecolor.."%s|r", type(click), parent, name))
-		return
-	elseif (tooltip1 and type(tooltip1) ~= "string") or (tooltip2 and type(tooltip2) ~= "string") then
-		SLE:Print(format("You function contains unappropriate type for 5th or 6th argument \""..E["media"].hexvaluecolor.."tooltip|r\" in function "..E["media"].hexvaluecolor.."UB:CreateDropdownButton|r. Parent: "..E["media"].hexvaluecolor.."%s|r. Name: "..E["media"].hexvaluecolor.."%s|r", parent, name))
-		return
-	elseif (addon and type(addon) ~= "string" and type(addon) ~= nil and name ~= "Boss") then
-		SLE:Print(format("You function contains unappropriate type for 8rd argument \""..E["media"].hexvaluecolor.."addon|r\" in function "..E["media"].hexvaluecolor.."UB:CreateDropdownButton|r. Your type is "..E["media"].hexvaluecolor.."%s|r (should be \"strigh\"). Parent: "..E["media"].hexvaluecolor.."%s|r. Name: "..E["media"].hexvaluecolor.."%s|r", type(addon), parent, name))
-		return
-	end
-	UB.menuHolder[parent][name] = CreateFrame("Button", "SLEUI"..parent..name, UB.menuHolder[parent])
-	local b = UB.menuHolder[parent][name]
-	local toggle = UB.menuHolder[parent].Toggle
-	if addon and name == "Boss" then
-		b.shown = true
-		b.bossmode = function() end
-		if IsAddOnLoaded("DBM-Core") then
-			b.bossmode = function() DBM:LoadGUI() end
-		-- elseif IsAddOnLoaded("Bigwigs") then
-			-- b.bossmode = function() end
-		elseif IsAddOnLoaded("VEM-Core") then
-			b.bossmode = function() VEM:LoadGUI() end
-		-- elseif IsAddOnLoaded("DXE_Loader") then
-			-- b.bossmode = function() end
-		-- elseif IsAddOnLoaded("") then
-			-- b.bossmode = function() end
-		else
-			b.shown = false
-		end
-	elseif always and type(always) == "boolean" then
-		b.shown = true
-	elseif addon then
-		if IsAddOnLoaded(addon) then
-			b.shown = true
-		else
-			b.shown = false
-		end
-	end
-	if not b.shown then return end
-
-	b:SetScript("OnClick", function(self)
-		click()
-		toggle.opened = false
-		UB:ToggleCats()
-	end)
-
-	if tooltip1 then
-		b:SetScript("OnEnter", function(self)
-			UB:OnEnter()
-			GameTooltip:SetOwner(self)
-			GameTooltip:AddLine(tooltip1, 1, .96, .41, .6, .6, 1)
-			if tooltip2 then GameTooltip:AddLine(tooltip2, 1, 1, 1, 1, 1, 1) end
-			GameTooltip:Show()
-		end)
-		b:SetScript("OnLeave", function(self)
-			UB:OnLeave()
-			GameTooltip:Hide()
-		end)
-	else
-		b:HookScript('OnEnter', UB.OnEnter)
-		b:HookScript('OnEnter', UB.OnEnter)
-	end
-	Sk:HandleButton(b)
-
-	if text and type(text) == "string" then
-		b.text = b:CreateFontString(nil,"OVERLAY",b)
-		b.text:FontTemplate()
-		b.text:SetPoint("CENTER", b, 'CENTER', 0, -1)
-		b.text:SetJustifyH("CENTER")
-		b.text:SetText(text)
-		b:SetFontString(b.text)
-	end
-
-	tinsert(UB[parent.."Table"], b)
-end
-
-function UB:CreateSeparator(parent, name, size, space)
-	UB.menuHolder[parent][name] = CreateFrame("Frame", "SLEUI"..parent..name, UB.menuHolder[parent])
-	local f = UB.menuHolder[parent][name]
-	f.isSeparator = true
-	f.shown = true
-	f.size = size or 1
-	f.space = space or 2
-	f:CreateBackdrop("Transparent")
-
-	tinsert(UB[parent.."Table"], f)
-end
-
-function UB:ToggleCats()
-	if UB.menuHolder.Config.Toggle.opened then
-		UB.menuHolder.Config:Show()
-	else
-		UB.menuHolder.Config:Hide()
-	end
-	if UB.menuHolder.Addon.Toggle.opened then
-		UB.menuHolder.Addon:Show()
-	else
-		UB.menuHolder.Addon:Hide()
-	end
-	if UB.menuHolder.Status.Toggle.opened then
-		UB.menuHolder.Status:Show()
-	else
-		UB.menuHolder.Status:Hide()
-	end
-	if UB.menuHolder.Roll.Toggle.opened then
-		UB.menuHolder.Roll:Show()
-	else
-		UB.menuHolder.Roll:Hide()
-	end
-end
-
-function UB:ClassicSetup()
+function UB:ClassicSetup(menu)
 	local button
-	local db = E.db.sle.uibuttons

-	button = UB.menuHolder.Config
+	button = menu.Config
 	button:SetScript("OnClick", function(self)
 		E:ToggleConfig()
 	end)
-	button:HookScript('OnEnter', UB.OnEnter)
-	button:HookScript('OnLeave', UB.OnLeave)
+	button:HookScript('OnEnter', function(self) OnEnter(self, menu) end)
+	button:HookScript('OnLeave', function(self) OnLeave(self, menu) end)

-	button = UB.menuHolder.Reload
+	button = menu.Reload
 	button:SetScript("OnClick", function(self)
 		ReloadUI()
 	end)
-	button:HookScript('OnEnter', UB.OnEnter)
-	button:HookScript('OnLeave', UB.OnLeave)
+	button:HookScript('OnEnter', function(self) OnEnter(self, menu) end)
+	button:HookScript('OnLeave', function(self) OnLeave(self, menu) end)

-	button = UB.menuHolder.MoveUI
+	button = menu.MoveUI
 	button:SetScript("OnClick", function(self)
 		E:ToggleConfigMode()
 	end)
-	button:HookScript('OnEnter', UB.OnEnter)
-	button:HookScript('OnLeave', UB.OnLeave)
+	button:HookScript('OnEnter', function(self) OnEnter(self, menu) end)
+	button:HookScript('OnLeave', function(self) OnLeave(self, menu) end)

-	button = UB.menuHolder.Boss
+	button = menu.Boss
 	button:SetScript("OnClick", function(self)
 		if IsAddOnLoaded("DBM-Core") then
 			DBM:LoadGUI()
-		-- elseif IsAddOnLoaded("Bigwigs") then
-			-- b.bossmode = function() end
 		elseif IsAddOnLoaded("VEM-Core") then
 			VEM:LoadGUI()
-		-- elseif IsAddOnLoaded("DXE_Loader") then
-			-- b.bossmode = function() end
-		-- elseif IsAddOnLoaded("") then
-			-- b.bossmode = function() end
 		end
 	end)
-	button:HookScript('OnEnter', UB.OnEnter)
-	button:HookScript('OnLeave', UB.OnLeave)
+	button:HookScript('OnEnter', function(self) OnEnter(self, menu) end)
+	button:HookScript('OnLeave', function(self) OnLeave(self, menu) end)

-	button = UB.menuHolder.Addon
+	button = menu.Addon
 	button:SetScript("OnClick", function(self)
 		GameMenuButtonAddons:Click()
 	end)
-	button:HookScript('OnEnter', UB.OnEnter)
-	button:HookScript('OnLeave', UB.OnLeave)
+	button:HookScript('OnEnter', function(self) OnEnter(self, menu) end)
+	button:HookScript('OnLeave', function(self) OnLeave(self, menu) end)
 end

-function UB:ConfigSetup()
-	local button = UB.menuHolder.Config.Toggle
-	local db = E.db.sle.uibuttons
-	button.opened = false
-
-	UB.menuHolder.Config:Hide()
-	button:RegisterForClicks("LeftButtonDown", "RightButtonDown");
-	button:SetScript("OnClick", function(self, button, down)
-		if button == "LeftButton" then
-			if self.opened then
-				self.opened = false
-			else
-				self.opened = true
-				UB.menuHolder.Addon.Toggle.opened = false
-				UB.menuHolder.Status.Toggle.opened = false
-				UB.menuHolder.Roll.Toggle.opened = false
-			end
-			UB:ToggleCats()
-		elseif button == "RightButton" and E.db.sle.uibuttons.cfunc.enable then
-			UB.menuHolder.Config[E.db.sle.uibuttons.cfunc.called]:Click()
-		end
-	end)
-	button:HookScript('OnEnter', UB.OnEnter)
-	button:HookScript('OnLeave', UB.OnLeave)
-
+function UB:ConfigSetup(menu)
 	--UB:CreateSeparator("Config", "SLE_StartSeparator", 1, 2)
-	UB:CreateDropdownButton(true, "Config", "Elv", "ElvUI", L["ElvUI Config"], L["Click to toggle config window"],  function() E:ToggleConfig() end)
-	UB:CreateDropdownButton(true, "Config", "SLE", "S&L", L["S&L Config"], L["Click to toggle Shadow & Light config group"],  function() E:ToggleConfig(); ACD:SelectGroup("ElvUI", "sle", "options") end)
-	UB:CreateSeparator("Config", "SLE_FirstSeparator", 4, 2)
-	UB:CreateDropdownButton(true, "Config", "Reload", "/reloadui", L["Reload UI"], L["Click to reload your interface"],  function() ReloadUI() end)
-	UB:CreateDropdownButton(true, "Config", "MoveUI", "/moveui", L["Move UI"], L["Click to unlock moving ElvUI elements"],  function() E:ToggleConfigMode() end)
+	menu:CreateDropdownButton("Config", "Elv", "ElvUI", L["ElvUI Config"], L["Click to toggle config window"],  function() E:ToggleConfig() end, nil, true)
+	menu:CreateDropdownButton("Config", "SLE", "S&L", L["S&L Config"], L["Click to toggle Shadow & Light config group"],  function() E:ToggleConfig(); ACD:SelectGroup("ElvUI", "sle", "options") end, nil, true)
+	menu:CreateSeparator("Config", "First", 4, 2)
+	menu:CreateDropdownButton( "Config", "Reload", "/reloadui", L["Reload UI"], L["Click to reload your interface"],  function() ReloadUI() end, nil, true)
+	menu:CreateDropdownButton("Config", "MoveUI", "/moveui", L["Move UI"], L["Click to unlock moving ElvUI elements"],  function() E:ToggleConfigMode() end, nil, true)
 	--UB:CreateSeparator("Config", "SLE_EndSeparator", 1, 2)
 end

-function UB:AddonSetup()
-	local button = UB.menuHolder.Addon.Toggle
-	button.opened = false
-	UB.menuHolder.Addon:Hide()
-
-	button:RegisterForClicks("LeftButtonDown", "RightButtonDown");
-	button:SetScript("OnClick", function(self, button, down)
-		if button == "LeftButton" then
-			if self.opened then
-				self.opened = false
-			else
-				self.opened = true
-				UB.menuHolder.Config.Toggle.opened = false
-				UB.menuHolder.Status.Toggle.opened = false
-				UB.menuHolder.Roll.Toggle.opened = false
-			end
-			UB:ToggleCats()
-		elseif button == "RightButton" and E.db.sle.uibuttons.afunc.enable then
-			UB.menuHolder.Addon[E.db.sle.uibuttons.afunc.called]:Click()
-		end
-	end)
-	button:HookScript('OnEnter', UB.OnEnter)
-	button:HookScript('OnLeave', UB.OnLeave)
-
+function UB:AddonSetup(menu)
 	--UB:CreateSeparator("Addon", "SLE_StartSeparator", 1, 2)
-	UB:CreateDropdownButton(true, "Addon", "Manager", L["AddOns"], L["AddOns Manager"], L["Click to toggle the AddOn Manager frame."],  function() GameMenuButtonAddons:Click() end)
-	UB:CreateDropdownButton(false, "Addon", "Boss", L["Boss Mod"], L["Boss Mod"], L["Click to toggle the Configuration/Option Window from the Bossmod you have enabled."], function() UB.menuHolder.Addon.Boss.bossmode() end, true)
-	UB:CreateSeparator("Addon", "SLE_FirstSeparator", 4, 2)
-	UB:CreateDropdownButton(false, "Addon", "Altoholic", "Altoholic", nil, nil, function() Altoholic:ToggleUI() end, "Altoholic")
-	UB:CreateDropdownButton(false, "Addon", "AtlasLoot", "AtlasLoot", nil, nil, function() AtlasLoot.GUI:Toggle() end, "AtlasLoot")
-	UB:CreateDropdownButton(false, "Addon", "WeakAuras", "WeakAuras", nil, nil, function() SlashCmdList.WEAKAURAS() end, "WeakAuras")
-	UB:CreateDropdownButton(false, "Addon", "xCT", "xCT+", nil, nil, function() xCT_Plus:ToggleConfigTool() end, "xCT+")
-	UB:CreateDropdownButton(false, "Addon", "Swatter", "Swatter", nil, nil, function() Swatter.ErrorShow() end, "!Swatter")
+	menu:CreateDropdownButton("Addon", "Manager", L["AddOns"], L["AddOns Manager"], L["Click to toggle the AddOn Manager frame."],  function() GameMenuButtonAddons:Click() end, nil, true)
+
+	menu:CreateDropdownButton("Addon", "DBM", L["Boss Mod"], L["Boss Mod"], L["Click to toggle the Configuration/Option Window from the Bossmod you have enabled."], function() DBM:LoadGUI() end, "DBM-Core")
+	menu:CreateDropdownButton("Addon", "VEM", L["Boss Mod"], L["Boss Mod"], L["Click to toggle the Configuration/Option Window from the Bossmod you have enabled."], function() VEM:LoadGUI() end, "VEM-Core")
+	menu:CreateSeparator("Addon", "First", 4, 2)
+	menu:CreateDropdownButton("Addon", "Altoholic", "Altoholic", nil, nil, function() Altoholic:ToggleUI() end, "Altoholic")
+	menu:CreateDropdownButton("Addon", "AtlasLoot", "AtlasLoot", nil, nil, function() AtlasLoot.GUI:Toggle() end, "AtlasLoot")
+	menu:CreateDropdownButton("Addon", "WeakAuras", "WeakAuras", nil, nil, function() SlashCmdList.WEAKAURAS() end, "WeakAuras")
+	menu:CreateDropdownButton("Addon", "xCT", "xCT+", nil, nil, function() xCT_Plus:ToggleConfigTool() end, "xCT+")
+	menu:CreateDropdownButton("Addon", "Swatter", "Swatter", nil, nil, function() Swatter.ErrorShow() end, "!Swatter")


 	--Always keep at the bottom--
-	UB:CreateDropdownButton(false, "Addon", "WowLua", "WowLua", nil, nil, function() SlashCmdList["WOWLUA"]("") end, "WowLua")
+	menu:CreateDropdownButton("Addon", "WowLua", "WowLua", nil, nil, function() SlashCmdList["WOWLUA"]("") end, "WowLua", false)
 	--UB:CreateSeparator("Addon", "SLE_EndSeparator", 1, 2)
 end

-function UB:StatusSetup()
-	local button = UB.menuHolder.Status.Toggle
-	local db = E.db.sle.uibuttons
-	button.opened = false
-	UB.menuHolder.Status:Point("TOP", button, "BOTTOM", 0, -4)
-	UB.menuHolder.Status:Hide()
-	button:RegisterForClicks("LeftButtonDown", "RightButtonDown");
-	button:SetScript("OnClick", function(self, button, down)
-		if button == "LeftButton" then
-			if self.opened then
-				self.opened = false
-			else
-				self.opened = true
-				UB.menuHolder.Config.Toggle.opened = false
-				UB.menuHolder.Addon.Toggle.opened = false
-				UB.menuHolder.Roll.Toggle.opened = false
-			end
-			UB:ToggleCats()
-		elseif button == "RightButton" and E.db.sle.uibuttons.sfunc.enable then
-			UB.menuHolder.Status[E.db.sle.uibuttons.sfunc.called]:Click()
-		end
-	end)
-	button:HookScript('OnEnter', UB.OnEnter)
-	button:HookScript('OnLeave', UB.OnLeave)
-
-	UB:CreateDropdownButton(true, "Status", "AFK", L["AFK"], nil, nil,  function() SendChatMessage("" ,"AFK" ) end)
-	UB:CreateDropdownButton(true, "Status", "DND", L["DND"], nil, nil,  function() SendChatMessage("" ,"DND" ) end)
+function UB:StatusSetup(menu)
+	menu:CreateDropdownButton("Status", "AFK", L["AFK"], nil, nil,  function() SendChatMessage("" ,"AFK" ) end)
+	menu:CreateDropdownButton("Status", "DND", L["DND"], nil, nil,  function() SendChatMessage("" ,"DND" ) end)
 end

-function UB:RollSetup()
-	local button = UB.menuHolder.Roll.Toggle
-	local db = E.db.sle.uibuttons
-	button.opened = false
-	UB.menuHolder.Roll:Point("TOP", button, "BOTTOM", 0, -4)
-	UB.menuHolder.Roll:Hide()
-	button:RegisterForClicks("LeftButtonDown", "RightButtonDown");
-	button:SetScript("OnClick", function(self, button, down)
-		if button == "LeftButton" then
-			if self.opened then
-				self.opened = false
-			else
-				self.opened = true
-				UB.menuHolder.Config.Toggle.opened = false
-				UB.menuHolder.Addon.Toggle.opened = false
-				UB.menuHolder.Status.Toggle.opened = false
-			end
-			UB:ToggleCats()
-		elseif button == "RightButton" and E.db.sle.uibuttons.rfunc.enable then
-			UB.menuHolder.Roll[E.db.sle.uibuttons.rfunc.called]:Click()
-		end
-	end)
-	button:HookScript('OnEnter', UB.OnEnter)
-	button:HookScript('OnLeave', UB.OnLeave)
-
-	UB:CreateDropdownButton(true, "Roll", "Ten", "1-10", nil, nil,  function() RandomRoll(1, 10) end)
-	UB:CreateDropdownButton(true, "Roll", "Twenty", "1-20", nil, nil,  function() RandomRoll(1, 20) end)
-	UB:CreateDropdownButton(true, "Roll", "Thirty", "1-30", nil, nil,  function() RandomRoll(1, 30) end)
-	UB:CreateDropdownButton(true, "Roll", "Forty", "1-40", nil, nil,  function() RandomRoll(1, 40) end)
-	UB:CreateDropdownButton(true, "Roll", "Hundred", "1-100", nil, nil,  function() RandomRoll(1, 100) end)
-	UB:CreateDropdownButton(true, "Roll", "Custom", L["Custom"], nil, nil,  function() CusomRollCall() end)
+function UB:RollSetup(menu)
+	menu:CreateDropdownButton("Roll", "Ten", "1-10", nil, nil,  function() RandomRoll(1, 10) end)
+	menu:CreateDropdownButton("Roll", "Twenty", "1-20", nil, nil,  function() RandomRoll(1, 20) end)
+	menu:CreateDropdownButton("Roll", "Thirty", "1-30", nil, nil,  function() RandomRoll(1, 30) end)
+	menu:CreateDropdownButton("Roll", "Forty", "1-40", nil, nil,  function() RandomRoll(1, 40) end)
+	menu:CreateDropdownButton("Roll", "Hundred", "1-100", nil, nil,  function() RandomRoll(1, 100) end)
+	menu:CreateDropdownButton("Roll", "Custom", L["Custom"], nil, nil,  function() CustomRollCall() end)
 end

-function UB:MoverSize()
-	local db = E.db.sle.uibuttons
-	if db.position == "uib_vert" then
-		UB.menuHolder:SetWidth(db.size + (E.PixelMode and 2 or 4))
-		UB.menuHolder:SetHeight((db.size*UB.NumBut)+((E.PixelMode and db.spacing or db.spacing+2)*(UB.NumBut-1))+2)
+function UB:SetupBar(menu)
+	if E.private.sle.uiButtonStyle == "classic" then
+		menu:CreateCoreButton("Config", "C")
+		menu:CreateCoreButton("Reload", "R")
+		menu:CreateCoreButton("MoveUI", "M")
+		menu:CreateCoreButton("Boss", "B")
+		menu:CreateCoreButton("Addon", "A")
+		UB:ClassicSetup(menu)
 	else
-		UB.menuHolder:SetWidth((db.size*UB.NumBut)+((E.PixelMode and db.spacing or db.spacing+2)*(UB.NumBut-1))+2)
-		UB.menuHolder:SetHeight(db.size + (E.PixelMode and 2 or 4))
-	end
-end
+		menu:CreateCoreButton("Config", "C")
+		UB:ConfigSetup(menu)

-function UB:FrameSize()
-	local db = E.db.sle.uibuttons
-	if not db.size then return end
-	UB:MoverSize()
+		menu:CreateCoreButton("Addon", "A")
+		UB:AddonSetup(menu)

-	for i = 1, #UB.ToggleTable do
-		UB.ToggleTable[i]:Size(db.size)
-	end
+		menu:CreateCoreButton("Status", "S")
+		UB:StatusSetup(menu)

-	if E.private.sle.uiButtonStyle == "dropdown" then
-		for i = 1, #UB.MetaTable do
-			local group = UB.MetaTable[i]
-			local mass = UB[group.."Table"]
-			for n = 1, #mass do
-				if mass[n].isSeparator then
-					mass[n]:Size((db.size * 3.1) - 2, mass[n].size)
-				else
-					mass[n]:Size(db.size * 3.1, db.size)
-				end
-			end
-		end
+		menu:CreateCoreButton("Roll", "R")
+		UB:RollSetup(menu)
 	end
-
-	UB:Positioning()
 end

-function UB:UpdateDropdownLayout(group, backdrop)
-	local count = -1
-	local sepS, sepC = 0, 0
-	local header = UB.menuHolder[group]
-	local db = E.db.sle.uibuttons
-	header:ClearAllPoints()
-	header:Point(db.point, header.Toggle, db.anchor, db.xoffset, db.yoffset)
-	local T = UB[group.."Table"]
-	for i = 1, #T do
-		local button, prev, next = T[i], T[i-1], T[i+1]
-		local y_offset = prev and ((E.PixelMode and -db.spacing or -(db.spacing+2))-(prev.isSeparator and prev.space or 0)-(button.isSeparator and button.space or 0)) or 0
-		button:Point("TOP", (prev or header), (prev and "BOTTOM" or "TOP"), 0, y_offset)
-		count = button.isSeparator and count or count + 1
-		sepS = (button.isSeparator and sepS + ((prev and 2 or 1)*button.space + button.size)) or sepS
-		sepC = button.isSeparator and sepC + 1 or sepC
-	end
-	header:Size(db.size * 3.1, (db.size * (count+1))+(db.spacing*(count))+sepS+(.5*sepC))
-	if backdrop then
-		header.backdrop:Show()
-	else
-		header.backdrop:Hide()
+function UB:RightClicks(menu)
+	for i = 1, #menu.ToggleTable do
+		menu.ToggleTable[i]:RegisterForClicks("LeftButtonDown", "RightButtonDown")
 	end
-end
-
-function UB:Positioning()
-	local db = E.db.sle.uibuttons
-
-	--position check
-	local header = UB.menuHolder
-	if db.position == "uib_vert" then
-		for i = 1, #UB.ToggleTable do
-			local button, prev = UB.ToggleTable[i], UB.ToggleTable[i-1]
-			UB.ToggleTable[i]:ClearAllPoints()
-			UB.ToggleTable[i]:Point("TOP", (prev or header), prev and "BOTTOM" or "TOP", 0, prev and (E.PixelMode and -db.spacing or -(db.spacing+2)) or (E.PixelMode and -1 or -2))
+
+	menu.Config.Toggle:HookScript("OnClick", function(self, button, down)
+		if button == "RightButton" and E.db.sle.uibuttons.Config.enable then
+			menu.Addon[menu.db.Config.called]:Click()
 		end
-	else
-		for i = 1, #UB.ToggleTable do
-			local button, prev = UB.ToggleTable[i], UB.ToggleTable[i-1]
-			UB.ToggleTable[i]:ClearAllPoints()
-			UB.ToggleTable[i]:Point("LEFT", (prev or header), prev and "RIGHT" or "LEFT", prev and (E.PixelMode and db.spacing or db.spacing+2) or (E.PixelMode and 1 or 2), 0)
+	end)
+	menu.Addon.Toggle:HookScript("OnClick", function(self, button, down)
+		if button == "RightButton" and E.db.sle.uibuttons.Addon.enable then
+			menu.Addon[menu.db.Addon.called]:Click()
 		end
-	end
-	if E.private.sle.uiButtonStyle == "dropdown" then
-		for i = 1, #UB.MetaTable do
-			UB:UpdateDropdownLayout(UB.MetaTable[i], E.db.sle.uibuttons.dropdownBackdrop)
+	end)
+	menu.Status.Toggle:HookScript("OnClick", function(self, button, down)
+		if button == "RightButton" and E.db.sle.uibuttons.Status.enable then
+			menu.Addon[menu.db.Status.called]:Click()
 		end
-	end
+	end)
+	menu.Roll.Toggle:HookScript("OnClick", function(self, button, down)
+		if button == "RightButton" and E.db.sle.uibuttons.Roll.enable then
+			menu.Addon[menu.db.Roll.called]:Click()
+		end
+	end)
 end

-function UB:Toggle()
-	if not E.db.sle.uibuttons.enable then
-		UB.menuHolder:Hide()
-	else
-		UB.menuHolder:Show()
-		UB:UpdateMouseOverSetting()
-	end
-end
+function UB:Initialize()
+	UB.Holder = lib:CreateFrame("SLE_UIButtons", E.db.sle.uibuttons, P.sle.uibuttons, E.private.sle.uiButtonStyle, "dropdown")
+	local menu = UB.Holder
+	menu:SetupMover(L["S&L UI Buttons"], "ALL,S&L,S&L MISC,UIButtons")

-function UB:CreateMetaTable()
-	if E.private.sle.uiButtonStyle ~= "dropdown" then return end
-	UB.MetaTable = {
-		"Config",
-		"Addon",
-		"Status",
-		"Roll",
-	}
-end
+	UB:SetupBar(menu)

-function UB:InsertButtons()
-	--This function is purely cosmetic and used only for hooking other button creating funct to it by any external addon
-end
+	menu:FrameSize()
+	menu:ToggleShow()

-function UB:Initialize()
-	UB:CreateFrame()
-
-	UB:InsertButtons() --For external buttons
-
-	UB:CreateMetaTable()
-
-	UB:FrameSize()
-	UB:Toggle()
-
-	E.FrameLocks['SLEUIButtonHolder'] = true
-
-	E:CreateMover(UB.menuHolder, "UIBFrameMover", L["UI Buttons"], nil, nil, nil, "ALL,S&L,S&L MISC")
-	UB:MoverSize()
+	UB.FrameSize = menu.FrameSize
+
+	UB:RightClicks(menu)
 end
\ No newline at end of file
diff --git a/ElvUI_SLE/options/uibuttons_c.lua b/ElvUI_SLE/options/uibuttons_c.lua
index 50266d5..b31d3cd 100644
--- a/ElvUI_SLE/options/uibuttons_c.lua
+++ b/ElvUI_SLE/options/uibuttons_c.lua
@@ -14,6 +14,7 @@ local positionValues = {
 };

 local function configTable()
+	local Bar = UB.Holder
 	E.Options.args.sle.args.options.args.general.args.uibuttons = {
 		type = "group",
 		name = L["UI Buttons"],
@@ -35,7 +36,7 @@ local function configTable()
 				name = L["Enable"],
 				desc = L["Show/Hide UI buttons."],
 				get = function(info) return E.db.sle.uibuttons.enable end,
-				set = function(info, value) E.db.sle.uibuttons.enable = value; UB:Toggle() end
+				set = function(info, value) E.db.sle.uibuttons.enable = value; Bar:ToggleShow() end
 			},
 			style = {
 				order = 4,
@@ -62,7 +63,7 @@ local function configTable()
 				min = 12, max = 25, step = 1,
 				disabled = function() return not E.db.sle.uibuttons.enable end,
 				get = function(info) return E.db.sle.uibuttons.size end,
-				set = function(info, value) E.db.sle.uibuttons.size = value; UB:FrameSize() end,
+				set = function(info, value) E.db.sle.uibuttons.size = value; Bar:FrameSize() end,
 			},
 			spacing = {
 				order = 7,
@@ -72,7 +73,7 @@ local function configTable()
 				min = 1, max = 10, step = 1,
 				disabled = function() return not E.db.sle.uibuttons.enable end,
 				get = function(info) return E.db.sle.uibuttons.spacing end,
-				set = function(info, value) E.db.sle.uibuttons.spacing = value; UB:FrameSize() end,
+				set = function(info, value) E.db.sle.uibuttons.spacing = value; Bar:FrameSize() end,
 			},
 			mouse = {
 				order = 8,
@@ -81,28 +82,36 @@ local function configTable()
 				desc = L["Show on mouse over."],
 				disabled = function() return not E.db.sle.uibuttons.enable end,
 				get = function(info) return E.db.sle.uibuttons.mouse end,
-				set = function(info, value) E.db.sle.uibuttons.mouse = value; UB:UpdateMouseOverSetting() end
+				set = function(info, value) E.db.sle.uibuttons.mouse = value; Bar:UpdateMouseOverSetting() end
+			},
+			menuBackdrop = {
+				order = 9,
+				type = "toggle",
+				name = L["Backdrop"],
+				disabled = function() return not E.db.sle.uibuttons.enable or E.private.sle.uiButtonStyle == "classic" end,
+				get = function(info) return E.db.sle.uibuttons.menuBackdrop end,
+				set = function(info, value) E.db.sle.uibuttons.menuBackdrop = value; Bar:UpdateBackdrop() end
 			},
 			dropdownBackdrop = {
-				order = 8,
+				order = 10,
 				type = "toggle",
 				name = L["Dropdown Backdrop"],
 				disabled = function() return not E.db.sle.uibuttons.enable or E.private.sle.uiButtonStyle == "classic" end,
 				get = function(info) return E.db.sle.uibuttons.dropdownBackdrop end,
-				set = function(info, value) E.db.sle.uibuttons.dropdownBackdrop = value; UB:FrameSize() end
+				set = function(info, value) E.db.sle.uibuttons.dropdownBackdrop = value; Bar:FrameSize() end
 			},
 			position = {
-				order = 10,
+				order = 11,
 				name = L["Buttons position"],
 				desc = L["Layout for UI buttons."],
 				type = "select",
 				values = {
-					["uib_hor"] = L['Horizontal'],
-					["uib_vert"] = L['Vertical'],
+					["horizontal"] = L['Horizontal'],
+					["vertical"] = L['Vertical'],
 				},
 				disabled = function() return not E.db.sle.uibuttons.enable end,
 				get = function(info) return E.db.sle.uibuttons.position end,
-				set = function(info, value) E.db.sle.uibuttons.position = value; UB:FrameSize() end,
+				set = function(info, value) E.db.sle.uibuttons.position = value; Bar:FrameSize() end,
 			},
 			point = {
 				type = 'select',
@@ -111,7 +120,7 @@ local function configTable()
 				desc = L['What point of dropdown will be attached to the toggle button.'],
 				disabled = function() return not E.db.sle.uibuttons.enable or E.private.sle.uiButtonStyle == "classic" end,
 				get = function(info) return E.db.sle.uibuttons.point end,
-				set = function(info, value) E.db.sle.uibuttons.point = value; UB:FrameSize() end,
+				set = function(info, value) E.db.sle.uibuttons.point = value; Bar:FrameSize() end,
 				values = positionValues,
 			},
 			anchor = {
@@ -121,7 +130,7 @@ local function configTable()
 				desc = L['What point to anchor dropdown on the toggle button.'],
 				disabled = function() return not E.db.sle.uibuttons.enable or E.private.sle.uiButtonStyle == "classic" end,
 				get = function(info) return E.db.sle.uibuttons.anchor end,
-				set = function(info, value) E.db.sle.uibuttons.anchor = value; UB:FrameSize() end,
+				set = function(info, value) E.db.sle.uibuttons.anchor = value; Bar:FrameSize() end,
 				values = positionValues,
 			},
 			xoffset = {
@@ -132,7 +141,7 @@ local function configTable()
 				min = -10, max = 10, step = 1,
 				disabled = function() return not E.db.sle.uibuttons.enable or E.private.sle.uiButtonStyle == "classic" end,
 				get = function(info) return E.db.sle.uibuttons.xoffset end,
-				set = function(info, value) E.db.sle.uibuttons.xoffset = value; UB:FrameSize() end,
+				set = function(info, value) E.db.sle.uibuttons.xoffset = value; Bar:FrameSize() end,
 			},
 			yoffset = {
 				order = 16,
@@ -142,7 +151,7 @@ local function configTable()
 				min = -10, max = 10, step = 1,
 				disabled = function() return not E.db.sle.uibuttons.enable or E.private.sle.uiButtonStyle == "classic" end,
 				get = function(info) return E.db.sle.uibuttons.yoffset end,
-				set = function(info, value) E.db.sle.uibuttons.yoffset = value; UB:FrameSize() end,
+				set = function(info, value) E.db.sle.uibuttons.yoffset = value; Bar:FrameSize() end,
 			},
 			minroll = {
 				order = 17,
@@ -162,7 +171,7 @@ local function configTable()
 				get = function(info) return E.db.sle.uibuttons.roll.max end,
 				set = function(info, value) E.db.sle.uibuttons.roll.max = value; end,
 			},
-			cFunc = {
+			Config = {
 				order = 19,
 				name = "\"C\" "..L["Quick Action"],
 				type = "group",
@@ -174,8 +183,8 @@ local function configTable()
 						type = "toggle",
 						name = L["Enable"],
 						desc = L["Use quick access (on right click) for this button."],
-						get = function(info) return E.db.sle.uibuttons.cfunc.enable end,
-						set = function(info, value) E.db.sle.uibuttons.cfunc.enable = value end
+						get = function(info) return E.db.sle.uibuttons.Config.enable end,
+						set = function(info, value) E.db.sle.uibuttons.Config.enable = value end
 					},
 					called = {
 						order = 2,
@@ -188,12 +197,12 @@ local function configTable()
 							["Reload"] = L["Reload UI"],
 							["MoveUI"] = L["Move UI"],
 						},
-						get = function(info) return E.db.sle.uibuttons.cfunc.called end,
-						set = function(info, value) E.db.sle.uibuttons.cfunc.called = value; end,
+						get = function(info) return E.db.sle.uibuttons.Config.called end,
+						set = function(info, value) E.db.sle.uibuttons.Config.called = value; end,
 					},
 				},
 			},
-			aFunc = {
+			Addon = {
 				order = 20,
 				name = "\"A\" "..L["Quick Action"],
 				type = "group",
@@ -205,8 +214,8 @@ local function configTable()
 						type = "toggle",
 						name = L["Enable"],
 						desc = L["Use quick access (on right click) for this button."],
-						get = function(info) return E.db.sle.uibuttons.afunc.enable end,
-						set = function(info, value) E.db.sle.uibuttons.afunc.enable = value end
+						get = function(info) return E.db.sle.uibuttons.Addon.enable end,
+						set = function(info, value) E.db.sle.uibuttons.Addon.enable = value end
 					},
 					called = {
 						order = 2,
@@ -217,12 +226,12 @@ local function configTable()
 							["Manager"] = L["Addons"],
 							["Boss"] = L["Boss Mod"],
 						},
-						get = function(info) return E.db.sle.uibuttons.afunc.called end,
-						set = function(info, value) E.db.sle.uibuttons.afunc.called = value; end,
+						get = function(info) return E.db.sle.uibuttons.Addon.called end,
+						set = function(info, value) E.db.sle.uibuttons.Addon.called = value; end,
 					},
 				},
 			},
-			sFunc = {
+			Status = {
 				order = 21,
 				name = "\"S\" "..L["Quick Action"],
 				type = "group",
@@ -234,8 +243,8 @@ local function configTable()
 						type = "toggle",
 						name = L["Enable"],
 						desc = L["Use quick access (on right click) for this button."],
-						get = function(info) return E.db.sle.uibuttons.sfunc.enable end,
-						set = function(info, value) E.db.sle.uibuttons.sfunc.enable = value end
+						get = function(info) return E.db.sle.uibuttons.Status.enable end,
+						set = function(info, value) E.db.sle.uibuttons.Status.enable = value end
 					},
 					called = {
 						order = 2,
@@ -246,12 +255,12 @@ local function configTable()
 							["AFK"] = L["AFK"],
 							["DND"] = L["DND"],
 						},
-						get = function(info) return E.db.sle.uibuttons.sfunc.called end,
-						set = function(info, value) E.db.sle.uibuttons.sfunc.called = value; end,
+						get = function(info) return E.db.sle.uibuttons.Status.called end,
+						set = function(info, value) E.db.sle.uibuttons.Status.called = value; end,
 					},
 				},
 			},
-			rFunc = {
+			Roll = {
 				order = 22,
 				name = "\"R\" "..L["Quick Action"],
 				type = "group",
@@ -263,8 +272,8 @@ local function configTable()
 						type = "toggle",
 						name = L["Enable"],
 						desc = L["Use quick access (on right click) for this button."],
-						get = function(info) return E.db.sle.uibuttons.rfunc.enable end,
-						set = function(info, value) E.db.sle.uibuttons.rfunc.enable = value end
+						get = function(info) return E.db.sle.uibuttons.Roll.enable end,
+						set = function(info, value) E.db.sle.uibuttons.Roll.enable = value end
 					},
 					called = {
 						order = 2,
@@ -280,18 +289,13 @@ local function configTable()
 							["Custom"] = L["Custom"],

 						},
-						get = function(info) return E.db.sle.uibuttons.rfunc.called end,
-						set = function(info, value) E.db.sle.uibuttons.rfunc.called = value; end,
+						get = function(info) return E.db.sle.uibuttons.Roll.called end,
+						set = function(info, value) E.db.sle.uibuttons.Roll.called = value; end,
 					},
 				},
 			},
 		},
 	}
-	if E.private.sle.uiButtonStyle == "dropdown" then
-		if IsAddOnLoaded("ElvUI_BenikUI") then
-			E.Options.args.sle.args.options.args.general.args.uibuttons.args.cFunc.args.called.values["Benik"] = "BenikUI"
-		end
-	end
 end

 table.insert(E.SLEConfigs, configTable)
\ No newline at end of file