Skip to content
Open
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 @@ -31,7 +31,6 @@
import javafx.scene.control.ListCell;
import javafx.scene.control.ListView;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Region;
import javafx.scene.layout.StackPane;
import org.jackhuang.hmcl.game.Version;
Expand Down Expand Up @@ -66,10 +65,11 @@ public GameListPopupMenu() {
this.getStyleClass().add("popup-menu-content");

listView.setCellFactory(Cell::new);
listView.setFixedCellSize(60);

listView.setFixedCellSize(50);
listView.setPrefWidth(300);

listView.prefHeightProperty().bind(Bindings.size(getItems()).multiply(60).add(2));
listView.prefHeightProperty().bind(Bindings.size(getItems()).multiply(50).add(2));
Comment thread
CiiLu marked this conversation as resolved.

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

public Cell(ListView<GameItem> listView) {
this.setPadding(Insets.EMPTY);
HBox root = new HBox();

root.setSpacing(8);
root.setAlignment(Pos.CENTER_LEFT);

StackPane imageViewContainer = new StackPane();
FXUtils.setLimitWidth(imageViewContainer, 32);
FXUtils.setLimitHeight(imageViewContainer, 32);

this.imageView = new ImageContainer(32);
imageViewContainer.getChildren().setAll(imageView);
this.imageView.setMouseTransparent(true);
BorderPane.setAlignment(imageView, Pos.CENTER);

this.content = new TwoLineListItem();
this.content.setMouseTransparent(true);
FXUtils.onChangeAndOperate(tag, tag -> {
content.getTags().clear();
if (StringUtils.isNotBlank(tag)) {
content.addTag(tag);
}
});
BorderPane.setAlignment(content, Pos.CENTER);
root.getChildren().setAll(imageView, content);

StackPane pane = new StackPane();
pane.getChildren().setAll(root);
pane.getStyleClass().add("menu-container");
root.setMouseTransparent(true);
BorderPane container = new BorderPane();
container.getStyleClass().add("container");
container.setPickOnBounds(false);
container.setLeft(imageView);
container.setCenter(content);

RipplerContainer ripplerContainer = new RipplerContainer(pane);
FXUtils.onClicked(ripplerContainer, () -> {
RipplerContainer ripplerContainer = new RipplerContainer(container);

StackPane rootPane = new StackPane();
rootPane.getStyleClass().add("advanced-list-item");
rootPane.getChildren().setAll(ripplerContainer);
Comment thread
CiiLu marked this conversation as resolved.
rootPane.maxWidthProperty().bind(listView.widthProperty().subtract(5));

FXUtils.onClicked(rootPane, () -> {
GameItem item = getItem();
if (item != null) {
item.getProfile().setSelectedVersion(item.getId());
if (getScene().getWindow() instanceof JFXPopup popup)
popup.hide();
}
});
this.graphic = ripplerContainer;
ripplerContainer.maxWidthProperty().bind(listView.widthProperty().subtract(5));

this.graphic = rootPane;
}

@Override
Expand Down