mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-25 07:27:18 +01:00
Fix issue with popup centering
This commit is contained in:
parent
2d7aecd2ed
commit
7b82bdb41e
1 changed files with 17 additions and 0 deletions
|
@ -17,11 +17,13 @@
|
||||||
|
|
||||||
package io.bitsquare.gui.popups;
|
package io.bitsquare.gui.popups;
|
||||||
|
|
||||||
|
import io.bitsquare.common.UserThread;
|
||||||
import io.bitsquare.common.util.Utilities;
|
import io.bitsquare.common.util.Utilities;
|
||||||
import io.bitsquare.gui.main.MainView;
|
import io.bitsquare.gui.main.MainView;
|
||||||
import io.bitsquare.gui.util.Transitions;
|
import io.bitsquare.gui.util.Transitions;
|
||||||
import io.bitsquare.locale.BSResources;
|
import io.bitsquare.locale.BSResources;
|
||||||
import io.bitsquare.user.Preferences;
|
import io.bitsquare.user.Preferences;
|
||||||
|
import javafx.beans.value.ChangeListener;
|
||||||
import javafx.geometry.HPos;
|
import javafx.geometry.HPos;
|
||||||
import javafx.geometry.Insets;
|
import javafx.geometry.Insets;
|
||||||
import javafx.geometry.Orientation;
|
import javafx.geometry.Orientation;
|
||||||
|
@ -241,12 +243,27 @@ public class Popup {
|
||||||
centerPopup();
|
centerPopup();
|
||||||
|
|
||||||
MainView.blurLight();
|
MainView.blurLight();
|
||||||
|
|
||||||
|
// sometimes the positioning fails if UI is very busy and app window gets moved
|
||||||
|
ChangeListener<Number> positionListener = (observable, oldValue, newValue) -> {
|
||||||
|
if (stage != null)
|
||||||
|
UserThread.runAfter(this::centerPopup, 1);
|
||||||
|
};
|
||||||
|
owner.getScene().getWindow().xProperty().addListener(positionListener);
|
||||||
|
owner.getScene().getWindow().yProperty().addListener(positionListener);
|
||||||
|
|
||||||
|
UserThread.runAfter(() -> {
|
||||||
|
owner.getScene().getWindow().xProperty().removeListener(positionListener);
|
||||||
|
owner.getScene().getWindow().yProperty().removeListener(positionListener);
|
||||||
|
}, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void centerPopup() {
|
protected void centerPopup() {
|
||||||
Window window = owner.getScene().getWindow();
|
Window window = owner.getScene().getWindow();
|
||||||
double titleBarHeight = window.getHeight() - owner.getScene().getHeight();
|
double titleBarHeight = window.getHeight() - owner.getScene().getHeight();
|
||||||
Point2D point = owner.localToScene(0, 0);
|
Point2D point = owner.localToScene(0, 0);
|
||||||
|
log.error("window window.getX()=" + window.getX());
|
||||||
|
log.error("window window.getY()=" + window.getY());
|
||||||
stage.setX(Math.round(window.getX() + point.getX() + (owner.getWidth() - stage.getWidth()) / 2));
|
stage.setX(Math.round(window.getX() + point.getX() + (owner.getWidth() - stage.getWidth()) / 2));
|
||||||
stage.setY(Math.round(window.getY() + titleBarHeight + point.getY() + (owner.getHeight() - stage.getHeight()) / 2));
|
stage.setY(Math.round(window.getY() + titleBarHeight + point.getY() + (owner.getHeight() - stage.getHeight()) / 2));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue