aboutsummaryrefslogtreecommitdiffstats
path: root/src/nativewindow/classes/com
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-03-14 11:26:10 +0100
committerSven Gothel <[email protected]>2013-03-14 11:26:10 +0100
commitdd705f1eb14b87b207e375ea0d71e00155a9933f (patch)
tree131c131ea2fff2298e2306326ceced93f578ae06 /src/nativewindow/classes/com
parent896e8b021b39e9415040a57a1d540d7d24b02db1 (diff)
OSX/CALayer: Simplify FixCALayerLayout()/layoutSurfaceLayer() call, no more need for explicit call
- OffscreenLayerSurface.layoutSurfaceLayer() removed, no more required - JAWTWindow adds a ComponentListener, which issues FixCALayerLayout() at resized, moved and shown. - MyNSOpenGLLayer no more requires fix*Size() methods - MyNSOpenGLLayer::setDedicatedSize() need no explicit CATransaction, performed by caller.
Diffstat (limited to 'src/nativewindow/classes/com')
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java46
1 files changed, 39 insertions, 7 deletions
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java
index 99b629d1a..3e5e629b6 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java
@@ -43,6 +43,8 @@ import com.jogamp.nativewindow.MutableGraphicsConfiguration;
import java.awt.Component;
import java.awt.Container;
+import java.awt.event.ComponentEvent;
+import java.awt.event.ComponentListener;
import java.applet.Applet;
import javax.media.nativewindow.AbstractGraphicsConfiguration;
import javax.media.nativewindow.AbstractGraphicsDevice;
@@ -110,6 +112,25 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
this.component = windowObject;
this.isApplet = false;
this.offscreenSurfaceLayer = 0;
+ this.component.addComponentListener(new ComponentListener() {
+ @Override
+ public void componentResized(ComponentEvent e) {
+ layoutSurfaceLayerIfEnabled();
+ }
+
+ @Override
+ public void componentMoved(ComponentEvent e) {
+ layoutSurfaceLayerIfEnabled();
+ }
+
+ @Override
+ public void componentShown(ComponentEvent e) {
+ layoutSurfaceLayerIfEnabled();
+ }
+
+ @Override
+ public void componentHidden(ComponentEvent e) { }
+ });
}
protected synchronized void invalidate() {
@@ -215,16 +236,27 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
}
protected abstract void attachSurfaceLayerImpl(final long layerHandle);
- @Override
- public void layoutSurfaceLayer() throws NativeWindowException {
- if( !isOffscreenLayerSurfaceEnabled() ) {
- throw new NativeWindowException("Not an offscreen layer surface");
- }
- if( 0 != offscreenSurfaceLayer) {
+ /**
+ * Layout the offscreen layer according to the implementing class's constraints.
+ * <p>
+ * This method allows triggering a re-layout of the offscreen surface
+ * in case the implementation requires it.
+ * </p>
+ * <p>
+ * Call this method if any parent or ancestor's layout has been changed,
+ * which could affects the layout of this surface.
+ * </p>
+ * @see #isOffscreenLayerSurfaceEnabled()
+ * @throws NativeWindowException if {@link #isOffscreenLayerSurfaceEnabled()} == false
+ */
+ protected void layoutSurfaceLayerImpl() {}
+
+ private final void layoutSurfaceLayerIfEnabled() throws NativeWindowException {
+ if( isOffscreenLayerSurfaceEnabled() && 0 != offscreenSurfaceLayer ) {
layoutSurfaceLayerImpl();
}
}
- protected void layoutSurfaceLayerImpl() {}
+
@Override
public final void detachSurfaceLayer() throws NativeWindowException {