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 #include "sequential_animation.h"
17 
18 #include <meta/api/util.h>
19 
20 META_BEGIN_NAMESPACE()
21 
22 namespace Internal {
23 
GetParams()24 AnimationState::AnimationStateParams SequentialAnimation::GetParams()
25 {
26     AnimationState::AnimationStateParams params;
27     params.owner = GetSelf<IAnimation>();
28     params.runningProperty = META_ACCESS_PROPERTY(Running);
29     params.progressProperty = META_ACCESS_PROPERTY(Progress);
30     params.totalDuration = META_ACCESS_PROPERTY(TotalDuration);
31     return params;
32 }
33 
Build(const IMetadata::Ptr & data)34 bool SequentialAnimation::Build(const IMetadata::Ptr& data)
35 {
36     if (Super::Build(data)) {
37         GetState().OnChildrenChanged()->AddHandler(
38             MakeCallback<IOnChanged>(this, &SequentialAnimation::ChildrenChanged));
39         return true;
40     }
41     return false;
42 }
43 
Evaluate()44 void SequentialAnimation::Evaluate()
45 {
46     if (GetState().Evaluate() == AnyReturn::SUCCESS) {
47         NotifyChanged();
48     }
49 }
50 
ChildrenChanged()51 void SequentialAnimation::ChildrenChanged()
52 {
53     SetValue(META_ACCESS_PROPERTY(Valid), GetState().IsValid());
54     NotifyChanged();
55 }
56 
57 } // namespace Internal
58 
59 META_END_NAMESPACE()
60