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