Skip to content

Commit 5065068

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 63d5582 commit 5065068

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

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

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
*******************************************************************************/
1515
package org.eclipse.swt.custom;
1616

17+
import java.util.*;
18+
1719
import org.eclipse.swt.*;
1820
import org.eclipse.swt.graphics.*;
1921
import org.eclipse.swt.widgets.*;
@@ -1380,10 +1382,23 @@ void drawSelected(int itemIndex, GC gc, Rectangle bounds, int state ) {
13801382

13811383
// draw highlight marker of selected tab
13821384
if (parent.selectionHighlightBarThickness > 0 && parent.simple) {
1383-
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);
1386-
gc.setBackground(previousColor);
1385+
int thickness = parent.selectionHighlightBarThickness;
1386+
boolean onBottom = parent.onBottom;
1387+
boolean highlight = parent.shouldHighlight();
1388+
1389+
Color oldBackground = gc.getBackground();
1390+
Color highlightColor = item.getDisplay().getSystemColor(
1391+
highlight ? SWT.COLOR_LIST_SELECTION : SWT.COLOR_WIDGET_DISABLED_FOREGROUND);
1392+
gc.setBackground(highlightColor);
1393+
1394+
int bottomY = y + height - 1;
1395+
int highlightY = onBottom ? bottomY - thickness : thickness + 1;
1396+
1397+
int[] shape2 = Arrays.copyOf(shape, shape.length);
1398+
// Update Y coordinates in shape to apply highlight thickness
1399+
shape2[1] = shape2[3] = shape2[shape2.length - 1] = shape2[shape2.length - 3] = highlightY;
1400+
gc.fillPolygon(shape2);
1401+
gc.setBackground(oldBackground);
13871402
}
13881403

13891404
// draw outline
@@ -1642,7 +1657,7 @@ void drawUnselected(int index, GC gc, Rectangle bounds, int state) {
16421657
if (imageBounds.width < maxImageWidth) {
16431658
int imageX = xDraw;
16441659
int imageHeight = imageBounds.height;
1645-
int imageY = y + (height - imageHeight) / 2;
1660+
int imageY = 1 + y + (height - imageHeight) / 2;
16461661
imageY += parent.onBottom ? -1 : 1;
16471662
int imageWidth = imageBounds.width * imageHeight / imageBounds.height;
16481663
gc.drawImage(image, imageX, imageY, imageWidth, imageHeight);

0 commit comments

Comments
 (0)