-
Notifications
You must be signed in to change notification settings - Fork 565
Update child controls style when a control is restyled #6264
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?
Update child controls style when a control is restyled #6264
Conversation
|
This should really check if the control is possibly involved in a child selector, and only do the recalculation in that case. |
|
Also, while I admit I'm pointing this out due to self-interest, as it affects switch buttons. But I do think having children update automatically is likely to be more generally useful. And the comment on the workaround in |
I agree with the sentiment - in 2e1c831, I added this; doesn't feel great, but would also worry that doing something more sophisticated would add a lot of complexity.
Nice spot! I've removed the workaround since whatever solution we land on should obsolete that. The only other thing in Content (right now, at least) which uses parent selectors is hud tooltips, which wouldn't ever have their styles changed after construction. |
|
I think I have worked out how to work around the lack of this for switch buttons; I can apply relevant pseudoclasses to the buttons' children and change the style rules accordingly. I'm going to put off actually implementing that for the moment, though, in hopes that this gets merged and saves me from having to. |
I have implemented a workaround in switch buttons. It ended up being a bit messier than I'd hoped, so I'm definitely still hoping this change will some day remove the need for workarounds. |
| AddChild(Label); | ||
| } | ||
|
|
||
| protected override void StylePropertiesChanged() |
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.
Remove this overload.
Mildly-controversial PR incoming.
I was looking to fix space-wizards/space-station-14#40923 - in that issue, the problematic element is a
CollapsibleHeading. TheCollapsibleHeadingis aContainerButtonwith a childTextureRect, which is what is used to display the triangles.So, the following style rules should do the trick. Use
collapsedTexturenormally, butexpandedTexturewhen the heading has been pressed:However, this only works once, and can't be changed once the
CollapsibleHeadingis visible. Pressing theCollapsibleHeadingwill toggle it's pressed pseudo state, which causes theCollapsibleHeadingto be restyled. However, the style rules are targetting the childTextureRect, which never gets queued to refresh it's style.This PR enqueues a style update for any child
Controls whenever a parentControl's style is updated. Potentially, this is a bunch more style re-evalulations, but not sure there's a cleverer way to do this, sinceSelector.Matchescould be doing anything, so no real way to know if child styles are affected.