Skip to content

Commit 9b8e67b

Browse files
authored
优化游戏列表 Popup 列表项大小 (#6119)
1 parent f5a5e6a commit 9b8e67b

1 file changed

Lines changed: 21 additions & 22 deletions

File tree

HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/GameListPopupMenu.java

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import javafx.scene.control.ListCell;
3232
import javafx.scene.control.ListView;
3333
import javafx.scene.layout.BorderPane;
34-
import javafx.scene.layout.HBox;
3534
import javafx.scene.layout.Region;
3635
import javafx.scene.layout.StackPane;
3736
import org.jackhuang.hmcl.game.Version;
@@ -69,10 +68,11 @@ public GameListPopupMenu() {
6968
this.getStyleClass().add("popup-menu-content");
7069

7170
listView.setCellFactory(Cell::new);
72-
listView.setFixedCellSize(60);
71+
72+
listView.setFixedCellSize(50);
7373
listView.setPrefWidth(300);
7474

75-
listView.prefHeightProperty().bind(Bindings.size(getItems()).multiply(60).add(2));
75+
listView.prefHeightProperty().bind(Bindings.size(getItems()).multiply(50).add(2));
7676

7777
Label placeholder = new Label(i18n("version.empty"));
7878
placeholder.setStyle("-fx-padding: 10px; -fx-text-fill: -monet-on-surface-variant; -fx-font-style: italic;");
@@ -97,44 +97,43 @@ private static final class Cell extends ListCell<GameItem> {
9797

9898
public Cell(ListView<GameItem> listView) {
9999
this.setPadding(Insets.EMPTY);
100-
HBox root = new HBox();
101-
102-
root.setSpacing(8);
103-
root.setAlignment(Pos.CENTER_LEFT);
104-
105-
StackPane imageViewContainer = new StackPane();
106-
FXUtils.setLimitWidth(imageViewContainer, 32);
107-
FXUtils.setLimitHeight(imageViewContainer, 32);
108100

109101
this.imageView = new ImageContainer(32);
110-
imageViewContainer.getChildren().setAll(imageView);
102+
this.imageView.setMouseTransparent(true);
103+
BorderPane.setAlignment(imageView, Pos.CENTER);
111104

112105
this.content = new TwoLineListItem();
106+
this.content.setMouseTransparent(true);
113107
FXUtils.onChangeAndOperate(tag, tag -> {
114108
content.getTags().clear();
115109
if (StringUtils.isNotBlank(tag)) {
116110
content.addTag(tag);
117111
}
118112
});
119-
BorderPane.setAlignment(content, Pos.CENTER);
120-
root.getChildren().setAll(imageView, content);
121113

122-
StackPane pane = new StackPane();
123-
pane.getChildren().setAll(root);
124-
pane.getStyleClass().add("menu-container");
125-
root.setMouseTransparent(true);
114+
BorderPane container = new BorderPane();
115+
container.getStyleClass().add("container");
116+
container.setPickOnBounds(false);
117+
container.setLeft(imageView);
118+
container.setCenter(content);
126119

127-
RipplerContainer ripplerContainer = new RipplerContainer(pane);
128-
FXUtils.onClicked(ripplerContainer, () -> {
120+
RipplerContainer ripplerContainer = new RipplerContainer(container);
121+
122+
StackPane rootPane = new StackPane();
123+
rootPane.getStyleClass().add("advanced-list-item");
124+
rootPane.getChildren().setAll(ripplerContainer);
125+
rootPane.maxWidthProperty().bind(listView.widthProperty().subtract(5));
126+
127+
FXUtils.onClicked(rootPane, () -> {
129128
GameItem item = getItem();
130129
if (item != null) {
131130
item.getProfile().setSelectedVersion(item.getId());
132131
if (getScene().getWindow() instanceof JFXPopup popup)
133132
popup.hide();
134133
}
135134
});
136-
this.graphic = ripplerContainer;
137-
ripplerContainer.maxWidthProperty().bind(listView.widthProperty().subtract(5));
135+
136+
this.graphic = rootPane;
138137
}
139138

140139
@Override

0 commit comments

Comments
 (0)