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 @@ -21,11 +21,12 @@
import javafx.application.Platform;
import javafx.beans.property.StringProperty;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.control.Label;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.Priority;
import javafx.scene.layout.VBox;
import org.jackhuang.hmcl.task.*;
import javafx.scene.layout.*;
Comment thread
Glavo marked this conversation as resolved.
import org.jackhuang.hmcl.task.FetchTask;
import org.jackhuang.hmcl.task.TaskExecutor;
import org.jackhuang.hmcl.task.TaskListener;
import org.jackhuang.hmcl.ui.FXUtils;
import org.jackhuang.hmcl.util.TaskCancellationAction;
import org.jackhuang.hmcl.util.i18n.I18n;
Expand Down Expand Up @@ -67,16 +68,18 @@ public TaskExecutorDialogPane(@NotNull TaskCancellationAction cancel) {
center.getChildren().setAll(lblTitle, taskListPane);
}

BorderPane bottom = new BorderPane();
this.setBottom(bottom);
HBox bottom = new HBox();
bottom.setAlignment(Pos.CENTER_LEFT);
bottom.setPadding(new Insets(0, 8, 8, 8));
bottom.setSpacing(8);
this.setBottom(bottom);
{
lblProgress = new Label();
bottom.setLeft(lblProgress);

Region spacer = new Region();
Comment on lines 77 to +78
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

lblProgress 的文本为空时(例如在任务刚开始或非下载任务中),由于它默认是可见且参与布局的,HBox 仍会为其保留位置并应用 spacing(8)。这会导致左侧出现额外的 8 像素间距,从而破坏整体的对齐效果。

建议将 lblProgressvisiblemanaged 属性与其文本是否为空进行绑定。这样当文本为空时,它不会占用任何布局空间,也不会产生多余的间距。

Suggested change
lblProgress = new Label();
bottom.setLeft(lblProgress);
Region spacer = new Region();
lblProgress = new Label();
lblProgress.visibleProperty().bind(lblProgress.textProperty().isNotEmpty());
lblProgress.managedProperty().bind(lblProgress.visibleProperty());
Region spacer = new Region();

HBox.setHgrow(spacer, Priority.ALWAYS);
btnCancel = new JFXButton(i18n("button.cancel"));
btnCancel.getStyleClass().add("dialog-cancel");
bottom.setRight(btnCancel);
bottom.getChildren().setAll(lblProgress, spacer, btnCancel);
}

setCancel(cancel);
Expand Down