Skip to content

raylib: (big) Replace gui_label and gui_text_box with Label and Text widgets; Add SelectionButton widget #35703

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

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

Conversation

TheSecurityDev
Copy link
Contributor

@TheSecurityDev TheSecurityDev commented Jul 12, 2025

Update:

I'm going to implement this in smaller PRs before completely removing the old functions so I don't have to modify everything at once.

Apologies for the large diff, but I couldn't really remove the old code without implementing the new widgets everywhere.

Summary of changes:

  • Rename widgets/label.py to widgets/text.py
  • Replace gui_label function with a Label widget class.
  • Replace gui_text_box function with a Text widget class. This class is used for rendering longer text that needs to break into multiple lines.
  • Replace all uses of gui_label with the Label class.
  • Replace all uses of gui_text_box with the Text widget class.
  • Add a new SelectionButton widget to widgets/button.py, and use it in setup.py to replace the manual drawing of the software buttons. The reason it's in this PR is because I had to replace the gui_label functions with something for those buttons, and they also definitely needed refactoring to avoid duplicating code.
  • Other minor refactoring, todo comments, constants added, etc.

I've tested most of the modified sections to the best of my ability while making the changes.

P.S. The only AI used was for generating initial templates and autocompletion.

Other notes:

I've noticed it's quite difficult to work with the widgets due to having to deal with the rects being passed in everywhere. I feel like we need a system that uses padding/margin, etc to calculate positions based on parent rects. Each widget should ideally handle calculating their own positions based on given X, Y, height, width, scale, etc. that's all relative to the parent.

Also, for the text rendering, a lot of times we always use the font size or text area height for the rect height, so this feels like it should be calculated in the widget instead of passing in the whole rect to the render function.

@github-actions github-actions bot added the ui label Jul 12, 2025
@TheSecurityDev TheSecurityDev marked this pull request as draft July 12, 2025 19:28
@TheSecurityDev
Copy link
Contributor Author

If this is too much I suppose I could just add the widgets in a separate PR and switch over a bit more gradually.

@TheSecurityDev TheSecurityDev marked this pull request as ready for review July 12, 2025 19:44
@adeebshihadeh
Copy link
Contributor

If this is too much I suppose I could just add the widgets in a separate PR and switch over a bit more gradually.

Yeah, it's generally better to split up PRs if you can. It's rarely better to have one this big. Keep them clean and simple!

@TheSecurityDev
Copy link
Contributor Author

TheSecurityDev commented Jul 12, 2025

If this is too much I suppose I could just add the widgets in a separate PR and switch over a bit more gradually.

Yeah, it's generally better to split up PRs if you can. It's rarely better to have one this big. Keep them clean and simple!

Alright, I can do that. But I will be gone until Monday so I will just leave this open in case Shane wants to merge it after all, since it's fully functional. I'll try to open at least one small step before I leave though.

@TheSecurityDev TheSecurityDev changed the title raylib: Replace gui_label and gui_text_box with Label and Text widgets; Add SelectionButton widget raylib: (big) Replace gui_label and gui_text_box with Label and Text widgets; Add SelectionButton widget Jul 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants