1 /*
2  * Copyright (c) 2023 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_COMMON_INTERACTION_DATA_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_INTERACTION_DATA_H
18 
19 #include "base/image/pixel_map.h"
20 #include "core/gestures/drag_event.h"
21 
22 namespace OHOS::Ace {
23 constexpr float PERCISION { 1E-6 };
24 enum class DragCursorStyleCore {
25     DEFAULT = 0,
26     FORBIDDEN,
27     COPY,
28     MOVE
29 };
30 
31 struct ShadowInfoCore {
32     RefPtr<PixelMap> pixelMap;
33     int32_t x = -1;
34     int32_t y = -1;
35 };
36 
37 struct ShadowOffsetData {
38     int32_t offsetX = -1;
39     int32_t offsetY = -1;
40     int32_t width = -1;
41     int32_t height = -1;
42 };
43 
44 struct DragDataCore {
45     std::vector<ShadowInfoCore> shadowInfos;
46     std::vector<uint8_t> buffer;
47     std::string udKey;
48     std::string extraInfo;
49     std::string filterInfo;
50     int32_t sourceType = -1;
51     int32_t dragNum = -1;
52     int32_t pointerId = -1;
53     int32_t displayX = -1;
54     int32_t displayY = -1;
55     int32_t displayId = -1;
56     int32_t mainWindow = -1;
57     bool hasCanceledAnimation = false;
58     bool hasCoordinateCorrected = false;
59     std::map<std::string, int64_t> summarys;
60 };
61 
62 struct DragNotifyMsg {
63     int32_t displayX = -1;
64     int32_t displayY = -1;
65     int32_t targetPid = -1;
66     DragRet result { DragRet::DRAG_FAIL };
67     DragBehavior dragBehavior { DragBehavior::UNKNOWN };
68 };
69 
70 struct DragDropRet {
71     DragRet result { DragRet::DRAG_FAIL };
72     bool hasCustomAnimation = false;
73     int32_t mainWindow = -1;
74     DragBehavior dragBehavior { DragBehavior::UNKNOWN };
75 };
76 
77 enum class DragState {
78     ERROR = 0,
79     START,
80     STOP,
81     CANCEL,
82     MOTION_DRAGGING
83 };
84 
85 enum class PreviewType {
86     FOREGROUND_COLOR = 0,
87     OPACITY = 1,
88     RADIUS = 2,
89     SCALE = 3
90 };
91 
92 struct PreviewStyle {
93     std::vector<PreviewType> types;
94     uint32_t foregroundColor = 0;
95     int32_t opacity = -1;
96     int32_t radius = -1;
97     float scale = -1;
98 
99     bool operator == (const PreviewStyle &other) const
100     {
101         return types == other.types && foregroundColor == other.foregroundColor && opacity == other.opacity &&
102                radius == other.radius && fabsf(scale - other.scale) < PERCISION;
103     }
104 
105     bool operator!=(const PreviewStyle &other) const
106     {
107         return !(*this == other);
108     }
109 };
110 
111 struct PreviewAnimation {
112     int32_t duration = -1;
113     std::string curveName;
114     std::vector<float> curve;
115 };
116 } // namespace OHOS::Ace
117 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_INTERACTION_DATA_H