OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_WM_GESTURES_LONG_PRESS_AFFORDANCE_HANDLER_H_ | 5 #ifndef ASH_WM_GESTURES_LONG_PRESS_AFFORDANCE_HANDLER_H_ |
6 #define ASH_WM_GESTURES_LONG_PRESS_AFFORDANCE_HANDLER_H_ | 6 #define ASH_WM_GESTURES_LONG_PRESS_AFFORDANCE_HANDLER_H_ |
7 | 7 |
8 #include "base/timer/timer.h" | 8 #include "base/timer/timer.h" |
9 #include "ui/aura/window_observer.h" | 9 #include "ui/aura/window_observer.h" |
10 #include "ui/gfx/animation/linear_animation.h" | 10 #include "ui/gfx/animation/linear_animation.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 // on a TAP_DOWN gesture. The animation sequence consists of two parts: | 24 // on a TAP_DOWN gesture. The animation sequence consists of two parts: |
25 // The first part is a grow animation that starts at semi-long-press and | 25 // The first part is a grow animation that starts at semi-long-press and |
26 // completes on a long-press gesture. The affordance animates to full size | 26 // completes on a long-press gesture. The affordance animates to full size |
27 // during grow animation. | 27 // during grow animation. |
28 // The second part is a shrink animation that start after grow and shrinks the | 28 // The second part is a shrink animation that start after grow and shrinks the |
29 // affordance out of view. | 29 // affordance out of view. |
30 class LongPressAffordanceHandler : public gfx::LinearAnimation, | 30 class LongPressAffordanceHandler : public gfx::LinearAnimation, |
31 public aura::WindowObserver { | 31 public aura::WindowObserver { |
32 public: | 32 public: |
33 LongPressAffordanceHandler(); | 33 LongPressAffordanceHandler(); |
34 virtual ~LongPressAffordanceHandler(); | 34 ~LongPressAffordanceHandler() override; |
35 | 35 |
36 // Displays or removes long press affordance according to the |event|. | 36 // Displays or removes long press affordance according to the |event|. |
37 void ProcessEvent(aura::Window* target, ui::GestureEvent* event); | 37 void ProcessEvent(aura::Window* target, ui::GestureEvent* event); |
38 | 38 |
39 private: | 39 private: |
40 friend class ash::test::SystemGestureEventFilterTest; | 40 friend class ash::test::SystemGestureEventFilterTest; |
41 | 41 |
42 class LongPressAffordanceView; | 42 class LongPressAffordanceView; |
43 | 43 |
44 enum LongPressAnimationType { | 44 enum LongPressAnimationType { |
45 NONE, | 45 NONE, |
46 GROW_ANIMATION, | 46 GROW_ANIMATION, |
47 SHRINK_ANIMATION, | 47 SHRINK_ANIMATION, |
48 }; | 48 }; |
49 | 49 |
50 void StartAnimation(); | 50 void StartAnimation(); |
51 void StopAffordance(); | 51 void StopAffordance(); |
52 void SetTapDownTarget(aura::Window* target); | 52 void SetTapDownTarget(aura::Window* target); |
53 | 53 |
54 // Overridden from gfx::LinearAnimation. | 54 // Overridden from gfx::LinearAnimation. |
55 virtual void AnimateToState(double state) override; | 55 void AnimateToState(double state) override; |
56 virtual void AnimationStopped() override; | 56 void AnimationStopped() override; |
57 | 57 |
58 // Overridden from aura::WindowObserver. | 58 // Overridden from aura::WindowObserver. |
59 virtual void OnWindowDestroying(aura::Window* window) override; | 59 void OnWindowDestroying(aura::Window* window) override; |
60 | 60 |
61 scoped_ptr<LongPressAffordanceView> view_; | 61 scoped_ptr<LongPressAffordanceView> view_; |
62 gfx::Point tap_down_location_; | 62 gfx::Point tap_down_location_; |
63 base::OneShotTimer<LongPressAffordanceHandler> timer_; | 63 base::OneShotTimer<LongPressAffordanceHandler> timer_; |
64 aura::Window* tap_down_target_; | 64 aura::Window* tap_down_target_; |
65 LongPressAnimationType current_animation_type_; | 65 LongPressAnimationType current_animation_type_; |
66 | 66 |
67 DISALLOW_COPY_AND_ASSIGN(LongPressAffordanceHandler); | 67 DISALLOW_COPY_AND_ASSIGN(LongPressAffordanceHandler); |
68 }; | 68 }; |
69 | 69 |
70 } // namespace ash | 70 } // namespace ash |
71 | 71 |
72 #endif // ASH_WM_GESTURES_LONG_PRESS_AFFORDANCE_HANDLER_H_ | 72 #endif // ASH_WM_GESTURES_LONG_PRESS_AFFORDANCE_HANDLER_H_ |
OLD | NEW |