Add More Pseudoclasses To ContainerButton#6573
Conversation
Toggle buttons need another state for when they're currently pressed/active, but they're being hovered still. This should be fine as it uses both Pseudoclasses so however they define their style sheet, it should use one or the other reasonable option, if defined.
PJB3005
left a comment
There was a problem hiding this comment.
I hate to do this but the way this is implemented, this is a breaking change for inheritors. Can that be avoided?
Do you mean the case where a control like Content's |
Yes, that one |
Yeah I think I can get that to work. I'll get to this later, but: it should be possible to expose more of BaseButton's visual state (either through a bitmask enum similar to |
This reverts commit 2201535.
This is for when you're attempting to press but haven't yet committed to toggling it yet.
|
This should hopefully address your concerns with the inheritance problem, though I'll need to write up a new PR description & title as I made some changes. Basically I did what I described earlier, but I also added the Also documented the StylePseudoClasses for clarity + because Julian has been bugging us about RT documentation... Let me know if you'd rather me split up this PR into two. |
About the PR
Instead of only allowing for one pseudoclass for a ContainerButton, I've made it set all applicable pseudoclasses.
I also added a new
Pressingpseudoclass to cover the case that they areAttemptingPress.The
DrawModevariable is now obsoleted as they should just read the properties they want directly.Unlike a previous version, there shouldn't be any inheritance breaking changes.
Why / Balance
This is useful for working with the
CheckBox, which needs a specific hover state for when it's already Pressed which is different from the normal hover. Plus, we can have it so that now hovering or trying to click a disabled button looks different.With the pressing state, we're now able to specifically style when the user is attempting to press, which used to default to Pressed even if not toggled yet, which caused some issues when styling PressedHover vs. just Hover.
Media
Content with new styles (w/ RT):
Current (w/ RT):
Content with flipped style properties (w/ RT):
Current:
Migration(s)
Most states will have no style changes, except for when it's in the new
Pressingstate. Currently it will default to StylePropertyHover + Pressed/Normal when hovered, and default to Pressed/Normal when the mouse is still pressed down but moved away, which is different from the old default to Pressed.The rest will all be the same except if there's a conflict over selector precedence. If a fork (doesn't happen in content) defines e.g. Disabled before Pressed or Normal after Hover, it will just pick the rule that comes later iirc, which will cause visual inconsistancies.
Changes
Added a new
PressingStylePseudoClass to ContainerButton, for when the user in attempting to hover.Changed the StylePseudoClass in ContainerButton to now set all applicable PseudoClasses (Hover/Normal/Pressed/Pressing/Disabled) for more styling opportunities. This may require some stylesheet adjustments.
Created a new public field, AttemptingPress, which tells if the user is trying to press a BaseButton.