Game Development Community

Custom Controls not showing up in GUI Editor

by Shawn Kennedy · in Torque 3D Professional · 11/24/2010 (12:30 pm) · 10 replies

Hello,

I just started poking around Torque 3D about a week ago. I've been tasked with implementing a GUI that includes animated buttons / images. After messing around with the GUI Editor a bit, I figured I could just derive a GuiAnimatedControl from GuiControl, and put all my animation support in there, and then derive animated Bitmap Buttons, etc from the GuiAnimatedControl and the respective control that I want to animate.

However, after adding my GuiAnimatedControl .h and .cpp to the engine/source/gui/core folder, and adding it to my project, it still isn't showing up in the GUI Editor. I'm sure there is just some simple step I'm missing.

So, could anyone explain to me (or point me in the direction of an explanation of) how to get custom controls to show up in the GUI Editor.

On a side note, if there is an easier way to set up animating buttons, I'm all ears.

#1
11/24/2010 (1:11 pm)
When you go to file -> new gui,then click on "gui class" and your new class should pop up along the rest stuff.
At least it works for me.

If you are dealing with animation,just derive from GuiBitmapCtrl.
#2
11/24/2010 (1:15 pm)
Yeah, see, that's where my problem lies. My GuiAnimatedControl isn't showing up in the File->New Gui->Gui Class list or the Control Palette.

What did you do to make it show up in there? Did you just derive from GuiControl (or one of it's derivations), and add it to your project? Or is there a step I'm missing?
#3
11/24/2010 (1:23 pm)
Actualy I am doing just nothing.
There are directives in each gui class : DECLARE_CONOBJECT, IMPLEMENT_CONOBJECT,DECLARE_CATEGORY and so on..
May be you have missed them.
I am using T3D 1.0 as well.
#4
11/24/2010 (2:22 pm)
Well, I think that was a step in the right direction. I made the following directives:

DECLARE_CONOBJECT,
DECLARE_DESCRIPTION,
DECLARE_CATEGORY, and
IMPLEMENT_CONOBJECT

And had to do the "typdef GuiControl Parent;" in the header as well.

GuiAnimatedCtrl is still a no show in the editor though. Like I said, I'm sure I'm missing some simple step, as if evidenced above by not doing the directives, but I haven't been able to find any documentation / tutorials on how to make Custom Controls show up in the editor.

Thank you for your help thus far Ivan.

Could there be anything else I'm missing?
#5
11/24/2010 (2:51 pm)
Shawn,try to add your gui on the fly.
art -> gui -> playGui.gui

new GuiAnimatedControl() {
   profile = "GuiDefaultProfile";

   // the rest stuff
   // ....

   };

May be T3D is searching to assign a profile.
#6
11/24/2010 (3:14 pm)
Well Ivan, I added the "new" to playGui.gui and sure enough the constructor for my control is being hit.

However, if I go to edit playGui.gui using the GUI Editor (which still doesn't show GuiAnimatedCtrl in the Control Palette), in the Inspector (tree view), all controls show up EXCEPT my custom control.

I'm still missing something that is causing the Editor to not recognize my custom control.
#7
11/24/2010 (3:50 pm)
I did a fast test, just duplicated the GuiBitmapCtrl to GuiBitmapCtrl2 and both classes (GuiBitmapCtrl and GuiBitmapCtrl2) appeared in the gui list. (T3D 1.1 beta 3)
#8
11/24/2010 (4:07 pm)
While I'm sure that I could duplicate control classes and add functionality to each to support animations, that's not really the route that I want to take.

I'm trying to derive from GuiControl, add animation support to this derived class, and then proceed to create GuiAnimatedButtonCtrl, GuiAnimatedBitmapCtrl, etc, by deriving from GuiAnimatedCtrl, AND the respective control that I want to add animation to.

If I were to just duplicate GuiButtonCtrl, and add animation support to it, then I would then have to duplicate all other controls I wanted and add that support over and over again. If I wanted to change my animation functionality, I would then have to change it in every one of my duplicated classes (instead of simply changing it in GuiAnimatedCtrl)... messy.

In order to do this correctly, I need to know what has to be in place in the source code to enable a custom control to show up in the GUI Editor.

Are there certain functions that have to be declared? written?

There is obviously something other than the directives that I need...
#9
11/24/2010 (4:14 pm)
Shawn,
there is no documentation about your question.
I did an example with GuiBitmapCtrl,because it derives from GuiControl.
You definitely skip something.
Try to step through the GuiBitmapCtrl class and see what you are missing.
At least this will save you a lot of time.
#10
11/24/2010 (5:16 pm)
Shawn, I think I know what you are wanting to do. I had done this for my splash item controls. What you have to do is create a base control that is derived from guiControl. Then your animated controls are derived from your base control. The editor only shows controls that are derived from guicontrol so it has to be in your inheritance stack. If you want an example take a look at my guisplashmanager control.