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

Highlighting problem when using the dark theme on Windows eclipse-platform/eclipse.platform.swt#811 #1690

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

Christopher-Hermann
Copy link
Contributor

@Christopher-Hermann Christopher-Hermann commented Feb 16, 2024

Highlighting problem when using the dark theme on Windows eclipse-platform/eclipse.platform.swt#811

JFace viewer are using OS selection color to highlight the selected item. On some OS this is not accessible. In particular when the eclipse is used with dark theme and the OS is used with light theme, this can cause really bad UI/UX experience. With this change, the selection color can be changed via color preference in the settings of eclipse.

Fixes eclipse-platform/eclipse.platform.swt#811

Example
Selection color on Windows Server in dark theme looks really bad:
272533915-9b63234a-6644-4174-9f2a-42b610eb5d66

Testing
On start up of eclipse, the selection colors in column viewers (table and tree viewer) should look like before.
On Windows, the dark theme should predefine the selection colors to fix the bad coloring on some Windows platforms.

In the preferences (Preferences > General > Appearance > Colors and Fonts), there are 4 new properties for the coloring of the viewer selection:

  • Basic > Selection foreground color for cell viewer
  • Basic > Selection background color for cell viewer
  • Basic > Selection foreground color for cell viewer without focus
  • Basic > Selection background color for cell viewer without focus
    Changing these colors should affect the coloring of the selection in viewers. The coloring should immediately be applied as soon as the apply button is confirmed. The reset button should reset the coloring to the OS specific highlight coloring, expect for Windows dark theme, where the predefined colors should be restored.

To test the in different kind of viewers, import project viewerSelectionDemo.zip and execute the command "Open Viewer Selection Demo". There a bunch of different viewers with different selection colors are rendered to test the coloring for focused/not focused viewers.

Open Questions/Issues
This will have impact on coloring for all eclipse installations on all OSs and themes. The default coloring of the OS is overwritten in any case, even if it is not needed. Maybe we should only overwrite the selection color if this is enabled/requested by the user via a preference setting?

Copy link
Contributor

github-actions bot commented Feb 16, 2024

Test Results

 1 809 files   - 3   1 809 suites   - 3   1h 41m 39s ⏱️ + 9m 15s
 7 616 tests +2   7 388 ✅ +2  228 💤 ±0  0 ❌ ±0 
24 000 runs  +6  23 251 ✅ +6  749 💤 ±0  0 ❌ ±0 

Results for commit 2014747. ± Comparison against base commit af7cdc3.

This pull request removes 3 and adds 5 tests. Note that renamed tests count towards both.
org.eclipse.ui.tests.pluginchecks.PluginWalkerTest ‑ ensureExtensionPointClassesAreAccessable
org.eclipse.ui.tests.pluginchecks.PluginWalkerTest ‑ ensurePluginxmlContainsAtLeastOneEntry
org.eclipse.ui.tests.pluginchecks.PluginWalkerTest ‑ validateAccessToBundle
org.eclipse.jface.internal.text.TableOwnerDrawSupportTest ‑ testPaintSelectionFocus
org.eclipse.jface.internal.text.TableOwnerDrawSupportTest ‑ testPaintSelectionNoFocus
org.eclipse.jface.internal.text.contentassist.CompletionTableDrawSupportTest ‑ testInstall
org.eclipse.jface.internal.text.contentassist.CompletionTableDrawSupportTest ‑ testPaintNonFocusSelectionInFocusColors
org.eclipse.jface.internal.text.contentassist.CompletionTableDrawSupportTest ‑ testStoreStyleRanges

♻️ This comment has been updated with latest results.

chirontt added a commit to chirontt/eclipse.platform.ui that referenced this pull request Apr 10, 2024
chirontt added a commit to chirontt/eclipse.platform.ui that referenced this pull request Apr 11, 2024
chirontt added a commit to chirontt/eclipse.platform.ui that referenced this pull request Apr 11, 2024
chirontt added a commit to chirontt/eclipse.platform.ui that referenced this pull request Apr 14, 2024
chirontt added a commit to chirontt/eclipse.platform.ui that referenced this pull request Apr 15, 2024
chirontt added a commit to chirontt/eclipse.platform.ui that referenced this pull request Apr 15, 2024
chirontt added a commit to chirontt/eclipse.platform.ui that referenced this pull request Apr 16, 2024
chirontt added a commit to chirontt/eclipse.platform.ui that referenced this pull request Apr 17, 2024
chirontt added a commit to chirontt/eclipse.platform.ui that referenced this pull request Apr 18, 2024
chirontt added a commit to chirontt/eclipse.platform.ui that referenced this pull request Apr 22, 2024
@fedejeanne
Copy link
Contributor

