1 /* 2 * Copyright (c) 2021-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_PATTERN_IMAGE_IMAGE_MODEL_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_IMAGE_IMAGE_MODEL_H 18 19 #include "base/geometry/dimension.h" 20 #include "base/image/pixel_map.h" 21 #include "base/memory/referenced.h" 22 #include "core/components/box/drag_drop_event.h" 23 #include "core/components/common/layout/constants.h" 24 #include "core/components/common/properties/border.h" 25 #include "core/components/common/properties/color.h" 26 #include "core/components/image/image_event.h" 27 #include "core/components_ng/event/gesture_event_hub.h" 28 29 namespace OHOS::Ace { 30 31 class ImageModel { 32 public: 33 static ImageModel* GetInstance(); 34 virtual ~ImageModel() = default; 35 36 virtual void SetAlt(const std::string& src) = 0; 37 virtual void SetBlur(double blur) = 0; 38 virtual void SetBorder(const Border& border) = 0; 39 virtual void SetBackBorder() = 0; 40 virtual void SetImageFit(ImageFit value) = 0; 41 virtual void SetMatchTextDirection(bool value) = 0; 42 virtual void SetFitOriginSize(bool value) = 0; 43 virtual void SetOnComplete(std::function<void(const LoadImageSuccessEvent& info)>&& callback) = 0; 44 virtual void SetOnError(std::function<void(const LoadImageFailEvent& info)>&& callback) = 0; 45 virtual void SetSvgAnimatorFinishEvent(std::function<void()>&& callback) = 0; 46 virtual void Create(const std::string& src, bool noPixMap, RefPtr<PixelMap>& pixMap) = 0; 47 virtual void SetImageSourceSize(const std::pair<Dimension, Dimension>& size) = 0; 48 virtual void SetImageFill(const Color& color) = 0; 49 virtual void SetImageInterpolation(ImageInterpolation interpolation) = 0; 50 virtual void SetImageRepeat(ImageRepeat imageRepeat) = 0; 51 virtual void SetImageRenderMode(ImageRenderMode imageRenderMode) = 0; 52 virtual bool IsSrcSvgImage() = 0; 53 virtual void SetAutoResize(bool autoResize) = 0; 54 virtual void SetSyncMode(bool syncMode) = 0; 55 virtual void SetColorFilterMatrix(const std::vector<float>& matrix) = 0; 56 virtual void SetDraggable(bool draggable) = 0; 57 virtual void SetOnDragStart(NG::OnDragStartFunc&& onDragStart) = 0; 58 virtual void SetOnDragEnter(NG::OnDragDropFunc&& onDragEnter) = 0; 59 virtual void SetOnDragLeave(NG::OnDragDropFunc&& onDragLeave) = 0; 60 virtual void SetOnDragMove(NG::OnDragDropFunc&& onDragMove) = 0; 61 virtual void SetOnDrop(NG::OnDragDropFunc&& onDrop) = 0; 62 virtual void SetCopyOption(const CopyOptions& copyOption) = 0; 63 virtual bool UpdateDragItemInfo(DragItemInfo& itemInfo) = 0; 64 65 private: 66 static std::unique_ptr<ImageModel> instance_; 67 }; 68 69 } // namespace OHOS::Ace 70 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_IMAGE_IMAGE_MODEL_H 71