Bug 465711 - Rendering of tabs when hovering using a dark theme makes
authorFabio Zadrozny <fabiofz@gmail.com>
Tue, 28 Apr 2015 17:27:25 +0000 (14:27 -0300)
committerFabio Zadrozny <fabiofz@gmail.com>
Tue, 28 Apr 2015 19:51:27 +0000 (16:51 -0300)
tab unreadable (CTabRendering)

Change-Id: I763285dd36f639ca2331ce9e0d41b146387dc0ba
Signed-off-by: Fabio Zadrozny <fabiofz@gmail.com>
bundles/org.eclipse.e4.ui.css.swt/plugin.xml
bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyUnselectHotTabsColorBackgroundHandler.java [new file with mode: 0644]
bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/internal/css/swt/ICTabRendering.java
bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/CTabRendering.java
bundles/org.eclipse.ui.themes/css/dark/e4-dark_globalstyle.css

index 1f7a6f5..96468a6 100644 (file)
       <handler
             adapter="org.eclipse.e4.ui.css.swt.dom.CTabFolderElement"
             composite="false"
+            handler="org.eclipse.e4.ui.css.swt.properties.custom.CSSPropertyUnselectHotTabsColorBackgroundHandler">
+         <property-name
+               name="unselected-hot-tab-color-background">
+         </property-name>
+      </handler>
+      <handler
+            adapter="org.eclipse.e4.ui.css.swt.dom.CTabFolderElement"
+            composite="false"
             handler="org.eclipse.e4.ui.css.swt.properties.custom.CSSPropertyShadowColorHandler">
          <property-name
                name="swt-shadow-color">
diff --git a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyUnselectHotTabsColorBackgroundHandler.java b/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyUnselectHotTabsColorBackgroundHandler.java
new file mode 100644 (file)
index 0000000..d1fd4db
--- /dev/null
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Fabio Zadrozny 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
+ *
+ * Contributors:
+ *     Fabio Zadrozny - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.e4.ui.css.swt.properties.custom;
+
+import org.eclipse.e4.ui.css.core.engine.CSSEngine;
+import org.eclipse.e4.ui.css.swt.properties.AbstractCSSPropertySWTHandler;
+import org.eclipse.e4.ui.internal.css.swt.ICTabRendering;
+import org.eclipse.swt.custom.CTabFolder;
+import org.eclipse.swt.custom.CTabFolderRenderer;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.widgets.Control;
+import org.w3c.dom.css.CSSValue;
+
+public class CSSPropertyUnselectHotTabsColorBackgroundHandler extends AbstractCSSPropertySWTHandler {
+
+       public static final String UNSELECTED_HOT_TAB_COLOR_BACKGROUND = "unselected-hot-tab-color-background";
+
+       @Override
+       protected void applyCSSProperty(Control control, String property,
+                       CSSValue value, String pseudo, CSSEngine engine) throws Exception {
+               if (UNSELECTED_HOT_TAB_COLOR_BACKGROUND.equals(property)) {
+                       if (!(control instanceof CTabFolder)) {
+                               return;
+                       }
+                       if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
+                               Color newColor = (Color) engine.convert(value, Color.class, control.getDisplay());
+                               CTabFolderRenderer renderer = ((CTabFolder) control).getRenderer();
+                               if (renderer instanceof ICTabRendering) {
+                                       ((ICTabRendering) renderer).setUnselectedHotTabsColorBackground(newColor);
+                               }
+                       }
+               }
+       }
+
+       @Override
+       protected String retrieveCSSProperty(Control control, String property,
+                       String pseudo, CSSEngine engine) throws Exception {
+               return null;
+       }
+
+}
index 7fe16bb..d2a5f3c 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- *  Copyright (c) 2014 IBM Corporation and others.
+ *  Copyright (c) 2014-2015 IBM Corporation 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
@@ -7,6 +7,7 @@
  *
  *  Contributors:
  *      IBM Corporation - initial API and implementation
