| 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/mac_util.h" | 10 #include "base/mac/mac_util.h" |
| 11 #include "chrome/browser/themes/theme_service.h" | 11 #include "chrome/browser/themes/theme_service.h" |
| 12 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 12 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
| 13 #import "chrome/browser/ui/cocoa/new_tab_button.h" | 13 #import "chrome/browser/ui/cocoa/new_tab_button.h" |
| 14 #import "chrome/browser/ui/cocoa/nsview_additions.h" | 14 #import "chrome/browser/ui/cocoa/nsview_additions.h" |
| 15 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" | 15 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" |
| 16 #import "chrome/browser/ui/cocoa/tabs/tab_view.h" |
| 16 #import "chrome/browser/ui/cocoa/view_id_util.h" | 17 #import "chrome/browser/ui/cocoa/view_id_util.h" |
| 17 #include "grit/generated_resources.h" | 18 #include "grit/generated_resources.h" |
| 18 #include "grit/theme_resources.h" | 19 #include "grit/theme_resources.h" |
| 19 #include "ui/base/l10n/l10n_util_mac.h" | 20 #include "ui/base/l10n/l10n_util_mac.h" |
| 20 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" | 21 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" |
| 21 | 22 |
| 22 @implementation TabStripView | 23 @implementation TabStripView |
| 23 | 24 |
| 24 @synthesize dropArrowShown = dropArrowShown_; | 25 @synthesize dropArrowShown = dropArrowShown_; |
| 25 @synthesize dropArrowPosition = dropArrowPosition_; | 26 @synthesize dropArrowPosition = dropArrowPosition_; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 | 69 |
| 69 // Draw the border bitmap, which is partially transparent. | 70 // Draw the border bitmap, which is partially transparent. |
| 70 NSImage* image = themeProvider->GetNSImageNamed(IDR_TOOLBAR_SHADE_TOP, true); | 71 NSImage* image = themeProvider->GetNSImageNamed(IDR_TOOLBAR_SHADE_TOP, true); |
| 71 if (NSMinY(dirtyRect) >= [image size].height) | 72 if (NSMinY(dirtyRect) >= [image size].height) |
| 72 return; | 73 return; |
| 73 | 74 |
| 74 NSRect borderRect = dirtyRect; | 75 NSRect borderRect = dirtyRect; |
| 75 borderRect.size.height = [image size].height; | 76 borderRect.size.height = [image size].height; |
| 76 borderRect.origin.y = 0; | 77 borderRect.origin.y = 0; |
| 77 | 78 |
| 78 NSDrawThreePartImage(borderRect, nil, image, nil, /*vertical=*/NO, | 79 BOOL focused = [[self window] isKeyWindow] || [[self window] isMainWindow]; |
| 79 NSCompositeSourceOver, 1.0, /*flipped=*/NO); | 80 NSDrawThreePartImage(borderRect, nil, image, nil, /*vertical=*/ NO, |
| 81 NSCompositeSourceOver, |
| 82 focused ? 1.0 : tabs::kImageNoFocusAlpha, |
| 83 /*flipped=*/ NO); |
| 80 } | 84 } |
| 81 | 85 |
| 82 - (void)drawRect:(NSRect)rect { | 86 - (void)drawRect:(NSRect)rect { |
| 83 NSRect boundsRect = [self bounds]; | 87 NSRect boundsRect = [self bounds]; |
| 84 | 88 |
| 85 [self drawBorder:boundsRect]; | 89 [self drawBorder:boundsRect]; |
| 86 | 90 |
| 87 // Draw drop-indicator arrow (if appropriate). | 91 // Draw drop-indicator arrow (if appropriate). |
| 88 // TODO(viettrungluu): this is all a stop-gap measure. | 92 // TODO(viettrungluu): this is all a stop-gap measure. |
| 89 if ([self dropArrowShown]) { | 93 if ([self dropArrowShown]) { |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 | 265 |
| 262 - (void)setNewTabButton:(NewTabButton*)button { | 266 - (void)setNewTabButton:(NewTabButton*)button { |
| 263 newTabButton_.reset([button retain]); | 267 newTabButton_.reset([button retain]); |
| 264 } | 268 } |
| 265 | 269 |
| 266 - (void)setController:(TabStripController*)controller { | 270 - (void)setController:(TabStripController*)controller { |
| 267 controller_ = controller; | 271 controller_ = controller; |
| 268 } | 272 } |
| 269 | 273 |
| 270 @end | 274 @end |
| OLD | NEW |