View Single Post
04/14/14, 03:12 AM   #6
Stormknight
 
Stormknight's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 128
Something you can do, that I have working nicely in my main addon is to chain components together on the screen with anchor points.


Say you have two labels: LABELA & LABELB.

You set the position of LABELA as normal, within your top-level container.

You can then use SetAnchor to anchor the TOP of LABELB to the BOTTOM of LABELA.

If you change the height of LABELA, then the position of LABELB on the screen will automatically adjust without you having to do any additional scripting to move it.

Code:
<GuiXml>
    <Controls>
        <TopLevelControl name="MyAddon" mouseEnabled="true" movable="true" clampedToScreen="true">
            <Dimensions x="200" y="150" />
            <Controls>
                <Label name="$(parent)LabelA" font="ZoFontWinH1" color="FFFFFF" inheritAlpha="true" wrapMode="TRUNCATE" verticalAlignment="TOP" horizontalAlignment="CENTER" text="This is Label A" />
                <Label name="$(parent)LabelB" font="ZoFontWinH5" color="FFFFFF" inheritAlpha="true" wrapMode="TRUNCATE" verticalAlignment="TOP" horizontalAlignment="CENTER" text="This is Label B" />
            </Controls>
        </TopLevelControl>
    </Controls>
</GuiXml>
then in your LUA:
Code:
MyAddonLabelB:SetAnchor(TOP, MyAddonLabelA, BOTTOM, 0, 0)
This means set the anchor of LabelB. We are anchoring the TOP of label B to the BOTTOM of Label A, with zero offsets.

Now when you change the size or position of LabelA, you'll see LabelB adjusts as well.

Last edited by Stormknight : 04/14/14 at 03:23 AM.
  Reply With Quote