Game Development Community

Window resizing/positioning

by Nathan Bowhay - ESAL · in Torque 3D Professional · 03/09/2010 (9:55 am) · 3 replies

I was wondering what windowRelative does exactly. I am looking for something to reposition a window only if the parent control hides it and was wondering first if there is something in torque that already does this?

If not then is there a way to add to an enum table after the fact (thinking not since I think they are const, so I would have to add it to the enum table in GuiControl)?

If there isn't a way to do that I was thinking about just using windowRelative in my own window class and having it do what I described, but I wanted to check it's current intended functionality to see if I would want that it or not.

#1
03/09/2010 (8:19 pm)
Re windowRelative:

This is currently for exclusive use by GuiWindowCtrl to enable automatic window repositioning for collapsible windows and repositioning by parent edge affinity (i.e. window maintains distance to closest parent corner... which is magically broken again in b1 after I fixed it recently).

I'm not quite sure from your description how you exactly want the repositioning to work but it sounds like windowRelative might not be quite your thing.

In all honesty, the entire GuiWindowCtrl related code to me seems only good for being largely shredded to pieces and rewritten. I'm not fond of any of the collapsing code and in general windows just don't behave well.

Re enum tables:

No, not really. These are usually defined as statics in C++ code. You *could* hack around this in C++ and create your own dynamically synthesized tables and patch up things but this wouldn't be quite the elegant thing.
#2
03/09/2010 (9:24 pm)
Ok cool. No it isn't really want. I just have a custom window class that inherits from the torque ones and added a bunch of functionality to it. So if there wasn't already something that did what I want I was going to over-ride onParentResize and then use that enum value to handle repositioning, but was wondering how to handle the Parent::onParentResize call. Probably best to just make a bool in my class and call the parent function.

In case anyone is wondering maybe I can explain with some ascii art:
|                   |
|                  <->
|        ------     |
|        | w  |     |
|        |    |     |
|        ------     |
---------------------

|               |
|              <->
|        ------ |
|        | w  | |
|        |    | |
|        ------ |
-----------------

|           |
|          <->
|    ------ |
|    | w  | |
|    |    | |
|    ------ |
-------------

So it doesn't move the window until (w) until the outer parent control will cover it up. Of course in the image I am only handling the x direction or horizontal resizing, but I would handle both.
#3
03/09/2010 (9:30 pm)

Actually, this behavior is what you *should* get too with windowRelative. However, I tested it and it only works 50%. I really need to give GuiWindowCtrl::parentResized another pass. Have it on my list for b2.