Skip to content

Commit 615b1db

Browse files
authored
fix: #5844 整合包实例版本号在特定场景下不显示 (#6054)
1 parent 0fa51f8 commit 615b1db

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/TwoLineListItem.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import javafx.beans.InvalidationListener;
2121
import javafx.beans.binding.Bindings;
22+
import javafx.beans.binding.DoubleBinding;
2223
import javafx.beans.property.StringProperty;
2324
import javafx.beans.property.StringPropertyBase;
2425
import javafx.collections.FXCollections;
@@ -30,7 +31,6 @@
3031
import javafx.scene.layout.HBox;
3132
import javafx.scene.layout.Priority;
3233
import javafx.scene.layout.VBox;
33-
import org.jackhuang.hmcl.ui.FXUtils;
3434

3535
public class TwoLineListItem extends VBox {
3636
private static final String DEFAULT_STYLE_CLASS = "two-line-list-item";
@@ -177,7 +177,14 @@ public ObservableList<Label> getTags() {
177177
lblTitle.setMinWidth(Label.USE_PREF_SIZE);
178178
scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
179179
scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
180-
FXUtils.onChangeAndOperate(tagsBox.heightProperty(), height -> FXUtils.setLimitHeight(scrollPane, height.doubleValue()));
180+
DoubleBinding expectedHeight = Bindings.createDoubleBinding(
181+
() -> tags.isEmpty() ? 0.0 : tagsBox.prefHeight(-1),
182+
tags
183+
);
184+
185+
scrollPane.minHeightProperty().bind(expectedHeight);
186+
scrollPane.prefHeightProperty().bind(expectedHeight);
187+
scrollPane.maxHeightProperty().bind(expectedHeight);
181188
firstLine.getChildren().setAll(lblTitle, scrollPane);
182189

183190
tags.addListener((InvalidationListener) ignored -> scrollPane.requestLayout());

0 commit comments

Comments
 (0)