diff --git a/desktop/src/main/java/bisq/desktop/main/overlays/Overlay.java b/desktop/src/main/java/bisq/desktop/main/overlays/Overlay.java index b2f7ae57e18..93475bcc0c5 100644 --- a/desktop/src/main/java/bisq/desktop/main/overlays/Overlay.java +++ b/desktop/src/main/java/bisq/desktop/main/overlays/Overlay.java @@ -19,6 +19,7 @@ import bisq.desktop.app.BisqApp; import bisq.desktop.components.AutoTooltipButton; +import bisq.desktop.components.AutoTooltipCheckBox; import bisq.desktop.components.AutoTooltipLabel; import bisq.desktop.components.BusyAnimation; import bisq.desktop.main.MainView; @@ -85,8 +86,6 @@ import lombok.extern.slf4j.Slf4j; -import static bisq.desktop.util.FormBuilder.addCheckBox; - @Slf4j public abstract class Overlay { @@ -156,6 +155,7 @@ protected enum Type { truncatedMessage; private String headlineStyle; protected Button actionButton, secondaryActionButton; + private HBox buttonBox; protected AutoTooltipButton closeButton; private HPos buttonAlignment = HPos.RIGHT; @@ -867,11 +867,12 @@ protected void addDontShowAgainCheckBox(boolean isChecked) { if (dontShowAgainText == null) dontShowAgainText = Res.get("popup.doNotShowAgain"); - CheckBox dontShowAgainCheckBox = addCheckBox(gridPane, rowIndex, dontShowAgainText, buttonDistance - 1); + CheckBox dontShowAgainCheckBox = new AutoTooltipCheckBox(dontShowAgainText); + HBox.setHgrow(dontShowAgainCheckBox, Priority.NEVER); + buttonBox.getChildren().add(0, dontShowAgainCheckBox); + dontShowAgainCheckBox.setSelected(isChecked); DontShowAgainLookup.dontShowAgain(dontShowAgainId, isChecked); - GridPane.setColumnIndex(dontShowAgainCheckBox, 0); - GridPane.setHalignment(dontShowAgainCheckBox, HPos.LEFT); dontShowAgainCheckBox.setOnAction(e -> DontShowAgainLookup.dontShowAgain(dontShowAgainId, dontShowAgainCheckBox.isSelected())); } } @@ -885,10 +886,30 @@ protected void addButtons() { closeButton = new AutoTooltipButton(closeButtonText == null ? Res.get("shared.close") : closeButtonText); closeButton.getStyleClass().add("compact-button"); closeButton.setOnAction(event -> doClose()); + closeButton.setMinWidth(120); + HBox.setHgrow(closeButton, Priority.SOMETIMES); + } + + Pane spacer = new Pane(); + + if (buttonAlignment == HPos.RIGHT) { + HBox.setHgrow(spacer, Priority.ALWAYS); + spacer.setMaxWidth(Double.MAX_VALUE); } + + buttonBox = new HBox(); + + GridPane.setHalignment(buttonBox, buttonAlignment); + GridPane.setRowIndex(buttonBox, ++rowIndex); + GridPane.setColumnSpan(buttonBox, 2); + GridPane.setMargin(buttonBox, new Insets(buttonDistance, 0, 0, 0)); + gridPane.getChildren().add(buttonBox); + if (actionHandlerOptional.isPresent() || actionButtonText != null) { actionButton = new AutoTooltipButton(actionButtonText == null ? Res.get("shared.ok") : actionButtonText); actionButton.setDefaultButton(true); + HBox.setHgrow(actionButton, Priority.SOMETIMES); + actionButton.getStyleClass().add("action-button"); //TODO app wide focus //actionButton.requestFocus(); @@ -897,17 +918,14 @@ protected void addButtons() { actionHandlerOptional.ifPresent(Runnable::run); }); - Pane spacer = new Pane(); - - HBox hBox = new HBox(); - hBox.setSpacing(10); + buttonBox.setSpacing(10); - hBox.setAlignment(Pos.CENTER); + buttonBox.setAlignment(Pos.CENTER); if (buttonAlignment == HPos.RIGHT) - hBox.getChildren().add(spacer); + buttonBox.getChildren().add(spacer); - hBox.getChildren().addAll(actionButton); + buttonBox.getChildren().addAll(actionButton); if (secondaryActionButtonText != null && secondaryActionHandlerOptional.isPresent()) { secondaryActionButton = new AutoTooltipButton(secondaryActionButtonText); @@ -916,31 +934,14 @@ protected void addButtons() { secondaryActionHandlerOptional.ifPresent(Runnable::run); }); - hBox.getChildren().add(secondaryActionButton); + buttonBox.getChildren().add(secondaryActionButton); } if (!hideCloseButton) - hBox.getChildren().add(closeButton); - - - if (buttonAlignment == HPos.RIGHT) { - HBox.setHgrow(spacer, Priority.ALWAYS); - spacer.setMaxWidth(Double.MAX_VALUE); - } - - GridPane.setHalignment(hBox, buttonAlignment); - GridPane.setRowIndex(hBox, ++rowIndex); - GridPane.setColumnSpan(hBox, 2); - GridPane.setMargin(hBox, new Insets(buttonDistance, 0, 0, 0)); - gridPane.getChildren().add(hBox); + buttonBox.getChildren().add(closeButton); } else if (!hideCloseButton) { closeButton.setDefaultButton(true); - GridPane.setHalignment(closeButton, buttonAlignment); - GridPane.setColumnSpan(closeButton, 2); - if (!showReportErrorButtons) - GridPane.setMargin(closeButton, new Insets(buttonDistance, 0, 0, 0)); - GridPane.setRowIndex(closeButton, ++rowIndex); - gridPane.getChildren().add(closeButton); + buttonBox.getChildren().addAll(spacer, closeButton); } } diff --git a/desktop/src/main/java/bisq/desktop/main/overlays/windows/DaoLaunchWindow.java b/desktop/src/main/java/bisq/desktop/main/overlays/windows/DaoLaunchWindow.java index 4d137190d77..af95c3c0f1d 100644 --- a/desktop/src/main/java/bisq/desktop/main/overlays/windows/DaoLaunchWindow.java +++ b/desktop/src/main/java/bisq/desktop/main/overlays/windows/DaoLaunchWindow.java @@ -127,8 +127,7 @@ protected void onShow() { protected void addButtons() { super.addButtons(); - closeButton.setPrefWidth(162); - actionButton.setPrefWidth(162); + closeButton.prefWidthProperty().bind(actionButton.widthProperty()); } ///////////////////////////////////////////////////////////////////////////////////////////