Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

FrostKiwi
Copy link
Contributor

@FrostKiwi FrostKiwi commented Apr 20, 2022

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

#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

@RobLoach
Copy link
Contributor

RobLoach commented Apr 20, 2022

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 RobLoach added the 5.x This would be made for Nuklear 5.x label Apr 20, 2022
@crazyBaboon
Copy link
Contributor

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

@FrostKiwi
Copy link
Contributor Author

FrostKiwi commented Apr 21, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
5.x This would be made for Nuklear 5.x
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants