So I've been writing my own UI framework, as one does in this community, and I wanted to talk about a realization that I came across. But first, I want to address an elephant that unfortunately snuck into the room: RmGui vs ImGui. While the thing I want to talk about might seem like it can be framed as a RmGui vs ImGui, I found the discussion around RmGui vs ImGui to be less beneficial to the point I want to make. Instead I want to frame the issue at hand as a question about whether a "parameter" is either shared, private or static. With this caveat out of the way, let us begin with a simple example.
Arguably UI frameworks are all about composing quads, one on top of another, some of which has text in them. So let us pretend for simplicity sake that our entire app are about different ways to draw and manipulate quads. Imagine an app the has several quads drawn on the screen, each with different sizes and colors. The user can then move individual quads around, resize them, and maybe even change each quad's color. This design almost begs that each quad would be represented by a different instance of an "object", each with position, dimensions, and color.
But what if with instead of being able to change each quad's color, there is only one color, and the user can "press a button" and all quads change their color to red, blue or green? What if they are all the same size and a different button makes them stack horizontally, vertically, or in a grid? This would call for a different design, right? One that has a global layout and color parameters, instead of one per quad.
A third scenario would call for a mixture of the two. If, for example, we would still want the user to be able to drag and resize each quad separately, but also want to change all quads color in a single "press of a button", then each quad would be naturally represented by position and dimensions, but the color would be set globally.
For completion sake I would also note, that some parameters are static, say some quads have rounded corners, but their radius is fixed at compile time. In this case it matters very little, to this discussion, whether we store the radius for each quad, have a global shared parameter, or just keep it as part of the code with no dedicated variable in memory.
When writing a generic UI framework I accidently locked myself into a specific tradeoff, one that is useful in certain cases, but detrimental in others. I find it difficult to find a compromise that would satisfy my needs.