| 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 #ifndef UI_VIEWS_CONTROLS_MENU_MENU_CONTROLLER_H_ | 5 #ifndef UI_VIEWS_CONTROLS_MENU_MENU_CONTROLLER_H_ |
| 6 #define UI_VIEWS_CONTROLS_MENU_MENU_CONTROLLER_H_ | 6 #define UI_VIEWS_CONTROLS_MENU_MENU_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 | 9 |
| 10 #include <list> | 10 #include <list> |
| 11 #include <set> | 11 #include <set> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
| 15 #include "base/memory/linked_ptr.h" |
| 15 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/timer/timer.h" | 17 #include "base/timer/timer.h" |
| 17 #include "ui/events/event.h" | 18 #include "ui/events/event.h" |
| 18 #include "ui/events/event_constants.h" | 19 #include "ui/events/event_constants.h" |
| 19 #include "ui/events/platform/platform_event_dispatcher.h" | 20 #include "ui/events/platform/platform_event_dispatcher.h" |
| 21 #include "ui/views/controls/button/menu_button.h" |
| 20 #include "ui/views/controls/menu/menu_config.h" | 22 #include "ui/views/controls/menu/menu_config.h" |
| 21 #include "ui/views/controls/menu/menu_delegate.h" | 23 #include "ui/views/controls/menu/menu_delegate.h" |
| 22 #include "ui/views/widget/widget_observer.h" | 24 #include "ui/views/widget/widget_observer.h" |
| 23 | 25 |
| 24 namespace base { | 26 namespace base { |
| 25 class MessagePumpDispatcher; | 27 class MessagePumpDispatcher; |
| 26 } | 28 } |
| 27 namespace gfx { | 29 namespace gfx { |
| 28 class Screen; | 30 class Screen; |
| 29 } | 31 } |
| (...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 | 544 |
| 543 // If the user accepted the selection, this is the result. | 545 // If the user accepted the selection, this is the result. |
| 544 MenuItemView* result_; | 546 MenuItemView* result_; |
| 545 | 547 |
| 546 // The event flags when the user selected the menu. | 548 // The event flags when the user selected the menu. |
| 547 int accept_event_flags_; | 549 int accept_event_flags_; |
| 548 | 550 |
| 549 // If not empty, it means we're nested. When Run is invoked from within | 551 // If not empty, it means we're nested. When Run is invoked from within |
| 550 // Run, the current state (state_) is pushed onto menu_stack_. This allows | 552 // Run, the current state (state_) is pushed onto menu_stack_. This allows |
| 551 // MenuController to restore the state when the nested run returns. | 553 // MenuController to restore the state when the nested run returns. |
| 552 std::list<State> menu_stack_; | 554 typedef std::pair<State, linked_ptr<MenuButton::PressedLock> > NestedState; |
| 555 std::list<NestedState> menu_stack_; |
| 553 | 556 |
| 554 // As the mouse moves around submenus are not opened immediately. Instead | 557 // As the mouse moves around submenus are not opened immediately. Instead |
| 555 // they open after this timer fires. | 558 // they open after this timer fires. |
| 556 base::OneShotTimer<MenuController> show_timer_; | 559 base::OneShotTimer<MenuController> show_timer_; |
| 557 | 560 |
| 558 // Used to invoke CancelAll(). This is used during drag and drop to hide the | 561 // Used to invoke CancelAll(). This is used during drag and drop to hide the |
| 559 // menu after the mouse moves out of the of the menu. This is necessitated by | 562 // menu after the mouse moves out of the of the menu. This is necessitated by |
| 560 // the lack of an ability to detect when the drag has completed from the drop | 563 // the lack of an ability to detect when the drag has completed from the drop |
| 561 // side. | 564 // side. |
| 562 base::OneShotTimer<MenuController> cancel_all_timer_; | 565 base::OneShotTimer<MenuController> cancel_all_timer_; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 589 gfx::Point drop_pt_; | 592 gfx::Point drop_pt_; |
| 590 int last_drop_operation_; | 593 int last_drop_operation_; |
| 591 | 594 |
| 592 // If true, we're in the middle of invoking ShowAt on a submenu. | 595 // If true, we're in the middle of invoking ShowAt on a submenu. |
| 593 bool showing_submenu_; | 596 bool showing_submenu_; |
| 594 | 597 |
| 595 // Task for scrolling the menu. If non-null indicates a scroll is currently | 598 // Task for scrolling the menu. If non-null indicates a scroll is currently |
| 596 // underway. | 599 // underway. |
| 597 scoped_ptr<MenuScrollTask> scroll_task_; | 600 scoped_ptr<MenuScrollTask> scroll_task_; |
| 598 | 601 |
| 599 MenuButton* menu_button_; | 602 // The lock to keep the menu button pressed while a menu is visible. |
| 603 scoped_ptr<MenuButton::PressedLock> pressed_lock_; |
| 600 | 604 |
| 601 // ViewStorage id used to store the view mouse drag events are forwarded to. | 605 // ViewStorage id used to store the view mouse drag events are forwarded to. |
| 602 // See UpdateActiveMouseView() for details. | 606 // See UpdateActiveMouseView() for details. |
| 603 const int active_mouse_view_id_; | 607 const int active_mouse_view_id_; |
| 604 | 608 |
| 605 internal::MenuControllerDelegate* delegate_; | 609 internal::MenuControllerDelegate* delegate_; |
| 606 | 610 |
| 607 // How deep we are in nested message loops. This should be at most 2 (when | 611 // How deep we are in nested message loops. This should be at most 2 (when |
| 608 // showing a context menu from a menu). | 612 // showing a context menu from a menu). |
| 609 int message_loop_depth_; | 613 int message_loop_depth_; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 628 bool item_selected_by_touch_; | 632 bool item_selected_by_touch_; |
| 629 | 633 |
| 630 scoped_ptr<MenuMessageLoop> message_loop_; | 634 scoped_ptr<MenuMessageLoop> message_loop_; |
| 631 | 635 |
| 632 DISALLOW_COPY_AND_ASSIGN(MenuController); | 636 DISALLOW_COPY_AND_ASSIGN(MenuController); |
| 633 }; | 637 }; |
| 634 | 638 |
| 635 } // namespace views | 639 } // namespace views |
| 636 | 640 |
| 637 #endif // UI_VIEWS_CONTROLS_MENU_MENU_CONTROLLER_H_ | 641 #endif // UI_VIEWS_CONTROLS_MENU_MENU_CONTROLLER_H_ |
| OLD | NEW |