Game Development Community

GuiRolloutCtrl question.

by Trediak · in Torque 2D Beginner · 06/21/2014 (10:38 pm) · 3 replies

Greetings all. New to the forums and Torque2d in general. I'm starting the learning process by learning the various GUI components and hopefully putting together some editors and documenting everything I can.

I have been trying to work with the GuiRolloutCtrl and I can't tell if I'm just stupid or if there is actually an issue with the control. I've spent the better part of 6-8 hours of the past two days experimenting with different taml options, reading what documentation there is, and even looking through and experimenting on the source code (including a comparison with Torque3D's version). When I use the control with no child control the expand and collapse work as would be expected (meaning, it expands to the correct height and collapses correctly). My problem occurs when I add a child control either by itself or wrapping it in a GuiControl. The initial display of the control is fine, but every time you expand and collapse the control via the header it expands a little bit less... until you get to the point where there is just the header, 1 pixel or so of the content, and the bottom border. The loss seems pretty constant, it is as if it is losing part of the content height when it calculates for the expansion animation.

While my trek into the source has brought me valuable information about how the control works and how it is rendered, my c++ and graphic programming skills are not at a point where I understand everything. Just wondering if anyone else has ever noticed this issue and possibly found a fix for it? I read a couple posts from 3 or 4 years ago that mentioned something very similar but the response was to work around it by creating the same functionality via other controls. I can do that, but I would really either like to learn what my mistake is (if that is the case) or find a fix for the control.

Thanks in advance for any help.

About the author

Recent Threads


#1
06/22/2014 (2:02 am)
Welcome to the forums Trediak!

After a grueling week creating the Particle Editor I also noticed funky behaviors with the GuirolloutCtrl.

I have not fully fixed them to my liking but the following tips might help!

GuiRolloutCtrl has a script callback you can use when it is either expanded or collapsed.

The following is from the Particle Editor scripts (which use nothing but procedurally generated rollouts containing other rollouts) : I populate the GuiRolloutcontrol and then manually collapse it. When the user expands it, I force the Guirollout controls to resize themselves to accommodate their children.

function GuiRolloutCtrl::onExpanded(%this)
{
%newgui = %this;
%parent = %this.getParent();

while(%parent != PFX_Preview.getId())
{
   %newgui = %parent;
   %parent = %newgui.getParent();
   %class = %parent.getClassName();
   if(%class $= "GuiRolloutCtrl")
   {
      %parent.sizeToContents();
   }
}
}

sizeToContents resizes the rollout to properly show its children. If I don't call that, I also get just a tiny sliver of the child controls.

Another useful trick to make GUI behave like you'd expect is to group your GuiControls in Stacks instead of placing them all "loosely" in the same parent GuiControl using Position.

Hope this helps somewhat!

Note : The Particle FX editor requires the latest development branch of T2D to run properly. You can also get a package ready to go from here
#2
06/22/2014 (11:37 pm)
Thanks for the tip Simon. Looks like I should have tested better because the issue ended up not being the GuiRolloutCtrl. I had the GuiRolloutCtrl wrapped inside of a GuiStackControl and I believe that was causing the problem. The minute I pulled it out on its own, it performed fine. Lesson learned.

On a side note, I had already taken a look at your Particle FX editor. Lots of good stuff in there for folks to learn from. Appreciate you putting it out there for everyone to peruse.
#3
06/23/2014 (12:59 am)
Glad to be of service!

The Particle Editor is there for people to learn, but I've also not finished it; I've made it as functional as possible, as quickly as possible. Everyone is encouraged to submit updates, fixes and tweaks to it, as well as particle effects you want to share as well!