winforms icon indicating copy to clipboard operation
winforms copied to clipboard

Issue 2053861 fix combo box flickering issue

Open LeafShi1 opened this issue 1 year ago • 10 comments

Fixes #2053861

Proposed changes

  • Separate DrawPopUpCombo from DrawFlatCombo method,draw the outer black border only when the ComboBox mouse is over

Customer Impact

  • Combobox no longer flickers when hovering over it

Regression?

  • No

Risk

  • Minimal

Screenshots

Before

Combo box flashes when you move the mouse over it BeforeChange

After

Combo boxes no longer flicker when you move the mouse over them AfterChange

Test methodology

  • Manually

Test environment(s)

  • .net 9.0.0-preview.6.24305.2
Microsoft Reviewers: Open in CodeFlow

LeafShi1 avatar Jun 13 '24 07:06 LeafShi1

Codecov Report

Attention: Patch coverage is 9.37500% with 29 lines in your changes missing coverage. Please review.

Project coverage is 74.46985%. Comparing base (fc56416) to head (86889e0). Report is 42 commits behind head on main.

Additional details and impacted files
@@                 Coverage Diff                 @@
##                main      #11529         +/-   ##
===================================================
+ Coverage   74.39859%   74.46985%   +0.07125%     
===================================================
  Files           3032        3039          +7     
  Lines         628149      629068        +919     
  Branches       46828       46836          +8     
===================================================
+ Hits          467334      468466       +1132     
+ Misses        157465      157242        -223     
- Partials        3350        3360         +10     
Flag Coverage Δ
Debug 74.46985% <9.37500%> (+0.07125%) :arrow_up:
integration 17.97590% <0.00000%> (-0.02466%) :arrow_down:
production 47.32729% <9.37500%> (+0.08032%) :arrow_up:
test 96.96223% <ø> (-0.00449%) :arrow_down:
unit 44.31360% <9.37500%> (+0.08465%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

codecov[bot] avatar Jun 13 '24 08:06 codecov[bot]

This link - https://devdiv.visualstudio.com/DevDiv/_queries/edit/2053861/?queryId=7c94b3b5-6b84-4f3d-9f76-ff1a7a7b7581 does not work, please fix it.

Had you tested this change at different themes and RtL applications?

The change looks reasonable.

Tanya-Solyanik avatar Jun 13 '24 22:06 Tanya-Solyanik

This link - https://devdiv.visualstudio.com/DevDiv/_queries/edit/2053861/?queryId=7c94b3b5-6b84-4f3d-9f76-ff1a7a7b7581 does not work, please fix it.

Had you tested this change at different themes and RtL applications?

The change looks reasonable.

Updated the link of the description and test in different environment Test in RTL app: RTL

Test in different theme: ThemeAquatuc ThemeDesert

Test in Flat Style: FlatStyle

There are still a flickering in Flat Style, and this flickering issue can be resolved by remove https://github.com/dotnet/winforms/blob/889fca6df2aa684e3557ef7737b443ed3af32455/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ComboBox/ComboBox.cs#L3880

But I am not sure if we can remove this directly, @Tanya-Solyanik What do you think?

LeafShi1 avatar Jun 14 '24 08:06 LeafShi1

@LeafShi1 - How do the high contrast themes look before your changes, did it get better or worse with the fix? FYI @merriemcgaw

Tanya-Solyanik avatar Jun 18 '24 22:06 Tanya-Solyanik

Before the modification, the Popup state was not obvious, and only a black border was displayed when the mouse entered the control white black

LeafShi1 avatar Jun 19 '24 09:06 LeafShi1

This is definitely not worse from my perspective. @Tanya-Solyanik?

merriemcgaw avatar Jun 19 '24 21:06 merriemcgaw

This is definitely not worse from my perspective. @Tanya-Solyanik?

The new behavior looks more intentional, i.e. we are adding a border when mouse is hovering. I don't mind taking this fix.

Tanya-Solyanik avatar Jun 20 '24 16:06 Tanya-Solyanik

@Olina-Zhang - could you please test this fix?

Tanya-Solyanik avatar Jun 20 '24 16:06 Tanya-Solyanik

@LeafShi1

But I am not sure if we can remove this directly, @Tanya-Solyanik What do you think?

No, we shouldn't do that. I agree. To fix that we would have to redesign the control look, maybe add a prominent border in the state when the mouse is not above the control

Tanya-Solyanik avatar Jun 20 '24 17:06 Tanya-Solyanik

@LeafShi1

But I am not sure if we can remove this directly, @Tanya-Solyanik What do you think?

No, we shouldn't do that. I agree. To fix that we would have to redesign the control look, maybe add a prominent border in the state when the mouse is not above the control

@Tanya-Solyanik Do we need to redesign the controls appearance now?

Before drawing Flat, the combobox control is as follows. Pic1: image

The method of drawing Flat is to draw Outboder and innerBorder. The result after drawing is as follows Pic2: image

When the cursor enters, it is necessary to complete the drawing from Pic1 to Pic2,the actual cause of the flickering is the use of g.DrawRectangle four times in a row when drawing the Flat type. So adding a protruding border when the mouse is not over the control does not seem to solve the flickering problem

LeafShi1 avatar Jun 21 '24 07:06 LeafShi1

@Tanya-Solyanik Do we need to redesign the controls appearance now?

No

Tanya-Solyanik avatar Jul 21 '24 22:07 Tanya-Solyanik

Verified this issue on 9.0.100-preview.7.24371.4 with dlls built from winforms repo of main branch, it was fixed. Flickering effect is no longer there when hovering over ComboBox. Results are as below:

PopupStyle

https://github.com/user-attachments/assets/fff6c129-6890-4203-9618-4ac17b8dfcab

FlatStyle

https://github.com/user-attachments/assets/eaaf3e8c-c057-4076-b47d-5f294e5ba9e9

Different Themes

https://github.com/user-attachments/assets/4c248269-c303-4a0b-a790-faf412703505

https://github.com/user-attachments/assets/3c7111d8-e452-49f8-ba89-080e463f9ae4

https://github.com/user-attachments/assets/bd6a23f1-5c09-4b9a-9d9e-69c7ebce47a7

https://github.com/user-attachments/assets/22d15301-8eda-4926-b7a4-d2abcf8949f2

Syareel-Sukeri avatar Jul 25 '24 08:07 Syareel-Sukeri

Verified this PR fixing in .NET 9.0.100-preview7.24402.8 test pass build from provided VS VAL build, it was fixed for ComboBox flickering issue when setting this control's FlatStyle == PopUp. But still repro for ComboBox's FlatStyle == Flat case. These are same as the testing result we tested before.

https://github.com/user-attachments/assets/b85553d6-0cdb-43a4-919c-3e25781be169

Olina-Zhang avatar Aug 05 '24 07:08 Olina-Zhang