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

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: ownership; comments; renames etc 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
« no previous file with comments | « ash/autoclick/common/DEPS ('k') | ash/autoclick/common/autoclick_controller_common.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
29 class AutoclickControllerCommon {
30 public:
31 class Delegate {
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
sadrul 2016/08/15 15:25:10 Let's add OnAutoClickCanceled() here too, which wi
riajiang 2016/08/15 17:16:23 Makes sense! Done.
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 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
« no previous file with comments | « ash/autoclick/common/DEPS ('k') | ash/autoclick/common/autoclick_controller_common.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698