OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_MESSAGE_LOOP_H_ | 5 #ifndef UI_VIEWS_CONTROLS_MENU_MENU_MESSAGE_LOOP_H_ |
6 #define UI_VIEWS_CONTROLS_MENU_MENU_MESSAGE_LOOP_H_ | 6 #define UI_VIEWS_CONTROLS_MENU_MENU_MESSAGE_LOOP_H_ |
7 | 7 |
| 8 #include "ui/events/event.h" |
8 #include "ui/gfx/native_widget_types.h" | 9 #include "ui/gfx/native_widget_types.h" |
9 | 10 |
10 namespace gfx { | 11 namespace gfx { |
11 class Point; | 12 class Point; |
12 } | 13 } |
13 | 14 |
14 namespace ui { | 15 namespace ui { |
15 class LocatedEvent; | 16 class LocatedEvent; |
16 } | 17 } |
17 | 18 |
18 namespace views { | 19 namespace views { |
19 | 20 |
20 class MenuController; | 21 class MenuController; |
21 class Widget; | 22 class Widget; |
22 | 23 |
23 // Interface used by MenuController to run a nested message loop while | 24 // Interface used by MenuController to run a nested message loop while |
24 // showing a menu, allowing for platform specific implementations. | 25 // showing a menu, allowing for platform specific implementations. |
25 class MenuMessageLoop { | 26 class MenuMessageLoop { |
26 public: | 27 public: |
27 virtual ~MenuMessageLoop() {} | 28 virtual ~MenuMessageLoop() {} |
28 | 29 |
29 // Create a platform specific instance. | 30 // Create a platform specific instance. |
30 static MenuMessageLoop* Create(); | 31 static MenuMessageLoop* Create(); |
31 | 32 |
32 // Repost |event| to |window|. | 33 // Repost |event| to |window|. |
33 // |screen_loc| is the event's location in screen coordinates. | 34 // |screen_loc| is the event's location in screen coordinates. |
34 static void RepostEventToWindow(const ui::LocatedEvent& event, | 35 // The |EventType| template argument indicates the type of the event. |
| 36 // For e.g. MouseEvent, TouchEvent, etc. |
| 37 template<class EventType> |
| 38 static void RepostEventToWindow(const EventType& event, |
35 gfx::NativeWindow window, | 39 gfx::NativeWindow window, |
36 const gfx::Point& screen_loc); | 40 const gfx::Point& screen_loc); |
37 | 41 |
38 // Runs the platform specific bits of the message loop. If |nested_menu| is | 42 // Runs the platform specific bits of the message loop. If |nested_menu| is |
39 // true we're being asked to run a menu from within a menu (eg a context | 43 // true we're being asked to run a menu from within a menu (eg a context |
40 // menu). | 44 // menu). |
41 virtual void Run(MenuController*, Widget* owner, bool nested_menu) = 0; | 45 virtual void Run(MenuController*, Widget* owner, bool nested_menu) = 0; |
42 | 46 |
43 // Quit an earlier call to Run(). | 47 // Quit an earlier call to Run(). |
44 virtual void QuitNow() = 0; | 48 virtual void QuitNow() = 0; |
45 | 49 |
46 // Clear any references to the owner widget that was passed into the previous | 50 // Clear any references to the owner widget that was passed into the previous |
47 // call to Run(). | 51 // call to Run(). |
48 virtual void ClearOwner() = 0; | 52 virtual void ClearOwner() = 0; |
49 }; | 53 }; |
50 | 54 |
51 } // namespace views | 55 } // namespace views |
52 | 56 |
53 #endif // UI_VIEWS_CONTROLS_MENU_MENU_MESSAGE_LOOP_H_ | 57 #endif // UI_VIEWS_CONTROLS_MENU_MENU_MESSAGE_LOOP_H_ |
OLD | NEW |