-
Notifications
You must be signed in to change notification settings - Fork 9.9k
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
base: master
Are you sure you want to change the base?
Conversation
…perty; add ret value to _render
…onents in updater.py
…Label class (matches old way)
…and Updater classes
…d gui_label function
…y software buttons to handle if toggleable is true
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. |
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:
widgets/label.py
to widgets/text.pygui_label
function with aLabel
widget class.gui_text_box
function with aText
widget class. This class is used for rendering longer text that needs to break into multiple lines.gui_label
with theLabel
class.gui_text_box
with theText
widget class.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.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.