04/29/20, 01:47 PM | #1 |
|
Centering Controls (Lua/XML)
Hello, I've written my first addon and will publish it as soon as I figure out this one issue.
I started out simple, with a TopLevelControl that contained a Label. The desired display would be the text in the label appearing centered on the screen, just above the reticle. This was easy and direct enough in XML (pretty much straight from the "build your first addon" tutorial): Code:
... <TopLevelControl name="SomeTopLevelControl" hidden="true" mouseEnabled="true" movable="true" clampedToScreen="true"> <Dimensions x="300" y="25" /> <Anchor point="BOTTOM" relativeTo="GuiRoot" relativePoint="CENTER" offsetY="-40"/> <Controls> <Label name="FooLabel" font="ZoFontWinH1" inheritAlpha="true" inheritScale="true" pixelRoundingEnabled="true" wrapMode="TRUNCATE" verticalAlignment="CENTER" horizontalAlignment="CENTER" text="Example Text Blah"> <Anchor point="TOP" relativeTo="$(parent)" relativePoint="TOP" /> </Label> </Controls> </TopLevelControl> ... Code:
... <TopLevelControl name="SomeTopLevelControl" hidden="true" mouseEnabled="true" movable="true" clampedToScreen="true"> <Dimensions x="300" y="25" /> <Anchor point="BOTTOM" relativeTo="GuiRoot" relativePoint="CENTER" offsetY="-40"/> <Controls> <Texture hidden="true" name="$(parent)Icon" inheritAlpha="true" inheritScale="true" pixelRoundingEnabled="true" textureFile="/esoui/art/lfg/lfg_icon_healer.dds"> <Dimensions x="40" y="40"/> <Anchor point="RIGHT" relativeTo="FooLabel" relativePoint="LEFT"/> </Texture> <Label name="FooLabel" font="ZoFontWinH1" inheritAlpha="true" inheritScale="true" pixelRoundingEnabled="true" wrapMode="TRUNCATE" verticalAlignment="CENTER" horizontalAlignment="CENTER" text="Example Text Blah"> <Anchor point="LEFT" relativeTo="$(parent)Icon" relativePoint="RIGHT" /> </Label> </Controls> </TopLevelControl> ... I've considered shimming the placement of the controls using Lua logic to calculate the position, but that seems ridiculous and there has to be a simple solution using anchors that I'm just not seeing. I've messed with it for several hours at this point and I thought I'd ask the experts. Thank you for any help in the matter! |
04/29/20, 01:54 PM | #2 |
From the code you posted it looks you are getting the order wrong. You are trying to anchor the texture to the label control, but define the label after the texture. When the game sees the line defining the anchor, FooLabel is nil, so instead it used the parent control SomeTopLevelControl as anchor target.
|
|
04/29/20, 02:12 PM | #3 |
|
Yes. Yes, that worked. Goddammit. Thanks very much for the assist!
Working solution that centers the texture+label correctly: Code:
... <TopLevelControl name="SomeTopLevelControl" hidden="true" mouseEnabled="true" movable="true" clampedToScreen="true"> <Dimensions x="300" y="25" /> <Anchor point="BOTTOM" relativeTo="GuiRoot" relativePoint="CENTER" offsetY="-40"/> <Controls> <Label name="FooLabel" font="ZoFontWinH1" inheritAlpha="true" inheritScale="true" pixelRoundingEnabled="true" wrapMode="TRUNCATE" verticalAlignment="CENTER" horizontalAlignment="CENTER" text="Example Text Blah"> <Anchor point="TOP" relativeTo="$(parent)" relativePoint="TOP" /> </Label> <Texture hidden="true" name="$(parent)Icon" inheritAlpha="true" inheritScale="true" pixelRoundingEnabled="true" textureFile="/esoui/art/lfg/lfg_icon_healer.dds"> <Dimensions x="40" y="40"/> <Anchor point="RIGHT" relativeTo="FooLabel" relativePoint="LEFT"/> </Texture> </Controls> </TopLevelControl> ... |
ESOUI » Developer Discussions » Lua/XML Help » Centering Controls (Lua/XML) |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|