summaryrefslogtreecommitdiffstats
path: root/src/test/com
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2019-03-21 00:54:16 +0100
committerSven Gothel <[email protected]>2019-03-21 00:54:16 +0100
commit5ae0eeca1a7031931d10c0db56539bf565ee9591 (patch)
treea6eaf0a8c1d8a375b073a8fa6523d446df664790 /src/test/com
parentc4cebae730496f95308ad7a9d01cabe2061d916e (diff)
NewtCanvasJFX.NativeWindow: Delegate required child window canvas position
NewtCanvasJFX.NativeWindow shall pass through NewtCanvasJFX's Canvas position to properly position the NEWT child window inside the top level Window. NewtJFXReparentingKeyAdapter demonstrating manual reparenting demonstrates this case. TestGearsES2NewtCanvasAWT's default behavior is to use a surrounding border for the NEWTCanvasAWT child, similar to TestNewtCanvasJFXGLn.
Diffstat (limited to 'src/test/com')
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java48
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtJFXReparentingKeyAdapter.java30
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtReparentingKeyAdapter.java9
4 files changed, 15 insertions, 74 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java
index dc6e95bab..77c4bf8f3 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java
@@ -91,7 +91,7 @@ public class TestGearsES2NewtCanvasAWT extends UITestCase {
static int screenIdx = 0;
static PointImmutable wpos;
static DimensionImmutable wsize, rwsize = null;
- static FrameLayout frameLayout = FrameLayout.None;
+ static FrameLayout frameLayout = FrameLayout.BorderCenterSurrounded;
static ResizeBy resizeBy = ResizeBy.Component;
static float[] reqSurfacePixelScale = new float[] { ScalableSurface.AUTOMAX_PIXELSCALE, ScalableSurface.AUTOMAX_PIXELSCALE };
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java
index 276c4ccb9..7e92c8438 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java
@@ -49,54 +49,6 @@ public class NewtAWTReparentingKeyAdapter extends NewtReparentingKeyAdapter {
this.frame = frame;
}
- public void keyPressed(final KeyEvent e) {
- if( e.isAutoRepeat() || e.isConsumed() ) {
- return;
- }
- if( 0 == e.getModifiers() ) { // all modifiers go to super class ..
- final int keySymbol = e.getKeySymbol();
- switch (keySymbol) {
- case KeyEvent.VK_R:
- e.setConsumed(true);
- quitAdapterOff();
- glWindow.invokeOnNewThread(null, false, new Runnable() {
- public void run() {
- final java.lang.Thread t = glWindow.setExclusiveContextThread(null);
- if(glWindow.getParent()==null) {
- printlnState("[reparent pre - glWin to HOME]");
- glWindow.reparentWindow(winHolder.getNativeWindow(), -1, -1, 0 /* hints */);
- } else {
- if( null != frame ) {
- final InsetsImmutable nInsets = glWindow.getInsets();
- final java.awt.Insets aInsets = frame.getInsets();
- int dx, dy;
- if( nInsets.getTotalHeight()==0 ) {
- dx = aInsets.left;
- dy = aInsets.top;
- } else {
- dx = nInsets.getLeftWidth();
- dy = nInsets.getTopHeight();
- }
- final int topLevelX = frame.getX()+frame.getWidth()+dx;
- final int topLevelY = frame.getY()+dy;
- printlnState("[reparent pre - glWin to TOP.1]", topLevelX+"/"+topLevelY+" - insets " + nInsets + ", " + aInsets);
- glWindow.reparentWindow(null, topLevelX, topLevelY, 0 /* hint */);
- } else {
- printlnState("[reparent pre - glWin to TOP.0]");
- glWindow.reparentWindow(null, -1, -1, 0 /* hints */);
- }
- }
- printlnState("[reparent post]");
- glWindow.requestFocus();
- glWindow.setExclusiveContextThread(t);
- quitAdapterOn();
- } } );
- break;
- }
- }
- super.keyPressed(e);
- }
-
@Override
public void setTitle() {
setTitle(frame, winHolder.getNativeWindow(), glWindow);
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtJFXReparentingKeyAdapter.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtJFXReparentingKeyAdapter.java
index 253cbbce0..3ed847ae3 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtJFXReparentingKeyAdapter.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtJFXReparentingKeyAdapter.java
@@ -50,6 +50,7 @@ public class NewtJFXReparentingKeyAdapter extends NewtReparentingKeyAdapter {
this.frame = frame;
}
+ @Override
public void keyPressed(final KeyEvent e) {
if( e.isAutoRepeat() || e.isConsumed() ) {
return;
@@ -64,29 +65,14 @@ public class NewtJFXReparentingKeyAdapter extends NewtReparentingKeyAdapter {
public void run() {
final java.lang.Thread t = glWindow.setExclusiveContextThread(null);
if(glWindow.getParent()==null) {
- printlnState("[reparent pre - glWin to HOME]");
- glWindow.reparentWindow(winHolder.getNativeWindow(), -1, -1, 0 /* hints */);
+ printlnState("[reparent pre - glWin to HOME: child pos "+winHolder.getNativeWindow().getX()+"/"+winHolder.getNativeWindow().getY()+"]");
+ glWindow.reparentWindow(winHolder.getNativeWindow(), winHolder.getNativeWindow().getX(), winHolder.getNativeWindow().getY(), 0 /* hints */);
+ glWindow.setPosition(winHolder.getNativeWindow().getX(), winHolder.getNativeWindow().getY());
} else {
- if( null != frame ) {
- final InsetsImmutable nInsets = glWindow.getInsets();
- final InsetsImmutable aInsets;
- {
- final int aILeft = (int)frame.getScene().getX();
- final int aITop = (int)frame.getScene().getY();
- final int aIRight = (int)(frame.getWidth()-frame.getScene().getWidth())-aILeft;
- final int aIBottom = (int)(frame.getHeight()-frame.getScene().getHeight())-aITop;
- aInsets = new Insets(aILeft, aIRight, aITop, aIBottom);
- }
- final Bounds bL = frame.getScene().getRoot().getBoundsInLocal();
- final Bounds bs = frame.getScene().getRoot().localToScreen(bL);
- final int topLevelX = (int)bs.getMinX();
- final int topLevelY = (int)bs.getMinY();
- printlnState("[reparent pre - glWin to TOP.1]", topLevelX+"/"+topLevelY+" - insets " + nInsets + ", " + aInsets);
- glWindow.reparentWindow(null, topLevelX, topLevelY, 0 /* hint */);
- } else {
- printlnState("[reparent pre - glWin to TOP.0]");
- glWindow.reparentWindow(null, -1, -1, 0 /* hints */);
- }
+ final com.jogamp.nativewindow.util.Point p0 = winHolder.getNativeWindow().getLocationOnScreen(null);
+ final com.jogamp.nativewindow.util.Point p1 = glWindow.getLocationOnScreen(null);
+ printlnState("[reparent pre - glWin to TOP.1] frame ", p0+", glWindow "+p1);
+ glWindow.reparentWindow(null, p1.getX(), p1.getY(), 0 /* hint */);
}
printlnState("[reparent post]");
glWindow.requestFocus();
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtReparentingKeyAdapter.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtReparentingKeyAdapter.java
index 969e2adb0..339230d48 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtReparentingKeyAdapter.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtReparentingKeyAdapter.java
@@ -51,6 +51,7 @@ public class NewtReparentingKeyAdapter extends NEWTDemoListener {
this.winHolder = winHolder;
}
+ @Override
public void keyPressed(final KeyEvent e) {
if( e.isAutoRepeat() || e.isConsumed() ) {
return;
@@ -71,11 +72,13 @@ public class NewtReparentingKeyAdapter extends NEWTDemoListener {
public void run() {
final java.lang.Thread t = glWindow.setExclusiveContextThread(null);
if(glWindow.getParent()==null) {
- printlnState("[reparent pre - glWin to HOME]");
+ printlnState("[reparent pre - glWin to HOME: child pos "+winHolder.getNativeWindow().getX()+"/"+winHolder.getNativeWindow().getY()+"]");
glWindow.reparentWindow(winHolder.getNativeWindow(), -1, -1, 0 /* hints */);
} else {
- printlnState("[reparent pre - glWin to TOP.0]");
- glWindow.reparentWindow(null, -1, -1, 0 /* hints */);
+ final com.jogamp.nativewindow.util.Point p0 = winHolder.getNativeWindow().getLocationOnScreen(null);
+ final com.jogamp.nativewindow.util.Point p1 = glWindow.getLocationOnScreen(null);
+ printlnState("[reparent pre - glWin to TOP.1] frame ", p0+", glWindow "+p1);
+ glWindow.reparentWindow(null, p1.getX(), p1.getY(), 0 /* hint */);
}
printlnState("[reparent post]");
glWindow.requestFocus();