Bug 465666: Fix bread crumb background in dark theme


Change-Id: Ifb6349ffd0af011933760e6ee8eef3f984209b8e
Signed-off-by: Matthias Becker <ma.becker@sap.com>
diff --git a/org.eclipse.debug.ui/css/e4-dark_debug_prefstyle.css b/org.eclipse.debug.ui/css/e4-dark_debug_prefstyle.css
index 205786c..179131d 100644
--- a/org.eclipse.debug.ui/css/e4-dark_debug_prefstyle.css
+++ b/org.eclipse.debug.ui/css/e4-dark_debug_prefstyle.css
@@ -21,4 +21,24 @@
 		'org.eclipse.debug.ui.errorColor=225,30,70'
 		'org.eclipse.debug.ui.inColor=140,175,210'
 		'org.eclipse.debug.ui.outColor=235,235,235'
+}
+
+#DebugBreadcrumbComposite,
+#DebugBreadcrumbItemComposite,
+#DebugBreadcrumbItemDetailComposite,
+#DebugBreadcrumbItemDetailTextComposite,
+#DebugBreadcrumbItemDetailImageComposite,
+#DebugBreadcrumbItemDetailTextLabel,
+#DebugBreadcrumbItemDetailImageLabel,
+#DebugBreadcrumbItemDropDownToolBar
+{
+    /*
+     * Bug 465666
+     *
+     * Note: as we can't change the arrow to black, we configure
+     * the background with the lighter color used for the background
+     * of toolbars and make the foreground color brighter too.
+     */
+    background-color:#515658;
+    color: white;
 }
\ No newline at end of file
diff --git a/org.eclipse.debug.ui/css/e4-light_debug_prefstyle.css b/org.eclipse.debug.ui/css/e4-light_debug_prefstyle.css
new file mode 100644
index 0000000..3cca01f
--- /dev/null
+++ b/org.eclipse.debug.ui/css/e4-light_debug_prefstyle.css
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * Copyright (c) 2018 SAP SE and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+#DebugBreadcrumbComposite,
+#DebugBreadcrumbItemComposite,
+#DebugBreadcrumbItemDetailComposite,
+#DebugBreadcrumbItemDetailTextComposite,
+#DebugBreadcrumbItemDetailImageComposite,
+#DebugBreadcrumbItemDetailTextLabel,
+#DebugBreadcrumbItemDetailImageLabel,
+#DebugBreadcrumbItemDropDownToolBar
+{
+    background-color:COLOR-WIDGET-LIGHT-SHADOW;
+}
\ No newline at end of file
diff --git a/org.eclipse.debug.ui/plugin.xml b/org.eclipse.debug.ui/plugin.xml
index a6826f9..ca0a02b 100644
--- a/org.eclipse.debug.ui/plugin.xml
+++ b/org.eclipse.debug.ui/plugin.xml
@@ -3266,6 +3266,12 @@
                refid="org.eclipse.e4.ui.css.theme.e4_dark">
          </themeid>
       </stylesheet>
+      <stylesheet
+            uri="css/e4-light_debug_prefstyle.css">
+         <themeid
+               refid="org.eclipse.e4.ui.css.theme.e4_default">
+         </themeid>
+      </stylesheet>
   </extension>
    <extension
          point="org.eclipse.debug.ui.launchConfigurationTypeImages">
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/BreadcrumbItem.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/BreadcrumbItem.java
index f6bc592..da32b47 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/BreadcrumbItem.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/BreadcrumbItem.java
@@ -69,6 +69,7 @@
 
         fExpandBlock= new BreadcrumbItemDropDown(this, fContainer);
 		fDetailsBlock= new BreadcrumbItemDetails(this, fContainer);
