Browse Source

Make api of more ToggleSplitPane customizable.

pull/214/head
weisj 4 years ago
parent
commit
f7190ae1f6
  1. 2
      core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameContentPane.java
  2. 14
      core/src/main/java/com/github/weisj/darklaf/components/tabframe/ToggleSplitPane.java

2
core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameContentPane.java

@ -151,7 +151,7 @@ public class TabFrameContentPane extends JPanel implements TabFrameContent {
consumer.accept(rightSplit, flag);
}
private void init() {
protected void init() {
disableAll(true);
setupSplitterPanes(ToggleSplitPane::savePosition, SPLITTER_DEFAULT_POSITION);
topSplit.savePosition(TOP_SPLIT_DEFAULT_POSITION);

14
core/src/main/java/com/github/weisj/darklaf/components/tabframe/ToggleSplitPane.java

@ -72,7 +72,7 @@ public class ToggleSplitPane extends JSplitPane {
this.resizable = resizable;
if (!resizable) {
lastEnabled = isEnabled();
this.lockedPosition = lockedPosition;
setLockedPosition(lockedPosition);
setEnabled(false);
getDivider().setEnabled(false);
setComponentZOrder(getDivider(), getComponentCount() - 1);
@ -83,6 +83,10 @@ public class ToggleSplitPane extends JSplitPane {
}
}
protected void setLockedPosition(final double lockedPosition) {
this.lockedPosition = lockedPosition;
}
protected BasicSplitPaneDivider getDivider() {
return ((BasicSplitPaneUI) getUI()).getDivider();
}
@ -97,7 +101,7 @@ public class ToggleSplitPane extends JSplitPane {
public void updateUI() {
super.updateUI();
setEnabled(enabled);
setResizable(resizable);
setResizable(isResizable());
}
public void savePosition() {
@ -150,7 +154,7 @@ public class ToggleSplitPane extends JSplitPane {
@Override
public int getLastDividerLocation() {
if (resizable) {
if (isResizable()) {
return super.getLastDividerLocation();
} else {
return getLocationForRelativePosition(lockedPosition);
@ -159,7 +163,7 @@ public class ToggleSplitPane extends JSplitPane {
@Override
public int getDividerLocation() {
if (resizable) {
if (isResizable()) {
return super.getDividerLocation();
} else {
return getLocationForRelativePosition(lockedPosition);
@ -170,7 +174,7 @@ public class ToggleSplitPane extends JSplitPane {
public void setDividerLocation(final int location) {
if (isInLayout) return;
isInLayout = true;
if (resizable) {
if (isResizable()) {
super.setDividerLocation(location);
} else {
forceSetDividerLocation(restorePercentage);

Loading…
Cancel
Save