Quantcast

-- Per latest API, update the drop down lib to use a given menu background

urnati [02-05-22 - 15:27]
-- Per latest API, update the drop down lib to use a given menu background
Filename
TitanClassic/libs/!LibUIDropDownMenu/LibUIDropDownMenu/LibUIDropDownMenu.lua
diff --git a/TitanClassic/libs/!LibUIDropDownMenu/LibUIDropDownMenu/LibUIDropDownMenu.lua b/TitanClassic/libs/!LibUIDropDownMenu/LibUIDropDownMenu/LibUIDropDownMenu.lua
index fdcb4dd..cbbddc9 100755
--- a/TitanClassic/libs/!LibUIDropDownMenu/LibUIDropDownMenu/LibUIDropDownMenu.lua
+++ b/TitanClassic/libs/!LibUIDropDownMenu/LibUIDropDownMenu/LibUIDropDownMenu.lua
@@ -31,7 +31,7 @@ local WoWClassicEra, WoWClassicTBC, WoWRetail
 local wowtocversion  = select(4, GetBuildInfo())
 if wowtocversion < 20000 then
 	WoWClassicEra = true
-elseif wowtocversion > 19999 and wowtocversion < 90000 then
+elseif wowtocversion > 19999 and wowtocversion < 90000 then
 	WoWClassicTBC = true
 else
 	WoWRetail = true
@@ -117,7 +117,7 @@ local function create_MenuButton(name, parent)
 	f.Highlight:SetBlendMode("ADD")
 	f.Highlight:SetAllPoints()
 	f.Highlight:Hide()
-
+
 	f.Check = f:CreateTexture(name.."Check", "ARTWORK")
 	f.Check:SetTexture("Interface\\Common\\UI-DropDownRadioChecks")
 	f.Check:SetSize(16, 16)
@@ -129,12 +129,12 @@ local function create_MenuButton(name, parent)
 	f.UnCheck:SetSize(16, 16)
 	f.UnCheck:SetPoint("LEFT", f, 0, 0)
 	f.UnCheck:SetTexCoord(0.5, 1, 0.5, 1)
-
+
 	f.Icon = f:CreateTexture(name.."Icon", "ARTWORK")
 	f.Icon:SetSize(16, 16)
 	f.Icon:SetPoint("RIGHT", f, 0, 0)
 	f.Icon:Hide()
-
+
 	-- ColorSwatch
 	local fcw
 	fcw = CreateFrame("Button", name.."ColorSwatch", f, BackdropTemplateMixin and DropDownMenuButtonMixin and "BackdropTemplate,ColorSwatchTemplate" or BackdropTemplateMixin and "BackdropTemplate" or nil)
@@ -166,7 +166,7 @@ local function create_MenuButton(name, parent)
 		lib:UIDropDownMenu_StartCounting(self:GetParent():GetParent())
 	end)
 	f.ColorSwatch = fcw
-
+
 	-- ExpandArrow
 	local fea = CreateFrame("Button", name.."ExpandArrow", f)

@@ -255,7 +255,7 @@ local function create_MenuButton(name, parent)
 				tooltip:Show();
 			end
 		end
-
+
 		if ( self.mouseOverIcon ~= nil ) then
 			self.Icon:SetTexture(self.mouseOverIcon);
 			self.Icon:Show();
@@ -270,7 +270,7 @@ local function create_MenuButton(name, parent)
 		lib:UIDropDownMenu_StartCounting(self:GetParent());

 		tooltip:Hide();
-
+
 		if ( self.mouseOverIcon ~= nil ) then
 			if ( self.icon ~= nil ) then
 				self.Icon:SetTexture(self.icon);
@@ -364,30 +364,41 @@ local BACKDROP_DIALOG_DARK = {
 		edgeSize = 32,
 		insets = { left = 11, right = 12, top = 12, bottom = 9, },
 }
