Skip to content

Commit 3419b9f

Browse files
vogellaclaude
andcommitted
Further simplify CTabFolderRenderer after curved tab removal
- Remove antialias() infrastructure: method, createAntialiasColors(), disposeAntialiasColors(), call sites, and the four color fields (selectedOuterColor, selectedInnerColor, tabAreaColor, lastBorderColor). antialias() was already a no-op since it returned early for simple tabs, which is now always the case. - Remove useEllipses() method and inline its constant true value: collapse the ternary in shortenText() and remove the dead truncation-without- ellipsis branch in computeSize(). useEllipses() returned parent.simple (always true) to decide whether to append "...". - Update @deprecated since version to 2026-06 for getSimple()/setSimple(). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent a4fef30 commit 3419b9f

File tree

2 files changed

+6
-89
lines changed

2 files changed

+6
-89
lines changed

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,7 +1251,7 @@ public int getSelectionIndex() {
12511251
* @since 3.0
12521252
* @deprecated Curved tabs are no longer supported.
12531253
*/
1254-
@Deprecated(forRemoval = true, since = "2026-04")
1254+
@Deprecated(forRemoval = true, since = "2026-06")
12551255
public boolean getSimple() {
12561256
checkWidget();
12571257
return simple;
@@ -2369,7 +2369,6 @@ public void reskin(int flags) {
23692369
@Override
23702370
public void setBackground (Color color) {
23712371
super.setBackground(color);
2372-
renderer.createAntialiasColors(); //TODO: need better caching strategy
23732372
updateBkImages(true);
23742373
redraw();
23752374
}
@@ -2498,7 +2497,6 @@ public void setBackground(Color[] colors, int[] percents, boolean vertical) {
24982497
@Override
24992498
public void setBackgroundImage(Image image) {
25002499
super.setBackgroundImage(image);
2501-
renderer.createAntialiasColors(); //TODO: need better caching strategy
25022500
redraw();
25032501
}
25042502
/**
@@ -3288,7 +3286,6 @@ public void setSelectionBackground (Color color) {
32883286
if (selectionBackground == color) return;
32893287
if (color == null) color = getDisplay().getSystemColor(SELECTION_BACKGROUND);
32903288
selectionBackground = color;
3291-
renderer.createAntialiasColors(); //TODO: need better caching strategy
32923289
if (selectedIndex > -1) redraw();
32933290
}
32943291
/**
@@ -3449,7 +3446,6 @@ public void setSelectionBackground(Image image) {
34493446
selectionGradientPercents = null;
34503447
}
34513448
selectionBgImage = image;
3452-
renderer.createAntialiasColors(); //TODO: need better caching strategy
34533449
if (selectedIndex > -1) redraw();
34543450
}
34553451
/**
@@ -3504,7 +3500,7 @@ public void setSelectionBarThickness(int thickness) {
35043500
* @since 3.0
35053501
* @deprecated Curved tabs are no longer supported.
35063502
*/
3507-
@Deprecated(forRemoval = true, since = "2026-04")
3503+
@Deprecated(forRemoval = true, since = "2026-06")
35083504
public void setSimple(boolean simple) {
35093505
checkWidget();
35103506
}

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

Lines changed: 4 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,6 @@ public class CTabFolderRenderer {
3333
protected CTabFolder parent;
3434

3535
Color fillColor;
36-
/* Selected item appearance */
37-
/* Colors for anti-aliasing */
38-
Color selectedOuterColor = null;
39-
Color selectedInnerColor = null;
40-
Color tabAreaColor = null;
41-
/*
42-
* Border color that was used in computing the cached anti-alias Colors.
43-
* We have to recompute the colors if the border color changes
44-
*/
45-
Color lastBorderColor = null;
4636

4737
private Font chevronFont = null;
4838

@@ -163,9 +153,6 @@ protected CTabFolderRenderer(CTabFolder parent) {
163153
this.parent = parent;
164154
}
165155

166-
void antialias (int[] shape, Color innerColor, Color outerColor, GC gc){
167-
}
168-
169156
/**
170157
* Returns the preferred size of a part.
171158
* <p>
@@ -255,14 +242,9 @@ protected Point computeSize (int part, int state, GC gc, int wHint, int hHint) {
255242
int minChars = parent.minChars;
256243
text = minChars == 0 ? null : item.getText();
257244
if (text != null && text.length() > minChars) {
258-
if (useEllipses()) {
259-
int end = minChars < ELLIPSIS.length() + 1 ? minChars : minChars - ELLIPSIS.length();
260-
text = text.substring(0, end);
261-
if (minChars > ELLIPSIS.length() + 1) text += ELLIPSIS;
262-
} else {
263-
int end = minChars;
264-
text = text.substring(0, end);
265-
}
245+
int end = minChars < ELLIPSIS.length() + 1 ? minChars : minChars - ELLIPSIS.length();
246+
text = text.substring(0, end);
247+
if (minChars > ELLIPSIS.length() + 1) text += ELLIPSIS;
266248
}
267249
} else {
268250
text = item.getText();
@@ -404,48 +386,6 @@ protected Rectangle computeTrim (int part, int state, int x, int y, int width, i
404386
return new Rectangle(x, y, width, height);
405387
}
406388

407-
void createAntialiasColors() {
408-
disposeAntialiasColors();
409-
lastBorderColor = parent.getDisplay().getSystemColor(BORDER1_COLOR);
410-
RGB lineRGB = lastBorderColor.getRGB();
411-
/* compute the selected color */
412-
RGB innerRGB = parent.selectionBackground.getRGB();
413-
if (parent.selectionBgImage != null ||
414-
(parent.selectionGradientColors != null && parent.selectionGradientColors.length > 1)) {
415-
innerRGB = null;
416-
}
417-
RGB outerRGB = parent.getBackground().getRGB();
418-
if (parent.gradientColors != null && parent.gradientColors.length > 1) {
419-
outerRGB = null;
420-
}
421-
if (outerRGB != null) {
422-
RGB from = lineRGB;
423-
RGB to = outerRGB;
424-
int red = from.red + 2*(to.red - from.red)/3;
425-
int green = from.green + 2*(to.green - from.green)/3;
426-
int blue = from.blue + 2*(to.blue - from.blue)/3;
427-
selectedOuterColor = new Color(red, green, blue);
428-
}
429-
if (innerRGB != null) {
430-
RGB from = lineRGB;
431-
RGB to = innerRGB;
432-
int red = from.red + 2*(to.red - from.red)/3;
433-
int green = from.green + 2*(to.green - from.green)/3;
434-
int blue = from.blue + 2*(to.blue - from.blue)/3;
435-
selectedInnerColor = new Color(red, green, blue);
436-
}
437-
/* compute the tabArea color */
438-
outerRGB = parent.getParent().getBackground().getRGB();
439-
if (outerRGB != null) {
440-
RGB from = lineRGB;
441-
RGB to = outerRGB;
442-
int red = from.red + 2*(to.red - from.red)/3;
443-
int green = from.green + 2*(to.green - from.green)/3;
444-
int blue = from.blue + 2*(to.blue - from.blue)/3;
445-
tabAreaColor = new Color(red, green, blue);
446-
}
447-
}
448-
449389
/**
450390
* Dispose of any operating system resources associated with
451391
* the renderer. Called by the CTabFolder parent upon receiving
@@ -454,8 +394,6 @@ void createAntialiasColors() {
454394
* @since 3.6
455395
*/
456396
protected void dispose() {
457-
disposeAntialiasColors();
458-
459397
fillColor = null;
460398

461399
if (chevronFont != null) {
@@ -464,10 +402,6 @@ protected void dispose() {
464402
}
465403
}
466404

467-
void disposeAntialiasColors() {
468-
tabAreaColor = selectedInnerColor = selectedOuterColor = null;
469-
}
470-
471405
/**
472406
* Draw a specified <code>part</code> of the CTabFolder using the provided <code>bounds</code> and <code>GC</code>.
473407
* <p>The valid CTabFolder <code>part</code> constants are:
@@ -1188,8 +1122,6 @@ void drawSelected(int itemIndex, GC gc, Rectangle bounds, int state ) {
11881122
if (shape[2*i + 1] == y + height + 1) shape[2*i + 1] -= 1;
11891123
}
11901124
Color borderColor = parent.getDisplay().getSystemColor(BORDER1_COLOR);
1191-
if (! borderColor.equals(lastBorderColor)) createAntialiasColors();
1192-
antialias(shape, selectedInnerColor, selectedOuterColor, gc);
11931125
gc.setForeground(borderColor);
11941126
gc.drawPolyline(shape);
11951127

@@ -1384,8 +1316,6 @@ void drawTabArea(GC gc, Rectangle bounds, int state) {
13841316

13851317
// Draw border line
13861318
if (borderLeft > 0) {
1387-
if (! borderColor.equals(lastBorderColor)) createAntialiasColors();
1388-
antialias(shape, null, tabAreaColor, gc);
13891319
gc.setForeground(borderColor);
13901320
gc.drawPolyline(shape);
13911321
}
@@ -1495,9 +1425,7 @@ void resetChevronFont() {
14951425
}
14961426

14971427
String shortenText(GC gc, String text, int width) {
1498-
return useEllipses()
1499-
? shortenText(gc, text, width, ELLIPSIS)
1500-
: shortenText(gc, text, width, ""); //$NON-NLS-1$
1428+
return shortenText(gc, text, width, ELLIPSIS);
15011429
}
15021430

15031431
String shortenText(GC gc, String text, int width, String ellipses) {
@@ -1519,11 +1447,4 @@ String shortenText(GC gc, String text, int width, String ellipses) {
15191447
return end == 0 ? text.substring(0, 1) : text + ellipses;
15201448
}
15211449

1522-
/*
1523-
* Return whether to use ellipses or just truncate labels
1524-
*/
1525-
boolean useEllipses() {
1526-
return true;
1527-
}
1528-
15291450
}

0 commit comments

Comments
 (0)