Skip to content

Commit 62054d9

Browse files
Adjust selection filling the curve for CTabFolder
When CTabFolder is selected there is a visible gap on top as well as on the top left where there is a curve (in RCP when theming is disabled). Also the image was too close to selection highlight which is adjusted here as well.
1 parent 136b375 commit 62054d9

File tree

1 file changed

+38
-2
lines changed

1 file changed

+38
-2
lines changed

bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolderRenderer.java

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,8 +1381,44 @@ void drawSelected(int itemIndex, GC gc, Rectangle bounds, int state ) {
13811381
// draw highlight marker of selected tab
13821382
if (parent.selectionHighlightBarThickness > 0 && parent.simple) {
13831383
Color previousColor = gc.getBackground();
1384-
gc.setBackground(item.getDisplay().getSystemColor(parent.shouldHighlight() ? SWT.COLOR_LIST_SELECTION : SWT.COLOR_WIDGET_DISABLED_FOREGROUND));
1385-
gc.fillRectangle(x + 1 /* outline */, parent.onBottom ? y + height - 1 - parent.selectionHighlightBarThickness : y + 1, width - 2 /*outline*/, parent.selectionHighlightBarThickness);
1384+
gc.setBackground(
1385+
item.getDisplay().getSystemColor(parent.shouldHighlight() ? SWT.COLOR_LIST_SELECTION
1386+
: SWT.COLOR_WIDGET_DISABLED_FOREGROUND));
1387+
1388+
int thickness = parent.selectionHighlightBarThickness;
1389+
1390+
if (parent.onBottom) {
1391+
gc.fillRectangle(x + 1, y + height - 1 - thickness, width - 2, thickness);
1392+
} else {
1393+
java.util.List<Integer> pts = new java.util.ArrayList<>();
1394+
1395+
// Left curve
1396+
pts.add(x); pts.add(y + 2);
1397+
pts.add(x + 1); pts.add(y + 1);
1398+
pts.add(x + 2); pts.add(y);
1399+
1400+
// Flat top across most of the tab
1401+
pts.add(x + width - 3); pts.add(y);
1402+
1403+
// Right curve
1404+
pts.add(x + width - 2); pts.add(y + 1);
1405+
pts.add(x + width - 1); pts.add(y + 2);
1406+
1407+
// Now append bottom edge points in reverse order (parallel to top)
1408+
for (int i = pts.size() - 2; i >= 0; i -= 2) {
1409+
int px = pts.get(i);
1410+
int py = pts.get(i + 1) + thickness;
1411+
pts.add(px);
1412+
pts.add(py);
1413+
}
1414+
1415+
// Convert to primitive int[]
1416+
int[] polygon = new int[pts.size()];
1417+
for (int i = 0; i < polygon.length; ++i) polygon[i] = pts.get(i);
1418+
1419+
gc.fillPolygon(polygon);
1420+
}
1421+
13861422
gc.setBackground(previousColor);
13871423
}
13881424

0 commit comments

Comments
 (0)