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