Quantcast

Another tweak to prevent 'bouincing' main menu bar if user uses a Titan bottom bar

urnati [11-25-18 - 18:23]
Another tweak to prevent 'bouincing' main menu bar if user uses a Titan bottom bar
Filename
Titan/TitanMovable.lua
Titan/TitanPanel.lua
diff --git a/Titan/TitanMovable.lua b/Titan/TitanMovable.lua
index aaa7e1d..ca12abf 100755
--- a/Titan/TitanMovable.lua
+++ b/Titan/TitanMovable.lua
@@ -50,13 +50,49 @@ hooksecurefunc(FrameRef, "SetPoint", function(self)
 end)
 --]]

+--[[ Titan
+NAME: TitanMovable_MenuBar_Disable
+DESC: Handle the main menu bar so Blizzard does not get upset.
+VAR: None
+OUT: None
+NOTE:
+- Needed because 8.0 made changes to the menu bar processing
+- Tell Blizzard that the bar is NOT user placed so when Blizzard makes it reappear, it is working
+:NOTE
+--]]
+function TitanMovable_MenuBar_Disable()
+	MainMenuBar:SetMovable(true);
+	MainMenuBar:SetUserPlaced(false);
+end
+
+--[[ Titan
+NAME: TitanMovable_MenuBar_Enable
+DESC: Handle the main menu bar so Blizzard does not get upset.
+VAR: None
+OUT: None
+NOTE:
+- Needed because 8.0 made changes to the menu bar processing
+- Tell Blizzard that the bar is user placed IF NOT in combat to prevent 'bouncing' of the bar if users use a bottom Titan bar
+- This is called for the various events Titan handles that do / may hide the main menu bar
+:NOTE
+--]]
+function TitanMovable_MenuBar_Enable()
+	if InCombatLockdown() then
+		-- wait until out of combat...
+	else
+		MainMenuBar:SetMovable(true);
+		MainMenuBar:SetUserPlaced(true);
+		MainMenuBar:SetMovable(false);
+	end
+end
+
 --[[ API
 NAME: TitanMovable_GetPanelYOffset
 DESC: Get the Y axis offset Titan needs (1 or 2 bars) at the given position - top or bottom.
 VAR: framePosition - TITAN_PANEL_PLACE_TOP or TITAN_PANEL_PLACE_BOTTOM
 OUT: Y axis offset, in pixels
 NOTE:
-- The prefered method to determine the Y offset needed by using TitanUtils_GetBarAnchors().
+- The preferred method to determine the Y offset needed by using TitanUtils_GetBarAnchors().
 :NOTE
 --]]
 function TitanMovable_GetPanelYOffset(framePosition) -- used by other addons
diff --git a/Titan/TitanPanel.lua b/Titan/TitanPanel.lua
index 0d081f8..0cab352 100644
--- a/Titan/TitanPanel.lua
+++ b/Titan/TitanPanel.lua
@@ -523,16 +523,13 @@ function TitanPanelBarButton:PLAYER_REGEN_DISABLED()
 	TitanUtils_CloseRightClickMenu();

 	-- Needed because 8.0 made changes to the menu bar processing (see TitanMovable)
-	MainMenuBar:SetMovable(true);
-	MainMenuBar:SetUserPlaced(false);
+	TitanMovable_MenuBar_Disable()
 end

 function TitanPanelBarButton:PLAYER_REGEN_ENABLED()
 	-- Needed because 8.0 made changes to the menu bar processing (see TitanMovable)
-	MainMenuBar:SetMovable(true);
-	MainMenuBar:SetUserPlaced(true);
-	MainMenuBar:SetMovable(false);
-
+	TitanMovable_MenuBar_Enable()
+
 	-- Outside combat check to see if frames need correction
 	TitanPanel_AdjustFrames()
 end
@@ -545,8 +542,14 @@ function TitanPanelBarButton:UNIT_ENTERED_VEHICLE(self, ...)
 	-- If in combat close all control frames and menus
 	TitanUtils_CloseAllControlFrames();
 	TitanUtils_CloseRightClickMenu();
+
+	-- Needed because 8.0 made changes to the menu bar processing (see TitanMovable)
+	TitanMovable_MenuBar_Disable()
 end
 function TitanPanelBarButton:UNIT_EXITED_VEHICLE(self, ...)
+	-- Needed because 8.0 made changes to the menu bar processing (see TitanMovable)
+	TitanMovable_MenuBar_Enable()
+
 	-- A combat check will be done inside the adjust
 	TitanPanel_AdjustFrames()
 end
@@ -556,8 +559,14 @@ function TitanPanelBarButton:PET_BATTLE_OPENING_START()
 --	TitanDebug("Pet_battle start: ")
 	-- Hide all bars and hiders
 	TitanPanelBarButton_HideAllBars()
+
+	-- Needed because 8.0 made changes to the menu bar processing (see TitanMovable)
+	TitanMovable_MenuBar_Disable()
 end
 function TitanPanelBarButton:PET_BATTLE_CLOSE()
+	-- Needed because 8.0 made changes to the menu bar processing (see TitanMovable)
+	TitanMovable_MenuBar_Enable()
+
 	-- A combat check will be done inside the adjust
 	TitanPanelBarButton_DisplayBarsWanted()
 end