Open falbrechtskirchinger opened 1 year ago
Would be cool to have something like that. That would ease up a lot.
I also like that especially with the similar structure to other GUI frameworks.
What bothers me a bit is the duplication (of the IDs) but I guess splitting the layout from the control-adding also has its benefits.
I'm not sure about the num_items
param though: What do we gain by that? I think being able to just add items as you go is a feature. Especially for changes: Adding a new item would then be a single line change instead of 2.
Working on the Addon Settings window, I'm really fed up with the task of manually laying out controls. Is there interest in a set of helper classes to simplify building GUI layouts?
I envision a two-step process, first, defining the layout using a builder pattern API, that computes a bunch of rectangles, then adding the controls using those rectangles in order. The builder API would require some redundancy, to spot certain errors early in the build phase and not later in the use phase, where they may be more difficult to locate. Every node in the layout would be named, auto-generated from the associated control ID using a macro, if applicable. Again, this is to provide meaningful error messages.
Here's what I've come up with so far (this is based on
iwAddons.cpp
and uses the IDs defined there):I'm using strong typing for things like widths, heights, etc. to provide more concise overloads. Would probably rely on some TMP to not repeat myself.
No strings would be stored in Release builds and error checking would only be active in Debug builds.
This is just a start. I've put more thought into some aspects and implementation details. Just let me know if I should pursue this or spend my time elsewhere. (I really want this – or something like it – for more UI work I'd like to do.)