From 14de8ffd5955ca4c549bd4921bcbb947451f80d9 Mon Sep 17 00:00:00 2001 From: Sebastian Stenzel Date: Tue, 23 Jul 2019 16:51:25 +0200 Subject: [PATCH] make window resizable (fixes #932) [ci skip] --- .../ui/mainwindow/MainWindowController.java | 15 +++++++++------ .../ui/mainwindow/MainWindowModule.java | 7 +++++-- main/ui/src/main/resources/fxml/main_window.fxml | 13 +++++++++---- main/ui/src/main/resources/fxml/vault_list.fxml | 1 - 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/main/ui/src/main/java/org/cryptomator/ui/mainwindow/MainWindowController.java b/main/ui/src/main/java/org/cryptomator/ui/mainwindow/MainWindowController.java index 201c652ce..79c094156 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/mainwindow/MainWindowController.java +++ b/main/ui/src/main/java/org/cryptomator/ui/mainwindow/MainWindowController.java @@ -2,9 +2,9 @@ package org.cryptomator.ui.mainwindow; import javafx.fxml.FXML; import javafx.scene.layout.HBox; +import javafx.scene.layout.Region; import javafx.stage.Stage; import org.cryptomator.ui.FxApplication; -import org.cryptomator.ui.FxApplicationScoped; import org.cryptomator.ui.common.FxController; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -21,10 +21,8 @@ public class MainWindowController implements FxController { private final CountDownLatch shutdownLatch; private final Stage window; private final FxApplication application; - - @FXML public HBox titleBar; - + public Region resizer; private double xOffset; private double yOffset; @@ -43,8 +41,13 @@ public class MainWindowController implements FxController { yOffset = event.getSceneY(); }); titleBar.setOnMouseDragged(event -> { - titleBar.getScene().getWindow().setX(event.getScreenX() - xOffset); - titleBar.getScene().getWindow().setY(event.getScreenY() - yOffset); + window.setX(event.getScreenX() - xOffset); + window.setY(event.getScreenY() - yOffset); + }); + resizer.setOnMouseDragged(event -> { + // we know for a fact that window is borderless. i.e. the scene starts at 0/0 of the window. + window.setWidth(event.getSceneX()); + window.setHeight(event.getSceneY()); }); } diff --git a/main/ui/src/main/java/org/cryptomator/ui/mainwindow/MainWindowModule.java b/main/ui/src/main/java/org/cryptomator/ui/mainwindow/MainWindowModule.java index 22c8bc6e7..66c134c3b 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/mainwindow/MainWindowModule.java +++ b/main/ui/src/main/java/org/cryptomator/ui/mainwindow/MainWindowModule.java @@ -29,8 +29,11 @@ public abstract class MainWindowModule { @MainWindowScoped static Stage provideStage() { Stage stage = new Stage(); - stage.setMinWidth(652.0); - stage.setMinHeight(440.0); + // TODO: min/max values chosen arbitrarily. We might wanna take a look at the user's resolution... + stage.setMinWidth(650); + stage.setMinHeight(440); + stage.setMaxWidth(1000); + stage.setMaxHeight(700); stage.initStyle(StageStyle.UNDECORATED); return stage; } diff --git a/main/ui/src/main/resources/fxml/main_window.fxml b/main/ui/src/main/resources/fxml/main_window.fxml index 7b56ed282..6fcf80df3 100644 --- a/main/ui/src/main/resources/fxml/main_window.fxml +++ b/main/ui/src/main/resources/fxml/main_window.fxml @@ -8,6 +8,7 @@ + - - - - + + + + + + + + diff --git a/main/ui/src/main/resources/fxml/vault_list.fxml b/main/ui/src/main/resources/fxml/vault_list.fxml index 84072e878..143760606 100644 --- a/main/ui/src/main/resources/fxml/vault_list.fxml +++ b/main/ui/src/main/resources/fxml/vault_list.fxml @@ -1,7 +1,6 @@ -