From 4c27e4234ddce3fb2400003cd46ce8fbb147ff5b Mon Sep 17 00:00:00 2001 From: Patrick Tasse Date: Wed, 18 Mar 2015 13:53:52 -0400 Subject: [PATCH] tmf: Fix event table item default colors and foreground positions 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 Reviewed-on: https://git.eclipse.org/r/44124 Reviewed-by: Hudson CI Reviewed-by: Bernd Hufmann Tested-by: Bernd Hufmann --- .../tmf/ui/viewers/events/TmfEventsTable.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/events/TmfEventsTable.java b/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/events/TmfEventsTable.java index cebbbcf4bb..3522a24786 100644 --- a/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/events/TmfEventsTable.java +++ b/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/events/TmfEventsTable.java @@ -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) { -- 2.34.1