| 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" |
| 11 #include "chrome/browser/download/download_util.h" | 11 #include "chrome/browser/download/download_util.h" |
| 12 #import "chrome/browser/themes/theme_service.h" | 12 #import "chrome/browser/themes/theme_service.h" |
| 13 #import "chrome/browser/ui/cocoa/download/download_item_cell.h" | 13 #import "chrome/browser/ui/cocoa/download/download_item_cell.h" |
| 14 #import "chrome/browser/ui/cocoa/image_utils.h" | 14 #import "chrome/browser/ui/cocoa/image_utils.h" |
| 15 #import "chrome/browser/ui/cocoa/themed_window.h" | 15 #import "chrome/browser/ui/cocoa/themed_window.h" |
| 16 #include "grit/theme_resources.h" | 16 #include "grit/theme_resources.h" |
| 17 #import "third_party/GTM/AppKit/GTMNSAnimation+Duration.h" | 17 #import "third_party/GTM/AppKit/GTMNSAnimation+Duration.h" |
| 18 #import "third_party/GTM/AppKit/GTMNSColor+Luminance.h" | 18 #import "third_party/GTM/AppKit/GTMNSColor+Luminance.h" |
| 19 #include "ui/base/l10n/l10n_util.h" | 19 #include "ui/base/l10n/l10n_util.h" |
| 20 #include "ui/base/text/text_elider.h" | 20 #include "ui/base/text/text_elider.h" |
| 21 #include "ui/gfx/canvas_skia_paint.h" | 21 #include "ui/gfx/canvas_skia_paint.h" |
| 22 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" |
| 22 | 23 |
| 23 namespace { | 24 namespace { |
| 24 | 25 |
| 25 // Distance from top border to icon. | 26 // Distance from top border to icon. |
| 26 const CGFloat kImagePaddingTop = 7; | 27 const CGFloat kImagePaddingTop = 7; |
| 27 | 28 |
| 28 // Distance from left border to icon. | 29 // Distance from left border to icon. |
| 29 const CGFloat kImagePaddingLeft = 9; | 30 const CGFloat kImagePaddingLeft = 9; |
| 30 | 31 |
| 31 // Width of icon. | 32 // Width of icon. |
| (...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 646 NSPoint p2 = NSMakePoint(cx + kDropdownArrowWidth/2, | 647 NSPoint p2 = NSMakePoint(cx + kDropdownArrowWidth/2, |
| 647 cy - kDropdownArrowHeight/3 + kDropdownAreaY); | 648 cy - kDropdownArrowHeight/3 + kDropdownAreaY); |
| 648 NSPoint p3 = NSMakePoint(cx, cy + kDropdownArrowHeight*2/3 + kDropdownAreaY); | 649 NSPoint p3 = NSMakePoint(cx, cy + kDropdownArrowHeight*2/3 + kDropdownAreaY); |
| 649 NSBezierPath *triangle = [NSBezierPath bezierPath]; | 650 NSBezierPath *triangle = [NSBezierPath bezierPath]; |
| 650 [triangle moveToPoint:p1]; | 651 [triangle moveToPoint:p1]; |
| 651 [triangle lineToPoint:p2]; | 652 [triangle lineToPoint:p2]; |
| 652 [triangle lineToPoint:p3]; | 653 [triangle lineToPoint:p3]; |
| 653 [triangle closePath]; | 654 [triangle closePath]; |
| 654 | 655 |
| 655 NSGraphicsContext* context = [NSGraphicsContext currentContext]; | 656 NSGraphicsContext* context = [NSGraphicsContext currentContext]; |
| 656 [context saveGraphicsState]; | 657 gfx::ScopedNSGraphicsContextSaveGState scopedGState(context); |
| 657 | 658 |
| 658 scoped_nsobject<NSShadow> shadow([[NSShadow alloc] init]); | 659 scoped_nsobject<NSShadow> shadow([[NSShadow alloc] init]); |
| 659 [shadow.get() setShadowColor:[NSColor whiteColor]]; | 660 [shadow.get() setShadowColor:[NSColor whiteColor]]; |
| 660 [shadow.get() setShadowOffset:NSMakeSize(0, -1)]; | 661 [shadow.get() setShadowOffset:NSMakeSize(0, -1)]; |
| 661 [shadow setShadowBlurRadius:0.0]; | 662 [shadow setShadowBlurRadius:0.0]; |
| 662 [shadow set]; | 663 [shadow set]; |
| 663 | 664 |
| 664 NSColor* fill = [self titleColorForPart:kDownloadItemMouseOverDropdownPart]; | 665 NSColor* fill = [self titleColorForPart:kDownloadItemMouseOverDropdownPart]; |
| 665 [fill setFill]; | 666 [fill setFill]; |
| 666 | 667 |
| 667 [triangle fill]; | 668 [triangle fill]; |
| 668 | |
| 669 [context restoreGraphicsState]; | |
| 670 } | 669 } |
| 671 | 670 |
| 672 - (NSRect)imageRectForBounds:(NSRect)cellFrame { | 671 - (NSRect)imageRectForBounds:(NSRect)cellFrame { |
| 673 return NSMakeRect(cellFrame.origin.x + kImagePaddingLeft, | 672 return NSMakeRect(cellFrame.origin.x + kImagePaddingLeft, |
| 674 cellFrame.origin.y + kImagePaddingTop, | 673 cellFrame.origin.y + kImagePaddingTop, |
| 675 kImageWidth, | 674 kImageWidth, |
| 676 kImageHeight); | 675 kImageHeight); |
| 677 } | 676 } |
| 678 | 677 |
| 679 - (void)hideSecondaryTitle { | 678 - (void)hideSecondaryTitle { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 726 } | 725 } |
| 727 return self; | 726 return self; |
| 728 } | 727 } |
| 729 | 728 |
| 730 - (void)setCurrentProgress:(NSAnimationProgress)progress { | 729 - (void)setCurrentProgress:(NSAnimationProgress)progress { |
| 731 [super setCurrentProgress:progress]; | 730 [super setCurrentProgress:progress]; |
| 732 [cell_ animation:self progressed:progress]; | 731 [cell_ animation:self progressed:progress]; |
| 733 } | 732 } |
| 734 | 733 |
| 735 @end | 734 @end |
| OLD | NEW |