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 "parallel_animation.h"
17 
18 #include <meta/api/util.h>
19 
20 META_BEGIN_NAMESPACE()
21 
22 namespace Internal {
23 
GetParams()24 AnimationState::AnimationStateParams ParallelAnimation::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 ParallelAnimation::Build(const IMetadata::Ptr& data)
35 {
36     if (Super::Build(data)) {
37         GetState().OnChildrenChanged()->AddHandler(MakeCallback<IOnChanged>(this, &ParallelAnimation::ChildrenChanged));
38         return true;
39     }
40     return false;
41 }
42 
Evaluate()43 void ParallelAnimation::Evaluate()
44 {
45     if (GetState().Evaluate() == AnyReturn::SUCCESS) {
46         NotifyChanged();
47     }
48 }
49 
ChildrenChanged()50 void ParallelAnimation::ChildrenChanged()
51 {
52     SetValue(META_ACCESS_PROPERTY(Valid), GetState().IsValid());
53     NotifyChanged();
54 }
55 
56 } // namespace Internal
57 
58 META_END_NAMESPACE()
59