• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Animating an Attached Window (was: Drawing Attention to a Control...)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >Drawing Attention to a Control to aid user in Error Recovery (From: Jerry Krinock <email@hidden>)
 >Re: Drawing Attention to a Control to aid user in Error Recovery (From: "email@hidden" <email@hidden>)
 >Animating an Attached Window (was: Drawing Attention to a Control...) (From: Jerry Krinock <email@hidden>)
 >Re: Animating an Attached Window (was: Drawing Attention to a Control...) (From: "email@hidden" <email@hidden>)

  • Prev by Date: Re: How to detect if mouse on border of view
  • Next by Date: Core Animation: What is a "trigger key"?
  • Previous by thread: Re: Animating an Attached Window (was: Drawing Attention to a Control...)
  • Next by thread: cross-process file open notifications
  • Index(es):
    • Date
    • Thread