Skip to content

Commit 9d72757

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 e15e9bf commit 9d72757

File tree

1 file changed

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

1 file changed

+17
-6
lines changed

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

Lines changed: 17 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;
@@ -626,12 +627,22 @@ void drawSelectedTab(int itemIndex, GC gc, Rectangle bounds) {
626627
if (onBottom) {
627628
highlightOnTop = !highlightOnTop;
628629
}
629-
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);
630+
final int highlightHeight = 1 + (superimposeKeylineOutline && highlightOnTop ? OUTER_KEYLINE_WIDTH : 0);
631+
632+
if (cornerSize == SQUARE_CORNER || highlightOnTop == onBottom) {
633+
int verticalOffset = highlightOnTop ? 0 : outlineBoundsForOutline.height - (highlightHeight);
634+
gc.setAdvanced(false);
635+
gc.fillRectangle(outlineBoundsForOutline.x, outlineBoundsForOutline.y + verticalOffset,
636+
outlineBoundsForOutline.width, highlightHeight + 1);
637+
} else {
638+
int[] highlightShape = Arrays.copyOfRange(tabOutlinePoints, 12, tabOutlinePoints.length - 12);
639+
int highlightY = highlightOnTop ? highlightHeight
640+
: outlineBoundsForOutline.height - highlightHeight;
641+
highlightShape[1] = highlightShape[3] = highlightShape[highlightShape.length
642+
- 1] = highlightShape[highlightShape.length - 3] = highlightY;
643+
gc.setAdvanced(false);
644+
gc.fillPolygon(highlightShape);
645+
}
635646
}
636647

637648
if (backgroundPattern != null) {

0 commit comments

Comments
 (0)