Feature to add scrollbar on message of overlays

This commit is contained in:
ThisPC 2023-08-31 17:24:14 +08:00 committed by woodser
parent 849a1c9c55
commit 6731512367
3 changed files with 31 additions and 7 deletions

View File

@ -271,6 +271,7 @@ public class TraditionalAccountsView extends PaymentAccountsView<GridPane, Tradi
.closeButtonText(Res.get("shared.cancel")) .closeButtonText(Res.get("shared.cancel"))
.actionButtonText(Res.get("shared.iUnderstand")) .actionButtonText(Res.get("shared.iUnderstand"))
.onAction(() -> doSaveNewAccount(paymentAccount)) .onAction(() -> doSaveNewAccount(paymentAccount))
.showScrollPane()
.show(); .show();
} else if (paymentAccount instanceof CashAtAtmAccount) { } else if (paymentAccount instanceof CashAtAtmAccount) {
// CashAtAtm has no chargeback risk so we don't show the text from payment.limits.info. // CashAtAtm has no chargeback risk so we don't show the text from payment.limits.info.

View File

@ -54,6 +54,8 @@ import javafx.scene.control.Button;
import javafx.scene.control.CheckBox; import javafx.scene.control.CheckBox;
import javafx.scene.control.Hyperlink; import javafx.scene.control.Hyperlink;
import javafx.scene.control.Label; import javafx.scene.control.Label;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.ScrollPane.ScrollBarPolicy;
import javafx.scene.input.KeyCode; import javafx.scene.input.KeyCode;
import javafx.scene.layout.ColumnConstraints; import javafx.scene.layout.ColumnConstraints;
import javafx.scene.layout.GridPane; import javafx.scene.layout.GridPane;
@ -154,6 +156,7 @@ public abstract class Overlay<T extends Overlay<T>> {
protected Integer displayOrderPriority = Integer.MAX_VALUE; protected Integer displayOrderPriority = Integer.MAX_VALUE;
protected boolean useAnimation = true; protected boolean useAnimation = true;
protected boolean showScrollPane = false;
protected Label headlineIcon, headLineLabel, messageLabel; protected Label headlineIcon, headLineLabel, messageLabel;
protected String headLine, message, closeButtonText, actionButtonText, protected String headLine, message, closeButtonText, actionButtonText,
@ -164,6 +167,7 @@ public abstract class Overlay<T extends Overlay<T>> {
protected Button actionButton, secondaryActionButton; protected Button actionButton, secondaryActionButton;
private HBox buttonBox; private HBox buttonBox;
protected AutoTooltipButton closeButton; protected AutoTooltipButton closeButton;
protected ScrollPane scrollPane;
private HPos buttonAlignment = HPos.RIGHT; private HPos buttonAlignment = HPos.RIGHT;
@ -470,6 +474,11 @@ public abstract class Overlay<T extends Overlay<T>> {
return cast(); return cast();
} }
public T showScrollPane() {
this.showScrollPane = true;
return cast();
}
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
// Protected // Protected
@ -807,13 +816,26 @@ public abstract class Overlay<T extends Overlay<T>> {
messageLabel = new AutoTooltipLabel(truncatedMessage); messageLabel = new AutoTooltipLabel(truncatedMessage);
messageLabel.setMouseTransparent(true); messageLabel.setMouseTransparent(true);
messageLabel.setWrapText(true); messageLabel.setWrapText(true);
GridPane.setHalignment(messageLabel, HPos.LEFT);
GridPane.setHgrow(messageLabel, Priority.ALWAYS); Region messageRegion;
GridPane.setMargin(messageLabel, new Insets(3, 0, 0, 0)); if (showScrollPane) {
GridPane.setRowIndex(messageLabel, ++rowIndex); scrollPane = new ScrollPane(messageLabel);
GridPane.setColumnIndex(messageLabel, 0); scrollPane.setHbarPolicy(ScrollBarPolicy.NEVER);
GridPane.setColumnSpan(messageLabel, 2); scrollPane.setVbarPolicy(ScrollBarPolicy.AS_NEEDED);
gridPane.getChildren().add(messageLabel); 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(); addFooter();
} }
} }

View File

@ -91,6 +91,7 @@ public class TacWindow extends Overlay<TacWindow> {
" - The arbitrator will then make a reimbursement request to the Haveno to get reimbursed for the refund they paid to the trader.\n\n" + " - 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."; "For more details and a general overview please read the full documentation about dispute resolution.";
message(text); message(text);
showScrollPane();
actionButtonText(Res.get("tacWindow.agree")); actionButtonText(Res.get("tacWindow.agree"));
closeButtonText(Res.get("tacWindow.disagree")); closeButtonText(Res.get("tacWindow.disagree"));
onClose(HavenoApp.getShutDownHandler()); onClose(HavenoApp.getShutDownHandler());