diff --git a/CHANGELOG.md b/CHANGELOG.md index dcdd8121..4b9e3fea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ FlatLaf Change Log #### New features and improvements +- SplitPane: Allow limiting one-touch expanding to a single side (set client + property `JSplitPane.expandableSide` to `"left"` or `"right"`). (issue #355) - TabbedPane: Selected tab underline color now changes depending on whether the focus is within the tab content. (issue #398) - IntelliJ Themes: diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatClientProperties.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatClientProperties.java index 0fb5e513..4b274f1c 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatClientProperties.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatClientProperties.java @@ -391,6 +391,40 @@ public interface FlatClientProperties */ String SCROLL_PANE_SMOOTH_SCROLLING = "JScrollPane.smoothScrolling"; + //---- JSplitPane --------------------------------------------------------- + + /** + * Specifies what side of the spilt pane is allowed to expand + * via one-touch expanding arrow buttons. + * Requires that one-touch expanding is enabled with + * {@link javax.swing.JSplitPane#setOneTouchExpandable(boolean)}. + *

+ * Component {@link javax.swing.JSplitPane}
+ * Value type {@link java.lang.String}
+ * Allowed Values + * {@link #SPLIT_PANE_EXPANDABLE_SIDE_LEFT} or + * {@link #SPLIT_PANE_EXPANDABLE_SIDE_RIGHT} + * + * @since 2.2 + */ + String SPLIT_PANE_EXPANDABLE_SIDE = "JSplitPane.expandableSide"; + + /** + * Allow expanding only left/top side of the split pane. + * + * @see #SPLIT_PANE_EXPANDABLE_SIDE + * @since 2.2 + */ + String SPLIT_PANE_EXPANDABLE_SIDE_LEFT = "left"; + + /** + * Allow expanding only right/bottom side of the split pane. + * + * @see #SPLIT_PANE_EXPANDABLE_SIDE + * @since 2.2 + */ + String SPLIT_PANE_EXPANDABLE_SIDE_RIGHT = "right"; + //---- JTabbedPane -------------------------------------------------------- /** diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatSplitPaneUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatSplitPaneUI.java index b619e3ad..0f3d5992 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatSplitPaneUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatSplitPaneUI.java @@ -34,6 +34,7 @@ import javax.swing.UIManager; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicSplitPaneDivider; import javax.swing.plaf.basic.BasicSplitPaneUI; +import com.formdev.flatlaf.FlatClientProperties; import com.formdev.flatlaf.ui.FlatStylingSupport.Styleable; import com.formdev.flatlaf.ui.FlatStylingSupport.StyleableUI; import com.formdev.flatlaf.ui.FlatStylingSupport.UnknownStyleException; @@ -352,7 +353,7 @@ public class FlatSplitPaneUI if( leftButton == null || rightButton == null || !splitPane.isOneTouchExpandable() ) return; - // increase side of buttons, which makes them easier to hit by the user + // increase size of buttons, which makes them easier to hit by the user // and avoids cut arrows at small divider sizes int extraSize = UIScale.scale( 4 ); if( orientation == JSplitPane.VERTICAL_SPLIT ) { @@ -367,10 +368,19 @@ public class FlatSplitPaneUI // hide buttons if not applicable boolean leftCollapsed = isLeftCollapsed(); - if( leftCollapsed ) + boolean rightCollapsed = isRightCollapsed(); + if( leftCollapsed || rightCollapsed ) { + leftButton.setVisible( !leftCollapsed ); + rightButton.setVisible( !rightCollapsed ); + } else { + Object expandableSide = splitPane.getClientProperty( FlatClientProperties.SPLIT_PANE_EXPANDABLE_SIDE ); + leftButton.setVisible( expandableSide == null || !FlatClientProperties.SPLIT_PANE_EXPANDABLE_SIDE_LEFT.equals( expandableSide ) ); + rightButton.setVisible( expandableSide == null || !FlatClientProperties.SPLIT_PANE_EXPANDABLE_SIDE_RIGHT.equals( expandableSide ) ); + } + + // move right button if left button is hidden + if( !leftButton.isVisible() ) rightButton.setLocation( leftButton.getLocation() ); - leftButton.setVisible( !leftCollapsed ); - rightButton.setVisible( !isRightCollapsed() ); } } }