• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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_IMAGE_IMAGE_EVENT_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_IMAGE_IMAGE_EVENT_H
18 
19 #include "base/image/image_defines.h"
20 #include "core/event/ace_events.h"
21 
22 namespace OHOS::Ace {
23 
24 class ACE_EXPORT LoadImageSuccessEvent : public BaseEventInfo {
25     DECLARE_RELATIONSHIP_OF_CLASSES(LoadImageSuccessEvent, BaseEventInfo);
26 
27 public:
28     LoadImageSuccessEvent(double width, double height, double componentWidth, double componentHeight,
29         int32_t loadingStatus = 1, double contentWidth = 0.0, double contentHeight = 0.0, double contentOffsetX = 0.0,
30         double contentOffsetY = 0.0) : BaseEventInfo("LoadImageSuccessEvent"), width_(width), height_(height),
31         componentWidth_(componentWidth), componentHeight_(componentHeight), loadingStatus_(loadingStatus),
32         contentWidth_(contentWidth), contentHeight_(contentHeight), contentOffsetX_(contentOffsetX),
33         contentOffsetY_(contentOffsetY) {}
34 
35     ~LoadImageSuccessEvent() = default;
36 
GetWidth()37     double GetWidth() const
38     {
39         return width_;
40     }
41 
GetHeight()42     double GetHeight() const
43     {
44         return height_;
45     }
46 
GetComponentWidth()47     double GetComponentWidth() const
48     {
49         return componentWidth_;
50     }
51 
GetComponentHeight()52     double GetComponentHeight() const
53     {
54         return componentHeight_;
55     }
56 
GetLoadingStatus()57     int32_t GetLoadingStatus() const
58     {
59         return loadingStatus_;
60     }
61 
GetContentWidth()62     double GetContentWidth() const
63     {
64         return contentWidth_;
65     }
66 
GetContentHeight()67     double GetContentHeight() const
68     {
69         return contentHeight_;
70     }
71 
GetContentOffsetX()72     double GetContentOffsetX() const
73     {
74         return contentOffsetX_;
75     }
76 
GetContentOffsetY()77     double GetContentOffsetY() const
78     {
79         return contentOffsetY_;
80     }
81 
82 private:
83     double width_ = 0.0;
84     double height_ = 0.0;
85     double componentWidth_ = 0.0;
86     double componentHeight_ = 0.0;
87     int32_t loadingStatus_ = 1; // [0] means [done layout], [1] means [load success]
88 
89     double contentWidth_ = 0.0;
90     double contentHeight_ = 0.0;
91     double contentOffsetX_ = 0.0;
92     double contentOffsetY_ = 0.0;
93 };
94 
95 class ACE_EXPORT LoadImageFailEvent : public BaseEventInfo {
96     DECLARE_RELATIONSHIP_OF_CLASSES(LoadImageFailEvent, BaseEventInfo);
97 
98 public:
LoadImageFailEvent(double componentWidth,double componentHeight,std::string errorMessage)99     LoadImageFailEvent(double componentWidth, double componentHeight, std::string errorMessage)
100         : BaseEventInfo("LoadImageFailEvent"), componentWidth_(componentWidth), componentHeight_(componentHeight),
101           errorMessage_(std::move(errorMessage))
102     {}
LoadImageFailEvent(double componentWidth,double componentHeight,std::string errorMessage,const ImageErrorInfo & errorInfo)103     LoadImageFailEvent(
104         double componentWidth, double componentHeight, std::string errorMessage, const ImageErrorInfo& errorInfo)
105         : BaseEventInfo("LoadImageFailEvent"), componentWidth_(componentWidth), componentHeight_(componentHeight),
106           errorMessage_(std::move(errorMessage)), errorInfo_(errorInfo)
107     {}
108     ~LoadImageFailEvent() override = default;
109 
GetComponentWidth()110     double GetComponentWidth() const
111     {
112         return componentWidth_;
113     }
114 
GetComponentHeight()115     double GetComponentHeight() const
116     {
117         return componentHeight_;
118     }
119 
GetErrorMessage()120     const std::string& GetErrorMessage() const
121     {
122         return errorMessage_;
123     }
124 
GetErrorInfo()125     ImageErrorInfo GetErrorInfo() const
126     {
127         return errorInfo_;
128     }
129 
130 private:
131     double componentWidth_ = 0.0;
132     double componentHeight_ = 0.0;
133     std::string errorMessage_;
134     ImageErrorInfo errorInfo_;
135 };
136 
137 } // namespace OHOS::Ace
138 
139 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_IMAGE_IMAGE_EVENT_H
140