Documentation / XML guide
Anchors
The nine points, what one anchor does, offsets, and anchoring to another region.
Regions aren't given a position on the screen. They are tied to each other: "my top left sits at that frame's top right, 10 to the right and 20 down". These ties are anchors. When a frame moves, everything anchored to it follows.
The nine points
Every region has nine points an anchor can name: four corners, four sides and the centre.
What one anchor says
An anchor reads: my point sits at the target's relativePoint, moved by
x and y.
A tip box beside a window
<Frame name="MyTip" parent="MyWindow">
<Size x="120" y="60"/>
<Anchors>
<Anchor point="TOPLEFT" relativeTo="MyWindow" relativePoint="TOPRIGHT" x="10" y="-20"/>
</Anchors>
</Frame>
y="-20" moves the tip
down. Measured (Retail)The parts of <Anchor>, and what happens when one is left out:
| Attribute | Meaning | Left out |
|---|---|---|
point | This region's point. | Needed: the anchor is left out without it. |
relativeTo, relativeKey | The target, by global name or by key path (Names and keys). | The parent; the screen if there is none. |
relativePoint | The target's point. | The same as point. |
x, y | The offset, in this region's own units. | 0. |
In Lua the same anchor is MyTip:SetPoint("TOPLEFT", MyWindow, "TOPRIGHT", 10, -20).
The offset can also be written as a child element, which wins over the attributes:
<Anchor point="TOPLEFT" relativePoint="TOPRIGHT">
<Offset x="10" y="-20"/>
</Anchor>
Offsets are in the region's own units
An offset is multiplied by the region's scale, its parents' scales included. A frame at scale 2 anchored 10 units from its parent's edge sits 20 of the parent's units away. Sizes work the same way. Measured (Retail)
Several anchors
- A second anchor for the same
pointreplaces the first, asSetPointdoes. Measured (Retail) - Anchors for different points add up, whether they come from templates or from the element. Two anchors can stretch a region between them: Sizes and stretching shows when that happens, and which anchor wins when two give the same edge.
- An anchor can't loop: a region can't be anchored to itself, or to a region that is anchored to it. Measured (Retail)