Immediate-Mode-UI / Nuklear

A single-header ANSI C immediate mode cross-platform GUI library
https://immediate-mode-ui.github.io/Nuklear/doc/index.html
8.89k stars 533 forks source link

Add Text Alignment Options to Checkboxes and Radios #592

Closed yukyduky closed 6 months ago

yukyduky commented 7 months ago

This PR adds alignment to check boxes and radio buttons. Originally I was annoyed at not being able to set what side the text appears on and how much space there was between the widget and the text without making a separate label widget and set out to add alignment to all widgets. I then quickly realized that most widgets take up all of their allocated space so it doesn't apply to them in the same way. If there is any widget that could use this that I have missed, please let me know :)

Anyway, here is how it looks:

image

yukyduky commented 7 months ago

Should be good to go :)

image

riri commented 7 months ago

Instead of doing an API breaking change, I would implement functions with extra parameters, and make the original ones using the new functions with the default alignment (left) as argument. This avoiding a major version change and keeping existing code base working.

yukyduky commented 7 months ago

Alright, I was a bit skeptical if it would be accepted as is^^ I can fix that tomorrow :)

yukyduky commented 7 months ago

I was also going to ask if I should've consolidated the alignment enums into one for both text and widgets but I'll take that as a no since that would also become a breaking change?

yukyduky commented 7 months ago

Fixed the API break.

RobLoach commented 7 months ago

Oh, this is a great addition. Haven't tested yet, or read through the code, but it's looking great. Anything else you'd like to get in for it?

yukyduky commented 7 months ago

Oh, this is a great addition. Haven't tested yet, or read through the code, but it's looking great. Anything else you'd like to get in for it?

Anything else? Do mean like apply alignment to other widgets as well?

RobLoach commented 7 months ago

Anything else you'd like to add to this Pull Request. Seems feature-complete, and other widgets could be in follow ups. Your call.

yukyduky commented 7 months ago

I think this will do for this PR. I would add more widgets, but I am unsure how they should act when aligned because all widgets I can think of take up all of the allocated space. If I come up with a way to do it then I will submit another PR :)

riri commented 7 months ago

Fixed the API break.

I recheck asap.

@RobLoach I second voice to keep it only with actual features in this PR, to enable a faster review and merge, unless you see that enabling to other widgets in the future would break the new API for alignment?

yukyduky commented 7 months ago

Fixed the issue and also set my IDE to use spaces for tabs from now on :)

yukyduky commented 7 months ago

Whoops! Fixed.