• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
META_BEGIN_NAMESPACE()21 META_BEGIN_NAMESPACE()
22 
23 namespace Internal {
24 
25 class KeyframeAnimation final
26     : public IntroduceInterfaces<PropertyAnimationFwd<IKeyframeAnimation>, IStartableAnimation> {
27     META_OBJECT(KeyframeAnimation, META_NS::ClassId::KeyframeAnimation, IntroduceInterfaces)
28 public:
29     KeyframeAnimation() = default;
30     ~KeyframeAnimation() override = default;
31 
32     META_BEGIN_STATIC_DATA()
33     META_STATIC_PROPERTY_DATA(IKeyframeAnimation, IAny::Ptr, From)
34     META_STATIC_PROPERTY_DATA(IKeyframeAnimation, IAny::Ptr, To)
35     META_END_STATIC_DATA()
36     META_IMPLEMENT_PROPERTY(IAny::Ptr, From)
37     META_IMPLEMENT_PROPERTY(IAny::Ptr, To)
38 
39 protected: // IStartableAnimation
40     void Pause() override;
41     void Restart() override;
42     void Seek(float position) override;
43     void Start() override;
44     void Stop() override;
45     void Finish() override;
46 
47 public: // IModifier
48     EvaluationResult ProcessOnGet(IAny& value) override;
49 
50 protected: // IAnimationInternal
51     void OnAnimationStateChanged(const AnimationStateChangedInfo& info) override;
52 
53 private:
54     void Evaluate() override;
55     AnimationState::AnimationStateParams GetParams() override;
56     void OnPropertyChanged(const TargetProperty& property, const IStackProperty::Ptr& previous) override;
57     void Initialize();
58     IAny::Ptr currentValue_;
59 };
60 
61 } // namespace Internal
62 
63 META_END_NAMESPACE()
64 
65 #endif // META_SRC_KEYFRAME_ANIMATION_H
66