Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
WoW
Talk
English
Views
Read
Edit
History
More
Search
Navigation
Home
Random page
Help using wiki
Editions
for WoW
for WildStar
for Solar2D
Documentation
for WoW
for WildStar
Reference
WoW
⦁ FrameXML
⦁ AddOns
⦁ API
⦁ WoW Lua
WildStar
⦁ AddOns
⦁ API
⦁ WildStar Lua
Engine
Tools
What links here
Related changes
Special pages
Page information
Site
Recent Changes
Editing
WoW:XML/Frame
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Details == === Description === Frames are the building blocks of the visual components of the user interface. All of the various visual elements of the UI are types of Frame, and inherit most if not all of the basic frame properties, in addition to adding some more. Frames are defined in the various <tt>.xml</tt> files in the <tt>Interface</tt> directory (except for the <tt>Bindings.xml</tt> files, which provide key bindings). === Events === In addition to Frames being the things that you can see, Frames are also the things which UI and game events are delivered to. If you're writing code that needs to know about something, it will need a Frame (though not necessarily a visible one) to receive the event. There are many types of events, though often in AddOn development it refers to an [[API event]] game event. rather than other UI events. A frame indicates its interest in events in a number of ways: ==== UI Interaction ==== The <Scripts> XML element of a frame definition defines a bunch of different handler types, for most of these (<OnEvent> being the exception) the Frame will automatically be informed of the appropriate events when they occur, via the defined handler script. ==== Game Interaction ==== Most of the useful information comes from game events, which are all passed to the frame via the generic <OnEvent> script handler. There are literally hundreds of types of Game Events, so rather than spend a lot of time passing every event to every handler, an AddOn must register its interest in a frame receiving a certain event. This is accomplished through the [[API Frame RegisterEvent|Frame:RegisterEvent("event")]] function, and is typically performed within the <OnLoad> or <OnShow> handlers. Once an event has been registered, the Frame's <OnEvent> handler will be called whenever that event occurs. === Virtual Frames === Frames, like all [[XML/LayoutFrame|LayoutFrame]] types, can be defined as virtual, in which case instead of defining an actual UI element that shows up, the definition provides a template which can then be used multiple times by other Frames. A good example of a virtual Frame is the chat window, there are actually several virtual frames which are assembled into a chat window, but then each potential chat window simply implements the virtual one, which reduces the amount of duplicated code required. === Parents === Frames have a parent frame. By default, the parent of any child frame is the frame the child is defined in. <pre> <Frame name="Fame1"> <Frames> <Frame name="Fame2"><!-- Frame2's 'parent' is automatically Frame1 --> </Frame> </Frames> </Frame> </pre> ; Visibility Each Frame can be shown and hidden. If a Frame is Hidden, then it and all of its children cease to be visible. It's far simpler to show and hide the parent frame of a complex set, than to try and manage the visibility of many elements independently. ; Scaling The UI engine is built to perform automatic scaling of UI elements, the entire UI (actually, the UIParent frame, which most frames are children of), or any component of it can be enlarged or shrunk to fit on a screen appropriately. Frames are scaled and located relative to their parent rather than the whole screen, which means that you only need to worry about how your subcomponents relate to each other, and then your component can be placed and sized any way necessary. ; Notes Complex visual elements are usually formed using many frames. It's considered good design to have a single related parent frame amongst them. By default, all child frames already use the frame they are defined in as their parent. If some of the frames are defined separately, they can still explicitly set their parent to a common frame, using the 'parent' attribute, and have the rest use that (or its children) as their parent. Well behaved UI AddOns will normally want their top-level parent frame, the highest-level frame that is not defined in another frame, to be set expressly to 'UIParent'. Failure to do so means, amongst other things, that the AddOn's frame won't vanish when the Hide UI key is pressed. === Frame Levels === Frame levels are that which determines what frame will be on top of other frame. Each frame has a frame level value. If frame A is placed in the same area as frame B, then the frame with the highest frame level will be on top of the other frame. Instead of going around and specifying that frame A should have frame level 12, and frame B frame level 15, Blizzard uses a set of predefined "groups" of frame levels called frameStrata. The valid values for frameStrata are "PARENT", "BACKGROUND", "LOW", "MEDIUM", "HIGH", "DIALOG", "FULLSCREEN_DIALOG" and "TOOLTIP" (there may be more). For the values "BACKGROUND" through "TOOLTIP" the values are listed in their assumed ascendancy (i.e. it is assumed that "BACKGROUND" will be below "LOW"). The default value is "PARENT" if no frameStrata is specified. There is also a special attribute called toplevel - this means (hopefully) that the frame should be on top of any other frame (or, possibly, on top of any other frame in the same [[XML/Frame|frameStrata]]). === frameLevel and frameStrata === :''What is the difference between frameLevel and frameStrata?'' Well first off, though you can set frameLevel in your <Frame> tag, frameLevel is dictated by XML nesting. Check this example out: <Frame name="MyFrame" frameStrata="DIALOG" parent="UIParent"> <Frames> <Button name="MyButton"/> </Frames> </Frame> Since UIParent's frameLevel is 1, the frame we created here should be frameLevel 2 and the Button should be frameLevel 3. You can check a frame's level with Frame:GetFrameLevel() and you can set it with Frame:SetFrameLevel(). However, setting a frame's level is ill-advised. It is given its level automatically and it's best to leave it that way. If you need to change a frame's level in your own code, best thing to do is just nest your code differently. Note: If the parent of a frame is changed by your code, the frame levels are not adjusted to compensate. You may need to adjust the frame's level to fix the way the frame displays. ;Possible Values: * 0 - No parent * 1 - Parent is UIParent * 2 and higher... The maximum value seems to be 129. If you call SetFrameLevel with a value greater than 129, the value passed will be ignored, and the frame level will be set to 129. In my experimentation, and with my WoW client (Windows), it seems higher values will stick, and be honored, if you call SetFrameLevel twice in a row. This is probably unreliable. If you find that you are having to set frame levels greater than 129, see if you can use a hierarchical set of parent frames instead. A more complete explanation of how frame levels are used is found at [[How the user interface is rendered]]. [[Category:XML elements]] [[Category:Interface customization]]
Summary:
Please note that all contributions to AddOn Studio are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see
AddOn Studio Wiki:Copyrights
for details).
Submissions must be written by you, or copied from a public domain or similar free resource (see
AddOn Studio Wiki:Copyrights
for details).
Cancel
Editing help
(opens in new window)