Skip to content

Commit 0263dbe

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 6d06b55 commit 0263dbe

File tree

1 file changed

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

1 file changed

+19
-11
lines changed

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

Lines changed: 19 additions & 11 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,24 @@ 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 = 2;
631+
if (cornerSize == SQUARE_CORNER || highlightOnTop == onBottom) {
632+
int verticalOffset = highlightOnTop ? 0 : outlineBoundsForOutline.height - (highlightHeight - 1);
633+
gc.fillRectangle(outlineBoundsForOutline.x,
634+
outlineBoundsForOutline.y + verticalOffset, outlineBoundsForOutline.width, highlightHeight);
635+
} else {
636+
int[] highlightShape = Arrays.copyOfRange(tabOutlinePoints, 12, tabOutlinePoints.length - 12);
637+
int highlightY = highlightOnTop ? highlightHeight
638+
: outlineBoundsForOutline.height - highlightHeight;
639+
highlightShape[1] = highlightShape[3] = highlightShape[highlightShape.length
640+
- 1] = highlightShape[highlightShape.length - 3] = highlightY;
641+
gc.setAdvanced(false);
642+
gc.fillPolygon(highlightShape);
643+
gc.setForeground(tabOutlineColor);
644+
if (TAB_OUTLINE_WIDTH > 0) {
645+
gc.drawPolyline(tabOutlinePoints);
646+
}
647+
}
635648
}
636649

637650
if (backgroundPattern != null) {
@@ -640,11 +653,6 @@ void drawSelectedTab(int itemIndex, GC gc, Rectangle bounds) {
640653
if (foregroundPattern != null) {
641654
foregroundPattern.dispose();
642655
}
643-
644-
gc.setForeground(tabOutlineColor);
645-
if (TAB_OUTLINE_WIDTH > 0) {
646-
gc.drawPolyline(tabOutlinePoints);
647-
}
648656
}
649657

650658
void drawUnselectedTab(int itemIndex, GC gc, Rectangle bounds, int state) {

0 commit comments

Comments
 (0)