| 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 #import "base/mac_util.h" | 8 #import "base/mac_util.h" |
| 9 #include "base/nsimage_cache_mac.h" | 9 #include "base/nsimage_cache_mac.h" |
| 10 #include "base/scoped_cftyperef.h" | 10 #include "base/scoped_cftyperef.h" |
| (...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 | 620 |
| 621 - (void)drawRect:(NSRect)dirtyRect { | 621 - (void)drawRect:(NSRect)dirtyRect { |
| 622 // If this tab is phantom, do not draw the tab background itself. The only UI | 622 // If this tab is phantom, do not draw the tab background itself. The only UI |
| 623 // element that will represent this tab is the favicon. | 623 // element that will represent this tab is the favicon. |
| 624 if ([controller_ phantom]) | 624 if ([controller_ phantom]) |
| 625 return; | 625 return; |
| 626 | 626 |
| 627 NSGraphicsContext* context = [NSGraphicsContext currentContext]; | 627 NSGraphicsContext* context = [NSGraphicsContext currentContext]; |
| 628 [context saveGraphicsState]; | 628 [context saveGraphicsState]; |
| 629 | 629 |
| 630 ThemeProvider* themeProvider = [[self window] themeProvider]; | 630 BrowserThemeProvider* themeProvider = |
| 631 static_cast<BrowserThemeProvider*>([[self window] themeProvider]); |
| 631 [context setPatternPhase:[[self window] themePatternPhase]]; | 632 [context setPatternPhase:[[self window] themePatternPhase]]; |
| 632 | 633 |
| 633 NSRect rect = [self bounds]; | 634 NSRect rect = [self bounds]; |
| 634 NSBezierPath* path = [self bezierPathForRect:rect]; | 635 NSBezierPath* path = [self bezierPathForRect:rect]; |
| 635 | 636 |
| 636 BOOL selected = [self state]; | 637 BOOL selected = [self state]; |
| 637 // Don't draw the window/tab bar background when selected, since the tab | 638 // Don't draw the window/tab bar background when selected, since the tab |
| 638 // background overlay drawn over it (see below) will be fully opaque. | 639 // background overlay drawn over it (see below) will be fully opaque. |
| 639 BOOL hasBackgroundImage = NO; | 640 BOOL hasBackgroundImage = NO; |
| 640 if (!selected) { | 641 if (!selected) { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 } | 710 } |
| 710 } | 711 } |
| 711 | 712 |
| 712 CGContextEndTransparencyLayer(cgContext); | 713 CGContextEndTransparencyLayer(cgContext); |
| 713 [context restoreGraphicsState]; | 714 [context restoreGraphicsState]; |
| 714 } | 715 } |
| 715 | 716 |
| 716 BOOL active = [[self window] isKeyWindow] || [[self window] isMainWindow]; | 717 BOOL active = [[self window] isKeyWindow] || [[self window] isMainWindow]; |
| 717 CGFloat borderAlpha = selected ? (active ? 0.3 : 0.2) : 0.2; | 718 CGFloat borderAlpha = selected ? (active ? 0.3 : 0.2) : 0.2; |
| 718 NSColor* borderColor = [NSColor colorWithDeviceWhite:0.0 alpha:borderAlpha]; | 719 NSColor* borderColor = [NSColor colorWithDeviceWhite:0.0 alpha:borderAlpha]; |
| 719 NSColor* highlightColor = [NSColor colorWithCalibratedWhite:0.96 alpha:1.0]; | 720 NSColor* highlightColor = themeProvider ? themeProvider->GetNSColor( |
| 721 themeProvider->UsingDefaultTheme() ? |
| 722 BrowserThemeProvider::COLOR_TOOLBAR_BEZEL : |
| 723 BrowserThemeProvider::COLOR_TOOLBAR, true) : nil; |
| 720 | 724 |
| 721 // Draw the top inner highlight within the currently selected tab. | 725 // Draw the top inner highlight within the currently selected tab if using |
| 722 if (selected) { | 726 // the default theme. |
| 727 if (selected && themeProvider && themeProvider->UsingDefaultTheme()) { |
| 723 NSAffineTransform* highlightTransform = [NSAffineTransform transform]; | 728 NSAffineTransform* highlightTransform = [NSAffineTransform transform]; |
| 724 [highlightTransform translateXBy:1.0 yBy:-1.0]; | 729 [highlightTransform translateXBy:1.0 yBy:-1.0]; |
| 725 scoped_nsobject<NSBezierPath> highlightPath([path copy]); | 730 scoped_nsobject<NSBezierPath> highlightPath([path copy]); |
| 726 [highlightPath transformUsingAffineTransform:highlightTransform]; | 731 [highlightPath transformUsingAffineTransform:highlightTransform]; |
| 727 [highlightColor setStroke]; | 732 [highlightColor setStroke]; |
| 728 [highlightPath setLineWidth:1.0]; | 733 [highlightPath setLineWidth:1.0]; |
| 729 [highlightPath stroke]; | 734 [highlightPath stroke]; |
| 730 highlightTransform = [NSAffineTransform transform]; | 735 highlightTransform = [NSAffineTransform transform]; |
| 731 [highlightTransform translateXBy:-2.0 yBy:0.0]; | 736 [highlightTransform translateXBy:-2.0 yBy:0.0]; |
| 732 [highlightPath transformUsingAffineTransform:highlightTransform]; | 737 [highlightPath transformUsingAffineTransform:highlightTransform]; |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1037 controlPoint1:NSMakePoint(topRight.x + bottomControlPointInset, | 1042 controlPoint1:NSMakePoint(topRight.x + bottomControlPointInset, |
| 1038 topRight.y) | 1043 topRight.y) |
| 1039 controlPoint2:NSMakePoint(bottomRight.x - baseControlPointOutset, | 1044 controlPoint2:NSMakePoint(bottomRight.x - baseControlPointOutset, |
| 1040 bottomRight.y)]; | 1045 bottomRight.y)]; |
| 1041 [path lineToPoint:NSMakePoint(bottomRight.x + 1, bottomRight.y)]; | 1046 [path lineToPoint:NSMakePoint(bottomRight.x + 1, bottomRight.y)]; |
| 1042 [path lineToPoint:NSMakePoint(bottomRight.x + 1, bottomRight.y - 2)]; | 1047 [path lineToPoint:NSMakePoint(bottomRight.x + 1, bottomRight.y - 2)]; |
| 1043 return path; | 1048 return path; |
| 1044 } | 1049 } |
| 1045 | 1050 |
| 1046 @end // @implementation TabView(Private) | 1051 @end // @implementation TabView(Private) |
| OLD | NEW |