diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/FXUtils.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/FXUtils.java index 0a1ade2f2..a24e5ab9b 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/FXUtils.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/FXUtils.java @@ -433,6 +433,20 @@ public final class FXUtils { return pane; } + public static void limitCellWidth(ListView listView, ListCell cell) { + ReadOnlyDoubleProperty widthProperty; + + if (listView.lookup(".clipped-container") instanceof Region clippedContainer) { + widthProperty = clippedContainer.widthProperty(); + } else { + widthProperty = listView.widthProperty(); + } + + cell.maxWidthProperty().bind(widthProperty); + cell.prefWidthProperty().bind(widthProperty); + cell.minWidthProperty().bind(widthProperty); + } + public static void smoothScrolling(ScrollPane scrollPane) { if (AnimationUtils.isAnimationEnabled()) ScrollUtils.addSmoothScrolling(scrollPane); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/JavaManagementPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/JavaManagementPage.java index 1465c9bab..90363c91c 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/JavaManagementPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/JavaManagementPage.java @@ -189,6 +189,7 @@ public final class JavaManagementPage extends ListPageBase { JavaPageSkin(JavaManagementPage skinnable) { super(skinnable); + this.listView.getStyleClass().add("no-horizontal-scrollbar"); } @Override @@ -210,7 +211,7 @@ public final class JavaManagementPage extends ListPageBase { @Override protected ListCell createListCell(JFXListView listView) { - return new JavaItemCell(); + return new JavaItemCell(listView); } } @@ -222,7 +223,7 @@ public final class JavaManagementPage extends ListPageBase { private final StackPane removeIconPane; private final Tooltip removeTooltip = new Tooltip(); - JavaItemCell() { + JavaItemCell(JFXListView listView) { BorderPane root = new BorderPane(); HBox center = new HBox(); @@ -272,6 +273,8 @@ public final class JavaManagementPage extends ListPageBase { root.setPadding(new Insets(8)); this.graphic = new RipplerContainer(root); + + FXUtils.limitCellWidth(listView, this); } @Override diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/DownloadListPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/DownloadListPage.java index 171fac320..676998138 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/DownloadListPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/DownloadListPage.java @@ -558,11 +558,8 @@ public class DownloadListPage extends Control implements DecoratorPage, VersionP setPrefWidth(0); - if (listView.lookup(".clipped-container") instanceof Region clippedContainer) { - maxWidthProperty().bind(clippedContainer.widthProperty()); - prefWidthProperty().bind(clippedContainer.widthProperty()); - minWidthProperty().bind(clippedContainer.widthProperty()); - } + FXUtils.limitCellWidth(listView, this); + } @Override diff --git a/HMCL/src/main/resources/assets/css/root.css b/HMCL/src/main/resources/assets/css/root.css index 3076120ea..eb10eae33 100644 --- a/HMCL/src/main/resources/assets/css/root.css +++ b/HMCL/src/main/resources/assets/css/root.css @@ -955,6 +955,13 @@ -fx-background-color: transparent; } +.no-horizontal-scrollbar .scroll-bar:horizontal { + -fx-opacity: 0; + -fx-max-height: 0; + -fx-min-height: 0; + -fx-pref-height: 0; +} + .options-list { -fx-background-color: transparent; -fx-effect: dropshadow(gaussian, rgba(0, 0, 0, 0.26), 5, 0.06, -0.5, 1);