Merge branch 'ripcurlx-feature/unify-tooltip-styling' into UI-improvements

This commit is contained in:
Manfred Karrer 2018-01-22 19:43:46 -05:00
commit c7e5563481
No known key found for this signature in database
GPG Key ID: 401250966A6B2C46
14 changed files with 51 additions and 103 deletions

View File

@ -35,7 +35,7 @@ bg color of non edit textFields: fafafa
-bs-very-light-grey:#F0F0F0; /* derive(-bs-white, -6%) 10 usages */
-bs-very-dark-grey: #3c3c3c; /* 8 usages */
-bs-very-dark-grey2: #111; /* 1 usages */
-bs-black-transparent: #80000000; /* 1 usages */
-bs-black-transparent: rgba(0, 0, 0, 0.5); /* 1 usages */
-bs-light-grey2: #cfcfcf;/* 2 usages */
-bs-light-grey3: #b5b5b5; /* 1 usages */
-bs-bg-grey4: #f6f6f6; /* 1 usages */
@ -360,42 +360,28 @@ textfield */
-fx-progress-color: -bs-dim-grey;
}
.hyperlink,
.hyperlink:hover,
.hyperlink:visited,
.hyperlink:hover:visited,
.hyperlink:focused
{
-fx-border-style: none;
-fx-border-width: 0px;
}
.hyperlink {
-fx-border-style: none;
-fx-border-width: 0px;
-fx-text-fill: -fx-accent;
}
.hyperlink .text {
-fx-fill: -bs-white;
-fx-border-style: none;
-fx-border-width: 0px;
}
.hyperlink .text {
-fx-fill: -fx-accent;
-fx-border-style: none;
-fx-border-width: 0px;
}
.hyperlink .text:hover,
.hyperlink .tooltip .text,
.hyperlink .text:hover {
-fx-fill: -bs-black;
-fx-border-style: none;
-fx-border-width: 0px;
.hyperlink:hover {
-fx-text-fill: -bs-black;
}
.hyperlink:hover,
.hyperlink:visited,
.hyperlink:hover:visited {
-fx-underline: false;
-fx-border-style: none;
-fx-border-width: 0px;
}
.hyperlink:focused {
-fx-border-style: none;
-fx-border-width: 0px;
}
.market-price-tooltip {
@ -473,7 +459,6 @@ textfield */
}
.table-view .table-row-cell .hyperlink .text:hover,
.table-view .table-row-cell:selected .hyperlink .tooltip .text,
.table-view .table-row-cell:selected .hyperlink .text:hover {
-fx-fill: -bs-black;
-fx-border-style: none;
@ -687,6 +672,15 @@ textfield */
-fx-background: -bs-grey;
}
#address-text-field {
-fx-cursor: hand;
-fx-text-fill: -fx-accent;
}
#address-text-field:hover {
-fx-text-fill: -bs-black;
}
/* Account setup */
#wizard-item-background-deactivated {
-fx-body-color: linear-gradient(to bottom, -bs-content-bg-grey, -bs-very-light-grey);

View File

