Skip to content

Commit

Permalink
Merge pull request #1945 from devinbileck/limit-initial-window-size
Browse files Browse the repository at this point in the history
Limit initial window size on application launch
  • Loading branch information
ManfredKarrer authored Nov 22, 2018
2 parents cd616ff + 27c41a0 commit d31fb45
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
22 changes: 17 additions & 5 deletions desktop/src/main/java/bisq/desktop/app/BisqApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@
import javafx.scene.layout.Pane;
import javafx.scene.layout.StackPane;

import java.awt.GraphicsEnvironment;
import java.awt.Rectangle;

import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;

Expand All @@ -83,8 +86,10 @@
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;

import static bisq.desktop.util.Layout.INITIAL_SCENE_HEIGHT;
import static bisq.desktop.util.Layout.INITIAL_SCENE_WIDTH;
import static bisq.desktop.util.Layout.INITIAL_WINDOW_HEIGHT;
import static bisq.desktop.util.Layout.INITIAL_WINDOW_WIDTH;
import static bisq.desktop.util.Layout.MIN_WINDOW_HEIGHT;
import static bisq.desktop.util.Layout.MIN_WINDOW_WIDTH;

@Slf4j
public class BisqApp extends Application implements UncaughtExceptionHandler {
Expand Down Expand Up @@ -205,7 +210,14 @@ public void handleUncaughtException(Throwable throwable, boolean doShutDown) {
///////////////////////////////////////////////////////////////////////////////////////////

private Scene createAndConfigScene(MainView mainView, Injector injector) {
Scene scene = new Scene(mainView.getRoot(), INITIAL_SCENE_WIDTH, INITIAL_SCENE_HEIGHT);
Rectangle maxWindowBounds = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
Scene scene = new Scene(mainView.getRoot(),
maxWindowBounds.width < INITIAL_WINDOW_WIDTH ?
(maxWindowBounds.width < MIN_WINDOW_WIDTH ? MIN_WINDOW_WIDTH : maxWindowBounds.width) :
INITIAL_WINDOW_WIDTH,
maxWindowBounds.height < INITIAL_WINDOW_HEIGHT ?
(maxWindowBounds.height < MIN_WINDOW_HEIGHT ? MIN_WINDOW_HEIGHT : maxWindowBounds.height) :
INITIAL_WINDOW_HEIGHT);
scene.getStylesheets().setAll(
"/bisq/desktop/bisq.css",
"/bisq/desktop/images.css",
Expand All @@ -231,8 +243,8 @@ else if (BisqEnvironment.getBaseCurrencyNetwork().isRegtest())
appName += " [REGTEST]";
stage.setTitle(appName);
stage.setScene(scene);
stage.setMinWidth(1020);
stage.setMinHeight(620);
stage.setMinWidth(MIN_WINDOW_WIDTH);
stage.setMinHeight(MIN_WINDOW_HEIGHT);

// on Windows the title icon is also used as task bar icon in a larger size
// on Linux no title icon is supported but also a large task bar icon is derived from that title icon
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
import java.util.Collections;
import java.util.function.Function;

import static bisq.desktop.util.Layout.INITIAL_SCENE_HEIGHT;
import static bisq.desktop.util.Layout.INITIAL_WINDOW_HEIGHT;

@FxmlView
public class OfferBookChartView extends ActivatableViewAndModel<VBox, OfferBookChartViewModel> {
Expand Down Expand Up @@ -116,7 +116,7 @@ public class OfferBookChartView extends ActivatableViewAndModel<VBox, OfferBookC
private final double initialOfferTableViewHeight = 109;
private final double pixelsPerOfferTableRow = (initialOfferTableViewHeight / 4.0) + 10.0; // initial visible row count=4
private final Function<Double, Double> offerTableViewHeight = (screenSize) -> {
int extraRows = screenSize <= INITIAL_SCENE_HEIGHT ? 0 : (int) ((screenSize - INITIAL_SCENE_HEIGHT) / pixelsPerOfferTableRow);
int extraRows = screenSize <= INITIAL_WINDOW_HEIGHT ? 0 : (int) ((screenSize - INITIAL_WINDOW_HEIGHT) / pixelsPerOfferTableRow);
return extraRows == 0 ? initialOfferTableViewHeight : Math.ceil(initialOfferTableViewHeight + (extraRows * pixelsPerOfferTableRow));
};

Expand Down
6 changes: 4 additions & 2 deletions desktop/src/main/java/bisq/desktop/util/Layout.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
package bisq.desktop.util;

public class Layout {
public static final double INITIAL_SCENE_WIDTH = 1200;
public static final double INITIAL_SCENE_HEIGHT = 710; //740
public static final double INITIAL_WINDOW_WIDTH = 1200;
public static final double INITIAL_WINDOW_HEIGHT = 710; //740
public static final double MIN_WINDOW_WIDTH = 1020;
public static final double MIN_WINDOW_HEIGHT = 620;
public static final double FIRST_ROW_DISTANCE = 20d;
public static final double GROUP_DISTANCE = 40d;
public static final double FIRST_ROW_AND_GROUP_DISTANCE = GROUP_DISTANCE + FIRST_ROW_DISTANCE;
Expand Down

0 comments on commit d31fb45

Please sign in to comment.