Gui Button Settings?
by Chase Webb · in Torque 2D Beginner · 10/18/2014 (7:54 am) · 2 replies
Hey all! I'm wondering if these settings are working correctly, and if they are, then how they are supposed to work. Specifically, I'm trying to make a button that resizes to my layout depending on some global variable set after some fancy scene window resizing for different screen sizes. Why I'm doing it's not important though, it's the end results of messing with these settings when making a button:
First, HorizSizing and VertSizing do the opposite of what I would expect them to do, and each time I change them they change the position AND the extent of the button. For example, if I set HorizSizing to Right and VertSizing to relative then it aligns to the left side of the screen and the extent width is correct, but the extent height is way off. If I set VertSizing to Bottom then it moves it to the top of the screen and then shrinks the size of the button to something really small. Centering either shrinks the button. Setting both to relative extend the button to the width of the entire screen. The autoSize settings don't appear to change anything at all.
What I want is a button that I can put the variables in for extent and position and have it show up exactly where I want it (for example $buttonsizeWidth might be 93 and $buttonsizeHeight might be 71, while position would be a 2 SPC 1). The variables are being set dynamically and are definitely being set correctly, but when they get used in the button's settings it's like they are not.
...So confused. Hopefully someone can help?
HorizSizing="relative";
VertSizing="relative";
Extent=$buttonsizeWidth SPC $buttonsizeHeight;
minExtent=$buttonsizeWidth SPC $buttonsizeHeight;
autoSizeWidth = true;
autoSizeHeight = true;
Position=%Position;First, HorizSizing and VertSizing do the opposite of what I would expect them to do, and each time I change them they change the position AND the extent of the button. For example, if I set HorizSizing to Right and VertSizing to relative then it aligns to the left side of the screen and the extent width is correct, but the extent height is way off. If I set VertSizing to Bottom then it moves it to the top of the screen and then shrinks the size of the button to something really small. Centering either shrinks the button. Setting both to relative extend the button to the width of the entire screen. The autoSize settings don't appear to change anything at all.
What I want is a button that I can put the variables in for extent and position and have it show up exactly where I want it (for example $buttonsizeWidth might be 93 and $buttonsizeHeight might be 71, while position would be a 2 SPC 1). The variables are being set dynamically and are definitely being set correctly, but when they get used in the button's settings it's like they are not.
...So confused. Hopefully someone can help?
#2
Something to keep an eye out for....
10/18/2014 (4:50 pm)
Hey Chase, I've noticed (unless it's been fixed) that it's generally more reliable if you set extent and position after creation:%button = new GuiSpriteButton()
{
HorizSizing="relative";
VertSizing="relative";
autoSizeWidth = true;
autoSizeHeight = true;
};
%button.Extent=$buttonsizeWidth SPC $buttonsizeHeight;
%button.Position=%Position;This may no longer be the case, but during 3SS development there were cases where setting these parameters during construction simply didn't work right.Something to keep an eye out for....
Associate Chris Haigler
Jester Dance
'width/height' resizing will change the extent of the control so that it matches its parent container.
'left/right' are actually reversed but will reposition a control so that it always maintains a certain distance from the left or right edge of its parent container. Setting horizSizing to 'right' with an xpos of 100, for example, will keep the control at 100 from the LEFT edge of the parent container.
'top/bottom' does the same as 'left/right', except it keeps the control a certain distance from the top or bottom edge.
What's the purpose of the $buttonsize vars? If you're calculating a width/height/pos yourself, you're probably going to want to set the sizing options to right/bottom and then call resize() on each control so that it resizes correctly.