The interface class
An interface, in its simplest meaning, is a container of elements. It's a window that can be moved around and scrolled and has all of the same features and event hooks as a regular element. Efficiency is also a great concern, as dealing with lots of elements in a single window is a definite possibility. Those problems can be dealt with by carefully designing a way of drawing elements at the appropriate time.
The way we want our interfaces to draw content is by using three separate textures for different purposes, as shown below:
The background layer is used for drawing backdrop elements
The content layer is where all of the elements of the interface are drawn
The controls layer hosts elements such as scrollbars that manipulate the content layer and don't need to be scrolled
With the design details out of the way, element storage deserves some attention. As it happens, the std::unordered_map
structure serves this purpose well:
using Elements = std::unordered_map<std::string...