Skip to content

Commit b088af9

Browse files
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)
1 parent a501e9a commit b088af9

1 file changed

Lines changed: 23 additions & 5 deletions

File tree

  • bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt

bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/CTabRendering.java

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package org.eclipse.e4.ui.workbench.renderers.swt;
1919

2020
import java.lang.reflect.Field;
21+
import java.util.Arrays;
2122
import java.util.Objects;
2223
import org.eclipse.core.runtime.Platform;
2324
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
@@ -627,11 +628,28 @@ void drawSelectedTab(int itemIndex, GC gc, Rectangle bounds) {
627628
highlightOnTop = !highlightOnTop;
628629
}
629630
int highlightHeight = 2;
630-
int verticalOffset = highlightOnTop ? 0 : bounds.height - (highlightHeight - 1);
631-
int horizontalOffset = itemIndex == 0 || cornerSize == SQUARE_CORNER ? 0 : 1;
632-
int widthAdjustment = cornerSize == SQUARE_CORNER ? 0 : 1;
633-
gc.fillRectangle(bounds.x + horizontalOffset, bounds.y + verticalOffset, bounds.width - widthAdjustment,
634-
highlightHeight);
631+
if (highlightOnTop == onBottom) {
632+
int verticalOffset = bounds.height - (highlightHeight);
633+
gc.fillRectangle(outlineBoundsForOutline.x, bounds.y + verticalOffset, outlineBoundsForOutline.width,
634+
highlightHeight);
635+
gc.setForeground(selectedTabHighlightColor);
636+
gc.drawLine(outlineBoundsForOutline.x, bounds.y + verticalOffset + highlightHeight,
637+
outlineBoundsForOutline.x + outlineBoundsForOutline.width,
638+
bounds.y + verticalOffset + highlightHeight);
639+
} else if (cornerSize == SQUARE_CORNER) {
640+
gc.fillRectangle(outlineBoundsForOutline.x,
641+
outlineBoundsForOutline.y, outlineBoundsForOutline.width, highlightHeight + 1);
642+
} else {
643+
boolean gcAdvanced = gc.getAdvanced();
644+
gc.setAdvanced(false);
645+
int[] highlightShape = Arrays.copyOfRange(tabOutlinePoints, 12, tabOutlinePoints.length - 12);
646+
int highlightY = highlightOnTop ? highlightHeight
647+
: outlineBoundsForOutline.height - highlightHeight;
648+
highlightShape[1] = highlightShape[3] = highlightShape[highlightShape.length
649+
- 1] = highlightShape[highlightShape.length - 3] = highlightY;
650+
gc.fillPolygon(highlightShape);
651+
gc.setAdvanced(gcAdvanced);
652+
}
635653
}
636654

637655
if (backgroundPattern != null) {

0 commit comments

Comments
 (0)