I have a desktop-like application which has 2 controllers: 'Desktop' which represents desktop icons and 'Taskbar' which represents the taskbar where you find buttons to minimize/restore windows already opened, like MS Windows is working.
The problem I currently have is the approach to "how should I display the window". Infact after doubleclicking the icon, I should create a window, and this could happen both on Desktop controller or on Taskbar controller (or maybe directly on the viewport, because they can be dragged anywhere). However, when I create a window, a new button should be created on the taskbar to minimize/restore it.
Because of this, I thought about handling window in the taskbar controller, however I don't know how to reach the Taskbar controller from the Desktop controller.
I have 3 ideas in my mind at the moment:
- The Desktop controller directly adds the button to the TaskbarView, but in this way I'm feeling like violating MVC pattern. Also I need to specify TaskbarView in Desktop views.
- The Desktop controller after icon doubleclick fires a custom event on the Taskbar controller. In this case the taskbar opens the windows and adds the button, this approach is quite linear but I don't know how to reference a controller from another controller (in this case, from Desktop to Taskbar)
- The Ext.Application register for itemdblclick event on Desktop controller. When this event is fired, it redirects (or call a custom event) on Taskbar controller. After this everything keeps going like point 2. In this way I centralize the Routing functionality (like rails), however could also happen that Application object becomes really big. Also I'm using it as a "gigant controller" to route everything, but this is not really a big problem, thinking about rails it does something similar.
- The application should not be split in 2 controllers (so Desktop and Taskbar should be one) and everything will be fine. I don't think this approach is correct.
So, my questions are:
- Which approach should I use: 1,2,3,4 (or specify if there is something different)?
- What a window should belongs to: Desktop controller, Taskbar controller, something else?
Thanks for any answer