Skip to content

[win32] Add workaround for missing selection indicator for menu item with image on Win11 (#501) #2143

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

wahlbrink
Copy link

For menu items of type CHECK and RADIO with an image, it create an second image with a checkmark/circle over the original image.

with image on Win11 (eclipse-platform#501)

For menu items of type CHECK and RADIO with an image, it create an
second image with a checkmark/circle over the original image.
@wahlbrink
Copy link
Author

ControlExample
IDE-noTheme
IDE-DarkTheme

@merks
Copy link
Contributor

merks commented May 13, 2025

@wahlbrink

This problem is the only reason why I have not upgraded by system to Windows 11.

Can you show a screen capture of how it looks with and without your changes? I'm not sure I can really test/see that on Windows 10.

@HeikoKlare

This problem has festered for years and I don't think Windows 11 itself will ever make the problem go away. It would be great for this to be reviewed to make any necessary changes or improvements.

@merks
Copy link
Contributor

merks commented May 13, 2025

Oh, I think this is the change:

image

@Phillipus
Copy link
Contributor

What should happen is that the menu item image is highlighted by a surrounding square (blue in light theme). Wasn't this possible as POC in #501?

Copy link
Contributor

Test Results

   545 files  ±0     545 suites  ±0   33m 1s ⏱️ - 6m 52s
 4 377 tests ±0   4 359 ✅ ±0   18 💤 ±0  0 ❌ ±0 
16 647 runs  ±0  16 506 ✅ ±0  141 💤 ±0  0 ❌ ±0 

Results for commit 1a6d4d4. ± Comparison against base commit f498ca3.

@merks
Copy link
Contributor

merks commented May 13, 2025

What should happen is that the menu item image is highlighted by a surrounding square (blue in light theme). Wasn't this possible as POC in #501?

The should happen is based on how it looked before, which was quite (very) nice. In fact kind of nicer visually than this proposal and more familiar. But, at this point 6 months later, I'm willing to say what should happen is something, maybe even anything reasonable, because that is better than nothing at all which we have currently and have had for far too long.

I really hope to see movement here...

@Phillipus
Copy link
Contributor

@merks Agreed. I just thought that the highlighted square was kind of working as POC in #501 ?

@merks
Copy link
Contributor

merks commented May 13, 2025

@merks Agreed. I just thought that the highlighted square was kind of working as POC in #501 ?

Yes, I think that approach is prettier. 😍 I just don't know if it's harder to implement and maybe harder to match the native styling. I don't know much, except that I'm willing to compromise at this point...

@HeikoKlare
Copy link
Contributor

Thank you for this proposal!
I agree that any solution to the issue is better than none. And given that this proposes a way to custom-draw the icon to be shown, it might be easy to just exchange how the icon is drawn later on if desired (replacing the check with a highlighted square in the background or whatever we agree on).
In the long run, we should probably try to mimic the highlighted square. Even though the check mark is what the more modern UI frameworks in Windows use, the highlighted square fits to every other visualization of selection we have in Eclipse right now.

At first glance, the change looks quite straightforward and should hopefully be of low risk. Still the question is if we want to process this for the upcoming release given that we are short before M3 (and at least I will not have time to have a more thorough look into this until Thursday).

@merks
Copy link
Contributor

merks commented May 30, 2025

What should happen is that the menu item image is highlighted by a surrounding square (blue in light theme). Wasn't this possible as POC in #501?

I scanned that very long issue and I'm not sure exactly where the POC code actually exists. So while I like visually what I see now on Windows 10, if no one can spend the effort to emulate that (which seems tricky with respect to theme adjustments) then I like that this PR provides a working solution that we can actually commit.

In my opinion, we need to move forward one way or the other before M1. So if someone has a better way and is willing to create a PR for it, that would be a good thing.

@HeikoKlare
Copy link
Contributor

In my opinion, we need to move forward one way or the other before M1. So if someone has a better way and is willing to create a PR for it, that would be a good thing.

Fully agree. From UX perspective the solution looks quite fine and I don't expect that anyone proposes a better one soon.
I still have it on my list to take a look at this from code perspective for M1 and will do as soon as I find the time so that we have it early in M1.

@Phillipus
Copy link
Contributor

What should happen is that the menu item image is highlighted by a surrounding square (blue in light theme). Wasn't this possible as POC in #501?

I scanned that very long issue and I'm not sure exactly where the POC code actually exists.

No code but @wahlbrink proposed possible solution "(A) Mimic Win 10 / Add blue box (as proposed)" here - is that possible or a no go?

@merks
Copy link
Contributor

merks commented May 31, 2025

I think anything that changes the size needed to render the decoration is disruptive and will likely lead to visual inconsistencies.

Copy link
Contributor

@HeikoKlare HeikoKlare left a comment

Choose a reason for hiding this comment

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

Thank you for this concrete proposal on addressing the long-standing issue with missing selection indicators in menu items!

The implementation seems to work fine. I have tested it also with different monitor zooms and it adapts as expected. Also the different configuration options work as designed. I did not find any functional issues within the code as well. So regarding all that, the PR is fine to me.

I am just a bit concerned that the implementation is scattered across the MenuItem implementation. This makes it difficult to understand even in the review and will become even more difficult when reading the code fragment without the context of a PR.

I don't want to bother with rewriting the adaptation, but in my opinion encapsulating all the custom selection image functionality at a single place might significantly improve the quality. It might be an (inner) Selection class (or the like) encapsulating:

  • the toggle state for which kind of customization to use based on the system propery
  • the initialization logic for the custom selected image
  • the custom selected image (currently the imageSelected field), which can be initialized on demand
  • the selected bitmap handle (currently the hBitmapSelected field), which can also be initialized on demand
  • the dispose functionality for all data related to the selection image (to be called when setting a new image on the menu item or releasing the menu item widget)
  • the functionality to fill the menu item info (called in updateImage() and setSelection())

This would serve two means:

  1. Locality: the functionality would be encapsulated at a single place so it can be understood, maintained and, if necessary, removed at that single place.
  2. Comprehensibility: as a side effect of putting all partial functionalities into methods of that encapsulating class, the purpose of the single code blocks becomes more clear (just like when extracting the code blocks into methods with self-explaining names).

But to point it out again: even without such a design refinement the change is fine and it will definitely improve UX compared to the given state by showing selected states again anyway.

int y0 = imageHeight / 2 - 8;
if (((style & SWT.CHECK) != 0)) {
int[] points = new int[] { x0 + 4, y0 + 10, x0 + 6, y0 + 12, x0 + 12, y0 + 6 };
gc.setAntialias(SWT.ON);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: alias is set in if and else clause, so it could be moved outside

gc.drawImage(image, imageWidth - imageBounds.width, (imageHeight - imageBounds.height) / 2);
int x0 = imageWidth - 16;
int y0 = imageHeight / 2 - 8;
if (((style & SWT.CHECK) != 0)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: to make the method a bit simpler and code a bit more comprehensive, you might extract the if and else blocks into methods drawCheck and drawRadio or the like

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants