• 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: "email@hidden" <email@hidden>
  • Date: Thu, 18 Feb 2010 16:27:44 +0000

>
> Thanks, Jonathan.  Using Matt Gemmel's idea of making an attached window, I wrote a class that makes a fat arrow with a blue gradient that looks like the one you get when you click a menu item after searching in Help.
>
> Now, I'd like it to be animated, like Apple's fat blue Help arrow, moving slowly in a little circle.  In Matt's code, he moves the attached window by re-creating it.  I could do this brute force, offsetting the frame with x=cos(wt) and y=sin(wt).
>
> In the Core Animation Programming Guide > Animatable Properties, it says that 'position' can be animated, and this has the effect of animating the frame.  I've never used Core Animation.  Is Core Animation the tool for this job or should I use my brute force?

I shake an authentication window on failure using the following CA code.

NSWindowController subclass

// shake it
[[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;
}

Regards

Jonathan

>
> Thanks,
>
> Jerry Krinock
>
>
> _______________________________________________
>
> 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

_______________________________________________

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

  • Follow-Ups:
    • Re: Animating an Attached Window (was: Drawing Attention to a Control...)
      • From: Dave Keck <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>)

  • Prev by Date: Re: NSTableViewDataSource Protocol
  • Next by Date: Determine smallest height of vertical scrollbar
  • Previous by thread: Animating an Attached Window (was: Drawing Attention to a Control...)
  • Next by thread: Re: Animating an Attached Window (was: Drawing Attention to a Control...)
  • Index(es):
    • Date
    • Thread