From ca989751a6ced95a3295a851689b664e97a2b8ca Mon Sep 17 00:00:00 2001 From: jmacxx <47253594+jmacxx@users.noreply.github.com> Date: Tue, 20 Apr 2021 17:03:34 -0500 Subject: [PATCH] Size GenericMessageWindow proportional to amount of text shown --- .../main/overlays/windows/GenericMessageWindow.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/desktop/src/main/java/bisq/desktop/main/overlays/windows/GenericMessageWindow.java b/desktop/src/main/java/bisq/desktop/main/overlays/windows/GenericMessageWindow.java index c3b6d34cc2b..8a51ae05cc1 100644 --- a/desktop/src/main/java/bisq/desktop/main/overlays/windows/GenericMessageWindow.java +++ b/desktop/src/main/java/bisq/desktop/main/overlays/windows/GenericMessageWindow.java @@ -59,6 +59,16 @@ private void addContent() { textArea.setEditable(false); textArea.setWrapText(true); // sizes the textArea to fit within its parent container - textArea.setPrefSize(Layout.INITIAL_WINDOW_WIDTH, Layout.INITIAL_WINDOW_HEIGHT * 0.9); + double verticalSizePercentage = ensureRange(countLines(message) / 20.0, 0.2, 0.7); + textArea.setPrefSize(Layout.INITIAL_WINDOW_WIDTH, Layout.INITIAL_WINDOW_HEIGHT * verticalSizePercentage); + } + + private static int countLines(String str) { + String[] lines = str.split("\r\n|\r|\n"); + return lines.length; + } + + private static double ensureRange(double value, double min, double max) { + return Math.min(Math.max(value, min), max); } }