• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 toolType = -1;
54     int32_t displayX = -1;
55     int32_t displayY = -1;
56     int32_t displayId = -1;
57     int32_t mainWindow = -1;
58     bool hasCanceledAnimation = false;
59     bool hasCoordinateCorrected = false;
60     std::map<std::string, int64_t> summarys;
61 };
62 
63 struct DragNotifyMsg {
64     int32_t displayX = -1;
65     int32_t displayY = -1;
66     int32_t targetPid = -1;
67     DragRet result { DragRet::DRAG_FAIL };
68     DragBehavior dragBehavior { DragBehavior::UNKNOWN };
69     bool isInnerAndOuterTriggerBothNeeded = true;
70 };
71 
72 struct DragDropRet {
73     DragRet result { DragRet::DRAG_FAIL };
74     bool hasCustomAnimation = false;
75     int32_t mainWindow = -1;
76     DragBehavior dragBehavior { DragBehavior::UNKNOWN };
77 };
78 
79 enum class DragState {
80     ERROR = 0,
81     START,
82     STOP,
83     CANCEL,
84     MOTION_DRAGGING
85 };
86 
87 enum class PreviewType {
88     FOREGROUND_COLOR = 0,
89     OPACITY = 1,
90     RADIUS = 2,
91     SCALE = 3
92 };
93 
94 struct PreviewStyle {
95     std::vector<PreviewType> types;
96     uint32_t foregroundColor = 0;
97     int32_t opacity = -1;
98     int32_t radius = -1;
99     float scale = -1;
100 
101     bool operator == (const PreviewStyle &other) const
102     {
103         return types == other.types && foregroundColor == other.foregroundColor && opacity == other.opacity &&
104                radius == other.radius && fabsf(scale - other.scale) < PERCISION;
105     }
106 
107     bool operator!=(const PreviewStyle &other) const
108     {
109         return !(*this == other);
110     }
111 };
112 
113 struct PreviewAnimation {
114     int32_t duration = -1;
115     std::string curveName;
116     std::vector<float> curve;
117 };
118 } // namespace OHOS::Ace
119 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_INTERACTION_DATA_H