Skip to content

Commit 691b22d

Browse files
Adjust selection bounds for Rounded Tabs
1 parent a4713f9 commit 691b22d

File tree

1 file changed

+19
-6
lines changed
  • bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt

1 file changed

+19
-6
lines changed

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

Lines changed: 19 additions & 6 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;
@@ -621,17 +622,29 @@ void drawSelectedTab(int itemIndex, GC gc, Rectangle bounds) {
621622
}
622623

623624
if (selectedTabHighlightColor != null) {
625+
Color oldBackground = gc.getBackground();
624626
gc.setBackground(selectedTabHighlightColor);
625627
boolean highlightOnTop = drawTabHighlightOnTop;
626628
if (onBottom) {
627629
highlightOnTop = !highlightOnTop;
628630
}
629-
int highlightHeight = 2 + (superimposeKeylineOutline && highlightOnTop ? OUTER_KEYLINE_WIDTH : 0);
630-
int verticalOffset = highlightOnTop ? 0 : outlineBoundsForOutline.height - (highlightHeight - 1);
631-
int horizontalOffset = itemIndex == 0 || cornerSize == SQUARE_CORNER ? 0 : 1;
632-
int widthAdjustment = cornerSize == SQUARE_CORNER ? 0 : 1;
633-
gc.fillRectangle(outlineBoundsForOutline.x + horizontalOffset, outlineBoundsForOutline.y + verticalOffset, outlineBoundsForOutline.width - widthAdjustment,
634-
highlightHeight);
631+
if (cornerSize == SQUARE_CORNER) {
632+
int highlightHeight = 2 + (superimposeKeylineOutline && highlightOnTop ? OUTER_KEYLINE_WIDTH : 0);
633+
int verticalOffset = highlightOnTop ? 0 : outlineBoundsForOutline.height - (highlightHeight - 1);
634+
int horizontalOffset = itemIndex == 0 || cornerSize == SQUARE_CORNER ? 0 : 1;
635+
int widthAdjustment = cornerSize == SQUARE_CORNER ? 0 : 1;
636+
gc.fillRectangle(outlineBoundsForOutline.x + horizontalOffset,
637+
outlineBoundsForOutline.y + verticalOffset, outlineBoundsForOutline.width - widthAdjustment,
638+
highlightHeight);
639+
} else {
640+
int[] highlightShape = Arrays.copyOf(tabOutlinePoints, tabOutlinePoints.length);
641+
// Update Y coordinates in shape to apply highlight thickness
642+
int thickness = 2;
643+
int highlightY = onBottom ? bottomY - thickness : thickness + 1;
644+
highlightShape[1] = highlightShape[3] = highlightShape[highlightShape.length - 1] = highlightShape[highlightShape.length - 3] = highlightY;
645+
gc.fillPolygon(highlightShape);
646+
}
647+
gc.setBackground(oldBackground);
635648
}
636649

637650
if (backgroundPattern != null) {

0 commit comments

Comments
 (0)