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 e6fe1fd72..9c4641d82 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
@@ -7,8 +7,7 @@ import javafx.fxml.FXML;
import javafx.scene.input.DragEvent;
import javafx.scene.input.TransferMode;
import javafx.scene.layout.HBox;
-import javafx.scene.layout.Region;
-import javafx.scene.layout.VBox;
+import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import org.cryptomator.common.LicenseHolder;
import org.cryptomator.common.vaults.VaultListManager;
@@ -46,8 +45,7 @@ public class MainWindowController implements FxController {
private final BooleanProperty draggingOver = new SimpleBooleanProperty();
private final BooleanProperty draggingVaultOver = new SimpleBooleanProperty();
public HBox titleBar;
- public VBox root;
- public Region resizer;
+ public StackPane root;
private double xOffset;
private double yOffset;
@@ -74,11 +72,6 @@ public class MainWindowController implements FxController {
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());
- });
updateChecker.automaticallyCheckForUpdatesIfEnabled();
root.setOnDragEntered(this::handleDragEvent);
root.setOnDragOver(this::handleDragEvent);
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 5ef76c5e0..52c223e65 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
@@ -68,6 +68,11 @@ abstract class MainWindowModule {
@FxControllerKey(MainWindowController.class)
abstract FxController bindMainWindowController(MainWindowController controller);
+ @Binds
+ @IntoMap
+ @FxControllerKey(ResizeController.class)
+ abstract FxController bindResizeController(ResizeController controller);
+
@Binds
@IntoMap
@FxControllerKey(VaultListController.class)
diff --git a/main/ui/src/main/java/org/cryptomator/ui/mainwindow/ResizeController.java b/main/ui/src/main/java/org/cryptomator/ui/mainwindow/ResizeController.java
new file mode 100644
index 000000000..fbf67aeb2
--- /dev/null
+++ b/main/ui/src/main/java/org/cryptomator/ui/mainwindow/ResizeController.java
@@ -0,0 +1,102 @@
+package org.cryptomator.ui.mainwindow;
+
+import javafx.fxml.FXML;
+import javafx.scene.input.MouseEvent;
+import javafx.scene.layout.Region;
+import javafx.stage.Stage;
+import org.cryptomator.ui.common.FxController;
+
+import javax.inject.Inject;
+
+@MainWindow
+public class ResizeController implements FxController {
+
+ private final Stage window;
+
+ public Region tlResizer;
+ public Region trResizer;
+ public Region blResizer;
+ public Region brResizer;
+
+ private double origX, origY, origW, origH;
+
+ @Inject
+ ResizeController(@MainWindow Stage window) {
+ this.window = window;
+ // TODO inject settings and save current position and size
+ }
+
+ @FXML
+ public void initialize() {
+ tlResizer.setOnMousePressed(this::startResize);
+ trResizer.setOnMousePressed(this::startResize);
+ blResizer.setOnMousePressed(this::startResize);
+ brResizer.setOnMousePressed(this::startResize);
+ tlResizer.setOnMouseDragged(this::resizeTopLeft);
+ trResizer.setOnMouseDragged(this::resizeTopRight);
+ blResizer.setOnMouseDragged(this::resizeBottomLeft);
+ brResizer.setOnMouseDragged(this::resizeBottomRight);
+ }
+
+ private void startResize(MouseEvent evt) {
+ origX = window.getX();
+ origY = window.getY();
+ origW = window.getWidth();
+ origH = window.getHeight();
+ }
+
+ private void resizeTopLeft(MouseEvent evt) {
+ resizeTop(evt);
+ resizeLeft(evt);
+ }
+
+ private void resizeTopRight(MouseEvent evt) {
+ resizeTop(evt);
+ resizeRight(evt);
+ }
+
+ private void resizeBottomLeft(MouseEvent evt) {
+ resizeBottom(evt);
+ resizeLeft(evt);
+ }
+
+ private void resizeBottomRight(MouseEvent evt) {
+ resizeBottom(evt);
+ resizeRight(evt);
+ }
+
+ private void resizeTop(MouseEvent evt) {
+ double newY = evt.getScreenY();
+ double dy = newY - origY;
+ double newH = origH - dy;
+ if (newH < window.getMaxHeight() && newH > window.getMinHeight()) {
+ window.setY(newY);
+ window.setHeight(newH);
+ }
+ }
+
+ private void resizeLeft(MouseEvent evt) {
+ double newX = evt.getScreenX();
+ double dx = newX - origX;
+ double newW = origW - dx;
+ if (newW < window.getMaxWidth() && newW > window.getMinWidth()) {
+ window.setX(newX);
+ window.setWidth(newW);
+ }
+ }
+
+ private void resizeBottom(MouseEvent evt) {
+ double newH = evt.getSceneY();
+ if (newH < window.getMaxHeight() && newH > window.getMinHeight()) {
+ window.setHeight(newH);
+ }
+ }
+
+ private void resizeRight(MouseEvent evt) {
+ double newW = evt.getSceneX();
+ if (newW < window.getMaxWidth() && newW > window.getMinWidth()) {
+ window.setWidth(newW);
+ }
+ }
+
+}
diff --git a/main/ui/src/main/resources/css/dark_theme.css b/main/ui/src/main/resources/css/dark_theme.css
index c290476f6..7ad3a1da5 100644
--- a/main/ui/src/main/resources/css/dark_theme.css
+++ b/main/ui/src/main/resources/css/dark_theme.css
@@ -184,20 +184,6 @@
-fx-fill: CONTROL_WHITE_BG_ARMED;
}
-.main-window .resizer {
- -fx-background-color: linear-gradient(to bottom right,
- transparent 50%,
- CONTROL_BORDER_NORMAL 51%,
- CONTROL_BORDER_NORMAL 60%,
- transparent 61%,
- transparent 70%,
- CONTROL_BORDER_NORMAL 71%,
- CONTROL_BORDER_NORMAL 80%,
- transparent 81%
- );
- -fx-cursor: nw_resize;
-}
-
.main-window .update-indicator {
-fx-background-color: PRIMARY_BG, white, INDICATOR_BG;
-fx-background-insets: 0, 1px, 2px;
diff --git a/main/ui/src/main/resources/css/light_theme.css b/main/ui/src/main/resources/css/light_theme.css
index 36e4d2aa0..a09d3a908 100644
--- a/main/ui/src/main/resources/css/light_theme.css
+++ b/main/ui/src/main/resources/css/light_theme.css
@@ -184,20 +184,6 @@
-fx-fill: CONTROL_WHITE_BG_ARMED;
}
-.main-window .resizer {
- -fx-background-color: linear-gradient(to bottom right,
- transparent 50%,
- CONTROL_BORDER_NORMAL 51%,
- CONTROL_BORDER_NORMAL 60%,
- transparent 61%,
- transparent 70%,
- CONTROL_BORDER_NORMAL 71%,
- CONTROL_BORDER_NORMAL 80%,
- transparent 81%
- );
- -fx-cursor: nw_resize;
-}
-
.main-window .update-indicator {
-fx-background-color: PRIMARY_BG, white, INDICATOR_BG;
-fx-background-insets: 0, 1px, 2px;
diff --git a/main/ui/src/main/resources/fxml/main_window.fxml b/main/ui/src/main/resources/fxml/main_window.fxml
index ef2517cb1..a61b0273b 100644
--- a/main/ui/src/main/resources/fxml/main_window.fxml
+++ b/main/ui/src/main/resources/fxml/main_window.fxml
@@ -10,68 +10,69 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/main/ui/src/main/resources/fxml/main_window_resize.fxml b/main/ui/src/main/resources/fxml/main_window_resize.fxml
new file mode 100644
index 000000000..c6d025ff5
--- /dev/null
+++ b/main/ui/src/main/resources/fxml/main_window_resize.fxml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file