Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/cocoa/tab_view.h" | 5 #import "chrome/browser/cocoa/tab_view.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/nsimage_cache_mac.h" | 8 #include "base/nsimage_cache_mac.h" |
| 9 #include "chrome/browser/browser_theme_provider.h" | 9 #include "chrome/browser/browser_theme_provider.h" |
| 10 #import "chrome/browser/cocoa/tab_controller.h" | 10 #import "chrome/browser/cocoa/tab_controller.h" |
| (...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 602 // element that will represent this tab is the favicon. | 602 // element that will represent this tab is the favicon. |
| 603 if ([controller_ phantom]) | 603 if ([controller_ phantom]) |
| 604 return; | 604 return; |
| 605 | 605 |
| 606 NSGraphicsContext* context = [NSGraphicsContext currentContext]; | 606 NSGraphicsContext* context = [NSGraphicsContext currentContext]; |
| 607 [context saveGraphicsState]; | 607 [context saveGraphicsState]; |
| 608 rect = [self bounds]; | 608 rect = [self bounds]; |
| 609 BOOL active = [[self window] isKeyWindow] || [[self window] isMainWindow]; | 609 BOOL active = [[self window] isKeyWindow] || [[self window] isMainWindow]; |
| 610 BOOL selected = [self state]; | 610 BOOL selected = [self state]; |
| 611 | 611 |
| 612 // Inset by 0.5 in order to draw on pixels rather than on borders (which would | 612 // Outset by 0.5 in order to draw on pixels rather than on borders (which |
| 613 // cause blurry pixels). Decrease height by 1 in order to move away from the | 613 // would cause blurry pixels). Subtract 1px of height to compensate, |
| 614 // edge for the dark shadow. | 614 // otherwise clipping will occur. |
| 615 rect = NSInsetRect(rect, -0.5, -0.5); | 615 rect = NSInsetRect(rect, -0.5, -0.5); |
| 616 rect.origin.y -= 1; | 616 rect.size.height -= 1; |
| 617 | 617 |
| 618 NSPoint bottomLeft = NSMakePoint(NSMinX(rect), NSMinY(rect) + 2); | 618 NSPoint bottomLeft = NSMakePoint(NSMinX(rect), NSMinY(rect) + 2); |
| 619 NSPoint bottomRight = NSMakePoint(NSMaxX(rect), NSMinY(rect) + 2); | 619 NSPoint bottomRight = NSMakePoint(NSMaxX(rect), NSMinY(rect) + 2); |
| 620 NSPoint topRight = | 620 NSPoint topRight = |
| 621 NSMakePoint(NSMaxX(rect) - kInsetMultiplier * NSHeight(rect), | 621 NSMakePoint(NSMaxX(rect) - kInsetMultiplier * NSHeight(rect), |
| 622 NSMaxY(rect)); | 622 NSMaxY(rect)); |
| 623 NSPoint topLeft = | 623 NSPoint topLeft = |
| 624 NSMakePoint(NSMinX(rect) + kInsetMultiplier * NSHeight(rect), | 624 NSMakePoint(NSMinX(rect) + kInsetMultiplier * NSHeight(rect), |
| 625 NSMaxY(rect)); | 625 NSMaxY(rect)); |
| 626 | 626 |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 749 if (selected) { | 749 if (selected) { |
| 750 [[NSColor colorWithDeviceWhite:0.0 alpha:active ? 0.3 : 0.15] set]; | 750 [[NSColor colorWithDeviceWhite:0.0 alpha:active ? 0.3 : 0.15] set]; |
| 751 } else { | 751 } else { |
| 752 [[NSColor colorWithDeviceWhite:0.0 alpha:active ? 0.2 : 0.15] set]; | 752 [[NSColor colorWithDeviceWhite:0.0 alpha:active ? 0.2 : 0.15] set]; |
| 753 [[NSBezierPath bezierPathWithRect:NSOffsetRect(rect, 0, 2.5)] addClip]; | 753 [[NSBezierPath bezierPathWithRect:NSOffsetRect(rect, 0, 2.5)] addClip]; |
| 754 } | 754 } |
| 755 [path setLineWidth:1.0]; | 755 [path setLineWidth:1.0]; |
| 756 [path stroke]; | 756 [path stroke]; |
| 757 [context restoreGraphicsState]; | 757 [context restoreGraphicsState]; |
| 758 | 758 |
| 759 // Draw the bottom border. | 759 // Mimic the tab strip's bottom border, which consists of a dark border |
| 760 // and light highlight. | |
| 760 if (!selected) { | 761 if (!selected) { |
| 761 [path addClip]; | 762 [path addClip]; |
| 762 NSRect borderRect, contentRect; | 763 NSRect tempRect = rect; |
|
rohitrao (ping after 24h)
2010/06/17 20:25:52
Call this something like fillRect instead of tempR
| |
| 763 NSDivideRect(rect, &borderRect, &contentRect, 2.5, NSMinYEdge); | 764 tempRect.origin.y = 1; |
| 764 [[NSColor colorWithDeviceWhite:0.0 alpha:active ? 0.3 : 0.15] set]; | 765 tempRect.size.height = 1; |
| 765 NSRectFillUsingOperation(borderRect, NSCompositeSourceOver); | 766 [[NSColor colorWithDeviceWhite:0.0 alpha:active ? 0.2 : 0.15] set]; |
| 767 NSRectFillUsingOperation(tempRect, NSCompositeSourceOver); | |
| 768 | |
| 769 tempRect.origin.y = 0; | |
| 770 [[NSColor colorWithCalibratedWhite:0.96 alpha:1.0] set]; | |
| 771 NSRectFillUsingOperation(tempRect, NSCompositeSourceOver); | |
| 766 } | 772 } |
| 773 | |
| 767 [context restoreGraphicsState]; | 774 [context restoreGraphicsState]; |
| 768 } | 775 } |
| 769 | 776 |
| 770 - (void)viewDidMoveToWindow { | 777 - (void)viewDidMoveToWindow { |
| 771 [super viewDidMoveToWindow]; | 778 [super viewDidMoveToWindow]; |
| 772 if ([self window]) { | 779 if ([self window]) { |
| 773 [controller_ updateTitleColor]; | 780 [controller_ updateTitleColor]; |
| 774 } | 781 } |
| 775 } | 782 } |
| 776 | 783 |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 950 } | 957 } |
| 951 | 958 |
| 952 if (nextUpdate < kNoUpdate) | 959 if (nextUpdate < kNoUpdate) |
| 953 [self performSelector:_cmd withObject:nil afterDelay:nextUpdate]; | 960 [self performSelector:_cmd withObject:nil afterDelay:nextUpdate]; |
| 954 | 961 |
| 955 [self resetLastGlowUpdateTime]; | 962 [self resetLastGlowUpdateTime]; |
| 956 [self setNeedsDisplay:YES]; | 963 [self setNeedsDisplay:YES]; |
| 957 } | 964 } |
| 958 | 965 |
| 959 @end // @implementation TabView(Private) | 966 @end // @implementation TabView(Private) |
| OLD | NEW |