41 CPArray _viewAnimations;
71 - (id)initWithViewAnimations:(CPArray)viewAnimations
81 - (void)startAnimation
83 var animationIndex = [_viewAnimations count];
84 while (animationIndex--)
86 var dictionary = [_viewAnimations objectAtIndex:animationIndex],
87 view = [
self _targetView:dictionary],
88 startFrame = [
self _startFrame:dictionary];
90 [view setFrame:startFrame];
92 var effect = [
self _effect:dictionary];
95 [view setAlphaValue:0.0];
96 [
self _targetView:view setHidden:NO];
99 [view setAlphaValue:1.0];
105 - (void)setCurrentProgress:(
float)progress
109 var animationIndex = [_viewAnimations count];
110 while (animationIndex--)
112 var dictionary = [_viewAnimations objectAtIndex:animationIndex],
113 view = [
self _targetView:dictionary],
114 startFrame = [
self _startFrame:dictionary],
115 endFrame = [
self _endFrame:dictionary],
116 differenceFrame = CGRectMakeZero(),
119 differenceFrame.origin.x = endFrame.origin.x - startFrame.origin.x;
120 differenceFrame.origin.y = endFrame.origin.y - startFrame.origin.y;
121 differenceFrame.size.width = endFrame.size.width - startFrame.size.width;
122 differenceFrame.size.height = endFrame.size.height - startFrame.size.height;
124 var intermediateFrame = CGRectMakeZero();
125 intermediateFrame.origin.x = startFrame.origin.x + differenceFrame.origin.x * value;
126 intermediateFrame.origin.y = startFrame.origin.y + differenceFrame.origin.y * value;
127 intermediateFrame.size.width = startFrame.size.width + differenceFrame.size.width * value;
128 intermediateFrame.size.height = startFrame.size.height + differenceFrame.size.height * value;
130 [view setFrame:intermediateFrame];
133 var effect = [
self _effect:dictionary];
135 [view setAlphaValue:1.0 * value];
137 [view setAlphaValue:1.0 + ( 0.0 - 1.0 ) * value];
139 if (progress === 1.0)
140 [
self _targetView:view setHidden:CGRectIsEmpty(endFrame) || [view alphaValue] === 0.0];
144 - (void)stopAnimation
146 var animationIndex = [_viewAnimations count];
147 while (animationIndex--)
149 var dictionary = [_viewAnimations objectAtIndex:animationIndex],
150 view = [
self _targetView:dictionary],
151 endFrame = [
self _endFrame:dictionary];
153 [view setFrame:endFrame];
155 var effect = [
self _effect:dictionary];
157 [view setAlphaValue:1.0];
159 [view setAlphaValue:0.0];
161 [
self _targetView:view setHidden:CGRectIsEmpty(endFrame) || [view alphaValue] === 0.0];
167 - (void)_targetView:(
id)theView setHidden:(BOOL)isHidden
169 if ([theView isKindOfClass:[
CPWindow class]])
172 [theView orderOut:self];
174 [theView orderFront:self];
177 [theView setHidden:isHidden];
182 var targetView = [dictionary
valueForKey:CPViewAnimationTargetKey];
191 var startFrame = [dictionary
valueForKey:CPViewAnimationStartFrameKey];
193 return [[
self _targetView:dictionary] frame];
200 var endFrame = [dictionary
valueForKey:CPViewAnimationEndFrameKey];
202 return [[
self _targetView:dictionary] frame];
209 return [dictionary
valueForKey:CPViewAnimationEffectKey];
212 - (CPArray)viewAnimations
214 return _viewAnimations;
222 - (void)setViewAnimations:(CPArray)viewAnimations
224 if (viewAnimations != _viewAnimations)
Used to implement exception handling (creating & raising).
CPViewAnimationStartFrameKey
CPViewAnimationFadeInEffect
CPViewAnimationFadeOutEffect
CPViewAnimationEndFrameKey
void raise:reason:(CPString aName, [reason] CPString aReason)
A mutable key-value pair collection.
void setViewAnimations:(CPArray viewAnimations)
An immutable string (collection of characters).
id valueForKey:(CPString aKey)
void setCurrentProgress:(float aProgress)
id stringWithFormat:(CPString format, [,] ...)