-
-
Notifications
You must be signed in to change notification settings - Fork 689
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
Fix box widget background color bug #1684
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see how this would address the problem for at least some problems, but I don't think it's a general fix.
Consider the case of a base widget with a grandchild; the grandchild has it's own specific background color specified. This PR will cascade a background color change onto the children, and then the grandchildren. If the children don't specify the background color, then that's probably the right behavior; but overriding the grandchild's explicit background color won't be.
Pack doesn't currently have an explicit concept of inherited styles; so it could also be argued that the solution doesn't lie in cascading the style definition down to children, but to making the children transparent by default so that base styles are visible. For platforms where transparency isn't an option as a background color, that, may mean implementing "pseudo" transparency by implementing this sort of style cascade; but that would be a platform-specific implementation, not a generic property of the style applicator.
(FYI - I've merged this PR with main; we've recently landed a big repo restructure, so any outstanding PRs will need to be merged before any of the CI will run).
Fair enough. With the test code below, the children each have their own explicit background color. The proposed fix seems to work in this particular scenario. Prior to the proposed change the children just used the background colour of the parent.
|
Yes - that example will work - but mostly by accident. The children's styles are being created (and therefore applied) after the parent's style has been applied, so the "cascading" aspect of your patch is never exercised (or, if it is exercised, the effect is being immediately overwritten). However, if you add a button, and make the handler for that button set the color of |
Thanks. Yes, just works by accident. As a learning exercise I added a button that sets the background colour of |
@gregcowell: Please give this PR a descriptive title rather than just an issue number. You can edit the title with the "Edit" button at the top right of the page. A better way to link the PR to the original issue is to write "Fixes #xxx" in the PR's first comment, as shown here. You can edit the comment by clicking the "..." menu at the top right of the comment. |
Fixes #988. Currently a box widget that is a child of another box widget takes on the background colour of the parent box widget. This fix ensures that a child box uses the background colour specified via its own style.
PR Checklist: