| 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 [[NSColor colorWithCalibratedWhite:168 / 255. alpha:1] set]; | 354 const CGFloat kNormalStrokeGray = 168 / 255.; |
| 355 [path stroke]; | 355 [[NSColor colorWithCalibratedWhite:kNormalStrokeGray alpha:1] set]; |
| 356 } else { | 356 } else { |
| 357 // In dark mode the top, middle, and bottom portions of the stroke are | 357 const CGFloat k30PercentAlpha = 0.3; |
| 358 // drawn in different colors. | 358 [[NSColor colorWithCalibratedWhite:0 alpha:k30PercentAlpha] set]; |
| 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 } | |
| 403 } | 359 } |
| 360 [path stroke]; |
| 404 } else { | 361 } else { |
| 405 ui::DrawNinePartImage(frame, | 362 ui::DrawNinePartImage(frame, |
| 406 isPopupMode_ ? kPopupBorderImageIds | 363 isPopupMode_ ? kPopupBorderImageIds |
| 407 : kNormalBorderImageIds, | 364 : kNormalBorderImageIds, |
| 408 NSCompositeSourceOver, | 365 NSCompositeSourceOver, |
| 409 1.0, | 366 1.0, |
| 410 true); | 367 true); |
| 411 } | 368 } |
| 412 | 369 |
| 413 // Draw the interior contents. We do this after drawing the border as some | 370 // Draw the interior contents. We do this after drawing the border as some |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 785 | 742 |
| 786 - (void)handleFocusEvent:(NSEvent*)event | 743 - (void)handleFocusEvent:(NSEvent*)event |
| 787 ofView:(AutocompleteTextField*)controlView { | 744 ofView:(AutocompleteTextField*)controlView { |
| 788 if ([controlView observer]) { | 745 if ([controlView observer]) { |
| 789 const bool controlDown = ([event modifierFlags] & NSControlKeyMask) != 0; | 746 const bool controlDown = ([event modifierFlags] & NSControlKeyMask) != 0; |
| 790 [controlView observer]->OnSetFocus(controlDown); | 747 [controlView observer]->OnSetFocus(controlDown); |
| 791 } | 748 } |
| 792 } | 749 } |
| 793 | 750 |
| 794 @end | 751 @end |
| OLD | NEW |