ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Lua/XML Help (https://www.esoui.com/forums/forumdisplay.php?f=175)
-   -   XML Anchors (https://www.esoui.com/forums/showthread.php?t=4314)

Weolo 02/19/15 01:18 PM

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>


Garkin 02/19/15 01:44 PM

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".

Weolo 02/19/15 01:52 PM

Thats brilliant!
Exactly the information I needed, thanks very much.


All times are GMT -6. The time now is 11:32 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI