From d79a1fe76cb01e0616f338e6e88ab2b88aaf52a6 Mon Sep 17 00:00:00 2001 From: Shahzaib Ibrahim Date: Wed, 10 Dec 2025 16:26:39 +0100 Subject: [PATCH] Adjust selection bounds for CTabRenderring Selected tabs highlight look slightly off and more noticeable when zoom is not 100%. These adjusted value shows no gaps from top and better aligned highlights for tabs (Theme is enabled) --- .../renderers/swt/CTabRendering.java | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/CTabRendering.java b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/CTabRendering.java index ddbdc346105..b21f52eb978 100644 --- a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/CTabRendering.java +++ b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/CTabRendering.java @@ -18,6 +18,7 @@ package org.eclipse.e4.ui.workbench.renderers.swt; import java.lang.reflect.Field; +import java.util.Arrays; import java.util.Objects; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.preferences.IEclipsePreferences; @@ -621,17 +622,26 @@ void drawSelectedTab(int itemIndex, GC gc, Rectangle bounds) { } if (selectedTabHighlightColor != null) { + Color oldBackground = gc.getBackground(); gc.setBackground(selectedTabHighlightColor); boolean highlightOnTop = drawTabHighlightOnTop; if (onBottom) { highlightOnTop = !highlightOnTop; } - int highlightHeight = 2; - int verticalOffset = highlightOnTop ? 0 : bounds.height - (highlightHeight - 1); - int horizontalOffset = itemIndex == 0 || cornerSize == SQUARE_CORNER ? 0 : 1; - int widthAdjustment = cornerSize == SQUARE_CORNER ? 0 : 1; - gc.fillRectangle(bounds.x + horizontalOffset, bounds.y + verticalOffset, bounds.width - widthAdjustment, - highlightHeight); + final int highlightHeight = 2 + (superimposeKeylineOutline && highlightOnTop ? OUTER_KEYLINE_WIDTH : 0); + + if (cornerSize == SQUARE_CORNER || highlightOnTop == onBottom) { + int verticalOffset = highlightOnTop ? 0 : outlineBoundsForOutline.height - (highlightHeight - 1); + gc.fillRectangle(outlineBoundsForOutline.x, outlineBoundsForOutline.y + verticalOffset, + outlineBoundsForOutline.width, highlightHeight); + } else { + int[] highlightShape = Arrays.copyOfRange(tabOutlinePoints, 8, tabOutlinePoints.length - 8); + int highlightY = highlightOnTop ? highlightHeight : outlineBoundsForOutline.height - highlightHeight; + highlightShape[1] = highlightShape[3] = highlightShape[highlightShape.length + - 1] = highlightShape[highlightShape.length - 3] = highlightY; + gc.fillPolygon(highlightShape); + } + gc.setBackground(oldBackground); } if (backgroundPattern != null) {