diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java index 418da72a628..c89e06e90a2 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java @@ -2379,9 +2379,16 @@ public void reskin(int flags) { } } +/** + * Sets the background color of the unselected tabs, clearing any background + * gradient set by {@link #setBackground(Color[], int[], boolean)}. + */ @Override public void setBackground (Color color) { super.setBackground(color); + gradientColors = null; + gradientPercents = null; + gradientVertical = false; updateBkImages(true); redraw(); } @@ -2501,7 +2508,8 @@ public void setBackground(Color[] colors, int[] percents, boolean vertical) { gradientPercents[i] = percents[i]; } gradientVertical = vertical; - setBackground(gradientColors[gradientColors.length-1]); + super.setBackground(gradientColors[gradientColors.length-1]); + updateBkImages(true); } // Refresh with the new settings diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_CTabFolder.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_CTabFolder.java index d0a0bafa065..6e9cbae3fb1 100644 --- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_CTabFolder.java +++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_CTabFolder.java @@ -1208,6 +1208,26 @@ public void test_moveItem_sameIndexIsNoOp() { assertEquals(2, ctabFolder.getSelectionIndex()); } +@Test +public void test_setBackgroundColorClearsGradient() { + createTabFolder(null); + Composite topRight = new Composite(ctabFolder, SWT.NONE); + topRight.setLayout(new FixedSizeLayout(16, 8)); + ctabFolder.setTopRight(topRight, SWT.RIGHT); + shell.setSize(400, 300); + shell.layout(true, true); + Color red = shell.getDisplay().getSystemColor(SWT.COLOR_RED); + Color blue = shell.getDisplay().getSystemColor(SWT.COLOR_BLUE); + + ctabFolder.setBackground(new Color[] { red, blue }, new int[] { 100 }, true); + assertNotNull(topRight.getBackgroundImage(), "gradient must be handed to the top right control"); + + ctabFolder.setBackground(blue); + assertNull(topRight.getBackgroundImage(), "solid background must replace the gradient"); + assertEquals(blue, topRight.getBackground()); + assertEquals(blue, ctabFolder.getBackground()); +} + @Test public void test_moveItem_errorCases() { createTabFolder(null, 3);