1 /* 2 * Copyright (c) 2022 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_TEXT_PICKER_TOSS_ANIMATION_CONTROLLER_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_TEXT_PICKER_TOSS_ANIMATION_CONTROLLER_H 18 19 #include "core/components/picker/picker_animation.h" 20 #include "core/components_ng/base/frame_node.h" 21 #include "core/pipeline_ng/pipeline_context.h" 22 #include "frameworks/base/memory/ace_type.h" 23 24 namespace OHOS::Ace::NG { 25 class TextPickerColumnPattern; 26 27 class TextPickerTossAnimationController : public virtual AceType { 28 DECLARE_ACE_TYPE(TextPickerTossAnimationController, AceType); 29 30 public: 31 TextPickerTossAnimationController() = default; 32 ~TextPickerTossAnimationController() = default; 33 SetColumn(const WeakPtr<TextPickerColumnPattern> & value)34 void SetColumn(const WeakPtr<TextPickerColumnPattern>& value) 35 { 36 column_ = value; 37 } 38 SetPipelineContext(const WeakPtr<PipelineContext> & pipeline)39 void SetPipelineContext(const WeakPtr<PipelineContext>& pipeline) 40 { 41 pipeline_ = pipeline; 42 } 43 44 void SetStart(double y); 45 46 void SetEnd(double y); 47 48 bool Play(); 49 50 private: 51 double GetCurrentTime() const; 52 53 double yStart_ = 0.0; 54 double yEnd_ = 0.0; 55 double timeStart_ = 0.0; 56 double timeEnd_ = 0.0; 57 double speed_ = 0.0; 58 59 RefPtr<PickerAnimation> toss_; 60 WeakPtr<TextPickerColumnPattern> column_; 61 WeakPtr<PipelineContext> pipeline_; 62 63 ACE_DISALLOW_COPY_AND_MOVE(TextPickerTossAnimationController); 64 }; 65 } // namespace OHOS::Ace::NG 66 67 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_TEXT_PICKER_TOSS_ANIMATION_CONTROLLER_H 68