mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-14 07:47:12 -06:00
TabbedPane: ActiveTabBorder: Added handling for thick content separators and 0 height selection indicator. Fixed scaling issues (presumably).
This commit is contained in:
@@ -640,21 +640,22 @@ public class FlatTabbedPaneUI
|
|||||||
if ( clientPropertyBoolean( tabPane, TABBED_PANE_ACTIVE_TAB_BORDER, activeTabBorder ) &&
|
if ( clientPropertyBoolean( tabPane, TABBED_PANE_ACTIVE_TAB_BORDER, activeTabBorder ) &&
|
||||||
clientPropertyBoolean( tabPane, TABBED_PANE_SHOW_CONTENT_SEPARATOR, true ))
|
clientPropertyBoolean( tabPane, TABBED_PANE_SHOW_CONTENT_SEPARATOR, true ))
|
||||||
{
|
{
|
||||||
|
int csh = scale(contentSeparatorHeight);
|
||||||
Rectangle bounds = getContentBorderBounds(tabPane.getTabPlacement());
|
Rectangle bounds = getContentBorderBounds(tabPane.getTabPlacement());
|
||||||
Rectangle r;
|
Rectangle r;
|
||||||
switch (tabPane.getTabPlacement()) {
|
switch (tabPane.getTabPlacement()) {
|
||||||
default:
|
default:
|
||||||
case TOP:
|
case TOP:
|
||||||
r = new Rectangle( bounds.x, bounds.y, bounds.width, contentSeparatorHeight);
|
r = new Rectangle( bounds.x, bounds.y, bounds.width, csh);
|
||||||
break;
|
break;
|
||||||
case BOTTOM:
|
case BOTTOM:
|
||||||
r = new Rectangle( bounds.x, bounds.y + bounds.height - contentSeparatorHeight, bounds.width, contentSeparatorHeight);
|
r = new Rectangle( bounds.x, bounds.y + bounds.height - csh, bounds.width, csh);
|
||||||
break;
|
break;
|
||||||
case LEFT:
|
case LEFT:
|
||||||
r = new Rectangle( bounds.x, bounds.y, contentSeparatorHeight, bounds.height);
|
r = new Rectangle( bounds.x, bounds.y, csh, bounds.height);
|
||||||
break;
|
break;
|
||||||
case RIGHT:
|
case RIGHT:
|
||||||
r = new Rectangle( bounds.x + bounds.width - contentSeparatorHeight, bounds.y, contentSeparatorHeight, bounds.height);
|
r = new Rectangle( bounds.x + bounds.width - csh, bounds.y, csh, bounds.height);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
tabPane.repaint(r);
|
tabPane.repaint(r);
|
||||||
@@ -1037,7 +1038,7 @@ public class FlatTabbedPaneUI
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void paintActiveTabBorder( Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h) {
|
protected void paintActiveTabBorder( Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h) {
|
||||||
float borderWidth = UIScale.scale( 1f );
|
float borderWidth = scale(contentSeparatorHeight);
|
||||||
g.setColor( (tabSeparatorColor != null) ? tabSeparatorColor : contentAreaColor );
|
g.setColor( (tabSeparatorColor != null) ? tabSeparatorColor : contentAreaColor );
|
||||||
|
|
||||||
switch( tabPlacement ) {
|
switch( tabPlacement ) {
|
||||||
@@ -1053,6 +1054,25 @@ public class FlatTabbedPaneUI
|
|||||||
((Graphics2D)g).fill( new Rectangle2D.Float( x, y + h - borderWidth, w, borderWidth) );
|
((Graphics2D)g).fill( new Rectangle2D.Float( x, y + h - borderWidth, w, borderWidth) );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tabSelectionHeight <= 0) {
|
||||||
|
//If there is no tab selection indicator, paint a top border as well
|
||||||
|
switch( tabPlacement ) {
|
||||||
|
default:
|
||||||
|
case TOP:
|
||||||
|
((Graphics2D)g).fill( new Rectangle2D.Float( x, y, w, borderWidth) );
|
||||||
|
break;
|
||||||
|
case BOTTOM:
|
||||||
|
((Graphics2D)g).fill( new Rectangle2D.Float( x, y + h - borderWidth, w, borderWidth) );
|
||||||
|
break;
|
||||||
|
case LEFT:
|
||||||
|
((Graphics2D)g).fill( new Rectangle2D.Float( x, y, borderWidth, h) );
|
||||||
|
break;
|
||||||
|
case RIGHT:
|
||||||
|
((Graphics2D)g).fill( new Rectangle2D.Float( x + w - borderWidth, y, borderWidth, h) );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void paintTabCloseButton( Graphics g, int tabIndex, int x, int y, int w, int h ) {
|
protected void paintTabCloseButton( Graphics g, int tabIndex, int x, int y, int w, int h ) {
|
||||||
@@ -1200,6 +1220,8 @@ public class FlatTabbedPaneUI
|
|||||||
int w = contentBorderBounds.width;
|
int w = contentBorderBounds.width;
|
||||||
int h = contentBorderBounds.height;
|
int h = contentBorderBounds.height;
|
||||||
|
|
||||||
|
int csh = scale( contentSeparatorHeight );
|
||||||
|
|
||||||
// compute insets for separator or full border
|
// compute insets for separator or full border
|
||||||
boolean hasFullBorder = clientPropertyBoolean( tabPane, TABBED_PANE_HAS_FULL_BORDER, this.hasFullBorder );
|
boolean hasFullBorder = clientPropertyBoolean( tabPane, TABBED_PANE_HAS_FULL_BORDER, this.hasFullBorder );
|
||||||
int sh = scale( contentSeparatorHeight * 100 ); // multiply by 100 because rotateInsets() does not use floats
|
int sh = scale( contentSeparatorHeight * 100 ); // multiply by 100 because rotateInsets() does not use floats
|
||||||
@@ -1234,28 +1256,28 @@ public class FlatTabbedPaneUI
|
|||||||
switch( tabPlacement ) {
|
switch( tabPlacement ) {
|
||||||
default:
|
default:
|
||||||
case TOP:
|
case TOP:
|
||||||
gapX = x + ax + 1 + (-scrollOffsetX + tabViewportOffsetX);
|
gapX = x + ax + csh + (-scrollOffsetX + tabViewportOffsetX);
|
||||||
gapY = y;
|
gapY = y;
|
||||||
gapW = aw - 2;
|
gapW = aw - csh*2;
|
||||||
gapH = contentSeparatorHeight;
|
gapH = csh;
|
||||||
break;
|
break;
|
||||||
case BOTTOM:
|
case BOTTOM:
|
||||||
gapX = x + ax + 1 + (-scrollOffsetX + tabViewportOffsetX);
|
gapX = x + ax + csh + (-scrollOffsetX + tabViewportOffsetX);
|
||||||
gapY = h - contentSeparatorHeight;
|
gapY = h - csh;
|
||||||
gapW = aw - 2;
|
gapW = aw - csh*2;
|
||||||
gapH = contentSeparatorHeight;
|
gapH = csh;
|
||||||
break;
|
break;
|
||||||
case LEFT:
|
case LEFT:
|
||||||
gapX = x;
|
gapX = x;
|
||||||
gapY = y + ay + 1 + (-scrollOffsetY + tabViewportOffsetY);
|
gapY = y + ay + csh + (-scrollOffsetY + tabViewportOffsetY);
|
||||||
gapW = contentSeparatorHeight;
|
gapW = csh;
|
||||||
gapH = ah - 2;
|
gapH = ah - csh*2;
|
||||||
break;
|
break;
|
||||||
case RIGHT:
|
case RIGHT:
|
||||||
gapX = w - contentSeparatorHeight;
|
gapX = w - csh;
|
||||||
gapY = y + ay + 1 + (-scrollOffsetY + tabViewportOffsetY);
|
gapY = y + ay + csh + (-scrollOffsetY + tabViewportOffsetY);
|
||||||
gapW = contentSeparatorHeight;
|
gapW = csh;
|
||||||
gapH = ah - 2;
|
gapH = ah - csh*2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1283,9 +1305,6 @@ public class FlatTabbedPaneUI
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ((Graphics2D)g).fill( new Rectangle2D.Float( x, y, tabViewport.getX() - x, contentSeparatorHeight) );
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
area.add( new Area( new Rectangle2D.Float(x, y, w, h) ) );
|
area.add( new Area( new Rectangle2D.Float(x, y, w, h) ) );
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user