diff options
author | Sven Gothel <[email protected]> | 2013-10-06 02:28:14 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2013-10-06 02:28:14 +0200 |
commit | ff86d8398ce66abddff4cbada8eabd1314a11d7b (patch) | |
tree | 12c1b11a85750caef762abefc60c02fae1623679 /src | |
parent | ae103ba597464ca25071950af7afe012e2b86c13 (diff) |
Bug 729: OSX CALayer invisible needs to have opacity 0 to not show hidden component.
Completes commit 3b02a219b1b9e446e87df1beb7da4266f74824fa
See unit test: TestBug816OSXCALayerPos03AWT
Diffstat (limited to 'src')
-rw-r--r-- | src/nativewindow/native/macosx/OSXmisc.m | 13 | ||||
-rw-r--r-- | src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03AWT.java | 5 |
2 files changed, 12 insertions, 6 deletions
diff --git a/src/nativewindow/native/macosx/OSXmisc.m b/src/nativewindow/native/macosx/OSXmisc.m index 889e1efd3..3b19440d7 100644 --- a/src/nativewindow/native/macosx/OSXmisc.m +++ b/src/nativewindow/native/macosx/OSXmisc.m @@ -336,6 +336,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetNSWindow0 @private BOOL fixedFrameSet; CGRect fixedFrame; + float visibleOpacity; } - (id)init; #ifdef DBG_LIFECYCLE @@ -358,6 +359,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetNSWindow0 MyCALayer * o = [super init]; o->fixedFrameSet = 0; o->fixedFrame = CGRectMake(0, 0, 0, 0); + o->visibleOpacity = 1.0; DBG_PRINT("MyCALayer::init.X: new %p\n", o); return o; } @@ -457,16 +459,17 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetNSWindow0 CGRect superFrame = [superLayer frame]; CGRect lFrame = [self frame]; if( visible ) { - // Setting opacity should not be required, otherwise we should save the opacity value. - // [subLayer setOpacity: 1.0]; - // [self setOpacity: 1.0]; + // Opacity must be 0 to see through the disabled CALayer + [subLayer setOpacity: visibleOpacity]; + [self setOpacity: visibleOpacity]; [self setHidden: NO]; [subLayer setHidden: NO]; } else { [subLayer setHidden: YES]; [self setHidden: YES]; - // [subLayer setOpacity: 0.0]; - // [self setOpacity: 0.0]; + visibleOpacity = [self opacity]; + [subLayer setOpacity: 0.0]; + [self setOpacity: 0.0]; } int posQuirk = 0 != ( NW_DEDICATEDFRAME_QUIRK_POSITION & caLayerQuirks ) && ( lFrame.origin.x!=0 || lFrame.origin.y!=0 ); int sizeQuirk = 0 != ( NW_DEDICATEDFRAME_QUIRK_SIZE & caLayerQuirks ) && ( lFrame.size.width!=width || lFrame.size.height!=height ); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03AWT.java index 6589cac1e..92d24e417 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03AWT.java @@ -86,7 +86,10 @@ public class TestBug816OSXCALayerPos03AWT extends UITestCase { checkbox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent ev) { glCanvas1.setVisible(checkbox.getState()); - System.out.println(glCanvas1.isVisible()); + System.out.println("Canvas visible: "+glCanvas1.isVisible()); + if( glCanvas1.isVisible() ) { + frame.validate(); // take care of resized frame while hidden + } } }); |