@Christopher-Hermann thank you for looking into this! I personally use the dark theme and am sometimes annoyed that it doesn't highlight stuff properly (at least on Windows).

I tested the viewer (on Windows 10) and I see this:

highlighting_issue_dark_theme_TestViewer

I like it!

Would it be possible to somehow also fix the auto-completion dialog though?

highlighting_issue_dark_theme_autocompletion

Or maybe I am just testing this the wrong way?

Here are the GIFs in raw format: gifs.zip

@Christopher-Hermann
Copy link
Contributor Author

Christopher-Hermann commented Apr 23, 2024

Would it be possible to somehow also fix the auto-completion dialog though?

I just looked into this exact issue today, see #1688. I hope I can finish the work on this the next weeks.

@Christopher-Hermann Christopher-Hermann force-pushed the viewer_selection_color_fix branch 2 times, most recently from fbe1bf5 to 0b528bf Compare April 23, 2024 13:38
@Christopher-Hermann
Copy link
Contributor Author

Christopher-Hermann commented Apr 23, 2024

Not sure about the design of TableOwnerDrawSupport and the sub class CompletionTableDrawSupport. Maybe someone has an better idea how to overwrite the selection color in CompletionTableDrawSupport.

@Christopher-Hermann
Copy link
Contributor Author

I would appreciate some assistance on deciding how to proceed with this PR.

Summary
Four new color options are now available in the preferences to style table and tree selections. Users can even customize these from the preferences dialog for a more personalized user experience:
image

This offers a significant UI/UX enhancement, especially on Windows, where the default OS coloring resulted in a poor user experience:
image

With these new color preferences, table and tree viewer selection colors remain consistent across all platforms, and can be tailored to individual user preferences. However, changing the selection color for every Eclipse installation might result into problems on certain platforms.

For instance, screenshots taken from Lars Vogels' tutorials on Linux Ubuntu show the default selection color to be orange:
image

Moreover, MacOS users can specify custom selection colors in the OS (Akzentfarbe), which is currently recognized by Eclipse:
image

Open Questions

  • Can we universally alter the default selection color across all operating systems?
  • Would it be better to make the selection coloring optional, perhaps by including an additional setting within the preferences?
  • Is it possible to consider OS selection coloring when initially launching Eclipse, while still providing users with the option to modify the coloring in the preferences?

@fedejeanne
Copy link
Contributor

fedejeanne commented Apr 24, 2024

Open Questions

* Can we universally alter the default selection color across all operating systems?

* Would it be better to make the selection coloring optional, perhaps by including an additional setting within the preferences?

* Is it possible to consider OS selection coloring when initially launching Eclipse, while still providing users with the option to modify the coloring in the preferences?

I don't know how the following could be achieved but my personal favorite would be:

  • Provide a new button to let the 4 new configurations use the "system color" (similar to Use System Font)
  • Use the system color by default: I would expect that Mac and Linux still look good when using the dark theme (also, the green "Akzentfarbe" should be used in Mac)
  • (Optionally) Override the system color for Windows when using the dark theme (if the decision on this is blocking the PR, just postpone it to another PR)

IMO letting the users fix the coloring problem on their own by actively changing it would be good enough for this PR.

My two cents on the issue :-)

@HeikoKlare
Copy link
Contributor

First of all, I really like and appreciate this contribution, as this dark theme highlighting problem on Windows is quite annoying. So thank you for working on that, @Christopher-Hermann!

I have to admit that I had no time yet to look into the proposed solution, so I can only give input in terms of "solution-independent expectations". Maybe they can help you in some way; otherwise feel free to ignore them:

  • From a pure user experience point of view, I would expect that on Linux and Mac everything stays as it is and on Windows the dark theme by default uses the new colors (as there are no native colors to be reasonably used).
  • From a more technical point of view, I would expect that by default the native colors are used and they can optionall be overwriting via preferences. On Windows, the theme could then overwrite these values by default. I am not sure whether that's possible with the preferences mechanism.

@Christopher-Hermann
Copy link
Contributor Author

  • From a more technical point of view, I would expect that by default the native colors are used and they can optionall be overwriting via preferences. On Windows, the theme could then overwrite these values by default. I am not sure whether that's possible with the preferences mechanism.

Yes, I also prefer this approach. I will have a look if something like this can be done within the preferences. I can imagine that taking the OS colors on the initial eclipse startup can also cause troubles when the OS color settings are changed in a later point in time. But I will have a look.

  • (Optionally) Override the system color for Windows when using the dark theme (if the decision on this is blocking the PR, just postpone it to another PR)

If the preference thing is not possible (or at least not with manageable effort) I will go for this approach to provide a quick fix at least for windows users. I think that's where the problem is most annoying. An then have a look on a separate PR.

@Christopher-Hermann
Copy link
Contributor Author

I achieved the desired behavior, at least for MacOS it's working fine:

  • System highlight color is set as viewer selection color on the startup of eclipse.
  • The color can be overwritten by the user via the color preferences.
  • For dark theme on Windows, the system colors are overwritten by the theme settings.

It would be nice if someone can test the latest changes on other platforms. As soon as testing looks good I will have a look if unit tests can be added.

@fedejeanne
Copy link
Contributor

fedejeanne commented May 7, 2024

@Christopher-Hermann could you please describe how you tested and what is the expected behavior?

Please explain which menus/preferences should be changed in the "Testing" section of this PR for future reference. I can test in Linux if it's ready in the next couple of hours. Thank you.

@Christopher-Hermann
Copy link
Contributor Author

Please explain which menus/preferences should be changed in the "Testing" section of this PR for future reference. I can test in Linux if it's ready in the next couple of hours. Thank you.

You can use the ZIP file provided under Testing here: #1690 (comment)
There are a bunch of Viewers rendered where the selection coloring with and without the fix can be compared.

Furthermore, the new selection color should be applied in all standard eclipse views using column viewer, for example project explorer, outline, etc.

On Linux, the behavior should be:

  • Every thing is colored as it was without the change (in light and dark theme)
  • Going to Preferences > General > Appearance > Colors and Fonts and changing the color settings for the selection (Baisc > Selection background color for cell viewer, etc.)
  • After changing the color settings, the viewers from the test ZIP and all Eclipse views should adapt the selection color accordingly

@fedejeanne
Copy link
Contributor

fedejeanne commented May 7, 2024

@Christopher-Hermann thank you for the details.

Changes look good in Linux and the colors can be changed. I also briefly tested in Windows and it looks OK.

Please remember to:

  • Edit the Testing section of this PR
  • Mention the 4 added configurations: where are they and what are their names?
  • Mention the expected state of the buttons according to the platform (Windows overrides the defaults so the state of the "Restore" button is different than on the other 2 platforms)
  • Mention a "quickly noticeable" change once you hit the "Apply" button (you should even see it in the preferences dialog).

The reason I insist on this is because it should be easy to see how to test and what to expect in which specific platform for newcomers. It would also give me and other reviewers an idea of how you tested and we could expand on that idea and test for stuff that you might have overlooked.

My findings

I also found that, in Linux:

  • The system values for "Selection background color for cell viewer without focus" (white) and "Selection foreground color for cell viewer without focus" (gray) don't work well together (look at the 2nd and 4th columns in the screenshot below)
  • Some borders are still painted on the right columns when working with cell selection (look at the 4th and 5th column of the screenshot below)

Screenshot from 2024-05-07 11-05-22

@Christopher-Hermann
Copy link
Contributor Author

Christopher-Hermann commented May 8, 2024

  • The system values for "Selection background color for cell viewer without focus" (white) and "Selection foreground color for cell viewer without focus" (gray) don't work well together (look at the 2nd and 4th columns in the screenshot below)

I noticed the same (not as bad as on Linux, but it could still be better) for MacOS. Maybe we need to define a color for the non focus selection. This shouldn't be affected by the OS highlight color anyway.

@Christopher-Hermann
Copy link
Contributor Author

  • Some borders are still painted on the right columns when working with cell selection (look at the 4th and 5th column of the screenshot below)

Not related to this change, I opened another issue: #1878. You can assign the issue to me, I will look into it later.

@BeckerWdf
Copy link
Contributor

Would be good to have some unit tests for the changes.
Also it would be nice if somebody on windows could test this PR.

Copy link
Contributor

@fedejeanne fedejeanne left a comment

Choose a reason for hiding this comment

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

I took a peek at the latest changes in b9ac801 and I have some minor comments.

I didn't test the changes yet, I will try to come back to this later this week.

Comment on lines +28 to +29
net.bytebuddy.byte-buddy;bundle-version="1.14.13",
net.bytebuddy.byte-buddy-agent;bundle-version="1.14.13"
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you really need these?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. byte-buddy is needed for Mockito, Mockito is needed to mock the static class GC.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hm, I thought it should be automatically added since I didn't see any other references to byte-buddy in the WS (but several references to Mockito).
The tests are failing (invalid access). Can you please look into that?

@Christopher-Hermann
Copy link
Contributor Author

For the failing unit test I will need some help. On my local machine I fixed the test by adding the packages as export package:
org.eclipse.jface.internal.text.contentassist;x-internal:=true, in bundles/org.eclipse.jface.text/META-INF/MANIFEST.MF
org.eclipse.jface.internal.text.contentassist, as export package in tests/org.eclipse.jface.text.tests/META-INF/MANIFEST.MF