+		fContainer.setData("org.eclipse.e4.ui.css.id", "DebugBreadcrumbItemComposite"); //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
 	/**
@@ -214,8 +215,9 @@
 		fDetailsBlock.setText(string);
 
 		//more or less space might be required for the label
-		if (fIsLast)
+		if (fIsLast) {
 			fContainer.layout(true, true);
+		}
 	}
 
 	/*
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/BreadcrumbItemDetails.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/BreadcrumbItemDetails.java
index c5a7567..62782a2 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/BreadcrumbItemDetails.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/BreadcrumbItemDetails.java
@@ -26,13 +26,11 @@
 import org.eclipse.swt.events.PaintListener;
 import org.eclipse.swt.events.TraverseEvent;
 import org.eclipse.swt.events.TraverseListener;
-import org.eclipse.swt.graphics.Color;
 import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Shell;
 
@@ -129,6 +127,13 @@
 		});
 
 		fDetailComposite.setTabList(new Control[] { fTextComposite });
+
+		fDetailComposite.setData("org.eclipse.e4.ui.css.id", "DebugBreadcrumbItemDetailComposite"); //$NON-NLS-1$ //$NON-NLS-2$
+		fTextComposite.setData("org.eclipse.e4.ui.css.id", "DebugBreadcrumbItemDetailTextComposite"); //$NON-NLS-1$ //$NON-NLS-2$
+		fImageComposite.setData("org.eclipse.e4.ui.css.id", "DebugBreadcrumbItemDetailImageComposite"); //$NON-NLS-1$ //$NON-NLS-2$
+		fElementImage.setData("org.eclipse.e4.ui.css.id", "DebugBreadcrumbItemDetailImageLabel"); //$NON-NLS-1$ //$NON-NLS-2$
+		fElementText.setData("org.eclipse.e4.ui.css.id", "DebugBreadcrumbItemDetailTextLabel"); //$NON-NLS-1$ //$NON-NLS-2$
+
 	}
 
 	/**
@@ -192,18 +197,21 @@
 	public int getWidth() {
 		int result= 2;
 
-		if (fElementImage.getImage() != null)
+		if (fElementImage.getImage() != null) {
 			result+= fElementImage.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
+		}
 
-		if (fTextVisible && fElementText.getText().length() > 0)
+		if (fTextVisible && fElementText.getText().length() > 0) {
 			result+= fElementText.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
+		}
 
 		return result;
 	}
 
 	public void setTextVisible(boolean enabled) {
-		if (fTextVisible == enabled)
+		if (fTextVisible == enabled) {
 			return;
+		}
 
 		fTextVisible= enabled;
 
@@ -224,7 +232,6 @@
 				fImageComposite.setFocus();
 			}
 		}
-		updateSelection();
 	}
 
 	/**
@@ -237,17 +244,18 @@
 	}
 
 	public void setSelected(boolean selected) {
-		if (selected == fSelected)
+		if (selected == fSelected) {
 			return;
+		}
 
 		fSelected= selected;
 
-		updateSelection();
 	}
 
 	public void setFocus(boolean enabled) {
-		if (enabled == fHasFocus)
+		if (enabled == fHasFocus) {
 			return;
+		}
 
 		fHasFocus= enabled;
 		if (fHasFocus) {
@@ -257,39 +265,6 @@
 				fImageComposite.setFocus();
 			}
 		}
-		updateSelection();
-	}
-
-	private void updateSelection() {
-		Color background;
-		Color foreground;
-
-		if (fSelected) {
-			background= Display.getDefault().getSystemColor(SWT.COLOR_LIST_SELECTION);
-			foreground= Display.getDefault().getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT);
-		} else {
-			foreground= null;
-			background= null;
-		}
-
-		if (isTextVisible()) {
-			fTextComposite.setBackground(background);
-			fElementText.setBackground(background);
-			fElementText.setForeground(foreground);
-
-			fImageComposite.setBackground(null);
-			fElementImage.setBackground(null);
-		} else {
-			fImageComposite.setBackground(background);
-			fElementImage.setBackground(background);
-
-			fTextComposite.setBackground(null);
-			fElementText.setBackground(null);
-			fElementText.setForeground(null);
-		}
-
-		fTextComposite.redraw();
-		fImageComposite.redraw();
 	}
 
 	/**
@@ -385,7 +360,6 @@
 			public void focusGained(FocusEvent e) {
 				if (!fHasFocus) {
 					fHasFocus= true;
-					updateSelection();
 				}
 			}
 
@@ -393,7 +367,6 @@
 			public void focusLost(FocusEvent e) {
 				if (fHasFocus) {
 					fHasFocus= false;
-					updateSelection();
 				}
 			}
 		});
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/BreadcrumbItemDropDown.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/BreadcrumbItemDropDown.java
index 76411f3..f0314db 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/BreadcrumbItemDropDown.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/BreadcrumbItemDropDown.java
@@ -207,6 +207,7 @@
 				}
 			});
 		}
+		fToolBar.setData("org.eclipse.e4.ui.css.id", "DebugBreadcrumbItemDropDownToolBar"); //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
 	/**
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/BreadcrumbViewer.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/BreadcrumbViewer.java
index 7fa402f..44f5f62 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/BreadcrumbViewer.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/BreadcrumbViewer.java
@@ -33,15 +33,12 @@
 import org.eclipse.swt.events.DisposeEvent;
 import org.eclipse.swt.events.MenuDetectEvent;
 import org.eclipse.swt.events.MenuDetectListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.GC;
 import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.graphics.RGB;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.swt.widgets.Widget;
 
@@ -98,20 +95,6 @@
 		fContainer.addTraverseListener(e -> e.doit = true);
 		fContainer.setBackgroundMode(SWT.INHERIT_DEFAULT);
 
-		fContainer.addListener(SWT.Resize, event -> {
-			int height = fContainer.getClientArea().height;
-
-			if (fGradientBackground == null || fGradientBackground.getBounds().height != height) {
-				Image image = height == 0 ? null : createGradientImage(height, event.display);
-				fContainer.setBackgroundImage(image);
-
-				if (fGradientBackground != null) {
-					fGradientBackground.dispose();
-				}
-				fGradientBackground = image;
-			}
-		});
-
 		hookControl(fContainer);
 
 		int columns= 1000;
@@ -777,71 +760,6 @@
 		fContainer.setRedraw(false);
 	}
 
-	   /**
-     * The image to use for the breadcrumb background as specified in
-     * https://bugs.eclipse.org/bugs/show_bug.cgi?id=221477
-     *
-     * @param height the height of the image to create
-     * @param display the current display
-     * @return the image for the breadcrumb background
-     */
-    private Image createGradientImage(int height, Display display) {
-        int width= 50;
-
-        Image result= new Image(display, width, height);
-
-        GC gc= new GC(result);
-
-        Color colorC= createColor(SWT.COLOR_WIDGET_BACKGROUND, SWT.COLOR_LIST_BACKGROUND, 35, display);
-        Color colorD= createColor(SWT.COLOR_WIDGET_BACKGROUND, SWT.COLOR_LIST_BACKGROUND, 45, display);
-        Color colorE= createColor(SWT.COLOR_WIDGET_BACKGROUND, SWT.COLOR_LIST_BACKGROUND, 80, display);
-        Color colorF= createColor(SWT.COLOR_WIDGET_BACKGROUND, SWT.COLOR_LIST_BACKGROUND, 70, display);
-        Color colorG= createColor(SWT.COLOR_WIDGET_BACKGROUND, SWT.COLOR_WHITE, 45, display);
-        Color colorH= createColor(SWT.COLOR_WIDGET_NORMAL_SHADOW, SWT.COLOR_LIST_BACKGROUND, 35, display);
-
-        try {
-            drawLine(width, 0, colorC, gc);
-            drawLine(width, 1, colorC, gc);
-
-            gc.setForeground(colorD);
-            gc.setBackground(colorE);
-            gc.fillGradientRectangle(0, 2, width, 2 + 8, true);
-
-            gc.setBackground(colorE);
-            gc.fillRectangle(0, 2 + 9, width, height - 4);
-
-            drawLine(width, height - 3, colorF, gc);
-            drawLine(width, height - 2, colorG, gc);
-            drawLine(width, height - 1, colorH, gc);
-
-        } finally {
-            gc.dispose();
-
-            colorC.dispose();
-            colorD.dispose();
-            colorE.dispose();
-            colorF.dispose();
-            colorG.dispose();
-            colorH.dispose();
-        }
-
-        return result;
-    }
-
-    private void drawLine(int width, int position, Color color, GC gc) {
-        gc.setForeground(color);
-        gc.drawLine(0, position, width, position);
-    }
-
-    private Color createColor(int color1, int color2, int ratio, Display display) {
-        RGB rgb1= display.getSystemColor(color1).getRGB();
-        RGB rgb2= display.getSystemColor(color2).getRGB();
-
-        RGB blend= blend(rgb2, rgb1, ratio);
-
-        return new Color(display, blend);
-    }
-
 	/**
 	 * Blends c1 and c2 based in the provided ratio.
 	 *