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 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 if (![secondaryColor gtm_isDarkColor]) | 399 if (![secondaryColor gtm_isDarkColor]) |
400 secondaryColor = [secondaryColor gtm_colorByAdjustingLuminance:-0.2]; | 400 secondaryColor = [secondaryColor gtm_colorByAdjustingLuminance:-0.2]; |
401 | 401 |
402 NSDictionary* secondaryTextAttributes = | 402 NSDictionary* secondaryTextAttributes = |
403 [NSDictionary dictionaryWithObjectsAndKeys: | 403 [NSDictionary dictionaryWithObjectsAndKeys: |
404 secondaryColor, NSForegroundColorAttributeName, | 404 secondaryColor, NSForegroundColorAttributeName, |
405 [self secondaryFont], NSFontAttributeName, | 405 [self secondaryFont], NSFontAttributeName, |
406 nil]; | 406 nil]; |
407 NSPoint secondaryPos = | 407 NSPoint secondaryPos = |
408 NSMakePoint(innerFrame.origin.x + kTextPosLeft, kSecondaryTextPosTop); | 408 NSMakePoint(innerFrame.origin.x + kTextPosLeft, kSecondaryTextPosTop); |
| 409 |
| 410 gfx::ScopedNSGraphicsContextSaveGState contextSave; |
409 NSGraphicsContext* nsContext = [NSGraphicsContext currentContext]; | 411 NSGraphicsContext* nsContext = [NSGraphicsContext currentContext]; |
410 CGContextRef cgContext = (CGContextRef)[nsContext graphicsPort]; | 412 CGContextRef cgContext = (CGContextRef)[nsContext graphicsPort]; |
411 [nsContext saveGraphicsState]; | |
412 [nsContext setCompositingOperation:NSCompositeSourceOver]; | 413 [nsContext setCompositingOperation:NSCompositeSourceOver]; |
413 CGContextSetAlpha(cgContext, statusAlpha_); | 414 CGContextSetAlpha(cgContext, statusAlpha_); |
414 [secondaryText drawAtPoint:secondaryPos | 415 [secondaryText drawAtPoint:secondaryPos |
415 withAttributes:secondaryTextAttributes]; | 416 withAttributes:secondaryTextAttributes]; |
416 [nsContext restoreGraphicsState]; | |
417 } | 417 } |
418 | 418 |
419 - (void)drawWithFrame:(NSRect)cellFrame inView:(NSView*)controlView { | 419 - (void)drawWithFrame:(NSRect)cellFrame inView:(NSView*)controlView { |
420 NSRect drawFrame = NSInsetRect(cellFrame, 1.5, 1.5); | 420 NSRect drawFrame = NSInsetRect(cellFrame, 1.5, 1.5); |
421 NSRect innerFrame = NSInsetRect(cellFrame, 2, 2); | 421 NSRect innerFrame = NSInsetRect(cellFrame, 2, 2); |
422 | 422 |
423 const float radius = 5; | 423 const float radius = 5; |
424 NSWindow* window = [controlView window]; | 424 NSWindow* window = [controlView window]; |
425 BOOL active = [window isKeyWindow] || [window isMainWindow]; | 425 BOOL active = [window isKeyWindow] || [window isMainWindow]; |
426 | 426 |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 cy - kDropdownArrowHeight/3 + kDropdownAreaY); | 572 cy - kDropdownArrowHeight/3 + kDropdownAreaY); |
573 NSPoint p2 = NSMakePoint(cx + kDropdownArrowWidth/2, | 573 NSPoint p2 = NSMakePoint(cx + kDropdownArrowWidth/2, |
574 cy - kDropdownArrowHeight/3 + kDropdownAreaY); | 574 cy - kDropdownArrowHeight/3 + kDropdownAreaY); |
575 NSPoint p3 = NSMakePoint(cx, cy + kDropdownArrowHeight*2/3 + kDropdownAreaY); | 575 NSPoint p3 = NSMakePoint(cx, cy + kDropdownArrowHeight*2/3 + kDropdownAreaY); |
576 NSBezierPath *triangle = [NSBezierPath bezierPath]; | 576 NSBezierPath *triangle = [NSBezierPath bezierPath]; |
577 [triangle moveToPoint:p1]; | 577 [triangle moveToPoint:p1]; |
578 [triangle lineToPoint:p2]; | 578 [triangle lineToPoint:p2]; |
579 [triangle lineToPoint:p3]; | 579 [triangle lineToPoint:p3]; |
580 [triangle closePath]; | 580 [triangle closePath]; |
581 | 581 |
582 NSGraphicsContext* context = [NSGraphicsContext currentContext]; | 582 gfx::ScopedNSGraphicsContextSaveGState scopedGState; |
583 gfx::ScopedNSGraphicsContextSaveGState scopedGState(context); | |
584 | 583 |
585 scoped_nsobject<NSShadow> shadow([[NSShadow alloc] init]); | 584 scoped_nsobject<NSShadow> shadow([[NSShadow alloc] init]); |
586 [shadow.get() setShadowColor:[NSColor whiteColor]]; | 585 [shadow.get() setShadowColor:[NSColor whiteColor]]; |
587 [shadow.get() setShadowOffset:NSMakeSize(0, -1)]; | 586 [shadow.get() setShadowOffset:NSMakeSize(0, -1)]; |
588 [shadow setShadowBlurRadius:0.0]; | 587 [shadow setShadowBlurRadius:0.0]; |
589 [shadow set]; | 588 [shadow set]; |
590 | 589 |
591 NSColor* fill = [self titleColorForPart:kDownloadItemMouseOverDropdownPart]; | 590 NSColor* fill = [self titleColorForPart:kDownloadItemMouseOverDropdownPart]; |
592 [fill setFill]; | 591 [fill setFill]; |
593 | 592 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
685 } | 684 } |
686 return self; | 685 return self; |
687 } | 686 } |
688 | 687 |
689 - (void)setCurrentProgress:(NSAnimationProgress)progress { | 688 - (void)setCurrentProgress:(NSAnimationProgress)progress { |
690 [super setCurrentProgress:progress]; | 689 [super setCurrentProgress:progress]; |
691 [cell_ animation:self progressed:progress]; | 690 [cell_ animation:self progressed:progress]; |
692 } | 691 } |
693 | 692 |
694 @end | 693 @end |
OLD | NEW |