set monospace font explicitly, add stage icons

This commit is contained in:
Craig Raw 2020-08-27 13:11:23 +02:00
parent ba017b2fcb
commit fa0c74f06b
35 changed files with 78 additions and 38 deletions

View file

@ -46,6 +46,7 @@ import javafx.scene.image.ImageView;
import javafx.scene.input.Dragboard;
import javafx.scene.input.TransferMode;
import javafx.scene.layout.StackPane;
import javafx.scene.text.Font;
import javafx.stage.FileChooser;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
@ -185,7 +186,8 @@ public class AppController implements Initializable {
}
});
tabs.setTabDragPolicy(TabPane.TabDragPolicy.REORDER);
//Draggle tabs introduce unwanted movement when selecting between them
//tabs.setTabDragPolicy(TabPane.TabDragPolicy.REORDER);
tabs.getTabs().addListener((ListChangeListener<Tab>) c -> {
if(c.next() && (c.wasAdded() || c.wasRemoved())) {
boolean walletAdded = c.getAddedSubList().stream().anyMatch(tab -> ((TabData)tab.getUserData()).getType() == TabData.TabType.WALLET);
@ -365,6 +367,7 @@ public class AppController implements Initializable {
Stage stage = new Stage();
stage.setTitle("About " + MainApp.APP_NAME);
stage.initStyle(org.controlsfx.tools.Platform.getCurrent() == org.controlsfx.tools.Platform.OSX ? StageStyle.UNDECORATED : StageStyle.DECORATED);
setStageIcon(stage);
stage.setResizable(false);
stage.setScene(new Scene(root));
controller.setStage(stage);
@ -608,12 +611,22 @@ public class AppController implements Initializable {
public static void showErrorDialog(String title, String content) {
Alert alert = new Alert(Alert.AlertType.ERROR);
setStageIcon(alert.getDialogPane().getScene().getWindow());
alert.setTitle(title);
alert.setHeaderText(title);
alert.setContentText(content);
alert.showAndWait();
}
public static void setStageIcon(Window window) {
Stage stage = (Stage)window;
stage.getIcons().add(new Image(AppController.class.getResourceAsStream("/image/sparrow.png")));
}
public static Font getMonospaceFont() {
return Font.font("Roboto Mono", 13);
}
public void selectTab(Wallet wallet) {
for(Tab tab : tabs.getTabs()) {
TabData tabData = (TabData) tab.getUserData();
@ -1158,7 +1171,7 @@ public class AppController implements Initializable {
currentBlockHeight = event.getBlockHeight();
targetBlockFeeRates = event.getTargetBlockFeeRates();
String banner = event.getServerBanner();
String status = "Connected: " + (banner == null ? "Server" : banner.split(System.lineSeparator(), 2)[0]) + " at height " + event.getBlockHeight();
String status = "Connected: " + (banner == null ? "Server" : banner.split("\\R", 2)[0]) + " at height " + event.getBlockHeight();
EventManager.get().post(new StatusEvent(status));
}

View file

@ -12,6 +12,7 @@ import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.text.Font;
import javafx.stage.Stage;
import org.controlsfx.glyphfont.GlyphFontRegistry;
import org.slf4j.LoggerFactory;
@ -38,6 +39,7 @@ public class MainApp extends Application {
GlyphFontRegistry.register(new FontAwesome5());
GlyphFontRegistry.register(new FontAwesome5Brands());
Font.loadFont(AppController.class.getResourceAsStream("/font/RobotoMono-Regular.ttf"), 13);
boolean createNewWallet = false;
Mode mode = Config.get().getMode();

View file

@ -1,6 +1,7 @@
package com.sparrowwallet.sparrow.control;
import com.sparrowwallet.drongo.wallet.WalletNode;
import com.sparrowwallet.sparrow.AppController;
import com.sparrowwallet.sparrow.EventManager;
import com.sparrowwallet.sparrow.event.ReceiveActionEvent;
import com.sparrowwallet.sparrow.event.ReceiveToEvent;
@ -10,7 +11,6 @@ import javafx.application.Platform;
import javafx.beans.property.ReadOnlyObjectWrapper;
import javafx.scene.control.*;
import javafx.scene.input.MouseButton;
import javafx.scene.text.Font;
import java.util.List;
import java.util.Optional;
@ -33,7 +33,7 @@ public class AddressTreeTable extends CoinTreeTable {
getColumns().add(addressCol);
if(address != null) {
addressCol.setMinWidth(TextUtils.computeTextWidth(Font.font("Courier"), address, 0.0));
addressCol.setMinWidth(TextUtils.computeTextWidth(AppController.getMonospaceFont(), address, 0.0));
}
TreeTableColumn<Entry, String> labelCol = new TreeTableColumn<>("Label");

View file

@ -32,6 +32,7 @@ public abstract class DeviceDialog<R> extends Dialog<R> {
final DialogPane dialogPane = getDialogPane();
dialogPane.getStylesheets().add(AppController.class.getResource("general.css").toExternalForm());
AppController.setStageIcon(dialogPane.getScene().getWindow());
StackPane stackPane = new StackPane();
dialogPane.setContent(stackPane);

View file

@ -1,6 +1,6 @@
package com.sparrowwallet.sparrow.control;
import javafx.scene.text.Font;
import com.sparrowwallet.sparrow.AppController;
public class IdLabel extends CopyableLabel {
public IdLabel() {
@ -9,6 +9,6 @@ public class IdLabel extends CopyableLabel {
public IdLabel(String text) {
super(text);
setFont(Font.font("Courier"));
setFont(AppController.getMonospaceFont());
}
}

View file

@ -26,6 +26,7 @@ public class KeystorePassphraseDialog extends Dialog<String> {
setTitle("Keystore Passphrase" + (walletName != null ? " - " + walletName : ""));
dialogPane.setHeaderText("Please enter the passphrase for keystore: \n" + keystore.getLabel());
dialogPane.getStylesheets().add(AppController.class.getResource("general.css").toExternalForm());
AppController.setStageIcon(dialogPane.getScene().getWindow());
dialogPane.getButtonTypes().addAll(ButtonType.CANCEL, ButtonType.OK);
dialogPane.setPrefWidth(380);
dialogPane.setPrefHeight(200);

View file

@ -5,7 +5,7 @@ import com.google.zxing.client.j2se.MatrixToImageConfig;
import com.google.zxing.client.j2se.MatrixToImageWriter;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.QRCodeWriter;
import com.sparrowwallet.sparrow.EventManager;
import com.sparrowwallet.sparrow.AppController;
import com.sparrowwallet.sparrow.io.ImportException;
import com.sparrowwallet.sparrow.ur.UR;
import com.sparrowwallet.sparrow.ur.UREncoder;
@ -48,6 +48,7 @@ public class QRDisplayDialog extends Dialog<UR> {
this.encoder = new UREncoder(ur, MAX_FRAGMENT_LENGTH, MIN_FRAGMENT_LENGTH, 0);
final DialogPane dialogPane = getDialogPane();
AppController.setStageIcon(dialogPane.getScene().getWindow());
StackPane stackPane = new StackPane();
qrImageView = new ImageView();

View file

@ -7,6 +7,7 @@ import com.sparrowwallet.drongo.protocol.Base43;
import com.sparrowwallet.drongo.protocol.Transaction;
import com.sparrowwallet.drongo.psbt.PSBT;
import com.sparrowwallet.drongo.uri.BitcoinURI;
import com.sparrowwallet.sparrow.AppController;
import com.sparrowwallet.sparrow.ur.ResultType;
import com.sparrowwallet.sparrow.ur.UR;
import com.sparrowwallet.sparrow.ur.URDecoder;
@ -34,6 +35,7 @@ public class QRScanDialog extends Dialog<QRScanDialog.Result> {
WebcamView webcamView = new WebcamView(webcamService);
final DialogPane dialogPane = getDialogPane();
AppController.setStageIcon(dialogPane.getScene().getWindow());
StackPane stackPane = new StackPane();
stackPane.getChildren().add(webcamView.getView());

View file

@ -11,6 +11,7 @@ public class SeedDisplayDialog extends Dialog<Void> {
public SeedDisplayDialog(Keystore decryptedKeystore) {
final DialogPane dialogPane = getDialogPane();
dialogPane.getStylesheets().add(AppController.class.getResource("general.css").toExternalForm());
AppController.setStageIcon(dialogPane.getScene().getWindow());
int lines = decryptedKeystore.getSeed().getMnemonicCode().size() / 3;
int height = lines * 40;

View file

@ -1,5 +1,6 @@
package com.sparrowwallet.sparrow.control;
import com.sparrowwallet.sparrow.AppController;
import javafx.application.Platform;
import javafx.beans.NamedArg;
import javafx.scene.control.*;
@ -24,7 +25,8 @@ public class TextAreaDialog extends Dialog<String> {
this.defaultValue = defaultValue;
getDialogPane().setContent(hbox);
dialogPane.setContent(hbox);
AppController.setStageIcon(dialogPane.getScene().getWindow());
dialogPane.getStyleClass().add("text-input-dialog");
dialogPane.getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);

View file

@ -23,8 +23,9 @@ public class TransactionIdDialog extends Dialog<Sha256Hash> {
public TransactionIdDialog() {
this.txid = (CustomTextField) TextFields.createClearableTextField();
txid.setFont(Font.font ("Courier", txid.getFont().getSize()));
txid.setFont(AppController.getMonospaceFont());
final DialogPane dialogPane = getDialogPane();
AppController.setStageIcon(dialogPane.getScene().getWindow());
setTitle("Load Transaction");
dialogPane.setHeaderText("Enter the transaction ID:");

View file

@ -3,13 +3,12 @@ package com.sparrowwallet.sparrow.control;
import com.google.common.eventbus.Subscribe;
import com.sparrowwallet.drongo.policy.PolicyType;
import com.sparrowwallet.drongo.wallet.Wallet;
import com.sparrowwallet.sparrow.AppController;
import com.sparrowwallet.sparrow.EventManager;
import com.sparrowwallet.sparrow.event.WalletExportEvent;
import com.sparrowwallet.sparrow.event.WalletImportEvent;
import com.sparrowwallet.sparrow.io.ColdcardMultisig;
import com.sparrowwallet.sparrow.io.Electrum;
import com.sparrowwallet.sparrow.io.WalletExport;
import com.sparrowwallet.sparrow.io.WalletImport;
import javafx.scene.control.*;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.StackPane;
@ -26,6 +25,7 @@ public class WalletExportDialog extends Dialog<Wallet> {
});
final DialogPane dialogPane = getDialogPane();
AppController.setStageIcon(dialogPane.getScene().getWindow());
StackPane stackPane = new StackPane();
dialogPane.setContent(stackPane);

View file

@ -2,6 +2,7 @@ package com.sparrowwallet.sparrow.control;
import com.google.common.eventbus.Subscribe;
import com.sparrowwallet.drongo.wallet.Wallet;
import com.sparrowwallet.sparrow.AppController;
import com.sparrowwallet.sparrow.EventManager;
import com.sparrowwallet.sparrow.event.WalletImportEvent;
import com.sparrowwallet.sparrow.io.*;
@ -21,6 +22,7 @@ public class WalletImportDialog extends Dialog<Wallet> {
});
final DialogPane dialogPane = getDialogPane();
AppController.setStageIcon(dialogPane.getScene().getWindow());
StackPane stackPane = new StackPane();
dialogPane.setContent(stackPane);

View file

@ -22,6 +22,7 @@ public class WalletNameDialog extends Dialog<String> {
public WalletNameDialog() {
this.name = (CustomTextField)TextFields.createClearableTextField();
final DialogPane dialogPane = getDialogPane();
AppController.setStageIcon(dialogPane.getScene().getWindow());
setTitle("Wallet Name");
dialogPane.setHeaderText("Enter a name for this wallet:");

View file

@ -36,6 +36,7 @@ public class WalletPasswordDialog extends Dialog<SecureString> {
setTitle("Wallet Password" + (walletName != null ? " - " + walletName : ""));
dialogPane.setHeaderText(walletName != null ? requirement.description.substring(0, requirement.description.length() - 1) + " for " + walletName + ":" : requirement.description);
dialogPane.getStylesheets().add(AppController.class.getResource("general.css").toExternalForm());
AppController.setStageIcon(dialogPane.getScene().getWindow());
dialogPane.getButtonTypes().addAll(ButtonType.CANCEL);
dialogPane.setPrefWidth(380);
dialogPane.setPrefHeight(260);

View file

@ -28,6 +28,7 @@ public class WelcomeDialog extends Dialog<Mode> {
setTitle("Welcome to Sparrow");
dialogPane.setHeaderText("Welcome to Sparrow!");
dialogPane.getStylesheets().add(AppController.class.getResource("general.css").toExternalForm());
AppController.setStageIcon(dialogPane.getScene().getWindow());
dialogPane.setPrefWidth(600);
dialogPane.setPrefHeight(480);

View file

@ -32,6 +32,7 @@ public class KeystoreImportDialog extends Dialog<Keystore> {
});
final DialogPane dialogPane = getDialogPane();
AppController.setStageIcon(dialogPane.getScene().getWindow());
try {
FXMLLoader ksiLoader = new FXMLLoader(AppController.class.getResource("keystoreimport/keystoreimport.fxml"));

View file

@ -27,6 +27,7 @@ public class PreferencesDialog extends Dialog<Boolean> {
public PreferencesDialog(PreferenceGroup initialGroup, boolean initialSetup) {
final DialogPane dialogPane = getDialogPane();
AppController.setStageIcon(dialogPane.getScene().getWindow());
try {
FXMLLoader preferencesLoader = new FXMLLoader(AppController.class.getResource("preferences/preferences.fxml"));

View file

@ -20,7 +20,7 @@
-fx-fill: #383a42;
}
.status-bar, .status-bar .status-label {
.status-bar .status-label {
-fx-alignment: center-left;
}

View file

@ -8,7 +8,7 @@
<?import com.sparrowwallet.sparrow.control.UnlabeledToggleSwitch?>
<?import com.sparrowwallet.drongo.BitcoinUnit?>
<VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="200" minWidth="350" prefHeight="750.0" prefWidth="1000.0" fx:controller="com.sparrowwallet.sparrow.AppController" xmlns="http://javafx.com/javafx/10.0.2-internal" xmlns:fx="http://javafx.com/fxml/1">
<VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="200" minWidth="350" prefHeight="770.0" prefWidth="1000.0" fx:controller="com.sparrowwallet.sparrow.AppController" xmlns="http://javafx.com/javafx/10.0.2-internal" xmlns:fx="http://javafx.com/fxml/1">
<children>
<MenuBar useSystemMenuBar="true">
<menus>
@ -33,7 +33,6 @@
<MenuItem styleClass="macHide" mnemonicParsing="false" text="Preferences..." onAction="#openPreferences"/>
<SeparatorMenuItem />
<MenuItem mnemonicParsing="false" text="Close Tab" onAction="#closeTab"/>
<SeparatorMenuItem styleClass="macHide" />
<MenuItem styleClass="macHide" mnemonicParsing="false" text="Quit" onAction="#quit"/>
</items>
</Menu>

View file

@ -28,7 +28,8 @@
}
.id {
-fx-font-family: Courier;
-fx-font-size: 13px;
-fx-font-family: 'Roboto Mono';
}
.form-separator {

View file

@ -27,8 +27,9 @@
-fx-translate-y: 2;
}
.uneditable-codearea {
-fx-font: 14px Courier;
.virtualized-scroll-pane .code-area, .uneditable-codearea {
-fx-font-size: 13px;
-fx-font-family: 'Roboto Mono';
-fx-padding: 4;
}

View file

@ -56,28 +56,28 @@
<Field text="ScriptSig:">
<VirtualizedScrollPane>
<content>
<ScriptArea fx:id="scriptSigArea" editable="false" wrapText="true" prefHeight="42" maxHeight="42" styleClass="uneditable-codearea" />
<ScriptArea fx:id="scriptSigArea" editable="false" wrapText="true" prefHeight="47" maxHeight="47" styleClass="uneditable-codearea" />
</content>
</VirtualizedScrollPane>
</Field>
<Field text="RedeemScript:">
<VirtualizedScrollPane fx:id="redeemScriptScroll">
<content>
<ScriptArea fx:id="redeemScriptArea" editable="false" wrapText="true" prefHeight="42" maxHeight="42" styleClass="uneditable-codearea" />
<ScriptArea fx:id="redeemScriptArea" editable="false" wrapText="true" prefHeight="47" maxHeight="47" styleClass="uneditable-codearea" />
</content>
</VirtualizedScrollPane>
</Field>
<Field text="Witnesses:">
<VirtualizedScrollPane fx:id="witnessesScroll">
<content>
<ScriptArea fx:id="witnessesArea" editable="false" wrapText="true" prefHeight="42" maxHeight="42" styleClass="uneditable-codearea" />
<ScriptArea fx:id="witnessesArea" editable="false" wrapText="true" prefHeight="47" maxHeight="47" styleClass="uneditable-codearea" />
</content>
</VirtualizedScrollPane>
</Field>
<Field text="WitnessScript:">
<VirtualizedScrollPane fx:id="witnessScriptScroll">
<content>
<ScriptArea fx:id="witnessScriptArea" editable="false" wrapText="true" prefHeight="42" maxHeight="42" styleClass="uneditable-codearea" />
<ScriptArea fx:id="witnessScriptArea" editable="false" wrapText="true" prefHeight="47" maxHeight="47" styleClass="uneditable-codearea" />
</content>
</VirtualizedScrollPane>
</Field>

View file

@ -20,8 +20,9 @@
.locktime { -fx-fill: #e5e5e6 }
.chart-legend-item{
-fx-font-family: Courier;
.chart-legend-item {
-fx-font-size: 13px;
-fx-font-family: 'Roboto Mono';
}
.default-color0.chart-pie { -fx-pie-color: #ca1243 }

View file

@ -52,7 +52,7 @@
<Field text="ScriptPubKey:">
<VirtualizedScrollPane>
<content>
<ScriptArea fx:id="scriptPubKeyArea" editable="false" wrapText="true" prefHeight="42" maxHeight="42" styleClass="uneditable-codearea" />
<ScriptArea fx:id="scriptPubKeyArea" editable="false" wrapText="true" prefHeight="47" maxHeight="47" styleClass="uneditable-codearea" />
</content>
</VirtualizedScrollPane>
</Field>

View file

@ -20,8 +20,9 @@
.locktime { -fx-fill: #e5e5e6 }
.chart-legend-item{
-fx-font-family: Courier;
.chart-legend-item {
-fx-font-size: 13;
-fx-font-family: 'Roboto Mono';
}
.default-color7.chart-pie { -fx-pie-color: #0184bc }

View file

@ -1,6 +1,7 @@
#txhex {
-fx-background-color: #ffffff;
-fx-font: 14px Courier;
-fx-font-size: 13px;
-fx-font-family: 'Roboto Mono';
-fx-padding: 2;
}

View file

@ -14,7 +14,8 @@
}
#fingerprint, #derivation, #xpub {
-fx-font-family: Courier;
-fx-font-size: 13px;
-fx-font-family: 'Roboto Mono';
}
#type {

View file

@ -46,7 +46,7 @@
<TextField fx:id="derivation" maxWidth="200"/>
</Field>
<Field text="xPub:">
<TextArea fx:id="xpub" wrapText="true" prefRowCount="2" maxHeight="40" />
<TextArea fx:id="xpub" wrapText="true" prefRowCount="2" maxHeight="50" />
</Field>
</Fieldset>
</Form>

View file

@ -60,7 +60,7 @@
<Field text="Script:">
<VirtualizedScrollPane>
<content>
<ScriptArea fx:id="scriptPubKeyArea" editable="false" wrapText="true" prefHeight="42" maxHeight="42" styleClass="uneditable-codearea" />
<ScriptArea fx:id="scriptPubKeyArea" editable="false" wrapText="true" prefHeight="47" maxHeight="47" styleClass="uneditable-codearea" />
</content>
</VirtualizedScrollPane>
</Field>
@ -72,7 +72,7 @@
<Field text="Descriptor:">
<VirtualizedScrollPane>
<content>
<CodeArea fx:id="outputDescriptor" editable="false" wrapText="true" prefHeight="63" maxHeight="63" styleClass="uneditable-codearea" />
<CodeArea fx:id="outputDescriptor" editable="false" wrapText="true" prefHeight="68" maxHeight="68" styleClass="uneditable-codearea" />
</content>
</VirtualizedScrollPane>
</Field>

View file

@ -52,7 +52,8 @@
}
#transactionDiagram .input-label, #transactionDiagram .recipient-label, #transactionDiagram .change-label, #transactionDiagram .fee-tooltip {
-fx-font-family: Courier;
-fx-font-size: 13px;
-fx-font-family: 'Roboto Mono';
}
#transactionDiagram .fee-warning-icon {

View file

@ -63,8 +63,8 @@
</Fieldset>
</Form>
<Form GridPane.columnIndex="2" GridPane.rowIndex="0">
<Fieldset inputGrow="SOMETIMES" text="">
<Button text="Scan QR" onAction="#scanQrAddress">
<Fieldset inputGrow="SOMETIMES" text="" style="-fx-padding: 2 0 0 0">
<Button text="Scan QR" onAction="#scanQrAddress" prefHeight="30">
<graphic>
<Glyph fontFamily="Font Awesome 5 Free Solid" fontSize="12" icon="CAMERA" />
</graphic>
@ -106,7 +106,7 @@
</AnchorPane>
</GridPane>
<AnchorPane>
<TransactionDiagram fx:id="transactionDiagram" maxWidth="700" maxHeight="230" AnchorPane.leftAnchor="60" />
<TransactionDiagram fx:id="transactionDiagram" maxWidth="700" maxHeight="230" AnchorPane.leftAnchor="100" />
</AnchorPane>
</VBox>
</center>

View file

@ -11,6 +11,7 @@
}
#spendingMiniscript {
-fx-font-family: Courier;
-fx-font-size: 13px;
-fx-font-family: 'Roboto Mono';
}

View file

@ -30,7 +30,8 @@
}
.address-cell, .utxo-row.entry-cell {
-fx-font-family: Courier;
-fx-font-size: 13px;
-fx-font-family: 'Roboto Mono';
}
.hashindex-row {
@ -123,5 +124,6 @@
}
.address-text-field {
-fx-font-family: Courier;
-fx-font-size: 13px;
-fx-font-family: 'Roboto Mono';
}

Binary file not shown.