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()24AnimationState::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)34bool ParallelAnimation::Build(const IMetadata::Ptr& data) 35 { 36 if (Super::Build(data)) { 37 if (auto changed = GetState().OnChildrenChanged()) { 38 changed->AddHandler(MakeCallback<IOnChanged>(this, &ParallelAnimation::ChildrenChanged)); 39 } 40 return true; 41 } 42 return false; 43 } 44 Evaluate()45void ParallelAnimation::Evaluate() 46 { 47 if (GetState().Evaluate() == AnyReturn::SUCCESS) { 48 NotifyChanged(); 49 } 50 } 51 ChildrenChanged()52void ParallelAnimation::ChildrenChanged() 53 { 54 SetValue(META_ACCESS_PROPERTY(Valid), GetState().IsValid()); 55 NotifyChanged(); 56 } 57 58 } // namespace Internal 59 60 META_END_NAMESPACE() 61