+local back_drop_info =
+	{
+		bgFile="Interface\\Tooltips\\UI-Tooltip-Background",
+		edgeFile="Interface\\Tooltips\\UI-Tooltip-Border",
+		tile = true,
+		tileEdge = true,
+		insets = { left = 1, right = 1, top = 1, bottom = 1 },
+		tileSize = 8,
+		edgeSize = 8,
+	}
+
 local function creatre_DropDownList(name, parent)
 	local f = _G[name] or CreateFrame("Button", name)
 	f:SetParent(parent or nil)
 	f:Hide()
 	f:SetFrameStrata("DIALOG")
 	f:EnableMouse(true)
-
+
 	--local fbd = _G[name.."Border"] or CreateFrame("Frame", name.."Border", f, BackdropTemplateMixin and "DialogBorderDarkTemplate" or nil)
 	local fbd = _G[name.."Border"] or CreateFrame("Frame", name.."Border", f, BackdropTemplateMixin and "BackdropTemplate" or nil)
 	fbd:SetAllPoints()
 	fbd:SetBackdrop(BACKDROP_DIALOG_DARK)
 	f.Border = fbd
-
+
 	--local fmb = _G[name.."MenuBackdrop"] or CreateFrame("Frame", name.."MenuBackdrop", f, BackdropTemplateMixin and "TooltipBackdropTemplate" or nil)
 	local fmb = _G[name.."MenuBackdrop"] or CreateFrame("Frame", name.."MenuBackdrop", f, BackdropTemplateMixin and "BackdropTemplate" or nil)
 	fmb:SetAllPoints()
-	fmb:SetBackdrop(BACKDROP_TOOLTIP_16_16_5555)
+	fmb:SetBackdrop(back_drop_info)
 	fmb:SetBackdropBorderColor(TOOLTIP_DEFAULT_COLOR.r, TOOLTIP_DEFAULT_COLOR.g, TOOLTIP_DEFAULT_COLOR.b)
 	fmb:SetBackdropColor(TOOLTIP_DEFAULT_BACKGROUND_COLOR.r, TOOLTIP_DEFAULT_BACKGROUND_COLOR.g, TOOLTIP_DEFAULT_BACKGROUND_COLOR.b)
 	f.MenuBackdrop = fmb
-
+
 	f.Button1 = _G[name.."Button1"] or create_MenuButton(name.."Button1", f)
 	f.Button1:SetID(1)
-
+
 	f:SetScript("OnClick", function(self)
 		self:Hide()
 	end)
@@ -470,7 +481,7 @@ local function creatre_DropDownList(name, parent)
 		end
 ]]
 	end)
-
+
 	return f
 end

@@ -484,70 +495,70 @@ local function create_DropDownMenu(name, parent)
 	else
 		f = CreateFrame("Frame", name, parent or nil)
 	end
-
+
 	if not name then name = "" end
-
+
 	f:SetSize(40, 32)
-
+
 	f.Left = f:CreateTexture(name.."Left", "ARTWORK")
 	f.Left:SetTexture("Interface\\Glues\\CharacterCreate\\CharacterCreate-LabelFrame")
 	f.Left:SetSize(25, 64)
 	f.Left:SetPoint("TOPLEFT", f, 0, 17)
 	f.Left:SetTexCoord(0, 0.1953125, 0, 1)
-
+
 	f.Middle = f:CreateTexture(name.."Middle", "ARTWORK")
 	f.Middle:SetTexture("Interface\\Glues\\CharacterCreate\\CharacterCreate-LabelFrame")
 	f.Middle:SetSize(115, 64)
 	f.Middle:SetPoint("LEFT", f.Left, "RIGHT")
 	f.Middle:SetTexCoord(0.1953125, 0.8046875, 0, 1)
-
+
 	f.Right = f:CreateTexture(name.."Right", "ARTWORK")
 	f.Right:SetTexture("Interface\\Glues\\CharacterCreate\\CharacterCreate-LabelFrame")
 	f.Right:SetSize(25, 64)
 	f.Right:SetPoint("LEFT", f.Middle, "RIGHT")
 	f.Right:SetTexCoord(0.8046875, 1, 0, 1)
