From 02d37b7042eab0393c51eeb3e763979dedc2ac36 Mon Sep 17 00:00:00 2001 From: jmacxx <47253594+jmacxx@users.noreply.github.com> Date: Fri, 6 Mar 2020 08:37:05 -0600 Subject: [PATCH] Size the offer book on window activation Currently the offer book tables are only being sized when the window proportions change. However if the window is made bigger before the offer book is opened, then the tables are not resized from their default. Other windows (for example Market -> Trades) solve this by make a sizing call in the activate method. In order to do this the sizing code is separated into a layout method where it can be called from both activate and the existing heightProperty listener. The same approach is taken here. Fixes #4030 --- .../market/offerbook/OfferBookChartView.java | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/desktop/src/main/java/bisq/desktop/main/market/offerbook/OfferBookChartView.java b/desktop/src/main/java/bisq/desktop/main/market/offerbook/OfferBookChartView.java index 1b4b18154f0..b51b4fe4835 100644 --- a/desktop/src/main/java/bisq/desktop/main/market/offerbook/OfferBookChartView.java +++ b/desktop/src/main/java/bisq/desktop/main/market/offerbook/OfferBookChartView.java @@ -42,6 +42,7 @@ import bisq.network.p2p.NodeAddress; +import bisq.common.UserThread; import bisq.common.config.Config; import bisq.common.util.Tuple3; import bisq.common.util.Tuple4; @@ -91,6 +92,7 @@ import java.util.Collections; import java.util.List; +import java.util.concurrent.TimeUnit; import java.util.function.Function; import static bisq.desktop.util.FormBuilder.addTopLabelAutocompleteComboBox; @@ -280,6 +282,7 @@ public Number fromString(String string) { sellOfferTableView.getSelectionModel().selectedItemProperty().addListener(sellTableRowSelectionListener); root.getScene().heightProperty().addListener(bisqWindowVerticalSizeListener); + layout(); updateChartData(); } @@ -321,13 +324,7 @@ private void createListener() { navigation.navigateTo(MainView.class, BuyOfferView.class); }; - bisqWindowVerticalSizeListener = (observable, oldValue, newValue) -> { - double newTableViewHeight = offerTableViewHeight.apply(newValue.doubleValue()); - if (buyOfferTableView.getHeight() != newTableViewHeight) { - buyOfferTableView.setMinHeight(newTableViewHeight); - sellOfferTableView.setMinHeight(newTableViewHeight); - } - }; + bisqWindowVerticalSizeListener = (observable, oldValue, newValue) -> layout(); } @Override @@ -665,4 +662,16 @@ private void reverseTableColumns() { Collections.reverse(columns); sellOfferTableView.getColumns().addAll(columns); } + + private void layout() { + UserThread.runAfter(() -> { + if (root.getScene() != null) { + double newTableViewHeight = offerTableViewHeight.apply(root.getScene().getHeight()); + if (buyOfferTableView.getHeight() != newTableViewHeight) { + buyOfferTableView.setMinHeight(newTableViewHeight); + sellOfferTableView.setMinHeight(newTableViewHeight); + } + } + }, 100, TimeUnit.MILLISECONDS); + } }