Documentation / XML guide
Templates
virtual templates, inherits, mixins, and the order a frame is built in.
A template is an element marked virtual="true". Nothing is built from it when it loads: it waits
until a frame names it in inherits, or Lua's CreateFrame is given its name. Templates
can inherit templates, so a window can be built up in layers of shared parts.
A panel, a titled panel made from it, and a window made from both (MyMovableTemplate and MyOptionsMixin stand for your own)
<Frame name="MyPanelTemplate" virtual="true">
<Size x="200" y="100"/>
<Layers>
<Layer level="BACKGROUND">
<Texture parentKey="Bg" setAllPoints="true">
<Color r="0" g="0" b="0" a="0.45"/>
</Texture>
</Layer>
</Layers>
</Frame>
<Frame name="MyTitledPanelTemplate" inherits="MyPanelTemplate" virtual="true">
<Layers>
<Layer level="OVERLAY">
<FontString parentKey="Title" inherits="GameFontNormal">
<Anchors><Anchor point="TOP" y="-6"/></Anchors>
</FontString>
</Layer>
</Layers>
</Frame>
<Frame name="MyOptions" parent="UIParent" inherits="MyTitledPanelTemplate, MyMovableTemplate"
mixin="MyOptionsMixin">
<Size x="320"/>
<Anchors><Anchor point="CENTER"/></Anchors>
</Frame>
The order a frame is built in
When Lizzard builds MyOptions, it works through four steps. Each step can change what an earlier one
set, so the element's own values, which come last, win.
<Size x="320"/> comes last and changes only the width; the height
it leaves out keeps the 100 its template set.Blizzard's code This is the order Blizzard's interface relies on, and Lizzard's probe compares whole templates built this way with the game's.
A template's frames, textures and font strings are made when it is applied, so MyOptions gets its own
Bg and Title. Anchors from templates and the element's own add up rather than replace each
other, unless they are for the same point: see Anchors.
Values a template gives when the element has none
parentKeyandparentArray: a template can name the frame in its parent. Blizzard's Edit Mode readsself.Selectionon frames whose template saysparentKey="Selection". Blizzard's codeparent="UIParent": a frame with no parent of its own takes its template's. One of Blizzard's chat windows depends on it; without it, it drew about one and a half times too big. Screenshot
Mixins
mixin="A, B" copies the functions and values of the global tables A and B into
the frame, so self:Method() works. secureMixin does the same. A table that doesn't exist yet
is reported: "mixin 'A' not found". The <Mixins><Mixin key="A"/></Mixins> form works
too, applied where it stands among the frame's children.
Guessed whether the game applies that form before the frame's
KeyValues.
Lua's CreateFrame("Frame", "Name", parent, "TemplateA, TemplateB") applies the templates the same
way, then runs the frame's OnLoad.