The core of all elements
The GUI_Element
class is the core of every single element and interface. It provides key functionality that higher level objects rely on, as well as enforcing the implementation of necessary methods, which leads to several distinctive element types.
A definition of the different element types is a good place to start:
enum class GUI_ElementType{ Window, Label, Button, Scrollbar, Textfield };
Each element has to hold different styles it can switch to, based on its state. The unordered_map
data structure suits our purposes pretty well:
using ElementStyles = std::unordered_map< GUI_ElementState, GUI_Style>;
A forward declaration of the owner class is also necessary to prevent cross-inclusion:
class GUI_Interface;
Next, we can begin ...
Get SFML Game Development By Example now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.