Menu

Zekit widget base classes: ownership, geometry, and repaint rules in C++
πŸ“°

Zekit widget base classes: ownership, geometry, and repaint rules in C++

DEV Community: cppΒ·ζ³½Β·about 4 hours ago
#lobPDp3b
#devtocpp#devto#dev#widget#enter
Reading 0:00
15s threshold

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.…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.