| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #import "chrome/browser/ui/cocoa/download/download_item_cell.h" | 5 #import "chrome/browser/ui/cocoa/download/download_item_cell.h" |
| 6 | 6 |
| 7 #include "base/sys_string_conversions.h" | 7 #include "base/sys_string_conversions.h" |
| 8 #include "chrome/browser/download/download_item.h" | 8 #include "chrome/browser/download/download_item.h" |
| 9 #include "chrome/browser/download/download_item_model.h" | 9 #include "chrome/browser/download/download_item_model.h" |
| 10 #include "chrome/browser/download/download_manager.h" | 10 #include "chrome/browser/download/download_manager.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 @interface DownloadItemCellAnimation : NSAnimation { | 80 @interface DownloadItemCellAnimation : NSAnimation { |
| 81 DownloadItemCell* cell_; | 81 DownloadItemCell* cell_; |
| 82 } | 82 } |
| 83 - (id)initWithDownloadItemCell:(DownloadItemCell*)cell | 83 - (id)initWithDownloadItemCell:(DownloadItemCell*)cell |
| 84 duration:(NSTimeInterval)duration | 84 duration:(NSTimeInterval)duration |
| 85 animationCurve:(NSAnimationCurve)animationCurve; | 85 animationCurve:(NSAnimationCurve)animationCurve; |
| 86 @end | 86 @end |
| 87 | 87 |
| 88 @interface DownloadItemCell(Private) | 88 @interface DownloadItemCell(Private) |
| 89 - (void)updateTrackingAreas:(id)sender; | 89 - (void)updateTrackingAreas:(id)sender; |
| 90 - (void)showSecondaryTitle; |
| 90 - (void)hideSecondaryTitle; | 91 - (void)hideSecondaryTitle; |
| 91 - (void)animation:(NSAnimation*)animation | 92 - (void)animation:(NSAnimation*)animation |
| 92 progressed:(NSAnimationProgress)progress; | 93 progressed:(NSAnimationProgress)progress; |
| 93 - (NSString*)elideTitle:(int)availableWidth; | 94 - (NSString*)elideTitle:(int)availableWidth; |
| 94 - (NSString*)elideStatus:(int)availableWidth; | 95 - (NSString*)elideStatus:(int)availableWidth; |
| 95 - (ui::ThemeProvider*)backgroundThemeWrappingProvider: | 96 - (ui::ThemeProvider*)backgroundThemeWrappingProvider: |
| 96 (ui::ThemeProvider*)provider; | 97 (ui::ThemeProvider*)provider; |
| 97 - (BOOL)pressedWithDefaultThemeOnPart:(DownloadItemMousePosition)part; | 98 - (BOOL)pressedWithDefaultThemeOnPart:(DownloadItemMousePosition)part; |
| 98 - (NSColor*)titleColorForPart:(DownloadItemMousePosition)part; | 99 - (NSColor*)titleColorForPart:(DownloadItemMousePosition)part; |
| 99 - (void)drawSecondaryTitleInRect:(NSRect)innerFrame; | 100 - (void)drawSecondaryTitleInRect:(NSRect)innerFrame; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 | 164 |
| 164 string16 statusText = downloadModel->GetStatusText(); | 165 string16 statusText = downloadModel->GetStatusText(); |
| 165 if (statusText.empty()) { | 166 if (statusText.empty()) { |
| 166 // Remove the status text label. | 167 // Remove the status text label. |
| 167 [self hideSecondaryTitle]; | 168 [self hideSecondaryTitle]; |
| 168 isStatusTextVisible_ = NO; | 169 isStatusTextVisible_ = NO; |
| 169 } else { | 170 } else { |
| 170 // Set status text. | 171 // Set status text. |
| 171 NSString* statusString = base::SysUTF16ToNSString(statusText); | 172 NSString* statusString = base::SysUTF16ToNSString(statusText); |
| 172 [self setSecondaryTitle:statusString]; | 173 [self setSecondaryTitle:statusString]; |
| 174 [self showSecondaryTitle]; |
| 173 isStatusTextVisible_ = YES; | 175 isStatusTextVisible_ = YES; |
| 174 } | 176 } |
| 175 | 177 |
| 176 switch (downloadModel->download()->state()) { | 178 switch (downloadModel->download()->state()) { |
| 177 case DownloadItem::COMPLETE: | 179 case DownloadItem::COMPLETE: |
| 178 // Small downloads may start in a complete state due to asynchronous | 180 // Small downloads may start in a complete state due to asynchronous |
| 179 // notifications. In this case, we'll get a second complete notification | 181 // notifications. In this case, we'll get a second complete notification |
| 180 // via the observers, so we ignore it and avoid creating a second complete | 182 // via the observers, so we ignore it and avoid creating a second complete |
| 181 // animation. | 183 // animation. |
| 182 if (completionAnimation_.get()) | 184 if (completionAnimation_.get()) |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 [triangle fill]; | 588 [triangle fill]; |
| 587 } | 589 } |
| 588 | 590 |
| 589 - (NSRect)imageRectForBounds:(NSRect)cellFrame { | 591 - (NSRect)imageRectForBounds:(NSRect)cellFrame { |
| 590 return NSMakeRect(cellFrame.origin.x + kImagePaddingLeft, | 592 return NSMakeRect(cellFrame.origin.x + kImagePaddingLeft, |
| 591 cellFrame.origin.y + kImagePaddingTop, | 593 cellFrame.origin.y + kImagePaddingTop, |
| 592 kImageWidth, | 594 kImageWidth, |
| 593 kImageHeight); | 595 kImageHeight); |
| 594 } | 596 } |
| 595 | 597 |
| 598 - (void)showSecondaryTitle { |
| 599 [self animation:nil progressed:0.0]; |
| 600 } |
| 601 |
| 596 - (void)hideSecondaryTitle { | 602 - (void)hideSecondaryTitle { |
| 597 if (isStatusTextVisible_) { | 603 if (isStatusTextVisible_) { |
| 598 // No core animation -- text in CA layers is not subpixel antialiased :-/ | 604 // No core animation -- text in CA layers is not subpixel antialiased :-/ |
| 599 hideStatusAnimation_.reset([[DownloadItemCellAnimation alloc] | 605 hideStatusAnimation_.reset([[DownloadItemCellAnimation alloc] |
| 600 initWithDownloadItemCell:self | 606 initWithDownloadItemCell:self |
| 601 duration:kHideStatusDuration | 607 duration:kHideStatusDuration |
| 602 animationCurve:NSAnimationEaseIn]); | 608 animationCurve:NSAnimationEaseIn]); |
| 603 [hideStatusAnimation_.get() setDelegate:self]; | 609 [hideStatusAnimation_.get() setDelegate:self]; |
| 604 [hideStatusAnimation_.get() startAnimation]; | 610 [hideStatusAnimation_.get() startAnimation]; |
| 605 } else { | 611 } else { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 } | 649 } |
| 644 return self; | 650 return self; |
| 645 } | 651 } |
| 646 | 652 |
| 647 - (void)setCurrentProgress:(NSAnimationProgress)progress { | 653 - (void)setCurrentProgress:(NSAnimationProgress)progress { |
| 648 [super setCurrentProgress:progress]; | 654 [super setCurrentProgress:progress]; |
| 649 [cell_ animation:self progressed:progress]; | 655 [cell_ animation:self progressed:progress]; |
| 650 } | 656 } |
| 651 | 657 |
| 652 @end | 658 @end |
| OLD | NEW |