mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-12-03 13:06:04 +00:00
拖拽capi挑单beta5.0
Signed-off-by: Zhang Jinyu <zhangjinyu101@huawei.com> Change-Id: Ia1945d0a2015bb8c1211c80fa317c41eb74d71fa
This commit is contained in:
parent
de3c2169e7
commit
3450f6156d
@ -84,6 +84,7 @@ void GetShadowInfoArray(
|
||||
|
||||
void PostStopDrag(std::shared_ptr<OHOS::Ace::NG::ArkUIInteralDragAction> dragAction, const RefPtr<Container>& container)
|
||||
{
|
||||
CHECK_NULL_VOID(container);
|
||||
auto taskExecutor = container->GetTaskExecutor();
|
||||
CHECK_NULL_VOID(taskExecutor);
|
||||
auto windowId = container->GetWindowId();
|
||||
@ -243,7 +244,10 @@ int32_t DragDropFuncWrapper::StartDragAction(std::shared_ptr<OHOS::Ace::NG::ArkU
|
||||
std::optional<DragDataCore> dragData;
|
||||
EnvelopedDragData(dragAction, dragData);
|
||||
if (!dragData) {
|
||||
manager->GetDragAction()->dragState = DragAdapterState::INIT;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(dragAction->dragStateMutex);
|
||||
manager->GetDragAction()->dragState = DragAdapterState::INIT;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
OnDragCallback callback = [dragAction, manager](const OHOS::Ace::DragNotifyMsg& dragNotifyMsg) {
|
||||
|
@ -315,7 +315,7 @@ bool DragDropManager::CheckDragDropProxy(int64_t id) const
|
||||
}
|
||||
|
||||
void DragDropManager::UpdateDragAllowDrop(
|
||||
const RefPtr<FrameNode>& dragFrameNode, const DragBehavior dragBehavior, const int32_t eventId)
|
||||
const RefPtr<FrameNode>& dragFrameNode, const DragBehavior dragBehavior, const int32_t eventId, bool isCapi)
|
||||
{
|
||||
if (!IsDropAllowed(dragFrameNode)) {
|
||||
UpdateDragStyle(DragCursorStyleCore::FORBIDDEN, eventId);
|
||||
@ -326,7 +326,9 @@ void DragDropManager::UpdateDragAllowDrop(
|
||||
CHECK_NULL_VOID(dragFrameNode);
|
||||
const auto& dragFrameNodeAllowDrop = dragFrameNode->GetAllowDrop();
|
||||
// special handling for no drag data present situation, always show as move
|
||||
if (dragFrameNodeAllowDrop.empty() || summaryMap_.empty()) {
|
||||
// For CAPI ,no ENABLE_DROP and DISABLE_DROP state, skip the judgment and consider it allowed to drop into. Continue
|
||||
// to set dragBehavior.
|
||||
if (!isCapi && (dragFrameNodeAllowDrop.empty() || summaryMap_.empty())) {
|
||||
UpdateDragStyle(DragCursorStyleCore::MOVE, eventId);
|
||||
return;
|
||||
}
|
||||
@ -1102,7 +1104,7 @@ void DragDropManager::FireOnDragEvent(
|
||||
} else if (event->GetResult() == DragRet::DISABLE_DROP) {
|
||||
UpdateDragStyle(DragCursorStyleCore::FORBIDDEN, pointerEvent.pointerEventId);
|
||||
} else {
|
||||
UpdateDragAllowDrop(frameNode, event->GetDragBehavior(), pointerEvent.pointerEventId);
|
||||
UpdateDragAllowDrop(frameNode, event->GetDragBehavior(), pointerEvent.pointerEventId, event->IsCapi());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -131,8 +131,8 @@ public:
|
||||
float GetWindowScale() const;
|
||||
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 UpdateDragAllowDrop(const RefPtr<FrameNode>& dragFrameNode, const DragBehavior dragBehavior,
|
||||
const int32_t eventId = -1, bool isCapi = false);
|
||||
void RequireSummary();
|
||||
void ClearSummary();
|
||||
void SetSummaryMap(const std::map<std::string, int64_t>& summaryMap)
|
||||
|
@ -287,6 +287,16 @@ public:
|
||||
pressedKeyCodes_ = pressedKeyCodes;
|
||||
}
|
||||
|
||||
void SetCapi(bool isCapi)
|
||||
{
|
||||
isCapi_ = isCapi;
|
||||
}
|
||||
|
||||
bool IsCapi()
|
||||
{
|
||||
return isCapi_;
|
||||
}
|
||||
|
||||
private:
|
||||
RefPtr<PasteData> pasteData_;
|
||||
double screenX_ = 0.0;
|
||||
@ -310,6 +320,7 @@ private:
|
||||
RefPtr<UnifiedData> dragInfo_;
|
||||
Velocity velocity_;
|
||||
std::vector<KeyCode> pressedKeyCodes_;
|
||||
bool isCapi_ = false;
|
||||
};
|
||||
|
||||
class NotifyDragEvent : public DragEvent {
|
||||
|
@ -223,6 +223,7 @@ struct ArkUIMouseEvent {
|
||||
struct ArkUIDragEvent {
|
||||
void* unifiedData;
|
||||
void* unifiedDataSummary;
|
||||
bool isSuitGetData;
|
||||
ArkUI_Int32 dragResult;
|
||||
ArkUI_Float64 touchPointX;
|
||||
ArkUI_Float64 touchPointY;
|
||||
|
@ -33,6 +33,8 @@ namespace {
|
||||
static void DragActionConvert(
|
||||
ArkUIDragAction* dragAction, std::shared_ptr<OHOS::Ace::NG::ArkUIInteralDragAction> internalDragAction)
|
||||
{
|
||||
CHECK_NULL_VOID(dragAction);
|
||||
CHECK_NULL_VOID(internalDragAction);
|
||||
internalDragAction->pointer = dragAction->pointerId;
|
||||
internalDragAction->size = dragAction->size;
|
||||
internalDragAction->previewOption.isScaleEnabled = dragAction->dragPreviewOption.isScaleEnabled;
|
||||
|
@ -135,15 +135,18 @@ void SetOnDragDrop(ArkUINodeHandle node, void* extraParam)
|
||||
std::vector<std::string> keepStr(summary.size());
|
||||
|
||||
SetDragEventProperty(info, event, strList, keepStr);
|
||||
event.dragEvent.isSuitGetData = true;
|
||||
|
||||
auto unifiedData = UdmfClient::GetInstance()->TransformUnifiedDataPtr(info->GetData());
|
||||
|
||||
event.dragEvent.unifiedData = unifiedData;
|
||||
event.dragEvent.dragBehavior = static_cast<ArkUI_Int32>(DragBehavior::UNKNOWN);
|
||||
PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
|
||||
SendArkUIAsyncEvent(&event);
|
||||
info->UseCustomAnimation(event.dragEvent.useCustomDropAnimation);
|
||||
info->SetResult(static_cast<DragRet>(event.dragEvent.dragResult));
|
||||
info->SetDragBehavior(static_cast<DragBehavior>(event.dragEvent.dragBehavior));
|
||||
info->SetCapi(true);
|
||||
};
|
||||
ViewAbstract::SetOnDrop(frameNode, onDragDrop);
|
||||
}
|
||||
@ -165,6 +168,7 @@ void SetOnDragStart(ArkUINodeHandle node, void* extraParam)
|
||||
std::vector<std::string> keepStr(summary.size());
|
||||
|
||||
SetDragEventProperty(info, event, strList, keepStr);
|
||||
event.dragEvent.isSuitGetData = false;
|
||||
|
||||
PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
|
||||
SendArkUIAsyncEvent(&event);
|
||||
@ -197,13 +201,15 @@ void SetOnDragEnter(ArkUINodeHandle node, void* extraParam)
|
||||
|
||||
SetDragEventProperty(info, event, strList, keepStr);
|
||||
auto unifiedData = UdmfClient::GetInstance()->TransformUnifiedDataPtr(info->GetData());
|
||||
|
||||
event.dragEvent.dragBehavior = static_cast<ArkUI_Int32>(DragBehavior::UNKNOWN);
|
||||
event.dragEvent.unifiedData = unifiedData;
|
||||
event.dragEvent.isSuitGetData = false;
|
||||
|
||||
PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
|
||||
SendArkUIAsyncEvent(&event);
|
||||
info->SetResult(static_cast<DragRet>(event.dragEvent.dragResult));
|
||||
info->SetDragBehavior(static_cast<DragBehavior>(event.dragEvent.dragBehavior));
|
||||
info->SetCapi(true);
|
||||
};
|
||||
ViewAbstract::SetOnDragEnter(frameNode, onDragEnter);
|
||||
}
|
||||
@ -226,11 +232,15 @@ void SetOnDragMove(ArkUINodeHandle node, void* extraParam)
|
||||
|
||||
SetDragEventProperty(info, event, strList, keepStr);
|
||||
auto unifiedData = UdmfClient::GetInstance()->TransformUnifiedDataPtr(info->GetData());
|
||||
event.dragEvent.dragBehavior = static_cast<ArkUI_Int32>(DragBehavior::UNKNOWN);
|
||||
event.dragEvent.unifiedData = unifiedData;
|
||||
event.dragEvent.isSuitGetData = false;
|
||||
|
||||
PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
|
||||
SendArkUIAsyncEvent(&event);
|
||||
info->SetResult(static_cast<DragRet>(event.dragEvent.dragResult));
|
||||
info->SetDragBehavior(static_cast<DragBehavior>(event.dragEvent.dragBehavior));
|
||||
info->SetCapi(true);
|
||||
};
|
||||
ViewAbstract::SetOnDragMove(frameNode, onDragMove);
|
||||
}
|
||||
@ -254,12 +264,15 @@ void SetOnDragLeave(ArkUINodeHandle node, void* extraParam)
|
||||
|
||||
SetDragEventProperty(info, event, strList, keepStr);
|
||||
auto unifiedData = UdmfClient::GetInstance()->TransformUnifiedDataPtr(info->GetData());
|
||||
|
||||
event.dragEvent.dragBehavior = static_cast<ArkUI_Int32>(DragBehavior::UNKNOWN);
|
||||
event.dragEvent.unifiedData = unifiedData;
|
||||
event.dragEvent.isSuitGetData = false;
|
||||
|
||||
PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
|
||||
SendArkUIAsyncEvent(&event);
|
||||
info->SetResult(static_cast<DragRet>(event.dragEvent.dragResult));
|
||||
info->SetDragBehavior(static_cast<DragBehavior>(event.dragEvent.dragBehavior));
|
||||
info->SetCapi(true);
|
||||
};
|
||||
ViewAbstract::SetOnDragLeave(frameNode, onDragLeave);
|
||||
}
|
||||
@ -295,6 +308,7 @@ void SetOnDragEnd(ArkUINodeHandle node, void* extraParam)
|
||||
auto unifiedData = UdmfClient::GetInstance()->TransformUnifiedDataPtr(info->GetData());
|
||||
|
||||
event.dragEvent.unifiedData = unifiedData;
|
||||
event.dragEvent.isSuitGetData = false;
|
||||
|
||||
// Did NOT define pressCode, so will NOT pass presscode to UI.
|
||||
event.dragEvent.dragResult = static_cast<ArkUI_Int32>(info->GetResult());
|
||||
@ -320,6 +334,8 @@ void SetOnPreDrag(ArkUINodeHandle node, void* extraParam)
|
||||
|
||||
// Did NOT define pressCode, so will NOT pass presscode to UI.
|
||||
event.componentAsyncEvent.data[0].i32 = static_cast<ArkUI_Int32>(preDragStatus);
|
||||
event.dragEvent.isSuitGetData = false;
|
||||
|
||||
PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
|
||||
SendArkUIAsyncEvent(&event);
|
||||
};
|
||||
|
@ -70,9 +70,8 @@ int32_t OH_ArkUI_DragEvent_GetUdmfData(ArkUI_DragEvent* event, OH_UdmfData* data
|
||||
if (!event || !dragEvent || (dragEvent->unifiedData == nullptr) || !data) {
|
||||
return ARKUI_ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
auto rawData = reinterpret_cast<OH_UdmfData*>(dragEvent->unifiedData);
|
||||
auto raw = dynamic_cast<OH_UdmfData*>(rawData);
|
||||
if (raw) {
|
||||
|
||||
if (!(dragEvent->isSuitGetData)) {
|
||||
return ARKUI_ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
auto unifiedData =
|
||||
@ -284,9 +283,6 @@ ArkUI_DragEvent* OH_ArkUI_DragAndDropInfo_GetDragEvent(ArkUI_DragAndDropInfo* dr
|
||||
return nullptr;
|
||||
}
|
||||
auto* dragAndDropInfos = reinterpret_cast<ArkUIDragAndDropInfo*>(dragAndDropInfo);
|
||||
if (!dragAndDropInfos) {
|
||||
return nullptr;
|
||||
}
|
||||
return reinterpret_cast<ArkUI_DragEvent*>(dragAndDropInfos->dragEvent);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user