Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2379,8 +2379,19 @@ 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) {
gradientColors = null;
gradientPercents = null;
gradientVertical = false;
Comment on lines +2388 to +2390

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than this one, this PR is good to go.

applyBackground(color);
}

private void applyBackground(Color color) {
super.setBackground(color);
updateBkImages(true);
redraw();
Expand Down Expand Up @@ -2501,7 +2512,7 @@ public void setBackground(Color[] colors, int[] percents, boolean vertical) {
gradientPercents[i] = percents[i];
}
gradientVertical = vertical;
setBackground(gradientColors[gradientColors.length-1]);
applyBackground(gradientColors[gradientColors.length-1]);
}

// Refresh with the new settings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading