1 /* 2 * Copyright (c) 2020-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 /** 17 * @addtogroup UI_Animator 18 * @{ 19 * 20 * @brief Defines UI animation effects and provides matched curves. 21 * 22 * @since 1.0 23 * @version 1.0 24 */ 25 26 /** 27 * @file animator_manager.h 28 * 29 * @brief Represents the animator manager. 30 * 31 * @since 1.0 32 * @version 1.0 33 */ 34 35 #ifndef GRAPHIC_LITE_ANIMATOR_MANAGER_H 36 #define GRAPHIC_LITE_ANIMATOR_MANAGER_H 37 38 #include "animator/animator.h" 39 #include "common/task.h" 40 #include "gfx_utils/list.h" 41 42 namespace OHOS { 43 /** 44 * @brief Represents the animator manager. 45 * 46 * This is a singleton class used to manage <b>Animator</b> instances. 47 * 48 * @see Task 49 * @since 1.0 50 * @version 1.0 51 */ 52 class AnimatorManager : public Task { 53 public: 54 /** 55 * @brief Obtains the <b>AnimatorManager</b> instance. 56 * 57 * @return Returns the <b>AnimatorManager</b> instance. 58 * @since 1.0 59 * @version 1.0 60 */ 61 static AnimatorManager* GetInstance(); 62 63 void Init() override; 64 65 /** 66 * @brief Adds the <b>Animator</b> instance to the <b>AnimatorManager</b> linked list for management, 67 * so that the {@link Run} function of the <b>Animator</b> class is called once for each frame. 68 * 69 * @param animator Indicates the pointer to the <b>Animator</b> instance to add. 70 * @see Remove 71 * @since 1.0 72 * @version 1.0 73 */ 74 void Add(Animator* animator); 75 76 /** 77 * @brief Removes the <b>Animator</b> instance from the <b>AnimatorManager</b> linked list. 78 * 79 * @param animator Indicates the pointer to the <b>Animator</b> instance to remove. 80 * @see Add 81 * @since 1.0 82 * @version 1.0 83 */ 84 void Remove(const Animator* animator); 85 86 void AnimatorTask(); 87 Callback()88 void Callback() override 89 { 90 AnimatorTask(); 91 } 92 93 protected: 94 List<Animator*> list_; AnimatorManager()95 AnimatorManager() {} ~AnimatorManager()96 virtual ~AnimatorManager() {} 97 AnimatorManager(const AnimatorManager&) = delete; 98 AnimatorManager& operator=(const AnimatorManager&) = delete; 99 AnimatorManager(AnimatorManager&&) = delete; 100 AnimatorManager& operator=(AnimatorManager&&) = delete; 101 }; 102 } // namespace OHOS 103 #endif 104