mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-12 23:07:15 -06:00
TabbedPane: option to disable tab run rotation in wrap layout (issue #574)
This commit is contained in:
@@ -3,6 +3,11 @@ FlatLaf Change Log
|
|||||||
|
|
||||||
## 2.5-SNAPSHOT
|
## 2.5-SNAPSHOT
|
||||||
|
|
||||||
|
#### New features and improvements
|
||||||
|
|
||||||
|
- TabbedPane: New option to disable tab run rotation in wrap layout. Set UI
|
||||||
|
value `TabbedPane.rotateTabRuns` to `false`. (issue #574)
|
||||||
|
|
||||||
#### Fixed bugs
|
#### Fixed bugs
|
||||||
|
|
||||||
- Fixed missing UI value `MenuItem.acceleratorDelimiter` on macOS. (was `null`,
|
- Fixed missing UI value `MenuItem.acceleratorDelimiter` on macOS. (was `null`,
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ import com.formdev.flatlaf.util.UIScale;
|
|||||||
* @uiDefault TabbedPane.showTabSeparators boolean
|
* @uiDefault TabbedPane.showTabSeparators boolean
|
||||||
* @uiDefault TabbedPane.tabSeparatorsFullHeight boolean
|
* @uiDefault TabbedPane.tabSeparatorsFullHeight boolean
|
||||||
* @uiDefault TabbedPane.hasFullBorder boolean
|
* @uiDefault TabbedPane.hasFullBorder boolean
|
||||||
* @uiDefault TabbedPane.activeTabBorder boolean
|
* @uiDefault TabbedPane.rotateTabRuns boolean
|
||||||
*
|
*
|
||||||
* @uiDefault TabbedPane.tabLayoutPolicy String wrap (default) or scroll
|
* @uiDefault TabbedPane.tabLayoutPolicy String wrap (default) or scroll
|
||||||
* @uiDefault TabbedPane.tabType String underlined (default) or card
|
* @uiDefault TabbedPane.tabType String underlined (default) or card
|
||||||
@@ -220,6 +220,7 @@ public class FlatTabbedPaneUI
|
|||||||
@Styleable protected boolean tabSeparatorsFullHeight;
|
@Styleable protected boolean tabSeparatorsFullHeight;
|
||||||
@Styleable protected boolean hasFullBorder;
|
@Styleable protected boolean hasFullBorder;
|
||||||
@Styleable protected boolean tabsOpaque = true;
|
@Styleable protected boolean tabsOpaque = true;
|
||||||
|
/** @since 2.5 */ @Styleable protected boolean rotateTabRuns = true;
|
||||||
|
|
||||||
@Styleable(type=String.class) private int tabType;
|
@Styleable(type=String.class) private int tabType;
|
||||||
@Styleable(type=String.class) private int tabsPopupPolicy;
|
@Styleable(type=String.class) private int tabsPopupPolicy;
|
||||||
@@ -342,6 +343,7 @@ public class FlatTabbedPaneUI
|
|||||||
tabSeparatorsFullHeight = UIManager.getBoolean( "TabbedPane.tabSeparatorsFullHeight" );
|
tabSeparatorsFullHeight = UIManager.getBoolean( "TabbedPane.tabSeparatorsFullHeight" );
|
||||||
hasFullBorder = UIManager.getBoolean( "TabbedPane.hasFullBorder" );
|
hasFullBorder = UIManager.getBoolean( "TabbedPane.hasFullBorder" );
|
||||||
tabsOpaque = UIManager.getBoolean( "TabbedPane.tabsOpaque" );
|
tabsOpaque = UIManager.getBoolean( "TabbedPane.tabsOpaque" );
|
||||||
|
rotateTabRuns = FlatUIUtils.getUIBoolean( "TabbedPane.rotateTabRuns", true );
|
||||||
|
|
||||||
tabType = parseTabType( UIManager.getString( "TabbedPane.tabType" ) );
|
tabType = parseTabType( UIManager.getString( "TabbedPane.tabType" ) );
|
||||||
tabsPopupPolicy = parseTabsPopupPolicy( UIManager.getString( "TabbedPane.tabsPopupPolicy" ) );
|
tabsPopupPolicy = parseTabsPopupPolicy( UIManager.getString( "TabbedPane.tabsPopupPolicy" ) );
|
||||||
@@ -1092,7 +1094,7 @@ public class FlatTabbedPaneUI
|
|||||||
|
|
||||||
// paint selection indicator
|
// paint selection indicator
|
||||||
if( isSelected )
|
if( isSelected )
|
||||||
paintTabSelection( g, tabPlacement, x, y, w, h );
|
paintTabSelection( g, tabPlacement, tabIndex, x, y, w, h );
|
||||||
|
|
||||||
if( tabPane.getTabComponentAt( tabIndex ) != null )
|
if( tabPane.getTabComponentAt( tabIndex ) != null )
|
||||||
return;
|
return;
|
||||||
@@ -1281,14 +1283,19 @@ public class FlatTabbedPaneUI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void paintTabSelection( Graphics g, int tabPlacement, int x, int y, int w, int h ) {
|
protected void paintTabSelection( Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h ) {
|
||||||
g.setColor( tabPane.isEnabled()
|
g.setColor( tabPane.isEnabled()
|
||||||
? (isTabbedPaneOrChildFocused() ? underlineColor : inactiveUnderlineColor)
|
? (isTabbedPaneOrChildFocused() ? underlineColor : inactiveUnderlineColor)
|
||||||
: disabledUnderlineColor );
|
: disabledUnderlineColor );
|
||||||
|
|
||||||
// paint underline selection
|
// paint underline selection
|
||||||
boolean atBottom = (getTabType() != TAB_TYPE_CARD);
|
boolean atBottom = (getTabType() != TAB_TYPE_CARD);
|
||||||
Insets contentInsets = getContentBorderInsets( tabPlacement );
|
Insets contentInsets = atBottom
|
||||||
|
? ((!rotateTabRuns && runCount > 1 && !isScrollTabLayout() && getRunForTab( tabPane.getTabCount(), tabIndex ) > 0)
|
||||||
|
? new Insets( 0, 0, 0, 0 )
|
||||||
|
: getContentBorderInsets( tabPlacement ))
|
||||||
|
: null;
|
||||||
|
|
||||||
int tabSelectionHeight = scale( atBottom ? this.tabSelectionHeight : cardTabSelectionHeight );
|
int tabSelectionHeight = scale( atBottom ? this.tabSelectionHeight : cardTabSelectionHeight );
|
||||||
int sx, sy;
|
int sx, sy;
|
||||||
switch( tabPlacement ) {
|
switch( tabPlacement ) {
|
||||||
@@ -1447,7 +1454,7 @@ public class FlatTabbedPaneUI
|
|||||||
else
|
else
|
||||||
g.clipRect( 0, vr.y, tabPane.getWidth(), vr.height );
|
g.clipRect( 0, vr.y, tabPane.getWidth(), vr.height );
|
||||||
|
|
||||||
paintTabSelection( g, tabPlacement, tabRect.x, tabRect.y, tabRect.width, tabRect.height );
|
paintTabSelection( g, tabPlacement, selectedIndex, tabRect.x, tabRect.y, tabRect.width, tabRect.height );
|
||||||
g.setClip( oldClip );
|
g.setClip( oldClip );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1600,6 +1607,11 @@ public class FlatTabbedPaneUI
|
|||||||
super.getTabRunCount( tabPane );
|
super.getTabRunCount( tabPane );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean shouldRotateTabRuns( int tabPlacement ) {
|
||||||
|
return rotateTabRuns;
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isLastInRun( int tabIndex ) {
|
private boolean isLastInRun( int tabIndex ) {
|
||||||
int run = getRunForTab( tabPane.getTabCount(), tabIndex );
|
int run = getRunForTab( tabPane.getTabCount(), tabIndex );
|
||||||
return lastTabInRun( tabPane.getTabCount(), run ) == tabIndex;
|
return lastTabInRun( tabPane.getTabCount(), run ) == tabIndex;
|
||||||
|
|||||||
@@ -722,6 +722,7 @@ public class TestFlatStyleableInfo
|
|||||||
"tabSeparatorsFullHeight", boolean.class,
|
"tabSeparatorsFullHeight", boolean.class,
|
||||||
"hasFullBorder", boolean.class,
|
"hasFullBorder", boolean.class,
|
||||||
"tabsOpaque", boolean.class,
|
"tabsOpaque", boolean.class,
|
||||||
|
"rotateTabRuns", boolean.class,
|
||||||
|
|
||||||
"tabType", String.class,
|
"tabType", String.class,
|
||||||
"tabsPopupPolicy", String.class,
|
"tabsPopupPolicy", String.class,
|
||||||
|
|||||||
@@ -739,6 +739,7 @@ public class TestFlatStyleableValue
|
|||||||
testBoolean( c, ui, "tabSeparatorsFullHeight", false );
|
testBoolean( c, ui, "tabSeparatorsFullHeight", false );
|
||||||
testBoolean( c, ui, "hasFullBorder", false );
|
testBoolean( c, ui, "hasFullBorder", false );
|
||||||
testBoolean( c, ui, "tabsOpaque", false );
|
testBoolean( c, ui, "tabsOpaque", false );
|
||||||
|
testBoolean( c, ui, "rotateTabRuns", false );
|
||||||
|
|
||||||
testString( c, ui, "tabType", "card" );
|
testString( c, ui, "tabType", "card" );
|
||||||
testString( c, ui, "tabsPopupPolicy", "asNeeded" );
|
testString( c, ui, "tabsPopupPolicy", "asNeeded" );
|
||||||
|
|||||||
@@ -891,6 +891,7 @@ public class TestFlatStyling
|
|||||||
ui.applyStyle( "tabSeparatorsFullHeight: false" );
|
ui.applyStyle( "tabSeparatorsFullHeight: false" );
|
||||||
ui.applyStyle( "hasFullBorder: false" );
|
ui.applyStyle( "hasFullBorder: false" );
|
||||||
ui.applyStyle( "tabsOpaque: false" );
|
ui.applyStyle( "tabsOpaque: false" );
|
||||||
|
ui.applyStyle( "rotateTabRuns: false" );
|
||||||
|
|
||||||
ui.applyStyle( "tabType: card" );
|
ui.applyStyle( "tabType: card" );
|
||||||
ui.applyStyle( "tabsPopupPolicy: asNeeded" );
|
ui.applyStyle( "tabsPopupPolicy: asNeeded" );
|
||||||
|
|||||||
@@ -840,6 +840,7 @@ TabbedPane.hoverColor
|
|||||||
TabbedPane.inactiveUnderlineColor
|
TabbedPane.inactiveUnderlineColor
|
||||||
TabbedPane.labelShift
|
TabbedPane.labelShift
|
||||||
TabbedPane.light
|
TabbedPane.light
|
||||||
|
TabbedPane.rotateTabRuns
|
||||||
TabbedPane.scrollButtonsPlacement
|
TabbedPane.scrollButtonsPlacement
|
||||||
TabbedPane.scrollButtonsPolicy
|
TabbedPane.scrollButtonsPolicy
|
||||||
TabbedPane.selectedBackground
|
TabbedPane.selectedBackground
|
||||||
|
|||||||
Reference in New Issue
Block a user