Clean up usage of rgba()#3967
Merged
freakboy3742 merged 7 commits intobeeware:mainfrom Dec 12, 2025
Merged
Conversation
HalfWhitt
commented
Dec 12, 2025
Member
Author
HalfWhitt
left a comment
There was a problem hiding this comment.
Most of these are very straightforward and mechanical — comments inline on a couple of places where I did more beyond search-and-replace.
| requested_color = rgba(0, 0, 0, 0) | ||
| else: | ||
| requested_color = color.rgba | ||
| parent_color = toga_color(SystemColors.Control) |
Member
Author
There was a problem hiding this comment.
toga_color() returns an rgb instance; since there's no difference now between that and rgba, no conversion needs to be done. (It was toga_color(SystemColors.Control).rgba.)
| match color, self._default_background_color: | ||
| case (colors.TRANSPARENT, _) | (None, colors.TRANSPARENT): | ||
| requested_color = rgb(0, 0, 0, 0) | ||
| case None, _: |
Member
Author
There was a problem hiding this comment.
Condensed four cases to three with spiffy new syntax : )
| return rgba(r, g, b, a[0]) | ||
| else: | ||
| return rgba(r, g, b) | ||
| return rgb(r, g, b, a[0] if a else 1) |
Member
Author
There was a problem hiding this comment.
Since rgb can take an alpha parameter, the conditional can be on the argument itself rather than what class to construct.
freakboy3742
approved these changes
Dec 12, 2025
Member
freakboy3742
left a comment
There was a problem hiding this comment.
👍 All looks good to me! Thanks for the cleanup!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As of, #3665,
rgbais now an alias for the preferredrgb, as in CSS. Toga's code base is still usingrgbain a number of places.PR Checklist: