For my ingame user interface I have implemented a textured object, that acts like button, has onMouseOver(), onClicked() , events etc.
Right now for every single object of that type, I have a property for the page it belongs. I.e. the Main menu widgets have page property set to 0, the Options widgets have their page propery set to 1 etc. Then, when the user press for example hit "escape" I set the page number to 0 and draw the widgets that have page property set to 0, when the user click on Options I set the page index to 1 and draw widgets that have page 1 etc..
This works but I have a feeling that it isn't flexible and could cause a lot of interating over the widgets list to draw only the elements that match the current page.
I think there might be better practices to implement GUI systems. For example, make separate list of widgets fort every page. Something like
std::vector<Widget*> mainPage ;
std::vector<Widget*> options ;
and then interate the appropriate list and draw elements.
Is there other better approaches ? How do you guys will implement such a GUI system ?
: Fixed tags.