I've been working on a hobby project, a UI framework, much like QT, SwiftUI, UIKit, WPF and alike, in my spare time.
I haven't planned to do it professionally and it is not meant to become one, it is just for my personal experimentation.
Currently it is on a very early stage and I'm developing it under Windows, but it is meant to be multiplatform. So the backend
for rendering could be skia, vulkan, directx etc. The language I'm developing it, C++, is not much relevant for my questions.
The responsibility of handling all UI controls or widgets is mine and it abstracts from the host-native Window. Once the hierarchy of UI widgets are built and rendered, what is left, is the interaction with the user.
The problem I'm facing now is how to handle the mouse, keyboard, touch, hover, capture, focus events, how to bubble them up, and how to design
the UI widgets hierarchy to handle all of them in a clean way. The solution I came up with is not clean and that rings a bell in my mind that something
is not right.
Beside the host (or platform dependent) window, at the top I have a Window class that handle all the widgets in a parent-child way relationship
(a three) and then I have widget class for the default cases. Every other UI controls derive from the widget class.
Furthermore, there will be widgets that have visual appearance, as well as widgets that helps laying out other widgets but not necessarily do they have a visual representation. So subdividing classes, in my case in C++, is fundamental to avoid repeating code and to have a clean scalable architecture.
I gave a look at other open source projects but I couldn't find any simplified one. Chromium, for example that is used in web apps, is huge one and it would take a while before I could even find what is responsible for what. Firefox I feel is at the same level.
Are there any documentation or open source projects to have look at?
Thanks
It doesn't really matter, these are just ways to draw into a native window and not the backend that owns that window.
> Once the hierarchy of UI widgets are built and rendered, what is left, is the interaction with the user.
Without interaction they aren't UI widgets, but merely organized graphics. You are only considering the easy, portable part of a GUI.
> I gave a look at other open source projects but I couldn't find any simplified one.
Consider the Windows API functions that deal with the GUI: they are comprehensive (particularly with respect to handling input and events), reasonably low level and more mature than anything you can design.
If you want to do more, layering something portable on top of them and on top of similar libraries for other platforms, the end product will be more complex, not simple (or naively "simplified").
I suggest Dear IMGUI and Qt as good case studies of opposite approaches: forfeiting platform specific and advanced features in order to simplify the user's job, or adding to native libraries whatever it takes to do everything well and in the same way on all platforms without reducing complexity. Test question: what do you want to do for assistive technology?