Hi all,
In the last few days I am thinking about the following JUCE-design issue :
Consider we have :
- only one main window and,
- many content components.
The issue is, what is the propper way to switch between content components, or to show some of them consecutively, according to user needs.
So far I have think about the following two designing patterns :
1. I use a singleton class with a data structure within (public around the application), in which I keep the main window pointer and a stack for the sequential appearance of the components. The last stored component is always the current shown one. In the constructor of each component I store it into the stack and in the destructor remove it from stack, so the previous one in the stack, is shown.
2. I have only one MAIN content component. When I need to use any other component, it is added to the MAIN one as a child and, removed from MAIN component, when it became out of use. By this way, there is no need to have a singleton class as in solution 1.
Solution 1 : It is a centralized procedure and every process can be an appropriate function into the singleton class(make the current component the contentOwned one, adjust the size and bounds of mainwindow according to component's size, shows current component, e.t.c.).
Solution 2 : Each component, is responsible to add itself as a child into the MAIN component, allows any user activity only on its elements, and at last restore the MAIN component's initial status when it goes out of scope.
Actually, I have no idea which of these designing patterns is the proper one, or if there is another better approache.
So, any suggestion on this issue is very appreciated.
Thanks in advance
George