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