Game Development Community

Strange GUI positioning. [Solved]

by Cosmic Logic · in Torque X 2D · 11/16/2009 (12:15 am) · 2 replies

Hey,

I've been trying to work in the GUIBitmapButton resource and I'm having some funny positioning troubles.
I've got it in with XML, as the rest of my GUI is, and I'm pretty sure I'm doing the positioning right in the XML:

<GUIBitmapButton name="button1">
          <Style nameRef="MyBitmapButtonStyle"/>
          <ButtonText>whee</ButtonText>
          <Active>true</Active>
          <FocusOnWake>false</FocusOnWake>
          <Position>
            <X>370</X>
            <Y>475</Y>
          </Position>
          <Size>
            <X>170</X>
            <Y>60</Y>
          </Size>
          <HorizSizing>Left</HorizSizing>
          <VertSizing>Top</VertSizing>
        </GUIBitmapButton>

This should be fine, but when I run the game the button doesn't render. I've used breakpoints to check if it exists, and it does. I can also assign a selected delegate that works as well if I set the inital focus to it. I put a breakpoint on _RenderChildControls(offset, updateRect); of it's parent control and it sees it in it's list of children, however when it checks to see if it's within it's clipping range it fails.
After looking in to the local variables and find the position of the control it's a little crazy.
The X,Y is 1480,920 despite the XML trying to make it 370,475.

I have even made a point of changing the position in code to 200,200 before and after setting the ContentControl.

I'm not really sure how to look in to the deserialization to find the exact point when XML becomes code to see if there is a wierd translation error or not. I can't see that being the case though, because I am manually changing the position after it has been created so there must be some reason why it's switching to that specific position.

Does anyone know why this might be happening?

#1
11/17/2009 (3:59 pm)
What is the button's parent? Remember, when working with the GUI, you want to make a blank GUISceneview as your root scene node. Then you want to add everything as child controls to the GUISceneview by setting their "Folder" property to your GUISceneview. Finally, set the GUISceneview as the GUICanvas' content control.
#2
11/17/2009 (5:09 pm)
Strange, looks like the:
<HorizSizing>Left</HorizSizing>  
           <VertSizing>Top</VertSizing>

Was the problem.