Hide previous pop-out animations when showing a new one

This commit is contained in:
Jacob Bandes-Storch
2016-09-12 23:50:46 -07:00
parent 590fd5b71b
commit d6652ff4e8
3 changed files with 15 additions and 3 deletions

View File

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

View File

@@ -28,10 +28,19 @@ static double const kFadeFinishTime = 0.70;
- (void)startAnimation:(id)sender;
@end
void OakShowPopOutAnimation (NSRect popOutRect, NSImage* anImage)
void OakShowPopOutAnimation (NSRect popOutRect, NSImage* anImage, BOOL hidePrevious)
{
if(popOutRect.size.width == 0 || popOutRect.size.height == 0)
return;
static NSMutableSet<NSWindow*>* previousWindows = [NSMutableSet set];
if(hidePrevious)
{
for(NSWindow* window in previousWindows)
[window close];
[previousWindows removeAllObjects];
}
popOutRect = NSInsetRect(popOutRect, -kExtendWidth, -kExtendHeight);
NSRect windowRect = popOutRect;
@@ -58,6 +67,7 @@ void OakShowPopOutAnimation (NSRect popOutRect, NSImage* anImage)
[window setFrame:[window frameRectForContentRect:windowRect] display:YES];
[window orderFront:nil];
[previousWindows addObject:window];
[aView startAnimation:nil];
}

View File

@@ -790,12 +790,14 @@ static std::string shell_quote (std::vector<std::string> paths)
documentView->remove_enclosing_folds(range.min().index, range.max().index);
[self ensureSelectionIsInVisibleArea:self];
BOOL firstRange = YES;
for(auto const& range : ranges)
{
NSRect imageRect;
NSImage* image = [self imageForRanges:range imageRect:&imageRect];
imageRect = [[self window] convertRectToScreen:[self convertRect:imageRect toView:nil]];
OakShowPopOutAnimation(imageRect, image);
OakShowPopOutAnimation(imageRect, image, firstRange);
firstRange = NO;
}
}