Thread Tools Display Modes
02/19/15, 01:18 PM   #1
Weolo
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 79
Question XML Anchors

Hi All

I am trying to create a group of textures and I am having trouble positioning them.

I don't completely understand Anchors yet.

Whats the easiest way with XML to align 4 textures each 20px square into a 2x2 grid shape?
Any tips on using Anchors?

Heres some bad XML code so we have something to work with

Code:
<Controls>
  <Control name="$(parent)_Section">
    <Controls>
      <Texture textureFile="something.dds">
        <Anchor point="TOPLEFT" relativePoint="$(parent)" relativeTo="TOPLEFT" offsetX="0" offsetY="0" />
        <Dimensions x="20" y="20" />
      </Texture>
      <Texture textureFile="something.dds">
        <Anchor point="TOPLEFT" relativePoint="$(parent)" relativeTo="TOPLEFT" offsetX="0" offsetY="0" />
        <Dimensions x="20" y="20" />
      </Texture>
      <Texture textureFile="something.dds">
        <Anchor point="TOPLEFT" relativePoint="$(parent)" relativeTo="TOPLEFT" offsetX="0" offsetY="0" />
        <Dimensions x="20" y="20" />
      </Texture>
      <Texture textureFile="something.dds">
        <Anchor point="TOPLEFT" relativePoint="$(parent)" relativeTo="TOPLEFT" offsetX="0" offsetY="0" />
        <Dimensions x="20" y="20" />
      </Texture>
    </Controls>
  </Control>
</Controls>

Last edited by Weolo : 02/19/15 at 01:39 PM. Reason: Typo
  Reply With Quote
02/19/15, 01:44 PM   #2
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
See picture here:
http://wiki.esoui.com/Control:SetAnchor

There is many ways how to do it, everything depends on how you want to handle parent control.

For example you can anchor first texture to the top left corner of parent control an then all other textures anchor to the first one:
XML Code:
  1. <Controls>
  2.   <Control name="$(parent)_Section">
  3.     <Controls>
  4.       <Texture name="$(parent)_Texture1" textureFile="something.dds">
  5.         <Anchor point="TOPLEFT" />
  6.         <Dimensions x="20" y="20" />
  7.       </Texture>
  8.       <Texture name="$(parent)_Texture2" textureFile="something.dds">
  9.         <Anchor point="TOPLEFT" relativeTo="$(parent)_Texture1" relativePoint="TOPRIGHT" />
  10.         <Dimensions x="20" y="20" />
  11.       </Texture>
  12.       <Texture name="$(parent)_Texture3" textureFile="something.dds">
  13.         <Anchor point="TOPLEFT" relativeTo="$(parent)_Texture1" relativePoint="BOTTOMLEFT" />
  14.         <Dimensions x="20" y="20" />
  15.       </Texture>
  16.       <Texture name="$(parent)_Texture4" textureFile="something.dds">
  17.         <Anchor point="TOPLEFT" relativeTo="$(parent)_Texture1" relativePoint="BOTTOMRIGHT" />
  18.         <Dimensions x="20" y="20" />
  19.       </Texture>
  20.     </Controls>
  21.   </Control>
  22. </Controls>

Another example could be anchoring to the center of parent control:
XML Code:
  1. <Controls>
  2.   <Control name="$(parent)_Section">
  3.     <Controls>
  4.       <Texture textureFile="something.dds">
  5.         <Anchor point="BOTTOMRIGHT" relativePoint="CENTER" />
  6.         <Dimensions x="20" y="20" />
  7.       </Texture>
  8.       <Texture textureFile="something.dds">
  9.         <Anchor point="BOTTOMLEFT" relativePoint="CENTER" />
  10.         <Dimensions x="20" y="20" />
  11.       </Texture>
  12.       <Texture textureFile="something.dds">
  13.         <Anchor point="TOPRIGHT" relativePoint="CENTER" />
  14.         <Dimensions x="20" y="20" />
  15.       </Texture>
  16.       <Texture textureFile="something.dds">
  17.         <Anchor point="TOPLEFT" relativePoint="CENTER" />
  18.         <Dimensions x="20" y="20" />
  19.       </Texture>
  20.     </Controls>
  21.   </Control>
  22. </Controls>

If you do not specify any anchor argument, it will use default. For example relativeTo will be "$(parent)", offsetX and offsetY will be "0".

Last edited by Garkin : 02/19/15 at 02:08 PM.
  Reply With Quote
02/19/15, 01:52 PM   #3
Weolo
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 79
Thats brilliant!
Exactly the information I needed, thanks very much.
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » XML Anchors


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off