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

Add Text Alignment Options to Checkboxes and Radios #592

Merged
merged 17 commits into from
Jan 8, 2024

Conversation

yukyduky
Copy link
Contributor

@yukyduky yukyduky commented Nov 26, 2023

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 yukyduky marked this pull request as ready for review November 26, 2023 13:30
@yukyduky
Copy link
Contributor Author

yukyduky commented Nov 26, 2023

Should be good to go :)

image

@riri
Copy link
Contributor

riri commented Nov 27, 2023

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
Copy link
Contributor Author

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

@yukyduky
Copy link
Contributor Author

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
Copy link
Contributor Author

Fixed the API break.

@RobLoach
Copy link
Contributor

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
Copy link
Contributor Author

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
Copy link
Contributor

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
Copy link
Contributor Author

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
Copy link
Contributor

riri commented Dec 11, 2023

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?

Copy link
Contributor

@riri riri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look good to me with a minor chore style fix :)

@@ -47,7 +47,11 @@ nk_draw_checkbox(struct nk_command_buffer *out,
text.text = style->text_normal;
}

text.text = nk_rgb_factor(text.text, style->color_factor);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

more strict with Nuklear source code: keep the indenting style (4 spaces instead of a tab), to repeat on all files in src

@yukyduky
Copy link
Contributor Author

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

nuklear.h Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You didn't rebuild nuklear.h from sources

@yukyduky
Copy link
Contributor Author

Whoops! Fixed.

Copy link
Contributor

@riri riri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems good for merging. Needing another reviewer before merging.

Thanks for that contribution :)

@RobLoach RobLoach changed the title Align toggleables Add Text Alignment Options to Checkboxes and Radios Jan 8, 2024
@RobLoach RobLoach merged commit 4344d5e into Immediate-Mode-UI:master Jan 8, 2024
1 check passed
@yukyduky yukyduky deleted the offical/align_widgets branch January 9, 2024 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants