The architecture for the GUI framework will resemble a lot of other toolkits such as Java's Swing/AWT library as it's a well working concept. Note that it is not exactly reproduced, rather is used as a source of inspiration. In the end, what we aim to achieve is a working menu state based on this design, but without pumping the state full of boilerplate GUI code.
We create a namespace
GUI in order to make the distinction clear to other parts of our game, since a lot of the names such as "component" are generic, and can be misinterpreted easily. We start with one core base class, which the entire hierarchy rests on. We call it
Component and in our case it is quite small. It defines the interface that we will be using regularly besides setting up the objects. The class defines a couple of virtual functions, one of which is the
handleEvent() function. We let the
Component class inherit from
sf::Drawable for the same reason as the scene nodes. To have an interface...