OAP Lizzard A game interface engine
Game interfaces, outside the game Settings
← XML guide

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.

The nine anchor points of a region A rectangle with a dot at each corner, the middle of each side, and the centre, labelled TOPLEFT, TOP, TOPRIGHT, LEFT, CENTER, RIGHT, BOTTOMLEFT, BOTTOM and BOTTOMRIGHT. TOPLEFT TOP TOPRIGHT LEFT CENTER RIGHT BOTTOMLEFT BOTTOM BOTTOMRIGHT
Point names are written in capitals, as Blizzard's code always writes them. Guessed whether the game also takes lower case; Lizzard doesn't.

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>
MyTip's top left anchored to MyWindow's top right MyWindow on the left. Its TOPRIGHT point is marked. MyTip's TOPLEFT point sits 10 to the right of it and 20 below. Positive x is to the right and positive y is up, so y -20 moves down. MyWindow the target (relativeTo) relativePoint TOPRIGHT x 10 y -20 MyTip point TOPLEFT 120 × 60 from its Size +x +y
The offset is measured from the target's point. Positive y is up, so y="-20" moves the tip down. Measured (Retail)

The parts of <Anchor>, and what happens when one is left out:

AttributeMeaningLeft out
pointThis region's point.Needed: the anchor is left out without it.
relativeTo, relativeKeyThe target, by global name or by key path (Names and keys).The parent; the screen if there is none.
relativePointThe target's point.The same as point.
x, yThe 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 point replaces the first, as SetPoint does. 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)