Browse Source

Renamed DarkSplitPaneUI.Style.Default to Grip.

Added option for the default split pane divider style.
pull/75/head
weisj 5 years ago
parent
commit
bb77f9255c
  1. 20
      core/src/main/java/com/github/weisj/darklaf/ui/splitpane/DarkSplitPaneUI.java
  2. 1
      core/src/main/resources/com/github/weisj/darklaf/properties/ui/splitPane.properties
  3. 4
      core/src/test/java/ui/splitPane/SplitPaneDemo.java

20
core/src/main/java/com/github/weisj/darklaf/ui/splitpane/DarkSplitPaneUI.java

@ -49,7 +49,7 @@ public class DarkSplitPaneUI extends BasicSplitPaneUI implements PropertyChangeL
public static ComponentUI createUI(final JComponent c) { public static ComponentUI createUI(final JComponent c) {
return new DarkSplitPaneUI(Style.DEFAULT); return new DarkSplitPaneUI(Style.get(UIManager.getString("SplitPane.defaultDividerStyle")));
} }
@Override @Override
@ -88,7 +88,7 @@ public class DarkSplitPaneUI extends BasicSplitPaneUI implements PropertyChangeL
@Override @Override
public BasicSplitPaneDivider createDefaultDivider() { public BasicSplitPaneDivider createDefaultDivider() {
if (style == Style.DEFAULT) { if (style == Style.GRIP) {
return new DarkSplitPaneDivider(this); return new DarkSplitPaneDivider(this);
} else { } else {
return new ThinDivider(this); return new ThinDivider(this);
@ -102,7 +102,7 @@ public class DarkSplitPaneUI extends BasicSplitPaneUI implements PropertyChangeL
@Override @Override
public void layoutContainer(final Container parent) { public void layoutContainer(final Container parent) {
super.layoutContainer(parent); super.layoutContainer(parent);
if (style != Style.DEFAULT) { if (style != Style.GRIP) {
Rectangle bounds = getDivider().getBounds(); Rectangle bounds = getDivider().getBounds();
if (getOrientation() == JSplitPane.HORIZONTAL_SPLIT) { if (getOrientation() == JSplitPane.HORIZONTAL_SPLIT) {
bounds.x -= DIVIDER_DRAG_OFFSET; bounds.x -= DIVIDER_DRAG_OFFSET;
@ -128,10 +128,10 @@ public class DarkSplitPaneUI extends BasicSplitPaneUI implements PropertyChangeL
} else if (Style.LINE.name.equals(val)) { } else if (Style.LINE.name.equals(val)) {
style = Style.LINE; style = Style.LINE;
} else { } else {
style = Style.DEFAULT; style = Style.GRIP;
} }
if (oldStyle != style) { if (oldStyle != style) {
if (style == Style.DEFAULT || oldStyle == Style.DEFAULT) { if (style == Style.GRIP || oldStyle == Style.GRIP) {
splitPane.setUI(new DarkSplitPaneUI(style)); splitPane.setUI(new DarkSplitPaneUI(style));
} else { } else {
splitPane.doLayout(); splitPane.doLayout();
@ -147,7 +147,7 @@ public class DarkSplitPaneUI extends BasicSplitPaneUI implements PropertyChangeL
} }
private enum Style { private enum Style {
DEFAULT("default"), GRIP("grip"),
LINE("line"), LINE("line"),
INVISIBLE("invisible"); INVISIBLE("invisible");
@ -157,6 +157,14 @@ public class DarkSplitPaneUI extends BasicSplitPaneUI implements PropertyChangeL
Style(final String name) { Style(final String name) {
this.name = name; this.name = name;
} }
static Style get(final String style) {
try {
return valueOf(style);
} catch (IllegalArgumentException e) {
return GRIP;
}
}
} }
private final class ThinDivider extends BasicSplitPaneDivider { private final class ThinDivider extends BasicSplitPaneDivider {

1
core/src/main/resources/com/github/weisj/darklaf/properties/ui/splitPane.properties

@ -29,6 +29,7 @@ SplitPane.highlight = %backgroundContainer
SplitPane.dividerLineColor = %borderSecondary SplitPane.dividerLineColor = %borderSecondary
SplitPane.dividerFocusColor = null SplitPane.dividerFocusColor = null
SplitPane.centerOneTouchButtons = true SplitPane.centerOneTouchButtons = true
SplitPane.defaultDividerStyle = grip
#Icons #Icons
SplitPane.horizontalGlue.icon = navigation/horizontalGlue.svg[themed](4,13) SplitPane.horizontalGlue.icon = navigation/horizontalGlue.svg[themed](4,13)

4
core/src/test/java/ui/splitPane/SplitPaneDemo.java

@ -76,10 +76,10 @@ public final class SplitPaneDemo implements ComponentDemo {
}}, "sgx"); }}, "sgx");
controlPanel.add(new JLabel("JSplitPane.style:", JLabel.RIGHT)); controlPanel.add(new JLabel("JSplitPane.style:", JLabel.RIGHT));
controlPanel.add(new JComboBox<String>() {{ controlPanel.add(new JComboBox<String>() {{
addItem("default"); addItem("grip");
addItem("line"); addItem("line");
addItem("invisible"); addItem("invisible");
setSelectedItem("default"); setSelectedItem(UIManager.get("SplitPane.defaultDividerStyle"));
addItemListener(e -> splitPane.putClientProperty("JSplitPane.style", e.getItem())); addItemListener(e -> splitPane.putClientProperty("JSplitPane.style", e.getItem()));
}}, "sgx"); }}, "sgx");
return panel; return panel;

Loading…
Cancel
Save