OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/tabs/tab_strip_view.h" | 5 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h" |
6 | 6 |
7 #include <cmath> // floor | 7 #include <cmath> // floor |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/mac/foundation_util.h" | 10 #include "base/mac/foundation_util.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 NSWindow* window = [self window]; | 59 NSWindow* window = [self window]; |
60 const ui::ThemeProvider* themeProvider = [window themeProvider]; | 60 const ui::ThemeProvider* themeProvider = [window themeProvider]; |
61 if (!themeProvider) | 61 if (!themeProvider) |
62 return; | 62 return; |
63 | 63 |
64 if (!ui::MaterialDesignController::IsModeMaterial()) { | 64 if (!ui::MaterialDesignController::IsModeMaterial()) { |
65 // First draw the toolbar bitmap, so that theme colors can shine through. | 65 // First draw the toolbar bitmap, so that theme colors can shine through. |
66 NSRect backgroundRect = [self bounds]; | 66 NSRect backgroundRect = [self bounds]; |
67 backgroundRect.size.height = 2 * [self cr_lineWidth]; | 67 backgroundRect.size.height = 2 * [self cr_lineWidth]; |
68 if (NSIntersectsRect(backgroundRect, dirtyRect)) | 68 if (NSIntersectsRect(backgroundRect, dirtyRect)) |
69 [super drawRect:backgroundRect]; | 69 [self drawBackground:backgroundRect]; |
70 | 70 |
71 // Draw the border bitmap, which is partially transparent. | 71 // Draw the border bitmap, which is partially transparent. |
72 NSImage* image = themeProvider->GetNSImageNamed(IDR_TOOLBAR_SHADE_TOP); | 72 NSImage* image = themeProvider->GetNSImageNamed(IDR_TOOLBAR_SHADE_TOP); |
73 NSRect borderRect = backgroundRect; | 73 NSRect borderRect = backgroundRect; |
74 borderRect.size.height = [image size].height; | 74 borderRect.size.height = [image size].height; |
75 if (NSIntersectsRect(borderRect, dirtyRect)) { | 75 if (NSIntersectsRect(borderRect, dirtyRect)) { |
76 BOOL focused = [window isMainWindow]; | 76 BOOL focused = [window isMainWindow]; |
77 NSDrawThreePartImage(borderRect, nil, image, nil, /*vertical=*/ NO, | 77 NSDrawThreePartImage(borderRect, nil, image, nil, /*vertical=*/ NO, |
78 NSCompositeSourceOver, | 78 NSCompositeSourceOver, |
79 focused ? 1.0 : tabs::kImageNoFocusAlpha, | 79 focused ? 1.0 : tabs::kImageNoFocusAlpha, |
80 /*flipped=*/ NO); | 80 /*flipped=*/ NO); |
81 } | 81 } |
82 | 82 |
83 return; | 83 return; |
84 } | 84 } |
85 | 85 |
86 NSColor* strokeColor; | 86 NSColor* strokeColor; |
87 if (themeProvider->HasCustomImage(IDR_THEME_TOOLBAR) || | 87 if (themeProvider->HasCustomImage(IDR_THEME_TOOLBAR) || |
88 themeProvider->HasCustomColor(ThemeProperties::COLOR_TOOLBAR)) { | 88 themeProvider->HasCustomColor(ThemeProperties::COLOR_TOOLBAR)) { |
89 // First draw the toolbar bitmap, so that theme colors can shine through. | 89 // First draw the toolbar bitmap, so that theme colors can shine through. |
90 NSRect backgroundRect = [self bounds]; | 90 NSRect backgroundRect = [self bounds]; |
91 backgroundRect.size.height = [self cr_lineWidth]; | 91 backgroundRect.size.height = [self cr_lineWidth]; |
92 if (NSIntersectsRect(backgroundRect, dirtyRect)) { | 92 if (NSIntersectsRect(backgroundRect, dirtyRect)) { |
93 [super drawRect:backgroundRect]; | 93 [self drawBackground:backgroundRect]; |
94 } | 94 } |
95 | 95 |
96 // Pre-MD the IDR_TOOLBAR_SHADE_TOP image would lay down a light highlight | 96 // Pre-MD the IDR_TOOLBAR_SHADE_TOP image would lay down a light highlight |
97 // which helped dark toolbars stand out from dark frames. Lay down a thin | 97 // which helped dark toolbars stand out from dark frames. Lay down a thin |
98 // highlight in MD also. | 98 // highlight in MD also. |
99 if ([window isMainWindow]) { | 99 if ([window isMainWindow]) { |
100 strokeColor = themeProvider->GetNSColor( | 100 strokeColor = themeProvider->GetNSColor( |
101 ThemeProperties::COLOR_TOOLBAR_STROKE_THEME); | 101 ThemeProperties::COLOR_TOOLBAR_STROKE_THEME); |
102 } else { | 102 } else { |
103 strokeColor = themeProvider->GetNSColor( | 103 strokeColor = themeProvider->GetNSColor( |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 if (visualEffectsDisabledForFullscreen_ || | 444 if (visualEffectsDisabledForFullscreen_ || |
445 themeProvider->HasCustomImage(IDR_THEME_FRAME) || | 445 themeProvider->HasCustomImage(IDR_THEME_FRAME) || |
446 themeProvider->HasCustomColor(ThemeProperties::COLOR_FRAME)) { | 446 themeProvider->HasCustomColor(ThemeProperties::COLOR_FRAME)) { |
447 [visualEffectView setState:NSVisualEffectStateInactive]; | 447 [visualEffectView setState:NSVisualEffectStateInactive]; |
448 } else { | 448 } else { |
449 [visualEffectView setState:NSVisualEffectStateFollowsWindowActiveState]; | 449 [visualEffectView setState:NSVisualEffectStateFollowsWindowActiveState]; |
450 } | 450 } |
451 } | 451 } |
452 | 452 |
453 @end | 453 @end |
OLD | NEW |