Not sure if something else needs to be done to fix this in the GitHub run

@alexanderKononov-sap
Copy link
Contributor

Thank you Christopher for taking on this task!
I have just tested it under Windows 11, and it works as expected.

  • New preferences take effect immediately after pressing "Apply"
  • Reset to default works
  • In all views that I tested, the selection had new colors that I set
  • Also in the code completion pop-over

The only thing I have noticed, is that in your test view, the 4th and 5th trees look the same. I assume that this is a copy-paste error in the test view, but if not, please check it out.
image

@fedejeanne
Copy link
Contributor

For the failing unit test I will need some help. On my local machine I fixed the test by adding the packages as export package: org.eclipse.jface.internal.text.contentassist;x-internal:=true, in bundles/org.eclipse.jface.text/META-INF/MANIFEST.MF org.eclipse.jface.internal.text.contentassist, as export package in tests/org.eclipse.jface.text.tests/META-INF/MANIFEST.MF

Not sure if something else needs to be done to fix this in the GitHub run

Maybe something similar to the problem we faced before, @HeikoKlare ? I mean the one fixed by eclipse-platform/eclipse.platform.swt@43cf295.

@HeikoKlare
Copy link
Contributor

The test is failing because the it tries to access a protected method (the constructor TableOwnerDrawSupport(Table)) without having access to it. The reason is that the test is placed in a test plug-in, which (in an OSGi environment) uses a different class loader than the to-be-tested plug-in, so that even though test class and tested class are placed in the same package they cannot access protected or package-visible methods of each other (even though one might assume that when considering ordinary Java visibility behavior).

If the to-be-tested functionality is not part of plug-in's public API but should still be tested in isolation (in terms of a proper unit test), you need to use one of the options discussed in eclipse-platform/.github#203, namely either plug-in-internal tests (as done in eclipse-platform/eclipse.platform.swt#1203 for SWT) or test fragments.

Maybe in this case it could be easier to instantiate the TableOwnerDrawSupport via public API (i.e., via TableOwnerDrawSupport::install(Table)) instead of providing a more complicated test setup?

…tform/eclipse.platform.swt#811

JFace viewer are using OS selection color to highlight the selected item. On some OS this is not accessible. With this change, the selection color can be changed via color preference in the settings of eclipse.

Fixes eclipse-platform/eclipse.platform.swt#811
The system selection/highlight color is set as default color for the viewer selection in Eclipse. This color setting can be overwritten by the user via the color preferences.
Overwrite the default selection color for dark theme on Windows since the system color on Windows is hard to read.
@Christopher-Hermann
Copy link
Contributor Author

Christopher-Hermann commented May 22, 2024

Maybe in this case it could be easier to instantiate the TableOwnerDrawSupport via public API (i.e., via TableOwnerDrawSupport::install(Table)) instead of providing a more complicated test setup?

Done, thanks for your help.

There are still some build failure and a test failure. It seems to be related to:
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.eclipse.tycho.extras:tycho-p2-extras-plugin:4.0.8-SNAPSHOT:compare-version-with-baselines (compare-attached-artifacts-with-release) on project org.eclipse.ui.themes: Only qualifier changed for (org.eclipse.ui.themes/1.2.2400.v20240522-0941). Expected to have bigger x.y.z than what is available in baseline (1.2.2400.v20240213-1133)
I will check on that

@BeckerWdf
Copy link
Contributor

Let's wait with version number increases once the freeze period is over and development for the next releases starts.

@HeikoKlare
Copy link
Contributor

In addition to the errors due to required version increments and API tools failures, there also seem to be some compilation problems:

Error:  Failed to execute goal org.eclipse.tycho:tycho-compiler-plugin:4.0.8-SNAPSHOT:compile (default-compile) on project org.eclipse.jface.text.tests: Compilation failure: Compilation failure: 
Error:  /home/runner/work/eclipse.platform.ui/eclipse.platform.ui/tests/org.eclipse.jface.text.tests/src/org/eclipse/jface/internal/text/contentassist/CompletionTableDrawSupportTest.java:[37] 
Error:  	CompletionTableDrawSupport.install(table);
Error:  	^^^^^^^^^^^^^^^^^^^^^^^^^^
Error:  Access restriction: The type 'CompletionTableDrawSupport' is not API (restriction on classpath entry '/home/runner/work/eclipse.platform.ui/eclipse.platform.ui/bundles/org.eclipse.jface.text/target/org.eclipse.jface.text-3.25.100-SNAPSHOT.jar')
[...]

Maybe those are worth to fix before the next development cycle starts.

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.

Highlighting problem when using the dark theme on Windows.
5 participants