Signed-off-by: zhangjinyu101 <zhangjinyu101@huawei.com>
Change-Id: Ibefa68695cd330a27876084b35dc73d3d6f70dce
This commit is contained in:
zhangjinyu101 2024-07-29 22:48:05 +08:00 committed by Zhang Jinyu
parent 9d6c0dcdbd
commit 1c8fbc3848
2 changed files with 20 additions and 8 deletions

View File

@ -35,11 +35,6 @@ static void DragActionConvert(
{
internalDragAction->pointer = dragAction->pointerId;
internalDragAction->size = dragAction->size;
auto* pixelMapTemp = reinterpret_cast<std::shared_ptr<void*>*>(dragAction->pixelmapArray);
for (int index = 0; index < dragAction->size; index++) {
auto pixelMap = PixelMap::CreatePixelMap(&pixelMapTemp[index]);
internalDragAction->pixelMapList.push_back(pixelMap);
}
internalDragAction->previewOption.isScaleEnabled = dragAction->dragPreviewOption.isScaleEnabled;
if (!internalDragAction->previewOption.isScaleEnabled) {
internalDragAction->previewOption.isDefaultShadowEnabled = dragAction->dragPreviewOption.isDefaultShadowEnabled;
@ -88,6 +83,11 @@ ArkUI_Int32 StartDrag(ArkUIDragAction* dragAction)
CHECK_NULL_VOID(listener);
listener(&outInfo, userData);
};
auto* pixelMapTemp = reinterpret_cast<std::shared_ptr<void*>*>(dragAction->pixelmapArray);
for (int index = 0; index < dragAction->size; index++) {
auto pixelMap = PixelMap::CreatePixelMap(&pixelMapTemp[index]);
internalDragAction->pixelMapList.push_back(pixelMap);
}
internalDragAction->callback = callbacks;
DragActionConvert(dragAction, internalDragAction);
OHOS::Ace::NG::DragDropFuncWrapper::StartDragAction(internalDragAction);

View File

@ -178,14 +178,17 @@ int32_t OH_ArkUI_DragAction_SetPixelMaps(ArkUI_DragAction* dragAction, OH_Pixelm
if (!dragActions) {
return ARKUI_ERROR_CODE_PARAM_INVALID;
}
std::vector<std::shared_ptr<OHOS::Media::PixelMap>> pixelMapList;
int32_t count = 0;
for (int32_t index = 0; index < size; index++) {
if (!pixelmapArray[index]) {
continue;
}
pixelMapList.push_back(pixelmapArray[index]->GetInnerPixelmap());
count++;
}
dragActions->pixelmapArray = reinterpret_cast<void**>(pixelMapList.data());
if (count < size || size < 0) {
return ARKUI_ERROR_CODE_PARAM_INVALID;
}
dragActions->pixelmapArray = reinterpret_cast<void**>(pixelmapArray);
dragActions->size = size;
return ARKUI_ERROR_CODE_NO_ERROR;
}
@ -297,6 +300,15 @@ int32_t OH_ArkUI_StartDrag(ArkUI_DragAction* dragAction)
if (!dragActions || !impl) {
return ARKUI_ERROR_CODE_PARAM_INVALID;
}
std::vector<std::shared_ptr<OHOS::Media::PixelMap>> pixelMapList;
auto pixelmapArray = reinterpret_cast<OH_PixelmapNative**>(dragActions->pixelmapArray);
for (int32_t index = 0; index < dragActions->size; index++) {
if (!pixelmapArray[index]) {
continue;
}
pixelMapList.push_back(pixelmapArray[index]->GetInnerPixelmap());
}
dragActions->pixelmapArray = reinterpret_cast<void**>(pixelMapList.data());
impl->getDragAdapterAPI()->startDrag(dragActions);
return ARKUI_ERROR_CODE_NO_ERROR;
}