-
-
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
Parent visibility not respected on add #3161
Comments
Nice catch! You mention special casing Although you've identified visibility as a property that is affected by this - but that's because visibility is the only property in Pack that can be affected by the parent style value. In future, when we have full CSS... cascading means that parents can impact on any style. At the very least, I'd argue that this isn't a "visibility" feature - it's a "refresh cascading properties" feature. I guess that's what is implied by your |
In the process of reviewing #2484, I've noticed a case where cascading is already an issue - background color on Winforms requires reapplying background color when the parent is changed because of how transparency is handled. So a style-wide approach would seem to make sense here. |
That's true, it could just be a However, another wrinkle I didn't consider is that this needs to propagate downward. When you add Parent to Grandparent, Child also needs to compute its cascaded properties. The way visibility is currently implemented, it searches upwards, potentially all the way to the root — but this will snowball when propagated downward. We'd only need a single tree traversal if, instead,
Hm... currently we assign an applicator when the widget is first created. Are you suggesting we avoid assigning an applicator then, and only assign it once the node is given a parent? There's nothing stopping you from adding a widget to a parent that doesn't currently have a parent or applicator of its own, and reparenting a widget that has children still needs to propagate the changes downward.
I think we're on the same page here.
Interesting, I'll have to take a look at that one. |
We definitely need to make sure we're not setting off a notification cascade by working in both directions. However, I don't think that's a concern here. Application in both directions is already happening. The
In the case you're describing, adding parent to grandparent means you need to interrogate Grandparent's visibility (which means potentially looking all the way to root); but the re-application of style is applied from Parent down. The style attribute of each node doesn't change; but the effective value passed to the applicator might. But this is already implemented; the only difference here is triggering the
Broadly speaking, that's what I was suggesting - but to be clear, it's also me noodling around looking for other ways to approach the problem, not a coherent API proposal. I'm mostly observing that when an applicator is assigned, one of the side effects is to apply the entire style... which is essentially what we're looking to do here. If we're able to combine the two requirements, that seems like a win.
Bikeshed color and bugs we haven't thought of notwithstanding, 👍 |
Wow, I've been staring at style so hard I forgot that the applicator already does this. Yeah, okay, this (probably) isn't as big a change as I was thinking for a second there.
It's getting late for me here, but soon (probably tomorrow) I can see about putting together at least a proof of concept... and then we can kibitz about what color to paint it. 😉
Ah, yeah I think I see where you're going there. I'm not sure either what that might look like, yet. |
Describe the bug
#2950 fixed inherited visibility in descendant widgets... but not entirely, it turns out. That test verifies that everything behaves as expected when the
visibility
property is set after the widget hierarchy is already established. However, the mechanism that looks up the chain for a hidden ancestor isn't done when adding a child.The simplest fix for this is to put
child.style.apply("visibility", child.style.visibility)
inWidget.add
, but that seems like mixing concerns — Widget probably shouldn't be special-casing a specific Pack property like that, and it can't be tested in the currenttest_apply.py
setup which uses dummy example nodes instead of actual widgets.Perhaps Pack — or even BaseStyle? – could gain a hook to be called once its node has been added to a new parent. So
child.style.apply("visibility", child.style.visibility)
would become something likechild.style._added_to_new_parent()
, so the style engine can perform whatever inheritance-related checks it needs to do. This could potentially go inNode.add
. Thoughts?Steps to reproduce
Expected behavior
A child's on-screen visibility should respect an ancestor's hidden status upon being added as its child.
Screenshots
No response
Environment
Logs
Additional context
No response
The text was updated successfully, but these errors were encountered: