animating a non-interpolated view property and totally confused
animating a non-interpolated view property and totally confused
- Subject: animating a non-interpolated view property and totally confused
- From: Nathan Vander Wilt <email@hidden>
- Date: Wed, 13 Feb 2008 20:07:43 -0600 (CST)
I'm trying to use Core/Cocoa Animation to coordinate
animating a property that my view must interpolate
itself. I want to animate whenever an enumeration
property gets changed, eg setTypeOfObject:kSquare when
it was a kCircle. So my view needs to know how far it
is between two enum values and figure out how to draw
something that is X% a kSquare and (1-X)% a kCircle on
its own.
My understanding is that in this case I need to
implement animationForKey: in my NSView subclass,
which must return an instance of CAAnimation. But it's
NSAnimation that has all the features I'm after, and
it's a subclass of NSObject that couldn't pose as a
CAAnimation. So I guess the CAAnimation would have my
view instance set as a delegate, and I'd need to make
my view's animationDidStart: delegate method start an
NSAnimation instance?
If that weren't convoluted enough, NSAnimation doesn't
use a delegate for something as basic as a progress
update. The Animation Programming Guide for Cocoa says
to subclass NSAnimation and override the
setCurrentProgress: method. Since my NSView instance
is the delegate anyway for the
animationShouldStart:/DidStop: methods, I implemented
this as:
-
(void)setCurrentProgress:(NSAnimationProgress)progress
{
[super setCurrentProgress:progress];
id delegate = [self delegate];
if ([delegate
respondsToSelector:@selector(animation:didProgressTo:)])
[delegate animation:self didProgressTo:progress];
}
However, to get the NSAnimation subclass to compile
without warnings, my NSView subclass needs to make its
animation:didProgressTo: method public. Even with the
delegate instead of an outlet shortcut, this is
getting very convoluted.
To top this all off, I still don't know where I would
look to get the property value I should be animating
"towards". When I've called [[myView animator]
setEnumerationValue:targetSetting], which object in
this soup can tell my view what targetSetting is?
Am I on the wrong track here? If I really have to
subclass NSAnimation, instantiate (and subclass??)
CAAnimation, and spaghetti everything together in a
bunch of view delegate methods just to get a steady
stream of progress values as a result of a property
change, I'd be better off sticking with my own
property accessors and an NSTimer.
thanks for any pointers,
-natevw
____________________________________________________________________________________
¡Capacidad ilimitada de almacenamiento en tu correo!
No te preocupes más por el espacio de tu cuenta con Correo Yahoo!:
http://correo.espanol.yahoo.com/
_______________________________________________
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