8335130: The test "javax/swing/plaf/synth/ComponentsOrientationSupport/5033822/bug5033822.java" fails because the background color of the tabs is displayed incorrectly.

Reviewed-by: achung, psadhukhan
This commit is contained in:
Abhishek Kumar 2024-08-09 05:09:27 +00:00
parent 0c1e9111d2
commit 9ab8c6b9ba
3 changed files with 41 additions and 40 deletions

View File

@ -935,25 +935,27 @@ class GTKPainter extends SynthPainter {
Graphics g,
int x, int y, int w, int h,
int tabIndex) {
Region id = context.getRegion();
int state = context.getComponentState();
int gtkState = ((state & SynthConstants.SELECTED) != 0 ?
SynthConstants.ENABLED : SynthConstants.PRESSED);
JTabbedPane pane = (JTabbedPane)context.getComponent();
int placement = pane.getTabPlacement();
if (UIManager.getBoolean("TabbedPane.tabsOpaque") || pane.isOpaque()) {
Region id = context.getRegion();
int state = context.getComponentState();
int gtkState = ((state & SynthConstants.SELECTED) != 0 ?
SynthConstants.ENABLED : SynthConstants.PRESSED);
int placement = pane.getTabPlacement();
// Fill the tab rect area
g.fillRect(x, y, w, h);
// Fill the tab rect area
g.fillRect(x, y, w, h);
synchronized (UNIXToolkit.GTK_LOCK) {
if (! ENGINE.paintCachedImage(g, x, y, w, h,
id, gtkState, placement, tabIndex)) {
PositionType side = POSITIONS[placement - 1];
ENGINE.startPainting(g, x, y, w, h,
id, gtkState, placement, tabIndex);
ENGINE.paintExtension(g, context, id, gtkState,
ShadowType.OUT, "tab", x, y, w, h, side, tabIndex);
ENGINE.finishPainting();
synchronized (UNIXToolkit.GTK_LOCK) {
if (!ENGINE.paintCachedImage(g, x, y, w, h,
id, gtkState, placement, tabIndex)) {
PositionType side = POSITIONS[placement - 1];
ENGINE.startPainting(g, x, y, w, h,
id, gtkState, placement, tabIndex);
ENGINE.paintExtension(g, context, id, gtkState,
ShadowType.OUT, "tab", x, y, w, h, side, tabIndex);
ENGINE.finishPainting();
}
}
}
}

View File

@ -2098,24 +2098,27 @@ class SynthPainterImpl extends SynthPainter {
public void paintTabbedPaneTabBackground(SynthContext context, Graphics g,
int x, int y, int w, int h,
int tabIndex, int orientation) {
if (orientation == JTabbedPane.LEFT) {
AffineTransform transform = new AffineTransform();
transform.scale(-1, 1);
transform.rotate(Math.toRadians(90));
paintBackground(context, g, y, x, h, w, transform);
} else if (orientation == JTabbedPane.RIGHT) {
AffineTransform transform = new AffineTransform();
transform.rotate(Math.toRadians(90));
transform.translate(0, -(x + w));
paintBackground(context, g, y, 0, h, w, transform);
} else if (orientation == JTabbedPane.BOTTOM) {
AffineTransform transform = new AffineTransform();
transform.translate(x,y);
transform.scale(1, -1);
transform.translate(0,-h);
paintBackground(context, g, 0, 0, w, h, transform);
} else {
paintBackground(context, g, x, y, w, h, null);
JTabbedPane pane = (JTabbedPane)context.getComponent();
if (UIManager.getBoolean("TabbedPane.tabsOpaque") || pane.isOpaque()) {
if (orientation == JTabbedPane.LEFT) {
AffineTransform transform = new AffineTransform();
transform.scale(-1, 1);
transform.rotate(Math.toRadians(90));
paintBackground(context, g, y, x, h, w, transform);
} else if (orientation == JTabbedPane.RIGHT) {
AffineTransform transform = new AffineTransform();
transform.rotate(Math.toRadians(90));
transform.translate(0, -(x + w));
paintBackground(context, g, y, 0, h, w, transform);
} else if (orientation == JTabbedPane.BOTTOM) {
AffineTransform transform = new AffineTransform();
transform.translate(x, y);
transform.scale(1, -1);
transform.translate(0, -h);
paintBackground(context, g, 0, 0, w, h, transform);
} else {
paintBackground(context, g, x, y, w, h, null);
}
}
}

View File

@ -127,7 +127,6 @@ public class SynthTabbedPaneUI extends BasicTabbedPaneUI
// Background color for unselected tabs
private Color unselectedBackground;
private boolean contentOpaque = true;
private boolean tabsOpaque = true;
/**
*
@ -156,7 +155,6 @@ public class SynthTabbedPaneUI extends BasicTabbedPaneUI
protected void installDefaults() {
selectColor = UIManager.getColor("TabbedPane.selected");
contentOpaque = UIManager.getBoolean("TabbedPane.contentOpaque");
tabsOpaque = UIManager.getBoolean("TabbedPane.tabsOpaque");
unselectedBackground = UIManager.getColor("TabbedPane.unselectedBackground");
updateStyle(tabPane);
}
@ -655,10 +653,8 @@ public class SynthTabbedPaneUI extends BasicTabbedPaneUI
g.setColor(getUnselectedBackgroundAt(tabIndex));
}
if (tabsOpaque || tabPane.isOpaque()) {
tabContext.getPainter().paintTabbedPaneTabBackground(tabContext, g,
x, y, width, height, tabIndex, placement);
}
tabContext.getPainter().paintTabbedPaneTabBackground(tabContext, g,
x, y, width, height, tabIndex, placement);
tabContext.getPainter().paintTabbedPaneTabBorder(tabContext, g,
x, y, width, height, tabIndex, placement);