!521 [NDK] animate api

Merge pull request !521 from lisitao/ndk_list_8
This commit is contained in:
openharmony_ci 2024-04-15 13:26:41 +00:00 committed by Gitee
commit 9f6b628788
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
6 changed files with 352 additions and 0 deletions

View File

@ -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",

View File

@ -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"
}
]

View File

@ -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 <cstdint>
#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 <b>onFinish</b> 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 <b>0</b> if the operation is successful; returns <b>401</b> 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

View File

@ -54,6 +54,8 @@ typedef enum {
ARKUI_NATIVE_DIALOG,
/** API related to gestures. For details, see the struct definition in <arkui/native_gesture.h>. */
ARKUI_NATIVE_GESTURE,
/** API related to animations. For details, see the struct definition in <arkui/native_animate.h>.*/
ARKUI_NATIVE_ANIMATE,
} ArkUI_NativeAPIVariantKind;
/**

View File

@ -56,6 +56,19 @@ extern "C" {
*/
int32_t OH_ArkUI_GetNodeHandleFromNapiValue(napi_env env, napi_value frameNode, ArkUI_NodeHandle* handle);
/**
* @brief Obtains a <b>UIContext</b> object on the ArkTS side and maps it to an <b>ArkUI_ContextHandle</b> object on the
* native side.
*
* @param env ndicates the NAPI environment pointer.
* @param value Indicates the <b>UIContext</b> object created on the ArkTS side.
* @param context Indicates the pointer to the <b>ArkUI_ContextHandle</b> 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

View File

@ -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.
*