Make OakPopOutAnimation window a child of the main window

This commit is contained in:
Jacob Bandes-Storch
2016-09-21 20:18:17 -07:00
parent 7713496749
commit f36ce366f4
4 changed files with 20 additions and 6 deletions

View File

@@ -1,3 +1,3 @@
#include <oak/misc.h>
PUBLIC void OakShowPopOutAnimation (NSRect aRect, NSImage* image, BOOL hidePrevious = YES);
PUBLIC void OakShowPopOutAnimation (NSView* parentView, NSRect aRect, NSImage* image, BOOL hidePrevious = YES);

View File

@@ -28,7 +28,7 @@ static double const kFadeFinishTime = 0.70;
- (void)startAnimation:(id)sender;
@end
void OakShowPopOutAnimation (NSRect popOutRect, NSImage* anImage, BOOL hidePrevious)
void OakShowPopOutAnimation (NSView* parentView, NSRect popOutRect, NSImage* anImage, BOOL hidePrevious)
{
if(popOutRect.size.width == 0 || popOutRect.size.height == 0)
return;
@@ -57,7 +57,6 @@ void OakShowPopOutAnimation (NSRect popOutRect, NSImage* anImage, BOOL hidePrevi
[window setBackgroundColor:[NSColor clearColor]];
[window setExcludedFromWindowsMenu:YES];
[window setIgnoresMouseEvents:YES];
[window setLevel:NSStatusWindowLevel];
[window setOpaque:NO];
[[window contentView] setWantsLayer:YES];
@@ -72,7 +71,11 @@ void OakShowPopOutAnimation (NSRect popOutRect, NSImage* anImage, BOOL hidePrevi
aView.contentImage = anImage;
[[window contentView] addSubview:aView];
if(NSScrollView* scrollView = parentView.enclosingScrollView)
[[NSNotificationCenter defaultCenter] addObserver:aView selector:@selector(parentViewBoundsDidChange:) name:NSViewBoundsDidChangeNotification object:scrollView.contentView];
[window setFrame:[window frameRectForContentRect:windowRect] display:YES];
[parentView.window addChildWindow:window ordered:NSWindowAbove];
[window orderFront:nil];
[previousViews addObject:aView];
@@ -161,4 +164,15 @@ void OakShowPopOutAnimation (NSRect popOutRect, NSImage* anImage, BOOL hidePrevi
[shapeLayer removeAllAnimations]; // Releases the animation which holds a strong reference to its delegate (us)
[[self window] close];
}
- (void)parentViewBoundsDidChange:(NSNotification*)notification
{
[shapeLayer removeAllAnimations]; // Releases the animation which holds a strong reference to its delegate (us)
[[self window] close];
}
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
@end

View File

@@ -18,7 +18,7 @@
- (void)mouseDown:(NSEvent*)anEvent
{
NSRect p = [[self window] convertRectToScreen:(NSRect){ [anEvent locationInWindow], NSMakeSize(48, 48) }];
OakShowPopOutAnimation(p, [NSImage imageNamed:NSImageNameComputer]);
OakShowPopOutAnimation(nil, p, [NSImage imageNamed:NSImageNameComputer]);
}
@end

View File

@@ -610,7 +610,7 @@ struct refresh_helper_t
NSRect imageRect;
NSImage* image = [_self imageForRanges:range imageRect:&imageRect];
imageRect = [[_self window] convertRectToScreen:[_self convertRect:imageRect toView:nil]];
OakShowPopOutAnimation(imageRect, image);
OakShowPopOutAnimation(_self, imageRect, image);
}
}
@@ -790,7 +790,7 @@ static std::string shell_quote (std::vector<std::string> paths)
NSRect imageRect;
NSImage* image = [self imageForRanges:range imageRect:&imageRect];
imageRect = [[self window] convertRectToScreen:[self convertRect:imageRect toView:nil]];
OakShowPopOutAnimation(imageRect, image, firstRange);
OakShowPopOutAnimation(self, imageRect, image, firstRange);
firstRange = NO;
}
}