Skip to content

Commit 8013b72

Browse files
committed
Don't set background color if zebra pattern is enabled on trees
On macOS setting "linesVisible" to true creates an zebra styled pattern on the tree. If we now set the background color via CSS on this tree that pattern would be gone. Setting the background color via CSS on a tree that has "linesVisible" to false does not do any harm.
1 parent 5c9af91 commit 8013b72

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/css2/CSSPropertyBackgroundSWTHandler.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,15 @@
2323
import org.eclipse.e4.ui.css.swt.helpers.CSSSWTImageHelper;
2424
import org.eclipse.e4.ui.css.swt.helpers.SWTElementHelpers;
2525
import org.eclipse.e4.ui.css.swt.properties.GradientBackgroundListener;
26+
import org.eclipse.swt.SWT;
2627
import org.eclipse.swt.custom.CTabFolder;
2728
import org.eclipse.swt.custom.CTabItem;
2829
import org.eclipse.swt.graphics.Color;
2930
import org.eclipse.swt.graphics.Image;
3031
import org.eclipse.swt.widgets.Button;
3132
import org.eclipse.swt.widgets.Control;
3233
import org.eclipse.swt.widgets.ToolItem;
34+
import org.eclipse.swt.widgets.Tree;
3335
import org.eclipse.swt.widgets.Widget;
3436
import org.w3c.dom.css.CSSValue;
3537

@@ -75,6 +77,11 @@ public void applyCSSPropertyBackgroundColor(Object element, CSSValue value,
7577
// ToolItem prevents itself from repaints if the same color is set
7678
((ToolItem) widget).setBackground(newColor);
7779
} else if (widget instanceof Control) {
80+
if ("cocoa".equals(SWT.getPlatform()) && widget instanceof Tree tree && tree.getLinesVisible()) {
81+
// on macOS "linesVisible" creates zebra-styled pattern.
82+
// If we now would set the background color this zebra pattern would be gone.
83+
break;
84+
}
7885
GradientBackgroundListener.remove((Control) widget);
7986
CSSSWTColorHelper.setBackground((Control) widget, newColor);
8087
CompositeElement.setBackgroundOverriddenByCSSMarker(widget);

0 commit comments

Comments
 (0)