From b3d6bc77ef18ecd01532dfcdcbb15a8cf926f857 Mon Sep 17 00:00:00 2001 From: woodser <13068859+woodser@users.noreply.github.com> Date: Thu, 5 Jun 2025 17:23:01 -0400 Subject: [PATCH] add styling to number of offers in pulldown menus --- .../src/main/java/haveno/desktop/haveno.css | 9 ++++++ .../java/haveno/desktop/util/GUIUtil.java | 30 ++++++++++++------- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/desktop/src/main/java/haveno/desktop/haveno.css b/desktop/src/main/java/haveno/desktop/haveno.css index 09016c41af..7c24526aaf 100644 --- a/desktop/src/main/java/haveno/desktop/haveno.css +++ b/desktop/src/main/java/haveno/desktop/haveno.css @@ -1697,6 +1697,15 @@ textfield */ -fx-pref-height: 35px; } +.offer-label { + -fx-background-color: rgb(50, 95, 182); + -fx-text-fill: white; + -fx-font-weight: normal; + -fx-background-radius: 999; + -fx-border-radius: 999; + -fx-padding: 0 6 0 6; +} + /* Offer */ .percentage-label { -fx-alignment: center; diff --git a/desktop/src/main/java/haveno/desktop/util/GUIUtil.java b/desktop/src/main/java/haveno/desktop/util/GUIUtil.java index d5f2658ae2..3097780c1a 100644 --- a/desktop/src/main/java/haveno/desktop/util/GUIUtil.java +++ b/desktop/src/main/java/haveno/desktop/util/GUIUtil.java @@ -149,10 +149,9 @@ public class GUIUtil { public final static int NUM_DECIMALS_PRECISE = 7; public final static int AMOUNT_DECIMALS_WITH_ZEROS = 3; public final static int AMOUNT_DECIMALS = 4; - private final static String NUM_OFFERS_SPACING = " "; + public static final double NUM_OFFERS_TRANSLATE_X = -13.0; public static final boolean disablePaymentUriLabel = true; // universally disable payment uri labels, allowing bigger xmr logo overlays - private static Preferences preferences; public static void setPreferences(Preferences preferences) { @@ -331,9 +330,11 @@ public class GUIUtil { Label label2 = new AutoTooltipLabel(CurrencyUtil.isCryptoCurrency(code) ? item.tradeCurrency.getNameAndCode() : code); label2.getStyleClass().add("currency-label"); Label label3 = new AutoTooltipLabel(CurrencyUtil.isCryptoCurrency(code) ? "" : item.tradeCurrency.getName()); - label3.getStyleClass().add("currency-label"); + if (!CurrencyUtil.isCryptoCurrency(code)) label3.getStyleClass().add("currency-label"); + Label label4 = new AutoTooltipLabel(); box.getChildren().addAll(label1, label2, label3); + if (!CurrencyUtil.isCryptoCurrency(code)) box.getChildren().add(label4); switch (code) { case GUIUtil.SHOW_ALL_FLAG: @@ -353,11 +354,12 @@ public class GUIUtil { label1.setGraphic(iconWrapper); } - if (preferences.isSortMarketCurrenciesNumerically()) { + if (preferences.isSortMarketCurrenciesNumerically() && item.numTrades > 0) { boolean isCrypto = CurrencyUtil.isCryptoCurrency(code); - Label offersTarget = isCrypto ? label2 : label3; - offersTarget.setText((!offersTarget.getText().isEmpty() ? offersTarget.getText() + NUM_OFFERS_SPACING : "") + "(" + item.numTrades + " " + - (item.numTrades == 1 ? postFixSingle : postFixMulti) + ")"); + Label offersTarget = isCrypto ? label3 : label4; + HBox.setMargin(offersTarget, new Insets(0, 0, 0, NUM_OFFERS_TRANSLATE_X)); + offersTarget.getStyleClass().add("offer-label"); + offersTarget.setText(item.numTrades + " " + (item.numTrades == 1 ? postFixSingle : postFixMulti)); } } @@ -460,13 +462,15 @@ public class GUIUtil { HBox box = new HBox(); box.setSpacing(20); + box.setAlignment(Pos.CENTER_LEFT); Label label1 = new AutoTooltipLabel(getCurrencyType(item.getCode())); label1.getStyleClass().add("currency-label-small"); Label label2 = new AutoTooltipLabel(CurrencyUtil.isCryptoCurrency(code) ? item.getNameAndCode() : code); label2.getStyleClass().add("currency-label"); Label label3 = new AutoTooltipLabel(CurrencyUtil.isCryptoCurrency(code) ? "" : item.getName()); - label3.getStyleClass().add("currency-label"); + if (!CurrencyUtil.isCryptoCurrency(code)) label3.getStyleClass().add("currency-label"); + Label label4 = new AutoTooltipLabel(); Optional offerCountOptional = Optional.ofNullable(offerCounts.get(code)); @@ -488,12 +492,16 @@ public class GUIUtil { } boolean isCrypto = CurrencyUtil.isCryptoCurrency(code); - Label offersTarget = isCrypto ? label2 : label3; - offerCountOptional.ifPresent(numOffer -> offersTarget.setText((!offersTarget.getText().isEmpty() ? offersTarget.getText() + NUM_OFFERS_SPACING : "") + "(" + numOffer + " " + - (numOffer == 1 ? postFixSingle : postFixMulti) + ")")); + Label offersTarget = isCrypto ? label3 : label4; + offerCountOptional.ifPresent(numOffers -> { + HBox.setMargin(offersTarget, new Insets(0, 0, 0, NUM_OFFERS_TRANSLATE_X)); + offersTarget.getStyleClass().add("offer-label"); + offersTarget.setText(numOffers + " " + (numOffers == 1 ? postFixSingle : postFixMulti)); + }); } box.getChildren().addAll(label1, label2, label3); + if (!CurrencyUtil.isCryptoCurrency(code)) box.getChildren().add(label4); setGraphic(box);