1.1 --- a/Source/GGBLayer.m Tue Mar 11 17:09:50 2008 -0700
1.2 +++ b/Source/GGBLayer.m Sun Mar 16 15:06:47 2008 -0700
1.3 @@ -30,6 +30,43 @@
1.4 }
1.5
1.6
1.7 +/*
1.8 +- (void)addAnimation:(CAAnimation *)anim forKey:(NSString *)key
1.9 +{
1.10 + NSLog(@"%@[%p] addAnimation: %p forKey: %@",[self class],self,anim,key);
1.11 + [super addAnimation: anim forKey: key];
1.12 +}
1.13 +*/
1.14 +
1.15 +
1.16 +- (void) animateAndBlock: (NSString*)keyPath from: (id)from to: (id)to duration: (NSTimeInterval)duration
1.17 +{
1.18 + //WARNING: This code works, but is a mess. I hope to find a better way to do this. --Jens 3/16/08
1.19 + CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath: keyPath];
1.20 + anim.duration= duration;
1.21 + anim.fromValue = from;
1.22 + anim.toValue = to;
1.23 + anim.isRemovedOnCompletion = YES;
1.24 + anim.delegate = self;
1.25 + [self addAnimation:anim forKey: @"animateAndBlock:"];
1.26 + _curAnimation = (id)[self animationForKey: @"animateAndBlock:"];
1.27 + [self setValue: to forKeyPath: keyPath]; // animation doesn't update the property value
1.28 +
1.29 + // Now wait for it to finish:
1.30 + while( _curAnimation ) {
1.31 + [[NSRunLoop currentRunLoop] runMode: NSDefaultRunLoopMode//NSEventTrackingRunLoopMode
1.32 + beforeDate: [NSDate dateWithTimeIntervalSinceNow: 0.1]];
1.33 + }
1.34 +}
1.35 +
1.36 +- (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag
1.37 +{
1.38 + if( anim==_curAnimation ) {
1.39 + _curAnimation = nil;
1.40 + }
1.41 +}
1.42 +
1.43 +
1.44 #if TARGET_OS_ASPEN
1.45
1.46 #pragma mark -