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 shaping the GUI_Element
class:
class GUI_Element{ friend class GUI_Interface; public: GUI_Element(const std::string& l_name, const GUI_ElementType& l_type, GUI_Interface* l_owner); virtual ~GUI_Element(); // Event...