OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
sadrul
2016/08/12 15:00:35
2016
riajiang
2016/08/12 16:31:39
Done.
| |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef ASH_AUTOCLICK_COMMON_AUTOCLICK_CONTROLLER_COMMON_H | |
6 #define ASH_AUTOCLICK_COMMON_AUTOCLICK_CONTROLLER_COMMON_H | |
7 | |
8 #include "ash/autoclick/common/autoclick_ring_handler.h" | |
9 #include "base/macros.h" | |
10 #include "base/timer/timer.h" | |
11 #include "ui/events/keycodes/keyboard_codes.h" | |
12 #include "ui/gfx/geometry/point.h" | |
13 | |
14 namespace views { | |
15 class Widget; | |
16 } | |
17 | |
18 namespace ui { | |
19 class MouseEvent; | |
20 class KeyEvent; | |
21 class TouchEvent; | |
22 class GestureEvent; | |
23 class ScrollEvent; | |
24 } | |
25 | |
26 namespace ash { | |
27 | |
28 // Autoclick controller common code for ash and mus. | |
29 class AutoclickControllerCommon { | |
30 public: | |
31 class Delegate { | |
32 public: | |
33 Delegate() {} | |
34 virtual ~Delegate() {} | |
35 | |
36 // Called when given |event_location| to create a ring widget at that | |
37 // location. | |
sadrul
2016/08/12 15:00:35
* Creates a ring widget at |event_location|.
riajiang
2016/08/12 16:31:38
Done.
| |
38 virtual views::Widget* CreateAutoclickRingWidget( | |
39 const gfx::Point& event_location) = 0; | |
sadrul
2016/08/12 15:00:36
Document the ownership of the returned Widget (e.g
riajiang
2016/08/12 16:31:39
Done.
| |
40 | |
41 // Called when the |event_location| is changed to update the parent of | |
42 // the |widget| if necessary. | |
sadrul
2016/08/12 15:00:35
* Moves |widget| to |event_location|
riajiang
2016/08/12 16:31:38
Done.
| |
43 virtual void UpdateAutoclickRingWidget( | |
44 views::Widget* widget, | |
45 const gfx::Point& event_location) = 0; | |
46 | |
47 virtual void DoAutoclick(const gfx::Point& event_location, | |
sadrul
2016/08/12 15:00:36
Generates a click with |mouse_event_flags| at |eve
riajiang
2016/08/12 16:31:38
Done.
| |
48 const int mouse_event_flags) = 0; | |
49 | |
50 private: | |
51 DISALLOW_COPY_AND_ASSIGN(Delegate); | |
52 }; | |
53 | |
54 AutoclickControllerCommon(base::TimeDelta delay, Delegate* delegate); | |
55 ~AutoclickControllerCommon(); | |
56 | |
57 void HandleMouseEvent(const ui::MouseEvent& event); | |
58 void HandleKeyEvent(const ui::KeyEvent& event); | |
59 void HandleTouchEvent(const ui::TouchEvent& event); | |
60 void HandleGestureEvent(const ui::GestureEvent& event); | |
61 void HandleScrollEvent(const ui::ScrollEvent& event); | |
62 | |
63 void SetAutoclickDelay(const base::TimeDelta delay); | |
64 void StopAutoclickTimer(); | |
65 void StopGesture(); | |
66 bool IsModifierKey(const ui::KeyboardCode key_code); | |
67 | |
68 private: | |
69 void InitClickTimer(); | |
70 | |
71 void DoAutoclick(); | |
72 | |
73 void GetAutoclickRingWidget(const gfx::Point& mouse_location); | |
sadrul
2016/08/12 15:00:35
Call this UpdateRingWidget(). (Get* implies the fu
riajiang
2016/08/12 16:31:38
Done.
| |
74 | |
75 base::TimeDelta delay_; | |
76 int mouse_event_flags_; | |
77 std::unique_ptr<base::Timer> autoclick_timer_; | |
78 Delegate* delegate_; | |
79 views::Widget* widget_; | |
sadrul
2016/08/12 15:00:35
Make this a std::unique_ptr<> if this owns the wid
riajiang
2016/08/12 16:31:39
Done.
| |
80 // The position in screen coordinates used to determine | |
81 // the distance the mouse has moved. | |
82 gfx::Point anchor_location_; | |
83 std::unique_ptr<AutoclickRingHandler> autoclick_ring_handler_; | |
84 | |
85 DISALLOW_COPY_AND_ASSIGN(AutoclickControllerCommon); | |
86 }; | |
87 | |
88 } // namespace ash | |
89 | |
90 #endif // ASH_AUTOCLICK_COMMON_AUTOCLICK_CONTROLLER_COMMON_H | |
OLD | NEW |