1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MANAGER_DRAG_DROP_DRAG_DROP_PROXY_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MANAGER_DRAG_DROP_DRAG_DROP_PROXY_H
18 
19 #include "base/memory/ace_type.h"
20 #include "base/memory/referenced.h"
21 #include "base/utils/noncopyable.h"
22 #include "core/gestures/gesture_event.h"
23 
24 namespace OHOS::Ace::NG {
25 class FrameNode;
26 
27 enum class DragEventType {
28     ENTER,
29     LEAVE,
30     MOVE,
31     DROP,
32     START,
33 };
34 
35 enum class DragType {
36     COMMON,
37     GRID,
38     LIST,
39     TEXT,
40 };
41 
42 class ACE_EXPORT DragDropProxy : public virtual AceType {
43     DECLARE_ACE_TYPE(DragDropProxy, AceType);
44 
45 public:
DragDropProxy(int64_t id)46     explicit DragDropProxy(int64_t id) : id_(id) {}
47     ~DragDropProxy() override = default;
48 
49     void OnTextDragStart(const std::string& extraInfo);
50     void OnDragStart(const GestureEvent& info, const std::string& extraInfo, const RefPtr<FrameNode>& frameNode);
51     void OnDragMove(const GestureEvent& info);
52     void OnDragEnd(const GestureEvent& info, bool isTextDragEnd = false);
53     void onDragCancel();
54     void OnItemDragStart(const GestureEvent& info, const RefPtr<FrameNode>& frameNode);
55     void OnItemDragMove(const GestureEvent& info, int32_t draggedIndex, DragType dragType);
56     void OnItemDragEnd(const GestureEvent& info, int32_t draggedIndex, DragType dragType);
57     void onItemDragCancel();
58     void DestroyDragWindow();
59 
60 private:
61     int64_t id_ = -1;
62 
63     ACE_DISALLOW_COPY_AND_MOVE(DragDropProxy);
64 };
65 } // namespace OHOS::Ace::NG
66 
67 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MANAGER_DRAG_DROP_DRAG_DROP_PROXY_H
68