| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 ASH_AUTOCLICK_AUTOCLICK_CONTROLLER_H | 5 #ifndef ASH_AUTOCLICK_AUTOCLICK_CONTROLLER_H |
| 6 #define ASH_AUTOCLICK_AUTOCLICK_CONTROLLER_H | 6 #define ASH_AUTOCLICK_AUTOCLICK_CONTROLLER_H |
| 7 | 7 |
| 8 #include <memory> | |
| 9 | |
| 10 #include "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
| 11 #include "base/macros.h" | 9 #include "base/macros.h" |
| 12 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| 13 #include "ui/gfx/geometry/point.h" | |
| 14 | 11 |
| 15 namespace ash { | 12 namespace ash { |
| 16 | 13 |
| 17 // Controls the autoclick a11y feature in ash. | 14 // Controls the autoclick a11y feature in ash. |
| 18 // If enabled, we will automatically send a click event a short time after | 15 // If enabled, we will automatically send a click event a short time after |
| 19 // the mouse had been at rest. | 16 // the mouse had been at rest. |
| 20 class ASH_EXPORT AutoclickController { | 17 class ASH_EXPORT AutoclickController { |
| 21 public: | 18 public: |
| 22 class Delegate { | |
| 23 public: | |
| 24 Delegate() {} | |
| 25 virtual ~Delegate() {} | |
| 26 | |
| 27 // Called when an autoclick gesture begins. | |
| 28 virtual void StartGesture(base::TimeDelta duration, | |
| 29 const gfx::Point& center_point_in_screen) = 0; | |
| 30 | |
| 31 // Called when the gesture has ended, either because the mouse moved or | |
| 32 // because the autoclick completed. | |
| 33 virtual void StopGesture() = 0; | |
| 34 | |
| 35 // Called when the autoclick target has changed. | |
| 36 virtual void SetGestureCenter(const gfx::Point& center_point_in_screen) = 0; | |
| 37 | |
| 38 private: | |
| 39 DISALLOW_COPY_AND_ASSIGN(Delegate); | |
| 40 }; | |
| 41 | |
| 42 virtual ~AutoclickController() {} | 19 virtual ~AutoclickController() {} |
| 43 | 20 |
| 44 // Set the delegate to work with. | |
| 45 virtual void SetDelegate(std::unique_ptr<Delegate> delegate) = 0; | |
| 46 | |
| 47 // Set whether autoclicking is enabled. | 21 // Set whether autoclicking is enabled. |
| 48 virtual void SetEnabled(bool enabled) = 0; | 22 virtual void SetEnabled(bool enabled) = 0; |
| 49 | 23 |
| 50 // Returns true if autoclicking is enabled. | 24 // Returns true if autoclicking is enabled. |
| 51 virtual bool IsEnabled() const = 0; | 25 virtual bool IsEnabled() const = 0; |
| 52 | 26 |
| 53 // Set the time to wait in milliseconds from when the mouse stops moving | 27 // Set the time to wait in milliseconds from when the mouse stops moving |
| 54 // to when the autoclick event is sent. | 28 // to when the autoclick event is sent. |
| 55 virtual void SetAutoclickDelay(base::TimeDelta delay) = 0; | 29 virtual void SetAutoclickDelay(base::TimeDelta delay) = 0; |
| 56 | 30 |
| 57 // Returns the autoclick delay in milliseconds. | |
| 58 virtual base::TimeDelta GetAutoclickDelay() const = 0; | |
| 59 | |
| 60 static AutoclickController* CreateInstance(); | 31 static AutoclickController* CreateInstance(); |
| 61 | 32 |
| 62 // The default wait time between last mouse movement and sending | 33 // The default wait time between last mouse movement and sending |
| 63 // the autoclick. | 34 // the autoclick. |
| 64 static const int kDefaultAutoclickDelayMs; | 35 static const int kDefaultAutoclickDelayMs; |
| 65 | 36 |
| 66 // Gets the default wait time as a base::TimeDelta object. | 37 // Gets the default wait time as a base::TimeDelta object. |
| 67 static base::TimeDelta GetDefaultAutoclickDelay(); | 38 static base::TimeDelta GetDefaultAutoclickDelay(); |
| 68 | 39 |
| 69 protected: | 40 protected: |
| 70 AutoclickController() {} | 41 AutoclickController() {} |
| 42 |
| 43 private: |
| 44 DISALLOW_COPY_AND_ASSIGN(AutoclickController); |
| 71 }; | 45 }; |
| 72 | 46 |
| 73 } // namespace ash | 47 } // namespace ash |
| 74 | 48 |
| 75 #endif // ASH_AUTOCLICK_AUTOCLICK_CONTROLLER_H | 49 #endif // ASH_AUTOCLICK_AUTOCLICK_CONTROLLER_H |
| OLD | NEW |