From 6946766301540c349c669fc07b0f9a094eb81d8e Mon Sep 17 00:00:00 2001 From: Zhiqiang Date: Sun, 21 Apr 2024 00:32:04 +0800 Subject: [PATCH] add json.fix the format issue. update the format. add napi method. add node content related structure/interface Signed-off-by: Zhiqiang --- arkui/ace_engine/native/libace.ndk.json | 24 +++++++ arkui/ace_engine/native/native_node.h | 78 ++++++++++++++++++++++ arkui/ace_engine/native/native_node_napi.h | 25 +++++-- arkui/ace_engine/native/native_type.h | 7 ++ 4 files changed, 129 insertions(+), 5 deletions(-) diff --git a/arkui/ace_engine/native/libace.ndk.json b/arkui/ace_engine/native/libace.ndk.json index 8576e71fb78..72bfa9a8190 100644 --- a/arkui/ace_engine/native/libace.ndk.json +++ b/arkui/ace_engine/native/libace.ndk.json @@ -678,5 +678,29 @@ { "first_introduced": "12", "name": "OH_ArkUI_PointerEvent_SetInterceptHitTestMode" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_NodeContent_AddNode" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_NodeContent_InsertNode" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_NodeContent_RemoveNode" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_NodeContent_RegisterCallback" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_NodeContentEvent_GetEventType" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_GetNodeContentFromNapiValue" } ] \ No newline at end of file diff --git a/arkui/ace_engine/native/native_node.h b/arkui/ace_engine/native/native_node.h index d856e862e37..040a618c9a7 100644 --- a/arkui/ace_engine/native/native_node.h +++ b/arkui/ace_engine/native/native_node.h @@ -5135,6 +5135,84 @@ ArkUI_NodeHandle OH_ArkUI_NodeCustomEvent_GetNodeHandle(ArkUI_NodeCustomEvent* e */ ArkUI_NodeCustomEventType OH_ArkUI_NodeCustomEvent_GetEventType(ArkUI_NodeCustomEvent* event); +/** + * @brief Defines the node content event type. + * + * @since 12 + */ +typedef enum { + /** Defines the attach event. */ + NOTE_CONTENT_EVENT_ON_ATTACH_TO_WINDOW = 0, + /** Defines the detach event. */ + NOTE_CONTENT_EVENT_ON_DETACH_FROM_WINDOW = 1, +} ArkUI_NodeContentEventType; + +/** + * @brief Defines the general structure of a node content event. + * @since 12 + */ +typedef struct ArkUI_NodeContentEvent ArkUI_NodeContentEvent; + +/** + * @brief Defines the callback function of a node content event. + * @since 12 + */ +typedef void(*ArkUI_NodeContentCallback)(ArkUI_NodeContentEvent* event); + +/** + * @brief register a callback functoin to a node content. + * + * @param content Indicates the pointer to the node content instance. + * @param callback Indicates the callback function. + * @return Returns 0 if success, + * Returns 401 if parameter exception occurs. + * @since 12 + */ +int32_t OH_ArkUI_NodeContent_RegisterCallback(ArkUI_NodeContentHandle content, ArkUI_NodeContentCallback callback); + +/** + * @brief Obtains the type of a node content event. + * + * @param event Indicates the pointer to the node content event. + * @return Returns the type of the node content event. + * @since 12 + */ +ArkUI_NodeContentEventType OH_ArkUI_NodeContentEvent_GetEventType(ArkUI_NodeContentEvent* event); + +/** + * @brief Add a node to a node content. + * + * @param content Indicates the pointer to the node content instance. + * @param node Indicates the pointer to the node + * @return Returns 0 if success, + * Returns 401 if parameter exception occurs. + * @since 12 + */ +int32_t OH_ArkUI_NodeContent_AddNode(ArkUI_NodeContentHandle content, ArkUI_NodeHandle node); + +/** + * @brief remove a node from a node content. + * + * @param content Indicates the pointer to the node content instance. + * @param node Indicates the pointer to the node + * @return Returns 0 if success, + * Returns 401 if parameter exception occurs. + * @since 12 + */ +int32_t OH_ArkUI_NodeContent_RemoveNode(ArkUI_NodeContentHandle content, ArkUI_NodeHandle node); + +/** + * @brief insert a node into a node content at a given position. + * + * @param content Indicates the pointer to the node content instance. + * @param node Indicates the pointer to the node + * @param position Indicates the position for inserting the node + * @return Returns 0 if success, + * Returns 401 if parameter exception occurs. + * @since 12 + */ +int32_t OH_ArkUI_NodeContent_InsertNode(ArkUI_NodeContentHandle content, ArkUI_NodeHandle node, int32_t position); + #ifdef __cplusplus }; #endif diff --git a/arkui/ace_engine/native/native_node_napi.h b/arkui/ace_engine/native/native_node_napi.h index bba0121e835..29e8d0dd31c 100644 --- a/arkui/ace_engine/native/native_node_napi.h +++ b/arkui/ace_engine/native/native_node_napi.h @@ -57,17 +57,32 @@ extern "C" { int32_t OH_ArkUI_GetNodeHandleFromNapiValue(napi_env env, napi_value frameNode, ArkUI_NodeHandle* handle); /** - * @brief Obtains a UIContext object on the ArkTS side and maps it to an ArkUI_ContextHandle object on the - * native side. + * @brief Obtains a UIContext object on the ArkTS side and maps it to an ArkUI_ContextHandle object on the + * native side. + * + * @param env ndicates the NAPI environment pointer. + * @param value Indicates the UIContext object created on the ArkTS side. + * @param context Indicates the pointer to the ArkUI_ContextHandle object. + * @return Returns 0 if success. + * Returns 401 if a parameter exception occurs. + * @since 12 + */ +int32_t OH_ArkUI_GetContextFromNapiValue(napi_env env, napi_value value, ArkUI_ContextHandle* context); + + +/** + * @brief Obtains a NodeContent object on the ArkTS side and maps it to an ArkUI_NodeContentHandle + * object on the native side. * * @param env ndicates the NAPI environment pointer. - * @param value Indicates the UIContext object created on the ArkTS side. - * @param context Indicates the pointer to the ArkUI_ContextHandle object. + * @param value Indicates the NodeContent object created on the ArkTS side. + * @param content Indicates the pointer to the ArkUI_NodeContentHandle object. * @return Returns 0 if success. * Returns 401 if a parameter exception occurs. * @since 12 */ -int32_t OH_ArkUI_GetContextFromNapiValue(napi_env env, napi_value value, ArkUI_ContextHandle* context); +int32_t OH_ArkUI_GetNodeContentFromNapiValue(napi_env env, napi_value value, ArkUI_NodeContentHandle* content); + #ifdef __cplusplus }; diff --git a/arkui/ace_engine/native/native_type.h b/arkui/ace_engine/native/native_type.h index b206f3c19ba..c44cfcf1be7 100644 --- a/arkui/ace_engine/native/native_type.h +++ b/arkui/ace_engine/native/native_type.h @@ -49,6 +49,13 @@ extern "C" { */ struct ArkUI_Node; +/** + * @brief Defines the pointer type of the ArkUI node content + * + * @since 12 + */ +typedef struct ArkUI_NodeContent* ArkUI_NodeContentHandle; + /** * @brief Defines the custom dialog box controller of ArkUI on the native side. * -- Gitee