mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-23 23:21:05 +00:00
commit
f9fea7a82a
@ -81,9 +81,9 @@ int32_t InteractionImpl::StartDrag(const DragDataCore& dragData,
|
||||
std::make_shared<StartDragListenerImpl>(callbackCore));
|
||||
}
|
||||
|
||||
int32_t InteractionImpl::UpdateDragStyle(OHOS::Ace::DragCursorStyleCore style)
|
||||
int32_t InteractionImpl::UpdateDragStyle(OHOS::Ace::DragCursorStyleCore style, const int32_t eventId)
|
||||
{
|
||||
return InteractionManager::GetInstance()->UpdateDragStyle(TranslateDragCursorStyle(style));
|
||||
return InteractionManager::GetInstance()->UpdateDragStyle(TranslateDragCursorStyle(style), eventId);
|
||||
}
|
||||
|
||||
int32_t InteractionImpl::UpdatePreviewStyle(const OHOS::Ace::PreviewStyle& previewStyle)
|
||||
|
@ -32,7 +32,7 @@ public:
|
||||
int32_t StartDrag(const DragDataCore& dragData,
|
||||
std::function<void(const OHOS::Ace::DragNotifyMsg&)> callback) override;
|
||||
|
||||
int32_t UpdateDragStyle(DragCursorStyleCore style) override;
|
||||
int32_t UpdateDragStyle(DragCursorStyleCore style, const int32_t eventId = -1) override;
|
||||
|
||||
int32_t UpdatePreviewStyle(const PreviewStyle& previewStyle) override;
|
||||
|
||||
|
@ -39,7 +39,7 @@ int32_t InteractionImpl::StartDrag(const DragDataCore& dragData,
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t InteractionImpl::UpdateDragStyle(OHOS::Ace::DragCursorStyleCore style)
|
||||
int32_t InteractionImpl::UpdateDragStyle(OHOS::Ace::DragCursorStyleCore style, const int32_t eventId)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ public:
|
||||
int32_t StartDrag(const DragDataCore& dragData,
|
||||
std::function<void(const OHOS::Ace::DragNotifyMsg&)> callback) override;
|
||||
|
||||
int32_t UpdateDragStyle(DragCursorStyleCore style) override;
|
||||
int32_t UpdateDragStyle(DragCursorStyleCore style, const int32_t eventId = -1) override;
|
||||
|
||||
int32_t UpdatePreviewStyle(const PreviewStyle& previewStyle) override;
|
||||
|
||||
|
@ -33,7 +33,7 @@ public:
|
||||
virtual int32_t StartDrag(const DragDataCore& dragData,
|
||||
std::function<void(const OHOS::Ace::DragNotifyMsg&)> callback) = 0;
|
||||
|
||||
virtual int32_t UpdateDragStyle(DragCursorStyleCore style) = 0;
|
||||
virtual int32_t UpdateDragStyle(DragCursorStyleCore style, const int32_t eventId = -1) = 0;
|
||||
|
||||
virtual int32_t UpdatePreviewStyle(const PreviewStyle& previewStyle) = 0;
|
||||
|
||||
|
@ -314,10 +314,11 @@ bool DragDropManager::CheckDragDropProxy(int64_t id) const
|
||||
return currentId_ == id;
|
||||
}
|
||||
|
||||
void DragDropManager::UpdateDragAllowDrop(const RefPtr<FrameNode>& dragFrameNode, const DragBehavior dragBehavior)
|
||||
void DragDropManager::UpdateDragAllowDrop(
|
||||
const RefPtr<FrameNode>& dragFrameNode, const DragBehavior dragBehavior, const int32_t eventId)
|
||||
{
|
||||
if (!IsDropAllowed(dragFrameNode)) {
|
||||
UpdateDragStyle(DragCursorStyleCore::FORBIDDEN);
|
||||
UpdateDragStyle(DragCursorStyleCore::FORBIDDEN, eventId);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -326,7 +327,7 @@ void DragDropManager::UpdateDragAllowDrop(const RefPtr<FrameNode>& dragFrameNode
|
||||
const auto& dragFrameNodeAllowDrop = dragFrameNode->GetAllowDrop();
|
||||
// special handling for no drag data present situation, always show as move
|
||||
if (dragFrameNodeAllowDrop.empty() || summaryMap_.empty()) {
|
||||
UpdateDragStyle(DragCursorStyleCore::MOVE);
|
||||
UpdateDragStyle(DragCursorStyleCore::MOVE, eventId);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -337,33 +338,34 @@ void DragDropManager::UpdateDragAllowDrop(const RefPtr<FrameNode>& dragFrameNode
|
||||
// draggedFrameNode or frameNode is disabled, otherwise use copy
|
||||
auto eventHub = dragFrameNode->GetEventHub<EventHub>();
|
||||
if (draggedFrameNode_ == dragFrameNode || !(eventHub && eventHub->IsEnabled())) {
|
||||
UpdateDragStyle(DragCursorStyleCore::MOVE);
|
||||
UpdateDragStyle(DragCursorStyleCore::MOVE, eventId);
|
||||
} else {
|
||||
UpdateDragStyle(DragCursorStyleCore::COPY);
|
||||
UpdateDragStyle(DragCursorStyleCore::COPY, eventId);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DragBehavior::MOVE: {
|
||||
UpdateDragStyle(DragCursorStyleCore::MOVE);
|
||||
UpdateDragStyle(DragCursorStyleCore::MOVE, eventId);
|
||||
break;
|
||||
}
|
||||
case DragBehavior::COPY: {
|
||||
UpdateDragStyle(DragCursorStyleCore::COPY);
|
||||
UpdateDragStyle(DragCursorStyleCore::COPY, eventId);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
UpdateDragStyle(DragCursorStyleCore::COPY);
|
||||
UpdateDragStyle(DragCursorStyleCore::COPY, eventId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DragDropManager::UpdateDragStyle(const DragCursorStyleCore& dragStyle)
|
||||
void DragDropManager::UpdateDragStyle(const DragCursorStyleCore& dragStyle, int32_t eventId)
|
||||
{
|
||||
if (dragStyle != dragCursorStyleCore_) {
|
||||
dragCursorStyleCore_ = dragStyle;
|
||||
TAG_LOGI(AceLogTag::ACE_DRAG, "Update DragStyle to %{public}d.", dragCursorStyleCore_);
|
||||
InteractionInterface::GetInstance()->UpdateDragStyle(dragCursorStyleCore_);
|
||||
TAG_LOGI(AceLogTag::ACE_DRAG, "Update DragStyle to %{public}d, pointerEventId: %{public}d.",
|
||||
dragCursorStyleCore_, eventId);
|
||||
InteractionInterface::GetInstance()->UpdateDragStyle(dragCursorStyleCore_, eventId);
|
||||
}
|
||||
}
|
||||
|
||||
@ -675,7 +677,7 @@ void DragDropManager::OnDragMove(const PointerEvent& pointerEvent, const std::st
|
||||
}
|
||||
|
||||
if (!isMouseDragged_ || isDragWindowShow_) {
|
||||
UpdateDragStyle(DragCursorStyleCore::MOVE);
|
||||
UpdateDragStyle(DragCursorStyleCore::MOVE, pointerEvent.pointerEventId);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -949,7 +951,7 @@ void DragDropManager::RequireSummary()
|
||||
std::string str = udkey + "-" + std::to_string(recordSize) + ";";
|
||||
summarys += str;
|
||||
}
|
||||
TAG_LOGD(AceLogTag::ACE_DRAG, "require summary: %{public}s", summarys.c_str());
|
||||
TAG_LOGI(AceLogTag::ACE_DRAG, "require summary: %{public}s", summarys.c_str());
|
||||
}
|
||||
std::string extraInfo;
|
||||
ret = InteractionInterface::GetInstance()->GetDragExtraInfo(extraInfo);
|
||||
@ -1089,14 +1091,14 @@ void DragDropManager::FireOnDragEvent(
|
||||
}
|
||||
if (event->GetResult() == DragRet::ENABLE_DROP) {
|
||||
if (event->GetDragBehavior() == DragBehavior::MOVE) {
|
||||
UpdateDragStyle(DragCursorStyleCore::MOVE);
|
||||
UpdateDragStyle(DragCursorStyleCore::MOVE, pointerEvent.pointerEventId);
|
||||
} else {
|
||||
UpdateDragStyle(DragCursorStyleCore::COPY);
|
||||
UpdateDragStyle(DragCursorStyleCore::COPY, pointerEvent.pointerEventId);
|
||||
}
|
||||
} else if (event->GetResult() == DragRet::DISABLE_DROP) {
|
||||
UpdateDragStyle(DragCursorStyleCore::FORBIDDEN);
|
||||
UpdateDragStyle(DragCursorStyleCore::FORBIDDEN, pointerEvent.pointerEventId);
|
||||
} else {
|
||||
UpdateDragAllowDrop(frameNode, event->GetDragBehavior());
|
||||
UpdateDragAllowDrop(frameNode, event->GetDragBehavior(), pointerEvent.pointerEventId);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -126,8 +126,10 @@ public:
|
||||
void SetExtraInfo(const std::string& extraInfo);
|
||||
void ClearExtraInfo();
|
||||
float GetWindowScale() const;
|
||||
void UpdateDragStyle(const DragCursorStyleCore& dragCursorStyleCore = DragCursorStyleCore::DEFAULT);
|
||||
void UpdateDragAllowDrop(const RefPtr<FrameNode>& dragFrameNode, const DragBehavior dragBehavior);
|
||||
void UpdateDragStyle(
|
||||
const DragCursorStyleCore& dragCursorStyleCore = DragCursorStyleCore::DEFAULT, const int32_t eventId = -1);
|
||||
void UpdateDragAllowDrop(
|
||||
const RefPtr<FrameNode>& dragFrameNode, const DragBehavior dragBehavior, const int32_t eventId = -1);
|
||||
void RequireSummary();
|
||||
void ClearSummary();
|
||||
void SetSummaryMap(const std::map<std::string, int64_t>& summaryMap)
|
||||
|
@ -81,6 +81,9 @@ struct PointerEvent final {
|
||||
PointerEvent(int32_t windowX, int32_t windowY, int32_t displayX, int32_t displayY)
|
||||
: windowX(windowX), windowY(windowY), displayX(displayX), displayY(displayY)
|
||||
{}
|
||||
PointerEvent(int32_t pointerEventId, int32_t windowX, int32_t windowY, int32_t displayX, int32_t displayY)
|
||||
: pointerEventId(pointerEventId), windowX(windowX), windowY(windowY), displayX(displayX), displayY(displayY)
|
||||
{}
|
||||
|
||||
Point GetPoint() const
|
||||
{
|
||||
|
@ -2217,7 +2217,9 @@ void PipelineContext::ResetDraggingStatus(const TouchEvent& touchPoint, const Re
|
||||
manager->SetDraggingPressedState(false);
|
||||
}
|
||||
if (manager->IsDragging() && manager->IsSameDraggingPointer(touchPoint.id)) {
|
||||
manager->OnDragEnd(PointerEvent(touchPoint.x, touchPoint.y), "");
|
||||
manager->OnDragEnd(
|
||||
PointerEvent(touchPoint.touchEventId, touchPoint.x, touchPoint.y, touchPoint.screenX, touchPoint.screenY),
|
||||
"");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ public:
|
||||
MOCK_METHOD(int32_t, StartDrag, (const DragDataCore& dragData,
|
||||
std::function<void(const OHOS::Ace::DragNotifyMsg&)> callback), (override));
|
||||
|
||||
MOCK_METHOD(int32_t, UpdateDragStyle, (DragCursorStyleCore style), (override));
|
||||
MOCK_METHOD(int32_t, UpdateDragStyle, (DragCursorStyleCore style, const int32_t eventId), (override));
|
||||
|
||||
MOCK_METHOD(int32_t, UpdatePreviewStyle, (const PreviewStyle& previewStyle), (override));
|
||||
|
||||
|
@ -370,7 +370,7 @@ HWTEST_F(DragDropManagerTestNgCoverage, DragDropManagerTestNgCoverage011, TestSi
|
||||
PointF point(100.0, 100.0);
|
||||
dragDropManager->OnDragStart({ GLOBAL_X, GLOBAL_Y }, childNode);
|
||||
dragDropManager->summaryMap_.insert(make_pair(NODE_TAG, frameNodeNullId));
|
||||
dragDropManager->UpdateDragAllowDrop(frameNode, DragBehavior::UNKNOWN);
|
||||
dragDropManager->UpdateDragAllowDrop(frameNode, DragBehavior::UNKNOWN, -1);
|
||||
EXPECT_FALSE(dragDropManager->summaryMap_.empty());
|
||||
|
||||
/**
|
||||
@ -380,7 +380,7 @@ HWTEST_F(DragDropManagerTestNgCoverage, DragDropManagerTestNgCoverage011, TestSi
|
||||
dragDropManager->summaryMap_.clear();
|
||||
dragDropManager->OnDragStart({ GLOBAL_X, GLOBAL_Y }, frameNode);
|
||||
dragDropManager->summaryMap_.insert(make_pair(NODE_TAG, frameNodeNullId));
|
||||
dragDropManager->UpdateDragAllowDrop(frameNode, DragBehavior::UNKNOWN);
|
||||
dragDropManager->UpdateDragAllowDrop(frameNode, DragBehavior::UNKNOWN, -1);
|
||||
EXPECT_FALSE(dragDropManager->summaryMap_.empty());
|
||||
|
||||
/**
|
||||
@ -389,7 +389,7 @@ HWTEST_F(DragDropManagerTestNgCoverage, DragDropManagerTestNgCoverage011, TestSi
|
||||
*/
|
||||
dragDropManager->summaryMap_.clear();
|
||||
dragDropManager->summaryMap_.insert(make_pair(NODE_TAG, frameNodeNullId));
|
||||
dragDropManager->UpdateDragAllowDrop(frameNode, DragBehavior::MOVE);
|
||||
dragDropManager->UpdateDragAllowDrop(frameNode, DragBehavior::MOVE, -1);
|
||||
EXPECT_FALSE(dragDropManager->summaryMap_.empty());
|
||||
|
||||
/**
|
||||
@ -398,7 +398,7 @@ HWTEST_F(DragDropManagerTestNgCoverage, DragDropManagerTestNgCoverage011, TestSi
|
||||
*/
|
||||
dragDropManager->summaryMap_.clear();
|
||||
dragDropManager->summaryMap_.insert(make_pair(ROOT_ETS_TAG, frameNodeNullId));
|
||||
dragDropManager->UpdateDragAllowDrop(frameNode, static_cast<DragBehavior>(-100));
|
||||
dragDropManager->UpdateDragAllowDrop(frameNode, static_cast<DragBehavior>(-100), -1);
|
||||
EXPECT_TRUE(allowDrop.find(ROOT_ETS_TAG) == allowDrop.end());
|
||||
}
|
||||
|
||||
|
@ -1466,7 +1466,7 @@ HWTEST_F(DragDropManagerTestNgNew, DragDropManagerTest049, TestSize.Level1)
|
||||
* @tc.expected: dragDropManager->summaryMap_.empty() return a true value.
|
||||
*/
|
||||
dragDropManager->summaryMap_.clear();
|
||||
dragDropManager->UpdateDragAllowDrop(frameNode, DragBehavior::COPY);
|
||||
dragDropManager->UpdateDragAllowDrop(frameNode, DragBehavior::COPY, -1);
|
||||
EXPECT_TRUE(dragDropManager->summaryMap_.empty());
|
||||
|
||||
/**
|
||||
@ -1474,7 +1474,7 @@ HWTEST_F(DragDropManagerTestNgNew, DragDropManagerTest049, TestSize.Level1)
|
||||
* @tc.expected: dragDropManager->summaryMap_.empty() return a false value.
|
||||
*/
|
||||
dragDropManager->summaryMap_.insert(make_pair(NODE_TAG, frameNodeNullId));
|
||||
dragDropManager->UpdateDragAllowDrop(frameNode, DragBehavior::COPY);
|
||||
dragDropManager->UpdateDragAllowDrop(frameNode, DragBehavior::COPY, -1);
|
||||
EXPECT_FALSE(dragDropManager->summaryMap_.empty());
|
||||
|
||||
/**
|
||||
@ -1483,7 +1483,7 @@ HWTEST_F(DragDropManagerTestNgNew, DragDropManagerTest049, TestSize.Level1)
|
||||
*/
|
||||
dragDropManager->summaryMap_.clear();
|
||||
dragDropManager->summaryMap_.insert(make_pair(ROOT_ETS_TAG, frameNodeNullId));
|
||||
dragDropManager->UpdateDragAllowDrop(frameNode, DragBehavior::COPY);
|
||||
dragDropManager->UpdateDragAllowDrop(frameNode, DragBehavior::COPY, -1);
|
||||
EXPECT_TRUE(allowDrop.find(ROOT_ETS_TAG) == allowDrop.end());
|
||||
}
|
||||
|
||||
@ -2034,13 +2034,13 @@ HWTEST_F(DragDropManagerTestNgNew, DragDropManagerTest067, TestSize.Level1)
|
||||
frameNode->SetAllowDrop(allowDrop);
|
||||
const auto& dragFrameNodeAllowDrop = frameNode->GetAllowDrop();
|
||||
EXPECT_NE(dragDropManager->draggedFrameNode_, frameNode);
|
||||
dragDropManager->UpdateDragAllowDrop(frameNode, DragBehavior::UNKNOWN);
|
||||
dragDropManager->UpdateDragAllowDrop(frameNode, DragBehavior::MOVE);
|
||||
dragDropManager->UpdateDragAllowDrop(frameNode, DragBehavior::UNKNOWN, -1);
|
||||
dragDropManager->UpdateDragAllowDrop(frameNode, DragBehavior::MOVE, -1);
|
||||
EXPECT_FALSE(dragFrameNodeAllowDrop.empty());
|
||||
EXPECT_FALSE(dragDropManager->summaryMap_.empty());
|
||||
|
||||
dragDropManager->draggedFrameNode_ = frameNode;
|
||||
dragDropManager->UpdateDragAllowDrop(frameNode, DragBehavior::UNKNOWN);
|
||||
dragDropManager->UpdateDragAllowDrop(frameNode, DragBehavior::UNKNOWN, -1);
|
||||
EXPECT_EQ(dragDropManager->draggedFrameNode_, frameNode);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user