From 95835c5220f689034b44fa40db970bd18b8807a3 Mon Sep 17 00:00:00 2001 From: lanshouren Date: Sat, 20 Apr 2024 15:28:35 +0800 Subject: [PATCH] ContentSlot - Provides placeholder component Signed-off-by: lanshouren Change-Id: I1a734a79fec3b730aa8e94fdf512406a8ec24ace --- arkui/ace_engine/native/native_node.h | 80 ++++++++++++++++++++++ arkui/ace_engine/native/native_node_napi.h | 13 ++++ arkui/ace_engine/native/native_type.h | 7 ++ 3 files changed, 100 insertions(+) diff --git a/arkui/ace_engine/native/native_node.h b/arkui/ace_engine/native/native_node.h index 09ddb997c..f9a1f762a 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 bba0121e8..505d14c36 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 8e290d69f..98a70fc5c 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. * -- Gitee