From 98ed02cdb7b325d8afde596a5ef04f97be2018d4 Mon Sep 17 00:00:00 2001
From: Sven Gothel
* Coverage is computed by:
* true
if given screen coordinates in screen/window units
+ * Returns true
if given screen coordinates in pixel units
* are contained by this {@link #getViewport() viewport}, otherwise false
.
+ * @param x x-coord in pixel units
+ * @param y y-coord in pixel units
*/
- public final boolean contains(int x, int y) {
+ public final boolean contains(final int x, final int y) {
return x >= viewport.getX() &&
x < viewport.getX() + viewport.getWidth() &&
y >= viewport.getY() &&
@@ -189,7 +191,8 @@ public abstract class MonitorDevice {
}
/**
- * Returns the coverage of given rectangle w/ this this {@link #getViewport() viewport}, i.e. between 0.0
and 1.0
.
+ * Returns the coverage of given rectangle in pixel units
+ * w/ this {@link #getViewport() viewport}, i.e. between 0.0
and 1.0
.
*
@@ -197,16 +200,17 @@ public abstract class MonitorDevice {
* coverage = area( isect ) / area( viewport ) ;
*
*
getMonitorMode().getSurfaceSize().getResolution()
* and getRotation()
*/
@@ -357,7 +357,7 @@ public class MonitorMode implements ComparablegetMonitorMode().getSurfaceSize().getResolution()
* and getRotation()
*/
diff --git a/src/newt/classes/com/jogamp/newt/Screen.java b/src/newt/classes/com/jogamp/newt/Screen.java
index 2a713c538..919b98b45 100644
--- a/src/newt/classes/com/jogamp/newt/Screen.java
+++ b/src/newt/classes/com/jogamp/newt/Screen.java
@@ -131,30 +131,41 @@ public abstract class Screen {
public abstract int getIndex();
/**
- * @return the x position of the virtual viewport's top-left origin in screen/window units.
+ * @return the x position of the virtual viewport's top-left origin in pixel units.
*/
public abstract int getX();
/**
- * @return the y position of the virtual viewport's top-left origin in screen/window units.
+ * @return the y position of the virtual viewport's top-left origin in pixel units.
*/
public abstract int getY();
/**
- * @return the rotated virtual viewport's width in screen/window units.
+ * @return the rotated virtual viewport's width in pixel units.
*/
public abstract int getWidth();
/**
- * @return the rotated virtual viewport's height in screen/window units.
+ * @return the rotated virtual viewport's height in pixel units.
*/
public abstract int getHeight();
/**
- * @return the rotated virtual viewport, i.e. origin and size in screen/window units.
+ * @return the rotated virtual viewport, i.e. origin and size in pixel units.
+ * @see #getViewportInWindowUnits(Window)
*/
public abstract RectangleImmutable getViewport();
+ /**
+ * Returns a newly created {@link Rectangle} containing the rotated virtual viewport
+ * in window units of the given {@link Window} instance.
+ * @return rotated viewport values, i.e. origin and size, in pixel units.
+ * @see #getViewport()
+ */
+ public final Rectangle getViewportInWindowUnits(final Window win) {
+ return win.convertToWindowUnits( (Rectangle) getViewport().cloneMutable() );
+ }
+
/**
* @return the associated Display
*/
@@ -181,14 +192,14 @@ public abstract class Screen {
public abstract List* If no coverage is detected the first {@link MonitorDevice} is returned. *
- * @param r arbitrary rectangle in screen/window units + * @param r arbitrary rectangle in pixel units */ - public final MonitorDevice getMainMonitor(RectangleImmutable r) { + public final MonitorDevice getMainMonitor(final RectangleImmutable r) { MonitorDevice res = null; float maxCoverage = Float.MIN_VALUE; final List
* Should be equal to {@link #getX()}, {@link #getY()}, {@link #getWidth()} and {@link #getHeight()},
* however, some native toolkits may choose a different virtual screen area.
diff --git a/src/newt/classes/com/jogamp/newt/Window.java b/src/newt/classes/com/jogamp/newt/Window.java
index b733406e8..872d67087 100644
--- a/src/newt/classes/com/jogamp/newt/Window.java
+++ b/src/newt/classes/com/jogamp/newt/Window.java
@@ -47,6 +47,7 @@ import javax.media.nativewindow.CapabilitiesImmutable;
import javax.media.nativewindow.NativeWindow;
import javax.media.nativewindow.WindowClosingProtocol;
import javax.media.nativewindow.util.Point;
+import javax.media.nativewindow.util.Rectangle;
import javax.media.nativewindow.util.RectangleImmutable;
/**
@@ -232,6 +233,18 @@ public interface Window extends NativeWindow, WindowClosingProtocol {
// Modes / States
//
+ /**
+ * 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 a newly created {@link Rectangle} containing the scaled window origin, {@link #getX()} & {@link #getY()},
+ * and size, {@link #getSurfaceWidth()} & {@link #getSurfaceHeight()}, in pixel units.
+ */
+ Rectangle getSurfaceBounds();
+
/**
* Sets the size of the window's client area in window units, excluding decorations.
*
@@ -329,19 +342,19 @@ public interface Window extends NativeWindow, WindowClosingProtocol {
/**
* Converts the given pixel units into window units in place.
- * @param pixelUnitsAndResult point storage holding the pixel units to convert
+ * @param pixelUnitsAndResult rectangle storage holding the pixel units to convert
* and the resulting conversion.
- * @return resulting point storage pixelUnitsAndResult for chaining holding the converted values
+ * @return resulting rectangle storage pixelUnitsAndResult for chaining holding the converted values
*/
- Point convertToWindowUnits(final Point pixelUnitsAndResult);
+ Rectangle convertToWindowUnits(final Rectangle pixelUnitsAndResult);
/**
* Converts the given window units into pixel units in place.
- * @param windowUnitsAndResult point storage holding the window units to convert
+ * @param windowUnitsAndResult rectangle storage holding the window units to convert
* and the resulting conversion.
- * @return resulting point storage windowUnitsAndResult for chaining holding the converted values
+ * @return resulting rectangle storage windowUnitsAndResult for chaining holding the converted values
*/
- Point convertToPixelUnits(final Point windowUnitsAndResult);
+ Rectangle convertToPixelUnits(final Rectangle windowUnitsAndResult);
void setUndecorated(boolean value);
diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
index 7ba4bddf0..ecd50aa5f 100644
--- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
+++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
@@ -47,6 +47,7 @@ import javax.media.nativewindow.NativeWindowException;
import javax.media.nativewindow.SurfaceUpdatedListener;
import javax.media.nativewindow.util.InsetsImmutable;
import javax.media.nativewindow.util.Point;
+import javax.media.nativewindow.util.Rectangle;
import javax.media.opengl.FPSCounter;
import javax.media.opengl.GL;
import javax.media.opengl.GL3;
@@ -363,33 +364,43 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind
}
@Override
- public final int[] convertToWindowUnits(final int[] pixelUnitsAndResult) {
- return window.convertToWindowUnits(pixelUnitsAndResult);
+ public final Rectangle getBounds() {
+ return window.getBounds();
}
@Override
- public final int[] convertToPixelUnits(final int[] windowUnitsAndResult) {
- return window.convertToPixelUnits(windowUnitsAndResult);
+ public final int getSurfaceWidth() {
+ return window.getSurfaceWidth();
+ }
+
+ @Override
+ public final int getSurfaceHeight() {
+ return window.getSurfaceHeight();
}
@Override
- public final Point convertToWindowUnits(final Point pixelUnitsAndResult) {
+ public final Rectangle getSurfaceBounds() {
+ return window.getSurfaceBounds();
+ }
+
+ @Override
+ public final int[] convertToWindowUnits(final int[] pixelUnitsAndResult) {
return window.convertToWindowUnits(pixelUnitsAndResult);
}
@Override
- public final Point convertToPixelUnits(final Point windowUnitsAndResult) {
+ public final int[] convertToPixelUnits(final int[] windowUnitsAndResult) {
return window.convertToPixelUnits(windowUnitsAndResult);
}
@Override
- public final int getSurfaceWidth() {
- return window.getSurfaceWidth();
+ public final Rectangle convertToWindowUnits(final Rectangle pixelUnitsAndResult) {
+ return window.convertToWindowUnits(pixelUnitsAndResult);
}
@Override
- public final int getSurfaceHeight() {
- return window.getSurfaceHeight();
+ public final Rectangle convertToPixelUnits(final Rectangle windowUnitsAndResult) {
+ return window.convertToPixelUnits(windowUnitsAndResult);
}
@Override
diff --git a/src/newt/classes/com/jogamp/newt/util/MonitorModeUtil.java b/src/newt/classes/com/jogamp/newt/util/MonitorModeUtil.java
index fdd7985fe..e019068f5 100644
--- a/src/newt/classes/com/jogamp/newt/util/MonitorModeUtil.java
+++ b/src/newt/classes/com/jogamp/newt/util/MonitorModeUtil.java
@@ -157,7 +157,7 @@ public class MonitorModeUtil {
/**
* @param monitorModes
- * @param resolution
+ * @param resolution in pixel units
* @return modes with nearest resolution, or matching ones. May return zero sized list for non.
*/
public static List