1 /* 2 * Copyright (c) 2021 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 "core/components/tween/tween_component.h" 17 18 namespace OHOS::Ace { 19 namespace { 20 21 const char* PREFIX = "BackendTween"; 22 uint32_t g_tweenComponentId = 0; 23 24 } // namespace 25 SetTweenOption(const TweenOption & option)26void TweenComponent::SetTweenOption(const TweenOption& option) 27 { 28 SetOptionCssChanged(true); 29 optionCss_ = std::move(option); 30 } 31 GetTweenOption() const32const TweenOption& TweenComponent::GetTweenOption() const 33 { 34 return optionCss_; 35 } 36 SetCustomTweenOption(const TweenOption & option)37void TweenComponent::SetCustomTweenOption(const TweenOption& option) 38 { 39 SetOptionCustomChanged(true); 40 optionCustom_ = std::move(option); 41 } 42 GetCustomTweenOption() const43const TweenOption& TweenComponent::GetCustomTweenOption() const 44 { 45 return optionCustom_; 46 } 47 SetAnimationOperation(const AnimationOperation & operation)48void TweenComponent::SetAnimationOperation(const AnimationOperation& operation) 49 { 50 SetOperationCssChanged(true); 51 operationCss_ = operation; 52 } 53 GetAnimationOperation() const54const AnimationOperation& TweenComponent::GetAnimationOperation() const 55 { 56 return operationCss_; 57 } 58 SetCustomAnimationOperation(const AnimationOperation & operation)59void TweenComponent::SetCustomAnimationOperation(const AnimationOperation& operation) 60 { 61 SetOperationCustomChanged(true); 62 operationCustom_ = operation; 63 } 64 GetCustomAnimationOperation() const65const AnimationOperation& TweenComponent::GetCustomAnimationOperation() const 66 { 67 return operationCustom_; 68 } 69 CreateElement()70RefPtr<Element> TweenComponent::CreateElement() 71 { 72 return AceType::MakeRefPtr<TweenElement>(GetId()); 73 } 74 AllocTweenComponentId()75ComposeId TweenComponent::AllocTweenComponentId() 76 { 77 return PREFIX + (std::to_string(g_tweenComponentId++)); 78 } 79 SetIsFirstFrameShow(bool isFirstFrameShow)80void TweenComponent::SetIsFirstFrameShow(bool isFirstFrameShow) 81 { 82 isFirstFrameShow_ = isFirstFrameShow; 83 } 84 GetIsFirstFrameShow() const85bool TweenComponent::GetIsFirstFrameShow() const 86 { 87 return isFirstFrameShow_; 88 } 89 SetAnimator(const RefPtr<Animator> & animator)90void TweenComponent::SetAnimator(const RefPtr<Animator>& animator) 91 { 92 animator_ = animator; 93 } 94 GetAnimator() const95RefPtr<Animator> TweenComponent::GetAnimator() const 96 { 97 return animator_; 98 } 99 100 } // namespace OHOS::Ace