| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/profile_menu_button.h" | 5 #import "chrome/browser/ui/cocoa/profile_menu_button.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #import "third_party/GTM/AppKit/GTMFadeTruncatingTextFieldCell.h" | 9 #import "third_party/GTM/AppKit/GTMFadeTruncatingTextFieldCell.h" |
| 10 | 10 |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 | 208 |
| 209 - (NSImage*)tabImageWithSize:(NSSize)tabSize | 209 - (NSImage*)tabImageWithSize:(NSSize)tabSize |
| 210 fillColor:(NSColor*)fillColor | 210 fillColor:(NSColor*)fillColor |
| 211 isPressed:(BOOL)isPressed { | 211 isPressed:(BOOL)isPressed { |
| 212 NSImage* image = [[[NSImage alloc] initWithSize:tabSize] autorelease]; | 212 NSImage* image = [[[NSImage alloc] initWithSize:tabSize] autorelease]; |
| 213 [image lockFocus]; | 213 [image lockFocus]; |
| 214 | 214 |
| 215 // White shadow for inset look | 215 // White shadow for inset look |
| 216 [[NSGraphicsContext currentContext] saveGraphicsState]; | 216 [[NSGraphicsContext currentContext] saveGraphicsState]; |
| 217 scoped_nsobject<NSShadow> tabShadow([[NSShadow alloc] init]); | 217 scoped_nsobject<NSShadow> tabShadow([[NSShadow alloc] init]); |
| 218 [tabShadow setShadowOffset:NSMakeSize(0, -1)]; | 218 [tabShadow.get() setShadowOffset:NSMakeSize(0, -1)]; |
| 219 [tabShadow setShadowBlurRadius:0]; | 219 [tabShadow setShadowBlurRadius:0]; |
| 220 [tabShadow setShadowColor:GetWhiteWithAlpha(0.6)]; | 220 [tabShadow.get() setShadowColor:GetWhiteWithAlpha(0.6)]; |
| 221 [tabShadow set]; | 221 [tabShadow set]; |
| 222 | 222 |
| 223 // Gray outline | 223 // Gray outline |
| 224 NSRect tabRect = NSMakeRect(0, 1, tabSize.width, tabSize.height - 1); | 224 NSRect tabRect = NSMakeRect(0, 1, tabSize.width, tabSize.height - 1); |
| 225 NSBezierPath* outlinePath = [self tabPathWithRect:tabRect | 225 NSBezierPath* outlinePath = [self tabPathWithRect:tabRect |
| 226 radius:kTabRoundRectRadius]; | 226 radius:kTabRoundRectRadius]; |
| 227 [[NSColor colorWithCalibratedWhite:0.44 alpha:1.0] set]; | 227 [[NSColor colorWithCalibratedWhite:0.44 alpha:1.0] set]; |
| 228 [outlinePath fill]; | 228 [outlinePath fill]; |
| 229 | 229 |
| 230 [[NSGraphicsContext currentContext] restoreGraphicsState]; | 230 [[NSGraphicsContext currentContext] restoreGraphicsState]; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 247 // Highlight on top | 247 // Highlight on top |
| 248 NSRect highlightRect = NSInsetRect(tabRect, 1, 0); | 248 NSRect highlightRect = NSInsetRect(tabRect, 1, 0); |
| 249 highlightRect.size.height = 1; | 249 highlightRect.size.height = 1; |
| 250 highlightRect.origin.y = NSMaxY(tabRect) - highlightRect.size.height; | 250 highlightRect.origin.y = NSMaxY(tabRect) - highlightRect.size.height; |
| 251 [GetWhiteWithAlpha(0.5) set]; | 251 [GetWhiteWithAlpha(0.5) set]; |
| 252 NSRectFillUsingOperation(highlightRect, NSCompositeSourceOver); | 252 NSRectFillUsingOperation(highlightRect, NSCompositeSourceOver); |
| 253 | 253 |
| 254 // Arrow shadow | 254 // Arrow shadow |
| 255 [[NSGraphicsContext currentContext] saveGraphicsState]; | 255 [[NSGraphicsContext currentContext] saveGraphicsState]; |
| 256 scoped_nsobject<NSShadow> arrowShadow([[NSShadow alloc] init]); | 256 scoped_nsobject<NSShadow> arrowShadow([[NSShadow alloc] init]); |
| 257 [arrowShadow setShadowOffset:NSMakeSize(0, -1)]; | 257 [arrowShadow.get() setShadowOffset:NSMakeSize(0, -1)]; |
| 258 [arrowShadow setShadowBlurRadius:0]; | 258 [arrowShadow setShadowBlurRadius:0]; |
| 259 [arrowShadow setShadowColor:GetBlackWithAlpha(0.6)]; | 259 [arrowShadow.get() setShadowColor:GetBlackWithAlpha(0.6)]; |
| 260 [arrowShadow set]; | 260 [arrowShadow set]; |
| 261 | 261 |
| 262 // Down arrow | 262 // Down arrow |
| 263 NSRect arrowRect; | 263 NSRect arrowRect; |
| 264 arrowRect.size.width = kTabArrowWidth; | 264 arrowRect.size.width = kTabArrowWidth; |
| 265 arrowRect.size.height = kTabArrowHeight; | 265 arrowRect.size.height = kTabArrowHeight; |
| 266 arrowRect.origin.x = NSMinX(tabRect) + roundf((NSWidth(tabRect) - | 266 arrowRect.origin.x = NSMinX(tabRect) + roundf((NSWidth(tabRect) - |
| 267 NSWidth(arrowRect)) / 2.0); | 267 NSWidth(arrowRect)) / 2.0); |
| 268 arrowRect.origin.y = NSMinY(tabRect) + roundf((tabRect.size.height - | 268 arrowRect.origin.y = NSMinY(tabRect) + roundf((tabRect.size.height - |
| 269 arrowRect.size.height) / 2.0); | 269 arrowRect.size.height) / 2.0); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 size.width = ceil(size.width); | 373 size.width = ceil(size.width); |
| 374 size.height = ceil(size.height); | 374 size.height = ceil(size.height); |
| 375 return size; | 375 return size; |
| 376 } | 376 } |
| 377 | 377 |
| 378 - (NSSize)minControlSize { | 378 - (NSSize)minControlSize { |
| 379 return [self tabRect].size; | 379 return [self tabRect].size; |
| 380 } | 380 } |
| 381 | 381 |
| 382 @end | 382 @end |
| OLD | NEW |