View Single Post
02-07-05, 12:39 PM   #3
mondinga
A Theradrim Guardian
AddOn Author - Click to view addons
Join Date: Jan 2005
Posts: 66
Toplevel doesn't have anything to do with frame level. Before beta ended slouken posted saying that toplevel="true" simply means the frame is something flagged for user interaction, most likely with the mouse. What actual impacts it has I'm unsure of, as the answer was fairly vague. At any rate, this means most default UI components are set to toplevel. A few things are not though, such as the durability frame.

And a frame's level within it's strata is not always set to 0 - it is determined first by it's XML nesting. For instance, take the player health bar in the player frame. PlayerFrameHealthBar:GetFrameLevel() returns 3. If you look, it is a direct child of the PlayerFrame itself, even if PlayerFrame is not set as it's parent. So, what does PlayerFrame return for a level? PlayerFrame:GetFrameLevel() returns 2, as expected.

But why is it 2, even though it's the lowest level frame in the PlayerFrame.xml file? Because the player frame's parent is set to UIParent, and UIParent:GetFrameLevel() does indeed return 1. And if you look, UIParent's parent is set to WorldFrame, which returns 0 for a frame level.

But this doesn't entirely make sense either, or sense as you'd expect it, if you're considering how frame levels work within different strata. The UIParent is set to MEDIUM strata, the PlayerFrame is set to LOW, and the WorldFrame is set to BACKGROUND, so why would the frame level of one extend above the other, if it's set to a lower strata? Perhaps these levels are simply unimportant to the XML engine, and are something cooked up solely by the LUA engine, without a thought to strata or context at all?

As I've always thought, the :SetFrameLevel() method is a sort of hack-ish way of manually defying the XML. Indeed, if you look through a lot of the default code, Blizz will intentionally embed frames within frames within frames, seemingly without reason, simply to get to the correct frame level they need for them to display. The player frame is a great example, as is the main menu bar.

At any rate, we don't know exactly how it all works, but that doesn't impact heavily being able to use the system. In the end you usually just have to do whatever works to get things to display and operate correctly.
  Reply With Quote