diff --git a/frameworks/core/components_ng/event/drag_event.cpp b/frameworks/core/components_ng/event/drag_event.cpp index ce4eb85d234cf4960704a6a00408e196a331f02c..19cf378b962e8a875776e41bcca848fe216bf58e 100644 --- a/frameworks/core/components_ng/event/drag_event.cpp +++ b/frameworks/core/components_ng/event/drag_event.cpp @@ -530,6 +530,9 @@ void DragEventActuator::OnCollectTouchTarget(const OffsetF& coordinateOffset, co } } else { auto renderContext = frameNode->GetRenderContext(); + CHECK_NULL_VOID(renderContext); + auto context = frameNode->GetContextRefPtr(); + CHECK_NULL_VOID(context); BorderRadiusProperty borderRadius; if (renderContext->GetBorderRadius().has_value()) { borderRadius.UpdateWithCheck(renderContext->GetBorderRadius().value()); @@ -543,7 +546,7 @@ void DragEventActuator::OnCollectTouchTarget(const OffsetF& coordinateOffset, co [renderContext_ = renderContext, borderRadius_ = borderRadius]() { renderContext_->UpdateBorderRadius(borderRadius_); }, - option.GetOnFinishEvent()); + option.GetOnFinishEvent(), nullptr, context); actuator->HidePixelMap(); actuator->HideFilter(); } @@ -752,6 +755,8 @@ void DragEventActuator::OnCollectTouchTarget(const OffsetF& coordinateOffset, co CHECK_NULL_VOID(imageNode); auto imageContext = imageNode->GetRenderContext(); CHECK_NULL_VOID(imageContext); + auto context = imageNode->GetContextRefPtr(); + CHECK_NULL_VOID(context); if (actuator->IsNeedGather()) { DragAnimationHelper::PlayGatherAnimation(imageNode, manager); DragAnimationHelper::ShowPreviewBadgeAnimation(gestureHub, manager); @@ -778,7 +783,7 @@ void DragEventActuator::OnCollectTouchTarget(const OffsetF& coordinateOffset, co [imageContext]() { imageContext->UpdateTransformScale({ PIXELMAP_DRAG_SCALE_MULTIPLE, PIXELMAP_DRAG_SCALE_MULTIPLE }); }, - option.GetOnFinishEvent()); + option.GetOnFinishEvent(), nullptr, context); actuator->SetEventColumn(actuator); }; auto longPressCancel = [weak = WeakClaim(this)](const GestureEvent& info) { @@ -984,9 +989,11 @@ void DragEventActuator::SetFilter(const RefPtr& actuator) manager->SetFilterActive(false); }); columnNode->GetRenderContext()->UpdateBackBlurRadius(FILTER_VALUE); + auto context = columnNode->GetContextRefPtr(); + CHECK_NULL_VOID(context); AnimationUtils::Animate( option, [columnNode, styleOption]() { columnNode->GetRenderContext()->UpdateBackBlurStyle(styleOption); }, - option.GetOnFinishEvent()); + option.GetOnFinishEvent(), nullptr, context); } TAG_LOGD(AceLogTag::ACE_DRAG, "DragEvent set filter success."); } @@ -1360,6 +1367,8 @@ void DragEventActuator::ShowPixelMapAnimation(const RefPtr& imageNode auto imageContext = imageNode->GetRenderContext(); CHECK_NULL_VOID(imageContext); CHECK_NULL_VOID(frameNode); + auto context = imageNode->GetContextRefPtr(); + CHECK_NULL_VOID(context); frameNode->SetOptionsAfterApplied(optionsAfterApplied_); DragAnimationHelper::SetImageNodeInitAttr(frameNode, imageNode); // update scale @@ -1395,7 +1404,7 @@ void DragEventActuator::ShowPixelMapAnimation(const RefPtr& imageNode } DragDropFuncWrapper::ResetNode(frameNode); }, - option.GetOnFinishEvent()); + option.GetOnFinishEvent(), nullptr, context); } void DragEventActuator::ExecutePreDragAction(const PreDragStatus preDragStatus, const RefPtr& frameNode) @@ -1622,6 +1631,8 @@ void DragEventActuator::HideTextAnimation(bool startDrag, double globalX, double } auto context = dragNode->GetRenderContext(); CHECK_NULL_VOID(context); + auto dragcontext = dragNode->GetContextRefPtr(); + CHECK_NULL_VOID(dragcontext); context->UpdateTransformScale(VectorF(1.0f, 1.0f)); AnimationUtils::Animate( option, @@ -1633,7 +1644,7 @@ void DragEventActuator::HideTextAnimation(bool startDrag, double globalX, double context->OnModifyDone(); } }, - option.GetOnFinishEvent()); + option.GetOnFinishEvent(), nullptr, dragcontext); TAG_LOGD(AceLogTag::ACE_DRAG, "DragEvent set hide text animation success."); } diff --git a/frameworks/core/components_ng/manager/drag_drop/drag_drop_initiating/drag_drop_initiating_state_base.cpp b/frameworks/core/components_ng/manager/drag_drop/drag_drop_initiating/drag_drop_initiating_state_base.cpp index c42dabf670c3fbd6b0c420d11c1490baae06c43e..1b22a0e63082bc0aecaf2367e032e4cd667c4e2a 100644 --- a/frameworks/core/components_ng/manager/drag_drop/drag_drop_initiating/drag_drop_initiating_state_base.cpp +++ b/frameworks/core/components_ng/manager/drag_drop/drag_drop_initiating/drag_drop_initiating_state_base.cpp @@ -163,6 +163,9 @@ void DragDropInitiatingStateBase::ResetBorderRadiusAnimation() auto frameNode = params.frameNode.Upgrade(); CHECK_NULL_VOID(frameNode); auto renderContext = frameNode->GetRenderContext(); + CHECK_NULL_VOID(renderContext); + auto context = frameNode->GetContextRefPtr(); + CHECK_NULL_VOID(context); BorderRadiusProperty borderRadius; if (renderContext->GetBorderRadius().has_value()) { borderRadius.UpdateWithCheck(renderContext->GetBorderRadius().value()); @@ -176,7 +179,7 @@ void DragDropInitiatingStateBase::ResetBorderRadiusAnimation() [renderContext = renderContext, borderRadius = borderRadius]() { renderContext->UpdateBorderRadius(borderRadius); }, - option.GetOnFinishEvent()); + option.GetOnFinishEvent(), nullptr, context); } bool DragDropInitiatingStateBase::CheckStatusForPanActionBegin( @@ -338,6 +341,8 @@ void DragDropInitiatingStateBase::HideTextAnimation(bool startDrag, double globa } auto context = dragNode->GetRenderContext(); CHECK_NULL_VOID(context); + auto dragcontext = dragNode->GetContextRefPtr(); + CHECK_NULL_VOID(dragcontext); context->UpdateTransformScale(VectorF(1.0f, 1.0f)); AnimationUtils::Animate( option, @@ -349,7 +354,7 @@ void DragDropInitiatingStateBase::HideTextAnimation(bool startDrag, double globa context->OnModifyDone(); } }, - option.GetOnFinishEvent()); + option.GetOnFinishEvent(), nullptr, dragcontext); } void DragDropInitiatingStateBase::HandleTextDragCallback() diff --git a/frameworks/core/components_ng/manager/drag_drop/drag_drop_initiating/drag_drop_initiating_state_lifting.cpp b/frameworks/core/components_ng/manager/drag_drop/drag_drop_initiating/drag_drop_initiating_state_lifting.cpp index 400fb9c0eba41235e94f6a4fcdc71aba412aacfb..e6d6c44b8fdcb1f8fa31342c0239dcefb8e135f5 100644 --- a/frameworks/core/components_ng/manager/drag_drop/drag_drop_initiating/drag_drop_initiating_state_lifting.cpp +++ b/frameworks/core/components_ng/manager/drag_drop/drag_drop_initiating/drag_drop_initiating_state_lifting.cpp @@ -235,6 +235,8 @@ void DragDropInitiatingStateLifting::SetScaleAnimation(int32_t fingerId) auto motion = AceType::MakeRefPtr(SPRING_RESPONSE, SPRING_DAMPING_FRACTION, 0); auto imageContext = imageNode->GetRenderContext(); CHECK_NULL_VOID(imageContext); + auto context = imageNode->GetContextRefPtr(); + CHECK_NULL_VOID(context); AnimationOption option; option.SetDuration(PIXELMAP_ANIMATION_TIME); option.SetCurve(motion); @@ -254,7 +256,7 @@ void DragDropInitiatingStateLifting::SetScaleAnimation(int32_t fingerId) [imageContext]() { imageContext->UpdateTransformScale({ PIXELMAP_DRAG_SCALE_MULTIPLE, PIXELMAP_DRAG_SCALE_MULTIPLE }); }, - option.GetOnFinishEvent()); + option.GetOnFinishEvent(), nullptr, context); } void DragDropInitiatingStateLifting::SetPixelMap() @@ -315,6 +317,8 @@ void DragDropInitiatingStateLifting::ShowPixelMapAnimation( auto machine = GetStateMachine(); CHECK_NULL_VOID(machine); + auto context = imageNode->GetContextRefPtr(); + CHECK_NULL_VOID(context); auto params = machine->GetDragDropInitiatingParams(); frameNode->SetOptionsAfterApplied(params.optionsAfterApplied); DragAnimationHelper::SetImageNodeInitAttr(frameNode, imageNode); @@ -340,7 +344,7 @@ void DragDropInitiatingStateLifting::ShowPixelMapAnimation( } DragDropFuncWrapper::ApplyNewestOptionExecutedFromModifierToNode(frameNode, imageNode); }, - option.GetOnFinishEvent()); + option.GetOnFinishEvent(), nullptr, context); } void DragDropInitiatingStateLifting::SetGatherAnimation(const RefPtr& context) diff --git a/frameworks/core/components_ng/manager/drag_drop/drag_drop_manager.cpp b/frameworks/core/components_ng/manager/drag_drop/drag_drop_manager.cpp index c1b8840f085c628a9d2b47fbb56ac3771966c89e..9fc34583e598b239a6142d03b76931745c4dbc08 100644 --- a/frameworks/core/components_ng/manager/drag_drop/drag_drop_manager.cpp +++ b/frameworks/core/components_ng/manager/drag_drop/drag_drop_manager.cpp @@ -2469,9 +2469,12 @@ void DragDropManager::DragMoveAnimation( void DragDropManager::DragMoveDefaultAnimation(const RefPtr& overlayManager, const DragPreviewInfo& info, AnimationOption option, const Offset& newOffset, Point point) { - auto renderContext = info_.textNode && info_.relativeContainerNode ? info_.relativeContainerNode->GetRenderContext() - : info_.imageNode->GetRenderContext(); + auto targetNode = info_.textNode && info_.relativeContainerNode ? info_.relativeContainerNode : info_.imageNode; + CHECK_NULL_VOID(targetNode); + auto renderContext = targetNode->GetRenderContext(); CHECK_NULL_VOID(renderContext); + auto context = targetNode->GetContextRefPtr(); + CHECK_NULL_VOID(context); auto offset = OffsetF(point.GetX(), point.GetY()); auto menuWrapperNode = GetMenuWrapperNodeFromDrag(); auto menuPosition = overlayManager->CalculateMenuPosition(menuWrapperNode, offset); @@ -2489,7 +2492,7 @@ void DragDropManager::DragMoveDefaultAnimation(const RefPtr& ove } UpdateGatherNodePosition(overlayManager, info.imageNode); }, - option.GetOnFinishEvent()); + option.GetOnFinishEvent(), nullptr, context); } void DragDropManager::DragMoveTransitionAnimation(const RefPtr& overlayManager, @@ -2501,6 +2504,8 @@ void DragDropManager::DragMoveTransitionAnimation(const RefPtr& auto offset = OffsetF(point.GetX(), point.GetY()); auto menuWrapperNode = GetMenuWrapperNodeFromDrag(); CHECK_NULL_VOID(overlayManager); + auto context = info_.imageNode->GetContextRefPtr(); + CHECK_NULL_VOID(context); auto menuPosition = overlayManager->CalculateMenuPosition(menuWrapperNode, offset); auto menuRenderContext = GetMenuRenderContextFromMenuWrapper(menuWrapperNode); AnimationUtils::Animate( @@ -2516,7 +2521,7 @@ void DragDropManager::DragMoveTransitionAnimation(const RefPtr& relativeContainerNodeRenderContext->UpdateTransformTranslate({ newOffset.GetX(), newOffset.GetY(), 0.0f }); UpdateGatherNodePosition(overlayManager, info.imageNode); }, - option.GetOnFinishEvent()); + option.GetOnFinishEvent(), nullptr, context); } void DragDropManager::UpdateDragPreviewScale() @@ -2653,6 +2658,8 @@ void DragDropManager::StartDragDefaultAnimation(AnimationOption option, const Of { auto renderContext = info_.imageNode->GetRenderContext(); CHECK_NULL_VOID(renderContext); + auto context = info_.imageNode->GetContextRefPtr(); + CHECK_NULL_VOID(context); auto animateCallback = [renderContext, info = info_, newOffset, overlayManager, animateProperty, point]() { CHECK_NULL_VOID(renderContext); DragAnimationHelper::UpdateStartAnimation(overlayManager, animateProperty, point, info, newOffset); @@ -2675,7 +2682,7 @@ void DragDropManager::StartDragDefaultAnimation(AnimationOption option, const Of CHECK_NULL_VOID(pipeline); pipeline->Animate(option, option.GetCurve(), animateCallback, option.GetOnFinishEvent()); } else { - AnimationUtils::Animate(option, animateCallback, option.GetOnFinishEvent()); + AnimationUtils::Animate(option, animateCallback, option.GetOnFinishEvent(), nullptr, context); } } diff --git a/frameworks/core/components_ng/manager/drag_drop/utils/drag_animation_helper.cpp b/frameworks/core/components_ng/manager/drag_drop/utils/drag_animation_helper.cpp index e01cf63f90764c8c3d774e767fba47c2fc409d78..3cee58e1a8ef7c21d626a63db93216d6dce6376b 100644 --- a/frameworks/core/components_ng/manager/drag_drop/utils/drag_animation_helper.cpp +++ b/frameworks/core/components_ng/manager/drag_drop/utils/drag_animation_helper.cpp @@ -194,6 +194,8 @@ void DragAnimationHelper::PlayNodeAnimationBeforeLifting(const RefPtr option.SetCurve(springCurve); auto renderContext = frameNode->GetRenderContext(); CHECK_NULL_VOID(renderContext); + auto context = frameNode->GetContextRefPtr(); + CHECK_NULL_VOID(context); renderContext->UpdateTransformScale({ 1.0f, 1.0f }); AnimationUtils::Animate( @@ -201,7 +203,7 @@ void DragAnimationHelper::PlayNodeAnimationBeforeLifting(const RefPtr [renderContext]() mutable { CHECK_NULL_VOID(renderContext); renderContext->UpdateTransformScale({ DEFAULT_ANIMATION_SCALE, DEFAULT_ANIMATION_SCALE }); - }); + }, nullptr, nullptr, context); } void DragAnimationHelper::PlayNodeResetAnimation(const RefPtr& actuator) @@ -215,6 +217,8 @@ void DragAnimationHelper::PlayNodeResetAnimation(const RefPtr } auto frameContext = frameNode->GetRenderContext(); CHECK_NULL_VOID(frameContext); + auto context = frameNode->GetContextRefPtr(); + CHECK_NULL_VOID(context); auto layoutProperty = frameNode->GetLayoutProperty(); if (layoutProperty) { layoutProperty->UpdateVisibility(VisibleType::VISIBLE); @@ -228,7 +232,7 @@ void DragAnimationHelper::PlayNodeResetAnimation(const RefPtr [frameContext]() mutable { frameContext->UpdateTransformScale({ 1.0f, 1.0f }); }, - option.GetOnFinishEvent()); + option.GetOnFinishEvent(), nullptr, context); } float DragAnimationHelper::GetLiftingNodeScale(const RefPtr& renderContext) @@ -301,6 +305,8 @@ void DragAnimationHelper::ShowBadgeAnimation(const RefPtr& textNode) CHECK_NULL_VOID(textNode); auto textNodeContext = textNode->GetRenderContext(); CHECK_NULL_VOID(textNodeContext); + auto context = textNode->GetContextRefPtr(); + CHECK_NULL_VOID(context); textNodeContext->SetVisible(true); auto windowScale = dragDropManager->GetWindowScale(); auto badgeScale = GreatNotEqual(windowScale, 0.0f) ? BADGE_ANIMATION_SCALE / windowScale : BADGE_ANIMATION_SCALE; @@ -320,7 +326,7 @@ void DragAnimationHelper::ShowBadgeAnimation(const RefPtr& textNode) [textNodeContext, badgeScale]() mutable { textNodeContext->UpdateTransformScale({ badgeScale, badgeScale }); }, - textOption.GetOnFinishEvent()); + textOption.GetOnFinishEvent(), nullptr, context); dragDropManager->SetIsShowBadgeAnimation(false); } @@ -499,6 +505,8 @@ void DragAnimationHelper::DoGrayedAnimation( auto frameTag = frameNode->GetTag(); auto gestureHub = frameNode->GetOrCreateGestureEventHub(); CHECK_NULL_VOID(gestureHub); + auto context = frameNode->GetContextRefPtr(); + CHECK_NULL_VOID(context); if (gestureHub->IsTextCategoryComponent(frameTag)) { return; } @@ -506,7 +514,7 @@ void DragAnimationHelper::DoGrayedAnimation( option.SetCurve(cure); AnimationUtils::Animate( option, [frameNode, opacity]() { ACE_UPDATE_NODE_RENDER_CONTEXT(Opacity, opacity, frameNode); }, - option.GetOnFinishEvent()); + option.GetOnFinishEvent(), nullptr, context); } RefPtr DragAnimationHelper::CreateImageNode(const RefPtr& pixelMap) @@ -761,6 +769,9 @@ void DragAnimationHelper::ShowDragNodeCopyAnimation(const RefPtr layoutProperty->UpdateVisibility(VisibleType::INVISIBLE); } auto renderContext = dragNodeCopy->GetRenderContext(); + CHECK_NULL_VOID(renderContext); + auto context = dragNodeCopy->GetContextRefPtr(); + CHECK_NULL_VOID(context); AnimationOption option; option.SetDuration(BEFORE_LIFTING_TIME); auto springCurve = AceType::MakeRefPtr(DEFAULT_INTERPOLATING_SPRING_VELOCITY, @@ -773,7 +784,7 @@ void DragAnimationHelper::ShowDragNodeCopyAnimation(const RefPtr CHECK_NULL_VOID(renderContext); renderContext->UpdateTransformScale({ DEFAULT_ANIMATION_SCALE, DEFAULT_ANIMATION_SCALE }); }, - option.GetOnFinishEvent() + option.GetOnFinishEvent(), nullptr, context ); } @@ -793,6 +804,8 @@ void DragAnimationHelper::HideDragNodeCopyWithAnimation(const RefPtrGetRenderContext(); CHECK_NULL_VOID(renderContext); + auto context = dragNodeCopy->GetContextRefPtr(); + CHECK_NULL_VOID(context); AnimationOption option; option.SetDuration(NODE_RESET_DURATION); option.SetCurve(Curves::SHARP); @@ -816,7 +829,7 @@ void DragAnimationHelper::HideDragNodeCopyWithAnimation(const RefPtrUpdateTransformScale({ 1.0, 1.0f }); }, - option.GetOnFinishEvent() + option.GetOnFinishEvent(), nullptr, context ); } @@ -973,6 +986,8 @@ void DragAnimationHelper::DragStartAnimation(const Offset& newOffset, const RefP CHECK_NULL_VOID(imageNode); auto renderContext = imageNode->GetRenderContext(); CHECK_NULL_VOID(renderContext); + auto context = imageNode->GetContextRefPtr(); + CHECK_NULL_VOID(context); AnimationUtils::Animate( option, [renderContext, info = dragDropManager->GetDragPreviewInfo(), newOffset, overlayManager, @@ -985,7 +1000,7 @@ void DragAnimationHelper::DragStartAnimation(const Offset& newOffset, const RefP dragDropManager->UpdateGatherNodeAttr(overlayManager, gatherAnimationInfo); dragDropManager->UpdateTextNodePosition(info.textNode, newOffset); }, - option.GetOnFinishEvent()); + option.GetOnFinishEvent(), nullptr, context); } void DragAnimationHelper::InitImageNodeProperties(const RefPtr& imageNode, const RefPtr& pixelMap)