fix fullscreen binding

This commit is contained in:
Martin Beyer
2021-08-25 11:31:29 +02:00
parent 957640b1ba
commit 6b4ea9a9eb
3 changed files with 25 additions and 19 deletions

View File

@@ -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());

View File

@@ -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();
}
}

View File

@@ -9,18 +9,17 @@
<fx:define>
<Cursor fx:id="nwResize" fx:constant="NW_RESIZE"/>
<Cursor fx:id="neResize" fx:constant="NE_RESIZE"/>
<Cursor fx:id="nsResize" fx:constant="N_RESIZE" />
<Cursor fx:id="ewResize" fx:constant="E_RESIZE" />
<Cursor fx:id="nsResize" fx:constant="N_RESIZE"/>
<Cursor fx:id="ewResize" fx:constant="E_RESIZE"/>
</fx:define>
<Region fx:id="tlResizer" cursor="${nwResize}" prefWidth="10" prefHeight="10" maxWidth="-Infinity" maxHeight="-Infinity" managed="${controller.showResizingArrows}" AnchorPane.topAnchor="0" AnchorPane.leftAnchor="0"/>
<Region fx:id="trResizer" cursor="${neResize}" prefWidth="10" prefHeight="10" maxWidth="-Infinity" maxHeight="-Infinity" managed="${controller.showResizingArrows}" AnchorPane.topAnchor="0" AnchorPane.rightAnchor="0"/>
<Region fx:id="blResizer" cursor="${neResize}" prefWidth="10" prefHeight="10" maxWidth="-Infinity" maxHeight="-Infinity" managed="${controller.showResizingArrows}" AnchorPane.bottomAnchor="0" AnchorPane.leftAnchor="0"/>
<Region fx:id="brResizer" cursor="${nwResize}" prefWidth="10" prefHeight="10" maxWidth="-Infinity" maxHeight="-Infinity" managed="${controller.showResizingArrows}" AnchorPane.bottomAnchor="0" AnchorPane.rightAnchor="0"/>
<Region fx:id="tResizer" cursor="${nsResize}" prefWidth="10" prefHeight="10" maxWidth="-Infinity" maxHeight="-Infinity" managed="${controller.showResizingArrows}" AnchorPane.leftAnchor="10.0" AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="0.0"/>
<Region fx:id="rResizer" cursor="${ewResize}" prefWidth="10" prefHeight="10" maxWidth="-Infinity" maxHeight="-Infinity" managed="${controller.showResizingArrows}" AnchorPane.bottomAnchor="10.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="10.0"/>
<Region fx:id="bResizer" cursor="${nsResize}" prefWidth="10" prefHeight="10" maxWidth="-Infinity" maxHeight="-Infinity" managed="${controller.showResizingArrows}" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="10.0" AnchorPane.rightAnchor="10.0"/>
<Region fx:id="lResizer" cursor="${ewResize}" prefWidth="10" prefHeight="10" maxWidth="-Infinity" maxHeight="-Infinity" managed="${controller.showResizingArrows}" AnchorPane.bottomAnchor="10.0" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="10.0"/>
<Region fx:id="tlResizer" cursor="${nwResize}" prefWidth="10" prefHeight="10" maxWidth="-Infinity" maxHeight="-Infinity" visible="${controller.showResizingArrows}" managed="${controller.showResizingArrows}" AnchorPane.topAnchor="0" AnchorPane.leftAnchor="0"/>
<Region fx:id="trResizer" cursor="${neResize}" prefWidth="10" prefHeight="10" maxWidth="-Infinity" maxHeight="-Infinity" visible="${controller.showResizingArrows}" managed="${controller.showResizingArrows}" AnchorPane.topAnchor="0" AnchorPane.rightAnchor="0"/>
<Region fx:id="blResizer" cursor="${neResize}" prefWidth="10" prefHeight="10" maxWidth="-Infinity" maxHeight="-Infinity" visible="${controller.showResizingArrows}" managed="${controller.showResizingArrows}" AnchorPane.bottomAnchor="0" AnchorPane.leftAnchor="0"/>
<Region fx:id="brResizer" cursor="${nwResize}" prefWidth="10" prefHeight="10" maxWidth="-Infinity" maxHeight="-Infinity" visible="${controller.showResizingArrows}" managed="${controller.showResizingArrows}" AnchorPane.bottomAnchor="0" AnchorPane.rightAnchor="0"/>
<Region fx:id="tResizer" cursor="${nsResize}" prefWidth="10" prefHeight="10" maxWidth="-Infinity" maxHeight="-Infinity" visible="${controller.showResizingArrows}" managed="${controller.showResizingArrows}" AnchorPane.leftAnchor="10.0" AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="0.0"/>
<Region fx:id="rResizer" cursor="${ewResize}" prefWidth="10" prefHeight="10" maxWidth="-Infinity" maxHeight="-Infinity" visible="${controller.showResizingArrows}" managed="${controller.showResizingArrows}" AnchorPane.bottomAnchor="10.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="10.0"/>
<Region fx:id="bResizer" cursor="${nsResize}" prefWidth="10" prefHeight="10" maxWidth="-Infinity" maxHeight="-Infinity" visible="${controller.showResizingArrows}" managed="${controller.showResizingArrows}" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="10.0" AnchorPane.rightAnchor="10.0"/>
<Region fx:id="lResizer" cursor="${ewResize}" prefWidth="10" prefHeight="10" maxWidth="-Infinity" maxHeight="-Infinity" visible="${controller.showResizingArrows}" managed="${controller.showResizingArrows}" AnchorPane.bottomAnchor="10.0" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="10.0"/>
</AnchorPane>