| 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_view.h" | 5 #import "chrome/browser/ui/cocoa/tabs/tab_view.h" |
| 6 | 6 |
| 7 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/mac/sdk_forward_declarations.h" | 9 #include "base/mac/sdk_forward_declarations.h" |
| 10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 } | 100 } |
| 101 | 101 |
| 102 ui::ThreePartImage& GetMaskImage() { | 102 ui::ThreePartImage& GetMaskImage() { |
| 103 CR_DEFINE_STATIC_LOCAL(ui::ThreePartImage, mask, | 103 CR_DEFINE_STATIC_LOCAL(ui::ThreePartImage, mask, |
| 104 (imageForResourceID(IDR_TAB_ALPHA_LEFT), nullptr, | 104 (imageForResourceID(IDR_TAB_ALPHA_LEFT), nullptr, |
| 105 imageForResourceID(IDR_TAB_ALPHA_RIGHT))); | 105 imageForResourceID(IDR_TAB_ALPHA_RIGHT))); |
| 106 | 106 |
| 107 return mask; | 107 return mask; |
| 108 } | 108 } |
| 109 | 109 |
| 110 ui::ThreePartImage& GetStrokeImage() { | 110 ui::ThreePartImage& GetStrokeImage(bool active) { |
| 111 if (!ui::MaterialDesignController::IsModeMaterial() && !active) { |
| 112 CR_DEFINE_STATIC_LOCAL( |
| 113 ui::ThreePartImage, inactiveStroke, |
| 114 (imageForResourceID(IDR_TAB_INACTIVE_LEFT), |
| 115 imageForResourceID(IDR_TAB_INACTIVE_CENTER), |
| 116 imageForResourceID(IDR_TAB_INACTIVE_RIGHT))); |
| 117 return inactiveStroke; |
| 118 } |
| 111 CR_DEFINE_STATIC_LOCAL( | 119 CR_DEFINE_STATIC_LOCAL( |
| 112 ui::ThreePartImage, stroke, | 120 ui::ThreePartImage, stroke, |
| 113 (imageForResourceID(IDR_TAB_ACTIVE_LEFT), | 121 (imageForResourceID(IDR_TAB_ACTIVE_LEFT), |
| 114 imageForResourceID(IDR_TAB_ACTIVE_CENTER), | 122 imageForResourceID(IDR_TAB_ACTIVE_CENTER), |
| 115 imageForResourceID(IDR_TAB_ACTIVE_RIGHT))); | 123 imageForResourceID(IDR_TAB_ACTIVE_RIGHT))); |
| 116 | 124 |
| 117 return stroke; | 125 return stroke; |
| 118 } | 126 } |
| 119 | 127 |
| 120 CGFloat LineWidthFromContext(CGContextRef context) { | 128 CGFloat LineWidthFromContext(CGContextRef context) { |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 NSRect bounds = [self bounds]; | 478 NSRect bounds = [self bounds]; |
| 471 if (ui::MaterialDesignController::IsModeMaterial()) { | 479 if (ui::MaterialDesignController::IsModeMaterial()) { |
| 472 // In Material Design the tab strip separator is always 1 pixel high - | 480 // In Material Design the tab strip separator is always 1 pixel high - |
| 473 // add a clip rect to avoid drawing the tab edge over it. | 481 // add a clip rect to avoid drawing the tab edge over it. |
| 474 NSRect clipRect = bounds; | 482 NSRect clipRect = bounds; |
| 475 clipRect.origin.y += [self cr_lineWidth]; | 483 clipRect.origin.y += [self cr_lineWidth]; |
| 476 NSRectClip(clipRect); | 484 NSRectClip(clipRect); |
| 477 // In MD, the tab stroke is always opaque. | 485 // In MD, the tab stroke is always opaque. |
| 478 alpha = 1; | 486 alpha = 1; |
| 479 } | 487 } |
| 480 GetStrokeImage().DrawInRect(bounds, NSCompositeSourceOver, alpha); | 488 GetStrokeImage(state_ == NSOnState) |
| 489 .DrawInRect(bounds, NSCompositeSourceOver, alpha); |
| 481 } | 490 } |
| 482 | 491 |
| 483 - (void)drawRect:(NSRect)dirtyRect { | 492 - (void)drawRect:(NSRect)dirtyRect { |
| 484 [self drawFill:dirtyRect]; | 493 [self drawFill:dirtyRect]; |
| 485 [self drawStroke:dirtyRect]; | 494 [self drawStroke:dirtyRect]; |
| 486 | 495 |
| 487 // We draw the title string directly instead of using a NSTextField subview. | 496 // We draw the title string directly instead of using a NSTextField subview. |
| 488 // This is so that we can get font smoothing to work on earlier OS, and even | 497 // This is so that we can get font smoothing to work on earlier OS, and even |
| 489 // when the tab background is a pattern image (when using themes). | 498 // when the tab background is a pattern image (when using themes). |
| 490 if (![titleView_ isHidden]) { | 499 if (![titleView_ isHidden]) { |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 928 NSAffineTransform* transform = [NSAffineTransform transform]; | 937 NSAffineTransform* transform = [NSAffineTransform transform]; |
| 929 [transform scaleXBy:-1 yBy:1]; | 938 [transform scaleXBy:-1 yBy:1]; |
| 930 [transform translateXBy:-17.5 yBy:-0.25]; | 939 [transform translateXBy:-17.5 yBy:-0.25]; |
| 931 [bezierPath transformUsingAffineTransform:transform]; | 940 [bezierPath transformUsingAffineTransform:transform]; |
| 932 | 941 |
| 933 [[NSColor whiteColor] set]; | 942 [[NSColor whiteColor] set]; |
| 934 [bezierPath fill]; | 943 [bezierPath fill]; |
| 935 } | 944 } |
| 936 | 945 |
| 937 @end // @implementation TabView(MaterialDesign) | 946 @end // @implementation TabView(MaterialDesign) |
| OLD | NEW |