RootElement
The top-most widget of the scene graph.
The guikit::RootElement is the root of the widget tree. Every Window creates one automatically and exposes it via Window::rootElement. It fills the entire window, draws the background color, and lays out all of its children.
This doc assumes using namespace guikit is set and #include <guikit/root.hpp> is included.
Otherwise, use guikit::RootElement instead of RootElement.
It inherits from Element, so everything in the Element reference is available.
Fields
background
The background color of the root.
Color background;Constructor
RootElement(Renderer *renderer, float width, float height)
Creates a root element with a fixed width and height. In normal usage you never construct this directly - the Window does it for you.
RootElement(Renderer *renderer, float width, float height);Destructor
~RootElement()
Destroys the root element.
~RootElement();Overrides
render()
Fills the window with background, then renders all children. Called every frame by the Window render loop.
void render();Example
#include <guikit/window.hpp>
#include <guikit/box.hpp>
#include <guikit/colors.hpp>
using namespace guikit;
int main() {
Window window("Root Demo", 800, 600);
window.rootElement->addChild<Box>()
.setBackgroundColor(Colors::Teal500())
.setWidth(300)
.setHeight(150);
window.show();
return 0;
}