mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-14 07:47:12 -06:00
TabbedPane: paint rounded tab area background for rounded cards (issue #717)
This commit is contained in:
@@ -12,6 +12,7 @@ FlatLaf Change Log
|
|||||||
https://www.formdev.com/flatlaf/native-libraries/.
|
https://www.formdev.com/flatlaf/native-libraries/.
|
||||||
- ScrollPane: Support rounded border. (PR #713)
|
- ScrollPane: Support rounded border. (PR #713)
|
||||||
- TabbedPane: Support vertical tabs. (PR #758, issue #633)
|
- TabbedPane: Support vertical tabs. (PR #758, issue #633)
|
||||||
|
- TabbedPane: Paint rounded tab area background for rounded cards. (issue #717)
|
||||||
- ToolBar: Added styling properties `separatorWidth` and `separatorColor`.
|
- ToolBar: Added styling properties `separatorWidth` and `separatorColor`.
|
||||||
|
|
||||||
#### Fixed bugs
|
#### Fixed bugs
|
||||||
|
|||||||
@@ -837,6 +837,8 @@ public class FlatTabbedPaneUI
|
|||||||
|
|
||||||
EventQueue.invokeLater( () -> {
|
EventQueue.invokeLater( () -> {
|
||||||
repaintRolloverPending = false;
|
repaintRolloverPending = false;
|
||||||
|
if( tabPane == null )
|
||||||
|
return;
|
||||||
|
|
||||||
int index = getRolloverTab();
|
int index = getRolloverTab();
|
||||||
if( index != oldIndex ) {
|
if( index != oldIndex ) {
|
||||||
@@ -1167,6 +1169,33 @@ public class FlatTabbedPaneUI
|
|||||||
|
|
||||||
paintContentBorder( g, tabPlacement, selectedIndex );
|
paintContentBorder( g, tabPlacement, selectedIndex );
|
||||||
|
|
||||||
|
// fill tabs area background
|
||||||
|
// - for rounded cards use partly rounded rectangle
|
||||||
|
if( tabsOpaque && !tabPane.isOpaque() && tabPane.getTabCount() > 0 ) {
|
||||||
|
Rectangle tr = null;
|
||||||
|
if( isScrollTabLayout() ) {
|
||||||
|
// scroll layout: use tab viewport bounds and add visible buttons
|
||||||
|
tr = tabViewport.getBounds();
|
||||||
|
for( Component child : tabPane.getComponents() ) {
|
||||||
|
if( child instanceof FlatTabAreaButton && child.isVisible() )
|
||||||
|
tr = tr.union( child.getBounds() );
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// wrap layout: use union of all tab rectangles
|
||||||
|
for( Rectangle r : rects )
|
||||||
|
tr = (tr != null) ? tr.union( r ) : r;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( tr != null ) {
|
||||||
|
g.setColor( tabPane.getBackground() );
|
||||||
|
|
||||||
|
if( (getTabType() == TAB_TYPE_CARD) && cardTabArc > 0 ) {
|
||||||
|
((Graphics2D)g).fill( createCardTabOuterPath( tabPlacement, tr.x, tr.y, tr.width, tr.height ) );
|
||||||
|
} else
|
||||||
|
g.fillRect( tr.x, tr.y, tr.width, tr.height );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if( !isScrollTabLayout() )
|
if( !isScrollTabLayout() )
|
||||||
paintTabArea( g, tabPlacement, selectedIndex );
|
paintTabArea( g, tabPlacement, selectedIndex );
|
||||||
}
|
}
|
||||||
@@ -1362,18 +1391,6 @@ debug*/
|
|||||||
{
|
{
|
||||||
boolean isCard = (getTabType() == TAB_TYPE_CARD);
|
boolean isCard = (getTabType() == TAB_TYPE_CARD);
|
||||||
|
|
||||||
// fill whole tab background if tab is rounded or has insets
|
|
||||||
if( (!isCard && tabArc > 0) ||
|
|
||||||
(isCard && cardTabArc > 0) ||
|
|
||||||
(!isCard && selectedInsets != null &&
|
|
||||||
(selectedInsets.top != 0 || selectedInsets.left != 0 ||
|
|
||||||
selectedInsets.bottom != 0 || selectedInsets.right != 0)) )
|
|
||||||
{
|
|
||||||
Color background = tabPane.getBackgroundAt( tabIndex );
|
|
||||||
g.setColor( FlatUIUtils.deriveColor( background, tabPane.getBackground() ) );
|
|
||||||
g.fillRect( x, y, w, h );
|
|
||||||
}
|
|
||||||
|
|
||||||
// apply insets
|
// apply insets
|
||||||
if( !isCard && selectedInsets != null ) {
|
if( !isCard && selectedInsets != null ) {
|
||||||
Insets insets = new Insets( 0, 0, 0, 0 );
|
Insets insets = new Insets( 0, 0, 0, 0 );
|
||||||
@@ -1387,14 +1404,16 @@ debug*/
|
|||||||
|
|
||||||
// paint tab background
|
// paint tab background
|
||||||
Color background = getTabBackground( tabPlacement, tabIndex, isSelected );
|
Color background = getTabBackground( tabPlacement, tabIndex, isSelected );
|
||||||
g.setColor( FlatUIUtils.deriveColor( background, tabPane.getBackground() ) );
|
if( background != tabPane.getBackground() ) {
|
||||||
if( !isCard && tabArc > 0 ) {
|
g.setColor( FlatUIUtils.deriveColor( background, tabPane.getBackground() ) );
|
||||||
float arc = scale( (float) tabArc ) / 2f;
|
if( !isCard && tabArc > 0 ) {
|
||||||
FlatUIUtils.paintSelection( (Graphics2D) g, x, y, w, h, null, arc, arc, arc, arc, 0 );
|
float arc = scale( (float) tabArc ) / 2f;
|
||||||
} else if( isCard && cardTabArc > 0 )
|
FlatUIUtils.paintSelection( (Graphics2D) g, x, y, w, h, null, arc, arc, arc, arc, 0 );
|
||||||
((Graphics2D)g).fill( createCardTabOuterPath( tabPlacement, x, y, w, h ) );
|
} else if( isCard && cardTabArc > 0 )
|
||||||
else
|
((Graphics2D)g).fill( createCardTabOuterPath( tabPlacement, x, y, w, h ) );
|
||||||
g.fillRect( x, y, w, h );
|
else
|
||||||
|
g.fillRect( x, y, w, h );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @since 2 */
|
/** @since 2 */
|
||||||
@@ -2340,17 +2359,6 @@ debug*/
|
|||||||
return FlatUIUtils.deriveColor( background, tabPane.getBackground() );
|
return FlatUIUtils.deriveColor( background, tabPane.getBackground() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void paint( Graphics g ) {
|
|
||||||
// fill button background
|
|
||||||
if( tabsOpaque || tabPane.isOpaque() ) {
|
|
||||||
g.setColor( tabPane.getBackground() );
|
|
||||||
g.fillRect( 0, 0, getWidth(), getHeight() );
|
|
||||||
}
|
|
||||||
|
|
||||||
super.paint( g );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void paintBackground( Graphics2D g ) {
|
protected void paintBackground( Graphics2D g ) {
|
||||||
// rotate button insets
|
// rotate button insets
|
||||||
|
|||||||
Reference in New Issue
Block a user