Skip to content
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

Only show vertical scrollbar if not enough space #2780

Merged
merged 1 commit into from
Sep 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@
import javafx.geometry.Bounds;
import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.control.*;
import javafx.scene.control.ContentDisplay;
import javafx.scene.control.Label;
import javafx.scene.control.ListCell;
import javafx.scene.control.ListView;
import javafx.scene.control.PopupControl;
import javafx.scene.control.Skin;
import javafx.scene.image.ImageView;
import javafx.scene.layout.HBox;
import javafx.scene.layout.StackPane;
Expand Down Expand Up @@ -101,6 +106,8 @@ private void initialize() {
hide();
}
});

maybeHideScrollbar();
}

private void showPopup() {
Expand Down Expand Up @@ -142,6 +149,17 @@ private boolean hasMouseExited(double mouseX, double mouseY) {
return !(inPopupBounds || inAreaBetweenButtonAndPopup);
}

private void maybeHideScrollbar() {
String hideScrollbarClass = "hide-vertical-scrollbar";
if (userProfileListView.getItems().size() <= MAX_USERS_SHOWN_AT_THE_SAME_TIME) {
if (!userProfileListView.getStyleClass().contains(hideScrollbarClass)) {
userProfileListView.getStyleClass().add(hideScrollbarClass);
}
} else {
userProfileListView.getStyleClass().remove(hideScrollbarClass);
}
}

private Callback<ListView<ListItem>, ListCell<ListItem>> getCellFactory() {
return new Callback<>() {
@Override
Expand Down
Loading