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