From 02b82b63ef6117093f225ed38cabcd2f4a1ad30d Mon Sep 17 00:00:00 2001 From: Manfred Karrer Date: Fri, 19 Sep 2014 00:47:15 +0200 Subject: [PATCH] Fix width problem with info component --- README.md | 2 +- src/main/java/io/bitsquare/gui/bitsquare.css | 4 + .../bitsquare/gui/components/InfoDisplay.java | 53 ++++----- .../changepassword/ChangePasswordView.fxml | 2 +- .../account/content/fiat/FiatAccountView.fxml | 4 +- .../content/password/PasswordView.fxml | 2 +- .../registration/RegistrationView.fxml | 2 +- .../restrictions/RestrictionsView.fxml | 6 +- .../content/seedwords/SeedWordsView.fxml | 2 +- .../gui/main/trade/OrderBookInfo.java | 102 ------------------ .../gui/main/trade/TradeNavigator.java | 29 +++++ .../bitsquare/gui/main/trade/TradeViewCB.java | 71 +++++++++--- .../main/trade/createoffer/CreateOfferPM.java | 36 +++---- .../trade/createoffer/CreateOfferView.fxml | 6 +- .../trade/createoffer/CreateOfferViewCB.java | 12 ++- .../main/trade/orderbook/OrderBookModel.java | 34 +++--- .../gui/main/trade/orderbook/OrderBookPM.java | 35 ++++-- .../main/trade/orderbook/OrderBookViewCB.java | 21 ++-- .../main/trade/takeoffer/TakeOfferModel.java | 68 +++++++----- .../gui/main/trade/takeoffer/TakeOfferPM.java | 73 +++++++------ .../main/trade/takeoffer/TakeOfferView.fxml | 13 ++- .../main/trade/takeoffer/TakeOfferViewCB.java | 20 ++-- .../resources/i18n/displayStrings.properties | 5 +- 23 files changed, 304 insertions(+), 298 deletions(-) delete mode 100644 src/main/java/io/bitsquare/gui/main/trade/OrderBookInfo.java create mode 100644 src/main/java/io/bitsquare/gui/main/trade/TradeNavigator.java diff --git a/README.md b/README.md index d79c1a4fa2..9088707413 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ You can generate coins on demand with the Bitcoin QT client with the following c **setgenerate true 101** 101 is used only for the first start because of the coin maturity of 100 blocks. Later for mining of a single block you can use 1 as number of blocks to be created. -More information about the regtest mode can be found [here](https://bitcoinj.github.io/testing). +More information about the regtest mode can be found [here](https://bitcoinj.github.io/testing) or [here](https://bitcoin.org/en/developer-examples#regtest-mode). The network mode is defined in the guice module (BitSquareModule) and is default set to regtest. Testnet should also work, but was not tested for a while as for developing regtest is much more convenient. diff --git a/src/main/java/io/bitsquare/gui/bitsquare.css b/src/main/java/io/bitsquare/gui/bitsquare.css index 8207b2d5ec..0125511f2e 100644 --- a/src/main/java/io/bitsquare/gui/bitsquare.css +++ b/src/main/java/io/bitsquare/gui/bitsquare.css @@ -205,6 +205,10 @@ textfield */ -fx-font-size: 14; } +#non-clickable-icon { + -fx-text-fill: #AAAAAA; +} + #clickable-icon { -fx-text-fill: -bs-theme-color; -fx-cursor: hand; diff --git a/src/main/java/io/bitsquare/gui/components/InfoDisplay.java b/src/main/java/io/bitsquare/gui/components/InfoDisplay.java index 73149b2bb8..2a23ac89c4 100644 --- a/src/main/java/io/bitsquare/gui/components/InfoDisplay.java +++ b/src/main/java/io/bitsquare/gui/components/InfoDisplay.java @@ -20,24 +20,25 @@ package io.bitsquare.gui.components; import io.bitsquare.locale.BSResources; import javafx.application.Platform; -import javafx.beans.property.DoubleProperty; import javafx.beans.property.IntegerProperty; import javafx.beans.property.ObjectProperty; -import javafx.beans.property.SimpleDoubleProperty; import javafx.beans.property.SimpleIntegerProperty; import javafx.beans.property.SimpleObjectProperty; import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.StringProperty; +import javafx.beans.value.ChangeListener; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.geometry.Insets; import javafx.geometry.VPos; import javafx.scene.*; import javafx.scene.control.*; -import javafx.scene.image.*; import javafx.scene.layout.*; import javafx.scene.text.*; +import de.jensd.fx.fontawesome.AwesomeDude; +import de.jensd.fx.fontawesome.AwesomeIcon; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -53,13 +54,12 @@ public class InfoDisplay extends Parent { private final StringProperty text = new SimpleStringProperty(); private final IntegerProperty rowIndex = new SimpleIntegerProperty(0); private final IntegerProperty columnIndex = new SimpleIntegerProperty(0); - private final DoubleProperty prefWidth = new SimpleDoubleProperty(740); private final ObjectProperty> onAction = new SimpleObjectProperty<>(); private final ObjectProperty gridPane = new SimpleObjectProperty<>(); private boolean useReadMore; - private final ImageView icon; + private final Label icon = AwesomeDude.createIconLabel(AwesomeIcon.INFO_SIGN); private final TextFlow textFlow; private final Label label; private final Hyperlink link; @@ -70,21 +70,18 @@ public class InfoDisplay extends Parent { /////////////////////////////////////////////////////////////////////////////////////////// public InfoDisplay() { - - icon = new ImageView(); - icon.setId("image-info"); - icon.setPickOnBounds(true); - icon.setPreserveRatio(true); + icon.setId("non-clickable-icon"); icon.visibleProperty().bind(visibleProperty()); GridPane.setValignment(icon, VPos.TOP); - GridPane.setMargin(icon, new Insets(4, 2, 0, 0)); + GridPane.setMargin(icon, new Insets(-2, 0, 0, 0)); GridPane.setRowSpan(icon, 2); label = new Label(); label.textProperty().bind(text); - label.prefWidthProperty().bind(prefWidth); label.setTextOverrun(OverrunStyle.WORD_ELLIPSIS); + // width is set a frame later so we hide it first + label.setVisible(false); link = new Hyperlink(BSResources.get("shared.readMore")); link.setPadding(new Insets(0, 0, 0, -2)); @@ -109,6 +106,11 @@ public class InfoDisplay extends Parent { Platform.runLater(() -> textFlow.getChildren().setAll(label, link)); }); + // update the width when the window gets resized + ChangeListener listener = (ov2, oldValue2, windowWidth) -> + label.setPrefWidth((double) windowWidth - localToScene(0, 0).getX() - 35); + + // when clicking "Read more..." we expand and change the link to the Help link.setOnAction(new EventHandler() { @Override @@ -117,6 +119,8 @@ public class InfoDisplay extends Parent { label.setWrapText(true); link.setText(BSResources.get("shared.openHelp")); + getScene().getWindow().widthProperty().removeListener(listener); + label.prefWidthProperty().unbind(); label.prefWidthProperty().bind(textFlow.widthProperty()); link.setVisited(false); // focus border is a bit confusing here so we remove it @@ -128,6 +132,18 @@ public class InfoDisplay extends Parent { } } }); + + sceneProperty().addListener((ov, oldValue, newValue) -> { + if (oldValue == null && newValue != null) { + newValue.getWindow().widthProperty().addListener(listener); + // localToScene does deliver 0 instead of the correct x position when scene propery gets set, + // so we delay for 1 render cycle + Platform.runLater(() -> { + label.setVisible(true); + label.setPrefWidth(newValue.getWindow().getWidth() - localToScene(0, 0).getX() - 35); + }); + } + }); } @@ -139,11 +155,6 @@ public class InfoDisplay extends Parent { this.text.set(text); } - public void setPrefWidth(double prefWidth) { - this.prefWidth.set(prefWidth); - // label.setPrefWidth(getPrefWidth()); - } - public void setGridPane(GridPane gridPane) { this.gridPane.set(gridPane); @@ -188,14 +199,6 @@ public class InfoDisplay extends Parent { return text; } - public double getPrefWidth() { - return prefWidth.get(); - } - - public DoubleProperty prefWidthProperty() { - return prefWidth; - } - public int getColumnIndex() { return columnIndex.get(); } diff --git a/src/main/java/io/bitsquare/gui/main/account/content/changepassword/ChangePasswordView.fxml b/src/main/java/io/bitsquare/gui/main/account/content/changepassword/ChangePasswordView.fxml index e83b0c366d..749628ba6a 100644 --- a/src/main/java/io/bitsquare/gui/main/account/content/changepassword/ChangePasswordView.fxml +++ b/src/main/java/io/bitsquare/gui/main/account/content/changepassword/ChangePasswordView.fxml @@ -59,7 +59,7 @@ - diff --git a/src/main/java/io/bitsquare/gui/main/account/content/fiat/FiatAccountView.fxml b/src/main/java/io/bitsquare/gui/main/account/content/fiat/FiatAccountView.fxml index 1e9fac8143..79f0905521 100644 --- a/src/main/java/io/bitsquare/gui/main/account/content/fiat/FiatAccountView.fxml +++ b/src/main/java/io/bitsquare/gui/main/account/content/fiat/FiatAccountView.fxml @@ -72,7 +72,7 @@ visible="false" prefWidth="150.0"/> - @@ -111,7 +111,7 @@