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/base/animation/animation_delegate.h" | 9 #include "ui/gfx/animation/animation_delegate.h" |
10 #include "ui/base/animation/linear_animation.h" | 10 #include "ui/gfx/animation/linear_animation.h" |
11 #include "ui/gfx/point.h" | 11 #include "ui/gfx/point.h" |
12 | 12 |
13 namespace aura { | 13 namespace aura { |
14 class Window; | 14 class Window; |
15 } | 15 } |
16 | 16 |
17 namespace ui { | 17 namespace ui { |
18 class LocatedEvent; | 18 class LocatedEvent; |
19 } | 19 } |
20 | 20 |
21 namespace ash { | 21 namespace ash { |
22 | 22 |
23 namespace test { | 23 namespace test { |
24 class SystemGestureEventFilterTest; | 24 class SystemGestureEventFilterTest; |
25 } | 25 } |
26 | 26 |
27 namespace internal { | 27 namespace internal { |
28 | 28 |
29 // LongPressAffordanceHandler displays an animated affordance that is shown | 29 // LongPressAffordanceHandler displays an animated affordance that is shown |
30 // on a TAP_DOWN gesture. The animation sequence consists of two parts: | 30 // on a TAP_DOWN gesture. The animation sequence consists of two parts: |
31 // The first part is a grow animation that starts at semi-long-press and | 31 // The first part is a grow animation that starts at semi-long-press and |
32 // completes on a long-press gesture. The affordance animates to full size | 32 // completes on a long-press gesture. The affordance animates to full size |
33 // during grow animation. | 33 // during grow animation. |
34 // The second part is a shrink animation that start after grow and shrinks the | 34 // The second part is a shrink animation that start after grow and shrinks the |
35 // affordance out of view. | 35 // affordance out of view. |
36 class LongPressAffordanceHandler : public ui::AnimationDelegate, | 36 class LongPressAffordanceHandler : public gfx::AnimationDelegate, |
37 public ui::LinearAnimation { | 37 public gfx::LinearAnimation { |
38 public: | 38 public: |
39 LongPressAffordanceHandler(); | 39 LongPressAffordanceHandler(); |
40 virtual ~LongPressAffordanceHandler(); | 40 virtual ~LongPressAffordanceHandler(); |
41 | 41 |
42 // Display or removes long press affordance according to the |event|. | 42 // Display or removes long press affordance according to the |event|. |
43 void ProcessEvent(aura::Window* target, | 43 void ProcessEvent(aura::Window* target, |
44 ui::LocatedEvent* event, | 44 ui::LocatedEvent* event, |
45 int touch_id); | 45 int touch_id); |
46 | 46 |
47 private: | 47 private: |
48 friend class ash::test::SystemGestureEventFilterTest; | 48 friend class ash::test::SystemGestureEventFilterTest; |
49 | 49 |
50 enum LongPressAnimationType { | 50 enum LongPressAnimationType { |
51 NONE, | 51 NONE, |
52 GROW_ANIMATION, | 52 GROW_ANIMATION, |
53 SHRINK_ANIMATION, | 53 SHRINK_ANIMATION, |
54 }; | 54 }; |
55 | 55 |
56 void StartAnimation(); | 56 void StartAnimation(); |
57 void StopAnimation(); | 57 void StopAnimation(); |
58 | 58 |
59 // Overridden from ui::LinearAnimation. | 59 // Overridden from gfx::LinearAnimation. |
60 virtual void AnimateToState(double state) OVERRIDE; | 60 virtual void AnimateToState(double state) OVERRIDE; |
61 virtual bool ShouldSendCanceledFromStop() OVERRIDE; | 61 virtual bool ShouldSendCanceledFromStop() OVERRIDE; |
62 | 62 |
63 // Overridden from ui::AnimationDelegate. | 63 // Overridden from gfx::AnimationDelegate. |
64 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; | 64 virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE; |
65 | 65 |
66 class LongPressAffordanceView; | 66 class LongPressAffordanceView; |
67 scoped_ptr<LongPressAffordanceView> view_; | 67 scoped_ptr<LongPressAffordanceView> view_; |
68 gfx::Point tap_down_location_; | 68 gfx::Point tap_down_location_; |
69 int tap_down_touch_id_; | 69 int tap_down_touch_id_; |
70 base::OneShotTimer<LongPressAffordanceHandler> timer_; | 70 base::OneShotTimer<LongPressAffordanceHandler> timer_; |
71 int64 tap_down_display_id_; | 71 int64 tap_down_display_id_; |
72 LongPressAnimationType current_animation_type_; | 72 LongPressAnimationType current_animation_type_; |
73 | 73 |
74 DISALLOW_COPY_AND_ASSIGN(LongPressAffordanceHandler); | 74 DISALLOW_COPY_AND_ASSIGN(LongPressAffordanceHandler); |
75 }; | 75 }; |
76 | 76 |
77 } // namespace internal | 77 } // namespace internal |
78 } // namespace ash | 78 } // namespace ash |
79 | 79 |
80 #endif // ASH_WM_GESTURES_LONG_PRESS_AFFORDANCE_HANDLER_H_ | 80 #endif // ASH_WM_GESTURES_LONG_PRESS_AFFORDANCE_HANDLER_H_ |
OLD | NEW |