Add GUI editor component in existing project

Bit of a noob question here - I've started work on an app with a MainComponent and custom component that is the main focus of the app. 

I'd like to start using the GUI editor to start adding GUI components alongside the custom component I've been developing,  mainly to allow the user to edit input data. Is it a good a idea to add a new component via the GUI editor in Introjucer so I can visually arrange everything,  kind of like a parent component? Any tips on organising things this way? 

I've been following the Getting Started with JUCE book but need a bit of help with this aspect.

Thanks!

Hi adamski,

basically the GUI editor is a handy way of generating your code from a visualisation of your interface. It is quite flexible in adding custom components, as long as they are derived from the Juce Component class (and even if the're not, but why would you want to?).  So you can use the GUI editor to layout your screen including your custom component, and test it in the editor (which renders the custom component as a box)

Couple of things to watch out for:

  • Add all your own code in the spaces provided in the generated code, or you will lose it when you regenerate
  • For a custom component, make sure you include the header in the includes section, and fill in the constructor parameters if needed.
  • Don't forget to choose relative sizing mode for your GUI elements if you want them to resize with the main window.

As far as organisation is concerned, the editor will produce a parent component with child components which are your controls. If you want your custom component to be the parent you need to follow a slightly different route. Generate your custom component from the editor with all the controls that you need, the add to the code the bits that make it custom. Essentially the GUI editor creates a new component that inherits from Component, plugs in the code to display and navigate child components, and after that you can do what you like to the code.

That did not answer the question.

The GUI editor is no longer maintained according to the juce team.

That answer suggested to add your components using code in the reserved code blocks. But I think the question was, how to make your own components accessible in the editor. I tried that and it is not doable, at least not easily and certainly not without patching up the juce code:

The machinery to create the GUI is ComponentBuilder. It is nowhere used except in the GUI editor, so you can safely assume it won’t be developed any further as well.
I had a go back then at writing a ComponentBuilder::TypeHandler, but even then it wouldn’t show up on the Projucer. You would need to add your TypeHandler to the Projucer and extend the menus there, I didn’t look further, how well that was doable, since from here it appeared as a dead end to me.

Hi Adamski, I seem to have misunderstood your question. Following on from the answer that daniel gave, I tend to just add the component in the editor and accept that I just see a blank square. This is fine if you have mainly JUCE components on your screen and just want to make sure that things are well positioned. If you a have a lot of non-JUCE components I find it starts becoming useless and I just rely on the layout functions in the library.

That is a good workflow to set things up. However you cannot change anything without changing the component types later. So every change you make is followed by a manual repair step.

Since the generated code isn’t according to modern best practice anyway (using std::unique_ptr instead of adding the members as components directly, adding superfluous reset() calls in the destructor etc.), I would not recommend using the GUI editor any longer.

BTW, this is in line with advise given from the juce team themselves.

I agree 100%

Wow, that question was from 7 years ago, when I was just starting to learn JUCE…!

I’ve long since abandoned creating GUI’s with the editor :slight_smile:

1 Like

Nelroy, this was a good answer for someone with a few years of programming experience, but not for the fotb newbie. That’s all. Keep posting and feeding the community.