Quantcast

TitanPanel : Removed the bottom 2 'spaces' on the right click menu since they were always blank

urnati [12-30-18 - 14:41]
TitanPanel : Removed the bottom 2 'spaces' on the right click menu since they were always blank
TitanUtils : Used updated LibUIDropDownMenu; create the right-click menu frame in Lua as needed
Filename
Titan/TitanPanel.lua
Titan/TitanUtils.lua
diff --git a/Titan/TitanPanel.lua b/Titan/TitanPanel.lua
index 2cf7c96..103c3f5 100644
--- a/Titan/TitanPanel.lua
+++ b/Titan/TitanPanel.lua
@@ -1770,8 +1770,8 @@ local function TitanPanel_MainMenu()
 	info.checked = glob --TitanAllGetVar("GlobalProfileUse")
 	info.keepShownOnClick = nil
 	L_UIDropDownMenu_AddButton(info, L_UIDROPDOWNMENU_MENU_LEVEL);
-
-	--local player, server = TitanUtils_ParseName(TitanAllGetVar("GlobalProfileName"))
+--[[
+	local player, server = TitanUtils_ParseName(TitanAllGetVar("GlobalProfileName"))
 	info = {};
 	info.notCheckable = true
 	info.text = "   "..TitanUtils_GetGreenText(server)
@@ -1783,7 +1783,7 @@ local function TitanPanel_MainMenu()
 	info.text = "      "..TitanUtils_GetGreenText(player)
 	info.value = "player";
 	L_UIDropDownMenu_AddButton(info);
-
+--]]
 end

 --[[ local
diff --git a/Titan/TitanUtils.lua b/Titan/TitanUtils.lua
index 609ddac..0728e97 100644
--- a/Titan/TitanUtils.lua
+++ b/Titan/TitanUtils.lua
@@ -1184,6 +1184,12 @@ function TitanUtils_PluginToRegister(self, isChildButton)
 		plugin_type = "",
 		notes = notes,
 	}
+
+	--[[ For updated menu lib (Dec 2018)
+	Old way was to use the XML file to declare the frame, now it needs to be in Lua
+	<Frame name="$parentRightClickMenu" inherits="L_UIDropDownMenuTemplate" id="1" hidden="true"></Frame>
+	--]]
+	local f = L_Create_UIDropDownMenu(self:GetName().."RightClickMenu", self)
 end

 --[[ Titan
@@ -1593,20 +1599,6 @@ function TitanPanelRightClickMenu_Toggle(self, isChildButton)
 	x, y, scale = TitanRightClick_UIScale()

 	L_ToggleDropDownMenu(1, nil, menu, frame, TitanUtils_Max(x - 40, 0), 0, nil, self);
---[[ was not used...
-	local listFrame = _G["DropDownList"..L_UIDROPDOWNMENU_MENU_LEVEL];
-	local offscreenX, offscreenY = TitanUtils_GetOffscreen(listFrame);
-
-	if offscreenX == 1 then
-		if position == TITAN_PANEL_PLACE_TOP then
-			listFrame:ClearAllPoints();
-			listFrame:SetPoint("TOPRIGHT", frame, "BOTTOMLEFT", x, 0);
-		else
-			listFrame:ClearAllPoints();
-			listFrame:SetPoint("BOTTOMRIGHT", frame, "TOPLEFT", x, 0);
-		end
-	end
---]]
 end

 --[[ Titan
@@ -1637,7 +1629,19 @@ function TitanPanelDisplayRightClickMenu_Toggle(self, isChildButton)
 	local x, y, scale
 	local menu

-	menu = _G[frame.."RightClickMenu"];
+	-- Per updated menu lib LibUIDropDownMenu Dec 2018
+	-- This could have been done in some initialize code but here it can react
+	-- better to future Titan frame code changes
+	desired_frame = frame.."RightClickMenu"
+	if _G[desired_frame] then
+		-- all is good - frame exists
+	else
+		-- need to create the frame
+		-- The _G is needed but it is explicit & shows what needs to done
+		_G[desired_frame] = L_Create_UIDropDownMenu(desired_frame, self)
+	end
+	menu = _G[desired_frame];
+
 	-- Initialize the DropDown Menu if not already initialized
 	TitanDisplayRightClickMenu_OnLoad(menu, "TitanPanelRightClickMenu_PrepareBarMenu")

@@ -1652,20 +1656,6 @@ function TitanPanelDisplayRightClickMenu_Toggle(self, isChildButton)
 	x, y, scale = TitanRightClick_UIScale()

 	L_ToggleDropDownMenu(1, nil, menu, frame, TitanUtils_Max(x - 40, 0), 0, nil, self)
-
---[[ was not used...
-	local listFrame = _G["DropDownList"..L_UIDROPDOWNMENU_MENU_LEVEL];
-	local offscreenX, offscreenY = TitanUtils_GetOffscreen(listFrame);
-	if offscreenX == 1 then
-		if position == TITAN_PANEL_PLACE_TOP then
-			listFrame:ClearAllPoints();
-			listFrame:SetPoint("TOPRIGHT", frame, "BOTTOMLEFT", x, 0);
-		else
-			listFrame:ClearAllPoints();
-			listFrame:SetPoint("BOTTOMRIGHT", frame, "TOPLEFT", x, 0);
-		end
-	end
---]]
 end

 --[[ Titan