| 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 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 }, | 307 }, |
| 308 // Currently focused window. | 308 // Currently focused window. |
| 309 { | 309 { |
| 310 IDR_THEME_TAB_BACKGROUND, // Background tab. | 310 IDR_THEME_TAB_BACKGROUND, // Background tab. |
| 311 IDR_THEME_TOOLBAR, // Active tab. | 311 IDR_THEME_TOOLBAR, // Active tab. |
| 312 }, | 312 }, |
| 313 }; | 313 }; |
| 314 | 314 |
| 315 // Themes don't have an inactive image so only look for one if there's no | 315 // Themes don't have an inactive image so only look for one if there's no |
| 316 // theme. | 316 // theme. |
| 317 bool active = [[self window] isKeyWindow] || [[self window] isMainWindow] || | 317 bool active = |
| 318 !themeProvider->UsingDefaultTheme(); | 318 [[self window] isMainWindow] || !themeProvider->UsingDefaultTheme(); |
| 319 return themeProvider->GetNSImageColorNamed(bitmapResources[active][selected]); | 319 return themeProvider->GetNSImageColorNamed(bitmapResources[active][selected]); |
| 320 } | 320 } |
| 321 | 321 |
| 322 // Draws the active tab background. | 322 // Draws the active tab background. |
| 323 - (void)drawFillForActiveTab:(NSRect)dirtyRect { | 323 - (void)drawFillForActiveTab:(NSRect)dirtyRect { |
| 324 NSColor* backgroundImageColor = [self backgroundColorForSelected:YES]; | 324 NSColor* backgroundImageColor = [self backgroundColorForSelected:YES]; |
| 325 [backgroundImageColor set]; | 325 [backgroundImageColor set]; |
| 326 | 326 |
| 327 // Themes can have partially transparent images. NSRectFill() is measurably | 327 // Themes can have partially transparent images. NSRectFill() is measurably |
| 328 // faster though, so call it for the known-safe default theme. | 328 // faster though, so call it for the known-safe default theme. |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 options:NSGradientDrawsBeforeStartingLocation]; | 422 options:NSGradientDrawsBeforeStartingLocation]; |
| 423 } | 423 } |
| 424 } | 424 } |
| 425 | 425 |
| 426 CGContextEndTransparencyLayer(cgContext); | 426 CGContextEndTransparencyLayer(cgContext); |
| 427 } | 427 } |
| 428 } | 428 } |
| 429 | 429 |
| 430 // Draws the tab outline. | 430 // Draws the tab outline. |
| 431 - (void)drawStroke:(NSRect)dirtyRect { | 431 - (void)drawStroke:(NSRect)dirtyRect { |
| 432 BOOL focused = [[self window] isKeyWindow] || [[self window] isMainWindow]; | 432 BOOL focused = [[self window] isMainWindow]; |
| 433 CGFloat alpha = focused ? 1.0 : tabs::kImageNoFocusAlpha; | 433 CGFloat alpha = focused ? 1.0 : tabs::kImageNoFocusAlpha; |
| 434 | 434 |
| 435 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 435 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 436 float height = | 436 float height = |
| 437 [rb.GetNativeImageNamed(IDR_TAB_ACTIVE_LEFT).ToNSImage() size].height; | 437 [rb.GetNativeImageNamed(IDR_TAB_ACTIVE_LEFT).ToNSImage() size].height; |
| 438 if (state_ == NSOnState) { | 438 if (state_ == NSOnState) { |
| 439 NSDrawThreePartImage(NSMakeRect(0, 0, NSWidth([self bounds]), height), | 439 NSDrawThreePartImage(NSMakeRect(0, 0, NSWidth([self bounds]), height), |
| 440 rb.GetNativeImageNamed(IDR_TAB_ACTIVE_LEFT).ToNSImage(), | 440 rb.GetNativeImageNamed(IDR_TAB_ACTIVE_LEFT).ToNSImage(), |
| 441 rb.GetNativeImageNamed(IDR_TAB_ACTIVE_CENTER).ToNSImage(), | 441 rb.GetNativeImageNamed(IDR_TAB_ACTIVE_CENTER).ToNSImage(), |
| 442 rb.GetNativeImageNamed(IDR_TAB_ACTIVE_RIGHT).ToNSImage(), | 442 rb.GetNativeImageNamed(IDR_TAB_ACTIVE_RIGHT).ToNSImage(), |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 if ([attribute isEqual:NSAccessibilityEnabledAttribute]) | 634 if ([attribute isEqual:NSAccessibilityEnabledAttribute]) |
| 635 return [NSNumber numberWithBool:YES]; | 635 return [NSNumber numberWithBool:YES]; |
| 636 | 636 |
| 637 return [super accessibilityAttributeValue:attribute]; | 637 return [super accessibilityAttributeValue:attribute]; |
| 638 } | 638 } |
| 639 | 639 |
| 640 - (ViewID)viewID { | 640 - (ViewID)viewID { |
| 641 return VIEW_ID_TAB; | 641 return VIEW_ID_TAB; |
| 642 } | 642 } |
| 643 | 643 |
| 644 // ThemedWindowDrawing implementation. |
| 645 |
| 646 - (void)windowDidChangeTheme { |
| 647 [self setNeedsDisplay:YES]; |
| 648 } |
| 649 |
| 650 - (void)windowDidChangeActive { |
| 651 [self setNeedsDisplay:YES]; |
| 652 } |
| 653 |
| 644 @end // @implementation TabView | 654 @end // @implementation TabView |
| 645 | 655 |
| 646 @implementation TabView (TabControllerInterface) | 656 @implementation TabView (TabControllerInterface) |
| 647 | 657 |
| 648 - (void)setController:(TabController*)controller { | 658 - (void)setController:(TabController*)controller { |
| 649 controller_ = controller; | 659 controller_ = controller; |
| 650 } | 660 } |
| 651 | 661 |
| 652 @end // @implementation TabView (TabControllerInterface) | 662 @end // @implementation TabView (TabControllerInterface) |
| 653 | 663 |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 787 CGFloat middleWidth = tabWidth - leftWidth - rightWidth; | 797 CGFloat middleWidth = tabWidth - leftWidth - rightWidth; |
| 788 NSRect middleRect = NSMakeRect(leftWidth, 0, middleWidth, kFillHeight); | 798 NSRect middleRect = NSMakeRect(leftWidth, 0, middleWidth, kFillHeight); |
| 789 [[NSColor whiteColor] setFill]; | 799 [[NSColor whiteColor] setFill]; |
| 790 NSRectFill(middleRect); | 800 NSRectFill(middleRect); |
| 791 | 801 |
| 792 maskCache_.reset(CGBitmapContextCreateImage(maskContext)); | 802 maskCache_.reset(CGBitmapContextCreateImage(maskContext)); |
| 793 return maskCache_; | 803 return maskCache_; |
| 794 } | 804 } |
| 795 | 805 |
| 796 @end // @implementation TabView(Private) | 806 @end // @implementation TabView(Private) |
| OLD | NEW |