Zekit is a C++20 desktop GUI toolkit that compiles to a single static library. This post covers the layer under every widget: the base classes, and the one rule that explains most of their API.
The library has four base classes. They stack:
Base class Responsibility
Widget geometry, hit testing, focus, value semantics
BoxWidget box appearance: body, border, radius, shadow
TextWidget single-line text layout and four text states
Panel everything above, plus layout β the one to inherit for custom containers
Widget doesn't know what a widget looks like. BoxWidget doesn't handle text. TextWidget doesn't lay out children. Pick the shallowest base that does what you need.
The rule behind most of this: widgets are values
Kit :: Label tip ( "Hello" ) ; win . AddWidget ( tip ) ;
Enter fullscreen mode
Exit fullscreen mode
AddWidget takes a widget by value . It moves the value into the window's tree and takes ownership.β¦