diff --git a/arkui/ace_engine/native/drawable_descriptor.h b/arkui/ace_engine/native/drawable_descriptor.h new file mode 100644 index 0000000000000000000000000000000000000000..0842b7a7e2a5d63937b1ef018fec37c9108133b4 --- /dev/null +++ b/arkui/ace_engine/native/drawable_descriptor.h @@ -0,0 +1,163 @@ +/* + * 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 UI capabilities of ArkUI on the native side, such as UI component creation and destruction, + * tree node operations, attribute setting, and event listening. + * + * @since 12 + */ + +/** + * @file drawable_descriptor.h + * + * @brief Defines theNativeDrawableDescriptor for the native module. + * + * @library libace_ndk.z.so + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 12 + */ + +#ifndef ARKUI_NATIVE_DRAWABLE_DESCRIPTOR_H +#define ARKUI_NATIVE_DRAWABLE_DESCRIPTOR_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Defines the drawable descriptor. + * + * @since 12 + */ +typedef struct ArkUI_DrawableDescriptor ArkUI_DrawableDescriptor; + +/** + * @brief Introduces the native pixel map information defined by Image Kit. + * + * @since 12 + */ +struct OH_PixelmapNative; + +/** + * @brief Defines the pointer to OH_PixelmapNative. + * + * @since 12 + */ +typedef struct OH_PixelmapNative* OH_PixelmapNativeHandle; + +/** + * @brief Creates a DrawableDescriptor from a Pixelmap. + * + * @param pixelMap Indicates the pointer to a Pixelmap + * @return Returns the pointer to the drawableDescriptor. + * @since 12 +*/ +ArkUI_DrawableDescriptor* OH_ArkUI_DrawableDescriptor_CreateFromPixelMap(OH_PixelmapNativeHandle pixelMap); + +/** + * @brief Creates a DrawableDescriptor from a Pixelmap array. + * + * @param array Indicates the pointer to a Pixelmap array. + * @param size Indicates the size of the Pixelmap array. + * @return Returns the pointer to the drawableDescriptor. + * @since 12 +*/ +ArkUI_DrawableDescriptor* OH_ArkUI_DrawableDescriptor_CreateFromAnimatedPixelMap( + OH_PixelmapNativeHandle* array, int32_t size); + +/** + * @brief Destroys the pointer to the drawableDescriptor. + * + * @param drawableDescriptor Indicates the pointer to the drawableDescriptor. + * @since 12 +*/ +void OH_ArkUI_DrawableDescriptor_Dispose(ArkUI_DrawableDescriptor* drawableDescriptor); + +/** + * @brief Obtains the Pixelmap object. + * + * @param drawableDescriptor Indicates the pointer to the drawableDescriptor. + * @return Returns the pointer to the PixelMap. + * @since 12 +*/ +OH_PixelmapNativeHandle OH_ArkUI_DrawableDescriptor_GetStaticPixelMap(ArkUI_DrawableDescriptor* drawableDescriptor); + +/** + * @brief Obtains the Pixelmap array used to play the animation. + * + * @param drawableDescriptor Indicates the pointer to the drawableDescriptor. + * @return Returns the pointer to the PixelMap array. + * @since 12 +*/ +OH_PixelmapNativeHandle* OH_ArkUI_DrawableDescriptor_GetAnimatedPixelMapArray( + ArkUI_DrawableDescriptor* drawableDescriptor); + +/** + * @brief Obtains the size of the Pixelmap array used to play the animation. + * + * @param drawableDescriptor Indicates the pointer to the drawableDescriptor. + * @return Returns the size of the Pixelmap array. + * @since 12 +*/ +int32_t OH_ArkUI_DrawableDescriptor_GetAnimatedPixelMapArraySize(ArkUI_DrawableDescriptor* drawableDescriptor); + +/** + * @brief Sets the total playback duration. + * + * @param drawableDescriptor Indicates the pointer to the drawableDescriptor. + * @param duration Indicates the total playback duration. The unit is millisecond. + * @since 12 +*/ +void OH_ArkUI_DrawableDescriptor_SetAnimationDuration(ArkUI_DrawableDescriptor* drawableDescriptor, int32_t duration); + +/** + * @brief Obtains the total playback duration. + * + * @param drawableDescriptor Indicates the pointer to the drawableDescriptor. + * @return Return the total playback duration. The unit is millisecond. + * @since 12 +*/ +int32_t OH_ArkUI_DrawableDescriptor_GetAnimationDuration(ArkUI_DrawableDescriptor* drawableDescriptor); + +/** + * @brief Sets the number of playback times. + * + * @param drawableDescriptor Indicates the pointer to the drawableDescriptor. + * @param iterations Indicates the number of playback times. + * @since 12 +*/ +void OH_ArkUI_DrawableDescriptor_SetAnimationIteration( + ArkUI_DrawableDescriptor* drawableDescriptor, int32_t iteration); + +/** + * @brief Obtains the number of playback times. + * + * @param drawableDescriptor Indicates the pointer to the drawableDescriptor. + * @return Returns the number of playback times. + * @since 12 +*/ +int32_t OH_ArkUI_DrawableDescriptor_GetAnimationIteration(ArkUI_DrawableDescriptor* drawableDescriptor); +#ifdef __cplusplus +}; +#endif + +#endif // ARKUI_NATIVE_DRAWABLE_DESCRIPTOR_H +/** @} */ diff --git a/arkui/ace_engine/native/libace.ndk.json b/arkui/ace_engine/native/libace.ndk.json index 3a15977129a3b91afc05d88d57eb186682e24f92..e880238e0011ec4f2d59c2b1648313421234daab 100644 --- a/arkui/ace_engine/native/libace.ndk.json +++ b/arkui/ace_engine/native/libace.ndk.json @@ -1010,5 +1010,53 @@ { "first_introduced": "12", "name": "OH_ArkUI_SwiperIndicator_GetSelectedColor" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_DrawableDescriptor_CreateFromPixelMap" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_DrawableDescriptor_CreateFromAnimatedPixelMap" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_DrawableDescriptor_Dispose" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_DrawableDescriptor_GetStaticPixelMap" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_DrawableDescriptor_GetAnimatedPixelMapArray" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_DrawableDescriptor_GetAnimatedPixelMapArraySize" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_DrawableDescriptor_SetAnimationDuration" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_DrawableDescriptor_GetAnimationDuration" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_DrawableDescriptor_SetAnimationIteration" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_DrawableDescriptor_GetAnimationIteration" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_GetDrawableDescriptorFromNapiValue" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_GetDrawableDescriptorFromResourceNapiValue" } ] \ 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 964e6d1774e1a12f307d9ef5aed8de9a53399f8f..48425085ce586f7ffcccf16490a92d3c967c9508 100644 --- a/arkui/ace_engine/native/native_node.h +++ b/arkui/ace_engine/native/native_node.h @@ -182,13 +182,13 @@ typedef enum { * Format of the {@link ArkUI_AttributeItem} parameter for setting the attribute:\n * .string: image address;\n * .value[0]?.i32: whether to repeat the image. Optional. The parameter type is {@link ArkUI_ImageRepeat}. - * .objcet: The parameter type is {@link ArkUI_DrawableDescriptor}. Either .string or .object must be set.\n + * .object: The parameter type is {@link ArkUI_DrawableDescriptor}. Either .string or .object must be set.\n * The default value is ARKUI_IMAGE_REPEAT_NONE.\n * \n * Format of the return value {@link ArkUI_AttributeItem}:\n * .string: image address;\n * .value[0].i32: whether to repeat the image. The parameter type is {@link ArkUI_ImageRepeat}.\n - * .objcet: The parameter type is {@link ArkUI_DrawableDescriptor}.\n + * .object: The parameter type is {@link ArkUI_DrawableDescriptor}.\n * */ NODE_BACKGROUND_IMAGE, @@ -1960,11 +1960,11 @@ typedef enum { * * Format of the {@link ArkUI_AttributeItem} parameter for setting the attribute:\n * .string: image address of the image span.\n - * .objcet: The parameter type is {@link ArkUI_DrawableDescriptor}. Either .string or .object must be set.\n + * .object: The parameter type is {@link ArkUI_DrawableDescriptor}. Either .string or .object must be set.\n * \n * Format of the return value {@link ArkUI_AttributeItem}:\n * .string: image address of the image span.\n - * .objcet: The parameter type is {@link ArkUI_DrawableDescriptor}.\n + * .object: The parameter type is {@link ArkUI_DrawableDescriptor}.\n * */ NODE_IMAGE_SPAN_SRC = MAX_NODE_SCOPE_NUM * ARKUI_NODE_IMAGE_SPAN, @@ -1988,11 +1988,11 @@ typedef enum { * * Format of the {@link ArkUI_AttributeItem} parameter for setting the attribute:\n * .string: image source.\n - * .objcet: The parameter type is {@link ArkUI_DrawableDescriptor}. Either .string or .object must be set.\n + * .object: The parameter type is {@link ArkUI_DrawableDescriptor}. Either .string or .object must be set.\n * \n * Format of the return value {@link ArkUI_AttributeItem}:\n * .string: image source.\n - * .objcet: The parameter type is {@link ArkUI_DrawableDescriptor}.\n + * .object: The parameter type is {@link ArkUI_DrawableDescriptor}.\n * */ NODE_IMAGE_SRC = MAX_NODE_SCOPE_NUM * ARKUI_NODE_IMAGE, @@ -3952,6 +3952,7 @@ typedef enum { * The default value is ARKUI_CURVE_EASE. \n * .value[4]?.i32: whether to enable the default spring animation. Optional. The default value 0 means not * to enable the default spring animation. \n + * .value[5]?.i32: Optional value, sets whether scrolling can cross the boundary. \n * \n * Format of the return value {@link ArkUI_AttributeItem}:\n * .value[0].f32: horizontal scrolling offset, in vp. \n diff --git a/arkui/ace_engine/native/native_node_napi.h b/arkui/ace_engine/native/native_node_napi.h index 29e8d0dd31c57f380967259d2200dffbf837887f..a1bf77b9ebed0c28d55e586adf677b2ef0ea3ead 100644 --- a/arkui/ace_engine/native/native_node_napi.h +++ b/arkui/ace_engine/native/native_node_napi.h @@ -37,6 +37,7 @@ #ifndef ARKUI_NATIVE_NODE_NAPI_H #define ARKUI_NATIVE_NODE_NAPI_H +#include "drawable_descriptor.h" #include "napi/native_api.h" #include "native_type.h" @@ -83,7 +84,33 @@ int32_t OH_ArkUI_GetContextFromNapiValue(napi_env env, napi_value value, ArkUI_C */ int32_t OH_ArkUI_GetNodeContentFromNapiValue(napi_env env, napi_value value, ArkUI_NodeContentHandle* content); +/** + * @brief Obtains a DrawableDescriptor object on the ArkTS side and maps it to an + * ArkUI_DrawableDescriptro object on the native side. + * + * @param env Indicates the NAPI environment pointer. + * @param value Indicates the DrawableDescriptor object created on the ArkTS side. + * @param drawableDescriptor Indicates the pointer to the ArkUI_DrawableDescriptro object. + * @return Returns 0 if success. + * Returns 401 if a parameter exception occurs. + * @since 12 +*/ +int32_t OH_ArkUI_GetDrawableDescriptorFromNapiValue( + napi_env env, napi_value value, ArkUI_DrawableDescriptor** drawableDescriptor); +/** + * @brief Obtains a Resource object on the ArkTS side and maps it to an + * ArkUI_DrawableDescriptro object on the native side. + * + * @param env Indicates the NAPI environment pointer. + * @param value Indicates the Resource object created on the ArkTS side. + * @param drawableDescriptor Indicates the pointer to the ArkUI_DrawableDescriptro object. + * @return Returns 0 if success. + * Returns 401 if a parameter exception occurs. + * @since 12 +*/ +int32_t OH_ArkUI_GetDrawableDescriptorFromResourceNapiValue( + napi_env env, napi_value value, ArkUI_DrawableDescriptor** drawableDescriptor); #ifdef __cplusplus }; #endif