• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <mutex>
20 
21 #include "base/geometry/dimension.h"
22 #include "base/image/pixel_map.h"
23 #include "base/memory/referenced.h"
24 #include "core/components/box/drag_drop_event.h"
25 #include "core/components/common/layout/constants.h"
26 #include "core/components/common/properties/border.h"
27 #include "core/components/common/properties/color.h"
28 #include "core/components/image/image_event.h"
29 #include "core/components_ng/event/gesture_event_hub.h"
30 #include "interfaces/inner_api/ace/ai/image_analyzer.h"
31 
32 namespace OHOS::Ace {
33 class ImageModel {
34 public:
35     static ImageModel *GetInstance();
36     virtual ~ImageModel() = default;
37 
38     virtual void SetAlt(const ImageSourceInfo &src) = 0;
39     virtual void SetBlur(double blur) = 0;
40     virtual void SetBorder(const Border &border) = 0;
41     virtual void SetBackBorder() = 0;
42     virtual void SetImageFit(ImageFit value) = 0;
43     virtual void SetMatchTextDirection(bool value) = 0;
44     virtual void SetFitOriginSize(bool value) = 0;
45     virtual void SetOnComplete(std::function<void(const LoadImageSuccessEvent &info)> &&callback) = 0;
46     virtual void SetOnError(std::function<void(const LoadImageFailEvent &info)> &&callback) = 0;
47     virtual void SetSvgAnimatorFinishEvent(std::function<void()> &&callback) = 0;
48     virtual void Create(const std::string &src, RefPtr<PixelMap> &pixmap, const std::string &bundleName,
49         const std::string &moduleName, bool isUriPureNumber = false) = 0;
50     virtual void SetImageSourceSize(const std::pair<Dimension, Dimension> &size) = 0;
51     virtual void SetImageFill(const Color &color) = 0;
52     virtual void SetImageInterpolation(ImageInterpolation interpolation) = 0;
53     virtual void SetImageRepeat(ImageRepeat imageRepeat) = 0;
54     virtual void SetImageRenderMode(ImageRenderMode imageRenderMode) = 0;
55     virtual bool IsSrcSvgImage() = 0;
56     virtual void SetAutoResize(bool autoResize) = 0;
57     virtual void SetResizableSlice(const ImageResizableSlice& slice) = 0;
58     virtual void SetSyncMode(bool syncMode) = 0;
59     virtual void SetColorFilterMatrix(const std::vector<float> &matrix) = 0;
60     virtual void SetDraggable(bool draggable) = 0;
61     virtual void SetOnDragStart(NG::OnDragStartFunc &&onDragStart) = 0;
62     virtual void SetOnDragEnter(NG::OnDragDropFunc &&onDragEnter) = 0;
63     virtual void SetOnDragLeave(NG::OnDragDropFunc &&onDragLeave) = 0;
64     virtual void SetOnDragMove(NG::OnDragDropFunc &&onDragMove) = 0;
65     virtual void SetOnDrop(NG::OnDragDropFunc &&onDrop) = 0;
66     virtual void SetCopyOption(const CopyOptions &copyOption) = 0;
67     virtual bool UpdateDragItemInfo(DragItemInfo &itemInfo) = 0;
68     virtual void EnableAnalyzer(bool isEnableAnalyzer) = 0;
69     virtual void SetImageAnalyzerConfig(const ImageAnalyzerConfig& config) = 0;
70     virtual void SetSmoothEdge(float value) = 0;
71 
72 private:
73     static std::unique_ptr<ImageModel> instance_;
74     static std::mutex mutex_;
75 };
76 } // namespace OHOS::Ace
77 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_IMAGE_IMAGE_MODEL_H
78