Original Post
Hey there.
I'm coding a GUI using C++ and openGL, but my problem is more design specific than API related.
Right now I'm using classes that derive from a base GUI class, and some of them use a composite pattern, such as Windows for example, I can add buttons, scrollbars, etc to it. The GUI is functional as it is, but sometimes, from a more user point of view it might not work very well, for an example I would like to have my buttons shine everytime my mouse cursor is over them.
Since I have a composite pattern I start from one element from my GUI and after it draws itself it calls the drawing function of the elements attached to it, all this starts in a GUIManager class. To make things like the button shine I would need to pass to the draw functions the required data for the elements to know which element the mouse is over and make a different draw, but i really wouldn't like to give this kind of task to my GUI elements.
Another way I had in mind would be my elements having a function that returns a list of their children elements, and the drawing functions would be called from my GUIManager class in which it would know what element a "special effect" should be applied, this seems more reasonable to me, the only requirement would be that the elements had to have an extra function where they would return their children.
Are there better options to do this?
I'm coding a GUI using C++ and openGL, but my problem is more design specific than API related.
Right now I'm using classes that derive from a base GUI class, and some of them use a composite pattern, such as Windows for example, I can add buttons, scrollbars, etc to it. The GUI is functional as it is, but sometimes, from a more user point of view it might not work very well, for an example I would like to have my buttons shine everytime my mouse cursor is over them.
Since I have a composite pattern I start from one element from my GUI and after it draws itself it calls the drawing function of the elements attached to it, all this starts in a GUIManager class. To make things like the button shine I would need to pass to the draw functions the required data for the elements to know which element the mouse is over and make a different draw, but i really wouldn't like to give this kind of task to my GUI elements.
Another way I had in mind would be my elements having a function that returns a list of their children elements, and the drawing functions would be called from my GUIManager class in which it would know what element a "special effect" should be applied, this seems more reasonable to me, the only requirement would be that the elements had to have an extra function where they would return their children.
Are there better options to do this?