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 "chrome/browser/themes/theme_service.h" | 10 #include "chrome/browser/themes/theme_service.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
57 CGFloat backgroundHeight = 2 * [self cr_lineWidth]; | 57 CGFloat backgroundHeight = 2 * [self cr_lineWidth]; |
58 if (NSMinY(dirtyRect) < backgroundHeight) { | 58 if (NSMinY(dirtyRect) < backgroundHeight) { |
59 gfx::ScopedNSGraphicsContextSaveGState scopedGState; | 59 gfx::ScopedNSGraphicsContextSaveGState scopedGState; |
60 NSGraphicsContext *context = [NSGraphicsContext currentContext]; | 60 NSGraphicsContext *context = [NSGraphicsContext currentContext]; |
61 NSPoint position = [[self window] themeImagePositionForAlignment: | 61 NSPoint position = [[self window] themeImagePositionForAlignment: |
62 THEME_IMAGE_ALIGN_WITH_TAB_STRIP]; | 62 THEME_IMAGE_ALIGN_WITH_TAB_STRIP]; |
63 [context cr_setPatternPhase:position forView:self]; | 63 [context cr_setPatternPhase:position forView:self]; |
64 | 64 |
65 // Themes don't have an inactive image so only look for one if there's no | 65 // Themes don't have an inactive image so only look for one if there's no |
66 // theme. | 66 // theme. |
67 bool active = [[self window] isKeyWindow] || [[self window] isMainWindow] || | 67 bool active = |
68 !themeProvider->UsingDefaultTheme(); | 68 [[self window] isMainWindow] || !themeProvider->UsingDefaultTheme(); |
Andre
2015/02/03 19:20:37
I discussed this with Robert yesterday.
The browse
| |
69 int resource_id = active ? IDR_THEME_TOOLBAR : IDR_THEME_TOOLBAR_INACTIVE; | 69 int resource_id = active ? IDR_THEME_TOOLBAR : IDR_THEME_TOOLBAR_INACTIVE; |
70 [themeProvider->GetNSImageColorNamed(resource_id) set]; | 70 [themeProvider->GetNSImageColorNamed(resource_id) set]; |
71 NSRectFill( | 71 NSRectFill( |
72 NSMakeRect(NSMinX(dirtyRect), 0, NSWidth(dirtyRect), backgroundHeight)); | 72 NSMakeRect(NSMinX(dirtyRect), 0, NSWidth(dirtyRect), backgroundHeight)); |
73 } | 73 } |
74 | 74 |
75 // Draw the border bitmap, which is partially transparent. | 75 // Draw the border bitmap, which is partially transparent. |
76 NSImage* image = themeProvider->GetNSImageNamed(IDR_TOOLBAR_SHADE_TOP); | 76 NSImage* image = themeProvider->GetNSImageNamed(IDR_TOOLBAR_SHADE_TOP); |
77 if (NSMinY(dirtyRect) >= [image size].height) | 77 if (NSMinY(dirtyRect) >= [image size].height) |
78 return; | 78 return; |
79 | 79 |
80 NSRect borderRect = dirtyRect; | 80 NSRect borderRect = dirtyRect; |
81 borderRect.size.height = [image size].height; | 81 borderRect.size.height = [image size].height; |
82 borderRect.origin.y = 0; | 82 borderRect.origin.y = 0; |
83 | 83 |
84 BOOL focused = [[self window] isKeyWindow] || [[self window] isMainWindow]; | 84 BOOL focused = [[self window] isMainWindow]; |
85 NSDrawThreePartImage(borderRect, nil, image, nil, /*vertical=*/ NO, | 85 NSDrawThreePartImage(borderRect, nil, image, nil, /*vertical=*/ NO, |
86 NSCompositeSourceOver, | 86 NSCompositeSourceOver, |
87 focused ? 1.0 : tabs::kImageNoFocusAlpha, | 87 focused ? 1.0 : tabs::kImageNoFocusAlpha, |
88 /*flipped=*/ NO); | 88 /*flipped=*/ NO); |
89 } | 89 } |
90 | 90 |
91 - (void)drawRect:(NSRect)rect { | 91 - (void)drawRect:(NSRect)rect { |
92 NSRect boundsRect = [self bounds]; | 92 NSRect boundsRect = [self bounds]; |
93 | 93 |
94 [self drawBorder:boundsRect]; | 94 [self drawBorder:boundsRect]; |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
289 } | 289 } |
290 | 290 |
291 - (void)setNewTabButton:(NewTabButton*)button { | 291 - (void)setNewTabButton:(NewTabButton*)button { |
292 newTabButton_.reset([button retain]); | 292 newTabButton_.reset([button retain]); |
293 } | 293 } |
294 | 294 |
295 - (void)setController:(TabStripController*)controller { | 295 - (void)setController:(TabStripController*)controller { |
296 controller_ = controller; | 296 controller_ = controller; |
297 } | 297 } |
298 | 298 |
299 // ThemedWindowDrawing implementation. | |
300 | |
301 - (void)windowDidChangeTheme { | |
302 [self setNeedsDisplay:YES]; | |
303 } | |
304 | |
305 - (void)windowDidChangeActive { | |
306 [self setNeedsDisplay:YES]; | |
307 } | |
308 | |
299 @end | 309 @end |
OLD | NEW |