-
+
 	f.Text = f:CreateFontString(name.."Text", "ARTWORK", "GameFontHighlightSmall")
 	f.Text:SetWordWrap(false)
 	f.Text:SetJustifyH("RIGHT")
 	f.Text:SetSize(0, 10)
 	f.Text:SetPoint("RIGHT", f.Right, -43, 2)
-
+
 	f.Icon = f:CreateTexture(name.."Icon", "OVERLAY")
 	f.Icon:Hide()
 	f.Icon:SetSize(16, 16)
 	f.Icon:SetPoint("LEFT", 30, 2)
-
+
 	f.Button = CreateFrame("Button", name.."Button", f)
 	f.Button:SetMotionScriptsWhileDisabled(true)
 	f.Button:SetSize(24, 24)
 	f.Button:SetPoint("TOPRIGHT", f.Right, -16, -18)
-
+
 	f.Button.NormalTexture = f.Button:CreateTexture(name.."NormalTexture")
 	f.Button.NormalTexture:SetTexture("Interface\\ChatFrame\\UI-ChatIcon-ScrollDown-Up")
 	f.Button.NormalTexture:SetSize(24, 24)
 	f.Button.NormalTexture:SetPoint("RIGHT", f.Button, 0, 0)
 	f.Button:SetNormalTexture(f.Button.NormalTexture)
-
+
 	f.Button.PushedTexture = f.Button:CreateTexture(name.."PushedTexture")
 	f.Button.PushedTexture:SetTexture("Interface\\ChatFrame\\UI-ChatIcon-ScrollDown-Down")
 	f.Button.PushedTexture:SetSize(24, 24)
 	f.Button.PushedTexture:SetPoint("RIGHT", f.Button, 0, 0)
 	f.Button:SetPushedTexture(f.Button.PushedTexture)
-
+
 	f.Button.DisabledTexture = f.Button:CreateTexture(name.."DisabledTexture")
 	f.Button.DisabledTexture:SetTexture("Interface\\ChatFrame\\UI-ChatIcon-ScrollDown-Disabled")
 	f.Button.DisabledTexture:SetSize(24, 24)
 	f.Button.DisabledTexture:SetPoint("RIGHT", f.Button, 0, 0)
 	f.Button:SetDisabledTexture(f.Button.DisabledTexture)
-
+
 	f.Button.HighlightTexture = f.Button:CreateTexture(name.."HighlightTexture")
 	f.Button.HighlightTexture:SetTexture("Interface\\Buttons\\UI-Common-MouseHilight")
 	f.Button.HighlightTexture:SetSize(24, 24)
 	f.Button.HighlightTexture:SetPoint("RIGHT", f.Button, 0, 0)
 	f.Button.HighlightTexture:SetBlendMode("ADD")
 	f.Button:SetHighlightTexture(f.Button.HighlightTexture)
-
+
 	-- Button Script
 	f.Button:SetScript("OnEnter", function(self, motion)
 		local parent = self:GetParent()
@@ -570,12 +581,12 @@ local function create_DropDownMenu(name, parent)
 		PlaySound(SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON)
 		end
 	end)
-
+
 	-- UIDropDownMenu Script
 	f:SetScript("OnHide", function(self)
 		lib:CloseDropDownMenus()
 	end)
-
+
 	return f
 end
 -- End of frame templates
@@ -592,7 +603,7 @@ local function create_DropDownButtons()
 	L_DropDownList1:SetSize(180, 10)
 	local _, fontHeight, _ = _G["L_DropDownList1Button1NormalText"]:GetFont()
 	L_UIDROPDOWNMENU_DEFAULT_TEXT_HEIGHT = fontHeight
-
+
 	L_DropDownList2 = creatre_DropDownList("L_DropDownList2")
 	L_DropDownList2:SetToplevel(true)
 	L_DropDownList2:SetFrameStrata("FULLSCREEN_DIALOG")
@@ -603,7 +614,7 @@ local function create_DropDownButtons()
 	-- UIParent integration; since we customize the name of DropDownList, we need to add it to golbal UIMenus table.
 	--tinsert(UIMenus, "L_DropDownList1");
 	--tinsert(UIMenus, "L_DropDownList2");
