|
|
@ -3,7 +3,6 @@ package com.weis.darklaf.ui.tabbedpane; |
|
|
|
import com.weis.darklaf.components.ScrollPopupMenu; |
|
|
|
import com.weis.darklaf.components.ScrollPopupMenu; |
|
|
|
import com.weis.darklaf.decorators.PopupMenuAdapter; |
|
|
|
import com.weis.darklaf.decorators.PopupMenuAdapter; |
|
|
|
import com.weis.darklaf.icons.EmptyIcon; |
|
|
|
import com.weis.darklaf.icons.EmptyIcon; |
|
|
|
import com.weis.darklaf.icons.IconLoader; |
|
|
|
|
|
|
|
import com.weis.darklaf.util.DarkUIUtil; |
|
|
|
import com.weis.darklaf.util.DarkUIUtil; |
|
|
|
import com.weis.darklaf.util.GraphicsContext; |
|
|
|
import com.weis.darklaf.util.GraphicsContext; |
|
|
|
import com.weis.darklaf.util.GraphicsUtil; |
|
|
|
import com.weis.darklaf.util.GraphicsUtil; |
|
|
@ -31,6 +30,8 @@ import java.util.function.Function; |
|
|
|
|
|
|
|
|
|
|
|
public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge { |
|
|
|
public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final int FOCUS_SIZE = 4; |
|
|
|
|
|
|
|
|
|
|
|
private static final TabbedPaneTransferHandler TRANSFER_HANDLER = new TabbedPaneTransferHandler(); |
|
|
|
private static final TabbedPaneTransferHandler TRANSFER_HANDLER = new TabbedPaneTransferHandler(); |
|
|
|
private final FocusListener focusListener = new FocusListener() { |
|
|
|
private final FocusListener focusListener = new FocusListener() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -81,10 +82,18 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge { |
|
|
|
final boolean isSelected) { |
|
|
|
final boolean isSelected) { |
|
|
|
g.setColor(getTabBorderColor()); |
|
|
|
g.setColor(getTabBorderColor()); |
|
|
|
switch (tabPlacement) { |
|
|
|
switch (tabPlacement) { |
|
|
|
case TOP -> g.fillRect(x, y + h - 1, w, 1); |
|
|
|
case TOP: |
|
|
|
case BOTTOM -> g.fillRect(x, y, w, 1); |
|
|
|
g.fillRect(x, y + h - 1, w, 1); |
|
|
|
case LEFT -> g.fillRect(x + w - 1, y, 1, h); |
|
|
|
break; |
|
|
|
case RIGHT -> g.fillRect(x, y, 1, h); |
|
|
|
case BOTTOM: |
|
|
|
|
|
|
|
g.fillRect(x, y, w, 1); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case LEFT: |
|
|
|
|
|
|
|
g.fillRect(x + w - 1, y, 1, h); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case RIGHT: |
|
|
|
|
|
|
|
g.fillRect(x, y, 1, h); |
|
|
|
|
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -104,10 +113,18 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge { |
|
|
|
int y = calculateTabAreaHeight(tabPlacement, runCount, maxTabHeight); |
|
|
|
int y = calculateTabAreaHeight(tabPlacement, runCount, maxTabHeight); |
|
|
|
int x = calculateTabAreaWidth(tabPlacement, runCount, maxTabWidth); |
|
|
|
int x = calculateTabAreaWidth(tabPlacement, runCount, maxTabWidth); |
|
|
|
switch (tabPlacement) { |
|
|
|
switch (tabPlacement) { |
|
|
|
case TOP -> paintTabAreaBorder(g, tabPlacement, 0, 0, width, y); |
|
|
|
case TOP: |
|
|
|
case BOTTOM -> paintTabAreaBorder(g, tabPlacement, 0, height - y, width, y + 1); |
|
|
|
paintTabAreaBorder(g, tabPlacement, 0, 0, width, y); |
|
|
|
case LEFT -> paintTabAreaBorder(g, tabPlacement, 0, 0, x, height); |
|
|
|
break; |
|
|
|
case RIGHT -> paintTabAreaBorder(g, tabPlacement, width - x, 0, x, height); |
|
|
|
case BOTTOM: |
|
|
|
|
|
|
|
paintTabAreaBorder(g, tabPlacement, 0, height - y, width, y + 1); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case LEFT: |
|
|
|
|
|
|
|
paintTabAreaBorder(g, tabPlacement, 0, 0, x, height); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case RIGHT: |
|
|
|
|
|
|
|
paintTabAreaBorder(g, tabPlacement, width - x, 0, x, height); |
|
|
|
|
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// If scrollable tabs are enabled, the tab area will be
|
|
|
|
// If scrollable tabs are enabled, the tab area will be
|
|
|
@ -131,10 +148,18 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge { |
|
|
|
((Graphics2D) g).setComposite(DarkUIUtil.ALPHA_COMPOSITE_2); |
|
|
|
((Graphics2D) g).setComposite(DarkUIUtil.ALPHA_COMPOSITE_2); |
|
|
|
} |
|
|
|
} |
|
|
|
switch (tabPane.getTabPlacement()) { |
|
|
|
switch (tabPane.getTabPlacement()) { |
|
|
|
case TOP -> g.fillRect(dropRect.x, dropRect.y, dropRect.width, dropRect.height - 1); |
|
|
|
case TOP: |
|
|
|
case BOTTOM -> g.fillRect(dropRect.x, dropRect.y + 1, dropRect.width, dropRect.height - 1); |
|
|
|
g.fillRect(dropRect.x, dropRect.y, dropRect.width, dropRect.height - 1); |
|
|
|
case LEFT -> g.fillRect(dropRect.x, dropRect.y, dropRect.width - 1, dropRect.height); |
|
|
|
break; |
|
|
|
case RIGHT -> g.fillRect(dropRect.x + 1, dropRect.y, dropRect.width - 1, dropRect.height); |
|
|
|
case BOTTOM: |
|
|
|
|
|
|
|
g.fillRect(dropRect.x, dropRect.y + 1, dropRect.width, dropRect.height - 1); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case LEFT: |
|
|
|
|
|
|
|
g.fillRect(dropRect.x, dropRect.y, dropRect.width - 1, dropRect.height); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case RIGHT: |
|
|
|
|
|
|
|
g.fillRect(dropRect.x + 1, dropRect.y, dropRect.width - 1, dropRect.height); |
|
|
|
|
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
context.restore(); |
|
|
|
context.restore(); |
|
|
|
} |
|
|
|
} |
|
|
@ -143,10 +168,18 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge { |
|
|
|
final int x, final int y, final int w, final int h) { |
|
|
|
final int x, final int y, final int w, final int h) { |
|
|
|
g.setColor(getTabBorderColor()); |
|
|
|
g.setColor(getTabBorderColor()); |
|
|
|
switch (tabPlacement) { |
|
|
|
switch (tabPlacement) { |
|
|
|
case TOP -> g.fillRect(x, y + h - 1, w, 1); |
|
|
|
case TOP: |
|
|
|
case BOTTOM -> g.fillRect(x, y, w, 1); |
|
|
|
g.fillRect(x, y + h - 1, w, 1); |
|
|
|
case LEFT -> g.fillRect(w - 1, y, 1, h); |
|
|
|
break; |
|
|
|
case RIGHT -> g.fillRect(x, y, 1, h); |
|
|
|
case BOTTOM: |
|
|
|
|
|
|
|
g.fillRect(x, y, w, 1); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case LEFT: |
|
|
|
|
|
|
|
g.fillRect(w - 1, y, 1, h); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case RIGHT: |
|
|
|
|
|
|
|
g.fillRect(x, y, 1, h); |
|
|
|
|
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -200,9 +233,18 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge { |
|
|
|
g.setColor(getAccentColor(DarkUIUtil.hasFocus(tabPane))); |
|
|
|
g.setColor(getAccentColor(DarkUIUtil.hasFocus(tabPane))); |
|
|
|
var r = rects[tabIndex]; |
|
|
|
var r = rects[tabIndex]; |
|
|
|
switch (tabPlacement) { |
|
|
|
switch (tabPlacement) { |
|
|
|
case LEFT -> g.fillRect(r.x, r.y + r.height - 4, r.width - 1, 4); |
|
|
|
case LEFT: |
|
|
|
case RIGHT -> g.fillRect(r.x + 1, r.y + r.height - 4, r.width - 1, 4); |
|
|
|
g.fillRect(r.x + r.width - FOCUS_SIZE - 1, r.y, FOCUS_SIZE, r.height); |
|
|
|
default -> g.fillRect(r.x, r.y + r.height - 4, r.width, 4); |
|
|
|
break; |
|
|
|
|
|
|
|
case RIGHT: |
|
|
|
|
|
|
|
g.fillRect(r.x + 1, r.y, FOCUS_SIZE, r.height); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case BOTTOM: |
|
|
|
|
|
|
|
g.fillRect(r.x, r.y + 1, r.width, FOCUS_SIZE); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
g.fillRect(r.x, r.y + r.height - FOCUS_SIZE, r.width, FOCUS_SIZE); |
|
|
|
|
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -410,21 +452,19 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge { |
|
|
|
var rect = super.getTabBounds(pane, i); |
|
|
|
var rect = super.getTabBounds(pane, i); |
|
|
|
if (scrollableTabLayoutEnabled() && rect != null |
|
|
|
if (scrollableTabLayoutEnabled() && rect != null |
|
|
|
&& dropTargetIndex >= 0 && i == dropTargetIndex) { |
|
|
|
&& dropTargetIndex >= 0 && i == dropTargetIndex) { |
|
|
|
switch (pane.getTabPlacement()) { |
|
|
|
int tabPlacement = pane.getTabPlacement(); |
|
|
|
case TOP, BOTTOM -> { |
|
|
|
if (tabPlacement == TOP || tabPlacement == BOTTOM) { |
|
|
|
if (pane.getComponentOrientation().isLeftToRight()) { |
|
|
|
if (pane.getComponentOrientation().isLeftToRight()) { |
|
|
|
rect.x -= dropRect.width; |
|
|
|
rect.x -= dropRect.width; |
|
|
|
rect.width += dropRect.width; |
|
|
|
rect.width += dropRect.width; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
rect.width += dropRect.width; |
|
|
|
rect.width += dropRect.width; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (tabPlacement == LEFT || tabPlacement == RIGHT) { |
|
|
|
case LEFT, RIGHT -> { |
|
|
|
|
|
|
|
rect.y -= dropRect.height; |
|
|
|
rect.y -= dropRect.height; |
|
|
|
rect.height += dropRect.height; |
|
|
|
rect.height += dropRect.height; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return rect; |
|
|
|
return rect; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -545,10 +585,15 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private Icon getNewTabIcon() { |
|
|
|
protected Icon getNewTabIcon() { |
|
|
|
return UIManager.getIcon("TabbedPane.newTab.icon"); |
|
|
|
return UIManager.getIcon("TabbedPane.newTab.icon"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected Icon getMoreTabsIcon() { |
|
|
|
|
|
|
|
return UIManager.getIcon("TabbedPane.moreTabs.icon"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected class MoreTabsButton extends DarkTabAreaButton { |
|
|
|
protected class MoreTabsButton extends DarkTabAreaButton { |
|
|
|
|
|
|
|
|
|
|
|
private final Icon icon; |
|
|
|
private final Icon icon; |
|
|
@ -556,7 +601,7 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge { |
|
|
|
private final static int PAD = 2; |
|
|
|
private final static int PAD = 2; |
|
|
|
|
|
|
|
|
|
|
|
protected MoreTabsButton() { |
|
|
|
protected MoreTabsButton() { |
|
|
|
icon = IconLoader.get().getUIAwareIcon("navigation/moreTabs.svg"); |
|
|
|
icon = getMoreTabsIcon(); |
|
|
|
setIcon(EmptyIcon.create(icon.getIconWidth(), icon.getIconHeight())); |
|
|
|
setIcon(EmptyIcon.create(icon.getIconWidth(), icon.getIconHeight())); |
|
|
|
putClientProperty("JButton.variant", "onlyLabel"); |
|
|
|
putClientProperty("JButton.variant", "onlyLabel"); |
|
|
|
putClientProperty("JButton.buttonType", "square"); |
|
|
|
putClientProperty("JButton.buttonType", "square"); |
|
|
@ -578,11 +623,11 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge { |
|
|
|
* A different icon might need a different offset. |
|
|
|
* A different icon might need a different offset. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
int off = 5; |
|
|
|
int off = 5; |
|
|
|
switch (tabPane.getTabPlacement()) { |
|
|
|
int tabPlacement = tabPane.getTabPlacement(); |
|
|
|
case TOP -> y += 2; |
|
|
|
if (tabPlacement == TOP) { |
|
|
|
case BOTTOM -> y -= 1; |
|
|
|
y += 2; |
|
|
|
default -> { |
|
|
|
} else if (tabPlacement == BOTTOM) { |
|
|
|
} |
|
|
|
y -= 1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
icon.paintIcon(this, g, x, y); |
|
|
|
icon.paintIcon(this, g, x, y); |
|
|
@ -662,26 +707,30 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge { |
|
|
|
var pref = scrollPopupMenu.getPreferredSize(); |
|
|
|
var pref = scrollPopupMenu.getPreferredSize(); |
|
|
|
boolean leftToRight = tabPane.getComponentOrientation().isLeftToRight(); |
|
|
|
boolean leftToRight = tabPane.getComponentOrientation().isLeftToRight(); |
|
|
|
switch (tabPane.getTabPlacement()) { |
|
|
|
switch (tabPane.getTabPlacement()) { |
|
|
|
case LEFT -> scrollPopupMenu.show(moreTabsButton, moreTabsButton.getWidth(), |
|
|
|
case LEFT: |
|
|
|
|
|
|
|
scrollPopupMenu.show(moreTabsButton, moreTabsButton.getWidth(), |
|
|
|
moreTabsButton.getHeight() - pref.height); |
|
|
|
moreTabsButton.getHeight() - pref.height); |
|
|
|
case RIGHT -> scrollPopupMenu.show(moreTabsButton, -pref.width, |
|
|
|
break; |
|
|
|
|
|
|
|
case RIGHT: |
|
|
|
|
|
|
|
scrollPopupMenu.show(moreTabsButton, -pref.width, |
|
|
|
moreTabsButton.getHeight() - pref.height); |
|
|
|
moreTabsButton.getHeight() - pref.height); |
|
|
|
case TOP -> { |
|
|
|
break; |
|
|
|
|
|
|
|
case TOP: |
|
|
|
if (leftToRight) { |
|
|
|
if (leftToRight) { |
|
|
|
scrollPopupMenu.show(moreTabsButton, moreTabsButton.getWidth() - pref.width, |
|
|
|
scrollPopupMenu.show(moreTabsButton, moreTabsButton.getWidth() - pref.width, |
|
|
|
moreTabsButton.getHeight()); |
|
|
|
moreTabsButton.getHeight()); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
scrollPopupMenu.show(moreTabsButton, 0, moreTabsButton.getHeight()); |
|
|
|
scrollPopupMenu.show(moreTabsButton, 0, moreTabsButton.getHeight()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
case BOTTOM -> { |
|
|
|
case BOTTOM: |
|
|
|
if (leftToRight) { |
|
|
|
if (leftToRight) { |
|
|
|
scrollPopupMenu.show(moreTabsButton, moreTabsButton.getWidth() - pref.width, |
|
|
|
scrollPopupMenu.show(moreTabsButton, moreTabsButton.getWidth() - pref.width, |
|
|
|
-pref.height); |
|
|
|
-pref.height); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
scrollPopupMenu.show(moreTabsButton, 0, -pref.height); |
|
|
|
scrollPopupMenu.show(moreTabsButton, 0, -pref.height); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -866,8 +915,7 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge { |
|
|
|
// Calculate how much space the tabs will need, based on the
|
|
|
|
// Calculate how much space the tabs will need, based on the
|
|
|
|
// minimum size required to display largest child + content border
|
|
|
|
// minimum size required to display largest child + content border
|
|
|
|
//
|
|
|
|
//
|
|
|
|
switch (tabPlacement) { |
|
|
|
if (tabPlacement == LEFT || tabPlacement == RIGHT) { |
|
|
|
case LEFT, RIGHT -> { |
|
|
|
|
|
|
|
int tabHeight = calculateTabHeight(tabPlacement, tabPane.getSelectedIndex(), |
|
|
|
int tabHeight = calculateTabHeight(tabPlacement, tabPane.getSelectedIndex(), |
|
|
|
getFontMetrics().getHeight()); |
|
|
|
getFontMetrics().getHeight()); |
|
|
|
if (scrollableTabSupport.moreTabsButton.isVisible()) { |
|
|
|
if (scrollableTabSupport.moreTabsButton.isVisible()) { |
|
|
@ -877,8 +925,7 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge { |
|
|
|
tabExtent = preferredTabAreaWidth(tabPlacement, |
|
|
|
tabExtent = preferredTabAreaWidth(tabPlacement, |
|
|
|
height - tabAreaInsets.top - tabAreaInsets.bottom); |
|
|
|
height - tabAreaInsets.top - tabAreaInsets.bottom); |
|
|
|
width += tabExtent; |
|
|
|
width += tabExtent; |
|
|
|
} |
|
|
|
} else { |
|
|
|
default -> { |
|
|
|
|
|
|
|
int tabWidth = calculateTabWidth(tabPlacement, tabPane.getSelectedIndex(), getFontMetrics()); |
|
|
|
int tabWidth = calculateTabWidth(tabPlacement, tabPane.getSelectedIndex(), getFontMetrics()); |
|
|
|
if (scrollableTabSupport.moreTabsButton.isVisible()) { |
|
|
|
if (scrollableTabSupport.moreTabsButton.isVisible()) { |
|
|
|
tabWidth += scrollableTabSupport.moreTabsButton.getPreferredSize().width; |
|
|
|
tabWidth += scrollableTabSupport.moreTabsButton.getPreferredSize().width; |
|
|
@ -887,7 +934,6 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge { |
|
|
|
tabExtent = preferredTabAreaHeight(tabPlacement, width - tabAreaInsets.left - tabAreaInsets.right); |
|
|
|
tabExtent = preferredTabAreaHeight(tabPlacement, width - tabAreaInsets.left - tabAreaInsets.right); |
|
|
|
height += tabExtent; |
|
|
|
height += tabExtent; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return new Dimension(width + insets.left + insets.right + contentInsets.left + contentInsets.right, |
|
|
|
return new Dimension(width + insets.left + insets.right + contentInsets.left + contentInsets.right, |
|
|
|
height + insets.bottom + insets.top + contentInsets.top + contentInsets.bottom); |
|
|
|
height + insets.bottom + insets.top + contentInsets.top + contentInsets.bottom); |
|
|
|
|
|
|
|
|
|
|
@ -902,9 +948,10 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge { |
|
|
|
boolean verticalTabRuns = !isHorizontalTabPlacement(); |
|
|
|
boolean verticalTabRuns = !isHorizontalTabPlacement(); |
|
|
|
boolean leftToRight = tabPane.getComponentOrientation().isLeftToRight(); |
|
|
|
boolean leftToRight = tabPane.getComponentOrientation().isLeftToRight(); |
|
|
|
|
|
|
|
|
|
|
|
switch (tabPlacement) { |
|
|
|
if (tabPlacement == LEFT || tabPlacement == RIGHT) { |
|
|
|
case LEFT, RIGHT -> maxTabWidth = calculateMaxTabWidth(tabPlacement); |
|
|
|
maxTabWidth = calculateMaxTabWidth(tabPlacement); |
|
|
|
default -> maxTabHeight = calculateMaxTabHeight(tabPlacement); |
|
|
|
} else { |
|
|
|
|
|
|
|
maxTabHeight = calculateMaxTabHeight(tabPlacement); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
runCount = 0; |
|
|
|
runCount = 0; |
|
|
@ -1347,59 +1394,51 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge { |
|
|
|
|
|
|
|
|
|
|
|
if (numChildren > 0) { |
|
|
|
if (numChildren > 0) { |
|
|
|
switch (tabPlacement) { |
|
|
|
switch (tabPlacement) { |
|
|
|
case LEFT -> { |
|
|
|
case LEFT: |
|
|
|
tw = calculateTabAreaWidth(tabPlacement, runCount, maxTabWidth); |
|
|
|
tw = calculateTabAreaWidth(tabPlacement, runCount, maxTabWidth); |
|
|
|
th = bounds.height - insets.top - insets.bottom - tabAreaInsets.top - tabAreaInsets.bottom; |
|
|
|
th = bounds.height - insets.top - insets.bottom - tabAreaInsets.top - tabAreaInsets.bottom; |
|
|
|
tx = insets.left + tabAreaInsets.left; |
|
|
|
tx = insets.left + tabAreaInsets.left; |
|
|
|
ty = insets.top + tabAreaInsets.top; |
|
|
|
ty = insets.top + tabAreaInsets.top; |
|
|
|
|
|
|
|
|
|
|
|
cx = insets.left + tw + contentInsets.left + tabAreaInsets.left + tabAreaInsets.right; |
|
|
|
cx = insets.left + tw + contentInsets.left + tabAreaInsets.left + tabAreaInsets.right; |
|
|
|
cy = insets.top + contentInsets.top; |
|
|
|
cy = insets.top + contentInsets.top; |
|
|
|
cw = bounds.width - insets.left - insets.right - tw - contentInsets.left - contentInsets.right |
|
|
|
cw = bounds.width - insets.left - insets.right - tw - contentInsets.left - contentInsets.right |
|
|
|
- tabAreaInsets.left - tabAreaInsets.right; |
|
|
|
- tabAreaInsets.left - tabAreaInsets.right; |
|
|
|
ch = bounds.height - insets.top - insets.bottom - contentInsets.top - contentInsets.bottom; |
|
|
|
ch = bounds.height - insets.top - insets.bottom - contentInsets.top - contentInsets.bottom; |
|
|
|
|
|
|
|
|
|
|
|
tw -= tabAreaInsets.left + tabAreaInsets.right; |
|
|
|
tw -= tabAreaInsets.left + tabAreaInsets.right; |
|
|
|
} |
|
|
|
break; |
|
|
|
case RIGHT -> { |
|
|
|
case RIGHT: |
|
|
|
tw = calculateTabAreaWidth(tabPlacement, runCount, maxTabWidth); |
|
|
|
tw = calculateTabAreaWidth(tabPlacement, runCount, maxTabWidth); |
|
|
|
th = bounds.height - insets.top - insets.bottom - tabAreaInsets.top - tabAreaInsets.bottom; |
|
|
|
th = bounds.height - insets.top - insets.bottom - tabAreaInsets.top - tabAreaInsets.bottom; |
|
|
|
tx = bounds.width - insets.right - tw + tabAreaInsets.left; |
|
|
|
tx = bounds.width - insets.right - tw + tabAreaInsets.left; |
|
|
|
ty = insets.top + tabAreaInsets.top; |
|
|
|
ty = insets.top + tabAreaInsets.top; |
|
|
|
|
|
|
|
|
|
|
|
cx = insets.left + contentInsets.left; |
|
|
|
cx = insets.left + contentInsets.left; |
|
|
|
cy = insets.top + contentInsets.top; |
|
|
|
cy = insets.top + contentInsets.top; |
|
|
|
cw = bounds.width - insets.left - insets.right - tw - contentInsets.left - contentInsets.right; |
|
|
|
cw = bounds.width - insets.left - insets.right - tw - contentInsets.left - contentInsets.right; |
|
|
|
ch = bounds.height - insets.top - insets.bottom - contentInsets.top - contentInsets.bottom; |
|
|
|
ch = bounds.height - insets.top - insets.bottom - contentInsets.top - contentInsets.bottom; |
|
|
|
|
|
|
|
|
|
|
|
tw -= tabAreaInsets.left + tabAreaInsets.right; |
|
|
|
tw -= tabAreaInsets.left + tabAreaInsets.right; |
|
|
|
} |
|
|
|
break; |
|
|
|
case BOTTOM -> { |
|
|
|
case BOTTOM: |
|
|
|
tw = bounds.width - insets.left - insets.right - tabAreaInsets.left - tabAreaInsets.right; |
|
|
|
tw = bounds.width - insets.left - insets.right - tabAreaInsets.left - tabAreaInsets.right; |
|
|
|
th = calculateTabAreaHeight(tabPlacement, runCount, maxTabHeight); |
|
|
|
th = calculateTabAreaHeight(tabPlacement, runCount, maxTabHeight); |
|
|
|
tx = insets.left + tabAreaInsets.left; |
|
|
|
tx = insets.left + tabAreaInsets.left; |
|
|
|
ty = bounds.height - insets.bottom - th + tabAreaInsets.top; |
|
|
|
ty = bounds.height - insets.bottom - th + tabAreaInsets.top; |
|
|
|
|
|
|
|
|
|
|
|
cx = insets.left + contentInsets.left; |
|
|
|
cx = insets.left + contentInsets.left; |
|
|
|
cy = insets.top + contentInsets.top; |
|
|
|
cy = insets.top + contentInsets.top; |
|
|
|
cw = bounds.width - insets.left - insets.right - contentInsets.left - contentInsets.right; |
|
|
|
cw = bounds.width - insets.left - insets.right - contentInsets.left - contentInsets.right; |
|
|
|
ch = bounds.height - insets.top - insets.bottom - th - contentInsets.top - contentInsets.bottom; |
|
|
|
ch = bounds.height - insets.top - insets.bottom - th - contentInsets.top - contentInsets.bottom; |
|
|
|
|
|
|
|
|
|
|
|
th -= tabAreaInsets.top + tabAreaInsets.bottom; |
|
|
|
th -= tabAreaInsets.top + tabAreaInsets.bottom; |
|
|
|
} |
|
|
|
break; |
|
|
|
default -> { |
|
|
|
default: |
|
|
|
tw = bounds.width - insets.left - insets.right - tabAreaInsets.left - tabAreaInsets.right; |
|
|
|
tw = bounds.width - insets.left - insets.right - tabAreaInsets.left - tabAreaInsets.right; |
|
|
|
th = calculateTabAreaHeight(tabPlacement, runCount, maxTabHeight); |
|
|
|
th = calculateTabAreaHeight(tabPlacement, runCount, maxTabHeight); |
|
|
|
tx = insets.left + tabAreaInsets.left; |
|
|
|
tx = insets.left + tabAreaInsets.left; |
|
|
|
ty = insets.top + tabAreaInsets.top; |
|
|
|
ty = insets.top + tabAreaInsets.top; |
|
|
|
|
|
|
|
|
|
|
|
cx = insets.left + contentInsets.left; |
|
|
|
cx = insets.left + contentInsets.left; |
|
|
|
cy = insets.top + th + contentInsets.top; |
|
|
|
cy = insets.top + th + contentInsets.top; |
|
|
|
cw = bounds.width - insets.left - insets.right - contentInsets.left - contentInsets.right; |
|
|
|
cw = bounds.width - insets.left - insets.right - contentInsets.left - contentInsets.right; |
|
|
|
ch = bounds.height - insets.top - insets.bottom - th - contentInsets.top - contentInsets.bottom; |
|
|
|
ch = bounds.height - insets.top - insets.bottom - th - contentInsets.top - contentInsets.bottom; |
|
|
|
|
|
|
|
|
|
|
|
th -= tabAreaInsets.top + tabAreaInsets.bottom; |
|
|
|
th -= tabAreaInsets.top + tabAreaInsets.bottom; |
|
|
|
} |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
JButton moreTabs = scrollableTabSupport.moreTabsButton; |
|
|
|
JButton moreTabs = scrollableTabSupport.moreTabsButton; |
|
|
|
JComponent newTab = scrollableTabSupport.newTabButton; |
|
|
|
JComponent newTab = scrollableTabSupport.newTabButton; |
|
|
@ -1418,15 +1457,13 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge { |
|
|
|
? newTab.getPreferredSize() |
|
|
|
? newTab.getPreferredSize() |
|
|
|
: new Dimension(0, 0); |
|
|
|
: new Dimension(0, 0); |
|
|
|
boolean leftToRight = tabPane.getComponentOrientation().isLeftToRight(); |
|
|
|
boolean leftToRight = tabPane.getComponentOrientation().isLeftToRight(); |
|
|
|
switch (tabPlacement) { |
|
|
|
if (tabPlacement == LEFT || tabPlacement == RIGHT) { |
|
|
|
case LEFT, RIGHT -> { |
|
|
|
|
|
|
|
vh = th - butSize.height - butSize2.height; |
|
|
|
vh = th - butSize.height - butSize2.height; |
|
|
|
moreTabs.setBounds(tx, ty + vh + butSize2.height, maxTabWidth, butSize.height); |
|
|
|
moreTabs.setBounds(tx, ty + vh + butSize2.height, maxTabWidth, butSize.height); |
|
|
|
if (showNewTabButton) { |
|
|
|
if (showNewTabButton) { |
|
|
|
newTab.setBounds(tx, ty + vh, maxTabWidth, butSize2.height); |
|
|
|
newTab.setBounds(tx, ty + vh, maxTabWidth, butSize2.height); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
default -> { |
|
|
|
|
|
|
|
if (leftToRight) { |
|
|
|
if (leftToRight) { |
|
|
|
vw = tw - butSize.width - butSize2.width; |
|
|
|
vw = tw - butSize.width - butSize2.width; |
|
|
|
moreTabs.setBounds(tx + vw + butSize2.width, ty, butSize.width, maxTabHeight); |
|
|
|
moreTabs.setBounds(tx + vw + butSize2.width, ty, butSize.width, maxTabHeight); |
|
|
@ -1442,7 +1479,6 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge { |
|
|
|
tx += butSize.width + butSize2.width; |
|
|
|
tx += butSize.width + butSize2.width; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
child.setBounds(tx, ty, vw, vh); |
|
|
|
child.setBounds(tx, ty, vw, vh); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
int tabHeight = maxTabHeight + tabAreaInsets.top + tabAreaInsets.bottom; |
|
|
|
int tabHeight = maxTabHeight + tabAreaInsets.top + tabAreaInsets.bottom; |
|
|
@ -1515,53 +1551,49 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge { |
|
|
|
|
|
|
|
|
|
|
|
if (numChildren > 0) { |
|
|
|
if (numChildren > 0) { |
|
|
|
switch (tabPlacement) { |
|
|
|
switch (tabPlacement) { |
|
|
|
case LEFT -> { |
|
|
|
case LEFT: |
|
|
|
tw = calculateTabAreaWidth(tabPlacement, runCount, maxTabWidth); |
|
|
|
tw = calculateTabAreaWidth(tabPlacement, runCount, maxTabWidth); |
|
|
|
tx = insets.left + tabAreaInsets.left; |
|
|
|
tx = insets.left + tabAreaInsets.left; |
|
|
|
ty = insets.top + tabAreaInsets.top; |
|
|
|
ty = insets.top + tabAreaInsets.top; |
|
|
|
th = bounds.height - insets.top - tabAreaInsets.top - insets.bottom - tabAreaInsets.bottom; |
|
|
|
th = bounds.height - insets.top - tabAreaInsets.top - insets.bottom - tabAreaInsets.bottom; |
|
|
|
|
|
|
|
|
|
|
|
cx = insets.left + tw + contentInsets.left + tabAreaInsets.left + tabAreaInsets.right; |
|
|
|
cx = insets.left + tw + contentInsets.left + tabAreaInsets.left + tabAreaInsets.right; |
|
|
|
cy = insets.top + contentInsets.top; |
|
|
|
cy = insets.top + contentInsets.top; |
|
|
|
cw = bounds.width - insets.left - insets.right - contentInsets.left - contentInsets.right - tw |
|
|
|
cw = bounds.width - insets.left - insets.right - contentInsets.left - contentInsets.right - tw |
|
|
|
- tabAreaInsets.left - tabAreaInsets.right; |
|
|
|
- tabAreaInsets.left - tabAreaInsets.right; |
|
|
|
ch = bounds.height - insets.top - insets.bottom - contentInsets.top - contentInsets.bottom; |
|
|
|
ch = bounds.height - insets.top - insets.bottom - contentInsets.top - contentInsets.bottom; |
|
|
|
} |
|
|
|
break; |
|
|
|
case RIGHT -> { |
|
|
|
case RIGHT: |
|
|
|
tw = calculateTabAreaWidth(tabPlacement, runCount, maxTabWidth); |
|
|
|
tw = calculateTabAreaWidth(tabPlacement, runCount, maxTabWidth); |
|
|
|
tx = bounds.width - insets.left - tw - tabAreaInsets.right - tabAreaInsets.left; |
|
|
|
tx = bounds.width - insets.left - tw - tabAreaInsets.right - tabAreaInsets.left; |
|
|
|
ty = insets.top + tabAreaInsets.top; |
|
|
|
ty = insets.top + tabAreaInsets.top; |
|
|
|
th = bounds.height - insets.top - tabAreaInsets.top - insets.bottom - tabAreaInsets.bottom; |
|
|
|
th = bounds.height - insets.top - tabAreaInsets.top - insets.bottom - tabAreaInsets.bottom; |
|
|
|
|
|
|
|
|
|
|
|
cx = insets.left + contentInsets.left; |
|
|
|
cx = insets.left + contentInsets.left; |
|
|
|
cy = insets.top + contentInsets.top; |
|
|
|
cy = insets.top + contentInsets.top; |
|
|
|
cw = bounds.width - insets.left - insets.right - contentInsets.left - contentInsets.right - tw |
|
|
|
cw = bounds.width - insets.left - insets.right - contentInsets.left - contentInsets.right - tw |
|
|
|
- tabAreaInsets.left - tabAreaInsets.right; |
|
|
|
- tabAreaInsets.left - tabAreaInsets.right; |
|
|
|
ch = bounds.height - insets.top - insets.bottom - contentInsets.top - contentInsets.bottom; |
|
|
|
ch = bounds.height - insets.top - insets.bottom - contentInsets.top - contentInsets.bottom; |
|
|
|
} |
|
|
|
break; |
|
|
|
case BOTTOM -> { |
|
|
|
case BOTTOM: |
|
|
|
th = calculateTabAreaHeight(tabPlacement, runCount, maxTabHeight); |
|
|
|
th = calculateTabAreaHeight(tabPlacement, runCount, maxTabHeight); |
|
|
|
ty = bounds.height - insets.bottom - th; |
|
|
|
ty = bounds.height - insets.bottom - th; |
|
|
|
tx = insets.left + tabAreaInsets.left; |
|
|
|
tx = insets.left + tabAreaInsets.left; |
|
|
|
tw = bounds.width - insets.left - insets.right - tabAreaInsets.left - tabAreaInsets.right; |
|
|
|
tw = bounds.width - insets.left - insets.right - tabAreaInsets.left - tabAreaInsets.right; |
|
|
|
|
|
|
|
|
|
|
|
cx = insets.left + contentInsets.left; |
|
|
|
cx = insets.left + contentInsets.left; |
|
|
|
cy = insets.top + contentInsets.top; |
|
|
|
cy = insets.top + contentInsets.top; |
|
|
|
cw = bounds.width - insets.left - insets.right - contentInsets.left - contentInsets.right; |
|
|
|
cw = bounds.width - insets.left - insets.right - contentInsets.left - contentInsets.right; |
|
|
|
ch = bounds.height - th - insets.top - insets.bottom - contentInsets.top - contentInsets.bottom; |
|
|
|
ch = bounds.height - th - insets.top - insets.bottom - contentInsets.top - contentInsets.bottom; |
|
|
|
} |
|
|
|
break; |
|
|
|
default -> { |
|
|
|
default: |
|
|
|
ty = insets.top + tabAreaInsets.top; |
|
|
|
ty = insets.top + tabAreaInsets.top; |
|
|
|
tx = insets.left + tabAreaInsets.left; |
|
|
|
tx = insets.left + tabAreaInsets.left; |
|
|
|
tw = bounds.width - insets.left - insets.right - tabAreaInsets.left - tabAreaInsets.right; |
|
|
|
tw = bounds.width - insets.left - insets.right - tabAreaInsets.left - tabAreaInsets.right; |
|
|
|
th = calculateTabAreaHeight(tabPlacement, runCount, maxTabHeight); |
|
|
|
th = calculateTabAreaHeight(tabPlacement, runCount, maxTabHeight); |
|
|
|
|
|
|
|
|
|
|
|
cx = insets.left + contentInsets.left; |
|
|
|
cx = insets.left + contentInsets.left; |
|
|
|
cy = insets.top + th + contentInsets.top + tabAreaInsets.top + tabAreaInsets.bottom; |
|
|
|
cy = insets.top + th + contentInsets.top + tabAreaInsets.top + tabAreaInsets.bottom; |
|
|
|
cw = bounds.width - insets.left - insets.right - contentInsets.left - contentInsets.right; |
|
|
|
cw = bounds.width - insets.left - insets.right - contentInsets.left - contentInsets.right; |
|
|
|
ch = bounds.height - th - insets.top - insets.bottom - contentInsets.top - contentInsets.bottom |
|
|
|
ch = bounds.height - th - insets.top - insets.bottom - contentInsets.top - contentInsets.bottom |
|
|
|
- tabAreaInsets.top - tabAreaInsets.bottom; |
|
|
|
- tabAreaInsets.top - tabAreaInsets.bottom; |
|
|
|
} |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
tabAreaBounds.setRect(tx, ty, tw, th); |
|
|
|
tabAreaBounds.setRect(tx, ty, tw, th); |
|
|
@ -1599,12 +1631,20 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge { |
|
|
|
int centerY = (tabHeight - h) / 2; |
|
|
|
int centerY = (tabHeight - h) / 2; |
|
|
|
int centerX = (tabWidth - w) / 2; |
|
|
|
int centerX = (tabWidth - w) / 2; |
|
|
|
switch (tabPlacement) { |
|
|
|
switch (tabPlacement) { |
|
|
|
case LEFT -> comp.setBounds(insets.left + centerX, ty - b.height, w, b.height); |
|
|
|
case LEFT: |
|
|
|
case RIGHT -> comp.setBounds(tx - tabAreaInsets.left + centerX, ty - b.height, |
|
|
|
comp.setBounds(insets.left + centerX, ty - b.height, w, b.height); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case RIGHT: |
|
|
|
|
|
|
|
comp.setBounds(tx - tabAreaInsets.left + centerX, ty - b.height, |
|
|
|
w, b.height); |
|
|
|
w, b.height); |
|
|
|
case TOP -> comp.setBounds(tx - b.width, insets.top + centerY, b.width, h); |
|
|
|
break; |
|
|
|
case BOTTOM -> comp.setBounds(tx - b.width, ty - tabAreaInsets.bottom + centerY, |
|
|
|
case TOP: |
|
|
|
|
|
|
|
comp.setBounds(tx - b.width, insets.top + centerY, b.width, h); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case BOTTOM: |
|
|
|
|
|
|
|
comp.setBounds(tx - b.width, ty - tabAreaInsets.bottom + centerY, |
|
|
|
b.width, h); |
|
|
|
b.width, h); |
|
|
|
|
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1617,12 +1657,20 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge { |
|
|
|
int centerY = (tabHeight - h) / 2; |
|
|
|
int centerY = (tabHeight - h) / 2; |
|
|
|
int centerX = (tabWidth - w) / 2; |
|
|
|
int centerX = (tabWidth - w) / 2; |
|
|
|
switch (tabPlacement) { |
|
|
|
switch (tabPlacement) { |
|
|
|
case LEFT -> comp.setBounds(insets.left + centerX, ty + th, w, b.height); |
|
|
|
case LEFT: |
|
|
|
case RIGHT -> comp.setBounds(tx - tabAreaInsets.left + centerX, ty + th, |
|
|
|
comp.setBounds(insets.left + centerX, ty + th, w, b.height); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case RIGHT: |
|
|
|
|
|
|
|
comp.setBounds(tx - tabAreaInsets.left + centerX, ty + th, |
|
|
|
w, b.height); |
|
|
|
w, b.height); |
|
|
|
case TOP -> comp.setBounds(tx + tw, insets.top + centerY, b.width, h); |
|
|
|
break; |
|
|
|
case BOTTOM -> comp.setBounds(tx + tw, ty - tabAreaInsets.bottom + centerY, |
|
|
|
case TOP: |
|
|
|
|
|
|
|
comp.setBounds(tx + tw, insets.top + centerY, b.width, h); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case BOTTOM: |
|
|
|
|
|
|
|
comp.setBounds(tx + tw, ty - tabAreaInsets.bottom + centerY, |
|
|
|
b.width, h); |
|
|
|
b.width, h); |
|
|
|
|
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|