OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef UI_VIEWS_COCOA_COCOA_DRAG_DROP_MANAGER_H_ | |
tapted
2016/05/24 08:06:02
update guard
spqchan
2016/05/26 01:56:54
Done.
| |
6 #define UI_VIEWS_COCOA_COCOA_DRAG_DROP_MANAGER_H_ | |
7 | |
8 #import <Cocoa/Cocoa.h> | |
9 | |
10 #include <memory> | |
11 #include <vector> | |
12 | |
13 #import "base/mac/scoped_nsobject.h" | |
14 #include "base/macros.h" | |
15 #include "ui/base/dragdrop/drag_drop_types.h" | |
16 #include "ui/views/views_export.h" | |
17 #include "ui/views/widget/drop_helper.h" | |
18 | |
19 class DropHelper; | |
20 | |
21 @interface CocoaDragDropDataProvider : NSObject<NSPasteboardItemDataProvider> | |
tapted
2016/05/24 08:06:02
This needs to be VIEWS_EXPORT in order to link vie
spqchan
2016/05/26 01:56:54
Done.
| |
22 | |
23 - (id)initWithData:(const ui::OSExchangeData&)data; | |
24 | |
25 @end | |
26 | |
27 namespace gfx { | |
28 class Point; | |
29 } // namespace gfx | |
tapted
2016/05/24 08:06:02
nit: we don't usually bother with comments on name
spqchan
2016/05/26 01:56:54
Done.
| |
30 | |
31 namespace ui { | |
32 class OSExchangeData; | |
33 } // namespace ui | |
34 | |
35 namespace views { | |
36 namespace test { | |
37 class CocoaDragDropTest; | |
38 } | |
39 | |
40 class BridgedNativeWidget; | |
41 | |
42 class VIEWS_EXPORT DragDropClientMac { | |
tapted
2016/05/24 08:06:02
nit: needs a comment (it's probably worth mentioni
spqchan
2016/05/26 01:56:54
Done.
| |
43 public: | |
44 explicit DragDropClientMac(BridgedNativeWidget* view); | |
45 ~DragDropClientMac(); | |
46 | |
47 // Initiates a drag and drop session. Returns the drag operation that was | |
48 // applied at the end of the drag drop session. | |
49 void StartDragAndDrop(const ui::OSExchangeData& data, | |
50 const gfx::Point& location, | |
51 int operation, | |
52 ui::DragDropTypes::DragEventSource source); | |
53 | |
54 // Called when mouse is dragged during a drag and drop. | |
55 NSDragOperation DragUpdate(id<NSDraggingInfo>); | |
56 | |
57 // Called when mouse is released during a drag and drop. | |
58 NSDragOperation Drop(id<NSDraggingInfo> sender); | |
59 | |
60 // Called when the drag and drop session has ended. | |
61 void EndDrag(); | |
62 | |
63 // Calls when the the views::View bridged by the content view is set or | |
64 // cleared. | |
65 void SetRootView(View* view); | |
66 | |
67 private: | |
68 friend class test::CocoaDragDropTest; | |
69 | |
70 // Converts the given NSPoint to the coordinate system in Views. | |
71 gfx::Point LocationInView(NSPoint point) const; | |
72 | |
73 // Provides the data for the drag and drop session. | |
74 base::scoped_nsobject<CocoaDragDropDataProvider> data_source_; | |
75 | |
76 // Used to handle drag and drop with Views. | |
77 std::unique_ptr<DropHelper> drop_helper_; | |
78 | |
79 // The drag and drop operation. | |
80 int operation_; | |
tapted
2016/05/24 08:06:02
needs to be initialized
spqchan
2016/05/26 01:56:54
Done.
| |
81 | |
82 // The bridge between the content view and the drag drop client. | |
83 BridgedNativeWidget* bridge_; | |
tapted
2016/05/24 08:06:01
// Weak. Owns |this|.
spqchan
2016/05/26 01:56:54
Done.
| |
84 | |
85 DISALLOW_COPY_AND_ASSIGN(DragDropClientMac); | |
86 }; | |
87 | |
88 } // namespace views | |
89 | |
90 #endif // UI_VIEWS_COCOA_COCOA_DRAG_DROP_MANAGER_H_ | |
OLD | NEW |