Chromium Code Reviews| Index: chrome/browser/ui/cocoa/download/download_item_cell.mm |
| diff --git a/chrome/browser/ui/cocoa/download/download_item_cell.mm b/chrome/browser/ui/cocoa/download/download_item_cell.mm |
| index 3e20cd06ed0285c75baf2564188478b57417f899..d4cff77000007fbc84ab94c16a1a38adbb2ecd9e 100644 |
| --- a/chrome/browser/ui/cocoa/download/download_item_cell.mm |
| +++ b/chrome/browser/ui/cocoa/download/download_item_cell.mm |
| @@ -109,7 +109,7 @@ const int kInterruptedAnimationDuration = 2.5; |
| - (void)setInitialState { |
| isStatusTextVisible_ = NO; |
| titleY_ = kPrimaryTextPosTop; |
| - statusAlpha_ = 1.0; |
| + statusAlpha_ = 0.0; |
| [self setFont:[NSFont systemFontOfSize: |
| [NSFont systemFontSizeForControlSize:NSSmallControlSize]]]; |
| @@ -144,10 +144,8 @@ const int kInterruptedAnimationDuration = 2.5; |
| [[NSNotificationCenter defaultCenter] removeObserver:self]; |
| if ([completionAnimation_ isAnimating]) |
| [completionAnimation_ stopAnimation]; |
| - if ([showStatusAnimation_ isAnimating]) |
| - [showStatusAnimation_ stopAnimation]; |
| - if ([hideStatusAnimation_ isAnimating]) |
| - [hideStatusAnimation_ stopAnimation]; |
| + if ([toggleStatusVisibilityAnimation_ isAnimating]) |
| + [toggleStatusVisibilityAnimation_ stopAnimation]; |
| if (trackingAreaButton_) { |
| [[self controlView] removeTrackingArea:trackingAreaButton_]; |
| trackingAreaButton_.reset(); |
| @@ -169,13 +167,11 @@ const int kInterruptedAnimationDuration = 2.5; |
| if (statusText.empty()) { |
| // Remove the status text label. |
| [self hideSecondaryTitle]; |
| - isStatusTextVisible_ = NO; |
| } else { |
| // Set status text. |
| NSString* statusString = base::SysUTF16ToNSString(statusText); |
| [self setSecondaryTitle:statusString]; |
| [self showSecondaryTitle]; |
| - isStatusTextVisible_ = YES; |
| } |
| switch (downloadModel->download()->state()) { |
| @@ -599,47 +595,62 @@ const int kInterruptedAnimationDuration = 2.5; |
| } |
| - (void)showSecondaryTitle { |
| - if (!isStatusTextVisible_) { |
| - // No core animation -- text in CA layers is not subpixel antialiased :-/ |
| - showStatusAnimation_.reset([[DownloadItemCellAnimation alloc] |
| - initWithDownloadItemCell:self |
| - duration:kShowStatusDuration |
| - animationCurve:NSAnimationEaseIn]); |
| - [showStatusAnimation_.get() setDelegate:self]; |
| - [showStatusAnimation_.get() startAnimation]; |
| + if (isStatusTextVisible_) |
| + return; |
| + isStatusTextVisible_ = YES; |
| + if (toggleStatusVisibilityAnimation_ && |
| + [toggleStatusVisibilityAnimation_ isAnimating]) { |
| + // If the animation is hiding the status text, cancel the animation and |
| + // show the status text immediately. |
| + [toggleStatusVisibilityAnimation_ stopAnimation]; |
| + [self animation:toggleStatusVisibilityAnimation_ progressed:1.0]; |
| + toggleStatusVisibilityAnimation_.reset(); |
| } else { |
| - // If the status line continues to be visible, don't show an animation |
| - [self animation:nil progressed:0.0]; |
| + // No core animation -- text in CA layers is not subpixel antialiased :-/ |
|
Nico
2011/07/04 16:39:02
Can you s/No/Don't use/?
|
| + toggleStatusVisibilityAnimation_.reset([[DownloadItemCellAnimation alloc] |
| + initWithDownloadItemCell:self |
| + duration:kShowStatusDuration |
| + animationCurve:NSAnimationEaseIn]); |
|
Nico
2011/07/04 16:39:02
ObjC style is to align the colons (:) vertically –
|
| + [toggleStatusVisibilityAnimation_.get() setDelegate:self]; |
| + [toggleStatusVisibilityAnimation_.get() startAnimation]; |
| + NSLog(@"start"); |
|
Nico
2011/07/04 16:39:02
Remove
|
| } |
| } |
| - (void)hideSecondaryTitle { |
|
Nico
2011/07/04 16:39:02
From what I can tell, this function is identical t
|
| - if (isStatusTextVisible_) { |
| - // No core animation -- text in CA layers is not subpixel antialiased :-/ |
| - hideStatusAnimation_.reset([[DownloadItemCellAnimation alloc] |
| - initWithDownloadItemCell:self |
| - duration:kHideStatusDuration |
| - animationCurve:NSAnimationEaseIn]); |
| - [hideStatusAnimation_.get() setDelegate:self]; |
| - [hideStatusAnimation_.get() startAnimation]; |
| - } else { |
| + if (!isStatusTextVisible_) |
| + return; |
| + isStatusTextVisible_ = NO; |
| + if (toggleStatusVisibilityAnimation_ && |
| + [toggleStatusVisibilityAnimation_ isAnimating]) { |
| // If the download is done so quickly that the status line is never visible, |
| // don't show an animation |
| - [self animation:nil progressed:1.0]; |
| + [toggleStatusVisibilityAnimation_ stopAnimation]; |
| + [self animation:toggleStatusVisibilityAnimation_ progressed:1.0]; |
| + toggleStatusVisibilityAnimation_.reset(); |
| + } else { |
| + // No core animation -- text in CA layers is not subpixel antialiased :-/ |
|
Nico
2011/07/04 16:39:02
here too
|
| + toggleStatusVisibilityAnimation_.reset([[DownloadItemCellAnimation alloc] |
| + initWithDownloadItemCell:self |
| + duration:kHideStatusDuration |
| + animationCurve:NSAnimationEaseIn]); |
|
Nico
2011/07/04 16:39:02
align : too
|
| + [toggleStatusVisibilityAnimation_.get() setDelegate:self]; |
| + [toggleStatusVisibilityAnimation_.get() startAnimation]; |
| } |
| } |
| - (void)animation:(NSAnimation*)animation |
| - progressed:(NSAnimationProgress)progress { |
| - if (animation == showStatusAnimation_) { |
| - titleY_ = (1 - progress)*kPrimaryTextOnlyPosTop + |
| - kPrimaryTextPosTop; |
| - statusAlpha_ = progress; |
| - [[self controlView] setNeedsDisplay:YES]; |
| - } else if (animation == hideStatusAnimation_ || animation == nil) { |
| - titleY_ = progress*kPrimaryTextOnlyPosTop + |
| - (1 - progress)*kPrimaryTextPosTop; |
| - statusAlpha_ = 1 - progress; |
| + progressed:(NSAnimationProgress)progress { |
| + NSLog(@"progress"); |
|
Nico
2011/07/04 16:39:02
remove
|
| + if (animation == toggleStatusVisibilityAnimation_) { |
| + if (isStatusTextVisible_) { |
| + titleY_ = (1 - progress)*kPrimaryTextOnlyPosTop + kPrimaryTextPosTop; |
| + statusAlpha_ = progress; |
| + } else { |
| + titleY_ = progress*kPrimaryTextOnlyPosTop + |
| + (1 - progress)*kPrimaryTextPosTop; |
| + statusAlpha_ = 1 - progress; |
| + } |
| [[self controlView] setNeedsDisplay:YES]; |
| } else if (animation == completionAnimation_) { |
| [[self controlView] setNeedsDisplay:YES]; |
| @@ -647,14 +658,24 @@ const int kInterruptedAnimationDuration = 2.5; |
| } |
| - (void)animationDidEnd:(NSAnimation *)animation { |
| - if (animation == showStatusAnimation_) |
| - showStatusAnimation_.reset(); |
| - else if (animation == hideStatusAnimation_) |
| - hideStatusAnimation_.reset(); |
| + if (animation == toggleStatusVisibilityAnimation_) |
| + toggleStatusVisibilityAnimation_.reset(); |
| else if (animation == completionAnimation_) |
| completionAnimation_.reset(); |
| } |
| +- (BOOL)isStatusTextVisible { |
| + return isStatusTextVisible_; |
| +} |
| + |
| +- (CGFloat)statusTextAlpha { |
| + return statusAlpha_; |
| +} |
| + |
| +- (void)skipVisibilityAnimation { |
| + [toggleStatusVisibilityAnimation_ setCurrentProgress:1.0]; |
| +} |
| + |
| @end |
| @implementation DownloadItemCellAnimation |