Re: Animating an Attached Window (was: Drawing Attention to a Control...)
Re: Animating an Attached Window (was: Drawing Attention to a Control...)
- Subject: Re: Animating an Attached Window (was: Drawing Attention to a Control...)
- From: Dave Keck <email@hidden>
- Date: Fri, 19 Feb 2010 13:52:34 -1000
> [[self window] setAnimations:[NSDictionary dictionaryWithObject:[self shakeAnimation:[[self window] frame]] forKey:@"frameOrigin"]];
> [[[self window] animator] setFrameOrigin:[[self window] frame].origin];
>
> /*
>
> shake animation
> http://www.cimgf.com/2008/02/27/core-animation-tutorial-window-shake-effect/
>
> */
> - (CAKeyframeAnimation *)shakeAnimation:(NSRect)frame
> {
> CAKeyframeAnimation *shakeAnimation = [CAKeyframeAnimation animation];
>
> CGMutablePathRef shakePath = CGPathCreateMutable();
> CGPathMoveToPoint(shakePath, NULL, NSMinX(frame), NSMinY(frame));
> int idx;
> for (idx = 0; idx < numberOfShakes; ++idx)
> {
> CGPathAddLineToPoint(shakePath, NULL, NSMinX(frame) - frame.size.width * vigourOfShake, NSMinY(frame));
> CGPathAddLineToPoint(shakePath, NULL, NSMinX(frame) + frame.size.width * vigourOfShake, NSMinY(frame));
> }
> CGPathCloseSubpath(shakePath);
> shakeAnimation.path = shakePath;
> shakeAnimation.duration = durationOfShake;
> return shakeAnimation;
> }
> - (CAKeyframeAnimation *)shakeAnimation:(NSRect)frame
> {
> CAKeyframeAnimation *shakeAnimation = [CAKeyframeAnimation animation];
>
> CGMutablePathRef shakePath = CGPathCreateMutable();
> CGPathMoveToPoint(shakePath, NULL, NSMinX(frame), NSMinY(frame));
> int idx;
> for (idx = 0; idx < numberOfShakes; ++idx)
> {
> CGPathAddLineToPoint(shakePath, NULL, NSMinX(frame) - frame.size.width * vigourOfShake, NSMinY(frame));
> CGPathAddLineToPoint(shakePath, NULL, NSMinX(frame) + frame.size.width * vigourOfShake, NSMinY(frame));
> }
> CGPathCloseSubpath(shakePath);
> shakeAnimation.path = shakePath;
> shakeAnimation.duration = durationOfShake;
> return shakeAnimation;
> }
Note that this code does not have any effect when compiled as 64-bit.
I don't remember all the details at the moment, but I believe the
issue is that the 'frameOrigin' property doesn't work under 64-bit. In
my own code I was forced to use the 'frame' property instead, which
changes the code a bit, but works for both 32- and 64-bit.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden