From 6b4ea9a9eba94bf1c551619976b65c28f1cabf94 Mon Sep 17 00:00:00 2001 From: Martin Beyer Date: Wed, 25 Aug 2021 11:31:29 +0200 Subject: [PATCH] fix fullscreen binding --- .../mainwindow/MainWindowTitleController.java | 2 +- .../ui/mainwindow/ResizeController.java | 19 ++++++++++----- .../resources/fxml/main_window_resize.fxml | 23 +++++++++---------- 3 files changed, 25 insertions(+), 19 deletions(-) diff --git a/src/main/java/org/cryptomator/ui/mainwindow/MainWindowTitleController.java b/src/main/java/org/cryptomator/ui/mainwindow/MainWindowTitleController.java index 2e68f66c5..bfa050f0b 100644 --- a/src/main/java/org/cryptomator/ui/mainwindow/MainWindowTitleController.java +++ b/src/main/java/org/cryptomator/ui/mainwindow/MainWindowTitleController.java @@ -73,7 +73,6 @@ public class MainWindowTitleController implements FxController { } }); titleBar.setOnMouseDragged(event -> { - //TODO should it be possible to move the window, when in fullscreen? if (window.isFullScreen()) return; window.setX(event.getScreenX() - xOffset); window.setY(event.getScreenY() - yOffset); @@ -86,6 +85,7 @@ public class MainWindowTitleController implements FxController { event.consume(); }); } + //TODO: almost duplicate from ResizeController.class private void saveSettings() { settings.windowYPositionProperty().setValue(window.getY()); diff --git a/src/main/java/org/cryptomator/ui/mainwindow/ResizeController.java b/src/main/java/org/cryptomator/ui/mainwindow/ResizeController.java index 4e6d80187..20c072895 100644 --- a/src/main/java/org/cryptomator/ui/mainwindow/ResizeController.java +++ b/src/main/java/org/cryptomator/ui/mainwindow/ResizeController.java @@ -1,5 +1,7 @@ package org.cryptomator.ui.mainwindow; +import javafx.beans.binding.Bindings; +import javafx.beans.binding.BooleanBinding; import javafx.fxml.FXML; import javafx.scene.input.MouseEvent; import javafx.scene.layout.Region; @@ -27,15 +29,17 @@ public class ResizeController implements FxController { public Region bResizer; public Region lResizer; - private double origX, origY, origW, origH; private final Settings settings; + private final BooleanBinding showResizingArrows; + @Inject ResizeController(@MainWindow Stage window, Settings settings) { this.window = window; this.settings = settings; + this.showResizingArrows = Bindings.createBooleanBinding(this::isShowResizingArrows, window.fullScreenProperty()); } @FXML @@ -72,8 +76,7 @@ public class ResizeController implements FxController { // if the position is illegal, then the window appears on the main screen in the middle of the window. window.setY((window.getMaxHeight() - window.getHeight()) / 2); window.setX((window.getMaxWidth() - window.getWidth()) / 2); - } - else { + } else { window.setX(settings.windowXPositionProperty().get()); window.setY(settings.windowYPositionProperty().get()); } @@ -152,9 +155,13 @@ public class ResizeController implements FxController { settings.windowXPositionProperty().setValue(window.getX()); } - public boolean isShowResizingArrows(){ - //If in fullscreen resizing should not be possible - return window.isFullScreen(); + public BooleanBinding showResizingArrowsProperty() { + return showResizingArrows; + } + + public boolean isShowResizingArrows() { + //If in fullscreen resizing should not be possible; + return !window.isFullScreen(); } } \ No newline at end of file diff --git a/src/main/resources/fxml/main_window_resize.fxml b/src/main/resources/fxml/main_window_resize.fxml index 49055610d..ce491b3a6 100644 --- a/src/main/resources/fxml/main_window_resize.fxml +++ b/src/main/resources/fxml/main_window_resize.fxml @@ -9,18 +9,17 @@ - - - - + + - - - - - - - - + + + + + + + + + \ No newline at end of file