-
+
 	-- Alternative by Dahk Celes (DDC) that avoids tainting UIMenus and CloseMenus()
 	hooksecurefunc("CloseMenus", function()
 		L_DropDownList1:Hide()
@@ -612,7 +623,7 @@ local function create_DropDownButtons()
 end

 do
-	if lib then
+	if lib then
 		create_DropDownButtons()
 	end
 end
@@ -1058,7 +1069,7 @@ function lib:UIDropDownMenu_AddButton(info, level)
 		end
 	end

-	if not info.notCheckable then
+	if not info.notCheckable then
 		local check = _G[listFrameName.."Button"..index.."Check"];
 		local uncheck = _G[listFrameName.."Button"..index.."UnCheck"];
 		if ( info.disabled ) then
@@ -1072,11 +1083,11 @@ function lib:UIDropDownMenu_AddButton(info, level)
 			uncheck:SetDesaturated(false);
 			uncheck:SetAlpha(1);
 		end
-
+
 		if info.customCheckIconAtlas or info.customCheckIconTexture then
 			check:SetTexCoord(0, 1, 0, 1);
 			uncheck:SetTexCoord(0, 1, 0, 1);
-
+
 			if info.customCheckIconAtlas then
 				check:SetAtlas(info.customCheckIconAtlas);
 				uncheck:SetAtlas(info.customUncheckIconAtlas or info.customCheckIconAtlas);
@@ -1224,7 +1235,7 @@ end

 function lib:UIDropDownMenu_Refresh(frame, useValue, dropdownLevel)
 	local maxWidth = 0;
-	local somethingChecked = nil;
+	local somethingChecked = nil;
 	if ( not dropdownLevel ) then
 		dropdownLevel = L_UIDROPDOWNMENU_MENU_LEVEL;
 	end
@@ -1634,7 +1645,7 @@ end

 local function containsMouse()
 	local result = false
-
+
 	for i = 1, L_UIDROPDOWNMENU_MAXLEVELS do
 		local dropdown = _G["L_DropDownList"..i];
 		if dropdown:IsShown() and dropdown:IsMouseOver() then
@@ -1668,8 +1679,8 @@ end
 -- hooking UIDropDownMenu_HandleGlobalMouseEvent
 do
 	if lib and WoWRetail then
-		hooksecurefunc("UIDropDownMenu_HandleGlobalMouseEvent", function(button, event)
-			lib:UIDropDownMenu_HandleGlobalMouseEvent(button, event)
+		hooksecurefunc("UIDropDownMenu_HandleGlobalMouseEvent", function(button, event)
+			lib:UIDropDownMenu_HandleGlobalMouseEvent(button, event)
 		end)

 	end
@@ -1777,7 +1788,7 @@ function lib:UIDropDownMenuButton_OpenColorPicker(self, button)
 		button = self;
 	end
 	L_UIDROPDOWNMENU_MENU_VALUE = button.value;
-	lib:OpenColorPicker(button);
+	lib:OpenColorPicker(button);
 end

 function lib:UIDropDownMenu_DisableButton(level, id)
@@ -1954,7 +1965,7 @@ function lib:Create_UIDropDownCustomMenuEntry(name, parent)
 	local f = _G[name] or CreateFrame("Frame", name, parent or nil)
 	f:EnableMouse(true)
 	f:Hide()
-
+
 	-- I am not 100% sure if below works for replacing the mixins
 	f:SetScript("GetPreferredEntryWidth", function(self)
 		return self:GetWidth()
@@ -1973,7 +1984,7 @@ function lib:Create_UIDropDownCustomMenuEntry(name, parent)
 	f:SetScript("GetContextData", function(self)
 		return self.contextData
 	end)
-
+
 	return f
 end

@@ -2023,4 +2034,3 @@ end
 function lib:EasyMenu_Initialize( frame, level, menuList )
 	easyMenu_Initialize( frame, level, menuList )
 end
-