From 6731512367d9020eae00527e4e821ae5cbad52cd Mon Sep 17 00:00:00 2001 From: ThisPC Date: Thu, 31 Aug 2023 17:24:14 +0800 Subject: [PATCH] Feature to add scrollbar on message of overlays --- .../TraditionalAccountsView.java | 1 + .../haveno/desktop/main/overlays/Overlay.java | 36 +++++++++++++++---- .../main/overlays/windows/TacWindow.java | 1 + 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/desktop/src/main/java/haveno/desktop/main/account/content/traditionalaccounts/TraditionalAccountsView.java b/desktop/src/main/java/haveno/desktop/main/account/content/traditionalaccounts/TraditionalAccountsView.java index e06cbf9843..1f108b817a 100644 --- a/desktop/src/main/java/haveno/desktop/main/account/content/traditionalaccounts/TraditionalAccountsView.java +++ b/desktop/src/main/java/haveno/desktop/main/account/content/traditionalaccounts/TraditionalAccountsView.java @@ -271,6 +271,7 @@ public class TraditionalAccountsView extends PaymentAccountsView doSaveNewAccount(paymentAccount)) + .showScrollPane() .show(); } else if (paymentAccount instanceof CashAtAtmAccount) { // CashAtAtm has no chargeback risk so we don't show the text from payment.limits.info. diff --git a/desktop/src/main/java/haveno/desktop/main/overlays/Overlay.java b/desktop/src/main/java/haveno/desktop/main/overlays/Overlay.java index d9f3630595..944b07b302 100644 --- a/desktop/src/main/java/haveno/desktop/main/overlays/Overlay.java +++ b/desktop/src/main/java/haveno/desktop/main/overlays/Overlay.java @@ -54,6 +54,8 @@ import javafx.scene.control.Button; import javafx.scene.control.CheckBox; import javafx.scene.control.Hyperlink; import javafx.scene.control.Label; +import javafx.scene.control.ScrollPane; +import javafx.scene.control.ScrollPane.ScrollBarPolicy; import javafx.scene.input.KeyCode; import javafx.scene.layout.ColumnConstraints; import javafx.scene.layout.GridPane; @@ -154,6 +156,7 @@ public abstract class Overlay> { protected Integer displayOrderPriority = Integer.MAX_VALUE; protected boolean useAnimation = true; + protected boolean showScrollPane = false; protected Label headlineIcon, headLineLabel, messageLabel; protected String headLine, message, closeButtonText, actionButtonText, @@ -164,6 +167,7 @@ public abstract class Overlay> { protected Button actionButton, secondaryActionButton; private HBox buttonBox; protected AutoTooltipButton closeButton; + protected ScrollPane scrollPane; private HPos buttonAlignment = HPos.RIGHT; @@ -470,6 +474,11 @@ public abstract class Overlay> { return cast(); } + public T showScrollPane() { + this.showScrollPane = true; + return cast(); + } + /////////////////////////////////////////////////////////////////////////////////////////// // Protected @@ -807,13 +816,26 @@ public abstract class Overlay> { messageLabel = new AutoTooltipLabel(truncatedMessage); messageLabel.setMouseTransparent(true); messageLabel.setWrapText(true); - GridPane.setHalignment(messageLabel, HPos.LEFT); - GridPane.setHgrow(messageLabel, Priority.ALWAYS); - GridPane.setMargin(messageLabel, new Insets(3, 0, 0, 0)); - GridPane.setRowIndex(messageLabel, ++rowIndex); - GridPane.setColumnIndex(messageLabel, 0); - GridPane.setColumnSpan(messageLabel, 2); - gridPane.getChildren().add(messageLabel); + + Region messageRegion; + if (showScrollPane) { + scrollPane = new ScrollPane(messageLabel); + scrollPane.setHbarPolicy(ScrollBarPolicy.NEVER); + scrollPane.setVbarPolicy(ScrollBarPolicy.AS_NEEDED); + scrollPane.setFitToWidth(true); + + messageRegion = scrollPane; + } else + messageRegion = messageLabel; + + GridPane.setHalignment(messageRegion, HPos.LEFT); + GridPane.setHgrow(messageRegion, Priority.ALWAYS); + GridPane.setMargin(messageRegion, new Insets(3, 0, 0, 0)); + GridPane.setRowIndex(messageRegion, ++rowIndex); + GridPane.setColumnIndex(messageRegion, 0); + GridPane.setColumnSpan(messageRegion, 2); + gridPane.getChildren().add(messageRegion); + addFooter(); } } diff --git a/desktop/src/main/java/haveno/desktop/main/overlays/windows/TacWindow.java b/desktop/src/main/java/haveno/desktop/main/overlays/windows/TacWindow.java index 4a272c6d82..a25e0cb642 100644 --- a/desktop/src/main/java/haveno/desktop/main/overlays/windows/TacWindow.java +++ b/desktop/src/main/java/haveno/desktop/main/overlays/windows/TacWindow.java @@ -91,6 +91,7 @@ public class TacWindow extends Overlay { " - The arbitrator will then make a reimbursement request to the Haveno to get reimbursed for the refund they paid to the trader.\n\n" + "For more details and a general overview please read the full documentation about dispute resolution."; message(text); + showScrollPane(); actionButtonText(Res.get("tacWindow.agree")); closeButtonText(Res.get("tacWindow.disagree")); onClose(HavenoApp.getShutDownHandler());