From 1cd74acf2ebb9e49fa7c4db5b194cf3f7f240409 Mon Sep 17 00:00:00 2001 From: woodser <13068859+woodser@users.noreply.github.com> Date: Sun, 18 May 2025 15:43:39 -0400 Subject: [PATCH] black popups with light background in dark mode --- .../src/main/java/haveno/desktop/haveno.css | 34 +++++++++++++++---- .../haveno/desktop/main/overlays/Overlay.java | 17 +--------- .../overlays/windows/TradeDetailsWindow.java | 24 ++----------- .../main/java/haveno/desktop/theme-dark.css | 3 +- .../main/java/haveno/desktop/theme-light.css | 1 + .../java/haveno/desktop/util/CssTheme.java | 4 +++ .../java/haveno/desktop/util/GUIUtil.java | 3 +- .../java/haveno/desktop/util/Transitions.java | 4 +-- 8 files changed, 42 insertions(+), 48 deletions(-) diff --git a/desktop/src/main/java/haveno/desktop/haveno.css b/desktop/src/main/java/haveno/desktop/haveno.css index 5d03358942..ece5ca9153 100644 --- a/desktop/src/main/java/haveno/desktop/haveno.css +++ b/desktop/src/main/java/haveno/desktop/haveno.css @@ -1386,14 +1386,26 @@ textfield */ } .text-area-popup { - -fx-border-color: -bs-color-background-popup; + -fx-border-color: -bs-color-background-popup-overlay; } .text-area-popup .content { - -fx-background-color: -bs-color-background-popup; + -fx-background-color: -bs-color-background-popup-overlay; } .text-area-popup:focused { + -fx-faint-focus-color: -bs-color-background-popup-overlay; +} + +.notification-popup-bg .text-area-popup, .peer-info-popup-bg .text-area-popup { + -fx-border-color: -bs-color-background-popup; +} + +.notification-popup-bg .text-area-popup .content, .peer-info-popup-bg .text-area-popup .content{ + -fx-background-color: -bs-color-background-popup; +} + +.notification-popup-bg .text-area-popup:focused, .peer-info-popup-bg .text-area-popup:focused { -fx-faint-focus-color: -bs-color-background-popup; } @@ -1925,10 +1937,10 @@ textfield */ -fx-background-color: -bs-content-background-gray; -fx-background-radius: 5; -fx-effect: null; - -fx-effect: dropshadow(gaussian, -bs-color-gray-10, 10, 0, 0, 0); -fx-background-insets: 10; -fx-background-radius: 15; -fx-border-radius: 15; + -fx-padding: 35, 40, 30, 40; } /******************************************************************************************************************** @@ -2203,7 +2215,18 @@ textfield */ -fx-text-fill: -bs-rd-error-red; } -.popup-bg, .notification-popup-bg, .peer-info-popup-bg { +.popup-bg { + -fx-font-size: 1.077em; + -fx-background-color: -bs-color-background-popup-overlay; + -fx-background-radius: 5; + -fx-effect: null; + -fx-background-insets: 10; + -fx-background-radius: 15; + -fx-border-radius: 15; + -fx-padding: 35, 40, 30, 40; +} + +.notification-popup-bg, .peer-info-popup-bg { -fx-font-size: 1.077em; -fx-text-fill: -bs-rd-font-dark; -fx-background-color: -bs-color-background-popup; @@ -2216,9 +2239,8 @@ textfield */ .popup-bg-top { -fx-font-size: 1.077em; -fx-text-fill: -bs-rd-font-dark; - -fx-background-color: -bs-color-background-popup; + -fx-background-color: -bs-color-background-popup-overlay; -fx-background-insets: 44; - -fx-effect: dropshadow(gaussian, -bs-text-color-transparent-dark, 44, 0, 0, 0); -fx-background-radius: 0 0 15px 15px; -fx-border-radius: 0 0 15px 15px; } 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 bea37946f8..e88eca513d 100644 --- a/desktop/src/main/java/haveno/desktop/main/overlays/Overlay.java +++ b/desktop/src/main/java/haveno/desktop/main/overlays/Overlay.java @@ -853,22 +853,7 @@ public abstract class Overlay> { messageTextArea = new TextArea(truncatedMessage); messageTextArea.setEditable(false); messageTextArea.getStyleClass().add("text-area-popup"); - messageTextArea.sceneProperty().addListener((o, oldScene, newScene) -> { - if (newScene != null) { - // avoid javafx css warning - CssTheme.loadSceneStyles(newScene, CssTheme.CSS_THEME_LIGHT, false); - messageTextArea.applyCss(); - var text = messageTextArea.lookup(".text"); - - messageTextArea.prefHeightProperty().bind(Bindings.createDoubleBinding(() -> { - return messageTextArea.getFont().getSize() + text.getBoundsInLocal().getHeight(); - }, text.boundsInLocalProperty())); - - text.boundsInLocalProperty().addListener((observableBoundsAfter, boundsBefore, boundsAfter) -> { - Platform.runLater(() -> messageTextArea.requestLayout()); - }); - } - }); + GUIUtil.adjustHeightAutomatically(messageTextArea); messageTextArea.setWrapText(true); Region messageRegion; diff --git a/desktop/src/main/java/haveno/desktop/main/overlays/windows/TradeDetailsWindow.java b/desktop/src/main/java/haveno/desktop/main/overlays/windows/TradeDetailsWindow.java index e14433f08d..479df192de 100644 --- a/desktop/src/main/java/haveno/desktop/main/overlays/windows/TradeDetailsWindow.java +++ b/desktop/src/main/java/haveno/desktop/main/overlays/windows/TradeDetailsWindow.java @@ -38,8 +38,9 @@ import haveno.core.xmr.wallet.BtcWalletService; import haveno.desktop.components.HavenoTextArea; import haveno.desktop.main.MainView; import haveno.desktop.main.overlays.Overlay; -import haveno.desktop.util.CssTheme; import haveno.desktop.util.DisplayUtils; +import haveno.desktop.util.GUIUtil; + import static haveno.desktop.util.DisplayUtils.getAccountWitnessDescription; import static haveno.desktop.util.FormBuilder.add2ButtonsWithBox; import static haveno.desktop.util.FormBuilder.addConfirmationLabelTextArea; @@ -48,12 +49,9 @@ import static haveno.desktop.util.FormBuilder.addLabelTxIdTextField; import static haveno.desktop.util.FormBuilder.addTitledGroupBg; import haveno.desktop.util.Layout; import haveno.network.p2p.NodeAddress; -import javafx.application.Platform; -import javafx.beans.binding.Bindings; import javafx.beans.property.IntegerProperty; import javafx.beans.property.SimpleIntegerProperty; import javafx.beans.value.ChangeListener; -import javafx.geometry.Insets; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.TextArea; @@ -127,7 +125,6 @@ public class TradeDetailsWindow extends Overlay { @Override protected void createGridPane() { super.createGridPane(); - gridPane.setPadding(new Insets(35, 40, 30, 40)); gridPane.getStyleClass().add("grid-pane"); } @@ -229,22 +226,7 @@ public class TradeDetailsWindow extends Overlay { TextArea textArea = addConfirmationLabelTextArea(gridPane, ++rowIndex, Res.get("payment.shared.extraInfo.offer"), "", 0).second; textArea.setText(offer.getCombinedExtraInfo().trim()); textArea.setMaxHeight(200); - textArea.sceneProperty().addListener((o, oldScene, newScene) -> { - if (newScene != null) { - // avoid javafx css warning - CssTheme.loadSceneStyles(newScene, CssTheme.CSS_THEME_LIGHT, false); - textArea.applyCss(); - var text = textArea.lookup(".text"); - - textArea.prefHeightProperty().bind(Bindings.createDoubleBinding(() -> { - return textArea.getFont().getSize() + text.getBoundsInLocal().getHeight(); - }, text.boundsInLocalProperty())); - - text.boundsInLocalProperty().addListener((observableBoundsAfter, boundsBefore, boundsAfter) -> { - Platform.runLater(() -> textArea.requestLayout()); - }); - } - }); + GUIUtil.adjustHeightAutomatically(textArea); textArea.setEditable(false); } diff --git a/desktop/src/main/java/haveno/desktop/theme-dark.css b/desktop/src/main/java/haveno/desktop/theme-dark.css index ed683c0fd2..29cf63d046 100644 --- a/desktop/src/main/java/haveno/desktop/theme-dark.css +++ b/desktop/src/main/java/haveno/desktop/theme-dark.css @@ -44,7 +44,8 @@ -bs-color-gray-aaa: #29292a; -bs-color-gray-fafa: #0a0a0a; -bs-color-gray-background: black; - -bs-color-background-popup: rgb(31, 31, 31); + -bs-color-background-popup: rgb(38, 38, 38); + -bs-color-background-popup-overlay: rgb(9, 9, 9); -bs-color-background-form-field: rgb(18, 18, 18); -bs-color-background-form-field-readonly: rgb(18, 18, 18); -bs-color-border-form-field: rgb(65, 65, 65); diff --git a/desktop/src/main/java/haveno/desktop/theme-light.css b/desktop/src/main/java/haveno/desktop/theme-light.css index b6e5bb6499..2775fa525e 100644 --- a/desktop/src/main/java/haveno/desktop/theme-light.css +++ b/desktop/src/main/java/haveno/desktop/theme-light.css @@ -113,6 +113,7 @@ -bs-color-background-row-odd: derive(-bs-color-background-pane, -6%); -bs-color-table-cell-dim: -bs-color-gray-ccc; -bs-color-background-popup: white; + -bs-color-background-popup-overlay: white; -bs-color-background-form-field: white; -bs-text-color-dim1: black; -bs-text-color-dim2: black; diff --git a/desktop/src/main/java/haveno/desktop/util/CssTheme.java b/desktop/src/main/java/haveno/desktop/util/CssTheme.java index 1e1c547607..4648d07eeb 100644 --- a/desktop/src/main/java/haveno/desktop/util/CssTheme.java +++ b/desktop/src/main/java/haveno/desktop/util/CssTheme.java @@ -58,6 +58,10 @@ public class CssTheme { scene.getStylesheets().add(cssThemeFolder + "theme-dev.css"); } + public static int getCurrentTheme() { + return currentCSSTheme; + } + public static boolean isDarkTheme() { return currentCSSTheme == CSS_THEME_DARK; } diff --git a/desktop/src/main/java/haveno/desktop/util/GUIUtil.java b/desktop/src/main/java/haveno/desktop/util/GUIUtil.java index 34391cc233..38a374d3ae 100644 --- a/desktop/src/main/java/haveno/desktop/util/GUIUtil.java +++ b/desktop/src/main/java/haveno/desktop/util/GUIUtil.java @@ -1188,8 +1188,7 @@ public class GUIUtil { textArea.sceneProperty().addListener((o, oldScene, newScene) -> { if (newScene != null) { // avoid javafx css warning - boolean isLightTheme = newScene.getStylesheets().stream().anyMatch(url -> url.contains("theme-light.css")); - CssTheme.loadSceneStyles(newScene, isLightTheme ? CssTheme.CSS_THEME_LIGHT : CssTheme.CSS_THEME_DARK, false); + CssTheme.loadSceneStyles(newScene, CssTheme.getCurrentTheme(), false); textArea.applyCss(); var text = textArea.lookup(".text"); diff --git a/desktop/src/main/java/haveno/desktop/util/Transitions.java b/desktop/src/main/java/haveno/desktop/util/Transitions.java index 300524ccce..ef7ec2ad9f 100644 --- a/desktop/src/main/java/haveno/desktop/util/Transitions.java +++ b/desktop/src/main/java/haveno/desktop/util/Transitions.java @@ -37,7 +37,7 @@ import javafx.util.Duration; @Singleton public class Transitions { - public final static int DEFAULT_DURATION = 600; + public final static int DEFAULT_DURATION = 400; private final Preferences preferences; private Timeline removeEffectTimeLine; @@ -111,7 +111,7 @@ public class Transitions { ColorAdjust darken = new ColorAdjust(); darken.setBrightness(0.0); blur.setInput(darken); - KeyValue kv2 = new KeyValue(darken.brightnessProperty(), brightness); + KeyValue kv2 = new KeyValue(darken.brightnessProperty(), CssTheme.isDarkTheme() ? brightness * -0.2 : brightness); KeyFrame kf2 = new KeyFrame(Duration.millis(getDuration(duration)), kv2); timeline.getKeyFrames().addAll(kf1, kf2); node.setEffect(blur);