WoW:XML/Layer: Difference between revisions

117 bytes added ,  11 January 2021
m
(→‎Elements: Fixed "FonstString" typos)
Line 3: Line 3:
A [[XML/Layer|Layer]] is a fundamental UI building block for defining visible UI elements of [[XML/Frame|Frames]]. A Layer is an element of an [[XML/Layers|Layers]] array defined in a [[XML/Frame|Frame]]. Layer XML elements, as a part of [[XML/Layers|Layers]] array, can be defined on any [[XML/Frame|Frame]], which includes elements like [[XML/Button|Buttons]] and [[XML/CheckButton|CheckButtons]].
A [[XML/Layer|Layer]] is a fundamental UI building block for defining visible UI elements of [[XML/Frame|Frames]]. A Layer is an element of an [[XML/Layers|Layers]] array defined in a [[XML/Frame|Frame]]. Layer XML elements, as a part of [[XML/Layers|Layers]] array, can be defined on any [[XML/Frame|Frame]], which includes elements like [[XML/Button|Buttons]] and [[XML/CheckButton|CheckButtons]].


==Inheritance==
== Inheritance ==
Inherited by: none, Inherits: none, Defined in: [[XML/Frame|Frame]] > [[XML/Layers|Layers]]
Inherited by: none, Inherits: none, Defined in: [[XML/Frame|Frame]] > [[XML/Layers|Layers]]


==Elements==
== Elements ==
* [[XML/Texture|Texture]] ... - 0 or more Textures to be rendered in the Layer
* [[XML/Texture|Texture]] ... - 0 or more Textures to be rendered in the Layer
* [[XML/FontString|FontString]] ... - 0 or more FontStrings to be rendered in the Layer
* [[XML/FontString|FontString]] ... - 0 or more FontStrings to be rendered in the Layer


==Attributes==
== Attributes ==
* level ([[XML/DRAWLAYER|DRAWLAYER]]) - Layer level in 'Z order'. Default is 'ARTWORK'.
* level ([[XML/DRAWLAYER|DRAWLAYER]]) - Layer level in 'Z order'. Default is 'ARTWORK'.
* textureSubLevel (int) - Additional sub-leveling of 'level'. Range of -8 .. 7. Default is '0'.
* textureSubLevel (int) - sub-level of 'level' for textures. Range of -8 .. 7. Default is '0'.


== Summary ==
== Summary ==
Line 18: Line 18:


=== Example ===
=== Example ===
  <[[XML/Frame|Frame]] name="MyFrame">
 
   <Layers>
  <[[XML/Frame|Frame]] name="MyFrame">
     &lt;Layer&gt;
   <Layers>
       &lt;[[XML/Texture|Texture]]&gt;
     <Layer>
         &lt;Size x="100" y="100" /&gt;
       <[[XML/Texture|Texture]]>
         &lt;HitRectInsets&gt;
         <Size x="100" y="100" />
           &lt;[[XML/AbsInset|AbsInset]] left="0" right="-100" top="0" bottom="0"/&gt;
         <HitRectInsets>
         &lt;/HitRectInsets&gt;
           <[[XML/AbsInset|AbsInset]] left="0" right="-100" top="0" bottom="0"/>
         &lt;Color a="1" r="1" g="1" b="1" /&gt;
         </HitRectInsets>
       &lt;/Texture&gt;
         <Color a="1" r="1" g="1" b="1" />
       &lt;Texture&gt;
       </Texture>
         &lt;Size x="100" y="100" /&gt;
       <Texture>
         &lt;Color a="1" r="1" g="1" b="1" /&gt;
         <Size x="100" y="100" />
       &lt;/Texture&gt;
         <Color a="1" r="1" g="1" b="1" />
     &lt;/Layer&gt;
       </Texture>
   &lt;/Layers&gt;
     </Layer>
  &lt;/Frame&gt;
   </Layers>
  </Frame>


This example will show a frame with a single default layer, displaying two textures.
This example will show a frame with a single default layer, displaying two textures.


== Details ==
== Details ==
=== level ===
There are 3 main levels of layer: BACKGROUND is in the back, ARTWORK is in the middle, and OVERLAY is in front. If you want to be sure that a object is before another, you must specify the level where you want to place it.


There are 3 levels of layers: BACKGROUND is in the back, ARTWORK is in the middle and OVERLAY is in front. If you want to be sure that a object is before another, you must specify the level where you want to place it.
* BACKGROUND - Level 0. Place the background of your frame here.
* BORDER - Level 1. Place the border of your frame here.
* ARTWORK - Level 2. Place the artwork of your frame here.
* OVERLAY - Level 3. Place your text, objects, and buttons in this level.
* HIGHLIGHT - Level 4. Special layer that only shows on mouseover.


BACKGROUND - Level 0. Place the background of your frame here. <br />
Elements in the 'HIGHLIGHT' Layer are automatically shown or hidden when the mouse enters or leaves. For Highlighting to work you need 'enableMouse="true"' in your <nowiki><Frame></nowiki> attributes.
BORDER - Level 1. Place the artwork of your frame here . <br />
ARTWORK - Level 2. Place the artwork of your frame here. <br />
OVERLAY - Level 3. Place your text, objects, and buttons in this level. <br />
HIGHLIGHT - Level 4. Place your text, objects, and buttons in this level. <br />


*Elements in the '''HIGHLIGHT''' Layer are '''automatically shown or hidden''' when the mouse enters or leaves.
Layer can be set on creation using the [[XML_properties#layers|<nowiki><Layers></nowiki>]] tag in XML, or the "layer" parameter in [[API Frame CreateTexture|Frame:CreateTexture]](). To change the layer after creation, use the [[API LayeredRegion SetDrawLayer|LayeredRegion:SetDrawLayer]]() function.
*For Highlighting to work you need '''enableMouse="true"''' in your ''<Frame>'' attributes.


Layer can be set on creation using the [[XML_properties#layers|''<Layers>'']] tag in XML, or the "layer" parameter in [[API Frame CreateTexture|Frame:CreateTexture]](). To change the layer after creation, use the [[API LayeredRegion SetDrawLayer|LayeredRegion:SetDrawLayer]]() function.
<Layers>
 
  <Layer level="BACKGROUND">
''Note: The above are capitalized for a reason. See example:''<BR />
 
&lt;Layers&gt;
  &lt;Layer level="BACKGROUND"&gt;
     ...
     ...
   &lt;/Layer&gt;
   </Layer>
   &lt;Layer level="ARTWORK"&gt;
   <Layer level="ARTWORK">
     ...
     ...
   &lt;/Layer&gt;
   </Layer>
   &lt;Layer level="OVERLAY"&gt;
   <Layer level="OVERLAY">
     ...
     ...
   &lt;/Layer&gt;
   </Layer>
  &lt;/Layers&gt;
  </Layers>
 
=== textureSubLevel ===
This allows for fine tuning order of Textures in a Layer. FontStrings are always drawn on top of Textures at the same Level, so this only applies to Textures.
 
== External links ==
* [//www.wowinterface.com/forums/showthread.php?t=37051 wowInterface forums] - discussion on Layer mechanics for patch 4.0 and newer