mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-10 22:17:13 -06:00
TabbedPane: avoid "jumping" tab area when switching L&F or when mouse wheel scrolling to last tab (regression in commit 4ad45088c4)
This commit is contained in:
@@ -3833,17 +3833,14 @@ debug*/
|
||||
moreTabsButtonVisible = true;
|
||||
}
|
||||
if( useScrollButtons ) {
|
||||
// layout forward button on trailing side
|
||||
if( !hideDisabledScrollButtons || forwardButton.isEnabled() ) {
|
||||
int buttonWidth = forwardButton.getPreferredSize().width;
|
||||
forwardButton.setBounds( leftToRight ? (x + w - buttonWidth) : x, y, buttonWidth, h );
|
||||
x += leftToRight ? 0 : buttonWidth;
|
||||
w -= buttonWidth;
|
||||
forwardButtonVisible = true;
|
||||
}
|
||||
// the tabViewport view size is set in
|
||||
// BasicTabbedPaneUI.TabbedPaneScrollLayout.calculateTabRects(),
|
||||
// which is called from calculateLayoutInfo()
|
||||
Point viewPosition = tabViewport.getViewPosition();
|
||||
Dimension viewSize = tabViewport.getViewSize();
|
||||
|
||||
// layout backward button
|
||||
if( !hideDisabledScrollButtons || backwardButton.isEnabled() ) {
|
||||
if( !hideDisabledScrollButtons || viewPosition.x > 0 ) {
|
||||
int buttonWidth = backwardButton.getPreferredSize().width;
|
||||
if( trailingScrollButtons ) {
|
||||
// on trailing side
|
||||
@@ -3857,6 +3854,15 @@ debug*/
|
||||
w -= buttonWidth;
|
||||
backwardButtonVisible = true;
|
||||
}
|
||||
|
||||
// layout forward button on trailing side
|
||||
if( !hideDisabledScrollButtons || viewSize.width - viewPosition.x > w ) {
|
||||
int buttonWidth = forwardButton.getPreferredSize().width;
|
||||
forwardButton.setBounds( leftToRight ? (x + w - buttonWidth) : x, y, buttonWidth, h );
|
||||
x += leftToRight ? 0 : buttonWidth;
|
||||
w -= buttonWidth;
|
||||
forwardButtonVisible = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3903,16 +3909,14 @@ debug*/
|
||||
moreTabsButtonVisible = true;
|
||||
}
|
||||
if( useScrollButtons ) {
|
||||
// layout forward button on bottom side
|
||||
if( !hideDisabledScrollButtons || forwardButton.isEnabled() ) {
|
||||
int buttonHeight = forwardButton.getPreferredSize().height;
|
||||
forwardButton.setBounds( x, y + h - buttonHeight, w, buttonHeight );
|
||||
h -= buttonHeight;
|
||||
forwardButtonVisible = true;
|
||||
}
|
||||
// the tabViewport view size is set in
|
||||
// BasicTabbedPaneUI.TabbedPaneScrollLayout.calculateTabRects(),
|
||||
// which is called from calculateLayoutInfo()
|
||||
Point viewPosition = tabViewport.getViewPosition();
|
||||
Dimension viewSize = tabViewport.getViewSize();
|
||||
|
||||
// layout backward button
|
||||
if( !hideDisabledScrollButtons || backwardButton.isEnabled() ) {
|
||||
if( !hideDisabledScrollButtons || viewPosition.y > 0 ) {
|
||||
int buttonHeight = backwardButton.getPreferredSize().height;
|
||||
if( trailingScrollButtons ) {
|
||||
// on bottom side
|
||||
@@ -3925,6 +3929,14 @@ debug*/
|
||||
h -= buttonHeight;
|
||||
backwardButtonVisible = true;
|
||||
}
|
||||
|
||||
// layout forward button on bottom side
|
||||
if( !hideDisabledScrollButtons || viewSize.height - viewPosition.y > h ) {
|
||||
int buttonHeight = forwardButton.getPreferredSize().height;
|
||||
forwardButton.setBounds( x, y + h - buttonHeight, w, buttonHeight );
|
||||
h -= buttonHeight;
|
||||
forwardButtonVisible = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user