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 eda50f32209fab64ec748fc62b135be69815bc2c..721249dab4fb7d1aa73793625d09f549257232b0 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 @@ -36,8 +36,6 @@ namespace OHOS::Ace::NG { namespace { int64_t g_proxyId = 0; -constexpr float PIXELMAP_POSITION_WIDTH = 0.5f; -constexpr float PIXELMAP_POSITION_HEIGHT = 0.2f; constexpr Dimension PIXELMAP_BORDER_RADIUS = 8.0_vp; constexpr Dimension PRESERVE_HEIGHT = 8.0_vp; constexpr float FIRST_PIXELMAP_OPACITY = 0.6f; @@ -148,42 +146,6 @@ void DragDropManager::UpdateDragWindowPosition(int32_t globalX, int32_t globalY) #endif } -void DragDropManager::UpdatePixelMapPosition(int32_t globalX, int32_t globalY) -{ - auto pipeline = NG::PipelineContext::GetCurrentContext(); - CHECK_NULL_VOID(pipeline); - auto manager = pipeline->GetOverlayManager(); - CHECK_NULL_VOID(manager); - auto rootNode = pipeline->GetRootElement(); - CHECK_NULL_VOID(rootNode); - if (manager->GetHasPixelMap()) { - auto columnNode = AceType::DynamicCast(rootNode->GetLastChild()); - CHECK_NULL_VOID(columnNode); - auto imageNode = AceType::DynamicCast(columnNode->GetLastChild()); - CHECK_NULL_VOID(imageNode); - auto geometryNode = imageNode->GetGeometryNode(); - CHECK_NULL_VOID(geometryNode); - auto width = geometryNode->GetFrameSize().Width(); - auto height = geometryNode->GetFrameSize().Height(); - auto imageContext = imageNode->GetRenderContext(); - CHECK_NULL_VOID(imageContext); - CHECK_NULL_VOID(draggedFrameNode_); - auto hub = draggedFrameNode_->GetOrCreateGestureEventHub(); - CHECK_NULL_VOID(hub); - if (!hub->GetTextDraggable()) { - hub = columnNode->GetOrCreateGestureEventHub(); - CHECK_NULL_VOID(hub); - } - RefPtr pixelMap = hub->GetPixelMap(); - CHECK_NULL_VOID(pixelMap); - float scale = NearZero(width) ? 1.0f : pixelMap->GetWidth() / width; - imageContext->UpdatePosition(NG::OffsetT( - Dimension(globalX - width * PIXELMAP_POSITION_WIDTH * scale - width / 2.0f + width * scale / 2.0f), - Dimension(globalY - height * PIXELMAP_POSITION_HEIGHT * scale - height / 2.0f + height * scale / 2.0f))); - imageContext->OnModifyDone(); - } -} - void DragDropManager::HideDragPreviewOverlay() { auto pipeline = NG::PipelineContext::GetCurrentContext(); diff --git a/frameworks/core/components_ng/manager/drag_drop/drag_drop_manager.h b/frameworks/core/components_ng/manager/drag_drop/drag_drop_manager.h index 4c8b7689a823ce10b297b8d0b4a14d40c48846dc..4b4f6262cf30befdbf1ac726b0b9aa5500245762 100644 --- a/frameworks/core/components_ng/manager/drag_drop/drag_drop_manager.h +++ b/frameworks/core/components_ng/manager/drag_drop/drag_drop_manager.h @@ -130,7 +130,6 @@ public: uint32_t GetRecordSize() const; Rect GetDragWindowRect(const Point& point); RefPtr CreateFrameworkDragDropProxy(); - void UpdatePixelMapPosition(int32_t globalX, int32_t globalY); void HideDragPreviewOverlay(); bool IsMsdpDragging() const; void UpdateDragEvent(RefPtr& event, const Point& point); diff --git a/test/unittest/core/manager/drag_drop_manager_test_ng_new.cpp b/test/unittest/core/manager/drag_drop_manager_test_ng_new.cpp index 3af1a9a99b23caf95ae54d5d24eba90ee7baacc4..274f30335cef3b699ef1773811b68f2b42fbee02 100644 --- a/test/unittest/core/manager/drag_drop_manager_test_ng_new.cpp +++ b/test/unittest/core/manager/drag_drop_manager_test_ng_new.cpp @@ -1574,76 +1574,6 @@ HWTEST_F(DragDropManagerTestNgNew, DragDropManagerTest051, TestSize.Level1) EXPECT_TRUE(dragDropManager->isDragCancel_); } -/** - * @tc.name: DragDropManagerTest052 - * @tc.desc: Test UpdatePixelMapPosition - * @tc.type: FUNC - * @tc.author: - */ -HWTEST_F(DragDropManagerTestNgNew, DragDropManagerTest052, TestSize.Level1) -{ - /** - * @tc.steps: step1. construct a DragDropManager. - * @tc.expected: dragDropManager is not null. - */ - auto dragDropManager = AceType::MakeRefPtr(); - ASSERT_NE(dragDropManager, nullptr); - auto pipeline = NG::PipelineContext::GetCurrentContext(); - auto manager = pipeline->GetOverlayManager(); - ASSERT_NE(manager, nullptr); - - /** - * @tc.steps: step2. call UpdatePixelMapPosition with GLOBAL_X and GLOBAL_Y. - * @tc.expected: manager->GetHasPixelMap() return a false value. - */ - dragDropManager->UpdatePixelMapPosition(GLOBAL_X, GLOBAL_Y); - EXPECT_FALSE(manager->GetHasPixelMap()); - - /** - * @tc.steps: step3. call UpdatePixelMapPosition with GLOBAL_X and GLOBAL_Y. - * @tc.expected: manager->GetHasPixelMap() return a true value. - */ - manager->SetHasPixelMap(true); - dragDropManager->UpdatePixelMapPosition(GLOBAL_X, GLOBAL_Y); - EXPECT_TRUE(manager->GetHasPixelMap()); - - /** - * @tc.steps: step4. construct customNode and overlayManager and update the properties. - * @tc.expected: customNode and geometryNode are not null. - */ - auto rootNode = pipeline->GetRootElement(); - auto columnNode = AceType::DynamicCast(rootNode->GetLastChild()); - RefPtr customNode = AceType::MakeRefPtr(NODE_TAG, -1, AceType::MakeRefPtr()); - ASSERT_NE(customNode, nullptr); - std::list> children = { customNode }; - columnNode->children_ = std::move(children); - - auto imageNode = AceType::DynamicCast(columnNode->GetLastChild()); - ASSERT_NE(imageNode, nullptr); - auto geometryNode = imageNode->GetGeometryNode(); - ASSERT_NE(geometryNode, nullptr); - auto imageContext = imageNode->GetRenderContext(); - dragDropManager->draggedFrameNode_ = AceType::DynamicCast(columnNode); - ASSERT_NE(imageContext, nullptr); - ASSERT_NE(dragDropManager->draggedFrameNode_, nullptr); - - /** - * @tc.steps: step5. call UpdatePixelMapPosition with GLOBAL_X and GLOBAL_Y. - * @tc.expected: hub is not null. - */ - dragDropManager->UpdatePixelMapPosition(GLOBAL_X, GLOBAL_Y); - auto hub = dragDropManager->draggedFrameNode_->GetOrCreateGestureEventHub(); - ASSERT_NE(hub, nullptr); - - /** - * @tc.steps: step6. call UpdateDragListener with Point. - * @tc.expected: hub->GetTextDraggable() return a true value. - */ - hub->SetTextDraggable(true); - dragDropManager->UpdatePixelMapPosition(GLOBAL_X, GLOBAL_Y); - EXPECT_TRUE(hub->GetTextDraggable()); -} - /** * @tc.name: DragDropManagerTest053 * @tc.desc: Test CalcDragPreviewDistanceWithPoint