m
Move page script moved page XML/Anchor to WoW:XML/Anchor without leaving a redirect
mNo edit summary |
m (Move page script moved page XML/Anchor to WoW:XML/Anchor without leaving a redirect) |
||
| (13 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
{{uixmltype}} | {{uixmltype}} | ||
An Anchor is also a fundamental UI building block for defining positional layout for UI elements of [[XML/LayoutFrame|LayoutFrames]]. An Anchor is an element of an [[XML/Anchors|Anchors]] array defined in a [[XML/LayoutFrame|LayoutFrame]]. Anchor XML elements, as a part of [[XML/Anchors|Anchors]] array, can be defined on any [[XML/LayoutFrame|LayoutFrame]] or LayoutFrame type, which also includes [[XML/Frame|Frames]], [[XML/Texture|Textures]], and [[XML/FontString|FontStrings]]. | An Anchor is also a fundamental UI building block for defining positional layout for UI elements of [[XML/LayoutFrame|LayoutFrames]]. An Anchor is an element of an [[XML/Anchors|Anchors]] array defined in a [[XML/LayoutFrame|LayoutFrame]]. Anchor XML elements, as a part of [[XML/Anchors|Anchors]] array, can be defined on any [[XML/LayoutFrame|LayoutFrame]] or LayoutFrame type, which also includes [[XML/Frame|Frames]], [[XML/Texture|Textures]], and [[XML/FontString|FontStrings]]. | ||
| Line 11: | Line 11: | ||
** <[[XML/RelDimension|RelDimension]]> | ** <[[XML/RelDimension|RelDimension]]> | ||
==Attributes== | == Attributes == | ||
* point ([[XML/FRAMEPOINT|FRAMEPOINT]]) | * point ([[XML/FRAMEPOINT|FRAMEPOINT]]) - this place on this layout frame that should get anchored | ||
* relativeTo (string) - global name of LayoutFrame to make relative to. | * relativeTo (string) - global name of LayoutFrame to make relative to. By is relative to its parent. | ||
* relativeKey (string) - a Lua reference to make relative to. | * relativeKey (string) - a Lua reference to make relative to. Alternative to using 'relativeTo'. See 'parentKey' in [[XML/LayoutFrame|LayoutFrame]]. | ||
* relativePoint ([[XML/FRAMEPOINT|FRAMEPOINT]]) | * relativePoint ([[XML/FRAMEPOINT|FRAMEPOINT]]) - place on the relative frame that 'point' should anchored to. Default value is same as value of 'point' | ||
* x (int) | * x (int) - horizontal offset from the effective 'relativePoint'. Default is 0. | ||
* y (int) | * y (int) - vertical offset from the effective 'relativePoint'. Default is 0. | ||
== Summary == | == Summary == | ||
| Line 49: | Line 49: | ||
=== Points and Relative Points === | === Points and Relative Points === | ||
A particular edge or corner of a layout frame is an anchor 'point'. | 1) A particular edge or corner of a layout frame is an anchor 'point'. | ||
* point ([[XML/FRAMEPOINT|FRAMEPOINT]]) | * point ([[XML/FRAMEPOINT|FRAMEPOINT]]) | ||
For | This defines where in this layout frame that it should be anchored. For example, a value of 'TOPLEFT' refers to the top left corner of the of this layout frame. For an edge, 'LEFT' for example, the center of that edge is considered to be the actual anchor point, if no other anchors additionally overriding the layout frames vertical axis are defined. | ||
The 'relativePoint' defines where, on another layout frame, to place a particular 'point' of the layout frame itself. | 2) The 'relativePoint' defines where, on another layout frame, to place a particular 'point' of the layout frame itself. | ||
* relativePoint ([[XML/FRAMEPOINT|FRAMEPOINT]]) | * relativePoint ([[XML/FRAMEPOINT|FRAMEPOINT]]) | ||
This is the anchor's relative position on the 'relative frame'. By default, the anchor will attach to the same point on the relative frame as defined by 'point'. So, if 'point' is set to 'LEFT', then by default the anchor will also attach to the left side of the relative frame. If 'relativePoint' is set however, it overrides the default behavior. So if 'relativePoint' set to 'RIGHT', then the left side of this layout frame, in this example, will instead anchor to the right side of the relative frame. | |||
3) The 'relativeTo' and 'relativeKey' atributes define which other 'layout frame' this anchor is relative to. | |||
* relativeTo (string) | * relativeTo (string) | ||
* relativeKey (string) | * relativeKey (string) | ||
The 'relativeTo' is the name of a frame to use for the 'relativePoint'. | By default, all layout frames are relative to their parent. If either of these are set, then it overrides the relative layout frame with respect to this anchor point. Different anchors can also have different relative layout frames, such that a texture could automatically stretch across two different other layout frames. | ||
The 'relativeTo' is the global name of a frame to use for the 'relativePoint'. Alternatively, the 'relativeKey' is the name of a runtime Lua variable on this layout frame's parent, that contains a reference to the layout frame to be used for the 'relativePoint'. Using 'parentKey' elsewhere is a way to define these values for 'realtiveKey'. If 'relativeTo' is defined, then 'relativeKey' will be ignored. See the 'parentKey' attribute in [[XML/LayoutFrame]] as one of the many ways to set this value. | |||
=== Layouts === | === Layouts === | ||
Layout in printing or computer graphics is concerned with the flow of elements with respect to each other. A layout system is a system for defining that layout. For WoW, flow in layout is defined by frames and anchors, and flow order is established by 'laying out' frames from their creation order from top to bottom, and from parent to child. Frames with the | Layout in printing or computer graphics is concerned with the flow of elements with respect to each other. A layout system is a system for defining that layout. For WoW, flow in layout is defined by frames and anchors, and flow order is established by 'laying out' frames from their creation order from top to bottom, and from parent to child. Frames with the same parent and render z-order, will be rendered from first to last in definition order as well. | ||
<Frame name="Frame"> | <Frame name="Frame"> | ||
<Frames> | |||
<Frame name="Frame2"> | |||
<Size x="100" y="100"> | |||
<[[XML/Anchors|Anchors]]><[[XML/Anchor|Anchor]] point="TOP" relativePoint="BOTTOM" x="0" y="-10" /></Anchors> | |||
</frame> | |||
<Frame name="Frame3"> | |||
<Size x="100" y="100"> | |||
<[[XML/Anchors|Anchors]]><[[XML/Anchor|Anchor]] point="TOPLEFT" /></Anchors> | |||
</frame> | |||
</Frames> | |||
</Frame> | </Frame> | ||
This will place the 'Frame2' child at an offset of 10 from the bottom of its parent frame; 'relativeTo' for 'Frame2' is its parent by default. Frame3 will be rendered on top of Frame2 is they overlap. | This will place the 'Frame2' child at an offset of 10 from the bottom of its parent frame; 'relativeTo' for 'Frame2' is its parent by default. Frame3 will be rendered on top of Frame2 is they overlap. | ||
<Frame name="Frame3"> | <Frame name="Frame3"> | ||
<Size x="50" y="50"> | <Size x="50" y="50"> | ||
| Line 131: | Line 133: | ||
Each of these are, in the general case, equivalient: | Each of these are, in the general case, equivalient: | ||
<pre> | |||
<[[XML/Anchor|Anchor]] point="TOPLEFT" /> | |||
</pre> | |||
<pre> | |||
<[[XML/Anchor|Anchor]] point="TOPLEFT" relativeTo="$parent" /> | |||
</pre> | |||
<pre> | |||
<[[XML/Anchor|Anchor]] point="TOPLEFT" relativeKey="$parent" /> | |||
</pre> | |||
In each case the relative frame is parent. For the default case, the relative frame its the parent. For 'relativeTo', a named parent frame's full name will replace '$parent' causing 'relativeTo' to refer to the parent frame by name. For 'relativeKey', the named or unnamed parent frame's Lua 'reference' will be used as the relative frame, similar to 'self.GetParent()'. | In each case the relative frame is parent. For the default case, the relative frame its the parent. For 'relativeTo', a named parent frame's full name will replace '$parent' causing 'relativeTo' to refer to the parent frame by name. For 'relativeKey', the named or unnamed parent frame's Lua 'reference' will be used as the relative frame, similar to 'self.GetParent()'. | ||