Quantcast WoWInterface - View Single Post - Finding Frames of other Addons and overwriting their position
View Single Post
06-26-19, 12:16 PM   #18
Lybrial
A Black Drake
AddOn Compiler - Click to view compilations
Join Date: Jan 2010
Posts: 86
I was able to anchor my frames perfectly to the player resource bar:

Code:
	if (self.anchorFrame) then
		return;
	end
	
	self.anchorFrame = CreateFrame("Frame", "LybrialUIAnchor", UIParent);
	self.anchorFrame:Hide();
	self.anchorFrame.attachedVisibleFrames = {};
	self.anchorFrame:RegisterEvent("NAME_PLATE_UNIT_ADDED");
	self.anchorFrame:RegisterEvent("NAME_PLATE_UNIT_REMOVED");			
	self.anchorFrame.Attach = function(self, frame, frameTopLeft, frameBottomRight)
		self:SetParent(frame);
		self:ClearAllPoints();
		self:SetPoint("TOPLEFT", frameTopLeft, "TOPLEFT", 0, 0);
		self:SetPoint("BOTTOMRIGHT", frameBottomRight, "BOTTOMRIGHT", 0, 0);
		self:Show();
	end
	self.anchorFrame.Detach = function(self, frame)
		self:ClearAllPoints();
		self:Hide();
	end
	self.anchorFrame.eventHandler = function(self, event, nameplate)
		if (event == "NAME_PLATE_UNIT_ADDED") then
			if (UnitIsUnit(nameplate, "player")) then
				local frame = C_NamePlate.GetNamePlateForUnit("player");
				
				if (frame) then
					if (frame.kui and frame.kui.bg and frame.kui:IsShown()) then
						LybrialAnchors.anchorFrame:Attach(frame.kui, KuiNameplatesPlayerAnchor, KuiNameplatesPlayerAnchor);
					elseif (ElvUIPlayerNamePlateAnchor) then
						LybrialAnchors.anchorFrame:Attach(ElvUIPlayerNamePlateAnchor, ElvUIPlayerNamePlateAnchor, ElvUIPlayerNamePlateAnchor);
					else
						LybrialAnchors.anchorFrame:Attach(frame, frame.UnitFrame.healthBar, NamePlateDriverFrame.classNamePlatePowerBar);
					end
					
					LybrialAnchors.anchorFrame:Show();
					LybrialAnchors:OnUpdate();
				else
					LybrialAnchors.anchorFrame:Detach();
					LybrialAnchors.anchorFrame:Hide();
					LybrialAnchors:OnUpdate();
				end
			end
		elseif (event == "NAME_PLATE_UNIT_REMOVED") then
			if (UnitIsUnit(nameplate, "player")) then
				LybrialAnchors.anchorFrame:Detach();
				LybrialAnchors.anchorFrame:Hide();
				LybrialAnchors:OnUpdate();
			end
		end
	end
	self.anchorFrame:SetScript("OnEvent", self.anchorFrame.eventHandler);
To anchor raven to my frame I do this:

Code:
function Raven:SetupFrames()
	if (self.isLoaded and self.db.profile.enabled) then
		table.foreach(self.frames, function(key, value)
			local frame = _G[value];
			
			if (frame) then
				frame:ClearAllPoints();
				
				if (value == "RavenBarGroupShort_Buffs") then
					frame:SetPoint("CENTER", LybrialAnchors.anchorFrame, "CENTER", -215, -59);
				elseif (value == "RavenBarGroupDebuffs") then
					frame:SetPoint("CENTER", LybrialAnchors.anchorFrame, "CENTER", -215, -134);
				elseif (value == "RavenBarGroupZiel") then
					frame:SetPoint("CENTER", LybrialAnchors.anchorFrame, "CENTER", 217, -59);
				elseif (value == "RavenBarGroupCooldowns") then
					frame:SetPoint("CENTER", LybrialAnchors.anchorFrame, "CENTER", 0, -224);
				end
			end
		end);
	end
end
But here we are now at Patch 8.2 and as expected:

Code:
7x Raven\Nest.lua:918: Action[FrameMeasurement] failed because[Can't measure restricted regions]: attempted from: RavenBarGroupDebuffs:GetLeft().
[C]: in function `GetLeft'
Raven\Nest.lua:918: in function `Nest_GetAnchorPoint'
Raven\Bars.lua:677: in function `UpdatePositions'
Raven\Bars.lua:2099: in function `UpdateBars'
Raven\Main.lua:1109: in function `Update'
Raven\Main.lua:820: in function <Raven\Main.lua:816>

Locals:
(*temporary) = RavenBarGroupDebuffs {
 0 = <userdata>
}
Is there any way around this?
  Reply With Quote