Skip to content

Commit

Permalink
Merge pull request #2780 from axpoems/fix-vertical-scrollbar
Browse files Browse the repository at this point in the history
Only show vertical scrollbar if not enough space
  • Loading branch information
HenrikJannsen authored Sep 8, 2024
2 parents 89d70cf + e0b9c57 commit b2ef722
Showing 1 changed file with 19 additions and 1 deletion.
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

0 comments on commit b2ef722

Please sign in to comment.