1 /* 2 * Copyright (c) 2022-2023 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_MODEL_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_IMAGE_ANIMATOR_IMAGE_ANIMATOR_MODEL_H 18 19 #include <mutex> 20 21 #include "base/memory/ace_type.h" 22 #include "core/components/image/image_animator_component.h" 23 24 namespace OHOS::Ace { 25 class ACE_FORCE_EXPORT ImageAnimatorModel { 26 public: 27 static ImageAnimatorModel* GetInstance(); 28 virtual ~ImageAnimatorModel() = default; 29 30 virtual void Create() = 0; 31 virtual void SetImages(const std::vector<ImageProperties>& images) = 0; 32 virtual void SetState(int32_t state) = 0; 33 virtual void SetDuration(int32_t duration) = 0; 34 virtual void SetIteration(int32_t iteration) = 0; 35 virtual void SetFillMode(int32_t fillMode) = 0; 36 virtual void SetPreDecode(int32_t preDecode) = 0; 37 virtual void SetIsReverse(bool isReverse) = 0; 38 virtual void SetFixedSize(bool fixedSize) = 0; 39 virtual void SetOnStart(std::function<void()>&& OnStart) = 0; 40 virtual void SetOnPause(std::function<void()>&& OnPause) = 0; 41 virtual void SetOnRepeat(std::function<void()>&& OnRepeat) = 0; 42 virtual void SetOnCancel(std::function<void()>&& OnCancel) = 0; 43 virtual void SetOnFinish(std::function<void()>&& OnFinish) = 0; 44 45 private: 46 static std::unique_ptr<ImageAnimatorModel> instance_; 47 static std::mutex mutex_; 48 }; 49 } // namespace OHOS::Ace 50 51 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_IMAGE_ANIMATOR_IMAGE_ANIMATOR_MODEL_H 52