1 /* 2 * Copyright (c) 2024 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_FUNC_WRAPPER_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MANAGER_DRAG_DROP_DRAG_DROP_FUNC_WRAPPER_H 18 19 #include "core/pipeline_ng/pipeline_context.h" 20 21 #include "base/memory/ace_type.h" 22 #include "base/memory/referenced.h" 23 #include "core/components_ng/base/frame_node.h" 24 #include "core/components_ng/gestures/gesture_info.h" 25 26 namespace OHOS::Ace::NG { 27 /* DragDropFuncWrapper as a utility class, all function calls must use containerId. */ 28 class FrameNode; 29 class ACE_FORCE_EXPORT DragDropFuncWrapper { 30 public: 31 static int32_t StartDragAction(std::shared_ptr<OHOS::Ace::NG::ArkUIInteralDragAction> dragAction); 32 static void SetDraggingPointerAndPressedState(int32_t currentPointerId, int32_t containerId); 33 static void DecideWhetherToStopDragging(const PointerEvent& pointerEvent, 34 const std::string& extraParams, int32_t currentPointerId, int32_t containerId); 35 static void UpdateDragPreviewOptionsFromModifier( 36 std::function<void(WeakPtr<FrameNode>)> applyOnNodeSync, DragPreviewOption& options); 37 static void UpdatePreviewOptionDefaultAttr(DragPreviewOption& option); 38 static void UpdateExtraInfo(std::unique_ptr<JsonValue>& arkExtraInfoJson, DragPreviewOption& option); 39 static void PrepareRadiusParametersForDragData(std::unique_ptr<JsonValue>& arkExtraInfoJson, 40 DragPreviewOption& option); 41 static void PrepareShadowParametersForDragData(std::unique_ptr<JsonValue>& arkExtraInfoJson, 42 DragPreviewOption& option); 43 static void ParseShadowInfo(Shadow& shadow, std::unique_ptr<JsonValue>& arkExtraInfoJson); 44 static std::optional<Shadow> GetDefaultShadow(); 45 static std::optional<BorderRadiusProperty> GetDefaultBorderRadius(); 46 static float RadiusToSigma(float radius); 47 static std::optional<EffectOption> BrulStyleToEffection(const std::optional<BlurStyleOption>& blurStyleOp); 48 [[maybe_unused]] static double GetScaleWidth(int32_t containerId); 49 static void SetExtraInfo(int32_t containerId, std::string extraInfo); 50 static OffsetF GetPaintRectCenter(const RefPtr<FrameNode>& frameNode, bool checkWindowBoundary = true); 51 static bool IsExpandDisplay(const RefPtr<PipelineBase>& context); 52 static OffsetF GetCurrentWindowOffset(const RefPtr<PipelineBase>& context); 53 static OffsetF GetPaintRectCenterToScreen(const RefPtr<FrameNode>& frameNode); 54 static OffsetF GetFrameNodeOffsetToScreen(const RefPtr<FrameNode>& frameNode); 55 static RectF GetPaintRectToScreen(const RefPtr<FrameNode>& frameNode); 56 static void UpdateNodePositionToScreen(const RefPtr<FrameNode>& frameNode, OffsetF offset); 57 static void UpdateNodePositionToWindow(const RefPtr<FrameNode>& frameNode, OffsetF offset); 58 static void UpdatePositionFromFrameNode(const RefPtr<FrameNode>& targetNode, const RefPtr<FrameNode>& frameNode, 59 float width, float height); 60 }; 61 } // namespace OHOS::Ace::NG 62 63 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MANAGER_DRAG_DROP_DRAG_DROP_FUNC_WRAPPER_H