| 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/location_bar/autocomplete_text_field_cell.h" | 5 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/mac/foundation_util.h" | 10 #include "base/mac/foundation_util.h" |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 [[self backgroundColor] set]; | 344 [[self backgroundColor] set]; |
| 345 if (isPopupMode_) { | 345 if (isPopupMode_) { |
| 346 NSRectFillUsingOperation(NSInsetRect(frame, 1, 1), NSCompositeSourceOver); | 346 NSRectFillUsingOperation(NSInsetRect(frame, 1, 1), NSCompositeSourceOver); |
| 347 } else { | 347 } else { |
| 348 [path fill]; | 348 [path fill]; |
| 349 } | 349 } |
| 350 | 350 |
| 351 // Draw the border. | 351 // Draw the border. |
| 352 if (isModeMaterial) { | 352 if (isModeMaterial) { |
| 353 if (!inDarkMode) { | 353 if (!inDarkMode) { |
| 354 const CGFloat kNormalStrokeGray = 168 / 255.; | 354 [[NSColor colorWithCalibratedWhite:168 / 255. alpha:1] set]; |
| 355 [[NSColor colorWithCalibratedWhite:kNormalStrokeGray alpha:1] set]; | 355 [path stroke]; |
| 356 } else { | 356 } else { |
| 357 const CGFloat k30PercentAlpha = 0.3; | 357 // In dark mode the top, middle, and bottom portions of the stroke are |
| 358 [[NSColor colorWithCalibratedWhite:0 alpha:k30PercentAlpha] set]; | 358 // drawn in different colors. |
| 359 { |
| 360 gfx::ScopedNSGraphicsContextSaveGState saveState; |
| 361 [[NSColor colorWithCalibratedWhite:52 / 255. alpha:1] set]; |
| 362 [NSBezierPath clipRect:NSMakeRect(NSMinX(frame), NSMaxY(frame) - 2, |
| 363 NSWidth(frame), 2)]; |
| 364 [path stroke]; |
| 365 } |
| 366 { |
| 367 gfx::ScopedNSGraphicsContextSaveGState saveState; |
| 368 [[NSColor colorWithCalibratedWhite:61 / 255. alpha:1] set]; |
| 369 [NSBezierPath clipRect:NSMakeRect(NSMinX(frame), NSMinY(frame) + 3, |
| 370 NSWidth(frame), NSHeight(frame) - 5)]; |
| 371 [path stroke]; |
| 372 } |
| 373 { |
| 374 gfx::ScopedNSGraphicsContextSaveGState saveState; |
| 375 [[NSColor colorWithCalibratedWhite:71 / 255. alpha:1] set]; |
| 376 [NSBezierPath clipRect:NSMakeRect(NSMinX(frame), NSMinY(frame), |
| 377 NSWidth(frame), 3)]; |
| 378 [path stroke]; |
| 379 } |
| 380 |
| 381 // Draw a highlight beneath the top edge, and a shadow beneath the bottom |
| 382 // edge when on a Retina screen. |
| 383 { |
| 384 gfx::ScopedNSGraphicsContextSaveGState saveState; |
| 385 [NSBezierPath setDefaultLineWidth:singlePixelLineWidth_]; |
| 386 |
| 387 [[NSColor colorWithCalibratedWhite:120 / 255. alpha:1] set]; |
| 388 NSPoint origin = NSMakePoint(NSMinX(pathRect) + 3, |
| 389 NSMinY(pathRect) + singlePixelLineWidth_); |
| 390 NSPoint destination = |
| 391 NSMakePoint(NSMaxX(pathRect) - 3, |
| 392 NSMinY(pathRect) + singlePixelLineWidth_); |
| 393 [NSBezierPath strokeLineFromPoint:origin |
| 394 toPoint:destination]; |
| 395 |
| 396 if (singlePixelLineWidth_ < 1) { |
| 397 origin.y = destination.y = NSMaxY(pathRect) + singlePixelLineWidth_; |
| 398 [[AutocompleteTextField shadowColor] set]; |
| 399 [NSBezierPath strokeLineFromPoint:origin |
| 400 toPoint:destination]; |
| 401 } |
| 402 } |
| 359 } | 403 } |
| 360 [path stroke]; | |
| 361 } else { | 404 } else { |
| 362 ui::DrawNinePartImage(frame, | 405 ui::DrawNinePartImage(frame, |
| 363 isPopupMode_ ? kPopupBorderImageIds | 406 isPopupMode_ ? kPopupBorderImageIds |
| 364 : kNormalBorderImageIds, | 407 : kNormalBorderImageIds, |
| 365 NSCompositeSourceOver, | 408 NSCompositeSourceOver, |
| 366 1.0, | 409 1.0, |
| 367 true); | 410 true); |
| 368 } | 411 } |
| 369 | 412 |
| 370 // Draw the interior contents. We do this after drawing the border as some | 413 // Draw the interior contents. We do this after drawing the border as some |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 737 | 780 |
| 738 - (void)handleFocusEvent:(NSEvent*)event | 781 - (void)handleFocusEvent:(NSEvent*)event |
| 739 ofView:(AutocompleteTextField*)controlView { | 782 ofView:(AutocompleteTextField*)controlView { |
| 740 if ([controlView observer]) { | 783 if ([controlView observer]) { |
| 741 const bool controlDown = ([event modifierFlags] & NSControlKeyMask) != 0; | 784 const bool controlDown = ([event modifierFlags] & NSControlKeyMask) != 0; |
| 742 [controlView observer]->OnSetFocus(controlDown); | 785 [controlView observer]->OnSetFocus(controlDown); |
| 743 } | 786 } |
| 744 } | 787 } |
| 745 | 788 |
| 746 @end | 789 @end |
| OLD | NEW |