• 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 "core/event/ace_events.h"
20 
21 namespace OHOS::Ace {
22 
23 class ACE_EXPORT LoadImageSuccessEvent : public BaseEventInfo {
24     DECLARE_RELATIONSHIP_OF_CLASSES(LoadImageSuccessEvent, BaseEventInfo);
25 
26 public:
27     LoadImageSuccessEvent(double width, double height, double componentWidth, double componentHeight,
28         int32_t loadingStatus = 1) : BaseEventInfo("LoadImageSuccessEvent"), width_(width), height_(height),
29         componentWidth_(componentWidth), componentHeight_(componentHeight), loadingStatus_(loadingStatus) {}
30 
31     ~LoadImageSuccessEvent() = default;
32 
GetWidth()33     double GetWidth() const
34     {
35         return width_;
36     }
37 
GetHeight()38     double GetHeight() const
39     {
40         return height_;
41     }
42 
GetComponentWidth()43     double GetComponentWidth() const
44     {
45         return componentWidth_;
46     }
47 
GetComponentHeight()48     double GetComponentHeight() const
49     {
50         return componentHeight_;
51     }
52 
GetLoadingStatus()53     int32_t GetLoadingStatus() const
54     {
55         return loadingStatus_;
56     }
57 
58 private:
59     double width_ = 0.0;
60     double height_ = 0.0;
61     double componentWidth_ = 0.0;
62     double componentHeight_ = 0.0;
63     int32_t loadingStatus_ = 1; // [0] means [done layout], [1] means [load success]
64 };
65 
66 class ACE_EXPORT LoadImageFailEvent : public BaseEventInfo {
67     DECLARE_RELATIONSHIP_OF_CLASSES(LoadImageFailEvent, BaseEventInfo);
68 
69 public:
LoadImageFailEvent(double componentWidth,double componentHeight,std::string errorMessage)70     LoadImageFailEvent(double componentWidth, double componentHeight, std::string errorMessage)
71         : BaseEventInfo("LoadImageFailEvent"), componentWidth_(componentWidth), componentHeight_(componentHeight),
72         errorMessage_(errorMessage) {}
73     ~LoadImageFailEvent() = default;
74 
GetComponentWidth()75     double GetComponentWidth() const
76     {
77         return componentWidth_;
78     }
79 
GetComponentHeight()80     double GetComponentHeight() const
81     {
82         return componentHeight_;
83     }
84 
GetErrorMessage()85     const std::string& GetErrorMessage() const
86     {
87         return errorMessage_;
88     }
89 
90 private:
91     double componentWidth_ = 0.0;
92     double componentHeight_ = 0.0;
93     std::string errorMessage_;
94 };
95 
96 } // namespace OHOS::Ace
97 
98 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_IMAGE_IMAGE_EVENT_H
99