Wowpedia

We have moved to Warcraft Wiki. Click here for information and the new URL.

READ MORE

Wowpedia
Advertisement

Inheritance

Derived from: Frame

Contained in: Frames, Ui

Runtime object: UIOBJECT_object

Elements

Element

Attributes

attribute
description
attribute
description

Description

Derived from: LayoutFrame

Elements: TitleRegion, ResizeBounds, BackDrop, HitRectInsets, Layers, Frames, Scripts, BackgroundInsets

Attributes: alpha, parent, toplevel, movable, resizable, frameStrata, frameLevel, id, enableMouse, enableKeyboard

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 .xml files in the Interface directory (except for the Bindings.xml 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 a 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 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 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.

Frame Parents

Every Frame can have a parent frame, and well behaved UI AddOns will want to set their parent to UIParent (Failure to do so means, amongst other things, that the AddOn doesn't vanish when the Hide GUI key is pressed). A complex visual element is likely formed of multiple Frames, and it's considered good design to designate a parent Frame amongst them, and have the rest use that (or its children) as their parent. Doing this is useful for a couple of reasons.

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 World of Warcraft 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.

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 frameStrata). Valid values are "false" and "true".

Advertisement