@ -53,7 +53,6 @@ public class AddressTextField extends AnchorPane {
public AddressTextField() {
TextField textField = new TextField();
textField.setId("address-text-field");
textField.getStyleClass().addAll("highlight","show-hand");
textField.setEditable(false);
textField.textProperty().bind(address);
String tooltipText = Res.get("addressTextField.openWallet");

View File

@ -17,7 +17,6 @@ import org.slf4j.LoggerFactory;
public class AddressWithIconAndDirection extends AnchorPane {
private static final Logger log = LoggerFactory.getLogger(AddressWithIconAndDirection.class);
private final Hyperlink hyperlink;
private final Label openLinkIcon;
public AddressWithIconAndDirection(String text, String address, AwesomeIcon awesomeIcon, boolean received) {
Label directionIcon = new AutoTooltipLabel();
@ -31,11 +30,11 @@ public class AddressWithIconAndDirection extends AnchorPane {
hBox.setSpacing(-1);
Label label = new AutoTooltipLabel(text);
label.setMouseTransparent(true);
HBox.setMargin(label, new Insets(4, 0, 0, 0));
HBox.setMargin(label, new Insets(8, 0, 0, 0));
HBox.setHgrow(label, Priority.ALWAYS);
hyperlink = new Hyperlink(address);
HBox.setMargin(hyperlink, new Insets(1, 0, 0, 0));
hyperlink = new HyperlinkWithIcon(address, awesomeIcon);
HBox.setMargin(hyperlink, new Insets(0, 0, 0, 0));
HBox.setHgrow(hyperlink, Priority.SOMETIMES);
// You need to set max width to Double.MAX_VALUE to make HBox.setHgrow working like expected!
// also pref width needs to be not default (-1)
@ -44,29 +43,18 @@ public class AddressWithIconAndDirection extends AnchorPane {
hBox.getChildren().addAll(label, hyperlink);
openLinkIcon = new AutoTooltipLabel();
openLinkIcon.setLayoutY(3);
openLinkIcon.getStyleClass().addAll("icon", "highlight");
openLinkIcon.setOpacity(0.7);
AwesomeDude.setIcon(openLinkIcon, awesomeIcon);
AnchorPane.setLeftAnchor(directionIcon, 3.0);
AnchorPane.setTopAnchor(directionIcon, 2.0);
AnchorPane.setTopAnchor(directionIcon, 6.0);
AnchorPane.setLeftAnchor(hBox, 22.0);
AnchorPane.setRightAnchor(hBox, 15.0);
AnchorPane.setRightAnchor(openLinkIcon, 4.0);
AnchorPane.setTopAnchor(openLinkIcon, 3.0);
getChildren().addAll(directionIcon, hBox, openLinkIcon);
getChildren().addAll(directionIcon, hBox);
}
public void setOnAction(EventHandler<ActionEvent> handler) {
hyperlink.setOnAction(handler);
openLinkIcon.setOnMouseClicked(e -> handler.handle(null));
}
public void setTooltip(Tooltip tooltip) {
hyperlink.setTooltip(tooltip);
openLinkIcon.setTooltip(tooltip);
}
}

View File

@ -47,7 +47,6 @@ public class BsqAddressTextField extends AnchorPane {
public BsqAddressTextField() {
TextField textField = new TextField();
textField.setId("address-text-field");
textField.getStyleClass().addAll("highlight","show-hand");
textField.setEditable(false);
textField.textProperty().bind(address);
String tooltipText = Res.get("addressTextField.copyToClipboard");

View File

@ -2,62 +2,29 @@ package io.bisq.gui.components;
import de.jensd.fx.fontawesome.AwesomeDude;
import de.jensd.fx.fontawesome.AwesomeIcon;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.scene.control.ContentDisplay;
import javafx.scene.control.Hyperlink;
import javafx.scene.control.Label;
import javafx.scene.control.Tooltip;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.layout.Priority;
public class HyperlinkWithIcon extends HBox {
private final Hyperlink hyperlink;
private final Label icon;
public class HyperlinkWithIcon extends Hyperlink {
public HyperlinkWithIcon(String text) {
this(text, AwesomeIcon.INFO_SIGN);
}
public HyperlinkWithIcon(String text, AwesomeIcon awesomeIcon) {
this(text, awesomeIcon, false);
}
public HyperlinkWithIcon(String text, boolean isCentered) {
this(text, AwesomeIcon.INFO_SIGN, isCentered);
}
super(text);
public HyperlinkWithIcon(String text, AwesomeIcon awesomeIcon, boolean isCentered) {
setSpacing(5);
hyperlink = new Hyperlink(text);
icon = new AutoTooltipLabel();
icon.getStyleClass().addAll("icon", "highlight");
Label icon = new Label();
AwesomeDude.setIcon(icon, awesomeIcon);
icon.setMinWidth(20);
icon.setOpacity(0.7);
HBox.setMargin(icon, new Insets(awesomeIcon == AwesomeIcon.INFO_SIGN ? 2 : 3, 0, 0, 0));
icon.getStyleClass().add("hyperlink");
if (isCentered) {
Pane spacer1 = new Pane();
spacer1.setMaxWidth(Double.MAX_VALUE);
HBox.setHgrow(spacer1, Priority.ALWAYS);
setGraphic(icon);
setContentDisplay(ContentDisplay.RIGHT);
Pane spacer2 = new Pane();
spacer2.setMaxWidth(Double.MAX_VALUE);
HBox.setHgrow(spacer2, Priority.ALWAYS);
getChildren().addAll(spacer1, hyperlink, icon, spacer2);
} else {
getChildren().addAll(hyperlink, icon);
}
}
public void setOnAction(EventHandler<ActionEvent> handler) {
hyperlink.setOnAction(handler);
icon.setOnMouseClicked(e -> handler.handle(null));
}
public void setTooltip(Tooltip tooltip) {
hyperlink.setTooltip(tooltip);
// TODO does not use the right style
icon.setTooltip(tooltip);
tooltipProperty().addListener((observable, oldValue, newValue) -> newValue.setStyle("-fx-text-fill: -bs-black"));
}
}

View File

@ -11,12 +11,13 @@ public class TooltipUtil {
for (Object node : skinBase.getChildren()) {
if (node instanceof Text) {
String displayedText = ((Text) node).getText();
if (displayedText.equals(labeled.getText())) {
String untruncatedText = labeled.getText();
if (displayedText.equals(untruncatedText)) {
if (labeled.getTooltip() != null) {
labeled.setTooltip(null);
}
} else if (labeled.getText() != null){
labeled.setTooltip(new Tooltip(labeled.getText()));
} else if (untruncatedText != null && !untruncatedText.trim().isEmpty()){
labeled.setTooltip(new Tooltip(untruncatedText));
}
}
}

View File

@ -92,7 +92,6 @@ public class TxIdTextField extends AnchorPane {
textField = new TextField();
textField.setId("address-text-field");
textField.getStyleClass().addAll("highlight","show-hand");
textField.setEditable(false);
textField.setTooltip(tooltip);
AnchorPane.setRightAnchor(textField, 80.0);

View File

@ -1039,7 +1039,7 @@ public class TraderDisputeView extends ActivatableView<VBox, Void> {
super.updateItem(item, empty);
if (item != null && !empty) {
field = new HyperlinkWithIcon(item.getShortTradeId(), true);
field = new HyperlinkWithIcon(item.getShortTradeId());
Optional<Trade> tradeOptional = tradeManager.getTradeById(item.getTradeId());
if (tradeOptional.isPresent()) {
field.setMouseTransparent(false);

View File

@ -679,7 +679,7 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
super.updateItem(item, empty);
if (item != null && !empty) {
field = new HyperlinkWithIcon(model.getPaymentMethod(item), true);
field = new HyperlinkWithIcon(model.getPaymentMethod(item));
field.setOnAction(event -> offerDetailsWindow.show(item.getOffer()));
field.setTooltip(new Tooltip(model.getPaymentMethodToolTip(item)));
setPadding(new Insets(4, 0, 0, 0));

View File

@ -216,7 +216,7 @@ public class ClosedTradesView extends ActivatableViewAndModel<VBox, ClosedTrades
public void updateItem(final ClosedTradableListItem item, boolean empty) {
super.updateItem(item, empty);
if (item != null && !empty) {
field = new HyperlinkWithIcon(model.getTradeId(item), true);
field = new HyperlinkWithIcon(model.getTradeId(item));
field.setOnAction(event -> {
Tradable tradable = item.getTradable();
if (tradable instanceof Trade)

View File

@ -129,7 +129,7 @@ public class FailedTradesView extends ActivatableViewAndModel<VBox, FailedTrades
public void updateItem(final FailedTradesListItem item, boolean empty) {
super.updateItem(item, empty);
if (item != null && !empty) {
field = new HyperlinkWithIcon(model.getTradeId(item), true);
field = new HyperlinkWithIcon(model.getTradeId(item));
field.setOnAction(event -> tradeDetailsWindow.show(item.getTrade()));
field.setTooltip(new Tooltip(Res.get("tooltip.openPopupForDetails")));
setGraphic(field);

View File

@ -169,7 +169,7 @@ public class OpenOffersView extends ActivatableViewAndModel<VBox, OpenOffersView
super.updateItem(item, empty);
if (item != null && !empty) {
field = new HyperlinkWithIcon(model.getTradeId(item), true);
field = new HyperlinkWithIcon(model.getTradeId(item));
field.setOnAction(event -> offerDetailsWindow.show(item.getOffer()));
field.setTooltip(new Tooltip(Res.get("tooltip.openPopupForDetails")));
setGraphic(field);

View File

@ -283,7 +283,7 @@ public class PendingTradesView extends ActivatableViewAndModel<VBox, PendingTrad
super.updateItem(item, empty);
if (item != null && !empty) {
field = new HyperlinkWithIcon(item.getTrade().getShortId(), true);
field = new HyperlinkWithIcon(item.getTrade().getShortId());
field.setOnAction(event -> tradeDetailsWindow.show(item.getTrade()));
field.setTooltip(new Tooltip(Res.get("tooltip.openPopupForDetails")));
setGraphic(field);

View File

@ -178,6 +178,7 @@ public class FormBuilder {
GridPane.setRowIndex(hyperlinkWithIcon, rowIndex);
GridPane.setColumnIndex(hyperlinkWithIcon, 0);
GridPane.setMargin(hyperlinkWithIcon, new Insets(top, 0, 0, -4));
GridPane.setHalignment(hyperlinkWithIcon, HPos.LEFT);
gridPane.getChildren().add(hyperlinkWithIcon);
return hyperlinkWithIcon;
}