feat(gui): add screen property to Stage
@@ -3,6 +3,7 @@ package engine.gui.stage;
import com.github.mouse0w0.observable.collection.ObservableCollections;
import com.github.mouse0w0.observable.collection.ObservableList;
import com.github.mouse0w0.observable.value.*;
+import engine.graphics.display.Screen;
import engine.graphics.display.Window;
import engine.graphics.display.callback.*;
import engine.graphics.image.ReadOnlyImage;
@@ -20,6 +21,8 @@ public class Stage {
private Stage owner;
+ private MutableObjectValue<Screen> screen;
+
private MutableIntValue x;
private MutableIntValue y;
@@ -122,6 +125,21 @@ public class Stage {
this.owner = owner;
}
+ private MutableObjectValue<Screen> screenImpl() {
+ if (screen == null) {
+ screen = new SimpleMutableObjectValue<>(Screen.getPrimary());
+ }
+ return screen;
+ }
+
+ public final ObservableObjectValue<Screen> screen() {
+ return screenImpl().toUnmodifiable();
+ }
+
+ public final Screen getScreen() {
+ return screen == null ? Screen.getPrimary() : screen.get();
+ }
+
private MutableIntValue xImpl() {
if (x == null) {
x = new SimpleMutableIntValue();
@@ -487,6 +505,7 @@ public class Stage {
if (posCallback == null) posCallback = (window, x, y) -> {
xImpl().set(x);
yImpl().set(y);
+ screenImpl().set(window.getScreen());
};
window.addWindowPosCallback(posCallback);
@@ -515,7 +534,7 @@ public class Stage {
sizeToScene = false;
sizeToScene();
} else {
- window.setSize(getWidth(), getHeight());
+ setSize(getWidth(), getHeight());
}
if (x == null && y == null) {
