OLD | NEW |
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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 CHROME_BROWSER_CHROMEOS_UI_AUTOCLICK_RING_HANDLER_H_ | 5 #ifndef ASH_AUTOCLICK_COMMON_AUTOCLICK_RING_HANDLER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_UI_AUTOCLICK_RING_HANDLER_H_ | 6 #define ASH_AUTOCLICK_COMMON_AUTOCLICK_RING_HANDLER_H_ |
7 | 7 |
8 #include <memory> | |
9 | |
10 #include "ash/autoclick/autoclick_controller.h" | |
11 #include "base/macros.h" | 8 #include "base/macros.h" |
12 #include "base/timer/timer.h" | 9 #include "base/timer/timer.h" |
13 #include "ui/aura/window_observer.h" | 10 #include "ui/aura/window_observer.h" |
14 #include "ui/events/event.h" | |
15 #include "ui/gfx/animation/linear_animation.h" | 11 #include "ui/gfx/animation/linear_animation.h" |
16 #include "ui/gfx/geometry/point.h" | 12 #include "ui/gfx/geometry/point.h" |
17 | 13 |
18 namespace chromeos { | 14 namespace views { |
| 15 class Widget; |
| 16 } |
| 17 |
| 18 namespace ash { |
19 | 19 |
20 // AutoclickRingHandler displays an animated affordance that is shown | 20 // AutoclickRingHandler displays an animated affordance that is shown |
21 // on autoclick gesture. The animation sequence consists of two circles which | 21 // on autoclick gesture. The animation sequence consists of two circles which |
22 // shrink towards the spot the autoclick will generate a mouse event. | 22 // shrink towards the spot the autoclick will generate a mouse event. |
23 class AutoclickRingHandler : public gfx::LinearAnimation, | 23 class AutoclickRingHandler : public gfx::LinearAnimation, |
24 public aura::WindowObserver, | 24 public aura::WindowObserver { |
25 public ash::AutoclickController::Delegate { | |
26 public: | 25 public: |
27 AutoclickRingHandler(); | 26 AutoclickRingHandler(); |
28 ~AutoclickRingHandler() override; | 27 ~AutoclickRingHandler() override; |
29 | 28 |
| 29 void StartGesture(base::TimeDelta duration, |
| 30 const gfx::Point& center_point_in_screen, |
| 31 aura::Window* target, |
| 32 views::Widget* widget); |
| 33 void StopGesture(); |
| 34 void SetGestureCenter(const gfx::Point& center_point_in_screen, |
| 35 aura::Window* target, |
| 36 views::Widget* widget); |
| 37 |
30 private: | 38 private: |
31 // Overriden from ash::AutoclickController::Delegate. | |
32 void StartGesture(base::TimeDelta duration, | |
33 const gfx::Point& center_point_in_screen) override; | |
34 void StopGesture() override; | |
35 void SetGestureCenter(const gfx::Point& center_point_in_screen) override; | |
36 | |
37 class AutoclickRingView; | 39 class AutoclickRingView; |
38 | 40 |
39 enum class AnimationType { | 41 enum class AnimationType { |
40 NONE, | 42 NONE, |
41 GROW_ANIMATION, | 43 GROW_ANIMATION, |
42 SHRINK_ANIMATION, | 44 SHRINK_ANIMATION, |
43 }; | 45 }; |
44 | 46 |
45 aura::Window* GetTargetWindow(); | |
46 void SetTapDownTarget(); | |
47 void StartAnimation(base::TimeDelta duration); | 47 void StartAnimation(base::TimeDelta duration); |
48 void StopAutoclickRing(); | 48 void StopAutoclickRing(); |
49 void SetTapDownTarget(aura::Window* target); | 49 void SetTapDownTarget(aura::Window* target); |
50 | 50 |
51 // Overridden from gfx::LinearAnimation. | 51 // Overridden from gfx::LinearAnimation. |
52 void AnimateToState(double state) override; | 52 void AnimateToState(double state) override; |
53 void AnimationStopped() override; | 53 void AnimationStopped() override; |
54 | 54 |
55 // Overridden from aura::WindowObserver. | 55 // Overridden from aura::WindowObserver. |
56 void OnWindowDestroying(aura::Window* window) override; | 56 void OnWindowDestroying(aura::Window* window) override; |
57 | 57 |
58 std::unique_ptr<AutoclickRingView> view_; | 58 std::unique_ptr<AutoclickRingView> view_; |
| 59 views::Widget* ring_widget_; |
59 // Location of the simulated mouse event from auto click in screen | 60 // Location of the simulated mouse event from auto click in screen |
60 // coordinates. | 61 // coordinates. |
61 gfx::Point tap_down_location_; | 62 gfx::Point tap_down_location_; |
62 // The target window is observed by AutoclickRingHandler for the duration of | 63 // The target window is observed by AutoclickRingHandler for the duration of |
63 // a autoclick gesture. | 64 // a autoclick gesture. |
64 aura::Window* tap_down_target_; | 65 aura::Window* tap_down_target_; |
65 AnimationType current_animation_type_; | 66 AnimationType current_animation_type_; |
66 base::TimeDelta animation_duration_; | 67 base::TimeDelta animation_duration_; |
67 | 68 |
68 DISALLOW_COPY_AND_ASSIGN(AutoclickRingHandler); | 69 DISALLOW_COPY_AND_ASSIGN(AutoclickRingHandler); |
69 }; | 70 }; |
70 | 71 |
71 } // namespace chromeos | 72 } // namespace ash |
72 | 73 |
73 #endif // CHROME_BROWSER_CHROMEOS_UI_AUTOCLICK_RING_HANDLER_H_ | 74 #endif // ASH_AUTOCLICK_COMMON_AUTOCLICK_RING_HANDLER_H_ |
OLD | NEW |