Basics of Custom Component with editable layout at runtime

Hi,

I´m new to JUCE so I expect this question won't be too basic to be asked here, as I can find any examples of this or specific information I think I´m  missing  a basic concept of how the code should work here.

I'm working in my first app with JUCE. It's a one year development project and I want to settle good basics. I want to create a custom component (let's say a grid of TextButtons) which changes layout dynamically when the user adds or removes buttons from it. I don't have problems starting the application with different initial setups but I can't make it work to let the user modify it at runtime.

How I´m thinking:

1 - Start the app and create a initial grid adding and making visible buttons
2 - When the user changes the layout remove all children from the grid component that holds the buttons.
3 - Create again the buttons with the new ones and add and make them visible.
3 - Repaint?

But nothing changes on the GUI. Also there's the tabs component in JUCE that does this so I think it can be possible as it has addTab and RemoveTab and works adding and removing children.

Also I read about valueTrees and that their changes can be linked to a Component. But I don't know if as I read in other parts of the forum that this is a better way only if you have a really complicated layout to handle.

Thanks in advance. I'm loving JUCE and I´m learning a lot of C++ working with it.

You are probably over thinking this. Removing every single component from the original parent and recreating them all again from scratch seems like overkill. Why not just call Component::removeChildComponents() to remove the ones you don't want any more?  

Hi Rory,

Thanks fro taking a look at this. You´re probably right :) I´m looking at too many new things at the same time. I´ll follow that path.