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_DRAG_DROP_DRAG_DROP_CONTROLLER_H_ | 5 #ifndef ASH_DRAG_DROP_DRAG_DROP_CONTROLLER_H_ |
6 #define ASH_DRAG_DROP_DRAG_DROP_CONTROLLER_H_ | 6 #define ASH_DRAG_DROP_DRAG_DROP_CONTROLLER_H_ |
7 | 7 |
8 #include "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
11 #include "ui/aura/client/drag_drop_client.h" | 11 #include "ui/aura/client/drag_drop_client.h" |
12 #include "ui/aura/window_observer.h" | 12 #include "ui/aura/window_observer.h" |
13 #include "ui/base/animation/animation_delegate.h" | |
14 #include "ui/base/dragdrop/os_exchange_data.h" | 13 #include "ui/base/dragdrop/os_exchange_data.h" |
15 #include "ui/base/events/event_constants.h" | 14 #include "ui/base/events/event_constants.h" |
16 #include "ui/base/events/event_handler.h" | 15 #include "ui/base/events/event_handler.h" |
| 16 #include "ui/gfx/animation/animation_delegate.h" |
17 #include "ui/gfx/rect.h" | 17 #include "ui/gfx/rect.h" |
18 | 18 |
19 namespace aura { | 19 namespace aura { |
20 class RootWindow; | 20 class RootWindow; |
21 class Window; | 21 class Window; |
22 } | 22 } |
23 | 23 |
24 namespace ui { | 24 namespace gfx { |
25 class LinearAnimation; | 25 class LinearAnimation; |
26 } | 26 } |
27 | 27 |
28 namespace ash { | 28 namespace ash { |
29 | 29 |
30 namespace test { | 30 namespace test { |
31 class DragDropControllerTest; | 31 class DragDropControllerTest; |
32 } | 32 } |
33 | 33 |
34 namespace internal { | 34 namespace internal { |
35 | 35 |
36 class DragDropTracker; | 36 class DragDropTracker; |
37 class DragDropTrackerDelegate; | 37 class DragDropTrackerDelegate; |
38 class DragImageView; | 38 class DragImageView; |
39 | 39 |
40 class ASH_EXPORT DragDropController | 40 class ASH_EXPORT DragDropController |
41 : public aura::client::DragDropClient, | 41 : public aura::client::DragDropClient, |
42 public ui::EventHandler, | 42 public ui::EventHandler, |
43 public ui::AnimationDelegate, | 43 public gfx::AnimationDelegate, |
44 public aura::WindowObserver { | 44 public aura::WindowObserver { |
45 public: | 45 public: |
46 DragDropController(); | 46 DragDropController(); |
47 virtual ~DragDropController(); | 47 virtual ~DragDropController(); |
48 | 48 |
49 void set_should_block_during_drag_drop(bool should_block_during_drag_drop) { | 49 void set_should_block_during_drag_drop(bool should_block_during_drag_drop) { |
50 should_block_during_drag_drop_ = should_block_during_drag_drop; | 50 should_block_during_drag_drop_ = should_block_during_drag_drop; |
51 } | 51 } |
52 | 52 |
53 // Overridden from aura::client::DragDropClient: | 53 // Overridden from aura::client::DragDropClient: |
(...skipping 17 matching lines...) Expand all Loading... |
71 virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE; | 71 virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE; |
72 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; | 72 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; |
73 | 73 |
74 // Overridden from aura::WindowObserver. | 74 // Overridden from aura::WindowObserver. |
75 virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE; | 75 virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE; |
76 | 76 |
77 protected: | 77 protected: |
78 // Helper method to create a LinearAnimation object that will run the drag | 78 // Helper method to create a LinearAnimation object that will run the drag |
79 // cancel animation. Caller take ownership of the returned object. Protected | 79 // cancel animation. Caller take ownership of the returned object. Protected |
80 // for testing. | 80 // for testing. |
81 virtual ui::LinearAnimation* CreateCancelAnimation( | 81 virtual gfx::LinearAnimation* CreateCancelAnimation( |
82 int duration, | 82 int duration, |
83 int frame_rate, | 83 int frame_rate, |
84 ui::AnimationDelegate* delegate); | 84 gfx::AnimationDelegate* delegate); |
85 | 85 |
86 // Actual implementation of |DragCancel()|. protected for testing. | 86 // Actual implementation of |DragCancel()|. protected for testing. |
87 virtual void DoDragCancel(int drag_cancel_animation_duration_ms); | 87 virtual void DoDragCancel(int drag_cancel_animation_duration_ms); |
88 | 88 |
89 private: | 89 private: |
90 friend class ash::test::DragDropControllerTest; | 90 friend class ash::test::DragDropControllerTest; |
91 | 91 |
92 // Overridden from ui::AnimationDelegate: | 92 // Overridden from gfx::AnimationDelegate: |
93 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; | 93 virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE; |
94 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; | 94 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE; |
95 virtual void AnimationCanceled(const ui::Animation* animation) OVERRIDE; | 95 virtual void AnimationCanceled(const gfx::Animation* animation) OVERRIDE; |
96 | 96 |
97 // Helper method to start drag widget flying back animation. | 97 // Helper method to start drag widget flying back animation. |
98 void StartCanceledAnimation(int animation_duration_ms); | 98 void StartCanceledAnimation(int animation_duration_ms); |
99 | 99 |
100 // Helper method to forward |pending_log_tap_| event to |drag_source_window_|. | 100 // Helper method to forward |pending_log_tap_| event to |drag_source_window_|. |
101 void ForwardPendingLongTap(); | 101 void ForwardPendingLongTap(); |
102 | 102 |
103 // Helper method to reset everything. | 103 // Helper method to reset everything. |
104 void Cleanup(); | 104 void Cleanup(); |
105 | 105 |
106 scoped_ptr<DragImageView> drag_image_; | 106 scoped_ptr<DragImageView> drag_image_; |
107 gfx::Vector2d drag_image_offset_; | 107 gfx::Vector2d drag_image_offset_; |
108 const ui::OSExchangeData* drag_data_; | 108 const ui::OSExchangeData* drag_data_; |
109 int drag_operation_; | 109 int drag_operation_; |
110 | 110 |
111 // Window that is currently under the drag cursor. | 111 // Window that is currently under the drag cursor. |
112 aura::Window* drag_window_; | 112 aura::Window* drag_window_; |
113 | 113 |
114 // Starting and final bounds for the drag image for the drag cancel animation. | 114 // Starting and final bounds for the drag image for the drag cancel animation. |
115 gfx::Rect drag_image_initial_bounds_for_cancel_animation_; | 115 gfx::Rect drag_image_initial_bounds_for_cancel_animation_; |
116 gfx::Rect drag_image_final_bounds_for_cancel_animation_; | 116 gfx::Rect drag_image_final_bounds_for_cancel_animation_; |
117 | 117 |
118 scoped_ptr<ui::LinearAnimation> cancel_animation_; | 118 scoped_ptr<gfx::LinearAnimation> cancel_animation_; |
119 | 119 |
120 // Window that started the drag. | 120 // Window that started the drag. |
121 aura::Window* drag_source_window_; | 121 aura::Window* drag_source_window_; |
122 | 122 |
123 // Indicates whether the caller should be blocked on a drag/drop session. | 123 // Indicates whether the caller should be blocked on a drag/drop session. |
124 // Only be used for tests. | 124 // Only be used for tests. |
125 bool should_block_during_drag_drop_; | 125 bool should_block_during_drag_drop_; |
126 | 126 |
127 // Closure for quitting nested message loop. | 127 // Closure for quitting nested message loop. |
128 base::Closure quit_closure_; | 128 base::Closure quit_closure_; |
129 | 129 |
130 scoped_ptr<ash::internal::DragDropTracker> drag_drop_tracker_; | 130 scoped_ptr<ash::internal::DragDropTracker> drag_drop_tracker_; |
131 scoped_ptr<DragDropTrackerDelegate> drag_drop_window_delegate_; | 131 scoped_ptr<DragDropTrackerDelegate> drag_drop_window_delegate_; |
132 | 132 |
133 ui::DragDropTypes::DragEventSource current_drag_event_source_; | 133 ui::DragDropTypes::DragEventSource current_drag_event_source_; |
134 | 134 |
135 // Holds a synthetic long tap event to be sent to the |drag_source_window_|. | 135 // Holds a synthetic long tap event to be sent to the |drag_source_window_|. |
136 // See comment in OnGestureEvent() on why we need this. | 136 // See comment in OnGestureEvent() on why we need this. |
137 scoped_ptr<ui::GestureEvent> pending_long_tap_; | 137 scoped_ptr<ui::GestureEvent> pending_long_tap_; |
138 | 138 |
139 base::WeakPtrFactory<DragDropController> weak_factory_; | 139 base::WeakPtrFactory<DragDropController> weak_factory_; |
140 | 140 |
141 DISALLOW_COPY_AND_ASSIGN(DragDropController); | 141 DISALLOW_COPY_AND_ASSIGN(DragDropController); |
142 }; | 142 }; |
143 | 143 |
144 } // namespace internal | 144 } // namespace internal |
145 } // namespace ash | 145 } // namespace ash |
146 | 146 |
147 #endif // ASH_DRAG_DROP_DRAG_DROP_CONTROLLER_H_ | 147 #endif // ASH_DRAG_DROP_DRAG_DROP_CONTROLLER_H_ |
OLD | NEW |