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_UTILS_DRAG_ANIMATION_HELPER_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MANAGER_DRAG_DROP_UTILS_DRAG_ANIMATION_HELPER_H 18 19 #include "core/components_ng/event/drag_event.h" 20 #include "core/components_ng/pattern/menu/menu_pattern.h" 21 #include "core/components_ng/pattern/menu/wrapper/menu_wrapper_pattern.h" 22 23 namespace OHOS::Ace::NG { 24 25 class FrameNode; 26 class OverlayManager; 27 class DragEventActuator; 28 struct GatherNodeChildInfo; 29 struct CalcResult { 30 float maxDistance = 0.0f; 31 float minDistance = 0.0f; 32 float maxTranslation = 0.0f; 33 }; 34 35 class ACE_FORCE_EXPORT DragAnimationHelper { 36 public: 37 static OffsetF CalcOffsetToTarget(OffsetF curPos, OffsetF targetrPos, CalcResult& calcResult); 38 static void CalcDistanceBeforeLifting(bool isGrid, CalcResult& calcResult, OffsetF gatherNodeCenter, 39 const std::vector<GatherNodeChildInfo>& gatherNodeChildrenInfo); 40 static void PlayGatherNodeTranslateAnimation(const RefPtr<DragEventActuator>& actuator, 41 const RefPtr<OverlayManager>& overlayManager); 42 static void PlayGatherAnimationBeforeLifting(const RefPtr<DragEventActuator>& actuator); 43 static void PlayNodeAnimationBeforeLifting(const RefPtr<FrameNode>& frameNode); 44 static void PlayGatherNodeOpacityAnimation(const RefPtr<OverlayManager>& overlayManager); 45 static void PlayNodeResetAnimation(const RefPtr<DragEventActuator>& actuator); 46 static void PlayGatherAnimation(const RefPtr<FrameNode>& frameNode, const RefPtr<OverlayManager>& overlayManager); 47 static void ShowBadgeAnimation(const RefPtr<FrameNode>& textNode); 48 static void CalcBadgeTextPosition(const RefPtr<MenuPattern>& menuPattern, 49 const RefPtr<OverlayManager>& manager, const RefPtr<FrameNode>& imageNode, const RefPtr<FrameNode>& textNode); 50 static OffsetF CalcBadgeTextOffset(const RefPtr<MenuPattern>& menuPattern, const RefPtr<FrameNode>& imageNode, 51 const RefPtr<PipelineBase>& context, int32_t badgeLength); 52 static void UpdateBadgeLayoutAndRenderContext( 53 const RefPtr<FrameNode>& textNode, int32_t badgeLength, int32_t childSize); 54 static void UpdateGatherNodeToTop(); 55 static void ShowGatherAnimationWithMenu(const RefPtr<FrameNode>& menuWrapperNode); 56 }; 57 } 58 #endif