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 #include "ui/views/controls/menu/menu_controller.h" | 5 #include "ui/views/controls/menu/menu_controller.h" |
6 | 6 |
7 #include "base/i18n/case_conversion.h" | 7 #include "base/i18n/case_conversion.h" |
8 #include "base/i18n/rtl.h" | 8 #include "base/i18n/rtl.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/time.h" | 10 #include "base/time.h" |
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 } | 523 } |
524 | 524 |
525 void MenuController::OnMouseEntered(SubmenuView* source, | 525 void MenuController::OnMouseEntered(SubmenuView* source, |
526 const ui::MouseEvent& event) { | 526 const ui::MouseEvent& event) { |
527 // MouseEntered is always followed by a mouse moved, so don't need to | 527 // MouseEntered is always followed by a mouse moved, so don't need to |
528 // do anything here. | 528 // do anything here. |
529 } | 529 } |
530 | 530 |
531 #if defined(OS_LINUX) | 531 #if defined(OS_LINUX) |
532 bool MenuController::OnMouseWheel(SubmenuView* source, | 532 bool MenuController::OnMouseWheel(SubmenuView* source, |
533 const MouseWheelEvent& event) { | 533 const ui::MouseWheelEvent& event) { |
534 MenuPart part = GetMenuPart(source, event.location()); | 534 MenuPart part = GetMenuPart(source, event.location()); |
535 return part.submenu && part.submenu->OnMouseWheel(event); | 535 return part.submenu && part.submenu->OnMouseWheel(event); |
536 } | 536 } |
537 #endif | 537 #endif |
538 | 538 |
539 ui::GestureStatus MenuController::OnGestureEvent(SubmenuView* source, | 539 ui::GestureStatus MenuController::OnGestureEvent( |
540 const GestureEvent& event) { | 540 SubmenuView* source, |
| 541 const ui::GestureEvent& event) { |
541 MenuPart part = GetMenuPart(source, event.location()); | 542 MenuPart part = GetMenuPart(source, event.location()); |
542 if (event.type() == ui::ET_GESTURE_TAP_DOWN) { | 543 if (event.type() == ui::ET_GESTURE_TAP_DOWN) { |
543 SetSelectionOnPointerDown(source, event); | 544 SetSelectionOnPointerDown(source, event); |
544 return ui::GESTURE_STATUS_CONSUMED; | 545 return ui::GESTURE_STATUS_CONSUMED; |
545 } else if (event.type() == ui::ET_GESTURE_LONG_PRESS) { | 546 } else if (event.type() == ui::ET_GESTURE_LONG_PRESS) { |
546 if (part.type == MenuPart::MENU_ITEM && part.menu) { | 547 if (part.type == MenuPart::MENU_ITEM && part.menu) { |
547 if (ShowContextMenu(part.menu, source, event)) | 548 if (ShowContextMenu(part.menu, source, event)) |
548 return ui::GESTURE_STATUS_CONSUMED; | 549 return ui::GESTURE_STATUS_CONSUMED; |
549 } | 550 } |
550 } else if (event.type() == ui::ET_GESTURE_TAP) { | 551 } else if (event.type() == ui::ET_GESTURE_TAP) { |
(...skipping 28 matching lines...) Expand all Loading... |
579 return source->GetMenuItem()->GetDelegate()->AreDropTypesRequired( | 580 return source->GetMenuItem()->GetDelegate()->AreDropTypesRequired( |
580 source->GetMenuItem()); | 581 source->GetMenuItem()); |
581 } | 582 } |
582 | 583 |
583 bool MenuController::CanDrop(SubmenuView* source, const OSExchangeData& data) { | 584 bool MenuController::CanDrop(SubmenuView* source, const OSExchangeData& data) { |
584 return source->GetMenuItem()->GetDelegate()->CanDrop(source->GetMenuItem(), | 585 return source->GetMenuItem()->GetDelegate()->CanDrop(source->GetMenuItem(), |
585 data); | 586 data); |
586 } | 587 } |
587 | 588 |
588 void MenuController::OnDragEntered(SubmenuView* source, | 589 void MenuController::OnDragEntered(SubmenuView* source, |
589 const DropTargetEvent& event) { | 590 const ui::DropTargetEvent& event) { |
590 valid_drop_coordinates_ = false; | 591 valid_drop_coordinates_ = false; |
591 } | 592 } |
592 | 593 |
593 int MenuController::OnDragUpdated(SubmenuView* source, | 594 int MenuController::OnDragUpdated(SubmenuView* source, |
594 const DropTargetEvent& event) { | 595 const ui::DropTargetEvent& event) { |
595 StopCancelAllTimer(); | 596 StopCancelAllTimer(); |
596 | 597 |
597 gfx::Point screen_loc(event.location()); | 598 gfx::Point screen_loc(event.location()); |
598 View::ConvertPointToScreen(source, &screen_loc); | 599 View::ConvertPointToScreen(source, &screen_loc); |
599 if (valid_drop_coordinates_ && screen_loc == drop_pt_) | 600 if (valid_drop_coordinates_ && screen_loc == drop_pt_) |
600 return last_drop_operation_; | 601 return last_drop_operation_; |
601 drop_pt_ = screen_loc; | 602 drop_pt_ = screen_loc; |
602 valid_drop_coordinates_ = true; | 603 valid_drop_coordinates_ = true; |
603 | 604 |
604 MenuItemView* menu_item = GetMenuItemAt(source, event.x(), event.y()); | 605 MenuItemView* menu_item = GetMenuItemAt(source, event.x(), event.y()); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 void MenuController::OnDragExited(SubmenuView* source) { | 652 void MenuController::OnDragExited(SubmenuView* source) { |
652 StartCancelAllTimer(); | 653 StartCancelAllTimer(); |
653 | 654 |
654 if (drop_target_) { | 655 if (drop_target_) { |
655 StopShowTimer(); | 656 StopShowTimer(); |
656 SetDropMenuItem(NULL, MenuDelegate::DROP_NONE); | 657 SetDropMenuItem(NULL, MenuDelegate::DROP_NONE); |
657 } | 658 } |
658 } | 659 } |
659 | 660 |
660 int MenuController::OnPerformDrop(SubmenuView* source, | 661 int MenuController::OnPerformDrop(SubmenuView* source, |
661 const DropTargetEvent& event) { | 662 const ui::DropTargetEvent& event) { |
662 DCHECK(drop_target_); | 663 DCHECK(drop_target_); |
663 // NOTE: the delegate may delete us after invoking OnPerformDrop, as such | 664 // NOTE: the delegate may delete us after invoking OnPerformDrop, as such |
664 // we don't call cancel here. | 665 // we don't call cancel here. |
665 | 666 |
666 MenuItemView* item = state_.item; | 667 MenuItemView* item = state_.item; |
667 DCHECK(item); | 668 DCHECK(item); |
668 | 669 |
669 MenuItemView* drop_target = drop_target_; | 670 MenuItemView* drop_target = drop_target_; |
670 MenuDelegate::DropPosition drop_position = drop_position_; | 671 MenuDelegate::DropPosition drop_position = drop_position_; |
671 | 672 |
(...skipping 1471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2143 | 2144 |
2144 #if defined(USE_AURA) | 2145 #if defined(USE_AURA) |
2145 void MenuController::OnWindowActivated(aura::Window* active, | 2146 void MenuController::OnWindowActivated(aura::Window* active, |
2146 aura::Window* old_active) { | 2147 aura::Window* old_active) { |
2147 if (!drag_in_progress_) | 2148 if (!drag_in_progress_) |
2148 Cancel(EXIT_ALL); | 2149 Cancel(EXIT_ALL); |
2149 } | 2150 } |
2150 #endif | 2151 #endif |
2151 | 2152 |
2152 } // namespace views | 2153 } // namespace views |
OLD | NEW |