From 251012c77e1483cc169dac7b3c5b087a782b0070 Mon Sep 17 00:00:00 2001 From: urnati Date: Thu, 21 Mar 2019 15:00:10 -0400 Subject: [PATCH] #1219 : Change to move extra action button above Blizzard menu bar (added code derived from UIParent) --- Titan/TitanMovable.lua | 110 ++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 88 insertions(+), 22 deletions(-) diff --git a/Titan/TitanMovable.lua b/Titan/TitanMovable.lua index ae92ad2..8112f6a 100755 --- a/Titan/TitanMovable.lua +++ b/Titan/TitanMovable.lua @@ -180,7 +180,7 @@ function TitanMovable_GetPanelYOffset(framePosition) -- used by other addons end local scale = TitanPanelGetVar("Scale") -- return the requested offset - -- 0 will be returned if the user has not bars showing + -- 0 will be returned if the user has no bars showing -- or the scale is not valid if scale and framePosition then if framePosition == TITAN_PANEL_PLACE_TOP then @@ -234,6 +234,8 @@ Swiped from Vrul on wowinterface forum The table UIPARENT_MANAGED_FRAME_POSITIONS does not hold all Blizzard frames. It is cleared for each frame in case the frame is in or might be in the table in the future. + +Titan does not control the frames as other addons so we honor a user placed frame :NOTE --]] local function SetPosition(frame, ...) @@ -247,7 +249,8 @@ local function SetPosition(frame, ...) UIPARENT_MANAGED_FRAME_POSITIONS[name] = nil end frame:SetMovable(true) -- allow frame to move - frame:SetUserPlaced(true) -- tell Blizzard to back off +-- Titan honors a user placed frame so we don't need this +-- frame:SetUserPlaced(true) -- tell Blizzard to back off frame:SetDontSavePosition(true) frame:SetAttribute('ignoreFramePositionManager', true) frame.ignoreFramePositionManager = true @@ -269,8 +272,8 @@ OUT: top_bottom - Frame is at top or bottom, expecting Titan constant for top or local function MoveFrame(frame_ptr, start_y, top_bottom, force) local frame = _G[frame_ptr] - if frame and (frame:IsUserPlaced() - or frame.MALockPointHook -- Allow MoveAnything to be used w/o error + if frame and (frame:IsUserPlaced() or + frame.MALockPointHook -- Allow MoveAnything to be used w/o error ) then -- skip this frame @@ -281,14 +284,28 @@ local function MoveFrame(frame_ptr, start_y, top_bottom, force) -- check for nil which will cause an error if point and relativeTo and relativePoint and xOfs then -- do not care about yOfs -- should be safe... - frame:ClearAllPoints(); - frame:SetPoint(point, relativeTo:GetName(), relativePoint, xOfs, y) +-- frame:ClearAllPoints(); +-- frame:SetPoint(point, relativeTo:GetName(), relativePoint, xOfs, y) +--[[ + if frame == ExtraActionBarFrame then + TitanDebug ("MoveFrame :" + .." "..tostring(frame:GetName()) + .." point:"..tostring(point) + .." relativeTo:"..tostring(relativeTo:GetName()) + .." relativePoint:"..tostring(relativePoint) + .." xOfs:"..tostring(xOfs) + .." y:"..tostring(y) + ) + end +--]] + SetPosition(frame, point, relativeTo:GetName(), relativePoint, xOfs, y) else -- do not proceed --[[ TitanDebug ("MoveFrame nil :" + .." "..tostring(frame:GetName()) .."point:"..tostring(point) - .."relativeTo:"..tostring(relativeTo) + .."relativeTo:"..tostring(relativeTo:GetName()) .."relativePoint:"..tostring(relativePoint) .."xOfs:"..tostring(xOfs) ) @@ -298,6 +315,13 @@ local function MoveFrame(frame_ptr, start_y, top_bottom, force) --[[ Some frames such as the ticket frame may not be visible or even created --]] +--[[ + TitanDebug ("MoveFrame no adj :" + .." "..tostring(frame:GetName()) + .." adj: "..tostring(DoAdjust(top_bottom, force)) + .." shown: "..tostring(frame:IsShown()) + ) +--]] end end end @@ -305,7 +329,8 @@ end xx_xOfs = 0 --[[ local NAME: MoveMenuFrame -DESC: Adjust the MainMenuBar frame. Needed because :GetPoint does NOT work. This is modeled after MoveFrame to keep it similar. +DESC: Adjust the MainMenuBar frame. Needed because :GetPoint does NOT always work for MainMenuBar. +This is modeled after MoveFrame to keep it similar. Titan sets the IsUserPlaced for the MainMenuBar frame so Titan needs to adjust. VAR: frame_ptr - Text string of the frame name VAR: start_y - Any offset due to the specific frame @@ -328,20 +353,6 @@ local function MoveMenuFrame(frame_ptr, start_y, top_bottom, force) end xOfs = TitanPanelGetVar("MainMenuBarXAdj") ---[[ - -- 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 ---]] --- frame:ClearAllPoints(); --- frame:SetPoint("BOTTOM", "UIParent", "BOTTOM", xOfs, yOffset); SetPosition(frame, "BOTTOM", "UIParent", "BOTTOM", xOfs, yOffset) adj = true else @@ -454,6 +465,17 @@ local function Titan_ContainerFrames_Relocate() end end +local function has_pet_bar() + local hasPetBar = false + if ( ( PetActionBarFrame and PetActionBarFrame:IsShown() ) or ( StanceBarFrame and StanceBarFrame:IsShown() ) or + ( MultiCastActionBarFrame and MultiCastActionBarFrame:IsShown() ) or ( PossessBarFrame and PossessBarFrame:IsShown() ) or + ( MainMenuBarVehicleLeaveButton and MainMenuBarVehicleLeaveButton:IsShown() ) ) then +-- tinsert(yOffsetFrames, "pet"); + hasPetBar = true; + end + return hasPetBar +end + --[[ local NAME: MData table DESC: MData is a local table that holds each frame Titan may need to adjust. It controls the offsets needed to make room for the Titan bar(s). @@ -518,6 +540,50 @@ local MData = { move = function (force) MoveMenuFrame("MainMenuBar", 0, TITAN_PANEL_PLACE_BOTTOM, force) end, addonAdj = false, }, + [11] = {frameName = "ExtraActionBarFrame", + move = function (force) + -- Only spend cycles if the frame is shown. + if ExtraActionBarFrame + and ExtraActionBarFrame:IsShown() then + -- Need to calc Y because Y depends on what else is shown + --[=[ UIParent + Look at UIParent.lua for logic (UIParent_ManageFramePosition) + --]=] + local actionBarOffset = 45; + local menuBarTop = 55; + local overrideActionBarTop = 40; + local petBattleTop = 60; + + local yOfs = 18 -- FramePositionDelegate:UIParentManageFramePositions + if MainMenuBar and MainMenuBar:IsShown() then + yOfs = yOfs + menuBarTop + end + if (MultiBarBottomLeft and MultiBarBottomLeft:IsShown()) + or (MultiBarBottomRight and MultiBarBottomRight:IsShown()) + then + yOfs = yOfs + actionBarOffset + end + if (has_pet_bar()) + and (MultiBarBottomRight and MultiBarBottomRight:IsShown()) + then + yOfs = yOfs + petBattleTop + end +--[[ +TitanDebug ("MData ExtraActionBarFrame :" + .." yOfs:"..tostring(yOfs) + ) +--]] + MoveFrame("ExtraActionBarFrame", yOfs, TITAN_PANEL_PLACE_BOTTOM, force) + end + end, + addonAdj = false, }, +--[=[ +--]=] +--[[ + [12] = {frameName = "OrderHallCommandBar", + move = function (force) + MoveFrame("OrderHallCommandBar", 0, TITAN_PANEL_PLACE_TOP, force) end, + addonAdj = false, }, --]] } -- 1.7.9.5