Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(196)

Side by Side Diff: ash/autoclick/common/autoclick_controller_common.h

Issue 2193563002: ash: Refactor autoclick common code to ash/autoclick/common. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: interface Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
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.
sky 2016/08/15 19:27:00 Please update this code to better document what au
riajiang 2016/08/16 00:44:24 Done.
29 class AutoclickControllerCommon {
30 public:
31 class Delegate {
sky 2016/08/15 19:27:00 It's preferable to put delegates/observers into th
riajiang 2016/08/16 00:44:24 Done.
32 public:
33 Delegate() {}
34 virtual ~Delegate() {}
35
36 // Creates a ring widget at |event_location|. AutoclickControllerCommon
37 // takes ownership of the created widget.
38 virtual std::unique_ptr<views::Widget> CreateAutoclickRingWidget(
39 const gfx::Point& event_location) = 0;
40
41 // Moves |widget| to |event_location|.
42 virtual void UpdateAutoclickRingWidget(
43 views::Widget* widget,
44 const gfx::Point& event_location) = 0;
45
46 // Generates a click with |mouse_event_flags| at |event_location|.
47 virtual void DoAutoclick(const gfx::Point& event_location,
48 const int mouse_event_flags) = 0;
49
50 virtual void OnAutoclickCanceled() = 0;
51
52 private:
53 DISALLOW_COPY_AND_ASSIGN(Delegate);
54 };
55
56 AutoclickControllerCommon(base::TimeDelta delay, Delegate* delegate);
57 ~AutoclickControllerCommon();
58
59 void HandleMouseEvent(const ui::MouseEvent& event);
60 void HandleKeyEvent(const ui::KeyEvent& event);
61 void HandleTouchEvent(const ui::TouchEvent& event);
sky 2016/08/15 19:27:00 Can touch/gesture/scroll be removed and instead ca
riajiang 2016/08/16 00:44:24 Done.
62 void HandleGestureEvent(const ui::GestureEvent& event);
63 void HandleScrollEvent(const ui::ScrollEvent& event);
64
65 void SetAutoclickDelay(const base::TimeDelta delay);
66 void CancelAutoclick();
67
68 private:
69 void InitClickTimer();
70
71 void DoAutoclick();
72
73 void UpdateRingWidget(const gfx::Point& mouse_location);
74
75 base::TimeDelta delay_;
76 int mouse_event_flags_;
77 std::unique_ptr<base::Timer> autoclick_timer_;
78 Delegate* delegate_;
79 std::unique_ptr<views::Widget> widget_;
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698