Skip to content

Commit

Permalink
Size the offer book on window activation
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jmacxx committed Mar 18, 2020
1 parent 879c3f2 commit 02d37b7
Showing 1 changed file with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -280,6 +282,7 @@ public Number fromString(String string) {
sellOfferTableView.getSelectionModel().selectedItemProperty().addListener(sellTableRowSelectionListener);

root.getScene().heightProperty().addListener(bisqWindowVerticalSizeListener);
layout();

updateChartData();
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
}

0 comments on commit 02d37b7

Please sign in to comment.