View Single Post
07-14-14, 08:56 AM   #20
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Actually, looking at your screenshot, you should use relative positioning for your portraits, too:

Code:
	-----------
	-- Portrait
	-----------
	if unit == "player" or unit == "target" then 
		local portrait = CreateFrame("PlayerModel", nil, frame)
		portrait:SetWidth(50)
		portrait:SetAlpha(0.8)
 
		if unit == "player" then
			portrait:SetPoint("TOPRIGHT", frame, "TOPLEFT")
			portrait:SetPoint("BOTTOMRIGHT", frame, "BOTTOMLEFT")
		else
			portrait:SetPoint("TOPLEFT", frame, "TOPRIGHT")
			portrait:SetPoint("BOTTOMLEFT", frame, "BOTTOMRIGHT")
		end

		portrait.PostUpdate = Portrait_PostUpdate
		frame.Portrait = portrait
	end
Your previous method of attaching the left corners of the portrait to the middle of the top and bottom of the frame, and then shifting it to the left by a hardcoded amount that depended on the combined width of the frame and portrait -- either of which you might want to change in the future, or even make user-configurable -- wasn't very logical, when the result you really want is to attach the right corners of the portrait to the left corners of the frame. By just doing what you actually want to do, you avoid needing to hardcode the offsets, and you avoid having values here that depend on unrelated values in other parts of your code.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote