1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef META_SRC_ANIMATION_KEYFRAME_ANIMATION_H 17 #define META_SRC_ANIMATION_KEYFRAME_ANIMATION_H 18 19 #include "animation.h" 20 21 META_BEGIN_NAMESPACE() 22 23 namespace Internal { 24 25 class KeyframeAnimation final : public PropertyAnimationFwd<KeyframeAnimation, META_NS::ClassId::KeyframeAnimation, 26 IKeyframeAnimation, IStartableAnimation> { 27 using Super = PropertyAnimationFwd<KeyframeAnimation, META_NS::ClassId::KeyframeAnimation, IKeyframeAnimation, 28 IStartableAnimation>; 29 30 public: 31 KeyframeAnimation() = default; 32 ~KeyframeAnimation() override = default; 33 34 protected: // IKeyframeAnimation 35 META_IMPLEMENT_INTERFACE_PROPERTY(IKeyframeAnimation, IAny::Ptr, From); 36 META_IMPLEMENT_INTERFACE_PROPERTY(IKeyframeAnimation, IAny::Ptr, To); 37 38 protected: // IStartableAnimation 39 void Pause() override; 40 void Restart() override; 41 void Seek(float position) override; 42 void Start() override; 43 void Stop() override; 44 void Finish() override; 45 46 public: // IModifier 47 EvaluationResult ProcessOnGet(IAny& value) override; 48 49 protected: // IAnimationInternal 50 void OnAnimationStateChanged(const AnimationStateChangedInfo& info) override; 51 52 private: 53 void Evaluate() override; 54 AnimationState::AnimationStateParams GetParams() override; 55 void OnPropertyChanged(const TargetProperty& property, const IStackProperty::Ptr& previous) override; 56 void Initialize(); 57 IAny::Ptr currentValue_; 58 }; 59 60 } // namespace Internal 61 62 META_END_NAMESPACE() 63 64 #endif // META_SRC_KEYFRAME_ANIMATION_H 65