diff --git a/arkui/ace_engine/native/native_node.h b/arkui/ace_engine/native/native_node.h index 09ddb997cc90562322f436dd277a743b602a1d6a..f9a1f762a5a25a9e6b09d8839033fe7d538ca118 100644 --- a/arkui/ace_engine/native/native_node.h +++ b/arkui/ace_engine/native/native_node.h @@ -4408,6 +4408,25 @@ typedef enum { */ typedef struct ArkUI_NodeCustomEvent ArkUI_NodeCustomEvent; +/** + * @brief Defines the node content event type. + * + * @since 12 + */ +typedef enum { + /** Defines the mount event. */ + NODE_CONTENT_EVENT_ON_ATTACH_TO_WINDOW = 0, + /** Defines the unmount event. */ + NODE_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 component adapter, which is used for lazy loading of elements of scrollable components. * @@ -5135,6 +5154,67 @@ ArkUI_NodeHandle OH_ArkUI_NodeCustomEvent_GetNodeHandle(ArkUI_NodeCustomEvent* e */ ArkUI_NodeCustomEventType OH_ArkUI_NodeCustomEvent_GetEventType(ArkUI_NodeCustomEvent* event); +/** + * @brief Obtains the type through a node content event. + * + * @param event Indicates the pointer to the node content. + * @return Returns the type of the node content event. + * @since 12 + */ +ArkUI_NodeContentEventType OH_ArkUI_NodeContentEvent_GetEventType(ArkUI_NodeContentEvent* event); + +/** + * @brief Adds a component to a node content. + * + * @param handle Indicates the pointer to the node content instance. + * @param node Indicates the pointer to the node. + * @return Returns 0 if success. + * Returns 401 if a parameter exception occurs. + * @since 12 + */ +int32_t OH_ArkUI_NodeContent_AddNode(ArkUI_NodeContentHandle handle, ArkUI_NodeHandle node); + +/** + * @brief Removes a component from a node content. + * + * @param handle Indicates the pointer to the node content. + * @param node Indicates the pointer to the node. + * @return Returns 0 if success. + * Returns 401 if a parameter exception occurs. + * @since 12 + */ +int32_t OH_ArkUI_NodeContent_RemoveNode(ArkUI_NodeContentHandle handle, ArkUI_NodeHandle node); + +/** + * @brief Inserts a component to a node content based on position. + * + * @param handle Indicates the pointer to the node content. + * @param node Indicates the pointer to the node. + * @param position Indicates the position to the node. + * @return Returns 0 if success. + * Returns 401 if a parameter exception occurs. + * @since 12 + */ +int32_t OH_ArkUI_NodeContent_InsertNode(ArkUI_NodeContentHandle handle, ArkUI_NodeHandle node, int32_t position); + +/** + * @brief Defines the node content event callback function. + * + * @since 12 + */ +typedef void (*ArkUI_NodeContentCallback)(ArkUI_NodeContentEvent* event); + +/** + * @brief Registers a callback function to a node content. + * + * @param handle Indicates the pointer to the node content. + * @param callback Indicates the callback function. + * @return Returns 0 if success. + * Returns 401 if a parameter exception occurs. + * @since 12 + */ +int32_t OH_ArkUI_NodeContent_RegisterCallback(ArkUI_NodeContentHandle handle, ArkUI_NodeContentCallback callback); + #ifdef __cplusplus }; #endif diff --git a/arkui/ace_engine/native/native_node_napi.h b/arkui/ace_engine/native/native_node_napi.h index bba0121e8356c5bd8fd12876e07ea4a33f07d944..505d14c36e5e77364be1d4ca5f4baef343d649fe 100644 --- a/arkui/ace_engine/native/native_node_napi.h +++ b/arkui/ace_engine/native/native_node_napi.h @@ -69,6 +69,19 @@ int32_t OH_ArkUI_GetNodeHandleFromNapiValue(napi_env env, napi_value frameNode, */ 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 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_GetNodeContentFromNapiValue(napi_env env, napi_value value, ArkUI_NodeContentHandle* content); + #ifdef __cplusplus }; #endif diff --git a/arkui/ace_engine/native/native_type.h b/arkui/ace_engine/native/native_type.h index 8e290d69f09819eec6c372f1281bc31eda460161..98a70fc5c0616b32ca2900d06f1f75fbac590b25 100644 --- a/arkui/ace_engine/native/native_type.h +++ b/arkui/ace_engine/native/native_type.h @@ -105,6 +105,13 @@ struct ArkUI_Context; */ typedef struct ArkUI_Context* ArkUI_ContextHandle; +/** + * @brief Defines the pointer type of the ArkUI native node content object. + * + * @since 12 + */ +typedef struct ArkUI_NodeContent* ArkUI_NodeContentHandle; + /** * @brief Defines the event callback type. *