tmf: Fix event table item default colors and foreground positions
authorPatrick Tasse <patrick.tasse@gmail.com>
Wed, 18 Mar 2015 17:53:52 +0000 (13:53 -0400)
committerPatrick Tasse <patrick.tasse@gmail.com>
Thu, 19 Mar 2015 18:14:50 +0000 (14:14 -0400)
The default system colors should be used whenever the default color
setting from the color setting manager is used. This no longer requires
special handling since if the color from the default color setting is
null. The current theme's system colors are not necessarily equal to
COLOR_LIST_BACKGROUND and COLOR_LIST_FOREGROUND.

The background needs to be drawn in the custom EraseItem listener if the
item background is different from the table's background (set to the
default system color as it is never changed), not when it is different
from COLOR_LIST_BACKGROUND (which may not be the default system color in
the current theme).

The text bounds and image bounds adjustments in the custom PaintItem
listener need to be set differently for Windows and Linux.

Change-Id: I06e6ed48e866ce7831ea3ad630d120a8cf228973
Signed-off-by: Patrick Tasse <patrick.tasse@gmail.com>
Reviewed-on: https://git.eclipse.org/r/44124
Reviewed-by: Hudson CI
Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/events/TmfEventsTable.java

index cebbbcf4bbbf6d9d7899bf28c99d2ac9e3a55760..3522a2478671d8699101e815306b217082801b0b 100644 (file)
@@ -673,7 +673,7 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS
                  * paint it or otherwise we would override the platform theme
                  * (e.g. alternating colors).
                  */
-                if (styleRanges != null || !background.equals(item.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND))) {
+                if (styleRanges != null || !background.equals(item.getParent().getBackground())) {
                     // we will paint the table item's background
                     event.detail &= ~SWT.BACKGROUND;
 
@@ -723,7 +723,11 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS
                     /*
                      * The image bounds don't match the default image position.
                      */
-                    gc.drawImage(image, imageBounds.x, imageBounds.y + 1);
+                    if (IS_LINUX) {
+                        gc.drawImage(image, imageBounds.x + 1, imageBounds.y + 3);
+                    } else {
+                        gc.drawImage(image, imageBounds.x, imageBounds.y + 1);
+                    }
                 }
                 gc.setForeground(item.getForeground(event.index));
                 gc.setFont(item.getFont(event.index));
@@ -732,7 +736,11 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS
                 /*
                  * The text bounds don't match the default text position.
                  */
-                gc.drawText(text, textBounds.x - 1, textBounds.y + 2, true);
+                if (IS_LINUX) {
+                    gc.drawText(text, textBounds.x + 1, textBounds.y + 3, true);
+                } else {
+                    gc.drawText(text, textBounds.x - 1, textBounds.y + 2, true);
+                }
             }
         });
 
@@ -1294,14 +1302,6 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS
             item.setForeground(colorSetting.getForegroundColor());
             item.setBackground(colorSetting.getBackgroundColor());
         }
-        /*
-         * Make sure the default system color is used. If the background is set
-         * to the default system color's value instead of null, it overrides the
-         * platform theme (e.g. alternating colors).
-         */
-        if (item.getBackground().equals(item.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND))) {
-            item.setBackground(null);
-        }
         item.setFont(fFont);
 
         if (searchMatch) {
This page took 0.027091 seconds and 5 git commands to generate.