!48287 修复拖拽阶段聚拢动效会发起的问题

Merge pull request !48287 from Zenix/b1109_fixGatherAnimation
This commit is contained in:
openharmony_ci 2024-11-19 01:38:56 +00:00 committed by Gitee
commit 5956bbfef1
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
6 changed files with 47 additions and 2 deletions

View File

@ -420,6 +420,7 @@ void DragEventActuator::OnCollectTouchTarget(const OffsetF& coordinateOffset, co
auto actionEnd = [weak = WeakClaim(this)](GestureEvent& info) {
TAG_LOGI(AceLogTag::ACE_DRAG, "Trigger drag action end.");
DragDropGlobalController::GetInstance().ResetDragDropInitiatingStatus();
auto pipelineContext = PipelineContext::GetCurrentContextSafelyWithCheck();
CHECK_NULL_VOID(pipelineContext);
auto dragDropManager = pipelineContext->GetDragDropManager();

View File

@ -483,6 +483,7 @@ void GestureEventHub::HandleOnDragStart(const GestureEvent& info)
TAG_LOGI(AceLogTag::ACE_DRAG, "Drag stop because user release mouse button");
return;
}
DragDropGlobalController::GetInstance().UpdateDragDropInitiatingStatus(frameNode, DragDropInitiatingStatus::MOVING);
if (info.GetInputEventType() == InputEventType::MOUSE_BUTTON) {
SetMouseDragMonitorState(true);
}
@ -854,6 +855,8 @@ void GestureEventHub::OnDragStart(const GestureEvent& info, const RefPtr<Pipelin
},
option.GetOnFinishEvent());
}
} else {
DragDropGlobalController::GetInstance().ResetDragDropInitiatingStatus();
}
if (info.GetInputEventType() == InputEventType::MOUSE_BUTTON && IsNeedSwitchToSubWindow()) {
ret = RegisterCoordinationListener(pipeline);
@ -1013,6 +1016,7 @@ OnDragCallbackCore GestureEventHub::GetDragCallback(const RefPtr<PipelineBase>&
TAG_LOGE(AceLogTag::ACE_DRAG, "handle drag end callback, can not get container.");
return;
}
DragDropGlobalController::GetInstance().ResetDragDropInitiatingStatus();
TAG_LOGI(
AceLogTag::ACE_DRAG, "handle drag end callback, windowId is %{public}d.", container->GetWindowId());
dragDropManager->ResetDragEndOption(notifyMessage, dragEvent, id);
@ -1192,6 +1196,7 @@ int32_t GestureEventHub::GetSelectItemSize()
void GestureEventHub::FireCustomerOnDragEnd(const RefPtr<PipelineBase>& context, const WeakPtr<EventHub>& hub)
{
DragDropGlobalController::GetInstance().ResetDragDropInitiatingStatus();
auto eventHub = hub.Upgrade();
CHECK_NULL_VOID(eventHub);
auto pipeline = AceType::DynamicCast<PipelineContext>(context);

View File

@ -18,6 +18,8 @@
#include <csignal>
#include <thread>
#include "core/components_ng/base/frame_node.h"
namespace OHOS::Ace::NG {
DragDropGlobalController::~DragDropGlobalController() {}
@ -40,5 +42,26 @@ bool DragDropGlobalController::IsMenuShowing() const
return isContextMenuShowing_;
}
void DragDropGlobalController::UpdateDragDropInitiatingStatus(const RefPtr<FrameNode>& frameNode,
const DragDropInitiatingStatus& dragStatus)
{
std::shared_lock<std::shared_mutex> lock(mutex_);
CHECK_NULL_VOID(frameNode);
if (dragStatus == DragDropInitiatingStatus::MOVING) {
currentDragNode_ = frameNode;
}
}
bool DragDropGlobalController::IsInMoving() const
{
std::shared_lock<std::shared_mutex> lock(mutex_);
return currentDragNode_;
}
void DragDropGlobalController::ResetDragDropInitiatingStatus()
{
std::shared_lock<std::shared_mutex> lock(mutex_);
currentDragNode_ = nullptr;
}
} // namespace OHOS::Ace

View File

@ -23,11 +23,19 @@
#include <shared_mutex>
#include <unordered_map>
#include "base/memory/referenced.h"
#include "base/utils/macros.h"
#include "base/utils/noncopyable.h"
namespace OHOS::Ace::NG {
class FrameNode;
enum class DragDropInitiatingStatus : int32_t {
IDLE = 0,
READY,
PRESS,
LIFTING,
MOVING,
};
class ACE_FORCE_EXPORT DragDropGlobalController {
public:
~DragDropGlobalController();
@ -36,6 +44,10 @@ public:
void UpdateMenuShowingStatus(bool isShowing);
bool IsMenuShowing() const;
bool IsInMoving() const;
void ResetDragDropInitiatingStatus();
void UpdateDragDropInitiatingStatus(const RefPtr<FrameNode>& frameNode,
const DragDropInitiatingStatus& dragStatus);
private:
DragDropGlobalController() = default;
@ -44,6 +56,7 @@ private:
// this is the real time menu show status flag, need to change to pair with menu target node in future
bool isContextMenuShowing_ = false;
ACE_DISALLOW_COPY_AND_MOVE(DragDropGlobalController);
RefPtr<FrameNode> currentDragNode_ = nullptr;
};
} // namespace OHOS::Ace::NG

View File

@ -29,6 +29,7 @@
#include "core/components_ng/base/frame_node.h"
#include "core/components_ng/manager/drag_drop/drag_drop_behavior_reporter/drag_drop_behavior_reporter.h"
#include "core/components_ng/manager/drag_drop/drag_drop_func_wrapper.h"
#include "core/components_ng/manager/drag_drop/drag_drop_global_controller.h"
#include "core/components_ng/pattern/grid/grid_event_hub.h"
#include "core/components_ng/pattern/list/list_event_hub.h"
#include "core/components_ng/pattern/menu/wrapper/menu_wrapper_pattern.h"
@ -639,6 +640,7 @@ void DragDropManager::TransDragWindowToDragFwk(int32_t windowContainerId)
TAG_LOGI(AceLogTag::ACE_DRAG, "TransDragWindowToDragFwk is %{public}d", isDragFwkShow_);
ACE_SCOPED_TRACE("drag: set drag window visible by transfer");
InteractionInterface::GetInstance()->SetDragWindowVisible(true);
DragDropGlobalController::GetInstance().ResetDragDropInitiatingStatus();
isDragFwkShow_ = true;
auto overlayManager = GetDragAnimationOverlayManager(windowContainerId);
CHECK_NULL_VOID(overlayManager);
@ -827,6 +829,7 @@ void DragDropManager::DoDragReset()
isDragWithContextMenu_ = false;
dampingOverflowCount_ = 0;
isDragNodeNeedClean_ = false;
DragDropGlobalController::GetInstance().ResetDragDropInitiatingStatus();
}
void DragDropManager::ResetDraggingStatus(const TouchEvent& touchPoint)

View File

@ -6466,7 +6466,7 @@ void OverlayManager::RemoveGatherNode()
void OverlayManager::RemoveGatherNodeWithAnimation()
{
if (!hasGatherNode_) {
if (!hasGatherNode_ || DragDropGlobalController::GetInstance().IsInMoving()) {
return;
}
TAG_LOGI(AceLogTag::ACE_DRAG, "Remove gather node with animation");