Fix display of mod with extra long display name (#6436)

This commit is contained in:
ZZZank
2026-09-08 21:57:32 +08:00
committed by GitHub
parent ce51dc4dd7
commit 7a8f931641
2 changed files with 10 additions and 2 deletions
@@ -25,6 +25,7 @@ import javafx.collections.ObservableList;
import javafx.css.PseudoClass;
import javafx.geometry.Pos;
import javafx.scene.control.Label;
import javafx.scene.control.OverrunStyle;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
import javafx.scene.layout.VBox;
@@ -45,6 +46,7 @@ public class TwoLineListItem extends VBox {
lblTitle = new Label();
lblTitle.getStyleClass().add("title");
lblTitle.setTextOverrun(OverrunStyle.ELLIPSIS);
this.firstLine = new HBox(lblTitle);
firstLine.getStyleClass().add("first-line");
@@ -167,8 +169,12 @@ public class TwoLineListItem extends VBox {
var tagsBox = new HBox(8);
tagsBox.getStyleClass().add("tags");
tagsBox.setAlignment(Pos.CENTER_LEFT);
// grow lazily after title has been placed
tagsBox.setPrefWidth(0);
tagsBox.setMinWidth(0);
HBox.setHgrow(tagsBox, Priority.ALWAYS);
HBox.setHgrow(tagsBox, Priority.SOMETIMES);
Bindings.bindContent(tagsBox.getChildren(), tags);
var isNotEmpty = Bindings.isNotEmpty(tags);
tagsBox.managedProperty().bind(isNotEmpty);
@@ -176,7 +182,8 @@ public class TwoLineListItem extends VBox {
FXUtils.setOverflowHidden(tagsBox);
lblTitle.setMinWidth(Label.USE_PREF_SIZE);
HBox.setHgrow(lblTitle, Priority.ALWAYS);
lblTitle.setMinWidth(0);
firstLine.getChildren().setAll(lblTitle, tagsBox);
}
return tags;
@@ -685,6 +685,7 @@ public final class ModListPage extends ListPageBase<ModListPage.ModInfoObject> i
modInfo.loadIcon(imageContainer, null);
TwoLineListItem title = new TwoLineListItem();
title.getTitleLabel().setWrapText(true);
if (modInfo.getModTranslations() != null && I18n.isUseChinese())
title.setTitle(modInfo.getModTranslations().getDisplayName());
else