Chromium Code Reviews| 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/strings/sys_string_conversions.h" | |
| 10 #include "grit/ui_resources.h" | 9 #include "grit/ui_resources.h" |
| 11 #import "third_party/GTM/AppKit/GTMNSBezierPath+RoundRect.h" | 10 #import "third_party/GTM/AppKit/GTMNSBezierPath+RoundRect.h" |
| 12 #include "ui/app_list/app_list_menu.h" | 11 #include "ui/app_list/app_list_menu.h" |
| 13 #import "ui/app_list/cocoa/current_user_menu_item_view.h" | 12 #import "ui/app_list/cocoa/current_user_menu_item_view.h" |
| 13 #include "ui/app_list/app_list_model.h" | |
|
tapted
2013/08/14 03:53:11
I think you can get by without changing #includes
calamity
2013/08/14 09:19:00
Done.
| |
| 14 #include "ui/app_list/app_list_view_delegate.h" | |
| 14 #include "ui/app_list/search_box_model.h" | 15 #include "ui/app_list/search_box_model.h" |
| 15 #include "ui/app_list/search_box_model_observer.h" | 16 #include "ui/app_list/search_box_model_observer.h" |
| 16 #import "ui/base/cocoa/controls/hover_image_menu_button.h" | 17 #import "ui/base/cocoa/controls/hover_image_menu_button.h" |
| 17 #import "ui/base/cocoa/controls/hover_image_menu_button_cell.h" | 18 #import "ui/base/cocoa/controls/hover_image_menu_button_cell.h" |
| 18 #import "ui/base/cocoa/menu_controller.h" | 19 #import "ui/base/cocoa/menu_controller.h" |
| 19 #include "ui/base/resource/resource_bundle.h" | 20 #include "ui/base/resource/resource_bundle.h" |
| 20 #include "ui/gfx/image/image_skia_util_mac.h" | 21 #include "ui/gfx/image/image_skia_util_mac.h" |
| 21 | 22 |
| 22 namespace { | 23 namespace { |
| 23 | 24 |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 366 - (void)addItemToMenu:(NSMenu*)menu | 367 - (void)addItemToMenu:(NSMenu*)menu |
| 367 atIndex:(NSInteger)index | 368 atIndex:(NSInteger)index |
| 368 fromModel:(ui::MenuModel*)model { | 369 fromModel:(ui::MenuModel*)model { |
| 369 [super addItemToMenu:menu | 370 [super addItemToMenu:menu |
| 370 atIndex:index | 371 atIndex:index |
| 371 fromModel:model]; | 372 fromModel:model]; |
| 372 if (model->GetCommandIdAt(index) != app_list::AppListMenu::CURRENT_USER) | 373 if (model->GetCommandIdAt(index) != app_list::AppListMenu::CURRENT_USER) |
| 373 return; | 374 return; |
| 374 | 375 |
| 375 base::scoped_nsobject<NSView> customItemView([[CurrentUserMenuItemView alloc] | 376 base::scoped_nsobject<NSView> customItemView([[CurrentUserMenuItemView alloc] |
| 376 initWithDelegate:[[searchBoxController_ delegate] appListDelegate]]); | 377 initWithCurrentUser:[[searchBoxController_ delegate] currentUserName] |
| 378 userEmail:[[searchBoxController_ delegate] currentUserEmail]]); | |
| 377 [[menu itemAtIndex:index] setView:customItemView]; | 379 [[menu itemAtIndex:index] setView:customItemView]; |
| 378 } | 380 } |
| 379 | 381 |
| 380 - (NSRect)confinementRectForMenu:(NSMenu*)menu | 382 - (NSRect)confinementRectForMenu:(NSMenu*)menu |
| 381 onScreen:(NSScreen*)screen { | 383 onScreen:(NSScreen*)screen { |
| 382 NSPopUpButton* menuButton = [searchBoxController_ menuControl]; | 384 NSPopUpButton* menuButton = [searchBoxController_ menuControl]; |
| 383 // Ensure the menu comes up below the menu button by trimming the window frame | 385 // Ensure the menu comes up below the menu button by trimming the window frame |
| 384 // to a point anchored below the bottom right of the button. | 386 // to a point anchored below the bottom right of the button. |
| 385 NSRect anchorRect = [menuButton convertRect:[menuButton bounds] | 387 NSRect anchorRect = [menuButton convertRect:[menuButton bounds] |
| 386 toView:nil]; | 388 toView:nil]; |
| 387 NSPoint anchorPoint = [[menuButton window] convertBaseToScreen:NSMakePoint( | 389 NSPoint anchorPoint = [[menuButton window] convertBaseToScreen:NSMakePoint( |
| 388 NSMaxX(anchorRect), | 390 NSMaxX(anchorRect), |
| 389 NSMinY(anchorRect) - kMenuOffsetFromButton)]; | 391 NSMinY(anchorRect) - kMenuOffsetFromButton)]; |
| 390 NSRect confinementRect = [[menuButton window] frame]; | 392 NSRect confinementRect = [[menuButton window] frame]; |
| 391 confinementRect.size = NSMakeSize(anchorPoint.x - NSMinX(confinementRect), | 393 confinementRect.size = NSMakeSize(anchorPoint.x - NSMinX(confinementRect), |
| 392 anchorPoint.y - NSMinY(confinementRect)); | 394 anchorPoint.y - NSMinY(confinementRect)); |
| 393 return confinementRect; | 395 return confinementRect; |
| 394 } | 396 } |
| 395 | 397 |
| 396 @end | 398 @end |
| OLD | NEW |