From 57b538def80c722ef37fd667d18ef83ee38283e9 Mon Sep 17 00:00:00 2001 From: "DESKTOP-H8KLN8I\\lisitao" Date: Fri, 7 Jun 2024 11:19:33 +0800 Subject: [PATCH] [NDK] add keyframe, animator, removeAllchild, api Signed-off-by:lisitaolisitao3@huawei.com Signed-off-by: DESKTOP-H8KLN8I\lisitao --- arkui/ace_engine/native/libace.ndk.json | 248 +++++++ arkui/ace_engine/native/native_animate.h | 798 ++++++++++++++++++++++- arkui/ace_engine/native/native_gesture.h | 8 + arkui/ace_engine/native/native_node.h | 11 + arkui/ace_engine/native/native_type.h | 20 + 5 files changed, 1080 insertions(+), 5 deletions(-) diff --git a/arkui/ace_engine/native/libace.ndk.json b/arkui/ace_engine/native/libace.ndk.json index 093ffa7c5..dd4a8d4f3 100644 --- a/arkui/ace_engine/native/libace.ndk.json +++ b/arkui/ace_engine/native/libace.ndk.json @@ -211,6 +211,10 @@ "first_introduced": "12", "name": "OH_ArkUI_PinchGesture_GetCenterY" }, + { + "first_introduced": "12", + "name": "OH_ArkUI_GestureEvent_GetNode" + }, { "first_introduced": "12", "name": "OH_ArkUI_GestureInterruptInfo_GetSystemFlag" @@ -1370,5 +1374,249 @@ { "first_introduced": "12", "name": "OH_ArkUI_AccessibilityValue_GetText" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_AnimateOption_SetICurve" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_AnimateOption_GetICurve" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_KeyframeAnimateOption_Create" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_KeyframeAnimateOption_Dispose" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_KeyframeAnimateOption_SetDelay" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_KeyframeAnimateOption_SetIterations" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_KeyframeAnimateOption_RegisterOnFinishCallback" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_KeyframeAnimateOption_SetDuration" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_KeyframeAnimateOption_SetCurve" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_KeyframeAnimateOption_RegisterOnEventCallback" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_KeyframeAnimateOption_GetDelay" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_KeyframeAnimateOption_GetIterations" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_KeyframeAnimateOption_GetDuration" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_KeyframeAnimateOption_GetCurve" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_AnimatorOption_Create" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_AnimatorOption_Dispose" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_AnimatorOption_SetDuration" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_AnimatorOption_SetDelay" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_AnimatorOption_SetIterations" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_AnimatorOption_SetFill" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_AnimatorOption_SetDirection" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_AnimatorOption_SetCurve" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_AnimatorOption_SetBegin" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_AnimatorOption_SetEnd" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_AnimatorOption_SetExpectedFrameRateRange" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_AnimatorOption_SetKeyframe" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_AnimatorOption_SetKeyframeCurve" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_AnimatorOption_GetDuration" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_AnimatorOption_GetDelay" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_AnimatorOption_GetIterations" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_AnimatorOption_GetFill" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_AnimatorOption_GetDirection" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_AnimatorOption_GetCurve" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_AnimatorOption_GetBegin" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_AnimatorOption_GetEnd" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_AnimatorOption_GetExpectedFrameRateRange" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_AnimatorOption_GetKeyframeTime" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_AnimatorOption_GetKeyframeValue" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_AnimatorOption_GetKeyframeCurve" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_AnimatorEvent_GetUserData" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_AnimatorOnFrameEvent_GetUserData" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_AnimatorOnFrameEvent_GetValue" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_AnimatorOption_RegisterOnFrameCallback" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_AnimatorOption_RegisterOnFinishCallback" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_AnimatorOption_RegisterOnCancelCallback" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_AnimatorOption_RegisterOnRepeatCallback" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_Animator_ResetAnimatorOption" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_Animator_Play" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_Animator_Finish" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_Animator_Pause" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_Animator_Cancel" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_Animator_Reverse" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_Curve_InitCurve" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_Curve_StepsCurve" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_Curve_CubicBezierCurve" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_Curve_SpringCurve" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_Curve_SpringMotion" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_Curve_ResponsiveSpringMotion" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_Curve_InterpolatingSpring" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_Curve_CustomCurve" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_Curve_disposeCurve" } ] \ No newline at end of file diff --git a/arkui/ace_engine/native/native_animate.h b/arkui/ace_engine/native/native_animate.h index dfef24f5e..c2f5c65a4 100644 --- a/arkui/ace_engine/native/native_animate.h +++ b/arkui/ace_engine/native/native_animate.h @@ -59,6 +59,55 @@ typedef struct { */ typedef struct ArkUI_AnimateOption ArkUI_AnimateOption; +/** +* @brief Defines an interpolation curve. +* +* @since 12 +*/ +typedef struct ArkUI_Curve ArkUI_Curve; + +/** + * @brief Defines the pointer to an interpolation curve. + * + * @since 12 + */ +typedef struct ArkUI_Curve* ArkUI_CurveHandle; + +/** + * @brief Defines the keyframe animation parameter object. + * + * @since 12 + */ +typedef struct ArkUI_KeyframeAnimateOption ArkUI_KeyframeAnimateOption; + +/** + * @brief Defines the animator parameter object. + * + * @since 12 + */ +typedef struct ArkUI_AnimatorOption ArkUI_AnimatorOption; + +/** + * @brief Defines the pointer to an animator object. + * + * @since 12 + */ +typedef struct ArkUI_Animator* ArkUI_AnimatorHandle; + +/** +* @brief Defines the animator callback event object. +* +* @since 12 +*/ +typedef struct ArkUI_AnimatorEvent ArkUI_AnimatorEvent; + +/** +* @brief Defines the callback object when the animator receives a frame. +* +* @since 12 +*/ +typedef struct ArkUI_AnimatorOnFrameEvent ArkUI_AnimatorOnFrameEvent; + /** * @brief Implements the native animation APIs provided by ArkUI. * @@ -71,10 +120,10 @@ typedef struct { * * @note Make sure the component attributes to be set in the event closure have been set before. * - * @param context UIContext。 + * @param context Indicates a UIContext instance. * @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 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 the error code. * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. @@ -82,6 +131,34 @@ typedef struct { */ int32_t (*animateTo)(ArkUI_ContextHandle context, ArkUI_AnimateOption* option, ArkUI_ContextCallback* update, ArkUI_AnimateCompleteCallback* complete); + + /** + * @brief Sets the keyframe animation. + * + * + * @param context Indicates a UIContext instance. + * @param option Indicates the keyframe animation parameters. + * @return Returns the error code. + * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. + * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. + */ + int32_t (*keyframeAnimateTo)(ArkUI_ContextHandle context, ArkUI_KeyframeAnimateOption* option); + + /** + * @brief Creates an animator object. + * + * @param context Indicates a UIContext instance. + * @param option Indicates the animator parameters. + * @return Returns the pointer to the animator object; returns NULL if a function parameter error occurs. + */ + ArkUI_AnimatorHandle (*createAnimator)(ArkUI_ContextHandle context, ArkUI_AnimatorOption* option); + + /** + * @brief Disposes of an animator object. + * + * @param animator Indicates the target animator object. + */ + void (*disposeAnimator)(ArkUI_AnimatorHandle animatorHandle); } ArkUI_NativeAnimateAPI_1; /** @@ -93,7 +170,7 @@ typedef struct { ArkUI_AnimateOption* OH_ArkUI_AnimateOption_Create(); /** -* @brief Destroys an animation configuration. +* @brief Disposes of an animation configuration. * * @since 12 */ @@ -121,7 +198,7 @@ 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. +* @return Returns the animated curve.If Null is returned, it means option is an invalid value. * @since 12 */ ArkUI_AnimationCurve OH_ArkUI_AnimateOption_GetCurve(ArkUI_AnimateOption* option); @@ -225,6 +302,717 @@ void OH_ArkUI_AnimateOption_SetPlayMode(ArkUI_AnimateOption* option, ArkUI_Anima */ void OH_ArkUI_AnimateOption_SetExpectedFrameRateRange(ArkUI_AnimateOption* option, ArkUI_ExpectedFrameRateRange* value); +/** +* @brief Sets the animation curve for the animation of an animator. +* +* @param option Indicates the animator parameters. +* @param value Indicates the animation curve settings. +* @since 12 +*/ +void OH_ArkUI_AnimateOption_SetICurve(ArkUI_AnimateOption* option, ArkUI_CurveHandle value); + +/** +* @brief Obtains the animation curve of the animation of an animator. +* +* @param option Indicates the animator parameters. +* @return Returns the animation curve of the specified animation. +* If Null is returned, it means option is an invalid value. +* @since 12 +*/ +ArkUI_CurveHandle OH_ArkUI_AnimateOption_GetICurve(ArkUI_AnimateOption* option); + +/** + * @brief Obtains the keyframe animation parameters. + * + * @param size Indicates the number of keyframe animation states. + * @return Returns the keyframe animation parameter object; returns NULL if the value of size is less than + * 0. + * @since 12 + */ +ArkUI_KeyframeAnimateOption* OH_ArkUI_KeyframeAnimateOption_Create(int32_t size); + +/** + * @brief Disposes of the keyframe animation parameter object. + * + * @param option Indicates the keyframe animation parameter object. + * @since 12 + */ +void OH_ArkUI_KeyframeAnimateOption_Dispose(ArkUI_KeyframeAnimateOption* option); + +/** + * @brief Sets the overall delay of a keyframe animation, in milliseconds. By default, the keyframe animation is played + * without delay. + * + * @param option Indicates the keyframe animation parameters. + * @param value Indicates the delay, in milliseconds. + * @return Returns the error code. + * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. + * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. + */ +int32_t OH_ArkUI_KeyframeAnimateOption_SetDelay(ArkUI_KeyframeAnimateOption* option, int32_t value); + +/** + * @brief Sets the number of times that the keyframe animation is played. By default, the animation is played once. + * The value -1 indicates that the animation is played for an unlimited number of times. The value 0 + * indicates that there is no animation. + * + * @param option Indicates the keyframe animation parameters. + * @param value Indicates the number of times that the animation is played. + * @return Returns the error code. + * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. + * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. + */ +int32_t OH_ArkUI_KeyframeAnimateOption_SetIterations(ArkUI_KeyframeAnimateOption* option, int32_t value); + +/** + * @brief Sets the callback invoked when the keyframe animation playback is complete. This API is called after the + * keyframe animation has played for the specified number of times. + * + * @param option Indicates the keyframe animation parameters. + * @param userData Indicates the pointer to a custom object. + * @param onFinish Indicates the callback. + * @return Returns the error code. + * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. + * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. + */ +int32_t OH_ArkUI_KeyframeAnimateOption_RegisterOnFinishCallback( + ArkUI_KeyframeAnimateOption* option, void* userData, void (*onFinish)(void* userData)); + +/** + * @brief Sets the duration of a keyframe animation, in milliseconds. + * + * @param option Indicates the keyframe animation parameters. + * @param value Indicates the duration to set, in milliseconds. + * @param index Indicates a state index. + * @return Returns the error code. + * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. + * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. + */ +int32_t OH_ArkUI_KeyframeAnimateOption_SetDuration(ArkUI_KeyframeAnimateOption* option, int32_t value, int32_t index); + +/** + * @brief Sets the animation curve for a specific keyframe in a keyframe animation. + * + * @note Because the springMotion, responsiveSpringMotion, and interpolatingSpring curves do not + * have effective duration settings, they are not supported. + * @param option Indicates the keyframe animation parameters. + * @param value Indicates the animation curve to set. + * @param index Indicates a state index. + * @return Returns the error code. + * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. + * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. + */ +int32_t OH_ArkUI_KeyframeAnimateOption_SetCurve( + ArkUI_KeyframeAnimateOption* option, ArkUI_CurveHandle value, int32_t index); + +/** + * @brief Sets the closure function of the state at the time of the keyframe, that is, the state to be reached at the + * time of the keyframe. + * + * @param option Indicates the keyframe animation parameters. + * @param event Indicates a closure function. + * @param userData Indicates the pointer to a custom object. + * @param index Indicates a state index. + * @return Returns the error code. + * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. + * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. + */ +int32_t OH_ArkUI_KeyframeAnimateOption_RegisterOnEventCallback( + ArkUI_KeyframeAnimateOption* option, void* userData, void (*event)(void* userData), int32_t index); + +/** + * @brief Obtains the overall delay of a keyframe animation + * + * @param option Indicates the keyframe animation parameters. + * @return Returns the overall delay. + * @since 12 + */ +int32_t OH_ArkUI_KeyframeAnimateOption_GetDelay(ArkUI_KeyframeAnimateOption* option); + +/** + * @brief Obtains the number of times that a keyframe animation is played. + * + * @param option Indicates the keyframe animation parameters. + * @return Returns the number of times that the animation is played. + * @since 12 + */ +int32_t OH_ArkUI_KeyframeAnimateOption_GetIterations(ArkUI_KeyframeAnimateOption* option); + +/** + * @brief Obtains the duration of a specific state in a keyframe animation. + * + * @param option Indicates the keyframe animation parameters. + * @param index Indicates a state index. + * @return Returns the duration. The unit is millisecond. + * @since 12 + */ +int32_t OH_ArkUI_KeyframeAnimateOption_GetDuration(ArkUI_KeyframeAnimateOption* option, int32_t index); + +/** + * @brief Obtains the animation curve of a specific state in a keyframe animation. + * + * @param option Indicates the keyframe animation parameters. + * @param index Indicates a state index. + * @return Returns the animated curve. + * Returns NULL if a parameter error occurs. + * @since 12 + */ +ArkUI_CurveHandle OH_ArkUI_KeyframeAnimateOption_GetCurve(ArkUI_KeyframeAnimateOption* option, int32_t index); + +/** + * @brief Creates an animator parameter object. + * + * @note When keyframeSize is greater than 0, the animation interpolation start point is 0, and the animation + * interpolation end point is 1; no setting is allowed. + * @param keyframeSize Indicates the number of keyframes. + * @return Returns the pointer to the animator parameter object. + * returns NULL if the value of size is less than 0. + * @since 12 + */ +ArkUI_AnimatorOption* OH_ArkUI_AnimatorOption_Create(int32_t keyframeSize); + +/** + * @brief Disposes of an animator parameter object. + * + * @since 12 + */ +void OH_ArkUI_AnimatorOption_Dispose(ArkUI_AnimatorOption* option); + +/** + * @brief Sets the duration for thea nimation of an animator, in milliseconds. + * + * @param option Indicates the target animator parameter object. + * @param value Indicates the playback duration, in milliseconds. + * @return Returns the error code. + * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. + * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. + */ +int32_t OH_ArkUI_AnimatorOption_SetDuration(ArkUI_AnimatorOption* option, int32_t value); + +/** + * @brief Sets the delay for playing the animation of an animator, in milliseconds. + * + * @param option Indicates an animator parameter object. + * @param value Indicates the delay to set, in milliseconds. + * @return Returns the error code. + * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. + * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. + */ +int32_t OH_ArkUI_AnimatorOption_SetDelay(ArkUI_AnimatorOption* option, int32_t value); + +/** + * @brief Sets the number of times that the animation of an animator is played. The value 0 means not to play the + * animation, and -1 means to play the animation for an unlimited number of times. + * + * @note If this parameter is set to a negative value other than -1, the value is invalid. In this case, the + * animation is played once. + * @param option Indicates an animator parameter object. + * @param value Indicates the number of times that the animation is played. + * @return Returns the error code. + * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. + * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. + */ +int32_t OH_ArkUI_AnimatorOption_SetIterations(ArkUI_AnimatorOption* option, int32_t value); + +/** + * @brief Sets whether the animation of an animator is restored to the initial state after being executed. + * + * @param option Indicates an animator parameter object. + * @param value Indicates whether to restore the animation to the initial state after the animation is executed. + * @return Returns the error code. + * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. + * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. + */ +int32_t OH_ArkUI_AnimatorOption_SetFill(ArkUI_AnimatorOption* option, ArkUI_AnimationFillMode value); + +/** + * @brief Sets the playback direction for the animation of an animator. + * + * @param option Indicates an animator parameter object. + * @param value Indicates the animation playback direction. + * @return Returns the error code. + * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. + * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. + */ +int32_t OH_ArkUI_AnimatorOption_SetDirection(ArkUI_AnimatorOption* option, ArkUI_AnimationDirection value); + +/** + * @brief Sets the interpolation curve for the animation of an animator. + * + * @note springCurve, springMotion, responsiveSpringMotion, interpolatingSpring, + * and customCurve curves are not supported. + * + * @param option Indicates an animator parameter object. + * @param value Indicates the target interpolation curve. + * @return Returns the error code. + * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. + * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. + */ +int32_t OH_ArkUI_AnimatorOption_SetCurve(ArkUI_AnimatorOption* option, ArkUI_CurveHandle value); + +/** + * @brief Sets the interpolation start point for the animation of an animator. + * @note This API does not take effect when the animation is a keyframe animation. + * + * @param option Indicates an animator parameter object. + * @param value Indicates the interpolation start point to set. + * @return Returns the error code. + * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. + * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. + */ +int32_t OH_ArkUI_AnimatorOption_SetBegin(ArkUI_AnimatorOption* option, float value); + +/** + * @brief Sets the interpolation end point for the animation of an animator. + * @note This API does not take effect when the animation is a keyframe animation. + * + * @param option Indicates an animator parameter object. + * @param value Indicates the interpolation end point to set. + * @return Returns the error code. + * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. + * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. + */ +int32_t OH_ArkUI_AnimatorOption_SetEnd(ArkUI_AnimatorOption* option, float value); + +/** + * @brief Sets the expected frame rate range for the animation of an animator. + * + * @param option Indicates an animator parameter object. + * @param value Indicates the expected frame rate range to set. + * @return Returns the error code. + * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. + * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. + */ +int32_t OH_ArkUI_AnimatorOption_SetExpectedFrameRateRange( + ArkUI_AnimatorOption* option, ArkUI_ExpectedFrameRateRange* value); + +/** + * @brief Sets the keyframe parameters for the animation of an animator. + * + * @param option Indicates an animator parameter object. + * @param time Indicates the keyframe time. Value range: [0,1]. + * @param value Indicates the keyframe value. + * @param index Indicates the keyframe index. + * @return Returns the error code. + * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. + * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. + */ +int32_t OH_ArkUI_AnimatorOption_SetKeyframe( + ArkUI_AnimatorOption* option, float time, float value, int32_t index); + +/** + * @brief Sets the keyframe curve type for the animation of an animator. + * + * @note springCurve, springMotion, responsiveSpringMotion, interpolatingSpring, + * and customCurve curves are not supported. + * + * @param option Indicates an animator parameter object. + * @param value Indicates the target interpolation curve. + * @param index Indicates the keyframe index. + * @return Returns the error code. + * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. + * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. + */ +int32_t OH_ArkUI_AnimatorOption_SetKeyframeCurve(ArkUI_AnimatorOption* option, ArkUI_CurveHandle value, int32_t index); +/** + * @brief Obtains the duration for playing an animation. + * + * @param option Indicates the animator parameters. + * @return Returns the duration for playing the animation, in milliseconds. + * @since 12 + */ +int32_t OH_ArkUI_AnimatorOption_GetDuration(ArkUI_AnimatorOption* option); + +/** + * @brief Obtains the delay for playing the animation of an animator. + * + * @param option Indicates the animator parameters. + * @return Returns the delay for playing the animation, in milliseconds. + * @since 12 + */ +int32_t OH_ArkUI_AnimatorOption_GetDelay(ArkUI_AnimatorOption* option); + +/** + * @brief Obtains the number of times that an animation is played. + * + * @param option Animator animation parameter. + * @return Returns the number of times that the animation is played. + * @since 12 + */ +int32_t OH_ArkUI_AnimatorOption_GetIterations(ArkUI_AnimatorOption* option); + +/** + * @brief Obtains whether the animator animation is restored to the initial state after being executed. + * + * @param option Indicates the animator parameters. + * @return Returns whether the animator animation is restored to the initial state after being executed. + * @since 12 + */ +ArkUI_AnimationFillMode OH_ArkUI_AnimatorOption_GetFill(ArkUI_AnimatorOption* option); + +/** + * @brief Obtains the playback direction of an animation. + * + * @param option Indicates the animator parameters. + * @return Returns the animation playback direction. + * @since 12 + */ +ArkUI_AnimationDirection OH_ArkUI_AnimatorOption_GetDirection(ArkUI_AnimatorOption* option); + +/** + * @brief Obtains the interpolation curve of the animation of an animator. + * + * @param option Indicates the animator parameters. + * @return Returns the interpolation curve of the animation. + * Returns NULL if a parameter error occurs. + * @since 12 + */ +ArkUI_CurveHandle OH_ArkUI_AnimatorOption_GetCurve(ArkUI_AnimatorOption* option); + +/** + * @brief Obtains the interpolation start point of an animation. + * + * @param option Indicates the animator parameters. + * @return Returns the interpolation start point of the animation. + * @since 12 + */ +float OH_ArkUI_AnimatorOption_GetBegin(ArkUI_AnimatorOption* option); + +/** + * @brief Obtains the interpolation end point of an animation. + * + * @param option Indicates the animator parameters. + * @return Returns the interpolation end point of the animation. + * @since 12 + */ +float OH_ArkUI_AnimatorOption_GetEnd(ArkUI_AnimatorOption* option); + +/** + * @brief Obtains the expected frame rate range of an animation. + * + * @param option Indicates the animator parameters. + * @return Returns the pointer to the expected frame rate range object. + * Returns NULL if a parameter error occurs. + * @since 12 + */ +ArkUI_ExpectedFrameRateRange* OH_ArkUI_AnimatorOption_GetExpectedFrameRateRange(ArkUI_AnimatorOption* option); + +/** + * @brief Obtains the keyframe time of an animation. + * + * @param option Indicates an animator parameter object. + * @param index Indicates the keyframe index. + * @return Returns the keyframe time. + * @since 12 + */ +float OH_ArkUI_AnimatorOption_GetKeyframeTime(ArkUI_AnimatorOption* option, int32_t index); + +/** + * @brief Obtains the keyframe value of an animation. + * + * @param option Indicates an animator parameter object. + * @param index Indicates the keyframe index. + * @return Returns the keyframe value. + * @since 12 + */ +float OH_ArkUI_AnimatorOption_GetKeyframeValue(ArkUI_AnimatorOption* option, int32_t index); + +/** + * @brief Obtains the interpolation curve for a keyframe in the animation of an animator. + * + * @param option Indicates an animator parameter object. + * @param index Indicates the keyframe index. + * @return Returns the interpolation curve. + * Returns NULL if a parameter error occurs. + * @since 12 + */ +ArkUI_CurveHandle OH_ArkUI_AnimatorOption_GetKeyframeCurve(ArkUI_AnimatorOption* option, int32_t index); + +/** + * @brief Obtains the custom object in an animation event object. + * + * @param event Indicates an animation event object. + * @return Returns the custom object. + * Returns NULL if a parameter error occurs. + * @since 12 + */ +void* OH_ArkUI_AnimatorEvent_GetUserData(ArkUI_AnimatorEvent* event); + +/** + * @brief Obtains the custom object in an animation event object. + * + * @param event Indicates an animation event object. + * @return Returns the custom object. + * @since 12 + */ +void* OH_ArkUI_AnimatorOnFrameEvent_GetUserData(ArkUI_AnimatorOnFrameEvent* event); + +/** + * @brief Obtains the current progress in an animation event object. + * + * @param event Indicates an animation event object. + * @return Returns the animation progress. + * @since 12 + */ +float OH_ArkUI_AnimatorOnFrameEvent_GetValue(ArkUI_AnimatorOnFrameEvent* event); + +/** + * @brief Sets the callback invoked when the animator receives a frame. + * + * @param animator Indicates an animator object. + * @param userData Indicates the custom parameter. + * @param callback Indicates the callback to set. + * @return Returns the error code. + * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. + * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. + */ +int32_t OH_ArkUI_AnimatorOption_RegisterOnFrameCallback( + ArkUI_AnimatorHandle animatorHandle, void* userData, void (*callback)(ArkUI_AnimatorOnFrameEvent* event)); + +/** + * @brief Sets the callback invoked when the animation playback is complete. + * + * @param animator Indicates an animator object. + * @param userData Indicates the custom parameter. + * @param callback Indicates the callback to set. + * @return Returns the error code. + * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. + * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. + */ +int32_t OH_ArkUI_AnimatorOption_RegisterOnFinishCallback( + ArkUI_AnimatorHandle animatorHandle, void* userData, void (*callback)(ArkUI_AnimatorEvent* event)); + +/** + * @brief Sets the callback invoked when the animation playback is canceled. + * + * @param animator Indicates an animator object. + * @param userData Indicates the custom parameter. + * @param callback Indicates the callback to set. + * @return Returns the error code. + * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. + * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. + */ +int32_t OH_ArkUI_AnimatorOption_RegisterOnCancelCallback( + ArkUI_AnimatorHandle animatorHandle, void* userData, void (*callback)(ArkUI_AnimatorEvent* event)); + +/** + * @brief Sets the callback invoked when the animation playback is repeated. + * + * @param animator Indicates an animator object. + * @param userData Indicates the custom parameter. + * @param callback Indicates the callback to set. + * @return Returns the error code. + * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. + * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. + */ +int32_t OH_ArkUI_AnimatorOption_RegisterOnRepeatCallback( + ArkUI_AnimatorHandle animatorHandle, void* userData, void (*callback)(ArkUI_AnimatorEvent* event)); + +/** + * @brief Resets the animation of an animator. + * + * @param animator Indicates an animator object. + * @param option Indicates the animator parameters. + * @return Returns the error code. + * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. + * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. + */ +int32_t OH_ArkUI_Animator_ResetAnimatorOption( + ArkUI_AnimatorHandle animatorHandle, ArkUI_AnimatorOption* option); + +/** + * @brief Starts the animation of an animator. + * + * @param animator Indicates an animator object. + * @return Returns the error code. + * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. + * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. + */ +int32_t OH_ArkUI_Animator_Play(ArkUI_AnimatorHandle animatorHandle); + +/** + * @brief Ends the animation of an animator. + * + * @param animator Indicates an animator object. + * @return Returns the error code. + * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. + * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. + */ +int32_t OH_ArkUI_Animator_Finish(ArkUI_AnimatorHandle animatorHandle); + +/** + * @brief Pauses the animation of an animator. + * + * @param animator Indicates an animator object. + * @return Returns the error code. + * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. + * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. + */ +int32_t OH_ArkUI_Animator_Pause(ArkUI_AnimatorHandle animatorHandle); + +/** + * @brief Cancels the animation of an animator. + * + * @param animator Indicates an animator object. + * @return Returns the error code. + * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. + * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. + */ +int32_t OH_ArkUI_Animator_Cancel(ArkUI_AnimatorHandle animatorHandle); + +/** + * @brief Plays the animation of an animator in reverse order. + * + * @param animator Indicates an animator object. + * @return Returns the error code. + * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. + * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. + */ +int32_t OH_ArkUI_Animator_Reverse(ArkUI_AnimatorHandle animatorHandle); + +/** + * @brief Implements initialization for the interpolation curve, which is used to create an interpolation curve based on + * the input parameter. + * + * @param curve Indicates the curve type. + * @return Returns the pointer to the interpolation object of the curve. + * Returns NULL if a parameter error occurs. + */ +ArkUI_CurveHandle OH_ArkUI_Curve_InitCurve(ArkUI_AnimationCurve curve); + +/** + * @brief Creates a step curve. + * + * @param count Indicates the number of steps. The value must be a positive integer. Value range: [1, +∞). + * @param end Indicates whether jumping occurs when the interpolation ends. + * true: Jumping occurs when the interpolation ends. false: Jumping occurs when the interpolation starts. + * @return Returns the pointer to the interpolation object of the curve. + * Returns NULL if a parameter error occurs. + */ +ArkUI_CurveHandle OH_ArkUI_Curve_StepsCurve(int32_t count, bool end); + +/** + * @brief Creates a cubic Bezier curve. + * + * + * @param x1 Indicates the X coordinate of the first point on the Bezier curve. Value range: [0, 1]. + * A value less than 0 is handed as 0. A value greater than 1 is handed as 1. + * @param y1 Indicates the Y coordinate of the first point on the Bezier curve. + * @param x2 Indicates the X coordinate of the second point on the Bezier curve. Value range: [0, 1]. + * A value less than 0 is handed as 0. A value greater than 1 is handed as 1. + * @param y2 Indicates the Y coordinate of the second point on the Bezier curve. + * @return Returns the pointer to the interpolation object of the curve. + * Returns NULL if a parameter error occurs. + */ +ArkUI_CurveHandle OH_ArkUI_Curve_CubicBezierCurve(float x1, float y1, float x2, float y2); + +/** + * @brief Creates a spring curve. The curve shape is subject to the spring parameters, and the animation duration is + * subject to the duration parameter in animation and animateTo. + * + * @param velocity Indicates the initial velocity of the spring. It is applied by external factors to the spring + * animation, designed to help ensure the smooth transition from the previous motion state. The velocity is the + * normalized velocity, and its value is equal to the actual velocity at the beginning of the animation divided by the + * animation attribute change value. + * @param mass Indicates the mass, which influences the inertia in the spring system. The greater the mass, the greater + * the amplitude of the oscillation, and the slower the speed of restoring to the equilibrium position. + * @param stiffness Indicates the stiffness. It is the degree to which an object deforms by resisting the force applied. + * In an elastic system, the greater the stiffness, the stronger the ability to resist deformation, and the faster the + * speed of restoring to the equilibrium position. + * @param damping Indicates the damping. It is used to describe the oscillation and attenuation of the system after + * being disturbed. The larger the damping, the smaller the number of oscillations of elastic motion, and the smaller + * the oscillation amplitude. + * @return Returns the pointer to the interpolation object of the curve. + * Returns NULL if a parameter error occurs. + */ +ArkUI_CurveHandle OH_ArkUI_Curve_SpringCurve(float velocity, float mass, float stiffness, float damping); + +/** + * @brief Creates a spring animation curve. If multiple spring animations are applied to the same attribute of an + * object, each animation replaces their predecessor and inherits the velocity. + * @note The animation duration is subject to the curve parameters, rather than the duration parameter in + * animation or animateTo. + * + * @param response Indicates the duration of one complete oscillation. + * @param dampingFraction Indicates the damping coefficient. + * > 0 and < 1: underdamped. In this case, the spring overshoots the equilibrium position. + * 1: critically damped. + * > 1: overdamped. In this case, the spring approaches equilibrium gradually. + * @param overlapDuration Indicates the duration for animations to overlap. When animations overlap, the response + * values of these animations will + * transit smoothly over this duration if they are different. + * @return Returns the pointer to the interpolation object of the curve. + * Returns NULL if a parameter error occurs. + */ +ArkUI_CurveHandle OH_ArkUI_Curve_SpringMotion(float response, float dampingFraction, float overlapDuration); + +/** + * @brief Creates a responsive spring animation curve. It is a special case of springMotion, with the only + * difference in the default values. It can be used together with springMotion. + * @note The animation duration is subject to the curve parameters, rather than the duration parameter in + * animation or animateTo. + * + * @param response Indicates the duration of one complete oscillation. + * @param dampingFraction Indicates the damping coefficient. + * > 0 and < 1: underdamped. In this case, the spring overshoots the equilibrium position. + * 1: critically damped. + * > 1: overdamped. In this case, the spring approaches equilibrium gradually. + * @param overlapDuration Indicates the duration for animations to overlap. When animations overlap, the + * response values of these animations will + * transit smoothly over this duration if they are different. + * @return Returns the pointer to the interpolation object of the curve. + * Returns NULL if a parameter error occurs. + */ +ArkUI_CurveHandle OH_ArkUI_Curve_ResponsiveSpringMotion(float response, float dampingFraction, float overlapDuration); + +/** + * @brief Creates an interpolating spring curve animated from 0 to 1. The actual animation value is calculated based on + * the curve. + * @note The animation duration is subject to the curve parameters, rather than the duration parameter in + * animation or animateTo. + * + * + * @param velocity Indicates the initial velocity of the spring. It is applied by external factors to the spring + * animation, esigned to help ensure the smooth transition from the previous motion state. The velocity is the + * normalized velocity, and its value is equal to the actual velocity + * at the beginning of the animation divided by the animation attribute change value. + * @param mass Indicates the mass, which influences the inertia in the spring system. + * The greater the mass, the greater the amplitude of the oscillation, and the slower the speed of restoring to the + * equilibrium position. + * @param stiffness Indicates the stiffness. It is the degree to which an object deforms by resisting the force applied. + * In an elastic system, the greater the stiffness, the stronger the ability to resist deformation, and the faster the + * speed of restoring to the equilibrium position. + * @param damping Indicates the damping. It is used to describe the oscillation and attenuation of the system after + * being disturbed. The larger the damping, the smaller the number of oscillations of elastic motion, and the smaller + * the oscillation amplitude. + * @return Returns the pointer to the interpolation object of the curve. + * Returns NULL if a parameter error occurs. + */ +ArkUI_CurveHandle OH_ArkUI_Curve_InterpolatingSpring(float velocity, float mass, float stiffness, float damping); + +/** + * @brief Creates a custom curve. + * + * @param userData Indicates the custom data. + * @param interpolate Indicates the custom interpolation callback. fraction indicates the input x value for + * interpolation when the animation starts; value range: [0,1]. + * The return value is the y value of the curve; value range: [0,1]. + * If fraction is 0, the return value 0 corresponds to the animation start point; any other return + * value means that the animation jumps at the start point. + * If fraction is 1, the return value 1 corresponds to the animation end point; any other return + * value means that the end value of the animation is not the value of the state variable, + * which will result in an effect of transition from that end value to the value of the state variable. + * @return Returns the pointer to the interpolation object of the curve. + * Returns NULL if a parameter error occurs. + */ +ArkUI_CurveHandle OH_ArkUI_Curve_CustomCurve(void* userData, float (*interpolate)(float fraction, void* userdata)); + +/** + * @brief Disposes of a custom curve. + * + * @param curve Indicates the pointer to the interpolation object of the curve. + */ +void OH_ArkUI_Curve_disposeCurve(ArkUI_CurveHandle curveHandle); #ifdef __cplusplus }; #endif diff --git a/arkui/ace_engine/native/native_gesture.h b/arkui/ace_engine/native/native_gesture.h index aa62a0f75..3f80d130f 100644 --- a/arkui/ace_engine/native/native_gesture.h +++ b/arkui/ace_engine/native/native_gesture.h @@ -399,6 +399,14 @@ float OH_ArkUI_PinchGesture_GetCenterX(const ArkUI_GestureEvent* event); */ float OH_ArkUI_PinchGesture_GetCenterY(const ArkUI_GestureEvent* event); +/** +* @brief Get the ARKUI component bound to the gesture. +* +* @param event gesture event. +* @return ARKUI component bound to the gesture.If Null is returned, it means event is an invalid value. +* @since 12 +*/ +ArkUI_NodeHandle OH_ArkUI_GestureEvent_GetNode(const ArkUI_GestureEvent* event); /** * @brief Defines the gesture APIs. * diff --git a/arkui/ace_engine/native/native_node.h b/arkui/ace_engine/native/native_node.h index 349ff9b9c..f0103919e 100644 --- a/arkui/ace_engine/native/native_node.h +++ b/arkui/ace_engine/native/native_node.h @@ -7013,6 +7013,17 @@ typedef struct { * @return Returns the pointer of the component, if not return NULL */ ArkUI_NodeHandle (*getParent)(ArkUI_NodeHandle node); + + /** + * @brief Uninstall all child nodes from the parent component. + * + * @param parent target node object. + * @return Returns the error code. + * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. + * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. + * @since 12 + */ + int32_t (*removeAllChildren)(ArkUI_NodeHandle parent); } ArkUI_NativeNodeAPI_1; /** diff --git a/arkui/ace_engine/native/native_type.h b/arkui/ace_engine/native/native_type.h index 0bec78cd8..db6351b43 100644 --- a/arkui/ace_engine/native/native_type.h +++ b/arkui/ace_engine/native/native_type.h @@ -1932,6 +1932,26 @@ typedef enum { ARKUI_ACCESSIBILITY_ACTION_PASTE = 1 << 4, } ArkUI_AccessibilityActionType; +/** + * @brief Enumerates the animation playback modes. + * + * @since 12 + */ +typedef enum { + /** The animation plays in forward loop mode. */ + ARKUI_ANIMATION_DIRECTION_NORMAL = 0, + /** The animation plays in reverse loop mode. */ + ARKUI_ANIMATION_DIRECTION_REVERSE, + /** The animation plays in alternating loop mode. When the animation is played for an odd number of times, the + * playback is in forward direction. When the animation is played for an even number of times, the playback is in + * reverse direction. */ + ARKUI_ANIMATION_DIRECTION_ALTERNATE, + /** The animation plays in reverse alternating loop mode. When the animation is played for an odd number of times, + * the playback is in reverse direction. When the animation is played for an even number of times, the playback is + * in forward direction. */ + ARKUI_ANIMATION_DIRECTION_ALTERNATE_REVERSE, +} ArkUI_AnimationDirection; + /** * @brief Define the rolling source enumeration value. * -- Gitee