Skip to content
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

Fixing ToolStrip button background rendering in HC theme #5614

Conversation

ArtemTatarinov
Copy link
Contributor

@ArtemTatarinov ArtemTatarinov commented Aug 30, 2021

Fixes #5502

Proposed changes

  • false flag is being passed while creating ToolStripHighContrastRenderer instance at ToolStripSystemRenderer, so after this flag is inverted at ToolStripHighContrastRenderer's constructor, the FillWhenSelected flag will be true (ToolStripProfessionalRenderer already has the same logic)
  • If there's a special overridden renderer for High Contrast theme, then base class should call that renderer's method for rendering backgrounds of ToolStripButton, ToolStripDropDownButton, ToolStripSplitButton (ToolStripProfessionalRenderer already has the same logic)

Customer Impact

Before fix

image

After fix
image
image
image

Regression?

  • No

Risk

  • Minimal

Test methodology

  • Manually
  • Unit tests
  • CTI team

Accessibility testing

  • Inspect
  • Accessibility Insights

Test environment(s)

Microsoft Windows [Version 10.0.19043.1165]
.NET SDK 6.0.100-rc.1.21416.15

Microsoft Reviewers: Open in CodeFlow

@merriemcgaw merriemcgaw added the a11yMAS High Priority - Accessibility violation of Microsoft Accessibility Standards label Aug 30, 2021
@dreddy-work
Copy link
Member

As per @merriemcgaw , we would need this servicing to 6.0 RC2.

@RussKie RussKie added the 📭 waiting-author-feedback The team requires more information from the author label Aug 31, 2021
@ghost ghost removed the 📭 waiting-author-feedback The team requires more information from the author label Aug 31, 2021
@ArtemTatarinov ArtemTatarinov force-pushed the Issue#5502_ToolStripButton_NoText_HighContrast branch from 68c662b to 7bfb681 Compare August 31, 2021 05:24
@ArtemTatarinov ArtemTatarinov added waiting-review This item is waiting on review by one or more members of team and removed a11yMAS High Priority - Accessibility violation of Microsoft Accessibility Standards labels Aug 31, 2021
Copy link
Member

@Tanya-Solyanik Tanya-Solyanik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but please describe testing done. Specifically it is important to test renderers for all possible styles and states of tool strip buttons, checked, CHeckState, and in response to different mouse actions(mouse over, left button down).

Consider adding a test case that enumerates these variations like buttons.cs does to our test app.

@Tanya-Solyanik Tanya-Solyanik added 📭 waiting-author-feedback The team requires more information from the author and removed waiting-review This item is waiting on review by one or more members of team labels Sep 1, 2021
@RussKie
Copy link
Member

RussKie commented Sep 1, 2021

Generally we should write rendering tests, if possible. There are a few example in the codebase, e.g. #4739.

Please ping me if you have any Qs.

@ghost ghost removed the 📭 waiting-author-feedback The team requires more information from the author label Sep 1, 2021
@ArtemTatarinov ArtemTatarinov marked this pull request as draft September 1, 2021 11:38
@ArtemTatarinov ArtemTatarinov added the a11yMAS High Priority - Accessibility violation of Microsoft Accessibility Standards label Sep 1, 2021
@ArtemTatarinov ArtemTatarinov marked this pull request as ready for review September 1, 2021 17:12
@ArtemTatarinov ArtemTatarinov added waiting-review This item is waiting on review by one or more members of team and removed waiting-review This item is waiting on review by one or more members of team labels Sep 1, 2021
dreddy-work
dreddy-work previously approved these changes Sep 1, 2021
dreddy-work
dreddy-work previously approved these changes Sep 2, 2021
Copy link
Member

@dreddy-work dreddy-work left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@dreddy-work dreddy-work added ready-to-merge PRs that are ready to merge but worth notifying the internal team. and removed waiting-review This item is waiting on review by one or more members of team labels Sep 2, 2021
@Tanya-Solyanik Tanya-Solyanik added 📭 waiting-author-feedback The team requires more information from the author and removed ready-to-merge PRs that are ready to merge but worth notifying the internal team. labels Sep 3, 2021
@ArtemTatarinov ArtemTatarinov force-pushed the Issue#5502_ToolStripButton_NoText_HighContrast branch from f625517 to 2d77eb9 Compare September 3, 2021 12:25
@ghost ghost removed the 📭 waiting-author-feedback The team requires more information from the author label Sep 3, 2021
@ArtemTatarinov ArtemTatarinov force-pushed the Issue#5502_ToolStripButton_NoText_HighContrast branch from 2d77eb9 to 5e45c76 Compare September 3, 2021 13:46
@ArtemTatarinov
Copy link
Contributor Author

