diff options
Diffstat (limited to 'src/newt/classes')
5 files changed, 58 insertions, 33 deletions
diff --git a/src/newt/classes/com/jogamp/newt/Window.java b/src/newt/classes/com/jogamp/newt/Window.java index 607ed285c..5134708c4 100644 --- a/src/newt/classes/com/jogamp/newt/Window.java +++ b/src/newt/classes/com/jogamp/newt/Window.java @@ -625,12 +625,6 @@ public interface Window extends NativeWindow, WindowClosingProtocol, ScalableSur // /** - * Returns a newly created {@link Rectangle} containing window origin, {@link #getX()} & {@link #getY()}, - * and size, {@link #getWidth()} & {@link #getHeight()}, in window units. - */ - Rectangle getBounds(); - - /** * Returns the <i>pixels per millimeter</i> of this window's {@link NativeSurface} * according to the {@link #getMainMonitor() main monitor}'s <i>current</i> {@link MonitorMode mode}'s * {@link SurfaceSize#getResolution() surface resolution}. diff --git a/src/newt/classes/com/jogamp/newt/javafx/NewtCanvasJFX.java b/src/newt/classes/com/jogamp/newt/javafx/NewtCanvasJFX.java index ae46e2922..288516deb 100644 --- a/src/newt/classes/com/jogamp/newt/javafx/NewtCanvasJFX.java +++ b/src/newt/classes/com/jogamp/newt/javafx/NewtCanvasJFX.java @@ -574,6 +574,16 @@ public class NewtCanvasJFX extends Canvas implements NativeWindowHolder, WindowC } @Override + public int getX() { + return NewtCanvasJFX.this.clientArea.getX(); // FIXME: Use 'scale' or an actual window-width + } + + @Override + public int getY() { + return NewtCanvasJFX.this.clientArea.getY(); // FIXME: Use 'scale' or an actual window-width + } + + @Override public int getWidth() { return getSurfaceWidth(); // FIXME: Use 'scale' or an actual window-width } @@ -584,6 +594,17 @@ public class NewtCanvasJFX extends Canvas implements NativeWindowHolder, WindowC } @Override + public final Rectangle getBounds() { + return new Rectangle(getX(), getY(), getWidth(), getHeight()); + } + + @Override + public final Rectangle getSurfaceBounds() { + return new Rectangle(getX(), getY(), // FIXME: 'scale' window -> pixel size + getSurfaceWidth(), getSurfaceHeight()); + } + + @Override public final int[] convertToWindowUnits(final int[] pixelUnitsAndResult) { return pixelUnitsAndResult; // FIXME HiDPI: use 'pixelScale' } @@ -643,16 +664,6 @@ public class NewtCanvasJFX extends Canvas implements NativeWindowHolder, WindowC } @Override - public int getX() { - return NewtCanvasJFX.this.clientArea.getX(); - } - - @Override - public int getY() { - return NewtCanvasJFX.this.clientArea.getY(); - } - - @Override public Point getLocationOnScreen(final Point point) { final Point los = NativeWindowFactory.getLocationOnScreen(this); // client window location on screen if(null!=point) { diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index c7e1c0a45..6b102ea68 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -467,6 +467,11 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind } @Override + public final Rectangle getSurfaceBounds() { + return window.getSurfaceBounds(); + } + + @Override public final int[] convertToWindowUnits(final int[] pixelUnitsAndResult) { return window.convertToWindowUnits(pixelUnitsAndResult); } diff --git a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java index fd9709331..b545a2e77 100644 --- a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java +++ b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java @@ -54,7 +54,6 @@ import jogamp.newt.swt.SWTEDTUtil; import org.eclipse.swt.SWT; import org.eclipse.swt.SWTException; import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.Canvas; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Event; @@ -80,7 +79,7 @@ public class NewtCanvasSWT extends Canvas implements NativeWindowHolder, WindowC private WindowClosingMode newtChildClosingMode = WindowClosingMode.DISPOSE_ON_CLOSE; private final WindowClosingMode closingMode = WindowClosingMode.DISPOSE_ON_CLOSE; - private volatile Rectangle clientAreaPixels, clientAreaWindow; + private volatile org.eclipse.swt.graphics.Rectangle clientAreaPixels, clientAreaWindow; /** pixelScale = pixelUnit / windowUnix */ private volatile float[] pixelScale = new float[] { 1f, 1f }; @@ -197,7 +196,7 @@ public class NewtCanvasSWT extends Canvas implements NativeWindowHolder, WindowC * </p> * @param r containing desired size */ - private final void setNewtChildSize(final Rectangle r) { + private final void setNewtChildSize(final org.eclipse.swt.graphics.Rectangle r) { if( !SWTAccessor.isOSX ) { final Point p = SWTAccessor.deviceZoomScaleUp(new Point(r.width, r.height)); newtChild.setSize(p.getX(), p.getY()); @@ -344,7 +343,7 @@ public class NewtCanvasSWT extends Canvas implements NativeWindowHolder, WindowC return true; // already valid } updatePosSizeCheck(); - final Rectangle nClientAreaWindow = clientAreaWindow; + final org.eclipse.swt.graphics.Rectangle nClientAreaWindow = clientAreaWindow; if(0 >= nClientAreaWindow.width || 0 >= nClientAreaWindow.height) { return false; } @@ -378,9 +377,9 @@ public class NewtCanvasSWT extends Canvas implements NativeWindowHolder, WindowC } protected final void updatePosSizeCheck() { - final Rectangle oClientAreaWindow = clientAreaWindow; - final Rectangle nClientAreaPixels = SWTAccessor.getClientAreaInPixels(this); - final Rectangle nClientAreaWindow = getClientArea(); + final org.eclipse.swt.graphics.Rectangle oClientAreaWindow = clientAreaWindow; + final org.eclipse.swt.graphics.Rectangle nClientAreaPixels = SWTAccessor.getClientAreaInPixels(this); + final org.eclipse.swt.graphics.Rectangle nClientAreaWindow = getClientArea(); final boolean sizeChanged, posChanged; { sizeChanged = nClientAreaWindow.width != oClientAreaWindow.width || nClientAreaWindow.height != oClientAreaWindow.height; @@ -689,6 +688,16 @@ public class NewtCanvasSWT extends Canvas implements NativeWindowHolder, WindowC } @Override + public int getX() { + return 0; + } + + @Override + public int getY() { + return 0; + } + + @Override public int getWidth() { return newtScaleUp(clientAreaWindow.width, clientAreaWindow.width); } @@ -699,6 +708,17 @@ public class NewtCanvasSWT extends Canvas implements NativeWindowHolder, WindowC } @Override + public final com.jogamp.nativewindow.util.Rectangle getBounds() { + return new com.jogamp.nativewindow.util.Rectangle(getX(), getY(), getWidth(), getHeight()); + } + + @Override + public final com.jogamp.nativewindow.util.Rectangle getSurfaceBounds() { + return new com.jogamp.nativewindow.util.Rectangle(getX(), getY(), + getSurfaceWidth(), getSurfaceHeight()); + } + + @Override public final int[] convertToWindowUnits(final int[] pixelUnitsAndResult) { pixelUnitsAndResult[0] /= pixelScale[0]; pixelUnitsAndResult[1] /= pixelScale[1]; @@ -762,16 +782,6 @@ public class NewtCanvasSWT extends Canvas implements NativeWindowHolder, WindowC } @Override - public int getX() { - return 0; - } - - @Override - public int getY() { - return 0; - } - - @Override public Point getLocationOnScreen(final Point point) { final Point los = NativeWindowFactory.getLocationOnScreen(this); // client window location on screen if(null!=point) { diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 8567be5cc..67f1e863b 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -2621,6 +2621,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @Override + public final Rectangle getSurfaceBounds() { + return new Rectangle(pixelPos[0], pixelPos[1], pixelSize[0], pixelSize[1]); + } + + @Override public final int[] convertToWindowUnits(final int[] pixelUnitsAndResult) { return SurfaceScaleUtils.scaleInv(pixelUnitsAndResult, pixelUnitsAndResult, hasPixelScale); } |