123b3eb3cSopenharmony_ci/* 223b3eb3cSopenharmony_ci * Copyright (c) 2021 Huawei Device Co., Ltd. 323b3eb3cSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 423b3eb3cSopenharmony_ci * you may not use this file except in compliance with the License. 523b3eb3cSopenharmony_ci * You may obtain a copy of the License at 623b3eb3cSopenharmony_ci * 723b3eb3cSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 823b3eb3cSopenharmony_ci * 923b3eb3cSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1023b3eb3cSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1123b3eb3cSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1223b3eb3cSopenharmony_ci * See the License for the specific language governing permissions and 1323b3eb3cSopenharmony_ci * limitations under the License. 1423b3eb3cSopenharmony_ci */ 1523b3eb3cSopenharmony_ci 1623b3eb3cSopenharmony_ci#ifndef FOUNDATION_ACE_FRAMEWORKS_BASE_GEOMETRY_ANIMATABLE_MATRIX4_H 1723b3eb3cSopenharmony_ci#define FOUNDATION_ACE_FRAMEWORKS_BASE_GEOMETRY_ANIMATABLE_MATRIX4_H 1823b3eb3cSopenharmony_ci 1923b3eb3cSopenharmony_ci#include "base/geometry/matrix4.h" 2023b3eb3cSopenharmony_ci#include "core/animation/animator.h" 2123b3eb3cSopenharmony_ci#include "core/animation/curve_animation.h" 2223b3eb3cSopenharmony_ci#include "core/components/common/properties/animation_option.h" 2323b3eb3cSopenharmony_ci 2423b3eb3cSopenharmony_cinamespace OHOS::Ace { 2523b3eb3cSopenharmony_ci 2623b3eb3cSopenharmony_ciusing RenderNodeAnimationCallback = std::function<void()>; 2723b3eb3cSopenharmony_ci 2823b3eb3cSopenharmony_ciclass ACE_EXPORT AnimatableMatrix4 : public Matrix4 { 2923b3eb3cSopenharmony_cipublic: 3023b3eb3cSopenharmony_ci AnimatableMatrix4() = default; 3123b3eb3cSopenharmony_ci ~AnimatableMatrix4() = default; 3223b3eb3cSopenharmony_ci 3323b3eb3cSopenharmony_ci explicit AnimatableMatrix4(Matrix4 matrix4, const AnimationOption& option = AnimationOption()) 3423b3eb3cSopenharmony_ci : Matrix4(matrix4), animationOption_(option) 3523b3eb3cSopenharmony_ci {} 3623b3eb3cSopenharmony_ci 3723b3eb3cSopenharmony_ci void SetContextAndCallback(const WeakPtr<PipelineBase>& context, const RenderNodeAnimationCallback& callback) 3823b3eb3cSopenharmony_ci { 3923b3eb3cSopenharmony_ci context_ = context; 4023b3eb3cSopenharmony_ci animationCallback_ = callback; 4123b3eb3cSopenharmony_ci } 4223b3eb3cSopenharmony_ci 4323b3eb3cSopenharmony_ci const AnimationOption& GetAnimationOption() const 4423b3eb3cSopenharmony_ci { 4523b3eb3cSopenharmony_ci return animationOption_; 4623b3eb3cSopenharmony_ci } 4723b3eb3cSopenharmony_ci 4823b3eb3cSopenharmony_ci void SetAnimationOption(const AnimationOption& option) 4923b3eb3cSopenharmony_ci { 5023b3eb3cSopenharmony_ci animationOption_ = option; 5123b3eb3cSopenharmony_ci } 5223b3eb3cSopenharmony_ci 5323b3eb3cSopenharmony_ci void SetAnimationStopCallback(const RenderNodeAnimationCallback& callback) 5423b3eb3cSopenharmony_ci { 5523b3eb3cSopenharmony_ci stopCallback_ = callback; 5623b3eb3cSopenharmony_ci } 5723b3eb3cSopenharmony_ci 5823b3eb3cSopenharmony_ci Animator::Status GetAnimationStatus() const 5923b3eb3cSopenharmony_ci { 6023b3eb3cSopenharmony_ci if (!animationController_) { 6123b3eb3cSopenharmony_ci return Animator::Status::IDLE; 6223b3eb3cSopenharmony_ci } 6323b3eb3cSopenharmony_ci return animationController_->GetStatus(); 6423b3eb3cSopenharmony_ci } 6523b3eb3cSopenharmony_ci 6623b3eb3cSopenharmony_ci AnimatableMatrix4& operator=(const Matrix4& matrix4); 6723b3eb3cSopenharmony_ci 6823b3eb3cSopenharmony_ci AnimatableMatrix4& operator=(const AnimatableMatrix4& newMatrix4); 6923b3eb3cSopenharmony_ci 7023b3eb3cSopenharmony_ci void MoveTo(const Matrix4& target); 7123b3eb3cSopenharmony_ci 7223b3eb3cSopenharmony_ci void SetEvaluator(const RefPtr<Evaluator<TransformOperation>>& evaluator) 7323b3eb3cSopenharmony_ci { 7423b3eb3cSopenharmony_ci evaluator_ = evaluator; 7523b3eb3cSopenharmony_ci } 7623b3eb3cSopenharmony_ci 7723b3eb3cSopenharmony_ciprivate: 7823b3eb3cSopenharmony_ci void AnimateTo(const Matrix4& endValue); 7923b3eb3cSopenharmony_ci void ResetController(); 8023b3eb3cSopenharmony_ci void OnAnimationCallback(const TransformOperation& value); 8123b3eb3cSopenharmony_ci void ResetAnimatableMatrix(); 8223b3eb3cSopenharmony_ci 8323b3eb3cSopenharmony_ciprivate: 8423b3eb3cSopenharmony_ci bool isFirstAssign_ = true; 8523b3eb3cSopenharmony_ci AnimationOption animationOption_; 8623b3eb3cSopenharmony_ci RefPtr<Animator> animationController_; 8723b3eb3cSopenharmony_ci WeakPtr<PipelineBase> context_; 8823b3eb3cSopenharmony_ci RenderNodeAnimationCallback animationCallback_; 8923b3eb3cSopenharmony_ci RenderNodeAnimationCallback stopCallback_; 9023b3eb3cSopenharmony_ci 9123b3eb3cSopenharmony_ci RefPtr<Evaluator<TransformOperation>> evaluator_; 9223b3eb3cSopenharmony_ci}; 9323b3eb3cSopenharmony_ci 9423b3eb3cSopenharmony_ci} // namespace OHOS::Ace 9523b3eb3cSopenharmony_ci 9623b3eb3cSopenharmony_ci#endif // FOUNDATION_ACE_FRAMEWORKS_BASE_GEOMETRY_ANIMATABLE_MATRIX4_H 97