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 #ifndef RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_ANIMATION_CALLBACK_H 17 #define RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_ANIMATION_CALLBACK_H 18 19 #include <functional> 20 #include <utility> 21 22 #include "animation/rs_animation_timing_protocol.h" 23 #include "common/rs_macros.h" 24 25 namespace OHOS { 26 namespace Rosen { 27 class RSC_EXPORT AnimationCallback { 28 public: 29 explicit AnimationCallback(const std::function<void()>&& callback); 30 virtual ~AnimationCallback(); 31 32 protected: 33 std::function<void()> callback_; 34 }; 35 36 class RSC_EXPORT AnimationFinishCallback : public AnimationCallback { 37 public: 38 AnimationFinishCallback( 39 std::function<void()> callback, FinishCallbackType finishCallbackType = FinishCallbackType::TIME_SENSITIVE); 40 ~AnimationFinishCallback() override = default; 41 // Execute the callback function immediately, can only be called once. 42 void Execute(); 43 44 const FinishCallbackType finishCallbackType_; 45 }; 46 47 class RSC_EXPORT AnimationRepeatCallback { 48 public: AnimationRepeatCallback(std::function<void ()> callback)49 AnimationRepeatCallback(std::function<void()> callback) : callback_(std::move(callback)) {} 50 ~AnimationRepeatCallback() = default; 51 // Execute the callback function, can be called repeatedly. 52 void Execute(); 53 54 protected: 55 std::function<void()> callback_; 56 }; 57 58 class RSC_EXPORT InteractiveAnimatorFinishCallback : public AnimationCallback { 59 public: 60 InteractiveAnimatorFinishCallback(std::function<void()> callback); 61 ~InteractiveAnimatorFinishCallback() override = default; 62 }; 63 } // namespace Rosen 64 } // namespace OHOS 65 66 #endif // RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_ANIMATION_CALLBACK_H 67