• 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_NG_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_IMAGE_IMAGE_MODEL_NG_H
18 
19 #include "core/components_ng/pattern/image/image_model.h"
20 
21 #include "core/components_ng/base/frame_node.h"
22 
23 namespace OHOS::Ace::NG {
24 // ImageModel is essentially the same class as ImageView
25 // there should be only one left in the final implementation
26 
27 class ACE_EXPORT ImageModelNG : public OHOS::Ace::ImageModel {
28 public:
29     void Create(const std::string &src, RefPtr<PixelMap> &pixMap, const std::string &bundleName,
30         const std::string &moduleName, bool isUriPureNumber = false) override;
31     void SetAlt(const ImageSourceInfo &src) override;
32     void SetBorder(const Border &border) override;
33     void SetBackBorder() override;
34     void SetBlur(double blur) override;
35     void SetImageFit(ImageFit value) override;
36     void SetMatchTextDirection(bool value) override;
37     void SetFitOriginSize(bool value) override;
38     void SetOnComplete(std::function<void(const LoadImageSuccessEvent &info)> &&callback) override;
39     void SetOnError(std::function<void(const LoadImageFailEvent &info)> &&callback) override;
40     void SetSvgAnimatorFinishEvent(std::function<void()> &&callback) override;
41     void SetImageSourceSize(const std::pair<Dimension, Dimension> &size) override;
42     void SetImageFill(const Color &color) override;
43     void SetImageInterpolation(ImageInterpolation interpolation) override;
44     void SetImageRepeat(ImageRepeat imageRepeat) override;
45     void SetImageRenderMode(ImageRenderMode imageRenderMode) override;
46     bool IsSrcSvgImage() override;
47     void SetAutoResize(bool autoResize) override;
48     void SetSyncMode(bool syncMode) override;
49     void SetColorFilterMatrix(const std::vector<float> &matrix) override;
50     void SetDraggable(bool draggable) override;
51     void SetOnDragStart(OnDragStartFunc &&onDragStart) override;
52     void SetOnDragEnter(OnDragDropFunc &&onDragEnter) override;
53     void SetOnDragLeave(OnDragDropFunc &&onDragLeave) override;
54     void SetOnDragMove(OnDragDropFunc &&onDragMove) override;
55     void SetOnDrop(OnDragDropFunc &&onDrop) override;
56     void SetCopyOption(const CopyOptions &copyOption) override;
57     void SetSmoothEdge(float value) override;
58     bool UpdateDragItemInfo(DragItemInfo &itemInfo) override;
59     void EnableAnalyzer(bool isEnableAnalyzer) override;
60     void SetImageAnalyzerConfig(const ImageAnalyzerConfig& config) override;
61     void SetResizableSlice(const ImageResizableSlice& slice) override;
62     static RefPtr<FrameNode> CreateFrameNode(int32_t nodeId, const std::string& src, RefPtr<PixelMap>& pixMap,
63         const std::string& bundleName, const std::string& moduleName, bool isUriPureNumber = false);
64     static void InitImage(FrameNode *frameNode, std::string& src);
65     static void SetSmoothEdge(FrameNode *frameNode, float value);
66     static void SetCopyOption(FrameNode *frameNode, CopyOptions copyOption);
67     static void SetAutoResize(FrameNode *frameNode, bool autoResize);
68     static void SetImageRepeat(FrameNode *frameNode, ImageRepeat imageRepeat);
69     static void SetImageRenderMode(FrameNode *frameNode, ImageRenderMode imageRenderMode);
70     static void SetSyncMode(FrameNode *frameNode, bool syncMode);
71     static void SetImageFit(FrameNode *frameNode, ImageFit value);
72     static void SetFitOriginSize(FrameNode *framNode, bool value);
73     static void SetImageSourceSize(FrameNode *frameNode, const std::pair<Dimension, Dimension> &size);
74     static void SetMatchTextDirection(FrameNode *frameNode, bool value);
75     static void SetImageFill(FrameNode *frameNode, const Color &color);
76     static void SetAlt(FrameNode *frameNode, const ImageSourceInfo &src);
77     static void SetImageInterpolation(FrameNode *frameNode, ImageInterpolation interpolation);
78     static void SetColorFilterMatrix(FrameNode *frameNode, const std::vector<float> &matrix);
79     static void SetDraggable(FrameNode *frameNode, bool draggable);
80     static void SetBackBorder(FrameNode *frameNode);
81     static bool IsSrcSvgImage(FrameNode* frameNode);
82 };
83 } // namespace OHOS::Ace::NG
84 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_IMAGE_IMAGE_MODEL_NG_H
85