Skip to content

Commit 108533e

Browse files
committed
Dim dirty tab bullet on inactive tabs in CTabFolderRenderer
The dirty indicator bullet inherited the tab text foreground color, which only varies between selected and unselected tabs in dark themes via CSS. In light themes the bullet looked identical on active and inactive tabs. Apply a reduced alpha (140) when drawing the bullet on unselected tabs so the active/inactive distinction works in any theme without CSS changes. Fixes #3278
1 parent 17667a8 commit 108533e

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -692,17 +692,17 @@ void drawBody(GC gc, Rectangle bounds, int state) {
692692
}
693693

694694
void drawClose(GC gc, Rectangle closeRect, int closeImageState) {
695-
drawClose(gc, closeRect, closeImageState, false);
695+
drawClose(gc, closeRect, closeImageState, false, false);
696696
}
697697

698-
void drawClose(GC gc, Rectangle closeRect, int closeImageState, boolean showDirtyIndicator) {
698+
void drawClose(GC gc, Rectangle closeRect, int closeImageState, boolean showDirtyIndicator, boolean selected) {
699699
if (closeRect.width == 0 || closeRect.height == 0) return;
700700

701701
// When dirty and not hovered/pressed, draw bullet instead of X
702702
if (showDirtyIndicator) {
703703
int maskedState = closeImageState & (SWT.HOT | SWT.SELECTED | SWT.BACKGROUND);
704704
if (maskedState != SWT.HOT && maskedState != SWT.SELECTED) {
705-
drawDirtyIndicator(gc, closeRect);
705+
drawDirtyIndicator(gc, closeRect, selected);
706706
return;
707707
}
708708
}
@@ -737,13 +737,18 @@ void drawClose(GC gc, Rectangle closeRect, int closeImageState, boolean showDirt
737737
gc.setForeground(originalForeground);
738738
}
739739

740-
private void drawDirtyIndicator(GC gc, Rectangle closeRect) {
740+
private void drawDirtyIndicator(GC gc, Rectangle closeRect, boolean selected) {
741741
int diameter = 8;
742742
int x = closeRect.x + (closeRect.width - diameter) / 2;
743743
int y = closeRect.y + (closeRect.height - diameter) / 2;
744744
Color originalBackground = gc.getBackground();
745+
int originalAlpha = gc.getAlpha();
745746
gc.setBackground(gc.getForeground());
747+
if (!selected) {
748+
gc.setAlpha(140);
749+
}
746750
gc.fillOval(x, y, diameter, diameter);
751+
gc.setAlpha(originalAlpha);
747752
gc.setBackground(originalBackground);
748753
}
749754

@@ -1142,7 +1147,7 @@ void drawSelected(int itemIndex, GC gc, Rectangle bounds, int state ) {
11421147
}
11431148
}
11441149
if (shouldAllocateCloseRect(item)) {
1145-
drawClose(gc, item.closeRect, item.closeImageState, shouldDrawDirtyIndicator(item));
1150+
drawClose(gc, item.closeRect, item.closeImageState, shouldDrawDirtyIndicator(item), true);
11461151
}
11471152
}
11481153
}
@@ -1317,7 +1322,7 @@ void drawUnselected(int index, GC gc, Rectangle bounds, int state) {
13171322
}
13181323
// draw close or dirty indicator
13191324
if (shouldAllocateCloseRect(item)) {
1320-
drawClose(gc, item.closeRect, item.closeImageState, shouldDrawDirtyIndicator(item));
1325+
drawClose(gc, item.closeRect, item.closeImageState, shouldDrawDirtyIndicator(item), false);
13211326
}
13221327
}
13231328
}

0 commit comments

Comments
 (0)