mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-23 15:10:30 +00:00
!38238 拖拽事件回调支持CAPI
Merge pull request !38238 from Zhang Jinyu/capi-callback
This commit is contained in:
commit
a35b075766
@ -2701,6 +2701,8 @@ frameworks/core/interfaces/native/node/node_content_modifier.cpp @arkuiframework
|
||||
frameworks/core/interfaces/native/node/node_content_modifier.h @arkuiframework
|
||||
frameworks/core/interfaces/native/node/node_date_picker_modifier.cpp @arkuipopupwindow
|
||||
frameworks/core/interfaces/native/node/node_date_picker_modifier.h @arkuipopupwindow
|
||||
frameworks/core/interfaces/native/node/node_drag_modifier.cpp @arkuievent
|
||||
frameworks/core/interfaces/native/node/node_drag_modifier.h @arkuievent
|
||||
frameworks/core/interfaces/native/node/node_folder_stack_modifier.cpp @arkuilayout
|
||||
frameworks/core/interfaces/native/node/node_folder_stack_modifier.h @arkuilayout
|
||||
frameworks/core/interfaces/native/node/node_gesture_modifier.cpp @arkuievent
|
||||
@ -2815,7 +2817,9 @@ frameworks/core/interfaces/native/node/view_model.h @arkuiframework
|
||||
frameworks/core/interfaces/native/node/water_flow_modifier.cpp @arkuiscroll
|
||||
frameworks/core/interfaces/native/node/water_flow_modifier.h @arkuiscroll
|
||||
interfaces/native/BUILD.gn @arkui_architecture
|
||||
interfaces/native/drag_and_drop.h @arkuievent
|
||||
interfaces/native/drawable_descriptor.h @arkui_image
|
||||
interfaces/native/event/drag_and_drop_impl.cpp @arkuievent
|
||||
interfaces/native/event/ui_input_event.cpp @arkuievent
|
||||
interfaces/native/event/ui_input_event_impl.h @arkuievent
|
||||
interfaces/native/libace.ndk.json @arkui_architecture
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include "base/image/file_uri_helper.h"
|
||||
#include "base/utils/utils.h"
|
||||
#include "core/common/udmf/unified_data.h"
|
||||
#include "ndk_data_conversion.h"
|
||||
namespace OHOS::Ace {
|
||||
UdmfClient* UdmfClient::GetInstance()
|
||||
{
|
||||
@ -84,6 +85,31 @@ napi_value UdmfClientImpl::TransformUdmfUnifiedData(RefPtr<UnifiedData>& Unified
|
||||
return dataVal;
|
||||
}
|
||||
|
||||
void* UdmfClientImpl::TransformUnifiedDataPtr(RefPtr<UnifiedData>& unifiedDataImpl)
|
||||
{
|
||||
CHECK_NULL_RETURN(unifiedDataImpl, nullptr);
|
||||
std::shared_ptr<UDMF::UnifiedData> unifiedData =
|
||||
AceType::DynamicCast<UnifiedDataImpl>(unifiedDataImpl)->GetUnifiedData();
|
||||
CHECK_NULL_RETURN(unifiedData, nullptr);
|
||||
return unifiedData.get();
|
||||
}
|
||||
|
||||
RefPtr<UnifiedData> UdmfClientImpl::TransformUnifiedDataForNative(void* rawData)
|
||||
{
|
||||
CHECK_NULL_RETURN(rawData, nullptr);
|
||||
auto udData = AceType::MakeRefPtr<UnifiedDataImpl>();
|
||||
auto udmfData = static_cast<OH_UdmfData*>(rawData);
|
||||
CHECK_NULL_RETURN(udmfData, nullptr);
|
||||
auto unifiedData = std::make_shared<UDMF::UnifiedData>();
|
||||
auto status = OHOS::UDMF::NdkDataConversion::GetNativeUnifiedData(udmfData, unifiedData);
|
||||
if (status) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
udData->SetUnifiedData(unifiedData);
|
||||
return udData;
|
||||
}
|
||||
|
||||
napi_value UdmfClientImpl::TransformSummary(std::map<std::string, int64_t>& summary)
|
||||
{
|
||||
auto engine = EngineHelper::GetCurrentEngine();
|
||||
|
@ -31,6 +31,8 @@ class UdmfClientImpl : public UdmfClient {
|
||||
public:
|
||||
RefPtr<UnifiedData> CreateUnifiedData() override;
|
||||
RefPtr<UnifiedData> TransformUnifiedData(napi_value napiValue) override;
|
||||
RefPtr<UnifiedData> TransformUnifiedDataForNative(void* rawData) override;
|
||||
void* TransformUnifiedDataPtr(RefPtr<UnifiedData>& unifiedData) override;
|
||||
napi_value TransformUdmfUnifiedData(RefPtr<UnifiedData>& UnifiedData) override;
|
||||
napi_value TransformSummary(std::map<std::string, int64_t>& summary) override;
|
||||
int32_t SetData(const RefPtr<UnifiedData>& unifiedData, std::string& key) override;
|
||||
|
@ -29,6 +29,16 @@ UdmfClient* UdmfClient::GetInstance()
|
||||
return &instance;
|
||||
}
|
||||
|
||||
RefPtr<UnifiedData> UdmfClientImpl::TransformUnifiedDataForNative(void* rawData)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void* UdmfClientImpl::TransformUnifiedDataPtr(RefPtr<UnifiedData>& unifiedData)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<UnifiedData> UdmfClientImpl::TransformUnifiedData(napi_value napiValue)
|
||||
{
|
||||
return nullptr;
|
||||
|
@ -28,6 +28,8 @@ class UdmfClientImpl : public UdmfClient {
|
||||
|
||||
public:
|
||||
RefPtr<UnifiedData> TransformUnifiedData(napi_value napiValue) override;
|
||||
RefPtr<UnifiedData> TransformUnifiedDataForNative(void* rawData) override;
|
||||
void* TransformUnifiedDataPtr(RefPtr<UnifiedData>& unifiedData) override;
|
||||
napi_value TransformUdmfUnifiedData(RefPtr<UnifiedData>& UnifiedData) override;
|
||||
napi_value TransformSummary(std::map<std::string, int64_t>& summary) override;
|
||||
RefPtr<UnifiedData> CreateUnifiedData() override;
|
||||
|
@ -40,6 +40,8 @@ class ACE_FORCE_EXPORT UdmfClient : public AceType {
|
||||
public:
|
||||
static UdmfClient* GetInstance();
|
||||
virtual RefPtr<UnifiedData> TransformUnifiedData(napi_value napiValue) = 0;
|
||||
virtual RefPtr<UnifiedData> TransformUnifiedDataForNative(void* rawData) = 0;
|
||||
virtual void* TransformUnifiedDataPtr(RefPtr<UnifiedData>& unifiedData) = 0;
|
||||
virtual napi_value TransformUdmfUnifiedData(RefPtr<UnifiedData>& UnifiedData) = 0;
|
||||
virtual napi_value TransformSummary(std::map<std::string, int64_t>& summary) = 0;
|
||||
virtual RefPtr<UnifiedData> CreateUnifiedData() = 0;
|
||||
|
@ -1297,6 +1297,17 @@ void ViewAbstract::AddDragFrameNodeToManager()
|
||||
dragDropManager->AddDragFrameNode(frameNode->GetId(), AceType::WeakClaim(frameNode));
|
||||
}
|
||||
|
||||
void ViewAbstract::AddDragFrameNodeToManager(FrameNode* frameNode)
|
||||
{
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
auto pipeline = frameNode->GetContext();
|
||||
CHECK_NULL_VOID(pipeline);
|
||||
auto dragDropManager = pipeline->GetDragDropManager();
|
||||
CHECK_NULL_VOID(dragDropManager);
|
||||
|
||||
dragDropManager->AddDragFrameNode(frameNode->GetId(), AceType::WeakClaim(frameNode));
|
||||
}
|
||||
|
||||
void ViewAbstract::SetDraggable(bool draggable)
|
||||
{
|
||||
auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
|
||||
@ -1332,6 +1343,52 @@ void ViewAbstract::SetOnDragStart(
|
||||
eventHub->SetOnDragStart(std::move(onDragStart));
|
||||
}
|
||||
|
||||
void ViewAbstract::SetOnDragStart(FrameNode* frameNode,
|
||||
std::function<DragDropInfo(const RefPtr<OHOS::Ace::DragEvent>&, const std::string&)>&& onDragStart)
|
||||
{
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
auto gestureHub = frameNode->GetOrCreateGestureEventHub();
|
||||
CHECK_NULL_VOID(gestureHub);
|
||||
gestureHub->InitDragDropEvent();
|
||||
|
||||
auto eventHub = frameNode->GetEventHub<EventHub>();
|
||||
CHECK_NULL_VOID(eventHub);
|
||||
eventHub->SetOnDragStart(std::move(onDragStart));
|
||||
}
|
||||
|
||||
void ViewAbstract::SetOnDragEnter(FrameNode* frameNode,
|
||||
std::function<void(const RefPtr<OHOS::Ace::DragEvent>&, const std::string&)>&& onDragEnter)
|
||||
{
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
auto eventHub = frameNode->GetEventHub<EventHub>();
|
||||
CHECK_NULL_VOID(eventHub);
|
||||
eventHub->SetCustomerOnDragFunc(DragFuncType::DRAG_ENTER, std::move(onDragEnter));
|
||||
|
||||
AddDragFrameNodeToManager(frameNode);
|
||||
}
|
||||
|
||||
void ViewAbstract::SetOnDragMove(FrameNode* frameNode,
|
||||
std::function<void(const RefPtr<OHOS::Ace::DragEvent>&, const std::string&)>&& onDragMove)
|
||||
{
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
auto eventHub = frameNode->GetEventHub<EventHub>();
|
||||
CHECK_NULL_VOID(eventHub);
|
||||
eventHub->SetCustomerOnDragFunc(DragFuncType::DRAG_MOVE, std::move(onDragMove));
|
||||
|
||||
AddDragFrameNodeToManager(frameNode);
|
||||
}
|
||||
|
||||
void ViewAbstract::SetOnDragLeave(FrameNode* frameNode,
|
||||
std::function<void(const RefPtr<OHOS::Ace::DragEvent>&, const std::string&)>&& onDragLeave)
|
||||
{
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
auto eventHub = frameNode->GetEventHub<EventHub>();
|
||||
CHECK_NULL_VOID(eventHub);
|
||||
eventHub->SetCustomerOnDragFunc(DragFuncType::DRAG_LEAVE, std::move(onDragLeave));
|
||||
|
||||
AddDragFrameNodeToManager(frameNode);
|
||||
}
|
||||
|
||||
void ViewAbstract::SetOnPreDrag(std::function<void(const PreDragStatus)>&& onPreDragFunc)
|
||||
{
|
||||
auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeEventHub<EventHub>();
|
||||
@ -1339,6 +1396,14 @@ void ViewAbstract::SetOnPreDrag(std::function<void(const PreDragStatus)>&& onPre
|
||||
eventHub->SetOnPreDrag(std::move(onPreDragFunc));
|
||||
}
|
||||
|
||||
void ViewAbstract::SetOnPreDrag(FrameNode* frameNode, std::function<void(const PreDragStatus)>&& onPreDragFunc)
|
||||
{
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
auto eventHub = frameNode->GetEventHub<EventHub>();
|
||||
CHECK_NULL_VOID(eventHub);
|
||||
eventHub->SetOnPreDrag(std::move(onPreDragFunc));
|
||||
}
|
||||
|
||||
void ViewAbstract::SetOnDragEnter(
|
||||
std::function<void(const RefPtr<OHOS::Ace::DragEvent>&, const std::string&)>&& onDragEnter)
|
||||
{
|
||||
@ -1387,6 +1452,29 @@ void ViewAbstract::SetOnDragEnd(std::function<void(const RefPtr<OHOS::Ace::DragE
|
||||
AddDragFrameNodeToManager();
|
||||
}
|
||||
|
||||
void ViewAbstract::SetOnDragEnd(
|
||||
FrameNode* frameNode, std::function<void(const RefPtr<OHOS::Ace::DragEvent>&)>&& onDragEnd)
|
||||
{
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
auto eventHub = frameNode->GetEventHub<EventHub>();
|
||||
CHECK_NULL_VOID(eventHub);
|
||||
eventHub->SetCustomerOnDragFunc(DragFuncType::DRAG_END, std::move(onDragEnd));
|
||||
|
||||
AddDragFrameNodeToManager(frameNode);
|
||||
}
|
||||
|
||||
void ViewAbstract::SetOnDrop(
|
||||
FrameNode* frameNode, std::function<void(const RefPtr<OHOS::Ace::DragEvent>&, const std::string&)>&& onDrop)
|
||||
{
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
auto eventHub = frameNode->GetEventHub<EventHub>();
|
||||
CHECK_NULL_VOID(eventHub);
|
||||
|
||||
eventHub->SetCustomerOnDragFunc(DragFuncType::DRAG_DROP, std::move(onDrop));
|
||||
|
||||
AddDragFrameNodeToManager(frameNode);
|
||||
}
|
||||
|
||||
void ViewAbstract::SetAlign(Alignment alignment)
|
||||
{
|
||||
if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
|
||||
|
@ -302,6 +302,7 @@ public:
|
||||
std::function<DragDropInfo(const RefPtr<OHOS::Ace::DragEvent> &, const std::string &)> &&onDragStart);
|
||||
static void SetOnPreDrag(
|
||||
std::function<void(const PreDragStatus)> &&onPreDragFunc);
|
||||
static void SetOnPreDrag(FrameNode* frameNode, std::function<void(const PreDragStatus)>&& onPreDragFunc);
|
||||
static void SetOnDragEnter(
|
||||
std::function<void(const RefPtr<OHOS::Ace::DragEvent> &, const std::string &)> &&onDragEnter);
|
||||
static void SetOnDragLeave(
|
||||
@ -309,8 +310,11 @@ public:
|
||||
static void SetOnDragMove(
|
||||
std::function<void(const RefPtr<OHOS::Ace::DragEvent> &, const std::string &)> &&onDragMove);
|
||||
static void SetOnDrop(std::function<void(const RefPtr<OHOS::Ace::DragEvent> &, const std::string &)> &&onDrop);
|
||||
static void SetOnDrop(FrameNode* frameNode, NG::OnDragDropFunc&& onDrop);
|
||||
|
||||
static void SetOnDragEnd(std::function<void(const RefPtr<OHOS::Ace::DragEvent> &)> &&onDragEnd);
|
||||
static void SetOnDragEnd(
|
||||
FrameNode* frameNode, std::function<void(const RefPtr<OHOS::Ace::DragEvent>&)>&& onDragEnd);
|
||||
static void SetMonopolizeEvents(bool monopolizeEvents);
|
||||
static void SetDragEventStrictReportingEnabled(bool dragEventStrictReportingEnabled);
|
||||
|
||||
@ -608,6 +612,14 @@ public:
|
||||
static void SetOnBlur(FrameNode* frameNode, OnBlurFunc &&onBlurCallback);
|
||||
static void SetOnClick(FrameNode* frameNode, GestureEventFunc &&clickEventFunc);
|
||||
static void SetOnTouch(FrameNode* frameNode, TouchEventFunc &&touchEventFunc);
|
||||
static void SetOnDragStart(FrameNode* frameNode,
|
||||
std::function<DragDropInfo(const RefPtr<OHOS::Ace::DragEvent>&, const std::string&)>&& onDragStart);
|
||||
static void SetOnDragEnter(FrameNode* frameNode,
|
||||
std::function<void(const RefPtr<OHOS::Ace::DragEvent>&, const std::string&)>&& onDragEnter);
|
||||
static void SetOnDragMove(FrameNode* frameNode,
|
||||
std::function<void(const RefPtr<OHOS::Ace::DragEvent>&, const std::string&)>&& onDragMove);
|
||||
static void SetOnDragLeave(FrameNode* frameNode,
|
||||
std::function<void(const RefPtr<OHOS::Ace::DragEvent>&, const std::string&)>&& onDragLeave);
|
||||
static void SetOnMouse(FrameNode* frameNode, OnMouseEventFunc &&onMouseEventFunc);
|
||||
static void SetOnHover(FrameNode* frameNode, OnHoverFunc &&onHoverEventFunc);
|
||||
static void SetOnKeyEvent(FrameNode* frameNode, OnKeyCallbackFunc &&onKeyCallback);
|
||||
@ -738,6 +750,7 @@ public:
|
||||
|
||||
private:
|
||||
static void AddDragFrameNodeToManager();
|
||||
static void AddDragFrameNodeToManager(FrameNode* frameNode);
|
||||
static void AddOverlayToFrameNode(const RefPtr<NG::FrameNode>& overlayNode,
|
||||
const std::optional<Alignment>& align, const std::optional<Dimension>& offsetX,
|
||||
const std::optional<Dimension>& offsetY);
|
||||
|
@ -1025,6 +1025,20 @@ public:
|
||||
ViewAbstract::SetOnDragStart(std::move(dragStart));
|
||||
}
|
||||
|
||||
static void SetOnDragStart(FrameNode* frameNode, NG::OnDragStartFunc&& onDragStart)
|
||||
{
|
||||
auto dragStart = [dragStartFunc = std::move(onDragStart)](const RefPtr<OHOS::Ace::DragEvent>& event,
|
||||
const std::string& extraParams) -> DragDropInfo {
|
||||
auto dragInfo = dragStartFunc(event, extraParams);
|
||||
DragDropInfo info;
|
||||
info.extraInfo = dragInfo.extraInfo;
|
||||
info.pixelMap = dragInfo.pixelMap;
|
||||
info.customNode = AceType::DynamicCast<UINode>(dragInfo.node);
|
||||
return info;
|
||||
};
|
||||
ViewAbstract::SetOnDragStart(frameNode, std::move(dragStart));
|
||||
}
|
||||
|
||||
void SetOnPreDrag(NG::OnPreDragFunc&& onPreDrag) override
|
||||
{
|
||||
ViewAbstract::SetOnPreDrag(std::move(onPreDrag));
|
||||
|
@ -219,6 +219,33 @@ struct ArkUIMouseEvent {
|
||||
ArkUI_Int32 interceptResult;
|
||||
};
|
||||
|
||||
struct ArkUIDragEvent {
|
||||
void* unifiedData;
|
||||
void* unifiedDataSummary;
|
||||
ArkUI_Int32 dragResult;
|
||||
ArkUI_Float64 touchPointX;
|
||||
ArkUI_Float64 touchPointY;
|
||||
ArkUI_Float64 previewRectWidth;
|
||||
ArkUI_Float64 previewRectHeight;
|
||||
ArkUI_Float64 velocityX;
|
||||
ArkUI_Float64 velocityY;
|
||||
ArkUI_Float64 velocity;
|
||||
ArkUI_Float64 windowX;
|
||||
ArkUI_Float64 windowY;
|
||||
ArkUI_Float64 displayX;
|
||||
ArkUI_Float64 displayY;
|
||||
ArkUI_Float64 screenX;
|
||||
ArkUI_Float64 screenY;
|
||||
ArkUI_Int64 modifierKeyState;
|
||||
ArkUI_Int32 dragBehavior;
|
||||
bool useCustomDropAnimation;
|
||||
ArkUI_Int32 subKind;
|
||||
ArkUI_Int32 preDragStatus;
|
||||
ArkUI_Int32 dataTypesCount;
|
||||
ArkUI_CharPtr* dataTypes;
|
||||
ArkUI_Int32 dataTypesMaxStrLength;
|
||||
};
|
||||
|
||||
struct ArkUIStringAndFloat {
|
||||
ArkUI_Float32 value;
|
||||
ArkUI_CharPtr valueStr;
|
||||
@ -673,6 +700,7 @@ enum ArkUIEventCategory {
|
||||
TEXT_ARRAY = 8,
|
||||
MOUSE_INPUT_EVENT = 9,
|
||||
MIXED_EVENT = 10,
|
||||
DRAG_EVENT = 11,
|
||||
};
|
||||
|
||||
#define ARKUI_MAX_EVENT_NUM 1000
|
||||
@ -695,6 +723,13 @@ enum ArkUIEventSubKind {
|
||||
ON_ATTACH,
|
||||
ON_DETACH,
|
||||
ON_ACCESSIBILITY_ACTIONS,
|
||||
ON_DRAG_START,
|
||||
ON_DRAG_ENTER,
|
||||
ON_DRAG_DROP,
|
||||
ON_DRAG_MOVE,
|
||||
ON_DRAG_LEAVE,
|
||||
ON_DRAG_END,
|
||||
ON_PRE_DRAG,
|
||||
ON_DETECT_RESULT_UPDATE = ARKUI_MAX_EVENT_NUM * ARKUI_TEXT,
|
||||
ON_IMAGE_COMPLETE = ARKUI_MAX_EVENT_NUM * ARKUI_IMAGE,
|
||||
ON_IMAGE_ERROR,
|
||||
@ -994,6 +1029,7 @@ struct ArkUINodeEvent {
|
||||
ArkUIAPIEventTextArray textArrayEvent;
|
||||
ArkUIMouseEvent mouseEvent;
|
||||
ArkUIMixedEvent mixedEvent;
|
||||
ArkUIDragEvent dragEvent;
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -72,6 +72,7 @@ template("ace_core_interfaces_native_node") {
|
||||
"node/node_container_span_modifier.cpp",
|
||||
"node/node_content_modifier.cpp",
|
||||
"node/node_date_picker_modifier.cpp",
|
||||
"node/node_drag_modifier.cpp",
|
||||
"node/node_folder_stack_modifier.cpp",
|
||||
"node/node_gesture_modifier.cpp",
|
||||
"node/node_image_modifier.cpp",
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include "core/interfaces/native/node/node_canvas_modifier.h"
|
||||
#include "core/interfaces/native/node/node_checkbox_modifier.h"
|
||||
#include "core/interfaces/native/node/node_common_modifier.h"
|
||||
#include "core/interfaces/native/node/node_drag_modifier.h"
|
||||
#include "core/interfaces/native/node/node_date_picker_modifier.h"
|
||||
#include "core/interfaces/native/node/node_image_modifier.h"
|
||||
#include "core/interfaces/native/node/node_list_modifier.h"
|
||||
@ -334,6 +335,13 @@ const ComponentAsyncEventHandler commonNodeAsyncEventHandlers[] = {
|
||||
NodeModifier::SetOnAttach,
|
||||
NodeModifier::SetOnDetach,
|
||||
NodeModifier::SetOnAccessibilityActions,
|
||||
NodeModifier::SetOnDragStart,
|
||||
NodeModifier::SetOnDragEnter,
|
||||
NodeModifier::SetOnDragDrop,
|
||||
NodeModifier::SetOnDragMove,
|
||||
NodeModifier::SetOnDragLeave,
|
||||
NodeModifier::SetOnDragEnd,
|
||||
NodeModifier::SetOnPreDrag,
|
||||
};
|
||||
|
||||
const ComponentAsyncEventHandler scrollNodeAsyncEventHandlers[] = {
|
||||
|
311
frameworks/core/interfaces/native/node/node_drag_modifier.cpp
Normal file
311
frameworks/core/interfaces/native/node/node_drag_modifier.cpp
Normal file
@ -0,0 +1,311 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "core/interfaces/native/node/node_drag_modifier.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "interfaces/native/native_type.h"
|
||||
#include "interfaces/native/node/node_model.h"
|
||||
#include "securec.h"
|
||||
|
||||
#include "base/geometry/ng/vector.h"
|
||||
#include "base/geometry/shape.h"
|
||||
#include "base/image/pixel_map.h"
|
||||
#include "base/log/log_wrapper.h"
|
||||
#include "base/memory/ace_type.h"
|
||||
#include "base/utils/system_properties.h"
|
||||
#include "base/utils/utils.h"
|
||||
#include "bridge/common/utils/utils.h"
|
||||
#include "core/animation/animation_pub.h"
|
||||
#include "core/animation/curves.h"
|
||||
#include "core/common/ime/text_input_type.h"
|
||||
#include "core/common/udmf/udmf_client.h"
|
||||
#include "core/components/common/layout/constants.h"
|
||||
#include "core/components/common/properties/animation_option.h"
|
||||
#include "core/components/common/properties/color.h"
|
||||
#include "core/components/common/properties/decoration.h"
|
||||
#include "core/components/common/properties/shadow.h"
|
||||
#include "core/components/theme/shadow_theme.h"
|
||||
#include "core/components_ng/base/frame_node.h"
|
||||
#include "core/components_ng/base/view_abstract.h"
|
||||
#include "core/components_ng/base/view_abstract_model_ng.h"
|
||||
#include "core/components_ng/pattern/shape/shape_abstract_model_ng.h"
|
||||
#include "core/components_ng/pattern/text/span_model_ng.h"
|
||||
#include "core/components_ng/property/transition_property.h"
|
||||
#include "core/event/axis_event.h"
|
||||
#include "core/gestures/drag_event.h"
|
||||
#include "core/image/image_source_info.h"
|
||||
#include "core/interfaces/arkoala/arkoala_api.h"
|
||||
#include "core/interfaces/native/node/node_api.h"
|
||||
#include "core/interfaces/native/node/touch_event_convertor.h"
|
||||
#include "core/interfaces/native/node/view_model.h"
|
||||
|
||||
namespace OHOS::Ace::NG {
|
||||
namespace NodeModifier {
|
||||
int64_t CalculateModifierKeyState(const std::vector<OHOS::Ace::KeyCode>& status)
|
||||
{
|
||||
int64_t modifierKeysState = 0;
|
||||
// check ctrl
|
||||
if ((std::find(status.begin(), status.end(), OHOS::Ace::KeyCode::KEY_CTRL_LEFT) != std::end(status)) ||
|
||||
(std::find(status.begin(), status.end(), OHOS::Ace::KeyCode::KEY_CTRL_RIGHT) != std::end(status))) {
|
||||
modifierKeysState |= ARKUI_MODIFIER_KEY_CTRL;
|
||||
}
|
||||
// check alt
|
||||
if ((std::find(status.begin(), status.end(), OHOS::Ace::KeyCode::KEY_ALT_LEFT) != std::end(status)) ||
|
||||
(std::find(status.begin(), status.end(), OHOS::Ace::KeyCode::KEY_ALT_RIGHT) != std::end(status))) {
|
||||
modifierKeysState |= ARKUI_MODIFIER_KEY_ALT;
|
||||
}
|
||||
// check shift
|
||||
if ((std::find(status.begin(), status.end(), OHOS::Ace::KeyCode::KEY_SHIFT_LEFT) != std::end(status)) ||
|
||||
(std::find(status.begin(), status.end(), OHOS::Ace::KeyCode::KEY_SHIFT_RIGHT) != std::end(status))) {
|
||||
modifierKeysState |= ARKUI_MODIFIER_KEY_SHIFT;
|
||||
}
|
||||
// check fn
|
||||
if (std::find(status.begin(), status.end(), OHOS::Ace::KeyCode::KEY_FN) != std::end(status)) {
|
||||
modifierKeysState |= ARKUI_MODIFIER_KEY_FN;
|
||||
}
|
||||
|
||||
return modifierKeysState;
|
||||
}
|
||||
|
||||
void SetDragEventProperty(const RefPtr<OHOS::Ace::DragEvent>& info, ArkUINodeEvent& event)
|
||||
{
|
||||
event.dragEvent.touchPointX = info->GetPreviewRect().GetOffset().GetX();
|
||||
event.dragEvent.touchPointY = info->GetPreviewRect().GetOffset().GetY();
|
||||
|
||||
event.dragEvent.windowX = info->GetX();
|
||||
event.dragEvent.windowY = info->GetY();
|
||||
event.dragEvent.displayX = info->GetDisplayX();
|
||||
event.dragEvent.displayY = info->GetDisplayY();
|
||||
event.dragEvent.screenX = info->GetScreenX();
|
||||
event.dragEvent.screenY = info->GetScreenY();
|
||||
|
||||
event.dragEvent.previewRectWidth = info->GetPreviewRect().Width();
|
||||
event.dragEvent.previewRectHeight = info->GetPreviewRect().Height();
|
||||
event.dragEvent.velocityX = info->GetVelocity().GetVelocityX();
|
||||
event.dragEvent.velocityY = info->GetVelocity().GetVelocityY();
|
||||
event.dragEvent.velocity = info->GetVelocity().GetVelocityValue();
|
||||
event.dragEvent.modifierKeyState = NodeModifier::CalculateModifierKeyState(info->GetPressedKeyCodes());
|
||||
auto summary = info->GetSummary();
|
||||
event.dragEvent.dataTypesCount = summary.size();
|
||||
|
||||
int32_t index = 0;
|
||||
int32_t maxLength = 0;
|
||||
std::vector<const char*> strList;
|
||||
std::vector<std::string> keepStr(summary.size());
|
||||
for (auto it = summary.begin(); it != summary.end(); it++) {
|
||||
int32_t keyLength = it->first.length();
|
||||
maxLength = std::max(maxLength, keyLength);
|
||||
keepStr[index] = it->first;
|
||||
strList.push_back(keepStr[index].c_str());
|
||||
++index;
|
||||
}
|
||||
event.dragEvent.dataTypes = strList.data();
|
||||
event.dragEvent.dataTypesMaxStrLength = maxLength;
|
||||
}
|
||||
|
||||
void SetOnDragDrop(ArkUINodeHandle node, void* extraParam)
|
||||
{
|
||||
auto* frameNode = reinterpret_cast<FrameNode*>(node);
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
int32_t nodeId = frameNode->GetId();
|
||||
auto onDragDrop = [frameNode, nodeId, extraParam](
|
||||
const RefPtr<OHOS::Ace::DragEvent>& info, const std::string& extraParams) -> void {
|
||||
ArkUINodeEvent event;
|
||||
event.kind = ArkUIEventCategory::DRAG_EVENT;
|
||||
event.nodeId = nodeId;
|
||||
event.extraParam = reinterpret_cast<intptr_t>(extraParam);
|
||||
event.dragEvent.subKind = ON_DRAG_DROP;
|
||||
|
||||
SetDragEventProperty(info, event);
|
||||
|
||||
auto unifiedData = UdmfClient::GetInstance()->TransformUnifiedDataPtr(info->GetData());
|
||||
|
||||
event.dragEvent.unifiedData = unifiedData;
|
||||
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));
|
||||
};
|
||||
ViewAbstract::SetOnDrop(frameNode, onDragDrop);
|
||||
}
|
||||
|
||||
void SetOnDragStart(ArkUINodeHandle node, void* extraParam)
|
||||
{
|
||||
auto* frameNode = reinterpret_cast<FrameNode*>(node);
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
int32_t nodeId = frameNode->GetId();
|
||||
auto onDragStart = [frameNode, nodeId, extraParam](const RefPtr<OHOS::Ace::DragEvent>& info,
|
||||
const std::string& extraParams) -> NG::DragDropBaseInfo {
|
||||
ArkUINodeEvent event;
|
||||
event.kind = ArkUIEventCategory::DRAG_EVENT;
|
||||
event.nodeId = nodeId;
|
||||
event.extraParam = reinterpret_cast<intptr_t>(extraParam);
|
||||
event.dragEvent.subKind = ON_DRAG_START;
|
||||
SetDragEventProperty(info, event);
|
||||
|
||||
PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
|
||||
SendArkUIAsyncEvent(&event);
|
||||
RefPtr<UnifiedData> udData =
|
||||
UdmfClient::GetInstance()->TransformUnifiedDataForNative(event.dragEvent.unifiedData);
|
||||
|
||||
info->SetData(udData);
|
||||
NG::DragDropBaseInfo dragDropInfo;
|
||||
return dragDropInfo;
|
||||
};
|
||||
ViewAbstractModelNG::SetOnDragStart(frameNode, onDragStart);
|
||||
}
|
||||
|
||||
void SetOnDragEnter(ArkUINodeHandle node, void* extraParam)
|
||||
{
|
||||
auto* frameNode = reinterpret_cast<FrameNode*>(node);
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
int32_t nodeId = frameNode->GetId();
|
||||
auto onDragEnter = [frameNode, nodeId, extraParam](
|
||||
const RefPtr<OHOS::Ace::DragEvent>& info, const std::string& extraParams) {
|
||||
ArkUINodeEvent event;
|
||||
event.kind = ArkUIEventCategory::DRAG_EVENT;
|
||||
event.nodeId = nodeId;
|
||||
event.extraParam = reinterpret_cast<intptr_t>(extraParam);
|
||||
event.dragEvent.subKind = ON_DRAG_ENTER;
|
||||
|
||||
SetDragEventProperty(info, event);
|
||||
auto unifiedData = UdmfClient::GetInstance()->TransformUnifiedDataPtr(info->GetData());
|
||||
|
||||
event.dragEvent.unifiedData = unifiedData;
|
||||
|
||||
PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
|
||||
SendArkUIAsyncEvent(&event);
|
||||
info->SetResult(static_cast<DragRet>(event.dragEvent.dragResult));
|
||||
info->SetDragBehavior(static_cast<DragBehavior>(event.dragEvent.dragBehavior));
|
||||
};
|
||||
ViewAbstract::SetOnDragEnter(frameNode, onDragEnter);
|
||||
}
|
||||
|
||||
void SetOnDragMove(ArkUINodeHandle node, void* extraParam)
|
||||
{
|
||||
auto* frameNode = reinterpret_cast<FrameNode*>(node);
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
int32_t nodeId = frameNode->GetId();
|
||||
auto onDragMove = [frameNode, nodeId, extraParam](
|
||||
const RefPtr<OHOS::Ace::DragEvent>& info, const std::string& extraParams) {
|
||||
ArkUINodeEvent event;
|
||||
event.kind = ArkUIEventCategory::DRAG_EVENT;
|
||||
event.nodeId = nodeId;
|
||||
event.extraParam = reinterpret_cast<intptr_t>(extraParam);
|
||||
event.dragEvent.subKind = ON_DRAG_MOVE;
|
||||
SetDragEventProperty(info, event);
|
||||
auto unifiedData = UdmfClient::GetInstance()->TransformUnifiedDataPtr(info->GetData());
|
||||
event.dragEvent.unifiedData = unifiedData;
|
||||
PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
|
||||
SendArkUIAsyncEvent(&event);
|
||||
info->SetResult(static_cast<DragRet>(event.dragEvent.dragResult));
|
||||
info->SetDragBehavior(static_cast<DragBehavior>(event.dragEvent.dragBehavior));
|
||||
};
|
||||
ViewAbstract::SetOnDragMove(frameNode, onDragMove);
|
||||
}
|
||||
|
||||
void SetOnDragLeave(ArkUINodeHandle node, void* extraParam)
|
||||
{
|
||||
auto* frameNode = reinterpret_cast<FrameNode*>(node);
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
int32_t nodeId = frameNode->GetId();
|
||||
auto onDragLeave = [frameNode, nodeId, extraParam](
|
||||
const RefPtr<OHOS::Ace::DragEvent>& info, const std::string& extraParams) {
|
||||
ArkUINodeEvent event;
|
||||
event.kind = ArkUIEventCategory::DRAG_EVENT;
|
||||
event.nodeId = nodeId;
|
||||
event.extraParam = reinterpret_cast<intptr_t>(extraParam);
|
||||
event.dragEvent.subKind = ON_DRAG_LEAVE;
|
||||
|
||||
SetDragEventProperty(info, event);
|
||||
auto unifiedData = UdmfClient::GetInstance()->TransformUnifiedDataPtr(info->GetData());
|
||||
|
||||
event.dragEvent.unifiedData = unifiedData;
|
||||
PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
|
||||
SendArkUIAsyncEvent(&event);
|
||||
info->SetResult(static_cast<DragRet>(event.dragEvent.dragResult));
|
||||
info->SetDragBehavior(static_cast<DragBehavior>(event.dragEvent.dragBehavior));
|
||||
};
|
||||
ViewAbstract::SetOnDragLeave(frameNode, onDragLeave);
|
||||
}
|
||||
|
||||
void SetOnDragEnd(ArkUINodeHandle node, void* extraParam)
|
||||
{
|
||||
auto* frameNode = reinterpret_cast<FrameNode*>(node);
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
int32_t nodeId = frameNode->GetId();
|
||||
auto onDragEnd = [frameNode, nodeId, extraParam](const RefPtr<OHOS::Ace::DragEvent>& info) -> void {
|
||||
ArkUINodeEvent event;
|
||||
event.kind = ArkUIEventCategory::DRAG_EVENT;
|
||||
event.nodeId = nodeId;
|
||||
event.extraParam = reinterpret_cast<intptr_t>(extraParam);
|
||||
event.dragEvent.subKind = ON_DRAG_END;
|
||||
auto summary = info->GetSummary();
|
||||
event.dragEvent.dataTypesCount = summary.size();
|
||||
|
||||
int32_t index = 0;
|
||||
int32_t maxLength = 0;
|
||||
std::vector<const char*> strList;
|
||||
std::vector<std::string> keepStr(summary.size());
|
||||
for (auto it = summary.begin(); it != summary.end(); it++) {
|
||||
int32_t keyLength = it->first.length();
|
||||
maxLength = std::max(maxLength, keyLength);
|
||||
keepStr[index] = it->first;
|
||||
strList.push_back(keepStr[index].c_str());
|
||||
++index;
|
||||
}
|
||||
event.dragEvent.dataTypes = strList.data();
|
||||
event.dragEvent.dataTypesMaxStrLength = maxLength;
|
||||
|
||||
auto unifiedData = UdmfClient::GetInstance()->TransformUnifiedDataPtr(info->GetData());
|
||||
|
||||
event.dragEvent.unifiedData = unifiedData;
|
||||
|
||||
// Did NOT define pressCode, so will NOT pass presscode to UI.
|
||||
event.dragEvent.dragResult = static_cast<ArkUI_Int32>(info->GetResult());
|
||||
event.dragEvent.dragBehavior = static_cast<ArkUI_Int32>(info->GetDragBehavior());
|
||||
|
||||
PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
|
||||
SendArkUIAsyncEvent(&event);
|
||||
};
|
||||
ViewAbstract::SetOnDragEnd(frameNode, onDragEnd);
|
||||
}
|
||||
|
||||
void SetOnPreDrag(ArkUINodeHandle node, void* extraParam)
|
||||
{
|
||||
auto* frameNode = reinterpret_cast<FrameNode*>(node);
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
int32_t nodeId = frameNode->GetId();
|
||||
auto onPreDrag = [frameNode, nodeId, extraParam](const PreDragStatus preDragStatus) -> void {
|
||||
ArkUINodeEvent event;
|
||||
event.kind = ArkUIEventCategory::COMPONENT_ASYNC_EVENT;
|
||||
event.nodeId = nodeId;
|
||||
event.extraParam = reinterpret_cast<intptr_t>(extraParam);
|
||||
event.componentAsyncEvent.subKind = ON_PRE_DRAG;
|
||||
|
||||
// Did NOT define pressCode, so will NOT pass presscode to UI.
|
||||
event.componentAsyncEvent.data[0].i32 = static_cast<ArkUI_Int32>(preDragStatus);
|
||||
PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
|
||||
SendArkUIAsyncEvent(&event);
|
||||
};
|
||||
ViewAbstract::SetOnPreDrag(frameNode, onPreDrag);
|
||||
}
|
||||
} // namespace NodeModifier
|
||||
} // namespace OHOS::Ace::NG
|
30
frameworks/core/interfaces/native/node/node_drag_modifier.h
Normal file
30
frameworks/core/interfaces/native/node/node_drag_modifier.h
Normal file
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef FRAMEWORKS_INTERFACE_INNER_API_NATIVE_NODE_NODE_DRAG_MODIFIER_H
|
||||
#define FRAMEWORKS_INTERFACE_INNER_API_NATIVE_NODE_NODE_DRAG_MODIFIER_H
|
||||
|
||||
#include "core/interfaces/native/node/node_api.h"
|
||||
|
||||
namespace OHOS::Ace::NG::NodeModifier {
|
||||
void SetOnDragStart(ArkUINodeHandle node, void* extraParam);
|
||||
void SetOnDragDrop(ArkUINodeHandle node, void* extraParam);
|
||||
void SetOnDragEnter(ArkUINodeHandle node, void* extraParam);
|
||||
void SetOnDragMove(ArkUINodeHandle node, void* extraParam);
|
||||
void SetOnDragLeave(ArkUINodeHandle node, void* extraParam);
|
||||
void SetOnDragEnd(ArkUINodeHandle node, void* extraParam);
|
||||
void SetOnPreDrag(ArkUINodeHandle node, void* extraParam);
|
||||
} // namespace OHOS::Ace::NG::NodeModifier
|
||||
#endif // FRAMEWORKS_INTERFACE_INNER_API_NATIVE_NODE_NODE_DRAG_MODIFIER_H
|
@ -53,6 +53,7 @@ ohos_shared_library("ace_ndk") {
|
||||
sources = [
|
||||
"//foundation/arkui/ace_engine/frameworks/core/components/common/properties/color.cpp",
|
||||
"//foundation/arkui/ace_engine/frameworks/core/components/xcomponent/native_interface_xcomponent_impl.cpp",
|
||||
"event/drag_and_drop_impl.cpp",
|
||||
"event/ui_input_event.cpp",
|
||||
"native_interface_xcomponent.cpp",
|
||||
"node/animate_impl.cpp",
|
||||
@ -96,6 +97,7 @@ ohos_shared_library("ace_ndk") {
|
||||
"hilog:libhilog",
|
||||
"image_framework:pixelmap",
|
||||
"napi:ace_napi",
|
||||
"udmf:udmf_client",
|
||||
]
|
||||
version_script =
|
||||
get_label_info(":libace_ndk_rom", "target_gen_dir") + "/" +
|
||||
|
800
interfaces/native/drag_and_drop.h
Normal file
800
interfaces/native/drag_and_drop.h
Normal file
@ -0,0 +1,800 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup ArkUI_NativeModule
|
||||
* @{
|
||||
*
|
||||
* @brief Provides drag and drop APIs of ArkUI on the native side.
|
||||
*
|
||||
* @since 12
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file drag_and_drop.h
|
||||
*
|
||||
* @brief Defines the native drag and drop APIs.
|
||||
*
|
||||
* @library libace_ndk.z.so
|
||||
* @syscap SystemCapability.ArkUI.ArkUI.Full
|
||||
* @since 12
|
||||
*/
|
||||
|
||||
#ifndef ARKUI_NATIVE_DRAG_AND_DROP_H
|
||||
#define ARKUI_NATIVE_DRAG_AND_DROP_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "native_type.h"
|
||||
#include "ui_input_event.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Defines an enum for drag results, which are set by the data receiver and transferred by the system to the
|
||||
* drag source so that the drag source is aware of the data processing result of the receiver.
|
||||
*
|
||||
* @since 12
|
||||
*/
|
||||
typedef enum {
|
||||
/** The drag and drop operation succeeded. */
|
||||
ARKUI_DRAG_RESULT_SUCCESSFUL,
|
||||
/** The drag and drop operation failed. */
|
||||
ARKUI_DRAG_RESULT_FAILED,
|
||||
/** The drag and drop operation was canceled. */
|
||||
ARKUI_DRAG_RESULT_CANCELED,
|
||||
} ArkUI_DragResult;
|
||||
|
||||
/**
|
||||
* @brief Defines an enum for data processing modes used when data is dropped, which affects the display of the badge.
|
||||
*
|
||||
* @since 12
|
||||
*/
|
||||
typedef enum {
|
||||
/** Copy. */
|
||||
ARKUI_DROP_OPERATION_COPY,
|
||||
/** Cut. */
|
||||
ARKUI_DROP_OPERATION_MOVE,
|
||||
} ArkUI_DropOperation;
|
||||
|
||||
/**
|
||||
* @brief Defines an enum for interaction states prior to a drop and drop operation.
|
||||
*
|
||||
* @since 12
|
||||
*/
|
||||
typedef enum {
|
||||
/** Unknown. */
|
||||
ARKUI_PREVIEW_DRAG_STATUS_UNKNOWN = -1,
|
||||
/** A drag gesture is being detected. */
|
||||
ARKUI_PREVIEW_DRAG_STATUS_ACTION_DETECTING,
|
||||
/** The component is ready to be dragged. */
|
||||
ARKUI_PREVIEW_DRAG_STATUS_READY_TO_TRIGGER_DRAG,
|
||||
/** A lift animation is started. */
|
||||
ARKUI_PREVIEW_DRAG_STATUS_PREVIEW_LIFT_STARTED,
|
||||
/** A lift animation is finished. */
|
||||
ARKUI_PREVIEW_DRAG_STATUS_PREVIEW_LIFT_FINISHED,
|
||||
/** A drop animation is started. */
|
||||
ARKUI_PREVIEW_DRAG_STATUS_PREVIEW_LANDING_STARTED,
|
||||
/** A drop animation is finished. */
|
||||
ARKUI_PREVIEW_DRAG_STATUS_PREVIEW_LANDING_FINISHED,
|
||||
/** A drop animation is terminated. */
|
||||
ARKUI_PREVIEW_DRAG_STATUS_CANCELED_BEFORE_DRAG,
|
||||
} ArkUI_PreviewDragStatus;
|
||||
|
||||
/**
|
||||
* @brief Defines an enum for drag preview scale modes.
|
||||
*
|
||||
* @since 12
|
||||
*/
|
||||
typedef enum {
|
||||
/**
|
||||
* The system automatically changes the position of the dragged point based on the scenario and
|
||||
* scales the drag preview based on set rules.
|
||||
*/
|
||||
ARKUI_DRAG_PREVIEW_SCALE_AUTO,
|
||||
/** The system does not scale the drag preview. */
|
||||
ARKUI_DRAG_PREVIEW_SCALE_DISABLED,
|
||||
} ArkUI_DragPreviewScaleMode;
|
||||
|
||||
/**
|
||||
* @brief Defines an enum for drag states.
|
||||
*
|
||||
* @since 12
|
||||
*/
|
||||
typedef enum {
|
||||
/** Unknown. */
|
||||
ARKUI_DRAG_STATUS_UNKNOWN = 0,
|
||||
/** Started. */
|
||||
ARKUI_DRAG_STATUS_STARTED,
|
||||
/** Ended. */
|
||||
ARKUI_DRAG_STATUS_ENDED,
|
||||
} ArkUI_DragStatus;
|
||||
|
||||
/**
|
||||
* @brief Defines a struct for a component event.
|
||||
*
|
||||
* @since 12
|
||||
*/
|
||||
typedef struct ArkUI_NodeEvent ArkUI_NodeEvent;
|
||||
|
||||
/**
|
||||
* @brief Defines a struct for a UI context object.
|
||||
*
|
||||
* @since 12
|
||||
*/
|
||||
typedef struct ArkUI_Context ArkUI_Context;
|
||||
|
||||
/**
|
||||
* @brief Defines a struct for a UI context object pointer.
|
||||
*
|
||||
* @since 12
|
||||
*/
|
||||
typedef struct ArkUI_Context* ArkUI_ContextHandle;
|
||||
|
||||
/**
|
||||
* @brief Defines a struct for a drag event.
|
||||
*
|
||||
* @since 12
|
||||
*/
|
||||
typedef struct ArkUI_DragEvent ArkUI_DragEvent;
|
||||
|
||||
/**
|
||||
* @brief Defines a struct for custom drag preview options.
|
||||
*
|
||||
* @since 12
|
||||
*/
|
||||
typedef struct ArkUI_DragPreviewOption ArkUI_DragPreviewOption;
|
||||
|
||||
/**
|
||||
* @brief Defines a struct for a drag action.
|
||||
*
|
||||
* @since 12
|
||||
*/
|
||||
typedef struct ArkUI_DragAction ArkUI_DragAction;
|
||||
|
||||
/**
|
||||
* @brief Defines a struct for drag and drop information returned through a drag status listener.
|
||||
*
|
||||
* @since 12
|
||||
*/
|
||||
typedef struct ArkUI_DragAndDropInfo ArkUI_DragAndDropInfo;
|
||||
|
||||
/**
|
||||
* @brief Defines a struct for UDMF unified data.
|
||||
*
|
||||
* @since 12
|
||||
*/
|
||||
typedef struct OH_UdmfData OH_UdmfData;
|
||||
|
||||
/**
|
||||
* @brief Defines the <b>Pixelmap</b> struct, which is used to perform operations related to a pixel map.
|
||||
*
|
||||
* @since 12
|
||||
*/
|
||||
typedef struct OH_PixelmapNative OH_PixelmapNative;
|
||||
|
||||
/**
|
||||
* @brief Obtains a <b>ArkUI_DragEvent</b> object from the specified <b>ArkUI_NodeEvent</b> object.
|
||||
*
|
||||
* @param node Indicates the pointer to an <b>ArkUI_NodeEvent</b> object.
|
||||
* @return Returns the pointer to an <b>ArkUI_DragEvent</b> object.
|
||||
* Returns <b>null</b> if the parameter passed in is invalid or is not a drag-related event.
|
||||
* @since 12
|
||||
*/
|
||||
ArkUI_DragEvent* OH_ArkUI_NodeEvent_GetDragEvent(ArkUI_NodeEvent* nodeEvent);
|
||||
|
||||
/**
|
||||
* @brief Obtains the interaction state prior to a drop and drop operation.
|
||||
*
|
||||
* @param node Indicates the pointer to an <b>ArkUI_NodeEvent</b> object.
|
||||
* @return Returns the interaction state prior to the drop and drop operation.
|
||||
* @since 12
|
||||
*/
|
||||
ArkUI_PreviewDragStatus OH_ArkUI_NodeEvent_GetPreviewDragStatus(ArkUI_NodeEvent* nodeEvent);
|
||||
|
||||
/**
|
||||
* @brief Sets whether to disable the default drop animation.
|
||||
* The default drop animation is enabled by default and can be disabled to apply a custom drop animation.
|
||||
*
|
||||
* @param event Indicates the pointer to an <b>ArkUI_DragEvent</b> object.
|
||||
* @param disable Indicates whether to disable the default drop animation.
|
||||
* The value <b>true</b> means to disable the default drop animation, and <b>false</b> means the opposite.
|
||||
* @return Returns the result code.
|
||||
* Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
|
||||
* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
|
||||
* @since 12
|
||||
*/
|
||||
int32_t OH_ArkUI_DragEvent_DisableDefaultDropAnimation(ArkUI_DragEvent* event, bool disable);
|
||||
|
||||
/**
|
||||
* @brief Sets the data processing mode.
|
||||
*
|
||||
* @param event Indicates the pointer to an <b>ArkUI_DragEvent</b> object.
|
||||
* @param dropOperation Indicates the data processing mode.
|
||||
* @return Returns the result code.
|
||||
* Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
|
||||
* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
|
||||
* @since 12
|
||||
*/
|
||||
int32_t OH_ArkUI_DragEvent_SetSuggestedDropOperation(ArkUI_DragEvent* event, ArkUI_DropOperation dropOperation);
|
||||
|
||||
/**
|
||||
* @brief Sets the result for a drag event.
|
||||
*
|
||||
* @param event Indicates the pointer to an <b>ArkUI_DragEvent</b> object.
|
||||
* @param result Indicates the drag result.
|
||||
* @return Returns the result code.
|
||||
* Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
|
||||
* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
|
||||
* @since 12
|
||||
*/
|
||||
int32_t OH_ArkUI_DragEvent_SetDragResult(ArkUI_DragEvent* event, ArkUI_DragResult result);
|
||||
|
||||
/**
|
||||
* @brief Set drag data for a drag event.
|
||||
*
|
||||
* @param event Indicates the pointer to an <b>ArkUI_DragEvent</b> object.
|
||||
* @param data Indicates the drag data.
|
||||
* @return Returns the result code.
|
||||
* Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
|
||||
* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
|
||||
* @since 12
|
||||
*/
|
||||
int32_t OH_ArkUI_DragEvent_SetData(ArkUI_DragEvent* event, OH_UdmfData* data);
|
||||
|
||||
/**
|
||||
* @brief Obtains the default drag data from a drag event.
|
||||
*
|
||||
* @param event Indicates the pointer to an <b>ArkUI_DragEvent</b> object.
|
||||
* @param data Indicates the pointer to an <b>OH_UdmfData</b> object. The application needs to create a pointer
|
||||
* for receiving data by using the {@link OH_UdmfData_Create} method.
|
||||
* @return Returns the result code.
|
||||
* Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
|
||||
* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
|
||||
* @since 12
|
||||
*/
|
||||
int32_t OH_ArkUI_DragEvent_GetUdmfData(ArkUI_DragEvent* event, OH_UdmfData *data);
|
||||
|
||||
/**
|
||||
* @brief Obtains the number of drag data types from a drag event.
|
||||
*
|
||||
* @param event Indicates the pointer to an <b>ArkUI_DragEvent</b> object.
|
||||
* @param count Indicates the number of drag data types returned.
|
||||
* @return Returns the result code.
|
||||
* Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
|
||||
* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
|
||||
* @since 12
|
||||
*/
|
||||
int32_t OH_ArkUI_DragEvent_GetDataTypeCount(ArkUI_DragEvent* event, int32_t* count);
|
||||
|
||||
/**
|
||||
* @brief Obtains the list of drag data types from a drag event.
|
||||
*
|
||||
* @param event Indicates the pointer to an <b>ArkUI_DragEvent</b> object.
|
||||
* @param eventTypeArray Indicates the list of the drag data types. You need to create a string array first.
|
||||
* @param length Indicates the total length of the list array. It must be greater than or equal to the number obtained
|
||||
* by using {@link OH_ArkUI_DragEvent_GetDataTypeCount}.
|
||||
* @param maxStrLen Indicates the max string length of drag data types.
|
||||
* @return Returns the result code.
|
||||
* Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
|
||||
* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
|
||||
* Returns {@link ARKUI_ERROR_CODE_BUFFER_SIZE_ERROR} if the giving buffer is not enough for string copy.
|
||||
* @since 12
|
||||
*/
|
||||
int32_t OH_ArkUI_DragEvent_GetDataTypes(
|
||||
ArkUI_DragEvent *event, char *eventTypeArray[], int32_t length, int32_t maxStrLen);
|
||||
|
||||
/**
|
||||
* @brief Obtains the drag result from a drag event.
|
||||
*
|
||||
* @param event Indicates the pointer to an <b>ArkUI_DragEvent</b> object.
|
||||
* @param result Indicates the drag result returned.
|
||||
* @return Returns the result code.
|
||||
* Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
|
||||
* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
|
||||
* @since 12
|
||||
*/
|
||||
int32_t OH_ArkUI_DragEvent_GetDragResult(ArkUI_DragEvent* event, ArkUI_DragResult* result);
|
||||
|
||||
/**
|
||||
* @brief Obtains the X coordinate of the touch point for a drag preview from a drag event.
|
||||
*
|
||||
* @param event Indicates the pointer to an <b>ArkUI_DragEvent</b> object.
|
||||
* @return Returns the X coordinate of the touch point, in px.
|
||||
* Returns the default value <b>0</b> if the input parameter is invalid.
|
||||
* @since 12
|
||||
*/
|
||||
float OH_ArkUI_DragEvent_GetPreviewTouchPointX(ArkUI_DragEvent* event);
|
||||
|
||||
/**
|
||||
* @brief Obtains the Y coordinate of the touch point for a drag preview from a drag event.
|
||||
*
|
||||
* @param event Indicates the pointer to an <b>ArkUI_DragEvent</b> object.
|
||||
* @return Returns the Y coordinate of the touch point, in px.
|
||||
* Returns the default value <b>0</b> if the input parameter is invalid.
|
||||
* @since 12
|
||||
*/
|
||||
float OH_ArkUI_DragEvent_GetPreviewTouchPointY(ArkUI_DragEvent* event);
|
||||
|
||||
/**
|
||||
* @brief Obtains the width of a drag preview from a drag event.
|
||||
*
|
||||
* @param event Indicates the pointer to an <b>ArkUI_DragEvent</b> object.
|
||||
* @return Returns the width of the drag preview, in px.
|
||||
* Returns the default value <b>0</b> if the input parameter is invalid.
|
||||
* @since 12
|
||||
*/
|
||||
float OH_ArkUI_DragEvent_GetPreviewRectWidth(ArkUI_DragEvent* event);
|
||||
|
||||
/**
|
||||
* @brief Obtains the height of a drag preview from a drag event.
|
||||
*
|
||||
* @param event Indicates the pointer to an <b>ArkUI_DragEvent</b> object.
|
||||
* @return Returns the height of the drag preview, in px.
|
||||
* Returns the default value <b>0</b> if the input parameter is invalid.
|
||||
* @since 12
|
||||
*/
|
||||
float OH_ArkUI_DragEvent_GetPreviewRectHeight(ArkUI_DragEvent* event);
|
||||
|
||||
/**
|
||||
* @brief Obtains the X coordinate of the touch point relative to the window from a drag event.
|
||||
*
|
||||
* @param event Indicates the pointer to an <b>ArkUI_DragEvent</b> object.
|
||||
* @return Returns the X coordinate of the touch point relative to the window, in px.
|
||||
* Returns the default value <b>0</b> if the input parameter is invalid.
|
||||
* @since 12
|
||||
*/
|
||||
float OH_ArkUI_DragEvent_GetTouchPointXToWindow(ArkUI_DragEvent* event);
|
||||
|
||||
/**
|
||||
* @brief Obtains the Y coordinate of the touch point relative to the window from a drag event.
|
||||
*
|
||||
* @param event Indicates the pointer to an <b>ArkUI_DragEvent</b> object.
|
||||
* @return Returns the Y coordinate of the touch point relative to the window, in px.
|
||||
* Returns the default value <b>0</b> if the input parameter is invalid.
|
||||
* @since 12
|
||||
*/
|
||||
float OH_ArkUI_DragEvent_GetTouchPointYToWindow(ArkUI_DragEvent* event);
|
||||
|
||||
/**
|
||||
* @brief Obtains the X coordinate of the touch point relative to the current display from a drag event.
|
||||
*
|
||||
* @param event Indicates the pointer to an <b>ArkUI_DragEvent</b> object.
|
||||
* @return Returns the X coordinate of the touch point relative to the current display, in px.
|
||||
* Returns the default value <b>0</b> if the input parameter is invalid.
|
||||
* @since 12
|
||||
*/
|
||||
float OH_ArkUI_DragEvent_GetTouchPointXToDisplay(ArkUI_DragEvent* event);
|
||||
|
||||
/**
|
||||
* @brief Obtains the Y coordinate of the touch point relative to the current display from a drag event.
|
||||
*
|
||||
* @param event Indicates the pointer to an <b>ArkUI_DragEvent</b> object.
|
||||
* @return Returns the Y coordinate of the touch point relative to the current display, in px.
|
||||
* Returns the default value <b>0</b> if the input parameter is invalid.
|
||||
* @since 12
|
||||
*/
|
||||
float OH_ArkUI_DragEvent_GetTouchPointYToDisplay(ArkUI_DragEvent* event);
|
||||
|
||||
/**
|
||||
* @brief Obtains the dragging velocity along the x-axis.
|
||||
*
|
||||
* @param event Indicates the pointer to an <b>ArkUI_DragEvent</b> object.
|
||||
* @return Returns the dragging velocity along the x-axis, in px.
|
||||
* Returns the default value <b>0</b> if the input parameter is invalid.
|
||||
* @since 12
|
||||
*/
|
||||
float OH_ArkUI_DragEvent_GetVelocityX(ArkUI_DragEvent* event);
|
||||
|
||||
/**
|
||||
* @brief Obtains the dragging velocity along the y-axis.
|
||||
*
|
||||
* @param event Indicates the pointer to an <b>ArkUI_DragEvent</b> object.
|
||||
* @return Returns the dragging velocity along the y-axis, in px.
|
||||
* Returns the default value <b>0</b> if the input parameter is invalid.
|
||||
* @since 12
|
||||
*/
|
||||
float OH_ArkUI_DragEvent_GetVelocityY(ArkUI_DragEvent* event);
|
||||
|
||||
/**
|
||||
* @brief Obtains the dragging velocity along the main axis.
|
||||
*
|
||||
* @param event Indicates the pointer to an <b>ArkUI_DragEvent</b> object.
|
||||
* @return Returns the dragging velocity along the main axis, in px.
|
||||
* Returns the default value <b>0</b> if the input parameter is invalid.
|
||||
* @since 12
|
||||
*/
|
||||
float OH_ArkUI_DragEvent_GetVelocity(ArkUI_DragEvent* event);
|
||||
|
||||
/**
|
||||
* @brief Obtains the pressed status of modifier keys from a drag event.
|
||||
*
|
||||
* @param event Indicates the pointer to an <b>ArkUI_DragEvent</b> object.
|
||||
* @param keys Indicates the returned combination of modifier keys that are currently pressed.
|
||||
* The application can determine the pressed modifier keys through bitwise operations.
|
||||
* @return Returns the result code.
|
||||
* Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
|
||||
* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
|
||||
* @since 12
|
||||
*/
|
||||
int32_t OH_ArkUI_DragEvent_GetModifierKeyStates(ArkUI_DragEvent* event, int64_t* keys);
|
||||
|
||||
/**
|
||||
* @brief Sets whether to enable strict reporting on drag events.
|
||||
* This feature is disabled by default, and you are advised to enable it.
|
||||
* If this feature is disabled, the parent component is not notified when an item in it is dragged over its child
|
||||
* component. If this feature is enabled, the component is notified of the dragged item's leaving, and the chil
|
||||
* component to which the dragged item is dropped is notified of the item's entering. This configuration is
|
||||
* related to a specific UI instance. You can pass in a specific component node on the current UI instance
|
||||
* for association.
|
||||
*
|
||||
* @param node Indicates the pointer to a component node.
|
||||
* @param enabled Indicates whether to enable strict reporting on drag events.
|
||||
* @return Returns the result code.
|
||||
* Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
|
||||
* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
|
||||
* @since 12
|
||||
*/
|
||||
int32_t OH_ArkUI_SetDragEventStrictReportWithNode(ArkUI_NodeHandle node, bool enabled);
|
||||
|
||||
/**
|
||||
* @brief Sets whether to enable strict reporting on drag events.
|
||||
* This feature is disabled by default, and you are advised to enable it.
|
||||
* If this feature is disabled, the parent component is not notified when an item in it is dragged over its child
|
||||
* component. If this feature is enabled, the component is notified of the dragged item's leaving, and the child
|
||||
* component to which the dragged item is dropped is notified of the item's entering. This configuration is
|
||||
* related to a specific UI instance. You can pass in a specific UI instance for association.
|
||||
*
|
||||
* @param uiContext Indicates the pointer to a UI instance.
|
||||
* @param enabled Indicates whether to enable strict reporting on drag events.
|
||||
* @return Returns the result code.
|
||||
* Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
|
||||
* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
|
||||
* @since 12
|
||||
*/
|
||||
int32_t OH_ArkUI_SetDragEventStrictReportWithContext(ArkUI_ContextHandle uiContext, bool enabled);
|
||||
|
||||
/**
|
||||
* @brief Sets the types of data that can be dropped to the specified component. This API resets the settings configured
|
||||
* through {@link OH_ArkUI_DisallowNodeAnyDropDataTypes} and {@link OH_ArkUI_AllowNodeAllDropDataTypes}.
|
||||
*
|
||||
* @param node Indicates the pointer to a component node.
|
||||
* @param typesArray Indicates the array of types of data that can be dropped.
|
||||
* @param count Indicates length of an array.
|
||||
* @return Returns the result code.
|
||||
* Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
|
||||
* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
|
||||
* @since 12
|
||||
*/
|
||||
int32_t OH_ArkUI_SetNodeAllowedDropDataTypes(ArkUI_NodeHandle node, const char* typesArray[], int32_t count);
|
||||
|
||||
/**
|
||||
* @brief Configures the specified component to disallow any data types. This API resets the settings configured through
|
||||
* {@link OH_ArkUI_SetNodeAllowedDropDataTypes}.
|
||||
*
|
||||
* @param node Indicates the pointer to a component node.
|
||||
* @return Returns the result code.
|
||||
* Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
|
||||
* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
|
||||
* @since 12
|
||||
*/
|
||||
int32_t OH_ArkUI_DisallowNodeAnyDropDataTypes(ArkUI_NodeHandle node);
|
||||
|
||||
/**
|
||||
* @brief Configures the specified component to allow any data types. This API resets the settings configured through
|
||||
* {@link OH_ArkUI_SetNodeAllowedDropDataTypes}.
|
||||
*
|
||||
* @param node Indicates the pointer to a component node.
|
||||
* @return Returns the result code.
|
||||
* Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
|
||||
* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
|
||||
* @since 12
|
||||
*/
|
||||
int32_t OH_ArkUI_AllowNodeAllDropDataTypes(ArkUI_NodeHandle node);
|
||||
|
||||
/**
|
||||
* @brief Sets whether the specified component is draggable.
|
||||
*
|
||||
* @param node Indicates the pointer to a component node.
|
||||
* @param bool Indicates whether the component is draggable.
|
||||
* @return Returns the result code.
|
||||
* Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
|
||||
* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
|
||||
* @since 12
|
||||
*/
|
||||
int32_t OH_ArkUI_SetNodeDraggable(ArkUI_NodeHandle node, bool enabled);
|
||||
|
||||
/**
|
||||
* @brief Sets a custom drag preview for the specified component.
|
||||
*
|
||||
* @param node Indicates the pointer to a component node.
|
||||
* @param preview Indicates the custom drag preview, which is a pixel map.
|
||||
* @return Returns the result code.
|
||||
* Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
|
||||
* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
|
||||
* @since 12
|
||||
*/
|
||||
int32_t OH_ArkUI_SetNodeDragPreview(ArkUI_NodeHandle node, OH_PixelmapNative* preview);
|
||||
|
||||
/**
|
||||
* @brief Creates an <b>ArkUI_DragPreviewOption</b> object.
|
||||
*
|
||||
* @return Returns the created <b>ArkUI_DragPreviewOption</b> object.
|
||||
* @since 12
|
||||
*/
|
||||
ArkUI_DragPreviewOption* OH_ArkUI_CreateDragPreviewOption(void);
|
||||
|
||||
/**
|
||||
* @brief Disposes of a <b>ArkUI_DragPreviewOption</b> object.
|
||||
*
|
||||
* @param option Indicates the pointer to an <b>ArkUI_DragPreviewOption</b> object.
|
||||
* @since 12
|
||||
*/
|
||||
void OH_ArkUI_DragPreviewOption_Dispose(ArkUI_DragPreviewOption* option);
|
||||
|
||||
/**
|
||||
* @brief Sets the scale mode for an <b>ArkUI_DragPreviewOption</b> object.
|
||||
*
|
||||
* @param option Indicates the pointer to an <b>ArkUI_DragPreviewOption</b> object.
|
||||
* @param scaleMode Indicates the scale mode.
|
||||
* @return Returns the result code.
|
||||
* Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
|
||||
* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
|
||||
* @since 12
|
||||
*/
|
||||
int32_t OH_ArkUI_DragPreviewOption_SetScaleMode(ArkUI_DragPreviewOption* option, ArkUI_DragPreviewScaleMode scaleMode);
|
||||
|
||||
/**
|
||||
* @brief Sets whether to enable the shadow effect for an <b>ArkUI_DragPreviewOption</b> object.
|
||||
* The shadow effect is enabled by default.
|
||||
*
|
||||
* @param option Indicates the pointer to an <b>ArkUI_DragPreviewOption</b> object.
|
||||
* @param enabled Indicates whether to enable the shadow effect.
|
||||
* @return Returns the result code.
|
||||
* Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
|
||||
* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
|
||||
* @since 12
|
||||
*/
|
||||
int32_t OH_ArkUI_DragPreviewOption_SetDefaultShadowEnabled(ArkUI_DragPreviewOption* option, bool enabled);
|
||||
|
||||
/**
|
||||
* @brief Sets whether to enable the rounded corner effect for an <b>ArkUI_DragPreviewOption</b> object.
|
||||
* The rounded corner effect is enabled by default.
|
||||
*
|
||||
* @param option Indicates the pointer to an <b>ArkUI_DragPreviewOption</b> object.
|
||||
* @param enabled Indicates whether to enable the rounded corner effect.
|
||||
* @return Returns the result code.
|
||||
* Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
|
||||
* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
|
||||
* @since 12
|
||||
*/
|
||||
int32_t OH_ArkUI_DragPreviewOption_SetDefaultRadiusEnabled(ArkUI_DragPreviewOption* option, bool enabled);
|
||||
|
||||
/**
|
||||
* @brief Sets whether to enable the badge for an <b>ArkUI_DragPreviewOption</b> object.
|
||||
* If this feature is enabled, a badge that contains the number of dragged items is displayed.
|
||||
*
|
||||
* @param option Indicates the pointer to an <b>ArkUI_DragPreviewOption</b> object.
|
||||
* @param enabled Indicates whether to enable badge.
|
||||
* @return Returns the result code.
|
||||
* Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
|
||||
* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
|
||||
* @since 12
|
||||
*/
|
||||
int32_t OH_ArkUI_DragPreviewOption_SetNumberBadgeEnabled(ArkUI_DragPreviewOption* option, bool enabled);
|
||||
|
||||
/**
|
||||
* @brief Sets the count on the badge.
|
||||
* The settings will overwrite the value in the <b>SetDragPreviewNumberBadgeEnabled</b> API.
|
||||
*
|
||||
* @param option Indicates the pointer to an <b>ArkUI_DragPreviewOption</b> object.
|
||||
* @param forcedNumber Indicates the count on the badge.
|
||||
* @return Returns the result code.
|
||||
* Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
|
||||
* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
|
||||
* @since 12
|
||||
*/
|
||||
int32_t OH_ArkUI_DragPreviewOption_SetBadgeNumber(ArkUI_DragPreviewOption* option, uint32_t forcedNumber);
|
||||
|
||||
/**
|
||||
* @brief Sets whether to enable the default animation on a click or touch, it's not used in drag action.
|
||||
*
|
||||
* @param option Indicates the pointer to an <b>ArkUI_DragPreviewOption</b> object.
|
||||
* @param enabled Indicates whether to enable the default animation on a click or touch.
|
||||
* @return Returns the result code.
|
||||
* Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
|
||||
* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
|
||||
* @since 12
|
||||
*/
|
||||
int32_t OH_ArkUI_DragPreviewOption_SetDefaultAnimationBeforeLiftingEnabled(
|
||||
ArkUI_DragPreviewOption* option, bool enabled);
|
||||
/**
|
||||
* @brief Sets an <b>ArkUI_DragPreviewOption</b> object for the specified component.
|
||||
*
|
||||
* @param node Indicates the pointer to a component node.
|
||||
* @param option Indicates the pointer to an <b>ArkUI_DragPreviewOption</b> object.
|
||||
* @return Returns the result code.
|
||||
* Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
|
||||
* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
|
||||
* @since 12
|
||||
*/
|
||||
int32_t OH_ArkUI_SetNodeDragPreviewOption(ArkUI_NodeHandle node, ArkUI_DragPreviewOption* option);
|
||||
|
||||
/**
|
||||
* @brief Creates a drag action object for a UI instance based on the specified component node of the current
|
||||
* UI instance.
|
||||
*
|
||||
* @param node Indicates the pointer to a component node.
|
||||
* @return Returns the pointer to the created drag action object; returns null if the operation fails.
|
||||
* @since 12
|
||||
*/
|
||||
ArkUI_DragAction* OH_ArkUI_CreateDragActionWithNode(ArkUI_NodeHandle node);
|
||||
|
||||
/**
|
||||
* @brief Creates a drag action object for the specified UI instance.
|
||||
*
|
||||
* @param uiContext Indicates the pointer to a UI instance.
|
||||
* @return Returns the pointer to the created drag action object; returns null if the operation fails.
|
||||
* @since 12
|
||||
*/
|
||||
ArkUI_DragAction* OH_ArkUI_CreateDragActionWithContext(ArkUI_ContextHandle uiContext);
|
||||
|
||||
/**
|
||||
* @brief Disposes of a drag action object.
|
||||
*
|
||||
* @param dragAction Indicates the pointer to the target drag action object.
|
||||
* @since 12
|
||||
*/
|
||||
void OH_ArkUI_DragAction_Dispose(ArkUI_DragAction* dragAction);
|
||||
|
||||
/**
|
||||
* @brief Sets the pointer ID. If only one finger is operating on the screen, the pointer ID is 0.
|
||||
* In general cases, you can set the pointer ID to 0.
|
||||
*
|
||||
* @param dragAction Indicates the pointer to the target drag action object.
|
||||
* @param pointer Indicates the pointer ID. The value ranges from 0 to 9.
|
||||
* @return Returns the result code.
|
||||
* Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
|
||||
* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
|
||||
* @since 12
|
||||
*/
|
||||
int32_t OH_ArkUI_DragAction_SetPointerId(ArkUI_DragAction* dragAction, int32_t pointer);
|
||||
|
||||
/**
|
||||
* @brief Sets the drag previews for a drag action.
|
||||
*
|
||||
* @param dragAction Indicates the pointer to the target drag action object.
|
||||
* @param pixelmapArray Indicates the array of the drag previews to set, which must be pixel maps.
|
||||
* @param size Indicates the size of the drag preview array.
|
||||
* @return Returns the result code.
|
||||
* Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
|
||||
* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
|
||||
* @since 12
|
||||
*/
|
||||
int32_t OH_ArkUI_DragAction_SetPixelMaps(
|
||||
ArkUI_DragAction* dragAction, OH_PixelmapNative* pixelmapArray[], int32_t size);
|
||||
|
||||
/**
|
||||
* @brief Sets the touch point relative to the upper left corner of the first drag preview (pixel map).
|
||||
*
|
||||
* @param dragAction Indicates the pointer to the target drag action object.
|
||||
* @param x Indicates the X coordinate of the touch point.
|
||||
* @return Returns the result code.
|
||||
* Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
|
||||
* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
|
||||
* @since 12
|
||||
*/
|
||||
int32_t OH_ArkUI_DragAction_SetTouchPointX(ArkUI_DragAction* dragAction, float x);
|
||||
|
||||
/**
|
||||
* @brief Sets the touch point relative to the upper left corner of the first drag preview (pixel map).
|
||||
*
|
||||
* @param dragAction Indicates the pointer to the target drag action object.
|
||||
* @param y Indicates the Y coordinate of the touch point.
|
||||
* @return Returns the result code.
|
||||
* Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
|
||||
* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
|
||||
* @since 12
|
||||
*/
|
||||
int32_t OH_ArkUI_DragAction_SetTouchPointY(ArkUI_DragAction* dragAction, float y);
|
||||
|
||||
/**
|
||||
* @brief Sets the drag data.
|
||||
*
|
||||
* @param dragAction Indicates the pointer to the target drag action object.
|
||||
* @param data Indicates the drag data.
|
||||
* @return Returns the result code.
|
||||
* Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
|
||||
* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
|
||||
* @since 12
|
||||
*/
|
||||
int32_t OH_ArkUI_DragAction_SetData(ArkUI_DragAction* dragAction, OH_UdmfData* data);
|
||||
|
||||
/**
|
||||
* @brief Sets an <b>ArkUI_DragPreviewOption</b> object for the specified drag action object.
|
||||
*
|
||||
* @param dragAction Indicates the pointer to the target drag action object.
|
||||
* @param option Indicates the pointer to an <b>ArkUI_DragPreviewOption</b> object.
|
||||
* @return Returns the result code.
|
||||
* Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
|
||||
* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
|
||||
* @since 12
|
||||
*/
|
||||
int32_t OH_ArkUI_DragAction_SetDragPreviewOption(ArkUI_DragAction* dragAction, ArkUI_DragPreviewOption* option);
|
||||
|
||||
/**
|
||||
* @brief Registers a drag status listener.
|
||||
* This listener can be used to check whether the data is successfully received and processed.
|
||||
*
|
||||
* @param dragAction Indicates the pointer to the target drag action object.
|
||||
* @param userData Indicates the custom user data.
|
||||
* @param listener
|
||||
* Indicates the listener to register. When the callback is invoked, the system returns a pointer to the drag status
|
||||
* object. The pointer is destroyed after the callback is complete and the application should not hold it anymore.
|
||||
* @return Returns the result code.
|
||||
* Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
|
||||
* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
|
||||
* @since 12
|
||||
*/
|
||||
int32_t OH_ArkUI_DragAction_RegisterStatusListener(ArkUI_DragAction* dragAction, void* userData,
|
||||
void(*listener)(ArkUI_DragAndDropInfo* dragAndDropInfo, void* userData));
|
||||
|
||||
/**
|
||||
* @brief Unregisters a drag status listener.
|
||||
*
|
||||
* @param dragAction Indicates the pointer to the target drag action object.
|
||||
* @since 12
|
||||
*/
|
||||
void OH_ArkUI_DragAction_UnregisterStatusListener(ArkUI_DragAction* dragAction);
|
||||
|
||||
/**
|
||||
* @brief Obtains the drag status of a drag action.
|
||||
*
|
||||
* @param dragAndDropInfo Indicates the drag and drop information returned by the drag status listener.
|
||||
* @return Returns an <b>ArkUI_DragStatus</b> object; returns <b>ArkUI_DRAG_STATUS_UNKNOWN</b> if an error occurs.
|
||||
* @since 12
|
||||
*/
|
||||
ArkUI_DragStatus OH_ArkUI_DragAndDropInfo_GetDragStatus(ArkUI_DragAndDropInfo* dragAndDropInfo);
|
||||
|
||||
/**
|
||||
* @brief Obtains a drag event based on the specified drag and drop information.
|
||||
* The drag event can then be used to obtain the drag result and the drag behavior, please note
|
||||
* other info is not included in such a drag event.
|
||||
*
|
||||
* @param dragAndDropInfo Indicates the drag and drop information returned by the drag status listener.
|
||||
* @return Returns an <b>ArkUI_DragEvent</b> object; returns null if an error occurs.
|
||||
* @since 12
|
||||
*/
|
||||
ArkUI_DragEvent* OH_ArkUI_DragAndDropInfo_GetDragEvent(ArkUI_DragAndDropInfo* dragAndDropInfo);
|
||||
|
||||
/**
|
||||
* @brief Initiates a drag action through the specified drag action object.
|
||||
*
|
||||
* @param dragAction Indicates a drag action object.
|
||||
* @return Returns the result code.
|
||||
* Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
|
||||
* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
|
||||
* @since 12
|
||||
*/
|
||||
int32_t OH_ArkUI_StartDrag(ArkUI_DragAction* dragAction);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif // ARKUI_NATIVE_DRAG_AND_DROP_H
|
||||
/** @} */
|
113
interfaces/native/event/drag_and_drop_impl.cpp
Normal file
113
interfaces/native/event/drag_and_drop_impl.cpp
Normal file
@ -0,0 +1,113 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "interfaces/native/drag_and_drop.h"
|
||||
#include "interfaces/native/node/event_converter.h"
|
||||
#include "interfaces/native/node/node_model.h"
|
||||
#include "native_node.h"
|
||||
#include "native_type.h"
|
||||
#include "ndk_data_conversion.h"
|
||||
#include "pixelmap_native_impl.h"
|
||||
#include "securec.h"
|
||||
|
||||
#include "base/error/error_code.h"
|
||||
#include "base/log/log_wrapper.h"
|
||||
#include "core/interfaces/arkoala/arkoala_api.h"
|
||||
#include "frameworks/bridge/common/utils/engine_helper.h"
|
||||
#include "frameworks/core/common/ace_engine.h"
|
||||
#include "frameworks/core/common/container.h"
|
||||
#include "frameworks/core/interfaces/native/node/node_api.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int32_t OH_ArkUI_DragEvent_GetModifierKeyStates(ArkUI_DragEvent* event, int64_t* keys)
|
||||
{
|
||||
if (event == NULL || keys == NULL) {
|
||||
return ARKUI_ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
auto dragEvent = reinterpret_cast<ArkUIDragEvent*>(event);
|
||||
*keys = dragEvent->modifierKeyState;
|
||||
return ARKUI_ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_DragEvent_SetData(ArkUI_DragEvent* event, OH_UdmfData* data)
|
||||
{
|
||||
auto dragEvent = reinterpret_cast<ArkUIDragEvent*>(event);
|
||||
|
||||
if (!event || !data || !dragEvent) {
|
||||
return ARKUI_ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
dragEvent->unifiedData = data;
|
||||
|
||||
return ARKUI_ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_DragEvent_GetUdmfData(ArkUI_DragEvent* event, OH_UdmfData* data)
|
||||
{
|
||||
auto dragEvent = reinterpret_cast<ArkUIDragEvent*>(event);
|
||||
|
||||
if (!event || !(dragEvent->unifiedData) || !data) {
|
||||
return ARKUI_ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
auto unifiedData =
|
||||
std::make_shared<OHOS::UDMF::UnifiedData>(*reinterpret_cast<OHOS::UDMF::UnifiedData*>(dragEvent->unifiedData));
|
||||
|
||||
auto status = OHOS::UDMF::NdkDataConversion::GetNdkUnifiedData(unifiedData, data);
|
||||
if (status) {
|
||||
return ARKUI_ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
return ARKUI_ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_DragEvent_GetDataTypeCount(ArkUI_DragEvent* event, int32_t* count)
|
||||
{
|
||||
auto dragEvent = reinterpret_cast<ArkUIDragEvent*>(event);
|
||||
|
||||
if (!event || !count || !dragEvent) {
|
||||
return ARKUI_ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
*count = dragEvent->dataTypesCount;
|
||||
return ARKUI_ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_DragEvent_GetDataTypes(
|
||||
ArkUI_DragEvent* event, char* eventTypeArray[], int32_t length, int32_t maxStrLen)
|
||||
{
|
||||
auto dragEvent = reinterpret_cast<ArkUIDragEvent*>(event);
|
||||
if (!event || !eventTypeArray || !dragEvent) {
|
||||
return ARKUI_ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
|
||||
if (length < dragEvent->dataTypesCount || maxStrLen < dragEvent->dataTypesMaxStrLength) {
|
||||
return ARKUI_ERROR_CODE_BUFFER_SIZE_ERROR;
|
||||
}
|
||||
for (int32_t i = 0; i < length; i++) {
|
||||
if (dragEvent->dataTypes[i]) {
|
||||
auto ret = strncpy_s(eventTypeArray[i], maxStrLen, dragEvent->dataTypes[i], maxStrLen);
|
||||
if (ret != 0) {
|
||||
return ARKUI_ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
eventTypeArray[i][maxStrLen] = '\0';
|
||||
} else {
|
||||
eventTypeArray[i][0] = '\0';
|
||||
}
|
||||
}
|
||||
return ARKUI_ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
@ -1762,5 +1762,213 @@
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_GetRouterPageId"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_NodeEvent_GetDragEvent"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_NodeEvent_GetPreviewDragStatus"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_DragEvent_DisableDefaultDropAnimation"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_DragEvent_SetSuggestedDropOperation"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_DragEvent_SetDragResult"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_DragEvent_SetData"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_DragEvent_GetUdmfData"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_DragEvent_GetDataTypeCount"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_DragEvent_GetDataTypes"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_DragEvent_GetDragResult"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_DragEvent_GetPreviewTouchPointX"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_DragEvent_GetPreviewTouchPointY"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_DragEvent_GetPreviewRectWidth"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_DragEvent_GetPreviewRectHeight"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_DragEvent_GetTouchPointXToWindow"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_DragEvent_GetTouchPointYToWindow"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_DragEvent_GetTouchPointXToDisplay"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_DragEvent_GetTouchPointYToDisplay"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_DragEvent_GetVelocityX"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_DragEvent_GetVelocityY"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_DragEvent_GetVelocity"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_DragEvent_GetModifierKeyStates"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_SetDragEventStrictReportWithNode"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_SetDragEventStrictReportWithContext"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_SetNodeAllowedDropDataTypes"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_DisallowNodeAnyDropDataTypes"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_AllowNodeAllDropDataTypes"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_SetNodeDraggable"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_SetNodeDragPreview"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_CreateDragPreviewOption"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_DragPreviewOption_Dispose"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_DragPreviewOption_SetScaleMode"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_DragPreviewOption_SetDefaultShadowEnabled"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_DragPreviewOption_SetDefaultRadiusEnabled"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_DragPreviewOption_SetNumberBadgeEnabled"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_DragPreviewOption_SetBadgeNumber"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_DragPreviewOption_SetDefaultAnimationBeforeLiftingEnabled"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_SetNodeDragPreviewOption"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_CreateDragActionWithNode"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_CreateDragActionWithContext"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_DragAction_Dispose"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_DragAction_SetPointerId"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_DragAction_SetPixelMaps"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_DragAction_SetTouchPointX"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_DragAction_SetTouchPointY"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_DragAction_SetData"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_DragAction_SetDragPreviewOption"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_DragAction_RegisterStatusListener"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_DragAction_UnregisterStatusListener"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_DragAndDropInfo_GetDragStatus"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_DragAndDropInfo_GetDragEvent"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_StartDrag"
|
||||
}
|
||||
]
|
||||
|
@ -5308,6 +5308,67 @@ typedef enum {
|
||||
*
|
||||
*/
|
||||
NODE_ON_ACCESSIBILITY_ACTIONS,
|
||||
|
||||
/**
|
||||
* @brief Notifies the listener of the interaction state prior to a drop and drop operation.
|
||||
*
|
||||
* This event is triggered when a drag operation is about to start on a draggable item. \n
|
||||
* When the event callback occurs, the union type in the {@link ArkUI_NodeEvent} object is
|
||||
* {@link ArkUI_NodeComponentEvent}. \n
|
||||
* {@link ArkUI_NodeComponentEvent} contains one parameter:\n
|
||||
* <b>ArkUI_NodeComponentEvent.data[0].i32</b>: corresponds to {@link ArkUI_PreViewDragStatus}. \n
|
||||
*/
|
||||
NODE_ON_PRE_DRAG = 14,
|
||||
/**
|
||||
* @brief Called when the user starts to drag an ite
|
||||
*
|
||||
* A drag operation is recognized only when the dragged item is moved far enough. \n
|
||||
* When the event callback occurs, the {@link ArkUI_DragEvent} object can be obtained from the
|
||||
* {@link ArkUI_NodeEvent} object. \n
|
||||
*/
|
||||
NODE_ON_DRAG_START = 15,
|
||||
/**
|
||||
* @brief Called when a dragged item enters the boundaries of the current component.
|
||||
*
|
||||
* The current component refers to the component that listens for this event. \n
|
||||
* When the event callback occurs, the {@link ArkUI_DragEvent} object can be obtained from the
|
||||
* {@link ArkUI_NodeEvent} object. \n
|
||||
*/
|
||||
NODE_ON_DRAG_ENTER = 16,
|
||||
/**
|
||||
* @brief Called when a dragged item moves in the current component.
|
||||
*
|
||||
* The current component refers to the component that listens for this event. \n
|
||||
* When the event callback occurs, the {@link ArkUI_DragEvent} object can be obtained from the
|
||||
* {@link ArkUI_NodeEvent} object. \n
|
||||
*/
|
||||
NODE_ON_DRAG_MOVE = 17,
|
||||
/**
|
||||
* @brief Called when a dragged item leaves the boundaries of the current component.
|
||||
*
|
||||
* The current component refers to the component that listens for this event. \n
|
||||
* When the event callback occurs, the {@link ArkUI_DragEvent} object can be obtained from the
|
||||
* {@link ArkUI_NodeEvent} object. \n
|
||||
*/
|
||||
NODE_ON_DRAG_LEAVE = 18,
|
||||
/**
|
||||
* @brief Called when a dragged item is dropped on the current component.
|
||||
* The component can obtain the drag data for processing through the callback.
|
||||
*
|
||||
* The current component refers to the component that listens for this event. \n
|
||||
* When the event callback occurs, the {@link ArkUI_DragEvent} object can be obtained from the
|
||||
* {@link ArkUI_NodeEvent} object. \n
|
||||
*/
|
||||
NODE_ON_DROP = 19,
|
||||
/**
|
||||
* @brief Called when a drag operation ends.
|
||||
* The drag source can obtain the drag result by registering this callback.
|
||||
*
|
||||
* A drag operation ends when the dragged item is released.
|
||||
* When the event callback occurs, the {@link ArkUI_DragEvent} object can be obtained from the
|
||||
* {@link ArkUI_NodeEvent} object. \n
|
||||
*/
|
||||
NODE_ON_DRAG_END = 20,
|
||||
/**
|
||||
* @brief 文本设置TextDataDetectorConfig且识别成功时,触发onDetectResultUpdate回调。
|
||||
*
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "base/error/error_code.h"
|
||||
#include "core/event/touch_event.h"
|
||||
#include "core/interfaces/arkoala/arkoala_api.h"
|
||||
#include "interfaces/native/drag_and_drop.h"
|
||||
|
||||
namespace OHOS::Ace::NodeModel {
|
||||
namespace {
|
||||
@ -203,6 +204,20 @@ ArkUI_Int32 ConvertOriginEventType(ArkUI_NodeEventType type, int32_t nodeType)
|
||||
return ON_TOUCH;
|
||||
case NODE_ON_CLICK:
|
||||
return ON_CLICK;
|
||||
case NODE_ON_DRAG_START:
|
||||
return ON_DRAG_START;
|
||||
case NODE_ON_DRAG_ENTER:
|
||||
return ON_DRAG_ENTER;
|
||||
case NODE_ON_DROP:
|
||||
return ON_DRAG_DROP;
|
||||
case NODE_ON_DRAG_MOVE:
|
||||
return ON_DRAG_MOVE;
|
||||
case NODE_ON_DRAG_LEAVE:
|
||||
return ON_DRAG_LEAVE;
|
||||
case NODE_ON_DRAG_END:
|
||||
return ON_DRAG_END;
|
||||
case NODE_ON_PRE_DRAG:
|
||||
return ON_PRE_DRAG;
|
||||
case NODE_CHECKBOX_EVENT_ON_CHANGE:
|
||||
return ON_CHECKBOX_CHANGE;
|
||||
case NODE_SLIDER_EVENT_ON_CHANGE:
|
||||
@ -381,6 +396,20 @@ ArkUI_Int32 ConvertToNodeEventType(ArkUIEventSubKind type)
|
||||
return NODE_TOUCH_EVENT;
|
||||
case ON_CLICK:
|
||||
return NODE_ON_CLICK;
|
||||
case ON_DRAG_START:
|
||||
return NODE_ON_DRAG_START;
|
||||
case ON_DRAG_ENTER:
|
||||
return NODE_ON_DRAG_ENTER;
|
||||
case ON_DRAG_DROP:
|
||||
return NODE_ON_DROP;
|
||||
case ON_DRAG_MOVE:
|
||||
return NODE_ON_DRAG_MOVE;
|
||||
case ON_DRAG_LEAVE:
|
||||
return NODE_ON_DRAG_LEAVE;
|
||||
case ON_DRAG_END:
|
||||
return NODE_ON_DRAG_END;
|
||||
case ON_PRE_DRAG:
|
||||
return NODE_ON_PRE_DRAG;
|
||||
case ON_CHECKBOX_CHANGE:
|
||||
return NODE_CHECKBOX_EVENT_ON_CHANGE;
|
||||
case ON_SLIDER_CHANGE:
|
||||
@ -571,6 +600,12 @@ bool ConvertEvent(ArkUINodeEvent* origin, ArkUI_NodeEvent* event)
|
||||
event->kind = ConvertToNodeEventType(subKind);
|
||||
return true;
|
||||
}
|
||||
case DRAG_EVENT: {
|
||||
event->category = static_cast<int32_t>(NODE_EVENT_CATEGORY_COMPONENT_EVENT);
|
||||
ArkUIEventSubKind subKind = static_cast<ArkUIEventSubKind>(origin->dragEvent.subKind);
|
||||
event->kind = ConvertToNodeEventType(subKind);
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "failed to convert origin event data");
|
||||
break;
|
||||
@ -855,6 +890,18 @@ int32_t OH_ArkUI_NodeEvent_SetReturnNumberValue(ArkUI_NodeEvent* event, ArkUI_Nu
|
||||
return OHOS::Ace::ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
ArkUI_DragEvent* OH_ArkUI_NodeEvent_GetDragEvent(ArkUI_NodeEvent* nodeEvent)
|
||||
{
|
||||
if (!nodeEvent || nodeEvent->category != static_cast<int32_t>(NODE_EVENT_CATEGORY_COMPONENT_EVENT)) {
|
||||
return nullptr;
|
||||
}
|
||||
const auto* originNodeEvent = reinterpret_cast<ArkUINodeEvent*>(nodeEvent->origin);
|
||||
if (!originNodeEvent) {
|
||||
return nullptr;
|
||||
}
|
||||
return const_cast<ArkUI_DragEvent*>(reinterpret_cast<const ArkUI_DragEvent*>(&(originNodeEvent->dragEvent)));
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
@ -509,6 +509,9 @@ int32_t GetNativeNodeEventType(ArkUINodeEvent* innerEvent)
|
||||
case MIXED_EVENT:
|
||||
subKind = static_cast<ArkUIEventSubKind>(innerEvent->mixedEvent.subKind);
|
||||
break;
|
||||
case DRAG_EVENT:
|
||||
subKind = static_cast<ArkUIEventSubKind>(innerEvent->dragEvent.subKind);
|
||||
break;
|
||||
default:
|
||||
break; /* Empty */
|
||||
}
|
||||
|
@ -178,6 +178,22 @@ enum {
|
||||
UI_MOUSE_EVENT_BUTTON_FORWARD = 5,
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Defines an enum for modifier keys.
|
||||
*
|
||||
* @since 12
|
||||
*/
|
||||
typedef enum {
|
||||
/** Ctrl. */
|
||||
ARKUI_MODIFIER_KEY_CTRL = 1 << 0,
|
||||
/** Shift. */
|
||||
ARKUI_MODIFIER_KEY_SHIFT = 1 << 1,
|
||||
/** Alt. */
|
||||
ARKUI_MODIFIER_KEY_ALT = 1 << 2,
|
||||
/** Fn. */
|
||||
ARKUI_MODIFIER_KEY_FN = 1 << 3,
|
||||
} ArkUI_ModifierKeyName;
|
||||
|
||||
/**
|
||||
* @brief Obtains the type of this UI input event.
|
||||
*
|
||||
|
@ -29,6 +29,8 @@ class MockUdmfClient : public UdmfClient {
|
||||
public:
|
||||
MOCK_METHOD(RefPtr<UnifiedData>, TransformUnifiedData, (napi_value napiValue), (override));
|
||||
MOCK_METHOD(napi_value, TransformUdmfUnifiedData, (RefPtr<UnifiedData>& UnifiedData), (override));
|
||||
MOCK_METHOD(RefPtr<UnifiedData>, TransformUnifiedDataForNative, (void* rawData), (override));
|
||||
MOCK_METHOD(void*, TransformUnifiedDataPtr, (RefPtr<UnifiedData>& UnifiedData), (override));
|
||||
MOCK_METHOD(napi_value, TransformSummary, ((std::map<std::string, int64_t>& summary)), (override));
|
||||
MOCK_METHOD(RefPtr<UnifiedData>, CreateUnifiedData, (), (override));
|
||||
MOCK_METHOD(int32_t, SetData, (const RefPtr<UnifiedData>& unifiedData, std::string& key), (override));
|
||||
|
Loading…
Reference in New Issue
Block a user