Every time WatchFrame_Update() is called (basically when something changes on the tracker frame), my mod does the following:
function ShowLines()
local width, height = 0, 0
local line1 = CreateFrame("Frame", WatchFrameLines, "WatchFrameLineTemplate")
line1.text:SetText("Quest Title")
line1:SetPoint("TOPLEFT", WatchFrameLines, "TOPLEFT", 0, 0)
line1:SetPoint("TOPRIGHT", WatchFrameLines, "TOPRIGHT", 0, 0)
local line2 = CreateFrame("Frame", WatchFrameLines, "WatchFrameLineTemplate")
line2.text:SetText("Quest Info")
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()
line1:SetWidth(width)
line2:SetWidth(width)
line1:Show()
line2:Show()
return width, height
end
function SetTrackerPosition()
local anchorPoint, xOffset, yOffset = "", 0, 0
WatchFrame:ClearAllPoints()
if(self.db.profile.trackerVerticalGrowth == "1-up") then
anchorPoint = "BOTTOM"
yOffset = self.db.profile.trackerBottom
else
anchorPoint = "TOP"
yOffset = self.db.profile.trackerTop
end
if(self.db.profile.trackerHorizontalGrowth == "1-left") then
anchorPoint = anchorPoint .. "RIGHT"
xOffset = self.db.profile.trackerRight
else
anchorPoint = anchorPoint .. "LEFT"
xOffset = self.db.profile.trackerLeft
end
WatchFrame:SetPoint(anchorPoint, UIParent, "BOTTOMLEFT", xOffset, yOffset)
end
function SaveTrackerPosition()
self.db.profile.trackerTop = watchFrame:GetTop()
self.db.profile.trackerBottom = watchFrame:GetBottom()
self.db.profile.trackerLeft = watchFrame:GetLeft()
self.db.profile.trackerRight = watchFrame:GetRight()
end
function WatchFrame_UpdateHook()
local width, height = ShowLines()
-- Resize the tracker to fit these strings
WatchFrame:SetSize(width, height)
SetTrackerAnchor()
SaveTrackerPosition()
end
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?
A frame can be visible without you being able to see it.
Example: print(CreateFrame("Frame"):IsVisible()) -- prints 1
If a frame has 0 alpha, no dimensions, or is not anchored to anything, it will not be seen by the user.
Are SetTrackerAnchor() and SaveTrackerPosition() actual Blizzard API? They are not called or defined in any of Blizzard's interface files. If not, may we see those functions please?
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.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
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?
Example: print(CreateFrame("Frame"):IsVisible()) -- prints 1
If a frame has 0 alpha, no dimensions, or is not anchored to anything, it will not be seen by the user.
Are SetTrackerAnchor() and SaveTrackerPosition() actual Blizzard API? They are not called or defined in any of Blizzard's interface files. If not, may we see those functions please?
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.