+ *      Fabio Zadrozny - Bug 465711
  *******************************************************************************/
 package org.eclipse.e4.ui.internal.css.swt;
 
@@ -21,6 +22,8 @@ public interface ICTabRendering {
 
        void setUnselectedTabsColor(Color[] colors, int[] percents);
 
+       void setUnselectedHotTabsColorBackground(Color color);
+
        void setTabOutline(Color color);
 
        void setInnerKeyline(Color color);
index 474ca98..a603822 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2010, 2014 IBM Corporation and others.
+ * Copyright (c) 2010, 2015 IBM Corporation 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
@@ -7,6 +7,7 @@
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
+ *     Fabio Zadrozny - Bug 465711
  *******************************************************************************/
 package org.eclipse.e4.ui.workbench.renderers.swt;
 
@@ -93,6 +94,8 @@ ICTabRendering {
        private CTabFolderRendererWrapper rendererWrapper;
        private CTabFolderWrapper parentWrapper;
 
+       private Color hotUnselectedTabsColorBackground;
+
        @Inject
        public CTabRendering(CTabFolder parent) {
                super(parent);
@@ -101,6 +104,11 @@ ICTabRendering {
        }
 
        @Override
+       public void setUnselectedHotTabsColorBackground(Color color) {
+               this.hotUnselectedTabsColorBackground = color;
+       }
+
+       @Override
        protected Rectangle computeTrim(int part, int state, int x, int y,
                        int width, int height) {
                boolean onBottom = parent.getTabPosition() == SWT.BOTTOM;
@@ -652,7 +660,13 @@ ICTabRendering {
                                                        + INNER_KEYLINE + OUTER_KEYLINE), bounds.y
                                                        + bounds.height);
 
-                       gc.setBackground(gc.getDevice().getSystemColor(SWT.COLOR_WHITE));
+                       Color color = hotUnselectedTabsColorBackground;
+                       if (color == null) {
+                               // Fallback: if color was not set, use white for highlighting
+                               // hot tab.
+                               color = gc.getDevice().getSystemColor(SWT.COLOR_WHITE);
+                       }
+                       gc.setBackground(color);
                        int[] tmpPoints = new int[index];
                        System.arraycopy(points, 0, tmpPoints, 0, index);
                        gc.fillPolygon(tmpPoints);
index 15c059a..664f648 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2010, 2014 Andrea Guarinoni and others.
+ * Copyright (c) 2010, 2015 Andrea Guarinoni 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
@@ -10,7 +10,7 @@
  *     Stefan Winkler <stefan@winklerweb.net> - Bug 434189
  *     Stefan Winkler <stefan@winklerweb.net> - Bug 430848
  *     Simon Scholz <simon.scholz@vogella.com> - Bug 431635
- *     Fabio Zadrozny <fabiofz@gmail.com> - Bug 465148
+ *     Fabio Zadrozny <fabiofz@gmail.com> - Bug 465148, 465711
  *******************************************************************************/
 
 /*******************************************************************************
@@ -319,10 +319,12 @@ CTabFolder {
     swt-selected-tab-fill: '#org-eclipse-ui-workbench-ACTIVE_TAB_BG_END'; /* title background for selected tab */
     swt-shadow-visible: false;
     swt-corner-radius: 16px;
+    unselected-hot-tab-color-background: #161616; /* Bug 465711 */
 }
 CTabFolder[style~='SWT.DOWN'][style~='SWT.BOTTOM'] {
     /* Set the styles for the bottom inner tabs (Bug 430051): */
     swt-tab-renderer: url('bundleclass://org.eclipse.e4.ui.workbench.renderers.swt/org.eclipse.e4.ui.workbench.renderers.swt.CTabRendering');
+    unselected-hot-tab-color-background: #161616; /* Bug 465711 */
 }
 
 Form,