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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "ash/drag_drop/drag_drop_animation_observer_client.h" | |
9 #include "ash/ash_export.h" | 10 #include "ash/ash_export.h" |
10 #include "ui/aura/client/drag_drop_client.h" | 11 #include "ui/aura/client/drag_drop_client.h" |
11 #include "ui/aura/event.h" | 12 #include "ui/aura/event.h" |
12 #include "ui/aura/event_filter.h" | 13 #include "ui/aura/event_filter.h" |
13 #include "ui/base/dragdrop/os_exchange_data.h" | 14 #include "ui/base/dragdrop/os_exchange_data.h" |
14 #include "ui/base/events.h" | 15 #include "ui/base/events.h" |
15 #include "ui/gfx/compositor/layer_animation_observer.h" | 16 #include "ui/gfx/compositor/layer_animation_observer.h" |
16 #include "ui/gfx/point.h" | 17 #include "ui/gfx/point.h" |
17 | 18 |
18 namespace aura { | 19 namespace aura { |
19 class Window; | 20 class Window; |
20 } | 21 } |
21 | 22 |
22 namespace ui { | 23 namespace ui { |
24 class LayerAnimationObserver; | |
23 class LayerAnimationSequence; | 25 class LayerAnimationSequence; |
24 } | 26 } |
25 | 27 |
26 namespace ash { | 28 namespace ash { |
27 | 29 |
28 namespace test { | 30 namespace test { |
29 class DragDropControllerTest; | 31 class DragDropControllerTest; |
30 } | 32 } |
31 | 33 |
32 namespace internal { | 34 namespace internal { |
33 | 35 |
34 class DragImageView; | 36 class DragImageView; |
35 | 37 |
36 class ASH_EXPORT DragDropController | 38 class ASH_EXPORT DragDropController |
37 : public aura::client::DragDropClient, | 39 : public aura::client::DragDropClient, |
38 public aura::EventFilter, | 40 public aura::EventFilter, |
39 public ui::LayerAnimationObserver { | 41 public DragDropAnimationObserverClient { |
40 public: | 42 public: |
41 DragDropController(); | 43 DragDropController(); |
42 virtual ~DragDropController(); | 44 virtual ~DragDropController(); |
43 | 45 |
44 void set_should_block_during_drag_drop(bool should_block_during_drag_drop) { | 46 void set_should_block_during_drag_drop(bool should_block_during_drag_drop) { |
45 should_block_during_drag_drop_ = should_block_during_drag_drop; | 47 should_block_during_drag_drop_ = should_block_during_drag_drop; |
46 } | 48 } |
47 | 49 |
48 // Overridden from aura::client::DragDropClient: | 50 // Overridden from aura::client::DragDropClient: |
49 virtual int StartDragAndDrop(const ui::OSExchangeData& data, | 51 virtual int StartDragAndDrop(const ui::OSExchangeData& data, |
(...skipping 12 matching lines...) Expand all Loading... | |
62 aura::MouseEvent* event) OVERRIDE; | 64 aura::MouseEvent* event) OVERRIDE; |
63 virtual ui::TouchStatus PreHandleTouchEvent(aura::Window* target, | 65 virtual ui::TouchStatus PreHandleTouchEvent(aura::Window* target, |
64 aura::TouchEvent* event) OVERRIDE; | 66 aura::TouchEvent* event) OVERRIDE; |
65 virtual ui::GestureStatus PreHandleGestureEvent( | 67 virtual ui::GestureStatus PreHandleGestureEvent( |
66 aura::Window* target, | 68 aura::Window* target, |
67 aura::GestureEvent* event) OVERRIDE; | 69 aura::GestureEvent* event) OVERRIDE; |
68 | 70 |
69 private: | 71 private: |
70 friend class ash::test::DragDropControllerTest; | 72 friend class ash::test::DragDropControllerTest; |
71 | 73 |
72 // Overridden from ui::LayerAnimationObserver: | 74 // Overridden from DragDropAnimationObserverClient: |
73 virtual void OnLayerAnimationEnded( | 75 virtual void OnDragDropAnimationsCompleted( |
74 const ui::LayerAnimationSequence* sequence) OVERRIDE; | 76 ui::ImplicitAnimationObserver* observer) OVERRIDE; |
75 virtual void OnLayerAnimationAborted( | |
76 const ui::LayerAnimationSequence* sequence) OVERRIDE; | |
77 virtual void OnLayerAnimationScheduled( | |
78 const ui::LayerAnimationSequence* sequence) OVERRIDE {} | |
79 | 77 |
80 // Helper method to start drag widget flying back animation. | 78 // Helper method to start drag widget flying back animation. |
81 void StartCanceledAnimation(); | 79 void StartCanceledAnimation(); |
82 | 80 |
83 // Helper method to reset everything. | 81 // Helper method to reset everything. |
84 void Cleanup(); | 82 void Cleanup(); |
85 | 83 |
86 scoped_ptr<DragImageView> drag_image_; | 84 scoped_ptr<DragImageView> drag_image_; |
87 const ui::OSExchangeData* drag_data_; | 85 const ui::OSExchangeData* drag_data_; |
88 int drag_operation_; | 86 int drag_operation_; |
89 aura::Window* dragged_window_; | 87 aura::Window* dragged_window_; |
90 gfx::Point drag_start_location_; | 88 gfx::Point drag_start_location_; |
91 | 89 |
92 bool drag_drop_in_progress_; | 90 bool drag_drop_in_progress_; |
93 | 91 |
94 // Indicates whether the caller should be blocked on a drag/drop session. | 92 // Indicates whether the caller should be blocked on a drag/drop session. |
95 // Only be used for tests. | 93 // Only be used for tests. |
96 bool should_block_during_drag_drop_; | 94 bool should_block_during_drag_drop_; |
97 | 95 |
96 // The live observers. When the controller is destroyed, these observers are | |
sky
2012/01/27 17:54:10
Update comment to reflect only one.
| |
97 // removed and destroyed as well. The drag drop controller owns the observers. | |
98 scoped_ptr<ui::ImplicitAnimationObserver> active_observer_; | |
99 | |
98 DISALLOW_COPY_AND_ASSIGN(DragDropController); | 100 DISALLOW_COPY_AND_ASSIGN(DragDropController); |
99 }; | 101 }; |
100 | 102 |
101 } // namespace internal | 103 } // namespace internal |
102 } // namespace ash | 104 } // namespace ash |
103 | 105 |
104 #endif // ASH_DRAG_DROP_DRAG_DROP_CONTROLLER_H_ | 106 #endif // ASH_DRAG_DROP_DRAG_DROP_CONTROLLER_H_ |
OLD | NEW |