Nuklear icon indicating copy to clipboard operation
Nuklear copied to clipboard

New internal rounding handling, window rounding, nk_vec4, group_rounding style setting

Open FrostKiwi opened this issue 2 years ago • 3 comments

This PR changes how rounding is handled internally to allow per-corner rounding to be specified in the api. As the branch name may imply, this is in preperation for quite a chunky PR introducing a bunch new elements, which depend on this feature. I decided to split it here to keep changes a bit more organized.

nk_fill_rect and nk_stroke_rect may now take rounding per corner to create for instance just rounding at the top, a speech bubble like thingy by making it 0 in one corner or a whacky combination of different sizes. grafik

Now rounding is specified by nk_vec4, which is essentially the same as the 4-float nk_rect, just with a different name. Since nk_rect specifies position and size, this didn't quite make sense for corner sizes, that's why the new vec4 type. The user-facing styling remains a single rounding float, so on that front nothing changes.

This unlocks window and group rounding to properly applied in regards to Titlebar and borders. Group rounding received it's own style property. Though some extra tweaks may be required to address how group borders are not the same thickness by default on all sides. Not every combination of Window features is clean though, the scroll bar may need to be patched to inherit one corner's window rounding, as the scrollbar pokes through in certain feature combinations like: No titlebar + scroll bar + no rounding on scrollbar.

grafik

https://github.com/Immediate-Mode-UI/Nuklear/issues/146 should be properly addressed with this.

Finally, I did try making a rounded scaler corner, but it was really just a dirt hack. This will be an extra PR later on. grafik

FrostKiwi avatar Apr 20 '22 05:04 FrostKiwi

This makes my life a lot easier, thanks for taking it on!

In terms of versioning, what are your thoughts on us opening up a 5.x branch, and pushing a bunch of these API-breaking changes in there until we're good to release version 5.0?

RobLoach avatar Apr 20 '22 16:04 RobLoach

This feat looks good - we need more of these! Thanks!

crazyBaboon avatar Apr 20 '22 18:04 crazyBaboon

If rounding is set too strong by the user, or if the widget is size is smaller than when rounding was configured, it breaks rendering: grafik Now there is the nuklear_internal.h function nk_clamp_rounding(), which ensures this doesn't happen by clamping the rounding of each corner to the maximum permitted by the widget's dimensions. nk_fill_rect and nk_stroke_rect automatically apply this. grafik

FrostKiwi avatar Apr 21 '22 05:04 FrostKiwi