diff --git a/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/offerbook/BisqEasyOfferbookUtil.java b/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/offerbook/BisqEasyOfferbookUtil.java index 9edee4685f..37f5fe5049 100644 --- a/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/offerbook/BisqEasyOfferbookUtil.java +++ b/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/offerbook/BisqEasyOfferbookUtil.java @@ -15,6 +15,8 @@ import javafx.scene.layout.HBox; import javafx.scene.layout.VBox; import javafx.util.Callback; +import org.fxmisc.easybind.EasyBind; +import org.fxmisc.easybind.Subscription; import java.util.Comparator; import java.util.List; @@ -51,44 +53,59 @@ public static Comparator sortByMarketActivity() { public static Callback, TableCell> getMarketLabelCellFactory() { - return column -> new TableCell<>() { - private final Label marketName = new Label(); - private final Label marketCode = new Label(); - private final Label numOffers = new Label(); - private final HBox hBox = new HBox(10, marketCode, numOffers); - private final VBox vBox = new VBox(0, marketName, hBox); - private final Tooltip tooltip = new BisqTooltip(); + return column -> { + return new TableCell<>() { + private final Label marketName = new Label(); + private final Label marketCode = new Label(); + private final Label numOffers = new Label(); + private final HBox hBox = new HBox(10, marketCode, numOffers); + private final VBox vBox = new VBox(0, marketName, hBox); + private final Tooltip tooltip = new BisqTooltip(); + private Subscription selectedMarketPin; + + { + setCursor(Cursor.HAND); + hBox.setAlignment(Pos.CENTER_LEFT); + vBox.setAlignment(Pos.CENTER_LEFT); + Tooltip.install(vBox, tooltip); + } - { - setCursor(Cursor.HAND); - marketName.getStyleClass().add("market-name"); - hBox.setAlignment(Pos.CENTER_LEFT); - vBox.setAlignment(Pos.CENTER_LEFT); - Tooltip.install(vBox, tooltip); - } + @Override + protected void updateItem(MarketChannelItem item, boolean empty) { + super.updateItem(item, empty); - @Override - protected void updateItem(MarketChannelItem item, boolean empty) { - super.updateItem(item, empty); - if (item != null && !empty) { - marketName.setText(item.getMarket().getQuoteCurrencyName()); - marketCode.setText(item.getMarket().getQuoteCurrencyCode()); - StringExpression formattedNumOffers = Bindings.createStringBinding(() -> - BisqEasyOfferbookUtil.getFormattedOfferNumber(item.getNumOffers().get()), item.getNumOffers()); - numOffers.textProperty().bind(formattedNumOffers); - StringExpression formattedTooltip = Bindings.createStringBinding(() -> - BisqEasyOfferbookUtil.getFormattedTooltip(item.getNumOffers().get(), item.getMarket().getQuoteCurrencyName()), item.getNumOffers()); - tooltip.textProperty().bind(formattedTooltip); - tooltip.setStyle("-fx-text-fill: -fx-dark-text-color;"); - - setGraphic(vBox); - } else { + if (selectedMarketPin != null) { + selectedMarketPin.unsubscribe(); + selectedMarketPin = null; + } numOffers.textProperty().unbind(); tooltip.textProperty().unbind(); + updateStyleClass(false); + + if (item != null && !empty) { + selectedMarketPin = EasyBind.subscribe(item.getSelected(), this::updateStyleClass); + marketName.setText(item.getMarket().getQuoteCurrencyName()); + marketCode.setText(item.getMarket().getQuoteCurrencyCode()); + StringExpression formattedNumOffers = Bindings.createStringBinding(() -> + BisqEasyOfferbookUtil.getFormattedOfferNumber(item.getNumOffers().get()), item.getNumOffers()); + numOffers.textProperty().bind(formattedNumOffers); + StringExpression formattedTooltip = Bindings.createStringBinding(() -> + BisqEasyOfferbookUtil.getFormattedTooltip(item.getNumOffers().get(), + item.getMarket().getQuoteCurrencyName()), item.getNumOffers()); + tooltip.textProperty().bind(formattedTooltip); + tooltip.setStyle("-fx-text-fill: -fx-dark-text-color;"); + + setGraphic(vBox); + } else { + setGraphic(null); + } + } - setGraphic(null); + private void updateStyleClass(boolean isSelected) { + marketName.getStyleClass().removeAll("market-name", "market-name-selected"); + marketName.getStyleClass().add(isSelected ? "market-name-selected" : "market-name"); } - } + }; }; } diff --git a/apps/desktop/desktop/src/main/resources/css/bisq_easy.css b/apps/desktop/desktop/src/main/resources/css/bisq_easy.css index ad9e2a53e8..2fb1470d49 100644 --- a/apps/desktop/desktop/src/main/resources/css/bisq_easy.css +++ b/apps/desktop/desktop/src/main/resources/css/bisq_easy.css @@ -244,6 +244,11 @@ } .market-selection-list .market-name .text { + -fx-fill: -fx-mid-text-color !important; + -fx-text-fill: -fx-mid-text-color !important; +} + +.market-selection-list .market-name-selected .text { -fx-fill: -fx-light-text-color !important; -fx-text-fill: -fx-light-text-color !important; }