From 2e0ca5f0737a727a233a3c7c7a90ca0854e5e92d Mon Sep 17 00:00:00 2001 From: Christopher Hermann Date: Fri, 16 Feb 2024 10:12:01 +0100 Subject: [PATCH 1/3] Keep theme coloring of cells in FocusCellOwnerDrawHighlighter In dark theme on macOS, the cell back ground color are colored in light colors when using a FocusCellOwnerDrawHighlighter. By setting the background color alpha to 0, the color is not even draw and the initial color is kept. --- .../eclipse/jface/viewers/FocusCellOwnerDrawHighlighter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/FocusCellOwnerDrawHighlighter.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/FocusCellOwnerDrawHighlighter.java index 8fe93c3c458..bfb37eb298c 100644 --- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/FocusCellOwnerDrawHighlighter.java +++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/FocusCellOwnerDrawHighlighter.java @@ -106,7 +106,7 @@ private void markFocusedCell(Event event, ViewerCell cell) { private void removeSelectionInformation(Event event, ViewerCell cell) { GC gc = event.gc; - gc.setBackground(cell.getViewerRow().getBackground(cell.getColumnIndex())); + gc.setAlpha(0);// Don't draw background to keep cell coloring of theme gc.setForeground(cell.getViewerRow().getForeground(cell.getColumnIndex())); gc.fillRectangle(cell.getBounds()); event.detail &= ~SWT.SELECTED; From 4f51faaaa8aab50add11545a3f133cc54cd8e7fd Mon Sep 17 00:00:00 2001 From: Christopher Hermann Date: Fri, 8 Mar 2024 12:53:19 +0100 Subject: [PATCH 2/3] Only apply background coloring on GTK --- bundles/org.eclipse.jface/META-INF/MANIFEST.MF | 3 ++- .../jface/viewers/FocusCellOwnerDrawHighlighter.java | 9 +++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/bundles/org.eclipse.jface/META-INF/MANIFEST.MF b/bundles/org.eclipse.jface/META-INF/MANIFEST.MF index 10bae5cb78a..68e47c816cc 100644 --- a/bundles/org.eclipse.jface/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.jface/META-INF/MANIFEST.MF @@ -37,7 +37,8 @@ Export-Package: org.eclipse.jface, Require-Bundle: org.eclipse.swt;bundle-version="[3.111.0,4.0.0)";visibility:=reexport, org.eclipse.core.commands;bundle-version="[3.4.0,4.0.0)";visibility:=reexport, org.eclipse.equinox.common;bundle-version="[3.18.0,4.0.0)", - org.eclipse.equinox.bidi;bundle-version="[0.10.0,2.0.0)";resolution:=optional + org.eclipse.equinox.bidi;bundle-version="[0.10.0,2.0.0)";resolution:=optional, + org.eclipse.core.runtime;bundle-version="[3.31.0,4.0.0)" Bundle-RequiredExecutionEnvironment: JavaSE-17 Import-Package: javax.xml.parsers, org.osgi.framework;version="[1.8.0,2.0.0)", diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/FocusCellOwnerDrawHighlighter.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/FocusCellOwnerDrawHighlighter.java index bfb37eb298c..34805739ac0 100644 --- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/FocusCellOwnerDrawHighlighter.java +++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/FocusCellOwnerDrawHighlighter.java @@ -17,6 +17,7 @@ package org.eclipse.jface.viewers; import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.Platform; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.GC; @@ -106,9 +107,13 @@ private void markFocusedCell(Event event, ViewerCell cell) { private void removeSelectionInformation(Event event, ViewerCell cell) { GC gc = event.gc; - gc.setAlpha(0);// Don't draw background to keep cell coloring of theme + if (Platform.WS_GTK.equals(Platform.getWS())) { + // On GTK, the line is highlighted even though the SELECTED flag is removed. To + // fix this issue, the background must be overwridden + gc.setBackground(cell.getViewerRow().getBackground(cell.getColumnIndex())); + gc.fillRectangle(cell.getBounds()); + } gc.setForeground(cell.getViewerRow().getForeground(cell.getColumnIndex())); - gc.fillRectangle(cell.getBounds()); event.detail &= ~SWT.SELECTED; } From cbf97372e52bca31d5b467575653fb0190e8ce3e Mon Sep 17 00:00:00 2001 From: Christopher Hermann Date: Fri, 8 Mar 2024 14:43:02 +0100 Subject: [PATCH 3/3] Remove dependency to org.eclipse.core.runtime --- bundles/org.eclipse.jface/META-INF/MANIFEST.MF | 3 +-- .../eclipse/jface/viewers/FocusCellOwnerDrawHighlighter.java | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/bundles/org.eclipse.jface/META-INF/MANIFEST.MF b/bundles/org.eclipse.jface/META-INF/MANIFEST.MF index 68e47c816cc..10bae5cb78a 100644 --- a/bundles/org.eclipse.jface/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.jface/META-INF/MANIFEST.MF @@ -37,8 +37,7 @@ Export-Package: org.eclipse.jface, Require-Bundle: org.eclipse.swt;bundle-version="[3.111.0,4.0.0)";visibility:=reexport, org.eclipse.core.commands;bundle-version="[3.4.0,4.0.0)";visibility:=reexport, org.eclipse.equinox.common;bundle-version="[3.18.0,4.0.0)", - org.eclipse.equinox.bidi;bundle-version="[0.10.0,2.0.0)";resolution:=optional, - org.eclipse.core.runtime;bundle-version="[3.31.0,4.0.0)" + org.eclipse.equinox.bidi;bundle-version="[0.10.0,2.0.0)";resolution:=optional Bundle-RequiredExecutionEnvironment: JavaSE-17 Import-Package: javax.xml.parsers, org.osgi.framework;version="[1.8.0,2.0.0)", diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/FocusCellOwnerDrawHighlighter.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/FocusCellOwnerDrawHighlighter.java index 34805739ac0..5001ba9b6da 100644 --- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/FocusCellOwnerDrawHighlighter.java +++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/FocusCellOwnerDrawHighlighter.java @@ -17,7 +17,6 @@ package org.eclipse.jface.viewers; import org.eclipse.core.runtime.Assert; -import org.eclipse.core.runtime.Platform; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.GC; @@ -107,7 +106,7 @@ private void markFocusedCell(Event event, ViewerCell cell) { private void removeSelectionInformation(Event event, ViewerCell cell) { GC gc = event.gc; - if (Platform.WS_GTK.equals(Platform.getWS())) { + if ("gtk".equals(SWT.getPlatform())) { //$NON-NLS-1$ // On GTK, the line is highlighted even though the SELECTED flag is removed. To // fix this issue, the background must be overwridden gc.setBackground(cell.getViewerRow().getBackground(cell.getColumnIndex()));