WoWInterface - View Single Post - GetRight() positioning problem
View Single Post
12-19-13, 10:44 PM   #1
A Fallenroot Satyr
Spyro's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2011
Posts: 20
Question GetRight() positioning problem

Hi guyz.

I want to move the FocusFrame's castbar (FocusFrameSpellBar) in a way that both frames (FocusFrame and FocusFrameSpellBar) have its right edges on the same line.

I can only change the X-offset of the anchor, because Blizzard's native code is constantly changing the anchor with different offsets and relative frames, to adjust the position of the castbar to the amount of buffs/debuffs of the FocusFrame.

I'm using GetRight() for the task:

Lua Code:
  1. local function FocusCastbarReposition()
  2.   local FocusRight = FocusFrame:GetRight() * FocusFrame:GetEffectiveScale()
  3.   local CastRight = FocusFrameSpellBar:GetRight() * FocusFrameSpellBar:GetEffectiveScale()
  4.   local Gap = FocusRight - CastRight
  5.   local P = { FocusFrameSpellBar:GetPoint() }
  6.   FocusFrameSpellBar:ClearAllPoints()
  7.   FocusFrameSpellBar:SetPoint(P[1], P[2], P[3], P[4] + Gap, P[5])
  8.   Addon:SetScript("OnUpdate", nil)
  9. end
  11. -- Changing the X-offset of FocusFrame's castbar in the
  12. -- next frame (when the anchor values will be updated)
  13. hooksecurefunc(FocusFrameSpellBar, "SetPoint", function()
  14.   Addon:SetScript("OnUpdate", FocusCastbarReposition)
  15. end)

But it doesn't works, the final position is not correct.
I have used the same technique (substraction using GetRight() values) with textures with success, but looks like when it's 2 frames with different scales, it's not that easy. :-/

Does anybody knows the solution?
  Reply With Quote