Quantcast

- Updated Movable to better handle Titan flags to turn off top or bottom adjust

urnati [10-04-18 - 16:08]
- Updated Movable to better handle Titan flags to turn off top or bottom adjust
Filename
Titan/TitanMovable.lua
diff --git a/Titan/TitanMovable.lua b/Titan/TitanMovable.lua
index 957afa3..36fde90 100755
--- a/Titan/TitanMovable.lua
+++ b/Titan/TitanMovable.lua
@@ -145,6 +145,36 @@ local function TitanMovableFrame_GetXOffset(frame, point)
 end

 --[[ local
+NAME: DoAdjust
+DESC: See if Titan should adjust based only on its own flags.
+VAR: place   - top or bottom
+OUT: boolean - true to adjust, false if not
+--]]
+local function DoAdjust(place)
+	local res = false -- assume we will not adjust
+	-- This is more work than it should be but Titan uses nil or true to be 'true' for these flags
+	-- We did it to ourselves - if (Aux)ScreenAdjust is true it means the user wants Titan to NOT adjust...
+	if place == TITAN_PANEL_PLACE_TOP then
+		if TitanPanelGetVar("ScreenAdjust") == 1 then
+			-- do not adjust
+		else
+			if TitanPanelGetVar("Bar_Show") or TitanPanelGetVar("Bar2_Show") then
+				res = true
+			end
+		end
+	elseif place == TITAN_PANEL_PLACE_BOTTOM then
+		if TitanPanelGetVar("AuxScreenAdjust") == 1 then
+			-- do not adjust
+		else
+			if TitanPanelGetVar("AuxBar_Show") or TitanPanelGetVar("AuxBar2_Show") then
+				res = true
+			end
+		end
+	end
+	return res
+end
+
+--[[ local
 NAME: MoveFrame
 DESC: Adjust the given frame. Expected are frames where :GetPoint works
 VAR: frame_ptr - Text string of the frame name
@@ -153,15 +183,19 @@ OUT: top_bottom - Frame is at top or bottom, expecting Titan constant for top or
 --]]
 local function MoveFrame(frame_ptr, start_y, top_bottom)
 	local frame = _G[frame_ptr]
-	if frame and frame:IsUserPlaced()
+	local adj = false
+	if frame and (frame:IsUserPlaced()
+			or frame.MALockPointHook  -- Allow MoveAnything to be used w/o error
+		)
 	then
 		-- skip this frame
 	else
-		if frame:IsShown() then
+		if DoAdjust(top_bottom) and frame:IsShown() then
 			local y = TitanMovable_GetPanelYOffset(top_bottom) + (start_y or 0) -- includes scale adjustment
 			local point, relativeTo, relativePoint, xOfs, yOfs = frame:GetPoint()
 			frame:ClearAllPoints();
 			frame:SetPoint(point, relativeTo:GetName(), relativePoint, xOfs, y)
+			adj = true
 		else
 			--[[
 			Some frames such as the ticket frame may not be visible or even created
@@ -180,35 +214,32 @@ OUT: top_bottom - Frame is at top or bottom, expecting Titan constant for top or
 --]]
 local function MoveMenuFrame(frame_ptr, start_y, top_bottom)
 	local frame = _G[frame_ptr]
-	if frame
-		-- do not check IsUserPlaced because Titan sets this.
-		-- Setting IsUserPlaced was done to prevent bottom bars 'bouncing'
+	local adj = false
+	if frame and (frame:IsUserPlaced()
+			or frame.MALockPointHook  -- Allow MoveAnything to be used w/o error
+		)
+		and DoAdjust(top_bottom)
 	then
 		local yOffset = TitanMovable_GetPanelYOffset(top_bottom) -- includes scale adjustment
-		--xOffset = TitanMovableFrame_GetXOffset(frame, top_bottom);
+--		xOffset = TitanMovableFrame_GetXOffset(frame, top_bottom);
 		if ( StatusTrackingBarManager:GetNumberVisibleBars() == 2 ) then
 			yOffset = yOffset + 17;
 		elseif ( StatusTrackingBarManager:GetNumberVisibleBars() == 1 ) then
 			yOffset = yOffset + 14;
 		end
-		frame:ClearAllPoints();
-		--[[
-		If the scale is around .85 or higher the bag menu overlaps the main menu
-		when the right menu bar is shown (adding more bottom buttons)
-		So shift the menu bar right a little based on the scaling.
-		We may have to get fancy checking exactly what is shown before shifting.
-		--]]
+		frame:ClearAllPoints();
+		-- This is a hack because GetPoint on MainMenuBar often returns all nil
+		-- If the scale is is around .85 or higher the bag menu overlaps the main menu
 		local fscale = tonumber(GetCVar("uiScale"))
 		local xadj = (fscale * 100) - 85
 		if xadj <= 0 then
 			xOfs = 0
 		else
+			-- Slide the menu bar left depending on scaling to allow bag menu room
 			xOfs = xadj * 6 * -1
 		end
-		--[[
-		This is a hack because GetPoint on MainMenuBar often returns nil values.
-		--]]
 		frame:SetPoint("BOTTOM", "UIParent", "BOTTOM", xOfs, yOffset);
+		adj = true
 	else
 		-- Unknown frame...
 	end
@@ -432,13 +463,12 @@ local function TitanMovableFrame_MoveFrames()
 	if not InCombatLockdown() then
 		for i = 1,#MData,1 do
 			if MData[i] then
-				local frame = _G[MData[i].frameName]
-				if MData[i].addonAdj      -- An addon has taken control of the frame
-				or frame.MALockPointHook  -- Allow MoveAnything to be used w/o error
-				then
-					-- skip
+				if MData[i].addonAdj then
+					-- An addon has taken control of the frame so skip
 				else
 					-- Adjust the frame per MData
+					MData[i].move()
+--[[
 					local ok, msg = pcall(function () MData[i].move() end)
 					if ok then
 						-- all is well
@@ -447,6 +477,7 @@ local function TitanMovableFrame_MoveFrames()
 							.." '"..(MData[i].frameName or "?").."."
 							.." "..msg, "error")
 					end
+--]]
 				end
 			end
 		end