-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Fix #13402: Make sidebar width proportional to window size and persist across sessions #13405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
c3c5654
7de6fd6
4054604
e93f078
5d621bb
a136181
50bb101
df94a74
8bfd8ad
0f501ad
a14e9d7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,8 +83,9 @@ public class JabRefFrame extends BorderPane implements LibraryTabContainer, UiMe | |
private enum PanelMode { MAIN_TABLE, MAIN_TABLE_AND_ENTRY_EDITOR } | ||
|
||
public static final String FRAME_TITLE = "JabRef"; | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(JabRefFrame.class); | ||
private static final double DEFAULT_SIDEBAR_DIVIDER_POSITION = 0.2; | ||
|
||
private final GuiPreferences preferences; | ||
private final AiService aiService; | ||
|
@@ -213,6 +214,7 @@ public JabRefFrame(Stage mainStage, | |
initKeyBindings(); | ||
frameDndHandler.initDragAndDrop(); | ||
initBindings(); | ||
initSidebarResizeListener(); | ||
} | ||
|
||
private void initLayout() { | ||
|
@@ -296,12 +298,26 @@ private void updateEditorPane() { | |
|
||
public void updateHorizontalDividerPosition() { | ||
if (mainStage.isShowing() && !sidePane.getChildren().isEmpty()) { | ||
horizontalSplit.setDividerPositions(preferences.getGuiPreferences().getHorizontalDividerPosition() / horizontalSplit.getWidth()); | ||
horizontalDividerSubscription = EasyBind.valueAt(horizontalSplit.getDividers(), 0) | ||
.mapObservable(SplitPane.Divider::positionProperty) | ||
.listenToValues((_, newValue) -> preferences.getGuiPreferences().setHorizontalDividerPosition(newValue.doubleValue())); | ||
double savedProportion = preferences.getGuiPreferences().getHorizontalDividerPosition(); | ||
if (Double.isNaN(savedProportion) || savedProportion <= 0 || savedProportion >= 1) { | ||
savedProportion = DEFAULT_SIDEBAR_DIVIDER_POSITION; | ||
} | ||
horizontalSplit.setDividerPositions(savedProportion); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indent is off |
||
|
||
if (horizontalDividerSubscription != null) { | ||
horizontalDividerSubscription.unsubscribe(); | ||
} | ||
|
||
horizontalDividerSubscription = EasyBind.valueAt(horizontalSplit.getDividers(), 0) | ||
.mapObservable(SplitPane.Divider::positionProperty) | ||
.listenToValues((_, newValue) -> { | ||
double newPos = newValue.doubleValue(); | ||
if (newPos > 0.0 && newPos < 1.0) { | ||
preferences.getGuiPreferences().setHorizontalDividerPosition(newPos); | ||
} | ||
}); | ||
} | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ? strange indent |
||
|
||
public void updateVerticalDividerPosition() { | ||
if (mainStage.isShowing() && panelMode.get() == PanelMode.MAIN_TABLE_AND_ENTRY_EDITOR) { | ||
|
@@ -447,6 +463,14 @@ private void initBindings() { | |
EasyBind.subscribe(preferences.getWorkspacePreferences().hideTabBarProperty(), _ -> updateTabBarVisible()); | ||
} | ||
|
||
private void initSidebarResizeListener() { | ||
mainStage.widthProperty().addListener((obs, oldVal, newVal) -> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why no |
||
if (!sidePane.getChildren().isEmpty()) { | ||
updateHorizontalDividerPosition(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here, inside, always a new listener is created. This will let the memory grow and grow and grow and grow and grow. |
||
} | ||
}); | ||
} | ||
|
||
private void updateTabBarVisible() { | ||
if (preferences.getWorkspacePreferences().shouldHideTabBar() && stateManager.getOpenDatabases().size() <= 1) { | ||
if (!tabbedPane.getStyleClass().contains("hide-tab-bar")) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why more spaces?