From 4cbf5ce979bdf391373845692bbb91f6444240a9 Mon Sep 17 00:00:00 2001 From: Glavo Date: Thu, 25 Jan 2024 21:11:21 +0800 Subject: [PATCH] Fix #2680: Revert TwoLineListItem (#2681) --- .../jackhuang/hmcl/ui/construct/TwoLineListItem.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/TwoLineListItem.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/TwoLineListItem.java index c0f6929cd..51c98e159 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/TwoLineListItem.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/TwoLineListItem.java @@ -26,7 +26,6 @@ import javafx.geometry.Insets; import javafx.scene.Node; import javafx.scene.control.Label; import javafx.scene.layout.HBox; -import javafx.scene.layout.Priority; import javafx.scene.layout.VBox; import org.jackhuang.hmcl.ui.FXUtils; import org.jackhuang.hmcl.util.AggregatedObservableList; @@ -39,6 +38,9 @@ public class TwoLineListItem extends VBox { private final ObservableList tags = FXCollections.observableArrayList(); private final StringProperty subtitle = new SimpleStringProperty(this, "subtitle"); + private final ObservableList tagLabels; + private final AggregatedObservableList firstLineChildren; + public TwoLineListItem(String titleString, String subtitleString) { this(); @@ -56,14 +58,14 @@ public class TwoLineListItem extends VBox { lblTitle.getStyleClass().add("title"); lblTitle.textProperty().bind(title); - ObservableList tagLabels = MappedObservableList.create(tags, tag -> { + tagLabels = MappedObservableList.create(tags, tag -> { Label tagLabel = new Label(); tagLabel.getStyleClass().add("tag"); tagLabel.setText(tag); HBox.setMargin(tagLabel, new Insets(0, 8, 0, 0)); return tagLabel; }); - AggregatedObservableList firstLineChildren = new AggregatedObservableList<>(); + firstLineChildren = new AggregatedObservableList<>(); firstLineChildren.appendList(FXCollections.singletonObservableList(lblTitle)); firstLineChildren.appendList(tagLabels); Bindings.bindContent(firstLine.getChildren(), firstLineChildren.getAggregatedList()); @@ -83,9 +85,6 @@ public class TwoLineListItem extends VBox { }); getStyleClass().add(DEFAULT_STYLE_CLASS); - - this.minWidthProperty().set(0); - HBox.setHgrow(this, Priority.SOMETIMES); } public String getTitle() {