Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

NSWindow+UliZoomEffect now turns off 10.7's own simple zoom effects t…

…emporarily so they don't get in the way of its animations.
  • Loading branch information...
commit 2b4086d65b0f9bd121a3f92f27efa021a53f873f 1 parent 5f0e77b
@uliwitness authored
Showing with 54 additions and 0 deletions.
  1. +54 −0 NSWindow+ULIZoomEffect.m
View
54 NSWindow+ULIZoomEffect.m
@@ -28,6 +28,25 @@
#import "NSWindow+ULIZoomEffect.h"
+#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_6
+
+// On 10.6 and lower, these 10.7 methods/symbols aren't declared, so we declare
+// them here and call them conditionally when available:
+// Otherwise 10.7's built-in animations get in the way of ours, which are cooler
+// because they can come from a certain rectangle and thus convey information.
+
+typedef NSInteger NSWindowAnimationBehavior;
+
+@interface NSWindow (ULITenSevenAnimationBehaviour)
+
+-(void) setAnimationBehavior: (NSWindowAnimationBehavior)animBehaviour;
+-(NSWindowAnimationBehavior) animationBehavior;
+
+@end
+
+#endif
+
+
@interface ULIQuicklyAnimatingWindow : NSWindow
{
CGFloat mAnimationResizeTime;
@@ -151,6 +170,9 @@ -(NSWindow*) uli_animationWindowForZoomEffectWithImage: (NSImage*)snapshotImage
NSWindow * animationWindow = [[ULIQuicklyAnimatingWindow alloc] initWithContentRect: myFrame styleMask: NSBorderlessWindowMask backing: NSBackingStoreBuffered defer: NO];
[animationWindow setOpaque: NO];
+ if( [animationWindow respondsToSelector: @selector(setAnimationBehavior:)] )
+ [animationWindow setAnimationBehavior: NSWindowAnimationBehaviorNone];
+
NSImageView * imageView = [[NSImageView alloc] initWithFrame: NSMakeRect(0,0,myFrame.size.width,myFrame.size.height)];
[imageView setImageScaling: NSImageScaleAxesIndependently];
[imageView setImageFrameStyle: NSImageFrameNone];
@@ -170,6 +192,11 @@ -(NSWindow*) uli_animationWindowForZoomEffectWithImage: (NSImage*)snapshotImage
-(void) makeKeyAndOrderFrontWithPopEffect
{
+ BOOL haveAnimBehaviour = [NSWindow instancesRespondToSelector: @selector(animationBehavior)];
+ NSWindowAnimationBehavior oldAnimationBehaviour = haveAnimBehaviour ? [self animationBehavior] : 0;
+ if( haveAnimBehaviour )
+ [self setAnimationBehavior: NSWindowAnimationBehaviorNone];
+
NSImage * snapshotImage = [self uli_imageWithSnapshotForceActive: YES];
NSRect myFrame = [self frame];
NSRect poppedFrame = NSInsetRect(myFrame, -20, -20);
@@ -186,6 +213,9 @@ -(void) makeKeyAndOrderFrontWithPopEffect
[self makeKeyAndOrderFront: nil];
NSEnableScreenUpdates();
+
+ if( haveAnimBehaviour )
+ [self setAnimationBehavior: oldAnimationBehaviour];
}
@@ -194,6 +224,11 @@ -(void) makeKeyAndOrderFrontWithZoomEffectFromRect: (NSRect)globalStartPoint
if( globalStartPoint.size.width < 1 || globalStartPoint.size.height < 1 )
globalStartPoint = [self uli_startRectForScreen: [self screen]];
+ BOOL haveAnimBehaviour = [NSWindow instancesRespondToSelector: @selector(animationBehavior)];
+ NSWindowAnimationBehavior oldAnimationBehaviour = haveAnimBehaviour ? [self animationBehavior] : 0;
+ if( haveAnimBehaviour )
+ [self setAnimationBehavior: NSWindowAnimationBehaviorNone];
+
NSImage * snapshotImage = [self uli_imageWithSnapshotForceActive: YES];
NSRect myFrame = [self frame];
myFrame.size = snapshotImage.size;
@@ -207,6 +242,9 @@ -(void) makeKeyAndOrderFrontWithZoomEffectFromRect: (NSRect)globalStartPoint
[self makeKeyAndOrderFront: nil];
NSEnableScreenUpdates();
+
+ if( haveAnimBehaviour )
+ [self setAnimationBehavior: oldAnimationBehaviour];
}
@@ -215,6 +253,11 @@ -(void) orderFrontWithZoomEffectFromRect: (NSRect)globalStartPoint
if( globalStartPoint.size.width < 1 || globalStartPoint.size.height < 1 )
globalStartPoint = [self uli_startRectForScreen: [self screen]];
+ BOOL haveAnimBehaviour = [NSWindow instancesRespondToSelector: @selector(animationBehavior)];
+ NSWindowAnimationBehavior oldAnimationBehaviour = haveAnimBehaviour ? [self animationBehavior] : 0;
+ if( haveAnimBehaviour )
+ [self setAnimationBehavior: NSWindowAnimationBehaviorNone];
+
NSImage * snapshotImage = [self uli_imageWithSnapshotForceActive: NO];
NSRect myFrame = [self frame];
myFrame.size = snapshotImage.size;
@@ -228,6 +271,9 @@ -(void) orderFrontWithZoomEffectFromRect: (NSRect)globalStartPoint
[self orderFront: nil];
NSEnableScreenUpdates();
+
+ if( haveAnimBehaviour )
+ [self setAnimationBehavior: oldAnimationBehaviour];
}
@@ -236,6 +282,11 @@ -(void) orderOutWithZoomEffectToRect: (NSRect)globalEndPoint
if( globalEndPoint.size.width < 1 || globalEndPoint.size.height < 1 )
globalEndPoint = [self uli_startRectForScreen: [self screen]];
+ BOOL haveAnimBehaviour = [NSWindow instancesRespondToSelector: @selector(animationBehavior)];
+ NSWindowAnimationBehavior oldAnimationBehaviour = haveAnimBehaviour ? [self animationBehavior] : 0;
+ if( haveAnimBehaviour )
+ [self setAnimationBehavior: NSWindowAnimationBehaviorNone];
+
NSImage * snapshotImage = [self uli_imageWithSnapshotForceActive: NO];
NSRect myFrame = [self frame];
myFrame.size = snapshotImage.size;
@@ -250,6 +301,9 @@ -(void) orderOutWithZoomEffectToRect: (NSRect)globalEndPoint
[animationWindow setFrame: globalEndPoint display: YES animate: YES];
[animationWindow close];
+
+ if( haveAnimBehaviour )
+ [self setAnimationBehavior: oldAnimationBehaviour];
}
@end
Please sign in to comment.
Something went wrong with that request. Please try again.