Skip to content

Commit cb3bd05

Browse files
committed
Change rendering of dirty indicator in tabs - using a circle
Tabs render dirty parts by showing a `*` in front of the tab name (e.g., in front of the file name. This information is hard to see by developers. This change introduces a graphical indicator on the close button to highlight dirty (unsaved) changes.
1 parent 68018d4 commit cb3bd05

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

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

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -884,15 +884,12 @@ void drawClose(GC gc, Rectangle closeRect, int closeImageState, boolean showDirt
884884
Color originalForeground = gc.getForeground();
885885
int state = closeImageState & (SWT.HOT | SWT.SELECTED | SWT.BACKGROUND);
886886
if (state == SWT.NONE) {
887-
if (showDirtyIndicator) drawDirtyIndicator(gc, closeRect, originalForeground, false);
888-
drawCloseButton(gc, closeRect, false);
887+
if (showDirtyIndicator)
888+
drawDirtyIndicator(gc, closeRect, originalForeground, false);
889+
else
890+
drawCloseButton(gc, closeRect, false);
889891
} else if (state == SWT.HOT || state == SWT.SELECTED) {
890-
if (showDirtyIndicator) {
891-
drawDirtyIndicator(gc, closeRect, originalForeground, true);
892-
drawCloseButton(gc, closeRect, false);
893-
} else {
894-
drawCloseButton(gc, closeRect, true);
895-
}
892+
drawCloseButton(gc, closeRect, true);
896893
} else if (state == SWT.BACKGROUND) {
897894
if (showDirtyIndicator)
898895
drawDirtyIndicator(gc, closeRect, originalForeground, false);
@@ -905,15 +902,17 @@ void drawClose(GC gc, Rectangle closeRect, int closeImageState, boolean showDirt
905902
}
906903

907904
private void drawDirtyIndicator(GC gc, Rectangle closeRect, Color originalForeground, boolean hot) {
908-
Color indicatorColor = hot ? getFillColor() : originalForeground;
909-
drawCloseBackground(gc, closeRect, indicatorColor);
905+
Color originalBackground = gc.getBackground();
906+
gc.setBackground(originalForeground);
907+
gc.fillOval(closeRect.x + 3, closeRect.y + 4, closeRect.width - 6, closeRect.height - 6);
908+
gc.setBackground(originalBackground);
910909
}
911910

912911
private void drawCloseBackground(GC gc, Rectangle closeRect, Color backgroundColor) {
913912
Color originalBackground = gc.getBackground();
914913
gc.setBackground(backgroundColor);
915914
gc.setForeground(originalBackground);
916-
gc.fillRoundRectangle(closeRect.x + 3, closeRect.y + 4, closeRect.width - 5, closeRect.height - 5, 4, 4);
915+
gc.fillRoundRectangle(closeRect.x + 1, closeRect.y + 2, closeRect.width - 2, closeRect.height - 2, 4, 4);
917916
gc.setBackground(originalBackground);
918917
}
919918

@@ -925,7 +924,7 @@ private void drawCloseButton(GC gc, Rectangle closeRect, boolean hot) {
925924
gc.setForeground(gc.getBackground());
926925
}
927926
// draw X with length of this constant
928-
final int lineLength = 6;
927+
final int lineLength = 9;
929928
int x = closeRect.x + Math.max(1, (closeRect.width-lineLength)/2);
930929
int y = closeRect.y + Math.max(1, (closeRect.height-lineLength)/2);
931930
y += parent.onBottom ? -1 : 1;

0 commit comments

Comments
 (0)