From 313eec4c102318bcd9ff4565a94ac71d2eb36cd8 Mon Sep 17 00:00:00 2001 From: Glavo Date: Tue, 17 Feb 2026 22:36:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20JFXDialogLayout=20?= =?UTF-8?q?=E6=BA=90=E4=BB=A3=E7=A0=81=20(#5546)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/jfoenix/controls/JFXDialogLayout.java | 104 ++++++++++++++++++ HMCL/src/main/resources/assets/css/root.css | 1 + 2 files changed, 105 insertions(+) create mode 100644 HMCL/src/main/java/com/jfoenix/controls/JFXDialogLayout.java diff --git a/HMCL/src/main/java/com/jfoenix/controls/JFXDialogLayout.java b/HMCL/src/main/java/com/jfoenix/controls/JFXDialogLayout.java new file mode 100644 index 000000000..0c032bc1b --- /dev/null +++ b/HMCL/src/main/java/com/jfoenix/controls/JFXDialogLayout.java @@ -0,0 +1,104 @@ +// +// Source code recreated from a .class file by IntelliJ IDEA +// (powered by Fernflower decompiler) +// + +package com.jfoenix.controls; + +import java.util.List; + +import javafx.collections.ObservableList; +import javafx.geometry.Insets; +import javafx.geometry.Orientation; +import javafx.scene.Node; +import javafx.scene.layout.FlowPane; +import javafx.scene.layout.StackPane; +import javafx.scene.layout.VBox; + +public class JFXDialogLayout extends StackPane { + private final StackPane heading = new StackPane(); + private final StackPane body = new StackPane(); + private final FlowPane actions = new FlowPane() { + protected double computeMinWidth(double height) { + if (this.getContentBias() == Orientation.HORIZONTAL) { + double maxPref = 0.0; + for (Node child : this.getChildren()) { + if (child.isManaged()) { + maxPref = Math.max(maxPref, child.minWidth(-1.0)); + } + } + + Insets insets = this.getInsets(); + return insets.getLeft() + this.snapSizeX(maxPref) + insets.getRight(); + } else { + return this.computePrefWidth(height); + } + } + + protected double computeMinHeight(double width) { + if (this.getContentBias() == Orientation.VERTICAL) { + double maxPref = 0.0; + + for (Node child : this.getChildren()) { + if (child.isManaged()) { + maxPref = Math.max(maxPref, child.minHeight(-1.0)); + } + } + + Insets insets = this.getInsets(); + return insets.getTop() + this.snapSizeY(maxPref) + insets.getBottom(); + } else { + return this.computePrefHeight(width); + } + } + }; + private static final String DEFAULT_STYLE_CLASS = "jfx-dialog-layout"; + + public JFXDialogLayout() { + this.getStyleClass().add(DEFAULT_STYLE_CLASS); + + VBox layout = new VBox(); + + this.heading.getStyleClass().add("jfx-layout-heading"); + this.heading.getStyleClass().add("title"); + + this.body.getStyleClass().add("jfx-layout-body"); + this.body.prefHeightProperty().bind(this.prefHeightProperty()); + this.body.prefWidthProperty().bind(this.prefWidthProperty()); + + this.actions.getStyleClass().add("jfx-layout-actions"); + + layout.getChildren().setAll(this.heading, this.body, this.actions); + + this.getChildren().add(layout); + } + + public ObservableList getHeading() { + return this.heading.getChildren(); + } + + public void setHeading(Node... titleContent) { + this.heading.getChildren().setAll(titleContent); + } + + public ObservableList getBody() { + return this.body.getChildren(); + } + + public void setBody(Node... body) { + this.body.getChildren().setAll(body); + } + + public ObservableList getActions() { + return this.actions.getChildren(); + } + + public void setActions(Node... actions) { + this.actions.getChildren().setAll(actions); + } + + public void setActions(List actions) { + this.actions.getChildren().setAll(actions); + } + +} diff --git a/HMCL/src/main/resources/assets/css/root.css b/HMCL/src/main/resources/assets/css/root.css index b22fc69b5..79a53a080 100644 --- a/HMCL/src/main/resources/assets/css/root.css +++ b/HMCL/src/main/resources/assets/css/root.css @@ -532,6 +532,7 @@ } .jfx-layout-heading { + -fx-font-weight: BOLD; -fx-font-size: 20.0px; -fx-alignment: center-left; -fx-padding: 5.0 0.0 5.0 0.0;