add GetDisplayX and GetDisplayY

Signed-off-by: b30058220 <baodi1@huawei.com>
Change-Id: Icb6824d44d78c147a1ac1cbde4c63e7163e6922d
This commit is contained in:
b30058220 2024-07-06 10:29:47 +00:00
parent 78a7a80895
commit c8e4ddcb69
7 changed files with 43 additions and 5 deletions

View File

@ -274,7 +274,6 @@ bool EventHub::IsFireOnDrop(const RefPtr<OHOS::Ace::DragEvent>& info)
|| info->GetResult() == DragRet::DRAG_DEFAULT
|| info->GetResult() == DragRet::ENABLE_DROP
|| info->GetResult() == DragRet::DISABLE_DROP;
return true;
}
void EventHub::HandleInternalOnDrop(const RefPtr<OHOS::Ace::DragEvent>& info, const std::string& extraParams)

View File

@ -729,6 +729,8 @@ void GestureEventHub::HandleOnDragStart(const GestureEvent& info)
}
event->SetScreenX(info.GetScreenLocation().GetX());
event->SetScreenY(info.GetScreenLocation().GetY());
event->SetDisplayX(info.GetScreenLocation().GetX());
event->SetDisplayY(info.GetScreenLocation().GetY());
event->SetSourceTool(info.GetSourceTool());
auto frameTag = frameNode->GetTag();

View File

@ -870,7 +870,7 @@ void DragDropManager::OnDragDrop(RefPtr<OHOS::Ace::DragEvent>& event, const RefP
auto point = pointerEvent.GetPoint();
auto eventHub = dragFrameNode->GetEventHub<EventHub>();
CHECK_NULL_VOID(eventHub);
UpdateDragEvent(event, point);
UpdateDragEvent(event, pointerEvent);
auto extraParams = eventHub->GetDragExtraParams(extraInfo_, point, DragEventType::DROP);
eventHub->FireCustomerOnDragFunc(DragFuncType::DRAG_DROP, event, extraParams);
eventHub->HandleInternalOnDrop(event, extraParams);
@ -1026,6 +1026,8 @@ void DragDropManager::FireOnDragEvent(
event->SetY((double)point.GetY());
event->SetScreenX((double)point.GetScreenX());
event->SetScreenY((double)point.GetScreenY());
event->SetDisplayX((double)pointerEvent.GetDisplayX());
event->SetDisplayY((double)pointerEvent.GetDisplayY());
event->SetVelocity(velocityTracker_.GetVelocity());
event->SetSummary(summaryMap_);
event->SetPreviewRect(GetDragWindowRect(point));
@ -1388,12 +1390,15 @@ void DragDropManager::UpdateNotifyDragEvent(
}
}
void DragDropManager::UpdateDragEvent(RefPtr<OHOS::Ace::DragEvent>& event, const Point& point)
void DragDropManager::UpdateDragEvent(RefPtr<OHOS::Ace::DragEvent>& event, const OHOS::Ace::PointerEvent& pointerEvent)
{
auto point = pointerEvent.GetPoint();
event->SetX(point.GetX());
event->SetY(point.GetY());
event->SetScreenX(point.GetScreenX());
event->SetScreenY(point.GetScreenY());
event->SetDisplayX((double)pointerEvent.GetDisplayX());
event->SetDisplayY((double)pointerEvent.GetDisplayY());
event->SetVelocity(velocityTracker_.GetVelocity());
event->SetSummary(summaryMap_);
event->SetPreviewRect(GetDragWindowRect(point));

View File

@ -141,7 +141,7 @@ public:
void HideDragPreviewOverlay();
void HideDragPreviewWindow(int32_t containerId);
bool IsMSDPDragging() const;
void UpdateDragEvent(RefPtr<OHOS::Ace::DragEvent>& event, const Point& point);
void UpdateDragEvent(RefPtr<OHOS::Ace::DragEvent>& event, const OHOS::Ace::PointerEvent& pointerEvent);
void UpdateNotifyDragEvent(
RefPtr<NotifyDragEvent>& notifyEvent, const Point& point, const DragEventType dragEventType);
bool CheckDragDropProxy(int64_t id) const;

View File

@ -89,6 +89,16 @@ struct PointerEvent final {
return Point(x, y, x, y);
}
}
int32_t GetDisplayX() const
{
return displayX;
}
int32_t GetDisplayY() const
{
return displayY;
}
};
} // namespace OHOS::Ace
#endif // FOUNDATION_ACE_FRAMEWORKS_CORE_EVENT_POINTER_EVENT_H

View File

@ -130,6 +130,26 @@ public:
y_ = y;
}
double GetDisplayX() const
{
return displayX_;
}
double GetDisplayY() const
{
return displayY_;
}
void SetDisplayX(double x)
{
displayX_ = x;
}
void SetDisplayY(double y)
{
displayY_ = y;
}
void SetDescription(const std::string& description)
{
description_ = description;
@ -273,6 +293,8 @@ private:
double screenY_ = 0.0;
double x_ = 0.0;
double y_ = 0.0;
double displayX_ = 0.0;
double displayY_ = 0.0;
std::string description_;
RefPtr<PixelMap> pixelMap_;
std::map<std::string, int64_t> summary_;

View File

@ -992,7 +992,7 @@ HWTEST_F(DragDropManagerTestNg, DragDropManagerTest017, TestSize.Level1)
* @tc.steps: step3. call UpdateDragEvent.
* @tc.expected: pipeline is not null.
*/
dragDropManager->UpdateDragEvent(event, Point(1.0f, 1.0f));
dragDropManager->UpdateDragEvent(event, PointerEvent(1, 1));
auto pipeline = PipelineContext::GetCurrentContext();
ASSERT_NE(pipeline, nullptr);
}