diff --git a/arkui/ace_engine/native/BUILD.gn b/arkui/ace_engine/native/BUILD.gn index 2539ea4d51003f98e318e430be91e4573844ed33..122bd36893b25e385ee26bca74ffccd8fd2cc98e 100644 --- a/arkui/ace_engine/native/BUILD.gn +++ b/arkui/ace_engine/native/BUILD.gn @@ -26,6 +26,7 @@ if (!is_arkui_x) { ohos_ndk_headers("arkui_header") { dest_dir = "$ndk_headers_out_dir/arkui/" sources = [ + "native_animate.h", "native_dialog.h", "native_event.h", "native_gesture.h", diff --git a/arkui/ace_engine/native/libace.ndk.json b/arkui/ace_engine/native/libace.ndk.json index 1a4c8d1b083e48d1db4b1dab4d1200dc217211ab..f6223576b7af045bbcf3b472cbb6291245d7d25f 100644 --- a/arkui/ace_engine/native/libace.ndk.json +++ b/arkui/ace_engine/native/libace.ndk.json @@ -606,5 +606,73 @@ { "first_introduced": "12", "name": "OH_ArkUI_WaterFlowSectionOption_GetMargin" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_AnimateOption_Create" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_AnimateOption_Dispose" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_AnimateOption_GetDuration" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_AnimateOption_GetTempo" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_AnimateOption_GetCurve" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_AnimateOption_GetDelay" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_AnimateOption_GetIterations" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_AnimateOption_GetPlayMode" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_AnimateOption_GetExpectedFrameRateRange" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_AnimateOption_SetDuration" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_AnimateOption_SetTempo" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_AnimateOption_SetCurve" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_AnimateOption_SetDelay" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_AnimateOption_SetIterations" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_AnimateOption_SetPlayMode" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_AnimateOption_SetExpectedFrameRateRange" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_GetContextFromNapiValue" } ] \ No newline at end of file diff --git a/arkui/ace_engine/native/native_animate.h b/arkui/ace_engine/native/native_animate.h new file mode 100644 index 0000000000000000000000000000000000000000..fbafc396fba73d771c4b67c49591091af895dfdd --- /dev/null +++ b/arkui/ace_engine/native/native_animate.h @@ -0,0 +1,230 @@ +/* + * 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 ARKUI_NATIVE_ANIMATE_H +#define ARKUI_NATIVE_ANIMATE_H + +#include + +#include "native_type.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** +* @brief Defines the expected frame rate range of the animation. +* +* @since 12 +*/ +typedef struct { + /** Expected minimum frame rate. */ + uint32_t min; + /** Expected maximum frame rate. */ + uint32_t max; + /** Expected optimal frame rate. */ + uint32_t expected; +} ArkUI_ExpectedFrameRateRange; + +/** +* @brief Defines the callback type for when the animation playback is complete. +* +* @since 12 +*/ +typedef struct { + /** Type of the onFinish callback. */ + ArkUI_FinishCallbackType type; + /** Callback invoked when the animation playback is complete. */ + void (*callback)(void* userData); + /** Custom type. */ + void* userData; +} ArkUI_AnimateCompleteCallback; + +/** +* @brief Defines the animation configuration. +* +* @since 12 +*/ +typedef struct ArkUI_AnimateOption ArkUI_AnimateOption; + +/** + * @brief Implements the native animation APIs provided by ArkUI. + * + * @version 1 + * @since 12 + */ +typedef struct { + /** + * @brief Defines an explicit animation. + * + * @note Make sure the component attributes to be set in the event closure have been set before. + * + * @param context UIContext。 + * @param option Indicates the pointer to an animation configuration. + * @param update Indicates the animation closure. The system automatically inserts a transition animation + * for the state change caused by the closure. + * @param complete Indicates the callback to be invoked when the animation playback is complete. + * @return Returns 0 if the operation is successful; returns 401 if a parameter error occurs. + */ + int32_t (*animateTo)(ArkUI_ContextHandle context, ArkUI_AnimateOption* option, ArkUI_ContextCallback* update, + ArkUI_AnimateCompleteCallback* complete); +} ArkUI_NativeAnimateAPI_1; + +/** +* @brief Creates an animation configuration. +* +* @return Returns the pointer to the created animation configuration. +* @since 12 +*/ +ArkUI_AnimateOption* OH_ArkUI_AnimateOption_Create(); + +/** +* @brief Destroys an animation configuration. +* +* @since 12 +*/ +void OH_ArkUI_AnimateOption_Dispose(ArkUI_AnimateOption* option); + +/** +* @brief Obtains the animation duration, in milliseconds. +* +* @param option Indicates the pointer to an animation configuration. +* @return Returns the duration. +* @since 12 +*/ +uint32_t OH_ArkUI_AnimateOption_GetDuration(ArkUI_AnimateOption* option); + +/** +* @brief Obtains the animation playback speed. +* +* @param option Indicates the pointer to an animation configuration. +* @return Returns the animation playback speed. +* @since 12 +*/ +float OH_ArkUI_AnimateOption_GetTempo(ArkUI_AnimateOption* option); + +/** +* @brief Obtains the animation curve. +* +* @param option Indicates the pointer to an animation configuration. +* @return Returns the animated curve. +* @since 12 +*/ +ArkUI_AnimationCurve OH_ArkUI_AnimateOption_GetCurve(ArkUI_AnimateOption* option); + +/** +* @brief Obtains the animation delay, in milliseconds. +* +* @param option Indicates the pointer to an animation configuration. +* @return Returns the animation delay. +* @since 12 +*/ +int32_t OH_ArkUI_AnimateOption_GetDelay(ArkUI_AnimateOption* option); + +/** +* @brief Obtains the number of times that an animation is played. +* +* @param option Indicates the pointer to an animation configuration. +* @return Returns the number of times that the animation is played. +* @since 12 +*/ +int32_t OH_ArkUI_AnimateOption_GetIterations(ArkUI_AnimateOption* option); + +/** +* @brief Obtains the animation playback mode. +* +* @param option Indicates the pointer to an animation configuration. +* @return Returns the animation playback mode. +* @since 12 +*/ +ArkUI_AnimationPlayMode OH_ArkUI_AnimateOption_GetPlayMode(ArkUI_AnimateOption* option); + +/** +* @brief Obtains the expected frame rate range of an animation. +* +* @param option Indicates the pointer to an animation configuration. +* @return Returns the expected frame rate range. +* @since 12 +*/ +ArkUI_ExpectedFrameRateRange* OH_ArkUI_AnimateOption_GetExpectedFrameRateRange(ArkUI_AnimateOption* option); + +/** +* @brief Sets the animation duration. +* +* @param option Indicates the pointer to an animation configuration. +* @param value Indicates the duration, in milliseconds. +* @since 12 +*/ +void OH_ArkUI_AnimateOption_SetDuration(ArkUI_AnimateOption* option, int32_t value); + +/** +* @brief Sets the animation playback speed. +* +* @param option Indicates the pointer to an animation configuration. +* @param value Indicates the animation playback speed. +* @since 12 +*/ +void OH_ArkUI_AnimateOption_SetTempo(ArkUI_AnimateOption* option, float value); + +/** +* @brief Sets the animation curve. +* +* @param option Indicates the pointer to an animation configuration. +* @param value Indicates the animated curve. +* @since 12 +*/ +void OH_ArkUI_AnimateOption_SetCurve(ArkUI_AnimateOption* option, ArkUI_AnimationCurve value); + +/** +* @brief Sets the animation delay. +* +* @param option Indicates the pointer to an animation configuration. +* @param value Indicates the animation delay. +* @since 12 +*/ +void OH_ArkUI_AnimateOption_SetDelay(ArkUI_AnimateOption* option, int32_t value); + +/** +* @brief Sets the number of times that an animation is played. +* +* @param option Indicates the pointer to an animation configuration. +* @param value Indicates the number of times that the animation is played. +* @since 12 +*/ +void OH_ArkUI_AnimateOption_SetIterations(ArkUI_AnimateOption* option, int32_t value); + +/** +* @brief Sets the animation playback mode. +* +* @param option Indicates the pointer to an animation configuration. +* @param value Indicates the animation playback mode. +* @since 12 +*/ +void OH_ArkUI_AnimateOption_SetPlayMode(ArkUI_AnimateOption* option, ArkUI_AnimationPlayMode value); + +/** +* @brief Sets the expected frame rate range of an animation. +* +* @param option Indicates the pointer to an animation configuration. +* @param value Indicates the expected frame rate range. +* @since 12 +*/ +void OH_ArkUI_AnimateOption_SetExpectedFrameRateRange(ArkUI_AnimateOption* option, ArkUI_ExpectedFrameRateRange* value); + +#ifdef __cplusplus +}; +#endif + +#endif // ARKUI_NATIVE_ANIMATE_H \ No newline at end of file diff --git a/arkui/ace_engine/native/native_interface.h b/arkui/ace_engine/native/native_interface.h index ba288efafb4dbbd19510d617d1858c34e13d1d9a..04b555af34978fb2fb7695860d647aab5b80c757 100644 --- a/arkui/ace_engine/native/native_interface.h +++ b/arkui/ace_engine/native/native_interface.h @@ -54,6 +54,8 @@ typedef enum { ARKUI_NATIVE_DIALOG, /** API related to gestures. For details, see the struct definition in . */ ARKUI_NATIVE_GESTURE, + /** API related to animations. For details, see the struct definition in .*/ + ARKUI_NATIVE_ANIMATE, } ArkUI_NativeAPIVariantKind; /** diff --git a/arkui/ace_engine/native/native_node_napi.h b/arkui/ace_engine/native/native_node_napi.h index cc219bd5a3406dd7122c2285bc088c6437f2ccc0..bba0121e8356c5bd8fd12876e07ea4a33f07d944 100644 --- a/arkui/ace_engine/native/native_node_napi.h +++ b/arkui/ace_engine/native/native_node_napi.h @@ -56,6 +56,19 @@ 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. + * + * @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); + #ifdef __cplusplus }; #endif diff --git a/arkui/ace_engine/native/native_type.h b/arkui/ace_engine/native/native_type.h index 4de1baab7bcfa94c88e7cab7c664941c6e42c136..b206f3c19ba13a2b520b65cdfcbdb7837a06d287 100644 --- a/arkui/ace_engine/native/native_type.h +++ b/arkui/ace_engine/native/native_type.h @@ -91,6 +91,31 @@ typedef struct ArkUI_NativeDialog* ArkUI_NativeDialogHandle; */ typedef struct ArkUI_WaterFlowSectionOption ArkUI_WaterFlowSectionOption; +/** + * @brief Defines the ArkUI native context object. + * + * @since 12 + */ +struct ArkUI_Context; + +/** + * @brief Defines the pointer to the context instance object pointer definition of ArkUI on the native side. + * + * @since 12 + */ +typedef struct ArkUI_Context* ArkUI_ContextHandle; + +/** + * @brief Defines the event callback type. + * + * @since 12 + */ +typedef struct { + /** Custom type. */ + void* userData; + /** Event callback. */ + void (*callback)(void* userData); +} ArkUI_ContextCallback; /** * @brief Provides the number types of ArkUI in the native code. * @@ -1369,6 +1394,19 @@ typedef struct { int32_t y; } ArkUI_IntOffset; +/** + * @brief Enumerates the animation onFinish callback types. + * + * @since 12 + */ +typedef enum { + /** The callback is invoked when the entire animation is removed once it has finished. */ + ARKUI_FINISH_CALLBACK_REMOVED = 0, + /** The callback is invoked when the animation logically enters the falling state, though it may still be in its + * long tail state. */ + ARKUI_FINISH_CALLBACK_LOGICALLY, +} ArkUI_FinishCallbackType; + /** * @brief Describes the margins of a component. *