| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // This file contains the Mac implementation the download animation, displayed | 5 // This file contains the Mac implementation the download animation, displayed |
| 6 // at the start of a download. The animation produces an arrow pointing | 6 // at the start of a download. The animation produces an arrow pointing |
| 7 // downwards and animates towards the bottom of the window where the new | 7 // downwards and animates towards the bottom of the window where the new |
| 8 // download appears in the download shelf. | 8 // download appears in the download shelf. |
| 9 | 9 |
| 10 #include "chrome/browser/download/download_started_animation.h" | 10 #include "chrome/browser/download/download_started_animation.h" |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]; | 159 [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]; |
| 160 | 160 |
| 161 // Positional animation. | 161 // Positional animation. |
| 162 CABasicAnimation* positionAnimation = | 162 CABasicAnimation* positionAnimation = |
| 163 [CABasicAnimation animationWithKeyPath:@"position"]; | 163 [CABasicAnimation animationWithKeyPath:@"position"]; |
| 164 CGFloat animationHeight = MIN(bounds.height(), 3 * imageHeight); | 164 CGFloat animationHeight = MIN(bounds.height(), 3 * imageHeight); |
| 165 NSPoint start = NSMakePoint(0, animationHeight); | 165 NSPoint start = NSMakePoint(0, animationHeight); |
| 166 NSPoint stop = NSMakePoint(0, imageHeight); | 166 NSPoint stop = NSMakePoint(0, imageHeight); |
| 167 [positionAnimation setFromValue:[NSValue valueWithPoint:start]]; | 167 [positionAnimation setFromValue:[NSValue valueWithPoint:start]]; |
| 168 [positionAnimation setToValue:[NSValue valueWithPoint:stop]]; | 168 [positionAnimation setToValue:[NSValue valueWithPoint:stop]]; |
| 169 [positionAnimation gtm_setDuration:0.6]; | 169 [positionAnimation gtm_setDuration:0.6 |
| 170 eventMask:NSLeftMouseDownMask]; |
| 170 [positionAnimation setTimingFunction:mediaFunction]; | 171 [positionAnimation setTimingFunction:mediaFunction]; |
| 171 | 172 |
| 172 // Opacity animation. | 173 // Opacity animation. |
| 173 CABasicAnimation* opacityAnimation = | 174 CABasicAnimation* opacityAnimation = |
| 174 [CABasicAnimation animationWithKeyPath:@"opacity"]; | 175 [CABasicAnimation animationWithKeyPath:@"opacity"]; |
| 175 [opacityAnimation setFromValue:[NSNumber numberWithFloat:1.0]]; | 176 [opacityAnimation setFromValue:[NSNumber numberWithFloat:1.0]]; |
| 176 [opacityAnimation setToValue:[NSNumber numberWithFloat:0.4]]; | 177 [opacityAnimation setToValue:[NSNumber numberWithFloat:0.4]]; |
| 177 [opacityAnimation gtm_setDuration:0.6]; | 178 [opacityAnimation gtm_setDuration:0.6 |
| 179 eventMask:NSLeftMouseDownMask]; |
| 178 [opacityAnimation setTimingFunction:mediaFunction]; | 180 [opacityAnimation setTimingFunction:mediaFunction]; |
| 179 | 181 |
| 180 // Group the animations together. | 182 // Group the animations together. |
| 181 CAAnimationGroup* animationGroup = [CAAnimationGroup animation]; | 183 CAAnimationGroup* animationGroup = [CAAnimationGroup animation]; |
| 182 NSArray* animations = | 184 NSArray* animations = |
| 183 [NSArray arrayWithObjects:positionAnimation, opacityAnimation, nil]; | 185 [NSArray arrayWithObjects:positionAnimation, opacityAnimation, nil]; |
| 184 [animationGroup setAnimations:animations]; | 186 [animationGroup setAnimations:animations]; |
| 185 | 187 |
| 186 // Set self as delegate so self receives -animationDidStop:finished:; | 188 // Set self as delegate so self receives -animationDidStop:finished:; |
| 187 [animationGroup setDelegate:self]; | 189 [animationGroup setDelegate:self]; |
| 188 [animationGroup setTimingFunction:mediaFunction]; | 190 [animationGroup setTimingFunction:mediaFunction]; |
| 189 [animationGroup gtm_setDuration:0.6]; | 191 [animationGroup gtm_setDuration:0.6 |
| 192 eventMask:NSLeftMouseDownMask]; |
| 190 [layer addAnimation:animationGroup forKey:@"downloadOpacityAndPosition"]; | 193 [layer addAnimation:animationGroup forKey:@"downloadOpacityAndPosition"]; |
| 191 | 194 |
| 192 observer_.reset(new DownloadAnimationTabObserver(self, tabContents)); | 195 observer_.reset(new DownloadAnimationTabObserver(self, tabContents)); |
| 193 } | 196 } |
| 194 return self; | 197 return self; |
| 195 } | 198 } |
| 196 | 199 |
| 197 - (void)dealloc { | 200 - (void)dealloc { |
| 198 [[NSNotificationCenter defaultCenter] removeObserver:self]; | 201 [[NSNotificationCenter defaultCenter] removeObserver:self]; |
| 199 [super dealloc]; | 202 [super dealloc]; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 226 } | 229 } |
| 227 | 230 |
| 228 @end | 231 @end |
| 229 | 232 |
| 230 void DownloadStartedAnimation::Show(TabContents* tab_contents) { | 233 void DownloadStartedAnimation::Show(TabContents* tab_contents) { |
| 231 DCHECK(tab_contents); | 234 DCHECK(tab_contents); |
| 232 | 235 |
| 233 // Will be deleted when the animation is complete. | 236 // Will be deleted when the animation is complete. |
| 234 [DownloadStartedAnimationMac startAnimationWithTabContents:tab_contents]; | 237 [DownloadStartedAnimationMac startAnimationWithTabContents:tab_contents]; |
| 235 } | 238 } |
| OLD | NEW |