1 /* 2 * Copyright (c) 2025 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 FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_PICKER_UTILS_TOSS_ANIMATION_CONTROLLER_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_PICKER_UTILS_TOSS_ANIMATION_CONTROLLER_H 18 19 #include "core/components/picker/picker_animation.h" 20 #include "core/pipeline_ng/pipeline_context.h" 21 #include "frameworks/base/memory/ace_type.h" 22 23 namespace OHOS::Ace::NG { 24 class PickerColumnPattern; 25 class TossAnimationController : public virtual AceType { 26 DECLARE_ACE_TYPE(TossAnimationController, AceType); 27 28 public: 29 TossAnimationController() = default; 30 ~TossAnimationController() = default; 31 SetColumn(const WeakPtr<PickerColumnPattern> & value)32 void SetColumn(const WeakPtr<PickerColumnPattern>& value) 33 { 34 column_ = value; 35 } 36 SetPipelineContext(const WeakPtr<PipelineContext> & pipeline)37 void SetPipelineContext(const WeakPtr<PipelineContext>& pipeline) 38 { 39 pipeline_ = pipeline; 40 } 41 42 void SetStart(double y); 43 44 void SetEnd(double y); 45 46 bool Play(); 47 GetTossNodeAnimation()48 RefPtr<NodeAnimatablePropertyFloat> GetTossNodeAnimation() 49 { 50 return property_; 51 } 52 53 void StartSpringMotion(); 54 55 RefPtr<Curve> UpdatePlayAnimationValue(); 56 57 void StopTossAnimation(); 58 GetTossEndPosition()59 double GetTossEndPosition() 60 { 61 return end_; 62 } 63 64 private: 65 double GetCurrentTime() const; 66 void CreatePropertyCallback(); 67 68 double yStart_ = 0.0; 69 double yEnd_ = 0.0; 70 double timeStart_ = 0.0; 71 double timeEnd_ = 0.0; 72 double speed_ = 0.0; 73 int32_t showCount_ = 0; 74 double end_ = 0.0; 75 WeakPtr<PickerColumnPattern> column_; 76 WeakPtr<PipelineContext> pipeline_; 77 78 RefPtr<NodeAnimatablePropertyFloat> property_; 79 80 ACE_DISALLOW_COPY_AND_MOVE(TossAnimationController); 81 }; 82 } // namespace OHOS::Ace::NG 83 84 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_PICKER_UTILS_TOSS_ANIMATION_CONTROLLER_H 85