C++ widget tree
Hello, great people.
I have been writing a ImGui OOP wrapper in C++ for about 6 weeks (exercise). So far OpenGL, would like to add Vulkan + WebGPU support.
What is the best way to structure widgets, layout, e.t.c.
My original idea is roughly this:
app contains list of unique_ptr<Window> (Each Window can be GlWindow, VulkanWindow, e.t.c.)
Window contains unique_ptr<Widget>.
Root widget calls childrens, and so on.
Each widget contains Yoga node, and layout can be computed topdown from root.
What I do like about this:
Its simple, extendable
For price of two virtual calls + overhead of layout computation, you
get everything that you could get from raw ImGui, just less boilerplate - if you want maximal performance, you can only use root widget polymorphically - the rest wont contain virtual calls, and will be inlined most likely
What I do not like:
I do not know about the price of virtual calls, and point of this whole exercise was supposed to be performance
I do not want this to be QT with GPU and ImGui
So the final queston is:
What are your advices on architecture here ?
Posted Aug 10, 2026, 4:22 PM UTC