mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-23 15:10:30 +00:00
[NDK] add animitor api
Signed-off-by:lisitaolisitao3@huawei.com Signed-off-by: lisitao <lisitao3@huawei.com> Change-Id: I33aba14ba5e8df6033aa5c39673419dabd65cdfa
This commit is contained in:
parent
9233c16636
commit
f81f00e594
@ -91,6 +91,9 @@ typedef ArkUI_ListItemSwipeActionOption* ArkUIListItemSwipeActionOptionHandle;
|
||||
typedef ArkUI_ListItemSwipeActionItem* ArkUIListItemSwipeActionItemHandle;
|
||||
typedef ArkUI_ListChildrenMainSize* ArkUIListChildrenMainSize;
|
||||
|
||||
struct _ArkUICurve;
|
||||
typedef _ArkUICurve* ArkUICurveHandle;
|
||||
|
||||
struct ArkUIRect {
|
||||
ArkUI_Float32 x;
|
||||
ArkUI_Float32 y;
|
||||
@ -554,6 +557,15 @@ struct ArkUISwiperMarginOptions {
|
||||
ArkUI_Bool ignoreBlank;
|
||||
};
|
||||
|
||||
struct ArkUI_AnimatorEvent {
|
||||
void* userData;
|
||||
};
|
||||
|
||||
struct ArkUI_AnimatorOnFrameEvent {
|
||||
float progress;
|
||||
void* userData;
|
||||
};
|
||||
|
||||
struct ArkUIPopupParam {
|
||||
ArkUI_Bool isShow;
|
||||
ArkUI_Bool useCustomComponent;
|
||||
@ -1015,6 +1027,8 @@ struct ArkUIAnimateOption {
|
||||
void* onFinishCallback;
|
||||
void* user;
|
||||
ArkUI_Int32 finishCallbackType;
|
||||
ArkUICurveHandle iCurve;
|
||||
ArkUI_Int32 curveType;
|
||||
};
|
||||
|
||||
struct ArkUIContext {
|
||||
@ -1089,6 +1103,62 @@ struct ArkUISliderValidSlideRange {
|
||||
ArkUI_Float32 to;
|
||||
};
|
||||
|
||||
struct ArkUIKeyframeState {
|
||||
ArkUI_Int32 duration;
|
||||
ArkUICurveHandle curve;
|
||||
ArkUI_Int32 curveType;
|
||||
void (*event)(void* userData);
|
||||
void* userData;
|
||||
};
|
||||
|
||||
struct ArkUIKeyframeAnimateOption {
|
||||
ArkUI_Int32 delay;
|
||||
ArkUI_Int32 iterations;
|
||||
void (*onFinish)(void* userData);
|
||||
void* userData;
|
||||
ArkUIKeyframeState* keyframes;
|
||||
ArkUI_Int32 keyframeSize;
|
||||
};
|
||||
|
||||
struct ArkUIKeyframe {
|
||||
ArkUI_Float32 keyTime;
|
||||
ArkUI_Float32 keyValue;
|
||||
ArkUICurveHandle curve;
|
||||
ArkUI_Int32 curveType;
|
||||
};
|
||||
|
||||
struct ArkUIAnimatorOption {
|
||||
ArkUI_Int32 duration;
|
||||
ArkUI_Int32 delay;
|
||||
ArkUI_Int32 iterations;
|
||||
ArkUI_Float32 begin;
|
||||
ArkUI_Float32 end;
|
||||
ArkUI_Int32 fill;
|
||||
ArkUI_Int32 direction;
|
||||
ArkUICurveHandle easing;
|
||||
ArkUI_Int32 curveType;
|
||||
ArkUI_Bool isHasExpectedFrameRateRange;
|
||||
ArkUIExpectedFrameRateRange expectedFrameRateRange;
|
||||
ArkUIKeyframe* keyframes;
|
||||
ArkUI_Int32 keyframeSize;
|
||||
void (*onFrame)(ArkUI_AnimatorOnFrameEvent* event);
|
||||
void* frameUserData;
|
||||
void (*onFinish)(ArkUI_AnimatorEvent* event);
|
||||
void* finishUserData;
|
||||
void (*onCancel)(ArkUI_AnimatorEvent* event);
|
||||
void* cancelUserData;
|
||||
void (*onRepeat)(ArkUI_AnimatorEvent* event);
|
||||
void* repeatUserData;
|
||||
};
|
||||
|
||||
struct ArkUIAnimator {
|
||||
void* animator;
|
||||
void* context;
|
||||
void* animatorOption;
|
||||
};
|
||||
|
||||
typedef ArkUIAnimator* ArkUIAnimatorHandle;
|
||||
|
||||
struct ArkUIImageFrameInfo {
|
||||
ArkUI_CharPtr src;
|
||||
ArkUI_Int32 width;
|
||||
@ -4061,8 +4131,30 @@ struct ArkUIAnimation {
|
||||
ArkUIVMContext vmContext, ArkUI_Int32 curve, ArkUI_Float32* options, ArkUI_Int32 callbackId);
|
||||
void (*closeImplicitAnimation)();
|
||||
void (*animateTo)(ArkUIContext* context, ArkUIAnimateOption option, void* event, void* userData);
|
||||
void (*keyframeAnimateTo)(ArkUIContext* context, ArkUIKeyframeAnimateOption* option);
|
||||
ArkUIAnimatorHandle (*createAnimator)(ArkUIContext* context, ArkUIAnimatorOption* option);
|
||||
void (*disposeAnimator)(ArkUIAnimatorHandle animator);
|
||||
ArkUI_Int32 (*animatorReset)(ArkUIAnimatorHandle animator, ArkUIAnimatorOption* option);
|
||||
ArkUI_Int32 (*animatorPlay)(ArkUIAnimatorHandle animator);
|
||||
ArkUI_Int32 (*animatorFinish)(ArkUIAnimatorHandle animator);
|
||||
ArkUI_Int32 (*animatorPause)(ArkUIAnimatorHandle animator);
|
||||
ArkUI_Int32 (*animatorCancel)(ArkUIAnimatorHandle animator);
|
||||
ArkUI_Int32 (*animatorReverse)(ArkUIAnimatorHandle animator);
|
||||
ArkUICurveHandle (*initCurve)(ArkUI_Int32 curve);
|
||||
ArkUICurveHandle (*stepsCurve)(ArkUI_Int32 count, ArkUI_Bool end);
|
||||
ArkUICurveHandle (*cubicBezierCurve)(ArkUI_Float32 x1, ArkUI_Float32 y1, ArkUI_Float32 x2, ArkUI_Float32 y2);
|
||||
ArkUICurveHandle (*springCurve)(
|
||||
ArkUI_Float32 velocity, ArkUI_Float32 mass, ArkUI_Float32 stiffness, ArkUI_Float32 damping);
|
||||
ArkUICurveHandle (*springMotion)(
|
||||
ArkUI_Float32 response, ArkUI_Float32 dampingFraction, ArkUI_Float32 overlapDuration);
|
||||
ArkUICurveHandle (*responsiveSpringMotion)(
|
||||
ArkUI_Float32 response, ArkUI_Float32 dampingFraction, ArkUI_Float32 overlapDuration);
|
||||
ArkUICurveHandle (*interpolatingSpring)(
|
||||
ArkUI_Float32 velocity, ArkUI_Float32 mass, ArkUI_Float32 stiffness, ArkUI_Float32 damping);
|
||||
ArkUICurveHandle (*customCurve)(
|
||||
ArkUI_Float32 (*interpolate)(ArkUI_Float32 fraction, void* userdata), void* userdata);
|
||||
void (*disposeCurve)(ArkUICurveHandle curve);
|
||||
};
|
||||
|
||||
struct ArkUINavigation {
|
||||
void (*popPageToIndex)(ArkUI_Int32 index);
|
||||
void (*setNavDestinationBackPressed)(ArkUIVMContext vmContext, ArkUINodeHandle node, ArkUI_Int32 indexerId);
|
||||
|
@ -15,10 +15,15 @@
|
||||
|
||||
#include "core/interfaces/native/node/node_animate.h"
|
||||
|
||||
#include "base/error/error_code.h"
|
||||
#include "base/memory/ace_type.h"
|
||||
#include "base/utils/utils.h"
|
||||
#include "core/animation/curve_animation.h"
|
||||
#include "core/animation/spring_curve.h"
|
||||
#include "core/common/ace_engine.h"
|
||||
#include "core/common/container.h"
|
||||
#include "core/common/container_scope.h"
|
||||
|
||||
namespace OHOS::Ace::NG::ViewAnimate {
|
||||
namespace {
|
||||
const std::vector<OHOS::Ace::RefPtr<OHOS::Ace::Curve>> CURVES_LIST = {
|
||||
@ -43,6 +48,17 @@ const std::vector<AnimationDirection> DIRECTION_LIST = {
|
||||
AnimationDirection::ALTERNATE,
|
||||
AnimationDirection::ALTERNATE_REVERSE,
|
||||
};
|
||||
|
||||
enum class ArkUICurveType {
|
||||
CURVE_TYPE_CURVE = 0,
|
||||
CURVE_TYPE_STEPS,
|
||||
CURVE_TYPE_CUBIC_BEZIER,
|
||||
CURVE_TYPE_SPRING,
|
||||
CURVE_TYPE_SPRING_MOTION,
|
||||
CURVE_TYPE_RESPONSIVE_SPRING_MOTION,
|
||||
CURVE_TYPE_INTERPOLATING_SPRING,
|
||||
CURVE_TYPE_CUSTOM,
|
||||
};
|
||||
} // namespace
|
||||
|
||||
void AnimateToInner(ArkUIContext* context, AnimationOption& option, const std::function<void()>& animateToFunc,
|
||||
@ -115,7 +131,12 @@ void AnimateTo(ArkUIContext* context, ArkUIAnimateOption option, void (*event)(v
|
||||
AnimationOption animationOption;
|
||||
animationOption.SetDuration(NearZero(static_cast<double>(option.tempo)) ? 0 : option.duration);
|
||||
animationOption.SetTempo(option.tempo);
|
||||
animationOption.SetCurve(CURVES_LIST[option.curve > CURVES_LIST.size() ? 0 : option.curve]);
|
||||
if (option.iCurve) {
|
||||
auto curve = reinterpret_cast<Curve*>(option.iCurve);
|
||||
animationOption.SetCurve(AceType::Claim(curve));
|
||||
} else {
|
||||
animationOption.SetCurve(CURVES_LIST[option.curve > CURVES_LIST.size() ? 0 : option.curve]);
|
||||
}
|
||||
animationOption.SetDelay(option.delay);
|
||||
animationOption.SetIteration(option.iterations);
|
||||
animationOption.SetAnimationDirection(
|
||||
@ -144,4 +165,320 @@ void AnimateTo(ArkUIContext* context, ArkUIAnimateOption option, void (*event)(v
|
||||
AnimateToInner(context, animationOption, onEvent, onFinishEvent, false);
|
||||
}
|
||||
|
||||
} // namespace OHOS::Ace::NG::ViewAnimate
|
||||
void KeyframeAnimateTo(ArkUIContext* context, ArkUIKeyframeAnimateOption* animateOption)
|
||||
{
|
||||
CHECK_NULL_VOID(context);
|
||||
ContainerScope scope(context->id);
|
||||
auto containerSafely = Container::GetContainer(context->id);
|
||||
CHECK_NULL_VOID(containerSafely);
|
||||
auto pipelineContext = containerSafely->GetPipelineContext();
|
||||
CHECK_NULL_VOID(pipelineContext);
|
||||
|
||||
AnimationOption option;
|
||||
if (animateOption->onFinish) {
|
||||
auto onFinishEvent = [onFinish = animateOption->onFinish, userData = animateOption->userData,
|
||||
id = context->id]() {
|
||||
ContainerScope scope(id);
|
||||
onFinish(userData);
|
||||
};
|
||||
option.SetOnFinishEvent(onFinishEvent);
|
||||
}
|
||||
|
||||
option.SetDelay(animateOption->delay);
|
||||
option.SetIteration(animateOption->iterations);
|
||||
|
||||
int duration = 0;
|
||||
for (int32_t i = 0; i < animateOption->keyframeSize; i++) {
|
||||
duration += animateOption->keyframes[i].duration;
|
||||
}
|
||||
option.SetDuration(duration);
|
||||
// actual curve is in keyframe, this curve will not be effective
|
||||
option.SetCurve(Curves::EASE_IN_OUT);
|
||||
pipelineContext->FlushBuild();
|
||||
pipelineContext->OpenImplicitAnimation(option, option.GetCurve(), option.GetOnFinishEvent());
|
||||
|
||||
for (int32_t i = 0; i < animateOption->keyframeSize; i++) {
|
||||
auto keyframe = animateOption->keyframes[i];
|
||||
if (!keyframe.event) {
|
||||
continue;
|
||||
}
|
||||
auto event = [&keyframe, &pipelineContext]() {
|
||||
keyframe.event(keyframe.userData);
|
||||
pipelineContext->FlushBuild();
|
||||
if (!pipelineContext->IsLayouting()) {
|
||||
pipelineContext->FlushUITasks();
|
||||
}
|
||||
};
|
||||
if (keyframe.curve) {
|
||||
auto curve = reinterpret_cast<Curve*>(keyframe.curve);
|
||||
AnimationUtils::AddDurationKeyFrame(keyframe.duration, AceType::Claim(curve), event);
|
||||
} else {
|
||||
AnimationUtils::AddDurationKeyFrame(keyframe.duration, Curves::EASE_IN_OUT, event);
|
||||
}
|
||||
}
|
||||
pipelineContext->CloseImplicitAnimation();
|
||||
}
|
||||
|
||||
RefPtr<Animation<double>> ParseAnimatorAnimation(const ArkUIAnimatorOption* option)
|
||||
{
|
||||
if (option->keyframeSize > 0) {
|
||||
auto keyframeAnimation = AceType::MakeRefPtr<KeyframeAnimation<double>>();
|
||||
for (int32_t i = 0; i < option->keyframeSize; i++) {
|
||||
auto keyframe = option->keyframes[i];
|
||||
auto animatorKeyframe = AceType::MakeRefPtr<Keyframe<double>>(keyframe.keyTime, keyframe.keyValue);
|
||||
if (keyframe.curve) {
|
||||
auto curve = reinterpret_cast<Curve*>(keyframe.curve);
|
||||
animatorKeyframe->SetCurve(AceType::Claim(curve));
|
||||
} else {
|
||||
animatorKeyframe->SetCurve(Curves::EASE_IN_OUT);
|
||||
}
|
||||
keyframeAnimation->AddKeyframe(animatorKeyframe);
|
||||
}
|
||||
return keyframeAnimation;
|
||||
} else {
|
||||
RefPtr<Animation<double>> animation;
|
||||
auto curve = reinterpret_cast<Curve*>(option->easing);
|
||||
if (curve) {
|
||||
animation = AceType::MakeRefPtr<CurveAnimation<double>>(option->begin, option->end, AceType::Claim(curve));
|
||||
} else {
|
||||
animation = AceType::MakeRefPtr<CurveAnimation<double>>(option->begin, option->end, Curves::EASE_IN_OUT);
|
||||
}
|
||||
return animation;
|
||||
}
|
||||
}
|
||||
|
||||
void ParseAnimatorOption(const RefPtr<Animator>& animator, ArkUIAnimatorOption* option)
|
||||
{
|
||||
animator->SetDuration(option->duration);
|
||||
animator->SetIteration(option->iterations);
|
||||
animator->SetAnimationDirection(static_cast<AnimationDirection>(option->direction));
|
||||
animator->SetStartDelay(option->delay);
|
||||
animator->SetFillMode(static_cast<FillMode>(option->fill));
|
||||
|
||||
if (option->isHasExpectedFrameRateRange) {
|
||||
FrameRateRange frameRateRange { option->expectedFrameRateRange.min, option->expectedFrameRateRange.max,
|
||||
option->expectedFrameRateRange.expected };
|
||||
animator->SetExpectedFrameRateRange(frameRateRange);
|
||||
}
|
||||
}
|
||||
|
||||
void RegisterAnimatorOnFrameEvent(const RefPtr<Animator>& animator, ArkUIAnimatorOption* option)
|
||||
{
|
||||
animator->ClearInterpolators();
|
||||
//onframe
|
||||
auto onFrameCallback = [callback = option->onFrame, userData = option->frameUserData](double value) {
|
||||
if (callback) {
|
||||
ArkUI_AnimatorOnFrameEvent event;
|
||||
event.progress = static_cast<ArkUI_Float32>(value);
|
||||
event.userData = userData;
|
||||
callback(&event);
|
||||
}
|
||||
};
|
||||
RefPtr<Animation<double>> animation = ParseAnimatorAnimation(option);
|
||||
if (animation) {
|
||||
animation->AddListener(onFrameCallback);
|
||||
animator->AddInterpolator(animation);
|
||||
}
|
||||
}
|
||||
|
||||
void RegisterAnimatorEvent(const RefPtr<Animator>& animator, ArkUIAnimatorOption* option)
|
||||
{
|
||||
animator->ClearStopListeners();
|
||||
animator->ClearIdleListeners();
|
||||
animator->ClearRepeatListeners();
|
||||
|
||||
RegisterAnimatorOnFrameEvent(animator, option);
|
||||
|
||||
//onfinish
|
||||
animator->AddStopListener([callback = option->onFinish, userData = option->finishUserData] {
|
||||
if (callback) {
|
||||
ArkUI_AnimatorEvent event;
|
||||
event.userData = userData;
|
||||
callback(&event);
|
||||
}
|
||||
});
|
||||
|
||||
//oncancel
|
||||
animator->AddIdleListener([callback = option->onCancel, userData = option->cancelUserData] {
|
||||
if (callback) {
|
||||
ArkUI_AnimatorEvent event;
|
||||
event.userData = userData;
|
||||
callback(&event);
|
||||
}
|
||||
});
|
||||
|
||||
//onRepeat
|
||||
animator->AddRepeatListener([callback = option->onRepeat, userData = option->repeatUserData] {
|
||||
if (callback) {
|
||||
ArkUI_AnimatorEvent event;
|
||||
event.userData = userData;
|
||||
callback(&event);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ArkUIAnimatorHandle CreateAnimator(ArkUIContext* context, ArkUIAnimatorOption* option)
|
||||
{
|
||||
CHECK_NULL_RETURN(context, nullptr);
|
||||
ContainerScope scope(context->id);
|
||||
auto containerSafely = Container::GetContainer(context->id);
|
||||
CHECK_NULL_RETURN(containerSafely, nullptr);
|
||||
auto pipelineContext = containerSafely->GetPipelineContext();
|
||||
CHECK_NULL_RETURN(pipelineContext, nullptr);
|
||||
|
||||
ArkUIAnimator* result = new ArkUIAnimator;
|
||||
auto animator = CREATE_ANIMATOR("ohos.animator");
|
||||
animator->AttachScheduler(pipelineContext);
|
||||
ParseAnimatorOption(animator, option);
|
||||
RegisterAnimatorEvent(animator, option);
|
||||
animator->IncRefCount();
|
||||
result->animator = AceType::RawPtr(animator);
|
||||
result->context = context;
|
||||
result->animatorOption = option;
|
||||
return result;
|
||||
}
|
||||
|
||||
void DisposeAnimator(ArkUIAnimatorHandle animatorHandle)
|
||||
{
|
||||
if (animatorHandle->animator) {
|
||||
auto* animator = reinterpret_cast<Animator*>(animatorHandle->animator);
|
||||
if (animator) {
|
||||
animator->DecRefCount();
|
||||
}
|
||||
}
|
||||
delete animatorHandle;
|
||||
}
|
||||
|
||||
int32_t AnimatorReset(ArkUIAnimatorHandle animatorHandle, ArkUIAnimatorOption* option)
|
||||
{
|
||||
CHECK_NULL_RETURN(animatorHandle, ERROR_CODE_PARAM_INVALID);
|
||||
CHECK_NULL_RETURN(animatorHandle->animator, ERROR_CODE_PARAM_INVALID);
|
||||
auto animator = reinterpret_cast<Animator*>(animatorHandle->animator);
|
||||
animator->Cancel();
|
||||
ParseAnimatorOption(AceType::Claim(animator), option);
|
||||
RegisterAnimatorEvent(AceType::Claim(animator), option);
|
||||
animatorHandle->animatorOption = option;
|
||||
animator->ResetIsReverse();
|
||||
return ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t AnimatorPlay(ArkUIAnimatorHandle animatorHandle)
|
||||
{
|
||||
CHECK_NULL_RETURN(animatorHandle, ERROR_CODE_PARAM_INVALID);
|
||||
CHECK_NULL_RETURN(animatorHandle->animator, ERROR_CODE_PARAM_INVALID);
|
||||
auto animator = reinterpret_cast<Animator*>(animatorHandle->animator);
|
||||
animator->Play();
|
||||
return ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t AnimatorFinish(ArkUIAnimatorHandle animatorHandle)
|
||||
{
|
||||
CHECK_NULL_RETURN(animatorHandle, ERROR_CODE_PARAM_INVALID);
|
||||
CHECK_NULL_RETURN(animatorHandle->animator, ERROR_CODE_PARAM_INVALID);
|
||||
auto animator = reinterpret_cast<Animator*>(animatorHandle->animator);
|
||||
animator->Finish();
|
||||
return ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t AnimatorPause(ArkUIAnimatorHandle animatorHandle)
|
||||
{
|
||||
CHECK_NULL_RETURN(animatorHandle, ERROR_CODE_PARAM_INVALID);
|
||||
CHECK_NULL_RETURN(animatorHandle->animator, ERROR_CODE_PARAM_INVALID);
|
||||
auto animator = reinterpret_cast<Animator*>(animatorHandle->animator);
|
||||
animator->Pause();
|
||||
return ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t AnimatorCancel(ArkUIAnimatorHandle animatorHandle)
|
||||
{
|
||||
CHECK_NULL_RETURN(animatorHandle, ERROR_CODE_PARAM_INVALID);
|
||||
CHECK_NULL_RETURN(animatorHandle->animator, ERROR_CODE_PARAM_INVALID);
|
||||
auto animator = reinterpret_cast<Animator*>(animatorHandle->animator);
|
||||
animator->Cancel();
|
||||
return ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t AnimatorReverse(ArkUIAnimatorHandle animatorHandle)
|
||||
{
|
||||
CHECK_NULL_RETURN(animatorHandle, ERROR_CODE_PARAM_INVALID);
|
||||
CHECK_NULL_RETURN(animatorHandle->animator, ERROR_CODE_PARAM_INVALID);
|
||||
auto animator = reinterpret_cast<Animator*>(animatorHandle->animator);
|
||||
animator->Reverse();
|
||||
return ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
ArkUICurveHandle CreateCurve(ArkUI_Int32 curve)
|
||||
{
|
||||
auto iCurve = AceType::RawPtr(CURVES_LIST[curve > CURVES_LIST.size() ? 0 : curve]);
|
||||
iCurve->IncRefCount();
|
||||
return reinterpret_cast<ArkUICurveHandle>(iCurve);
|
||||
}
|
||||
|
||||
ArkUICurveHandle CreateStepsCurve(ArkUI_Int32 count, ArkUI_Bool end)
|
||||
{
|
||||
auto curve = AceType::MakeRefPtr<StepsCurve>(count, static_cast<StepsCurvePosition>(end));
|
||||
curve->IncRefCount();
|
||||
return reinterpret_cast<ArkUICurveHandle>(AceType::RawPtr(curve));
|
||||
}
|
||||
|
||||
ArkUICurveHandle CreateCubicBezierCurve(ArkUI_Float32 x1, ArkUI_Float32 y1, ArkUI_Float32 x2, ArkUI_Float32 y2)
|
||||
{
|
||||
auto curve = AceType::MakeRefPtr<CubicCurve>(x1, y1, x2, y2);
|
||||
curve->IncRefCount();
|
||||
return reinterpret_cast<ArkUICurveHandle>(AceType::RawPtr(curve));
|
||||
}
|
||||
|
||||
ArkUICurveHandle CreateSpringCurve(
|
||||
ArkUI_Float32 velocity, ArkUI_Float32 mass, ArkUI_Float32 stiffness, ArkUI_Float32 damping)
|
||||
{
|
||||
auto curve = AceType::MakeRefPtr<SpringCurve>(velocity, mass, stiffness, damping);
|
||||
curve->IncRefCount();
|
||||
return reinterpret_cast<ArkUICurveHandle>(AceType::RawPtr(curve));
|
||||
}
|
||||
|
||||
ArkUICurveHandle CreateSpringMotion(
|
||||
ArkUI_Float32 response, ArkUI_Float32 dampingFraction, ArkUI_Float32 overlapDuration)
|
||||
{
|
||||
auto curve = AceType::MakeRefPtr<ResponsiveSpringMotion>(response, dampingFraction, overlapDuration);
|
||||
curve->IncRefCount();
|
||||
return reinterpret_cast<ArkUICurveHandle>(AceType::RawPtr(curve));
|
||||
}
|
||||
|
||||
ArkUICurveHandle CreateResponsiveSpringMotion(
|
||||
ArkUI_Float32 response, ArkUI_Float32 dampingFraction, ArkUI_Float32 overlapDuration)
|
||||
{
|
||||
auto curve = AceType::MakeRefPtr<ResponsiveSpringMotion>(response, dampingFraction, overlapDuration);
|
||||
curve->IncRefCount();
|
||||
return reinterpret_cast<ArkUICurveHandle>(AceType::RawPtr(curve));
|
||||
}
|
||||
|
||||
ArkUICurveHandle CreateInterpolatingSpring(
|
||||
ArkUI_Float32 velocity, ArkUI_Float32 mass, ArkUI_Float32 stiffness, ArkUI_Float32 damping)
|
||||
{
|
||||
auto curve = AceType::MakeRefPtr<InterpolatingSpring>(velocity, mass, stiffness, damping);
|
||||
curve->IncRefCount();
|
||||
return reinterpret_cast<ArkUICurveHandle>(AceType::RawPtr(curve));
|
||||
}
|
||||
|
||||
ArkUICurveHandle CreateCustomCurve(ArkUI_Float32 (*interpolate)(ArkUI_Float32 fraction, void* userData), void* userData)
|
||||
{
|
||||
auto func = [interpolate, userData](float value) -> float {
|
||||
if (interpolate) {
|
||||
return interpolate(value, userData);
|
||||
}
|
||||
return 0.0f;
|
||||
};
|
||||
auto curve = AceType::MakeRefPtr<CustomCurve>(func);
|
||||
curve->IncRefCount();
|
||||
return reinterpret_cast<ArkUICurveHandle>(AceType::RawPtr(curve));
|
||||
}
|
||||
|
||||
void DisposeCurve(ArkUICurveHandle curve)
|
||||
{
|
||||
CHECK_NULL_VOID(curve);
|
||||
auto* curvePtr = reinterpret_cast<Curve*>(curve);
|
||||
if (curvePtr) {
|
||||
curvePtr->DecRefCount();
|
||||
}
|
||||
}
|
||||
} // namespace OHOS::Ace::NG::ViewAnimate
|
@ -26,6 +26,31 @@ void AnimateToInner(AnimationOption& option, const std::function<void()>& animat
|
||||
|
||||
void AnimateTo(ArkUIContext* context, ArkUIAnimateOption option, void (*event)(void* userData), void* user);
|
||||
|
||||
void KeyframeAnimateTo(ArkUIContext* context, ArkUIKeyframeAnimateOption* animateOption);
|
||||
ArkUIAnimatorHandle CreateAnimator(ArkUIContext* context, ArkUIAnimatorOption* option);
|
||||
void DisposeAnimator(ArkUIAnimatorHandle animatorHandle);
|
||||
|
||||
int32_t AnimatorReset(ArkUIAnimatorHandle animatorHandle, ArkUIAnimatorOption* option);
|
||||
int32_t AnimatorPlay(ArkUIAnimatorHandle animatorHandle);
|
||||
int32_t AnimatorFinish(ArkUIAnimatorHandle animatorHandle);
|
||||
int32_t AnimatorPause(ArkUIAnimatorHandle animatorHandle);
|
||||
int32_t AnimatorCancel(ArkUIAnimatorHandle animatorHandle);
|
||||
int32_t AnimatorReverse(ArkUIAnimatorHandle animatorHandle);
|
||||
|
||||
ArkUICurveHandle CreateCurve(ArkUI_Int32 curve);
|
||||
ArkUICurveHandle CreateStepsCurve(ArkUI_Int32 count, ArkUI_Bool end);
|
||||
ArkUICurveHandle CreateCubicBezierCurve(ArkUI_Float32 x1, ArkUI_Float32 y1, ArkUI_Float32 x2, ArkUI_Float32 y2);
|
||||
ArkUICurveHandle CreateSpringCurve(
|
||||
ArkUI_Float32 velocity, ArkUI_Float32 mass, ArkUI_Float32 stiffness, ArkUI_Float32 damping);
|
||||
ArkUICurveHandle CreateSpringMotion(
|
||||
ArkUI_Float32 response, ArkUI_Float32 dampingFraction, ArkUI_Float32 overlapDuration);
|
||||
ArkUICurveHandle CreateResponsiveSpringMotion(
|
||||
ArkUI_Float32 response, ArkUI_Float32 dampingFraction, ArkUI_Float32 overlapDuration);
|
||||
ArkUICurveHandle CreateInterpolatingSpring(
|
||||
ArkUI_Float32 velocity, ArkUI_Float32 mass, ArkUI_Float32 stiffness, ArkUI_Float32 damping);
|
||||
ArkUICurveHandle CreateCustomCurve(
|
||||
ArkUI_Float32 (*interpolate)(ArkUI_Float32 fraction, void* userData), void* userData);
|
||||
void DisposeCurve(ArkUICurveHandle curve);
|
||||
} // namespace OHOS::Ace::NG::ViewAnimate
|
||||
|
||||
#endif // FOUNDATION_ACE_FRAMEWORKS_CORE_INTERFACES_NODE_ANIMATE_H
|
||||
|
@ -26,12 +26,14 @@
|
||||
#include "core/components_ng/base/ui_node.h"
|
||||
#include "core/components_ng/base/view_stack_processor.h"
|
||||
#include "core/interfaces/arkoala/arkoala_api.h"
|
||||
#include "core/interfaces/native/node/alphabet_indexer_modifier.h"
|
||||
#include "core/interfaces/native/node/calendar_picker_modifier.h"
|
||||
#include "core/interfaces/native/node/canvas_rendering_context_2d_modifier.h"
|
||||
#include "core/interfaces/native/node/custom_dialog_model.h"
|
||||
#include "core/interfaces/native/node/grid_modifier.h"
|
||||
#include "core/interfaces/native/node/node_adapter_impl.h"
|
||||
#include "core/interfaces/native/node/node_animate.h"
|
||||
#include "core/interfaces/native/node/node_canvas_modifier.h"
|
||||
#include "core/interfaces/native/node/node_adapter_impl.h"
|
||||
#include "core/interfaces/native/node/node_checkbox_modifier.h"
|
||||
#include "core/interfaces/native/node/node_common_modifier.h"
|
||||
#include "core/interfaces/native/node/node_date_picker_modifier.h"
|
||||
@ -41,9 +43,9 @@
|
||||
#include "core/interfaces/native/node/node_scroll_modifier.h"
|
||||
#include "core/interfaces/native/node/node_slider_modifier.h"
|
||||
#include "core/interfaces/native/node/node_swiper_modifier.h"
|
||||
#include "core/interfaces/native/node/node_text_modifier.h"
|
||||
#include "core/interfaces/native/node/node_text_area_modifier.h"
|
||||
#include "core/interfaces/native/node/node_text_input_modifier.h"
|
||||
#include "core/interfaces/native/node/node_text_modifier.h"
|
||||
#include "core/interfaces/native/node/node_textpicker_modifier.h"
|
||||
#include "core/interfaces/native/node/node_timepicker_modifier.h"
|
||||
#include "core/interfaces/native/node/node_toggle_modifier.h"
|
||||
@ -53,7 +55,9 @@
|
||||
#include "core/interfaces/native/node/alphabet_indexer_modifier.h"
|
||||
#include "core/interfaces/native/node/search_modifier.h"
|
||||
#include "core/interfaces/native/node/radio_modifier.h"
|
||||
#include "core/interfaces/native/node/search_modifier.h"
|
||||
#include "core/interfaces/native/node/select_modifier.h"
|
||||
#include "core/interfaces/native/node/util_modifier.h"
|
||||
#include "core/interfaces/native/node/view_model.h"
|
||||
#include "core/interfaces/native/node/water_flow_modifier.h"
|
||||
#include "core/interfaces/native/node/node_list_item_modifier.h"
|
||||
@ -534,7 +538,7 @@ void NotifyComponentAsyncEvent(ArkUINodeHandle node, ArkUIEventSubKind kind, Ark
|
||||
return;
|
||||
}
|
||||
eventHandle = TEXT_PICKER_NODE_ASYNC_EVENT_HANDLERS[subKind];
|
||||
break;
|
||||
break;
|
||||
}
|
||||
case ARKUI_CALENDAR_PICKER: {
|
||||
// calendar picker event type.
|
||||
@ -1190,6 +1194,100 @@ void AnimateTo(ArkUIContext* context, ArkUIAnimateOption option, void* event, vo
|
||||
ViewAnimate::AnimateTo(context, option, reinterpret_cast<void (*)(void*)>(event), user);
|
||||
}
|
||||
|
||||
void KeyframeAnimateTo(ArkUIContext* context, ArkUIKeyframeAnimateOption* animateOption)
|
||||
{
|
||||
ViewAnimate::KeyframeAnimateTo(context, animateOption);
|
||||
}
|
||||
|
||||
ArkUIAnimatorHandle CreateAnimator(ArkUIContext* context, ArkUIAnimatorOption* animateOption)
|
||||
{
|
||||
return ViewAnimate::CreateAnimator(context, animateOption);
|
||||
}
|
||||
|
||||
void DisposeAnimator(ArkUIAnimatorHandle animator)
|
||||
{
|
||||
ViewAnimate::DisposeAnimator(animator);
|
||||
}
|
||||
|
||||
ArkUI_Int32 AnimatorReset(ArkUIAnimatorHandle animator, ArkUIAnimatorOption* option)
|
||||
{
|
||||
return ViewAnimate::AnimatorReset(animator, option);
|
||||
}
|
||||
|
||||
ArkUI_Int32 AnimatorPlay(ArkUIAnimatorHandle animator)
|
||||
{
|
||||
return ViewAnimate::AnimatorPlay(animator);
|
||||
}
|
||||
|
||||
ArkUI_Int32 AnimatorFinish(ArkUIAnimatorHandle animator)
|
||||
{
|
||||
return ViewAnimate::AnimatorFinish(animator);
|
||||
}
|
||||
|
||||
ArkUI_Int32 AnimatorPause(ArkUIAnimatorHandle animator)
|
||||
{
|
||||
return ViewAnimate::AnimatorPause(animator);
|
||||
}
|
||||
|
||||
ArkUI_Int32 AnimatorCancel(ArkUIAnimatorHandle animator)
|
||||
{
|
||||
return ViewAnimate::AnimatorCancel(animator);
|
||||
}
|
||||
|
||||
ArkUI_Int32 AnimatorReverse(ArkUIAnimatorHandle animator)
|
||||
{
|
||||
return ViewAnimate::AnimatorReverse(animator);
|
||||
}
|
||||
|
||||
ArkUICurveHandle CreateCurve(ArkUI_Int32 curve)
|
||||
{
|
||||
return ViewAnimate::CreateCurve(curve);
|
||||
}
|
||||
|
||||
ArkUICurveHandle CreateStepsCurve(ArkUI_Int32 count, ArkUI_Bool end)
|
||||
{
|
||||
return ViewAnimate::CreateStepsCurve(count, end);
|
||||
}
|
||||
|
||||
ArkUICurveHandle CreateCubicBezierCurve(ArkUI_Float32 x1, ArkUI_Float32 y1, ArkUI_Float32 x2, ArkUI_Float32 y2)
|
||||
{
|
||||
return ViewAnimate::CreateCubicBezierCurve(x1, y1, x2, y2);
|
||||
}
|
||||
|
||||
ArkUICurveHandle CreateSpringCurve(
|
||||
ArkUI_Float32 velocity, ArkUI_Float32 mass, ArkUI_Float32 stiffness, ArkUI_Float32 damping)
|
||||
{
|
||||
return ViewAnimate::CreateSpringCurve(velocity, mass, stiffness, damping);
|
||||
}
|
||||
|
||||
ArkUICurveHandle CreateSpringMotion(
|
||||
ArkUI_Float32 response, ArkUI_Float32 dampingFraction, ArkUI_Float32 overlapDuration)
|
||||
{
|
||||
return ViewAnimate::CreateSpringMotion(response, dampingFraction, overlapDuration);
|
||||
}
|
||||
|
||||
ArkUICurveHandle CreateResponsiveSpringMotion(
|
||||
ArkUI_Float32 response, ArkUI_Float32 dampingFraction, ArkUI_Float32 overlapDuration)
|
||||
{
|
||||
return ViewAnimate::CreateResponsiveSpringMotion(response, dampingFraction, overlapDuration);
|
||||
}
|
||||
|
||||
ArkUICurveHandle CreateInterpolatingSpring(
|
||||
ArkUI_Float32 velocity, ArkUI_Float32 mass, ArkUI_Float32 stiffness, ArkUI_Float32 damping)
|
||||
{
|
||||
return ViewAnimate::CreateInterpolatingSpring(velocity, mass, stiffness, damping);
|
||||
}
|
||||
|
||||
ArkUICurveHandle CreateCustomCurve(ArkUI_Float32 (*interpolate)(ArkUI_Float32 fraction, void* userData), void* userData)
|
||||
{
|
||||
return ViewAnimate::CreateCustomCurve(interpolate, userData);
|
||||
}
|
||||
|
||||
void DisposeCurve(ArkUICurveHandle curve)
|
||||
{
|
||||
return ViewAnimate::DisposeCurve(curve);
|
||||
}
|
||||
|
||||
const ArkUIAnimation* GetAnimationAPI()
|
||||
{
|
||||
static const ArkUIAnimation modifier = {
|
||||
@ -1197,6 +1295,24 @@ const ArkUIAnimation* GetAnimationAPI()
|
||||
nullptr,
|
||||
nullptr,
|
||||
AnimateTo,
|
||||
KeyframeAnimateTo,
|
||||
CreateAnimator,
|
||||
DisposeAnimator,
|
||||
AnimatorReset,
|
||||
AnimatorPlay,
|
||||
AnimatorFinish,
|
||||
AnimatorPause,
|
||||
AnimatorCancel,
|
||||
AnimatorReverse,
|
||||
CreateCurve,
|
||||
CreateStepsCurve,
|
||||
CreateCubicBezierCurve,
|
||||
CreateSpringCurve,
|
||||
CreateSpringMotion,
|
||||
CreateResponsiveSpringMotion,
|
||||
CreateInterpolatingSpring,
|
||||
CreateCustomCurve,
|
||||
DisposeCurve,
|
||||
};
|
||||
return &modifier;
|
||||
}
|
||||
|
@ -1370,5 +1370,249 @@
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_ListItemSwipeActionOption_SetOnOffsetChangeWithUserData"
|
||||
},
|
||||
{
|
||||
"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_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"
|
||||
}
|
||||
]
|
||||
|
@ -59,6 +59,16 @@ typedef struct {
|
||||
*/
|
||||
typedef struct ArkUI_AnimateOption ArkUI_AnimateOption;
|
||||
|
||||
struct ArkUI_Curve;
|
||||
typedef struct ArkUI_Curve* ArkUI_CurveHandle;
|
||||
|
||||
typedef struct ArkUI_KeyframeAnimateOption ArkUI_KeyframeAnimateOption;
|
||||
typedef struct ArkUI_AnimatorOption ArkUI_AnimatorOption;
|
||||
typedef struct ArkUI_Animator* ArkUI_AnimatorHandle;
|
||||
|
||||
struct ArkUI_AnimatorEvent;
|
||||
struct ArkUI_AnimatorOnFrameEvent;
|
||||
|
||||
/**
|
||||
* @brief Implements the native animation APIs provided by ArkUI.
|
||||
*
|
||||
@ -80,6 +90,10 @@ typedef struct {
|
||||
*/
|
||||
int32_t (*animateTo)(ArkUI_ContextHandle context, ArkUI_AnimateOption* option, ArkUI_ContextCallback* update,
|
||||
ArkUI_AnimateCompleteCallback* complete);
|
||||
|
||||
int32_t (*keyframeAnimateTo)(ArkUI_ContextHandle context, ArkUI_KeyframeAnimateOption* option);
|
||||
ArkUI_AnimatorHandle (*createAnimator)(ArkUI_ContextHandle context, ArkUI_AnimatorOption* option);
|
||||
void (*disposeAnimator)(ArkUI_AnimatorHandle animator);
|
||||
} ArkUI_NativeAnimateAPI_1;
|
||||
|
||||
/**
|
||||
@ -223,6 +237,76 @@ void OH_ArkUI_AnimateOption_SetPlayMode(ArkUI_AnimateOption* option, ArkUI_Anima
|
||||
*/
|
||||
void OH_ArkUI_AnimateOption_SetExpectedFrameRateRange(ArkUI_AnimateOption* option, ArkUI_ExpectedFrameRateRange* value);
|
||||
|
||||
void OH_ArkUI_AnimateOption_SetICurve(ArkUI_AnimateOption* option, ArkUI_CurveHandle value);
|
||||
ArkUI_CurveHandle OH_ArkUI_AnimateOption_GetICurve(ArkUI_AnimateOption* option);
|
||||
|
||||
ArkUI_KeyframeAnimateOption* OH_ArkUI_KeyframeAnimateOption_Create(int32_t size);
|
||||
void OH_ArkUI_KeyframeAnimateOption_Dispose(ArkUI_KeyframeAnimateOption* option);
|
||||
int32_t OH_ArkUI_KeyframeAnimateOption_SetDelay(ArkUI_KeyframeAnimateOption* option, int32_t value);
|
||||
int32_t OH_ArkUI_KeyframeAnimateOption_SetIterations(ArkUI_KeyframeAnimateOption* option, int32_t value);
|
||||
int32_t OH_ArkUI_KeyframeAnimateOption_RegisterOnFinishCallback(
|
||||
ArkUI_KeyframeAnimateOption* option, void* userData, void (*onFinish)(void* userData));
|
||||
int32_t OH_ArkUI_KeyframeAnimateOption_SetDuration(ArkUI_KeyframeAnimateOption* option, int32_t value, int32_t index);
|
||||
int32_t OH_ArkUI_KeyframeAnimateOption_SetCurve(
|
||||
ArkUI_KeyframeAnimateOption* option, ArkUI_CurveHandle value, int32_t index);
|
||||
int32_t OH_ArkUI_KeyframeAnimateOption_RegisterOnEventCallback(
|
||||
ArkUI_KeyframeAnimateOption* option, void* userData, void (*event)(void* userData), int32_t index);
|
||||
int32_t OH_ArkUI_KeyframeAnimateOption_GetDelay(ArkUI_KeyframeAnimateOption* option);
|
||||
int32_t OH_ArkUI_KeyframeAnimateOption_GetIterations(ArkUI_KeyframeAnimateOption* option);
|
||||
int32_t OH_ArkUI_KeyframeAnimateOption_GetDuration(ArkUI_KeyframeAnimateOption* option, int32_t index);
|
||||
ArkUI_CurveHandle OH_ArkUI_KeyframeAnimateOption_GetCurve(ArkUI_KeyframeAnimateOption* option, int32_t index);
|
||||
ArkUI_AnimatorOption* OH_ArkUI_AnimatorOption_Create(int32_t keyframeSize);
|
||||
void OH_ArkUI_ArkUI_AnimatorOption_Dispose(ArkUI_AnimatorOption* option);
|
||||
int32_t OH_ArkUI_AnimatorOption_SetDuration(ArkUI_AnimatorOption* option, int32_t value);
|
||||
int32_t OH_ArkUI_AnimatorOption_SetDelay(ArkUI_AnimatorOption* option, int32_t value);
|
||||
int32_t OH_ArkUI_AnimatorOption_SetIterations(ArkUI_AnimatorOption* option, int32_t value);
|
||||
int32_t OH_ArkUI_AnimatorOption_SetFill(ArkUI_AnimatorOption* option, ArkUI_AnimationFillMode value);
|
||||
int32_t OH_ArkUI_AnimatorOption_SetDirection(ArkUI_AnimatorOption* option, ArkUI_AnimationDirection value);
|
||||
int32_t OH_ArkUI_AnimatorOption_SetCurve(ArkUI_AnimatorOption* option, ArkUI_CurveHandle value);
|
||||
int32_t OH_ArkUI_AnimatorOption_SetBegin(ArkUI_AnimatorOption* option, float value);
|
||||
int32_t OH_ArkUI_AnimatorOption_SetEnd(ArkUI_AnimatorOption* option, float value);
|
||||
int32_t OH_ArkUI_AnimatorOption_SetExpectedFrameRateRange(
|
||||
ArkUI_AnimatorOption* option, ArkUI_ExpectedFrameRateRange* value);
|
||||
int32_t OH_ArkUI_AnimatorOption_SetKeyframe(ArkUI_AnimatorOption* option, float time, float value, int32_t index);
|
||||
int32_t OH_ArkUI_AnimatorOption_SetKeyframeCurve(ArkUI_AnimatorOption* option, ArkUI_CurveHandle value, int32_t index);
|
||||
int32_t OH_ArkUI_AnimatorOption_GetDuration(ArkUI_AnimatorOption* option);
|
||||
int32_t OH_ArkUI_AnimatorOption_GetDelay(ArkUI_AnimatorOption* option);
|
||||
int32_t OH_ArkUI_AnimatorOption_GetIterations(ArkUI_AnimatorOption* option);
|
||||
ArkUI_AnimationFillMode OH_ArkUI_AnimatorOption_GetFill(ArkUI_AnimatorOption* option);
|
||||
ArkUI_AnimationDirection OH_ArkUI_AnimatorOption_GetDirection(ArkUI_AnimatorOption* option);
|
||||
ArkUI_CurveHandle OH_ArkUI_AnimatorOption_GetCurve(ArkUI_AnimatorOption* option);
|
||||
float OH_ArkUI_AnimatorOption_GetBegin(ArkUI_AnimatorOption* option);
|
||||
float OH_ArkUI_AnimatorOption_GetEnd(ArkUI_AnimatorOption* option);
|
||||
ArkUI_ExpectedFrameRateRange* OH_ArkUI_AnimatorOption_GetExpectedFrameRateRange(ArkUI_AnimatorOption* option);
|
||||
float OH_ArkUI_AnimatorOption_GetKeyframeTime(ArkUI_AnimatorOption* option, int32_t index);
|
||||
float OH_ArkUI_AnimatorOption_GetKeyframeValue(ArkUI_AnimatorOption* option, int32_t index);
|
||||
ArkUI_CurveHandle OH_ArkUI_AnimatorOption_GetKeyframeCurve(ArkUI_AnimatorOption* option, int32_t index);
|
||||
void* OH_ArkUI_AnimatorEvent_GetUserData(ArkUI_AnimatorEvent* event);
|
||||
void* OH_ArkUI_AnimatorOnFrameEvent_GetUserData(ArkUI_AnimatorOnFrameEvent* event);
|
||||
float OH_ArkUI_AnimatorOnFrameEvent_GetValue(ArkUI_AnimatorOnFrameEvent* event);
|
||||
int32_t OH_ArkUI_AnimatorOption_RegisterOnFrameCallback(
|
||||
ArkUI_AnimatorOption* option, void* userData, void (*callback)(ArkUI_AnimatorOnFrameEvent* event));
|
||||
int32_t OH_ArkUI_AnimatorOption_RegisterOnFinishCallback(
|
||||
ArkUI_AnimatorOption* option, void* userData, void (*callback)(ArkUI_AnimatorEvent* event));
|
||||
int32_t OH_ArkUI_AnimatorOption_RegisterOnCancelCallback(
|
||||
ArkUI_AnimatorOption* option, void* userData, void (*callback)(ArkUI_AnimatorEvent* event));
|
||||
int32_t OH_ArkUI_AnimatorOption_RegisterOnRepeatCallback(
|
||||
ArkUI_AnimatorOption* option, void* userData, void (*callback)(ArkUI_AnimatorEvent* event));
|
||||
int32_t OH_ArkUI_Animator_ResetAnimatorOption(ArkUI_AnimatorHandle animator, ArkUI_AnimatorOption* option);
|
||||
int32_t OH_ArkUI_Animator_Play(ArkUI_AnimatorHandle animator);
|
||||
int32_t OH_ArkUI_Animator_Finish(ArkUI_AnimatorHandle animator);
|
||||
int32_t OH_ArkUI_Animator_Pause(ArkUI_AnimatorHandle animator);
|
||||
int32_t OH_ArkUI_Animator_Cancel(ArkUI_AnimatorHandle animator);
|
||||
int32_t OH_ArkUI_Animator_Reverse(ArkUI_AnimatorHandle animator);
|
||||
ArkUI_CurveHandle OH_ArkUI_Curve_InitCurve(ArkUI_AnimationCurve curve);
|
||||
ArkUI_CurveHandle OH_ArkUI_Curve_StepsCurve(int32_t count, bool end);
|
||||
ArkUI_CurveHandle OH_ArkUI_Curve_CubicBezierCurve(float x1, float y1, float x2, float y2);
|
||||
ArkUI_CurveHandle OH_ArkUI_Curve_SpringCurve(float velocity, float mass, float stiffness, float damping);
|
||||
ArkUI_CurveHandle OH_ArkUI_Curve_SpringMotion(float response, float dampingFraction, float overlapDuration);
|
||||
ArkUI_CurveHandle OH_ArkUI_Curve_ResponsiveSpringMotion(float response, float dampingFraction, float overlapDuration);
|
||||
ArkUI_CurveHandle OH_ArkUI_Curve_InterpolatingSpring(float velocity, float mass, float stiffness, float damping);
|
||||
ArkUI_CurveHandle OH_ArkUI_Curve_CustomCurve(void* userData, float (*interpolate)(float fraction, void* userdata));
|
||||
void OH_ArkUI_Curve_disposeCurve(ArkUI_CurveHandle curveHandle);
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
@ -6773,6 +6773,15 @@ typedef struct {
|
||||
* @return Returns the pointer to the subnode if the subnode exists; returns <b>NULL</b> otherwise.
|
||||
*/
|
||||
ArkUI_NodeHandle (*getParent)(ArkUI_NodeHandle node);
|
||||
|
||||
/**
|
||||
* @brief 从父组件上卸载所有子节点。
|
||||
*
|
||||
* @param parent 目标节点对象。
|
||||
* @return 0 - 成功。
|
||||
* 401 - 函数参数异常。
|
||||
*/
|
||||
int32_t (*removeAllChildren)(ArkUI_NodeHandle parent);
|
||||
} ArkUI_NativeNodeAPI_1;
|
||||
|
||||
/**
|
||||
|
@ -1833,6 +1833,14 @@ typedef enum {
|
||||
ARKUI_SWIPER_INDICATOR_TYPE_DIGIT,
|
||||
} ArkUI_SwiperIndicatorType;
|
||||
|
||||
|
||||
typedef enum {
|
||||
ARKUI_ANIMATION_DIRECTION_NORMAL = 0,
|
||||
ARKUI_ANIMATION_DIRECTION_ALTERNATE,
|
||||
ARKUI_ANIMATION_DIRECTION_REVERSE,
|
||||
ARKUI_ANIMATION_DIRECTION_ALTERNATE_REVERSE,
|
||||
} ArkUI_AnimationDirection;
|
||||
|
||||
typedef enum {
|
||||
/** In the folded state, when the ListItem slides in the opposite direction to the main axis,
|
||||
* the operation item is hidden.*/
|
||||
|
@ -35,6 +35,10 @@ int32_t AnimateTo(ArkUI_ContextHandle context, ArkUI_AnimateOption* option, ArkU
|
||||
animateOption.curve = static_cast<ArkUI_Int32>(option->curve);
|
||||
animateOption.delay = option->delay;
|
||||
animateOption.iterations = option->iterations;
|
||||
if (option->iCurve) {
|
||||
animateOption.iCurve = option->iCurve->curve;
|
||||
animateOption.curveType = option->iCurve->baseCurveType;
|
||||
}
|
||||
animateOption.playMode = static_cast<ArkUI_Int32>(option->playMode);
|
||||
if (option->expectedFrameRateRange) {
|
||||
animateOption.expectedFrameRateRange =
|
||||
@ -59,4 +63,327 @@ int32_t AnimateTo(ArkUI_ContextHandle context, ArkUI_AnimateOption* option, ArkU
|
||||
return ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t KeyframeAnimateTo(ArkUI_ContextHandle context, ArkUI_KeyframeAnimateOption* option)
|
||||
{
|
||||
auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
|
||||
if (!impl || !context || !option || option->keyframes.size() == 0) {
|
||||
return ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
|
||||
ArkUIKeyframeAnimateOption animateOption {};
|
||||
animateOption.delay = option->delay;
|
||||
animateOption.iterations = option->iterations;
|
||||
animateOption.onFinish = option->onFinish;
|
||||
animateOption.userData = option->userData;
|
||||
ArkUIKeyframeState keyframes[option->keyframes.size()];
|
||||
for (int32_t i = 0; i < option->keyframes.size(); i++) {
|
||||
keyframes[i].duration = option->keyframes[i].duration;
|
||||
keyframes[i].event = option->keyframes[i].event;
|
||||
keyframes[i].userData = option->keyframes[i].userData;
|
||||
|
||||
auto curve = option->keyframes[i].curve;
|
||||
if (!curve) {
|
||||
continue;
|
||||
}
|
||||
//不支持当前curve
|
||||
if (curve->type == ARKUI_CURVE_TYPE_SPRING_MOTION || curve->type == ARKUI_CURVE_TYPE_RESPONSIVE_SPRING_MOTION ||
|
||||
curve->type == ARKUI_CURVE_TYPE_INTERPOLATING_SPRING) {
|
||||
continue;
|
||||
}
|
||||
keyframes[i].curve = curve->curve;
|
||||
keyframes[i].curveType = curve->type;
|
||||
}
|
||||
animateOption.keyframes = keyframes;
|
||||
animateOption.keyframeSize = option->keyframes.size();
|
||||
|
||||
impl->getAnimation()->keyframeAnimateTo(reinterpret_cast<ArkUIContext*>(context), &animateOption);
|
||||
return ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
ArkUIAnimatorOption* ConvertAnimatorOption(ArkUI_AnimatorOption* option)
|
||||
{
|
||||
ArkUIAnimatorOption* animatorOption = new ArkUIAnimatorOption;
|
||||
animatorOption->duration = option->duration;
|
||||
animatorOption->delay = option->delay;
|
||||
animatorOption->iterations = option->iterations;
|
||||
animatorOption->begin = option->begin;
|
||||
animatorOption->end = option->end;
|
||||
animatorOption->fill = option->fill;
|
||||
if (option->easing) {
|
||||
animatorOption->easing = option->easing->curve;
|
||||
animatorOption->curveType = option->easing->type;
|
||||
}
|
||||
|
||||
if (option->expectedFrameRateRange) {
|
||||
animatorOption->isHasExpectedFrameRateRange = 1;
|
||||
animatorOption->expectedFrameRateRange = { option->expectedFrameRateRange->min,
|
||||
option->expectedFrameRateRange->max, option->expectedFrameRateRange->expected };
|
||||
} else {
|
||||
animatorOption->isHasExpectedFrameRateRange = 0;
|
||||
}
|
||||
|
||||
int32_t keyframeSize = static_cast<int32_t>(option->keyframes.size());
|
||||
if (keyframeSize > 0) {
|
||||
animatorOption->keyframes = new ArkUIKeyframe[keyframeSize];
|
||||
for (int32_t i = 0; i < keyframeSize; ++i) {
|
||||
animatorOption->keyframes[i].keyTime = option->keyframes[i].keyTime;
|
||||
animatorOption->keyframes[i].keyValue = option->keyframes[i].keyValue;
|
||||
if (option->keyframes[i].curve) {
|
||||
animatorOption->keyframes[i].curve = option->keyframes[i].curve->curve;
|
||||
animatorOption->keyframes[i].curveType = option->keyframes[i].curve->type;
|
||||
} else {
|
||||
animatorOption->keyframes[i].curve = nullptr;
|
||||
animatorOption->keyframes[i].curveType = 0; // 默认或无效的曲线类型
|
||||
}
|
||||
}
|
||||
} else {
|
||||
animatorOption->keyframes = nullptr;
|
||||
}
|
||||
animatorOption->keyframeSize = keyframeSize;
|
||||
|
||||
animatorOption->onFrame = option->onFrame;
|
||||
animatorOption->onFinish = option->onFinish;
|
||||
animatorOption->onCancel = option->onCancel;
|
||||
animatorOption->onRepeat = option->onRepeat;
|
||||
|
||||
animatorOption->frameUserData = option->frameUserData;
|
||||
animatorOption->finishUserData = option->finishUserData;
|
||||
animatorOption->cancelUserData = option->cancelUserData;
|
||||
animatorOption->repeatUserData = option->repeatUserData;
|
||||
return animatorOption;
|
||||
}
|
||||
|
||||
ArkUI_AnimatorHandle CreateAnimator(ArkUI_ContextHandle context, ArkUI_AnimatorOption* option)
|
||||
{
|
||||
auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
|
||||
if (!impl || !context || !option) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto animatorOption = ConvertAnimatorOption(option);
|
||||
auto animator = impl->getAnimation()->createAnimator(reinterpret_cast<ArkUIContext*>(context), animatorOption);
|
||||
ArkUI_Animator* animatorHandle = new ArkUI_Animator { animator, option, animatorOption };
|
||||
return animatorHandle;
|
||||
}
|
||||
|
||||
void DisposeAnimator(ArkUI_AnimatorHandle animatorHandle)
|
||||
{
|
||||
auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
|
||||
if (!animatorHandle || !animatorHandle->animator) {
|
||||
return;
|
||||
}
|
||||
impl->getAnimation()->disposeAnimator(animatorHandle->animator);
|
||||
if (animatorHandle->animatorOption) {
|
||||
auto* animatorOption = reinterpret_cast<ArkUIAnimatorOption*>(animatorHandle->animatorOption);
|
||||
if (animatorOption->keyframes) {
|
||||
delete[] animatorOption->keyframes;
|
||||
animatorOption->keyframes = nullptr;
|
||||
}
|
||||
delete animatorOption;
|
||||
animatorHandle->animatorOption = nullptr;
|
||||
}
|
||||
delete animatorHandle;
|
||||
}
|
||||
|
||||
int32_t AnimatorReset(ArkUI_AnimatorHandle animatorHandle, ArkUI_AnimatorOption* option)
|
||||
{
|
||||
auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
|
||||
if (!impl || !animatorHandle || !animatorHandle->animator || !option) {
|
||||
return ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
|
||||
auto animatorOption = ConvertAnimatorOption(option);
|
||||
impl->getAnimation()->animatorReset(animatorHandle->animator, animatorOption);
|
||||
return ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t AnimatorPlay(ArkUI_AnimatorHandle animatorHandle)
|
||||
{
|
||||
auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
|
||||
if (!impl || !animatorHandle || !animatorHandle->animator) {
|
||||
return ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
impl->getAnimation()->animatorPlay(animatorHandle->animator);
|
||||
return ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t AnimatorFinish(ArkUI_AnimatorHandle animatorHandle)
|
||||
{
|
||||
auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
|
||||
if (!impl || !animatorHandle || !animatorHandle->animator) {
|
||||
return ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
impl->getAnimation()->animatorFinish(animatorHandle->animator);
|
||||
return ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t AnimatorPause(ArkUI_AnimatorHandle animatorHandle)
|
||||
{
|
||||
auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
|
||||
if (!impl || !animatorHandle || !animatorHandle->animator) {
|
||||
return ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
impl->getAnimation()->animatorPause(animatorHandle->animator);
|
||||
return ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t AnimatorCancel(ArkUI_AnimatorHandle animatorHandle)
|
||||
{
|
||||
auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
|
||||
if (!impl || !animatorHandle || !animatorHandle->animator) {
|
||||
return ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
impl->getAnimation()->animatorCancel(animatorHandle->animator);
|
||||
return ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t AnimatorReverse(ArkUI_AnimatorHandle animatorHandle)
|
||||
{
|
||||
auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
|
||||
if (!impl || !animatorHandle || !animatorHandle->animator) {
|
||||
return ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
impl->getAnimation()->animatorReverse(animatorHandle->animator);
|
||||
return ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
ArkUI_CurveHandle InitCurve(ArkUI_AnimationCurve animationCurve)
|
||||
{
|
||||
auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
|
||||
if (!impl) {
|
||||
return nullptr;
|
||||
}
|
||||
auto curve = impl->getAnimation()->initCurve(animationCurve);
|
||||
ArkUI_Curve* iCurve = new ArkUI_Curve({ ARKUI_CURVE_TYPE_BASE, curve, animationCurve });
|
||||
return iCurve;
|
||||
}
|
||||
|
||||
ArkUI_CurveHandle StepsCurve(int32_t count, bool end)
|
||||
{
|
||||
auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
|
||||
if (!impl || count < 1) {
|
||||
return nullptr;
|
||||
}
|
||||
auto curve = impl->getAnimation()->stepsCurve(count, end);
|
||||
ArkUI_Curve* iCurve = new ArkUI_Curve({ ARKUI_CURVE_TYPE_STEPS, curve });
|
||||
return iCurve;
|
||||
}
|
||||
|
||||
ArkUI_CurveHandle CubicBezierCurve(float x1, float y1, float x2, float y2)
|
||||
{
|
||||
auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
|
||||
if (!impl || x1 < 0 || x1 > 1 || x2 < 0 || x2 > 1) {
|
||||
return nullptr;
|
||||
}
|
||||
auto curve = impl->getAnimation()->cubicBezierCurve(x1, y1, x2, y2);
|
||||
ArkUI_Curve* iCurve = new ArkUI_Curve({ ARKUI_CURVE_TYPE_CUBIC_BEZIER, curve });
|
||||
return iCurve;
|
||||
}
|
||||
|
||||
ArkUI_CurveHandle SpringCurve(float velocity, float mass, float stiffness, float damping)
|
||||
{
|
||||
auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
|
||||
if (!impl) {
|
||||
return nullptr;
|
||||
}
|
||||
if (mass <= 0) {
|
||||
mass = 1;
|
||||
}
|
||||
if (stiffness <= 0) {
|
||||
stiffness = 1;
|
||||
}
|
||||
if (damping <= 0) {
|
||||
damping = 1;
|
||||
}
|
||||
auto curve = impl->getAnimation()->springCurve(velocity, mass, stiffness, damping);
|
||||
ArkUI_Curve* iCurve = new ArkUI_Curve({ ARKUI_CURVE_TYPE_SPRING, curve });
|
||||
return iCurve;
|
||||
}
|
||||
|
||||
ArkUI_CurveHandle SpringMotion(float response, float dampingFraction, float overlapDuration)
|
||||
{
|
||||
auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
|
||||
if (!impl) {
|
||||
return nullptr;
|
||||
}
|
||||
//default
|
||||
if (response <= 0) {
|
||||
response = 0.55f;
|
||||
}
|
||||
//default
|
||||
if (dampingFraction <= 0) {
|
||||
dampingFraction = 0.825f;
|
||||
}
|
||||
//default
|
||||
if (overlapDuration < 0) {
|
||||
overlapDuration = 0;
|
||||
}
|
||||
auto curve = impl->getAnimation()->springMotion(response, dampingFraction, overlapDuration);
|
||||
ArkUI_Curve* iCurve = new ArkUI_Curve({ ARKUI_CURVE_TYPE_SPRING_MOTION, curve });
|
||||
return iCurve;
|
||||
}
|
||||
|
||||
ArkUI_CurveHandle ResponsiveSpringMotion(float response, float dampingFraction, float overlapDuration)
|
||||
{
|
||||
auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
|
||||
if (!impl) {
|
||||
return nullptr;
|
||||
}
|
||||
//default
|
||||
if (response <= 0) {
|
||||
response = 0.15f;
|
||||
}
|
||||
//default
|
||||
if (dampingFraction < 0) {
|
||||
dampingFraction = 0.86f;
|
||||
}
|
||||
//default
|
||||
if (overlapDuration < 0) {
|
||||
overlapDuration = 0.25f;
|
||||
}
|
||||
auto curve = impl->getAnimation()->responsiveSpringMotion(response, dampingFraction, overlapDuration);
|
||||
ArkUI_Curve* iCurve = new ArkUI_Curve({ ARKUI_CURVE_TYPE_RESPONSIVE_SPRING_MOTION, curve });
|
||||
return iCurve;
|
||||
}
|
||||
|
||||
ArkUI_CurveHandle InterpolatingSpring(float velocity, float mass, float stiffness, float damping)
|
||||
{
|
||||
auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
|
||||
if (!impl) {
|
||||
return nullptr;
|
||||
}
|
||||
if (mass <= 0) {
|
||||
mass = 1;
|
||||
}
|
||||
if (stiffness <= 0) {
|
||||
stiffness = 1;
|
||||
}
|
||||
if (damping <= 0) {
|
||||
damping = 1;
|
||||
}
|
||||
auto curve = impl->getAnimation()->interpolatingSpring(velocity, mass, stiffness, damping);
|
||||
ArkUI_Curve* iCurve = new ArkUI_Curve({ ARKUI_CURVE_TYPE_INTERPOLATING_SPRING, curve });
|
||||
return iCurve;
|
||||
}
|
||||
|
||||
ArkUI_CurveHandle CustomCurve(void* userData, float (*interpolate)(float fraction, void* userdata))
|
||||
{
|
||||
auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
|
||||
if (!impl) {
|
||||
return nullptr;
|
||||
}
|
||||
auto curve = impl->getAnimation()->customCurve(interpolate, userData);
|
||||
ArkUI_Curve* iCurve = new ArkUI_Curve({ ARKUI_CURVE_TYPE_CUSTOM, curve });
|
||||
return iCurve;
|
||||
}
|
||||
|
||||
void DisposeCurve(ArkUI_CurveHandle curveHandle)
|
||||
{
|
||||
auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
|
||||
if (!impl || !curveHandle) {
|
||||
return;
|
||||
}
|
||||
impl->getAnimation()->disposeCurve(curveHandle->curve);
|
||||
delete curveHandle;
|
||||
}
|
||||
} // namespace OHOS::Ace::AnimateModel
|
@ -16,10 +16,13 @@
|
||||
#define ARKUI_NATIVE_ANIMATE_IMPL_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
#include "native_animate.h"
|
||||
#include "native_type.h"
|
||||
|
||||
#include "frameworks/core/interfaces/arkoala/arkoala_api.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@ -32,15 +35,101 @@ struct ArkUI_AnimateOption {
|
||||
int32_t iterations;
|
||||
ArkUI_AnimationPlayMode playMode;
|
||||
ArkUI_ExpectedFrameRateRange* expectedFrameRateRange;
|
||||
ArkUI_CurveHandle iCurve;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
ARKUI_CURVE_TYPE_BASE = 0,
|
||||
ARKUI_CURVE_TYPE_STEPS,
|
||||
ARKUI_CURVE_TYPE_CUBIC_BEZIER,
|
||||
ARKUI_CURVE_TYPE_SPRING,
|
||||
ARKUI_CURVE_TYPE_SPRING_MOTION,
|
||||
ARKUI_CURVE_TYPE_RESPONSIVE_SPRING_MOTION,
|
||||
ARKUI_CURVE_TYPE_INTERPOLATING_SPRING,
|
||||
ARKUI_CURVE_TYPE_CUSTOM,
|
||||
} ArkUI_CurveType;
|
||||
|
||||
struct ArkUI_Curve {
|
||||
ArkUI_CurveType type;
|
||||
ArkUICurveHandle curve;
|
||||
ArkUI_AnimationCurve baseCurveType;
|
||||
};
|
||||
|
||||
struct ArkUI_KeyframeState {
|
||||
int32_t duration;
|
||||
ArkUI_CurveHandle curve;
|
||||
void (*event)(void* userData);
|
||||
void* userData;
|
||||
};
|
||||
|
||||
struct ArkUI_KeyframeAnimateOption {
|
||||
int32_t delay;
|
||||
int32_t iterations;
|
||||
void (*onFinish)(void* userData);
|
||||
void* userData;
|
||||
std::vector<ArkUI_KeyframeState> keyframes;
|
||||
};
|
||||
|
||||
struct ArkUI_Keyframe {
|
||||
float keyTime;
|
||||
float keyValue;
|
||||
ArkUI_CurveHandle curve;
|
||||
};
|
||||
struct ArkUI_AnimatorOption {
|
||||
int32_t duration;
|
||||
int32_t delay;
|
||||
int32_t iterations;
|
||||
ArkUI_AnimationFillMode fill;
|
||||
ArkUI_AnimationDirection direction;
|
||||
float begin;
|
||||
float end;
|
||||
ArkUI_CurveHandle easing;
|
||||
ArkUI_ExpectedFrameRateRange* expectedFrameRateRange;
|
||||
std::vector<ArkUI_Keyframe> keyframes;
|
||||
void (*onFrame)(ArkUI_AnimatorOnFrameEvent* event);
|
||||
void* frameUserData;
|
||||
void (*onFinish)(ArkUI_AnimatorEvent* event);
|
||||
void* finishUserData;
|
||||
void (*onCancel)(ArkUI_AnimatorEvent* event);
|
||||
void* cancelUserData;
|
||||
void (*onRepeat)(ArkUI_AnimatorEvent* event);
|
||||
void* repeatUserData;
|
||||
};
|
||||
|
||||
struct ArkUI_Animator {
|
||||
ArkUIAnimatorHandle animator;
|
||||
ArkUI_AnimatorOption* option;
|
||||
ArkUIAnimatorOption* animatorOption;
|
||||
};
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
namespace OHOS::Ace::AnimateModel {
|
||||
|
||||
ArkUI_CurveHandle InitCurve(ArkUI_AnimationCurve animationCurve);
|
||||
ArkUI_CurveHandle StepsCurve(int32_t count, bool end);
|
||||
ArkUI_CurveHandle CubicBezierCurve(float x1, float y1, float x2, float y2);
|
||||
ArkUI_CurveHandle SpringCurve(float velocity, float mass, float stiffness, float damping);
|
||||
ArkUI_CurveHandle SpringMotion(float response, float dampingFraction, float overlapDuration);
|
||||
ArkUI_CurveHandle ResponsiveSpringMotion(float response, float dampingFraction, float overlapDuration);
|
||||
ArkUI_CurveHandle InterpolatingSpring(float velocity, float mass, float stiffness, float damping);
|
||||
ArkUI_CurveHandle CustomCurve(void* userData, float (*interpolate)(float fraction, void* userdata));
|
||||
void DisposeCurve(ArkUI_CurveHandle curveHandle);
|
||||
|
||||
int32_t AnimateTo(ArkUI_ContextHandle context, ArkUI_AnimateOption* option, ArkUI_ContextCallback* update,
|
||||
ArkUI_AnimateCompleteCallback* complete);
|
||||
|
||||
int32_t KeyframeAnimateTo(ArkUI_ContextHandle context, ArkUI_KeyframeAnimateOption* option);
|
||||
|
||||
ArkUI_AnimatorHandle CreateAnimator(ArkUI_ContextHandle context, ArkUI_AnimatorOption* option);
|
||||
void DisposeAnimator(ArkUI_AnimatorHandle animatorHandle);
|
||||
|
||||
int32_t AnimatorReset(ArkUI_AnimatorHandle animatorHandle, ArkUI_AnimatorOption* option);
|
||||
int32_t AnimatorPlay(ArkUI_AnimatorHandle animatorHandle);
|
||||
int32_t AnimatorFinish(ArkUI_AnimatorHandle animatorHandle);
|
||||
int32_t AnimatorPause(ArkUI_AnimatorHandle animatorHandle);
|
||||
int32_t AnimatorCancel(ArkUI_AnimatorHandle animatorHandle);
|
||||
int32_t AnimatorReverse(ArkUI_AnimatorHandle animatorHandle);
|
||||
}; // namespace OHOS::Ace::AnimateModel
|
||||
#endif
|
@ -89,6 +89,7 @@ ArkUI_NativeNodeAPI_1 nodeImpl_1 = {
|
||||
OHOS::Ace::NodeModel::GetUserData,
|
||||
OHOS::Ace::NodeModel::SetLengthMetricUnit,
|
||||
OHOS::Ace::NodeModel::GetParent,
|
||||
OHOS::Ace::NodeModel::RemoveAllChildren,
|
||||
};
|
||||
|
||||
ArkUI_NativeDialogAPI_1 dialogImpl_1 = {
|
||||
@ -133,6 +134,9 @@ ArkUI_NativeGestureAPI_1 gestureImpl_1 = {
|
||||
|
||||
ArkUI_NativeAnimateAPI_1 animateImpl_1 = {
|
||||
OHOS::Ace::AnimateModel::AnimateTo,
|
||||
OHOS::Ace::AnimateModel::KeyframeAnimateTo,
|
||||
OHOS::Ace::AnimateModel::CreateAnimator,
|
||||
OHOS::Ace::AnimateModel::DisposeAnimator,
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
@ -13,11 +13,15 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#include "animate_impl.h"
|
||||
#include "native_type.h"
|
||||
#include "node/node_model.h"
|
||||
|
||||
#include "base/error/error_code.h"
|
||||
#include "base/utils/utils.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@ -36,6 +40,7 @@ ArkUI_AnimateOption* OH_ArkUI_AnimateOption_Create()
|
||||
option->iterations = 1;
|
||||
option->playMode = ArkUI_AnimationPlayMode::ARKUI_ANIMATION_PLAY_MODE_NORMAL;
|
||||
option->expectedFrameRateRange = nullptr;
|
||||
option->iCurve = nullptr;
|
||||
return option;
|
||||
}
|
||||
|
||||
@ -152,6 +157,540 @@ void OH_ArkUI_AnimateOption_SetExpectedFrameRateRange(ArkUI_AnimateOption* optio
|
||||
option->expectedFrameRateRange = new ArkUI_ExpectedFrameRateRange { value->min, value->max, value->expected };
|
||||
}
|
||||
|
||||
void OH_ArkUI_AnimateOption_SetICurve(ArkUI_AnimateOption* option, ArkUI_CurveHandle value)
|
||||
{
|
||||
CHECK_NULL_VOID(option);
|
||||
CHECK_NULL_VOID(value);
|
||||
option->iCurve = value;
|
||||
}
|
||||
|
||||
ArkUI_CurveHandle OH_ArkUI_AnimateOption_GetICurve(ArkUI_AnimateOption* option)
|
||||
{
|
||||
CHECK_NULL_RETURN(option, nullptr);
|
||||
return option->iCurve;
|
||||
}
|
||||
|
||||
ArkUI_KeyframeAnimateOption* OH_ArkUI_KeyframeAnimateOption_Create(int32_t size)
|
||||
{
|
||||
ArkUI_KeyframeAnimateOption* animateOption = new ArkUI_KeyframeAnimateOption;
|
||||
animateOption->keyframes.resize(size);
|
||||
animateOption->delay = 0;
|
||||
animateOption->iterations = 1;
|
||||
animateOption->onFinish = nullptr;
|
||||
animateOption->userData = nullptr;
|
||||
|
||||
for (int32_t i = 0; i < size; ++i) {
|
||||
//duration default 1000
|
||||
animateOption->keyframes[i].duration = 1000;
|
||||
animateOption->keyframes[i].curve = nullptr;
|
||||
animateOption->keyframes[i].event = nullptr;
|
||||
animateOption->keyframes[i].userData = nullptr;
|
||||
}
|
||||
return animateOption;
|
||||
}
|
||||
|
||||
void OH_ArkUI_KeyframeAnimateOption_Dispose(ArkUI_KeyframeAnimateOption* option)
|
||||
{
|
||||
CHECK_NULL_VOID(option);
|
||||
delete option;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_KeyframeAnimateOption_SetDelay(ArkUI_KeyframeAnimateOption* option, int32_t value)
|
||||
{
|
||||
CHECK_NULL_RETURN(option, OHOS::Ace::ERROR_CODE_PARAM_INVALID);
|
||||
option->delay = value;
|
||||
return OHOS::Ace::ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_KeyframeAnimateOption_SetIterations(ArkUI_KeyframeAnimateOption* option, int32_t value)
|
||||
{
|
||||
CHECK_NULL_RETURN(option, OHOS::Ace::ERROR_CODE_PARAM_INVALID);
|
||||
//取值范围:[-1, +∞)
|
||||
if (value < -1) {
|
||||
return OHOS::Ace::ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
option->iterations = value;
|
||||
return OHOS::Ace::ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_KeyframeAnimateOption_RegisterOnFinishCallback(
|
||||
ArkUI_KeyframeAnimateOption* option, void* userData, void (*onFinish)(void* userData))
|
||||
{
|
||||
CHECK_NULL_RETURN(option, OHOS::Ace::ERROR_CODE_PARAM_INVALID);
|
||||
option->onFinish = onFinish;
|
||||
option->userData = userData;
|
||||
return OHOS::Ace::ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_KeyframeAnimateOption_SetDuration(ArkUI_KeyframeAnimateOption* option, int32_t value, int32_t index)
|
||||
{
|
||||
if (option == nullptr || index < 0 || index >= static_cast<int32_t>(option->keyframes.size())) {
|
||||
return OHOS::Ace::ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
if (value < 0) {
|
||||
value = 0;
|
||||
}
|
||||
option->keyframes[index].duration = value;
|
||||
return OHOS::Ace::ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_KeyframeAnimateOption_SetCurve(
|
||||
ArkUI_KeyframeAnimateOption* option, ArkUI_CurveHandle value, int32_t index)
|
||||
{
|
||||
if (option == nullptr || index < 0 || index >= static_cast<int32_t>(option->keyframes.size())) {
|
||||
return OHOS::Ace::ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
if (!value || !value->curve) {
|
||||
option->keyframes[index].curve = nullptr;
|
||||
return OHOS::Ace::ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
if (value->type == ARKUI_CURVE_TYPE_SPRING_MOTION || value->type == ARKUI_CURVE_TYPE_RESPONSIVE_SPRING_MOTION ||
|
||||
value->type == ARKUI_CURVE_TYPE_INTERPOLATING_SPRING) {
|
||||
return OHOS::Ace::ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
option->keyframes[index].curve = value;
|
||||
return OHOS::Ace::ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_KeyframeAnimateOption_RegisterOnEventCallback(
|
||||
ArkUI_KeyframeAnimateOption* option, void* userData, void (*event)(void* userData), int32_t index)
|
||||
{
|
||||
if (option == nullptr || index < 0 || index >= static_cast<int32_t>(option->keyframes.size())) {
|
||||
return OHOS::Ace::ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
option->keyframes[index].event = event;
|
||||
option->keyframes[index].userData = userData;
|
||||
return OHOS::Ace::ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_KeyframeAnimateOption_GetDelay(ArkUI_KeyframeAnimateOption* option)
|
||||
{
|
||||
CHECK_NULL_RETURN(option, 0);
|
||||
return option->delay;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_KeyframeAnimateOption_GetIterations(ArkUI_KeyframeAnimateOption* option)
|
||||
{
|
||||
CHECK_NULL_RETURN(option, 1);
|
||||
return option->iterations;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_KeyframeAnimateOption_GetDuration(ArkUI_KeyframeAnimateOption* option, int32_t index)
|
||||
{
|
||||
if (option == nullptr || index < 0 || index >= static_cast<int32_t>(option->keyframes.size())) {
|
||||
return 0;
|
||||
}
|
||||
return option->keyframes[index].duration;
|
||||
}
|
||||
|
||||
ArkUI_CurveHandle OH_ArkUI_KeyframeAnimateOption_GetCurve(ArkUI_KeyframeAnimateOption* option, int32_t index)
|
||||
{
|
||||
if (option == nullptr || index < 0 || index >= static_cast<int32_t>(option->keyframes.size())) {
|
||||
return nullptr;
|
||||
}
|
||||
return option->keyframes[index].curve;
|
||||
}
|
||||
|
||||
ArkUI_AnimatorOption* OH_ArkUI_AnimatorOption_Create(int32_t keyframeSize)
|
||||
{
|
||||
ArkUI_AnimatorOption* option = new ArkUI_AnimatorOption;
|
||||
option->keyframes.resize(keyframeSize);
|
||||
for (int32_t i = 0; i < keyframeSize; i++) {
|
||||
option->keyframes[i].curve = nullptr;
|
||||
}
|
||||
option->duration = 0;
|
||||
option->delay = 0;
|
||||
option->iterations = 1;
|
||||
option->fill = ARKUI_ANIMATION_FILL_MODE_FORWARDS;
|
||||
option->direction = ARKUI_ANIMATION_DIRECTION_NORMAL;
|
||||
option->begin = 0.0f;
|
||||
option->end = 1.0f;
|
||||
option->onFrame = nullptr;
|
||||
option->frameUserData = nullptr;
|
||||
option->onFinish = nullptr;
|
||||
option->finishUserData = nullptr;
|
||||
option->onCancel = nullptr;
|
||||
option->cancelUserData = nullptr;
|
||||
option->onRepeat = nullptr;
|
||||
option->repeatUserData = nullptr;
|
||||
option->expectedFrameRateRange = nullptr;
|
||||
return option;
|
||||
}
|
||||
|
||||
void OH_ArkUI_ArkUI_AnimatorOption_Dispose(ArkUI_AnimatorOption* option)
|
||||
{
|
||||
CHECK_NULL_VOID(option);
|
||||
if (option->expectedFrameRateRange) {
|
||||
delete option->expectedFrameRateRange;
|
||||
}
|
||||
delete option;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_AnimatorOption_SetDuration(ArkUI_AnimatorOption* option, int32_t value)
|
||||
{
|
||||
CHECK_NULL_RETURN(option, OHOS::Ace::ERROR_CODE_PARAM_INVALID);
|
||||
if (value < 0) {
|
||||
return OHOS::Ace::ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
option->duration = value;
|
||||
return OHOS::Ace::ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_AnimatorOption_SetDelay(ArkUI_AnimatorOption* option, int32_t value)
|
||||
{
|
||||
CHECK_NULL_RETURN(option, OHOS::Ace::ERROR_CODE_PARAM_INVALID);
|
||||
option->delay = value;
|
||||
return OHOS::Ace::ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_AnimatorOption_SetIterations(ArkUI_AnimatorOption* option, int32_t value)
|
||||
{
|
||||
CHECK_NULL_RETURN(option, OHOS::Ace::ERROR_CODE_PARAM_INVALID);
|
||||
if (value < -1) {
|
||||
value = 1;
|
||||
}
|
||||
option->iterations = value;
|
||||
return OHOS::Ace::ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_AnimatorOption_SetFill(ArkUI_AnimatorOption* option, ArkUI_AnimationFillMode value)
|
||||
{
|
||||
CHECK_NULL_RETURN(option, OHOS::Ace::ERROR_CODE_PARAM_INVALID);
|
||||
if (value > ARKUI_ANIMATION_FILL_MODE_BOTH || value < ARKUI_ANIMATION_FILL_MODE_NONE) {
|
||||
return OHOS::Ace::ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
option->fill = value;
|
||||
return OHOS::Ace::ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_AnimatorOption_SetDirection(ArkUI_AnimatorOption* option, ArkUI_AnimationDirection value)
|
||||
{
|
||||
CHECK_NULL_RETURN(option, OHOS::Ace::ERROR_CODE_PARAM_INVALID);
|
||||
if (value > ARKUI_ANIMATION_DIRECTION_ALTERNATE_REVERSE || value < ARKUI_ANIMATION_DIRECTION_NORMAL) {
|
||||
return OHOS::Ace::ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
option->direction = value;
|
||||
return OHOS::Ace::ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_AnimatorOption_SetCurve(ArkUI_AnimatorOption* option, ArkUI_CurveHandle value)
|
||||
{
|
||||
CHECK_NULL_RETURN(option, OHOS::Ace::ERROR_CODE_PARAM_INVALID);
|
||||
if (value) {
|
||||
if (value->type == ARKUI_CURVE_TYPE_SPRING || value->type == ARKUI_CURVE_TYPE_SPRING_MOTION ||
|
||||
value->type == ARKUI_CURVE_TYPE_RESPONSIVE_SPRING_MOTION ||
|
||||
value->type == ARKUI_CURVE_TYPE_INTERPOLATING_SPRING || value->type == ARKUI_CURVE_TYPE_CUSTOM) {
|
||||
option->easing = nullptr;
|
||||
return OHOS::Ace::ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
option->easing = value;
|
||||
return OHOS::Ace::ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_AnimatorOption_SetBegin(ArkUI_AnimatorOption* option, float value)
|
||||
{
|
||||
CHECK_NULL_RETURN(option, OHOS::Ace::ERROR_CODE_PARAM_INVALID);
|
||||
if (option->keyframes.size() > 0) {
|
||||
return OHOS::Ace::ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
option->begin = value;
|
||||
return OHOS::Ace::ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_AnimatorOption_SetEnd(ArkUI_AnimatorOption* option, float value)
|
||||
{
|
||||
CHECK_NULL_RETURN(option, OHOS::Ace::ERROR_CODE_PARAM_INVALID);
|
||||
if (option->keyframes.size() > 0) {
|
||||
return OHOS::Ace::ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
option->end = value;
|
||||
return OHOS::Ace::ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_AnimatorOption_SetExpectedFrameRateRange(
|
||||
ArkUI_AnimatorOption* option, ArkUI_ExpectedFrameRateRange* value)
|
||||
{
|
||||
CHECK_NULL_RETURN(option, OHOS::Ace::ERROR_CODE_PARAM_INVALID);
|
||||
CHECK_NULL_RETURN(value, OHOS::Ace::ERROR_CODE_PARAM_INVALID);
|
||||
option->expectedFrameRateRange = new ArkUI_ExpectedFrameRateRange { value->min, value->max, value->expected };
|
||||
return OHOS::Ace::ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_AnimatorOption_SetKeyframe(ArkUI_AnimatorOption* option, float time, float value, int32_t index)
|
||||
{
|
||||
CHECK_NULL_RETURN(option, OHOS::Ace::ERROR_CODE_PARAM_INVALID);
|
||||
if (time < 0 || time > 1) {
|
||||
return OHOS::Ace::ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
if (index >= 0 && index < option->keyframes.size()) {
|
||||
option->keyframes[index].keyTime = time;
|
||||
option->keyframes[index].keyValue = value;
|
||||
return OHOS::Ace::ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
return OHOS::Ace::ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_AnimatorOption_SetKeyframeCurve(ArkUI_AnimatorOption* option, ArkUI_CurveHandle value, int32_t index)
|
||||
{
|
||||
CHECK_NULL_RETURN(option, OHOS::Ace::ERROR_CODE_PARAM_INVALID);
|
||||
if (value) {
|
||||
if (value->type == ARKUI_CURVE_TYPE_SPRING || value->type == ARKUI_CURVE_TYPE_SPRING_MOTION ||
|
||||
value->type == ARKUI_CURVE_TYPE_RESPONSIVE_SPRING_MOTION ||
|
||||
value->type == ARKUI_CURVE_TYPE_INTERPOLATING_SPRING || value->type == ARKUI_CURVE_TYPE_CUSTOM) {
|
||||
option->keyframes[index].curve = nullptr;
|
||||
return OHOS::Ace::ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
if (index >= 0 && index < option->keyframes.size()) {
|
||||
option->keyframes[index].curve = value;
|
||||
return OHOS::Ace::ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
return OHOS::Ace::ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_AnimatorOption_GetDuration(ArkUI_AnimatorOption* option)
|
||||
{
|
||||
if (option != nullptr) {
|
||||
return option->duration;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_AnimatorOption_GetDelay(ArkUI_AnimatorOption* option)
|
||||
{
|
||||
if (option != nullptr) {
|
||||
return option->delay;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_AnimatorOption_GetIterations(ArkUI_AnimatorOption* option)
|
||||
{
|
||||
if (option != nullptr) {
|
||||
return option->iterations;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
ArkUI_AnimationFillMode OH_ArkUI_AnimatorOption_GetFill(ArkUI_AnimatorOption* option)
|
||||
{
|
||||
if (option != nullptr) {
|
||||
return option->fill;
|
||||
}
|
||||
return static_cast<ArkUI_AnimationFillMode>(-1);
|
||||
}
|
||||
|
||||
ArkUI_AnimationDirection OH_ArkUI_AnimatorOption_GetDirection(ArkUI_AnimatorOption* option)
|
||||
{
|
||||
if (option != nullptr) {
|
||||
return option->direction;
|
||||
}
|
||||
return static_cast<ArkUI_AnimationDirection>(-1);
|
||||
}
|
||||
|
||||
ArkUI_CurveHandle OH_ArkUI_AnimatorOption_GetCurve(ArkUI_AnimatorOption* option)
|
||||
{
|
||||
if (option != nullptr) {
|
||||
return option->easing;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
float OH_ArkUI_AnimatorOption_GetBegin(ArkUI_AnimatorOption* option)
|
||||
{
|
||||
if (option != nullptr) {
|
||||
return option->begin;
|
||||
}
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
float OH_ArkUI_AnimatorOption_GetEnd(ArkUI_AnimatorOption* option)
|
||||
{
|
||||
if (option != nullptr) {
|
||||
return option->end;
|
||||
}
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
ArkUI_ExpectedFrameRateRange* OH_ArkUI_AnimatorOption_GetExpectedFrameRateRange(ArkUI_AnimatorOption* option)
|
||||
{
|
||||
if (option != nullptr) {
|
||||
return option->expectedFrameRateRange;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
float OH_ArkUI_AnimatorOption_GetKeyframeTime(ArkUI_AnimatorOption* option, int32_t index)
|
||||
{
|
||||
if (option != nullptr && index >= 0 && index < option->keyframes.size()) {
|
||||
return option->keyframes[index].keyTime;
|
||||
}
|
||||
return -1.0f;
|
||||
}
|
||||
|
||||
float OH_ArkUI_AnimatorOption_GetKeyframeValue(ArkUI_AnimatorOption* option, int32_t index)
|
||||
{
|
||||
if (option != nullptr && index >= 0 && index < option->keyframes.size()) {
|
||||
return option->keyframes[index].keyValue;
|
||||
}
|
||||
return -1.0f;
|
||||
}
|
||||
|
||||
ArkUI_CurveHandle OH_ArkUI_AnimatorOption_GetKeyframeCurve(ArkUI_AnimatorOption* option, int32_t index)
|
||||
{
|
||||
if (option != nullptr && index >= 0 && index < option->keyframes.size()) {
|
||||
return option->keyframes[index].curve;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void* OH_ArkUI_AnimatorEvent_GetUserData(ArkUI_AnimatorEvent* event)
|
||||
{
|
||||
CHECK_NULL_RETURN(event, nullptr);
|
||||
return event->userData;
|
||||
}
|
||||
|
||||
void* OH_ArkUI_AnimatorOnFrameEvent_GetUserData(ArkUI_AnimatorOnFrameEvent* event)
|
||||
{
|
||||
CHECK_NULL_RETURN(event, nullptr);
|
||||
return event->userData;
|
||||
}
|
||||
|
||||
float OH_ArkUI_AnimatorOnFrameEvent_GetValue(ArkUI_AnimatorOnFrameEvent* event)
|
||||
{
|
||||
CHECK_NULL_RETURN(event, 0.0f);
|
||||
return event->progress;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_AnimatorOption_RegisterOnFrameCallback(
|
||||
ArkUI_AnimatorOption* option, void* userData, void (*callback)(ArkUI_AnimatorOnFrameEvent* event))
|
||||
{
|
||||
auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
|
||||
if (!impl || !option || !callback) {
|
||||
return OHOS::Ace::ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
option->onFrame = callback;
|
||||
option->frameUserData = userData;
|
||||
return OHOS::Ace::ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_AnimatorOption_RegisterOnFinishCallback(
|
||||
ArkUI_AnimatorOption* option, void* userData, void (*callback)(ArkUI_AnimatorEvent* event))
|
||||
{
|
||||
auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
|
||||
if (!impl || !option || !callback) {
|
||||
return OHOS::Ace::ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
|
||||
option->onFinish = callback;
|
||||
option->finishUserData = userData;
|
||||
return OHOS::Ace::ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_AnimatorOption_RegisterOnCancelCallback(
|
||||
ArkUI_AnimatorOption* option, void* userData, void (*callback)(ArkUI_AnimatorEvent* event))
|
||||
{
|
||||
auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
|
||||
if (!impl || !option || !callback) {
|
||||
return OHOS::Ace::ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
|
||||
option->onCancel = callback;
|
||||
option->cancelUserData = userData;
|
||||
return OHOS::Ace::ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_AnimatorOption_RegisterOnRepeatCallback(
|
||||
ArkUI_AnimatorOption* option, void* userData, void (*callback)(ArkUI_AnimatorEvent* event))
|
||||
{
|
||||
auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
|
||||
if (!impl || !option || !callback) {
|
||||
return OHOS::Ace::ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
|
||||
option->onRepeat = callback;
|
||||
option->repeatUserData = userData;
|
||||
return OHOS::Ace::ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_Animator_ResetAnimatorOption(ArkUI_AnimatorHandle animator, ArkUI_AnimatorOption* option)
|
||||
{
|
||||
return OHOS::Ace::AnimateModel::AnimatorReset(animator, option);
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_Animator_Play(ArkUI_AnimatorHandle animator)
|
||||
{
|
||||
return OHOS::Ace::AnimateModel::AnimatorPlay(animator);
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_Animator_Finish(ArkUI_AnimatorHandle animator)
|
||||
{
|
||||
return OHOS::Ace::AnimateModel::AnimatorFinish(animator);
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_Animator_Pause(ArkUI_AnimatorHandle animator)
|
||||
{
|
||||
return OHOS::Ace::AnimateModel::AnimatorPause(animator);
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_Animator_Cancel(ArkUI_AnimatorHandle animator)
|
||||
{
|
||||
return OHOS::Ace::AnimateModel::AnimatorCancel(animator);
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_Animator_Reverse(ArkUI_AnimatorHandle animator)
|
||||
{
|
||||
return OHOS::Ace::AnimateModel::AnimatorReverse(animator);
|
||||
}
|
||||
|
||||
ArkUI_CurveHandle OH_ArkUI_Curve_InitCurve(ArkUI_AnimationCurve curve)
|
||||
{
|
||||
return OHOS::Ace::AnimateModel::InitCurve(curve);
|
||||
}
|
||||
|
||||
ArkUI_CurveHandle OH_ArkUI_Curve_StepsCurve(int32_t count, bool end)
|
||||
{
|
||||
return OHOS::Ace::AnimateModel::StepsCurve(count, end);
|
||||
}
|
||||
|
||||
ArkUI_CurveHandle OH_ArkUI_Curve_CubicBezierCurve(float x1, float y1, float x2, float y2)
|
||||
{
|
||||
return OHOS::Ace::AnimateModel::CubicBezierCurve(x1, y1, x2, y2);
|
||||
}
|
||||
|
||||
ArkUI_CurveHandle OH_ArkUI_Curve_SpringCurve(float velocity, float mass, float stiffness, float damping)
|
||||
{
|
||||
return OHOS::Ace::AnimateModel::SpringCurve(velocity, mass, stiffness, damping);
|
||||
}
|
||||
|
||||
ArkUI_CurveHandle OH_ArkUI_Curve_SpringMotion(float response, float dampingFraction, float overlapDuration)
|
||||
{
|
||||
return OHOS::Ace::AnimateModel::SpringMotion(response, dampingFraction, overlapDuration);
|
||||
}
|
||||
|
||||
ArkUI_CurveHandle OH_ArkUI_Curve_ResponsiveSpringMotion(float response, float dampingFraction, float overlapDuration)
|
||||
{
|
||||
return OHOS::Ace::AnimateModel::ResponsiveSpringMotion(response, dampingFraction, overlapDuration);
|
||||
}
|
||||
|
||||
ArkUI_CurveHandle OH_ArkUI_Curve_InterpolatingSpring(float velocity, float mass, float stiffness, float damping)
|
||||
{
|
||||
return OHOS::Ace::AnimateModel::InterpolatingSpring(velocity, mass, stiffness, damping);
|
||||
}
|
||||
|
||||
ArkUI_CurveHandle OH_ArkUI_Curve_CustomCurve(void* userData, float (*interpolate)(float fraction, void* userdata))
|
||||
{
|
||||
return OHOS::Ace::AnimateModel::CustomCurve(userData, interpolate);
|
||||
}
|
||||
|
||||
void OH_ArkUI_Curve_disposeCurve(ArkUI_CurveHandle curveHandle)
|
||||
{
|
||||
return OHOS::Ace::AnimateModel::DisposeCurve(curveHandle);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
@ -443,4 +443,12 @@ ArkUI_NodeHandle GetParent(ArkUI_NodeHandle node)
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int32_t RemoveAllChildren(ArkUI_NodeHandle parentNode)
|
||||
{
|
||||
CHECK_NULL_RETURN(parentNode, ERROR_CODE_PARAM_INVALID);
|
||||
auto* impl = GetFullImpl();
|
||||
impl->getNodeModifiers()->getFrameNodeModifier()->clearChildren(parentNode->uiNodeHandle);
|
||||
return ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
} // namespace OHOS::Ace::NodeModel
|
||||
|
@ -171,4 +171,5 @@ ArkUI_NodeHandle GetLastChild(ArkUI_NodeHandle node);
|
||||
ArkUI_NodeHandle GetPreviousSibling(ArkUI_NodeHandle node);
|
||||
ArkUI_NodeHandle GetNextSibling(ArkUI_NodeHandle node);
|
||||
ArkUI_NodeHandle GetParent(ArkUI_NodeHandle node);
|
||||
int32_t RemoveAllChildren(ArkUI_NodeHandle parentNode);
|
||||
} // namespace OHOS::Ace::NodeModel
|
Loading…
Reference in New Issue
Block a user