Looks good, but please describe testing done. Specifically it is important to test renderers for all possible styles and states of tool strip buttons, checked, CHeckState, and in response to different mouse actions(mouse over, left button down).
Consider adding a test case that enumerates these variations like buttons.cs does to our test app.

I have added ToolStrip buttons to the ToolStripTests form and manually checked different mouse actions (mouse hover, LMB and RMB clicking), different DisplayStyles (Image, Text, ImageAndText) and Checked/CheckStates (Checked, Unchecked, Indeterminate) in Black and White HC themes. I found one issue: for CheckState.Indeterminate the background is rendered wrong just like the original cases of the issue but this time it doesn't matter if the button was selected:
image
image

I fixed it and tested again manually all the cases, looks like now it's good.
image
image

Issue Description
Background of the buttons with CheckState.Checked and CheckState.Indeterminate is rendered the same way in non-HC mode at .NET 6.0 and .NET Framework 4.7.2 , both states look like each other.

.NET 6.0
image

.NET Framework 4.7.2
image

This is happening because Checked property is used for rendering the ToolStrip items, not CheckState property, and the Checked property of the ToolStripButton class is false only for CheckState.Unchecked and is true for CheckState.Checked or CheckState.Indeterminate:
image

I used the same logic for fixing this issue. At the OnRenderButtonBackground method of the ToolStripHighContrastRenderer class there were two checks:
image

So, if we want to render the background of the button with CheckState.Indeterminate state in HC mode as it's done in non-HC mode, we should remove the redundant check for CheckState.Checked, because it will leave buttons with CheckState.Indeterminate without correct background rendering:
image

@Tanya-Solyanik
Copy link
Member

Background of the buttons with CheckState.Checked and CheckState.Indeterminate is rendered the same way in non-HC mode at .NET 6.0 and .NET Framework 4.7.2 , both states look like each other.

This is unfortunate... But this is an existing bug, we'll wait for external reports before we triage it.

Your fix for indeterminate HC makes sense. Thank you for the follow up!

Tanya-Solyanik
Tanya-Solyanik previously approved these changes Sep 3, 2021
Copy link
Member

@Tanya-Solyanik Tanya-Solyanik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@Tanya-Solyanik
Copy link
Member

Issue to track rendering tests - #5670

@Tanya-Solyanik Tanya-Solyanik added the 📬 waiting-for-testing The PR is awaiting manual testing by the primary team; no action is yet required from the author(s) label Sep 3, 2021
Copy link
Contributor

@vladimir-krestov vladimir-krestov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good ✔️
Waiting for testing results...

@@ -42,7 +42,7 @@ internal ToolStripRenderer HighContrastRenderer
{
if (toolStripHighContrastRenderer is null)
{
toolStripHighContrastRenderer = new ToolStripHighContrastRenderer(/*renderLikeSystem*/true);
toolStripHighContrastRenderer = new ToolStripHighContrastRenderer(/*renderLikeSystem*/systemRenderMode: false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
toolStripHighContrastRenderer = new ToolStripHighContrastRenderer(/*renderLikeSystem*/systemRenderMode: false);
toolStripHighContrastRenderer = new ToolStripHighContrastRenderer(systemRenderMode: false);

Copy link
Member

@RussKie RussKie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rendering tests?

@RussKie RussKie added the 📭 waiting-author-feedback The team requires more information from the author label Sep 6, 2021
@ArtemTatarinov ArtemTatarinov force-pushed the Issue#5502_ToolStripButton_NoText_HighContrast branch from 5e45c76 to 113816f Compare September 6, 2021 04:29
@Olina-Zhang Olina-Zhang removed the 📬 waiting-for-testing The PR is awaiting manual testing by the primary team; no action is yet required from the author(s) label Sep 7, 2021
@Olina-Zhang
Copy link
Member

Tested this fixing with no new issue found, hitting known GH issue: #5676

@dreddy-work
Copy link
Member

Rendering tests?

Rendering tests are tracked by #5670 .

@dreddy-work dreddy-work removed the 📭 waiting-author-feedback The team requires more information from the author label Sep 7, 2021
@dreddy-work dreddy-work merged commit a7761d1 into dotnet:main Sep 7, 2021
@ghost ghost added this to the 7.0 alpha1 milestone Sep 7, 2021
@ArtemTatarinov ArtemTatarinov deleted the Issue#5502_ToolStripButton_NoText_HighContrast branch September 8, 2021 05:54
@ghost ghost locked as resolved and limited conversation to collaborators Jan 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a11yMAS High Priority - Accessibility violation of Microsoft Accessibility Standards
Projects
None yet
7 participants