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_IMAGE_ANIMATOR_IMAGE_ANIMATOR_EVENT_HUB_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_IMAGE_ANIMATOR_IMAGE_ANIMATOR_EVENT_HUB_H 18 19 #include "base/memory/ace_type.h" 20 #include "core/components_ng/event/event_hub.h" 21 22 namespace OHOS::Ace::NG { 23 24 using AnimatorEvent = std::function<void()>; 25 26 class ImageAnimatorEventHub : public EventHub { 27 DECLARE_ACE_TYPE(ImageAnimatorEventHub, EventHub) 28 29 public: 30 ImageAnimatorEventHub() = default; 31 ~ImageAnimatorEventHub() override = default; 32 SetStartEvent(const AnimatorEvent & startEvent)33 void SetStartEvent(const AnimatorEvent& startEvent) 34 { 35 startEvent_ = startEvent; 36 } 37 GetStartEvent()38 const AnimatorEvent& GetStartEvent() const 39 { 40 return startEvent_; 41 } 42 SetStopEvent(const AnimatorEvent & stopEvent)43 void SetStopEvent(const AnimatorEvent& stopEvent) 44 { 45 stopEvent_ = stopEvent; 46 } 47 GetStopEvent()48 const AnimatorEvent& GetStopEvent() const 49 { 50 return stopEvent_; 51 } 52 SetPauseEvent(const AnimatorEvent & pauseEvent)53 void SetPauseEvent(const AnimatorEvent& pauseEvent) 54 { 55 pauseEvent_ = pauseEvent; 56 } 57 GetPauseEvent()58 const AnimatorEvent& GetPauseEvent() const 59 { 60 return pauseEvent_; 61 } 62 SetRepeatEvent(const AnimatorEvent & repeatEvent)63 void SetRepeatEvent(const AnimatorEvent& repeatEvent) 64 { 65 repeatEvent_ = repeatEvent; 66 } 67 GetRepeatEvent()68 const AnimatorEvent& GetRepeatEvent() const 69 { 70 return repeatEvent_; 71 } 72 SetCancelEvent(const AnimatorEvent & cancelEvent)73 void SetCancelEvent(const AnimatorEvent& cancelEvent) 74 { 75 cancelEvent_ = cancelEvent; 76 } 77 GetCancelEvent()78 const AnimatorEvent& GetCancelEvent() const 79 { 80 return cancelEvent_; 81 } 82 83 private: 84 AnimatorEvent startEvent_; 85 AnimatorEvent stopEvent_; 86 AnimatorEvent pauseEvent_; 87 AnimatorEvent repeatEvent_; 88 AnimatorEvent cancelEvent_; 89 }; 90 91 } // namespace OHOS::Ace::NG 92 93 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_IMAGE_ANIMATOR_IMAGE_ANIMATOR_EVENT_HUB_H 94