mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-07-08 15:59:26 -04:00
fix height of extra info popup on take offer
This commit is contained in:
parent
52c1c70a31
commit
abc5f7812c
2 changed files with 10 additions and 13 deletions
|
@ -18,6 +18,7 @@
|
|||
package haveno.desktop.main.overlays.windows;
|
||||
|
||||
import haveno.desktop.main.overlays.Overlay;
|
||||
import haveno.desktop.util.GUIUtil;
|
||||
import haveno.desktop.util.Layout;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.TextArea;
|
||||
|
@ -28,6 +29,7 @@ import static haveno.desktop.util.FormBuilder.addTextArea;
|
|||
|
||||
public class GenericMessageWindow extends Overlay<GenericMessageWindow> {
|
||||
private String preamble;
|
||||
private static final double MAX_TEXT_AREA_HEIGHT = 250;
|
||||
|
||||
public GenericMessageWindow() {
|
||||
super();
|
||||
|
@ -57,17 +59,7 @@ public class GenericMessageWindow extends Overlay<GenericMessageWindow> {
|
|||
textArea.setText(message);
|
||||
textArea.setEditable(false);
|
||||
textArea.setWrapText(true);
|
||||
// sizes the textArea to fit within its parent container
|
||||
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);
|
||||
textArea.setPrefWidth(Layout.INITIAL_WINDOW_WIDTH);
|
||||
GUIUtil.adjustHeightAutomatically(textArea, MAX_TEXT_AREA_HEIGHT);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1181,6 +1181,10 @@ public class GUIUtil {
|
|||
}
|
||||
|
||||
public static void adjustHeightAutomatically(TextArea textArea) {
|
||||
adjustHeightAutomatically(textArea, null);
|
||||
}
|
||||
|
||||
public static void adjustHeightAutomatically(TextArea textArea, Double maxHeight) {
|
||||
textArea.sceneProperty().addListener((o, oldScene, newScene) -> {
|
||||
if (newScene != null) {
|
||||
// avoid javafx css warning
|
||||
|
@ -1192,7 +1196,8 @@ public class GUIUtil {
|
|||
textArea.prefHeightProperty().bind(Bindings.createDoubleBinding(() -> {
|
||||
Insets padding = textArea.getInsets();
|
||||
double topBottomPadding = padding.getTop() + padding.getBottom();
|
||||
return textArea.getFont().getSize() + text.getBoundsInLocal().getHeight() + topBottomPadding;
|
||||
double prefHeight = textArea.getFont().getSize() + text.getBoundsInLocal().getHeight() + topBottomPadding;
|
||||
return maxHeight == null ? prefHeight : Math.min(prefHeight, maxHeight);
|
||||
}, text.boundsInLocalProperty()));
|
||||
|
||||
text.boundsInLocalProperty().addListener((observableBoundsAfter, boundsBefore, boundsAfter) -> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue