| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ui/app_list/cocoa/apps_search_box_controller.h" | 5 #import "ui/app_list/cocoa/apps_search_box_controller.h" |
| 6 | 6 |
| 7 #include "base/mac/foundation_util.h" | 7 #include "base/mac/foundation_util.h" |
| 8 #include "base/mac/mac_util.h" | 8 #include "base/mac/mac_util.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
| 11 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSBezierPath+RoundRect
.h" | 11 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSBezierPath+RoundRect
.h" |
| 12 #include "ui/app_list/app_list_menu.h" | 12 #include "ui/app_list/app_list_menu.h" |
| 13 #include "ui/app_list/app_list_model.h" | 13 #include "ui/app_list/app_list_model.h" |
| 14 #include "ui/app_list/resources/grit/app_list_resources.h" | 14 #include "ui/app_list/resources/grit/app_list_resources.h" |
| 15 #include "ui/app_list/search_box_model.h" | 15 #include "ui/app_list/search_box_model.h" |
| 16 #include "ui/app_list/search_box_model_observer.h" | 16 #include "ui/app_list/search_box_model_observer.h" |
| 17 #include "ui/base/cocoa/cocoa_base_utils.h" |
| 17 #import "ui/base/cocoa/controls/hover_image_menu_button.h" | 18 #import "ui/base/cocoa/controls/hover_image_menu_button.h" |
| 18 #import "ui/base/cocoa/controls/hover_image_menu_button_cell.h" | 19 #import "ui/base/cocoa/controls/hover_image_menu_button_cell.h" |
| 19 #import "ui/base/cocoa/menu_controller.h" | 20 #import "ui/base/cocoa/menu_controller.h" |
| 20 #include "ui/base/resource/resource_bundle.h" | 21 #include "ui/base/resource/resource_bundle.h" |
| 21 #include "ui/gfx/image/image_skia_util_mac.h" | 22 #include "ui/gfx/image/image_skia_util_mac.h" |
| 22 | 23 |
| 23 namespace { | 24 namespace { |
| 24 | 25 |
| 25 // Padding either side of the search icon and menu button. | 26 // Padding either side of the search icon and menu button. |
| 26 const CGFloat kPadding = 14; | 27 const CGFloat kPadding = 14; |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 return self; | 383 return self; |
| 383 } | 384 } |
| 384 | 385 |
| 385 - (NSRect)confinementRectForMenu:(NSMenu*)menu | 386 - (NSRect)confinementRectForMenu:(NSMenu*)menu |
| 386 onScreen:(NSScreen*)screen { | 387 onScreen:(NSScreen*)screen { |
| 387 NSPopUpButton* menuButton = [searchBoxController_ menuControl]; | 388 NSPopUpButton* menuButton = [searchBoxController_ menuControl]; |
| 388 // Ensure the menu comes up below the menu button by trimming the window frame | 389 // Ensure the menu comes up below the menu button by trimming the window frame |
| 389 // to a point anchored below the bottom right of the button. | 390 // to a point anchored below the bottom right of the button. |
| 390 NSRect anchorRect = [menuButton convertRect:[menuButton bounds] | 391 NSRect anchorRect = [menuButton convertRect:[menuButton bounds] |
| 391 toView:nil]; | 392 toView:nil]; |
| 392 NSPoint anchorPoint = [[menuButton window] convertBaseToScreen:NSMakePoint( | 393 NSPoint anchorPoint = ui::ConvertPointFromWindowToScreen( |
| 393 NSMaxX(anchorRect) + kMenuXOffsetFromButton, | 394 [menuButton window], |
| 394 NSMinY(anchorRect) - kMenuYOffsetFromButton)]; | 395 NSMakePoint(NSMaxX(anchorRect) + kMenuXOffsetFromButton, |
| 396 NSMinY(anchorRect) - kMenuYOffsetFromButton)); |
| 397 |
| 395 NSRect confinementRect = [[menuButton window] frame]; | 398 NSRect confinementRect = [[menuButton window] frame]; |
| 396 confinementRect.size = NSMakeSize(anchorPoint.x - NSMinX(confinementRect), | 399 confinementRect.size = NSMakeSize(anchorPoint.x - NSMinX(confinementRect), |
| 397 anchorPoint.y - NSMinY(confinementRect)); | 400 anchorPoint.y - NSMinY(confinementRect)); |
| 398 return confinementRect; | 401 return confinementRect; |
| 399 } | 402 } |
| 400 | 403 |
| 401 @end | 404 @end |
| OLD | NEW |