From 020ca2f312f4f8c484de3b9b5427710d3fb4985c Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Tue, 4 May 2021 10:23:35 +0200 Subject: [PATCH] always use 8 fraction digits when displaying btc amounts, use a fixed width font for numbers on osx --- .../com/sparrowwallet/sparrow/control/CoinCell.java | 11 ++++++++++- .../resources/com/sparrowwallet/sparrow/general.css | 4 ++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/control/CoinCell.java b/src/main/java/com/sparrowwallet/sparrow/control/CoinCell.java index ee79855f..8574b10d 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/CoinCell.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/CoinCell.java @@ -10,16 +10,24 @@ import javafx.scene.control.ContentDisplay; import javafx.scene.control.Tooltip; import javafx.scene.control.TreeTableCell; import javafx.scene.layout.Region; +import org.controlsfx.tools.Platform; +import java.text.DecimalFormat; +import java.text.DecimalFormatSymbols; import java.util.Locale; class CoinCell extends TreeTableCell { + public static final DecimalFormat TABLE_BTC_FORMAT = new DecimalFormat("0.00000000", DecimalFormatSymbols.getInstance(Locale.ENGLISH)); + private final Tooltip tooltip; public CoinCell() { super(); tooltip = new Tooltip(); getStyleClass().add("coin-cell"); + if(Platform.getCurrent() == Platform.OSX) { + getStyleClass().add("number-field"); + } } @Override @@ -38,7 +46,8 @@ class CoinCell extends TreeTableCell { BitcoinUnit unit = coinTreeTable.getBitcoinUnit(); String satsValue = String.format(Locale.ENGLISH, "%,d", amount.longValue()); - final String btcValue = CoinLabel.getBTCFormat().format(amount.doubleValue() / Transaction.SATOSHIS_PER_BITCOIN); + DecimalFormat decimalFormat = (amount.longValue() == 0L ? CoinLabel.getBTCFormat() : TABLE_BTC_FORMAT); + final String btcValue = decimalFormat.format(amount.doubleValue() / Transaction.SATOSHIS_PER_BITCOIN); if(unit.equals(BitcoinUnit.BTC)) { tooltip.setText(satsValue + " " + BitcoinUnit.SATOSHIS.getLabel()); diff --git a/src/main/resources/com/sparrowwallet/sparrow/general.css b/src/main/resources/com/sparrowwallet/sparrow/general.css index c5445bba..0cd42c14 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/general.css +++ b/src/main/resources/com/sparrowwallet/sparrow/general.css @@ -187,4 +187,8 @@ .icon-button:hover { -fx-opacity: 1.0; +} + +.number-field { + -fx-font-family: 'Helvetica Neue', 'System Regular'; } \ No newline at end of file