Every time WatchFrame_Update() is called (basically when something changes on the tracker frame), my mod does the following:
local width, height = 0, 0
local line1 = CreateFrame("Frame", WatchFrameLines, "WatchFrameLineTemplate")
line1:SetPoint("TOPLEFT", WatchFrameLines, "TOPLEFT", 0, 0)
line1:SetPoint("TOPRIGHT", WatchFrameLines, "TOPRIGHT", 0, 0)
local line2 = CreateFrame("Frame", WatchFrameLines, "WatchFrameLineTemplate")
line2:SetPoint("TOPLEFT", line1, "TOPLEFT", 0, 5)
line2:SetPoint("TOPRIGHT", line1, "TOPRIGHT", 0, 5)
width = max(line1.text:GetStringWidth(), line2.text:GetStringWidth())
height = line1:GetHeight() + line2:GetHeight()
return width, height
local anchorPoint, xOffset, yOffset = "", 0, 0
if(self.db.profile.trackerVerticalGrowth == "1-up") then
anchorPoint = "BOTTOM"
yOffset = self.db.profile.trackerBottom
anchorPoint = "TOP"
yOffset = self.db.profile.trackerTop
if(self.db.profile.trackerHorizontalGrowth == "1-left") then
anchorPoint = anchorPoint .. "RIGHT"
xOffset = self.db.profile.trackerRight
anchorPoint = anchorPoint .. "LEFT"
xOffset = self.db.profile.trackerLeft
WatchFrame:SetPoint(anchorPoint, UIParent, "BOTTOMLEFT", xOffset, yOffset)
self.db.profile.trackerTop = watchFrame:GetTop()
self.db.profile.trackerBottom = watchFrame:GetBottom()
self.db.profile.trackerLeft = watchFrame:GetLeft()
self.db.profile.trackerRight = watchFrame:GetRight()
local width, height = ShowLines()
-- Resize the tracker to fit these strings
If I leave out the call to SaveTrackerPosition(), this code works fine. However, if I put it in, except for the first time after I reload UI, the font strings no longer display. IsVisible() and IsShown() are both true for the frames, the WatchFrame is on the screen and so is the child frame that the lines are in so I can't figure out at all why this would be happening. The anchor that the frame is being set to doesn't change at all so I don't understand why saving the values of top, bottom, left, and right would affect the display. Anyone have any ideas?
Updated the original post with a simplified version of what each of the functions does. WatchFrameLineTemplate is defined in WatchFrame.xml (it's basically a frame with a font string that's defined in line.text).
To clarify my point about the frames being visible as far as I can tell, I also checked (using GetPoint) to make sure each line has a valid anchor and that WatchFrameLines (the frame the lines are parented to) has a valid anchor.
I really don't understand why people ask for help with their code, but then want to be all evasive about the actual code they're using. Either post your full actual code, or don't bother posting about it at all. It just wastes everyone's time to try to help you if all you'll post are random snippets, pseudo-code, or descriptions of what the code is supposed to do. :|
Heh, sorry, there's just a lot of it so I was trying to keep it simple. Pasted here: http://paste.wowace.com/1653/. The function ObjectiveDisplayHandler is the WatchFrame_UpdateHook I described above, SetTrackerPosition sets the anchor point, and SaveTrackerPosition updates the saved top, bottom, left, and right positions. The call in question is the commented out one on line 1155 - if I comment it out, everything works fine but if I put it in, suddenly the lines sometimes just don't show up.