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, double contentWidth = 0.0, double contentHeight = 0.0, double contentOffsetX = 0.0, 29 double contentOffsetY = 0.0) : BaseEventInfo("LoadImageSuccessEvent"), width_(width), height_(height), 30 componentWidth_(componentWidth), componentHeight_(componentHeight), loadingStatus_(loadingStatus), 31 contentWidth_(contentWidth), contentHeight_(contentHeight), contentOffsetX_(contentOffsetX), 32 contentOffsetY_(contentOffsetY) {} 33 34 ~LoadImageSuccessEvent() = default; 35 GetWidth()36 double GetWidth() const 37 { 38 return width_; 39 } 40 GetHeight()41 double GetHeight() const 42 { 43 return height_; 44 } 45 GetComponentWidth()46 double GetComponentWidth() const 47 { 48 return componentWidth_; 49 } 50 GetComponentHeight()51 double GetComponentHeight() const 52 { 53 return componentHeight_; 54 } 55 GetLoadingStatus()56 int32_t GetLoadingStatus() const 57 { 58 return loadingStatus_; 59 } 60 GetContentWidth()61 double GetContentWidth() const 62 { 63 return contentWidth_; 64 } 65 GetContentHeight()66 double GetContentHeight() const 67 { 68 return contentHeight_; 69 } 70 GetContentOffsetX()71 double GetContentOffsetX() const 72 { 73 return contentOffsetX_; 74 } 75 GetContentOffsetY()76 double GetContentOffsetY() const 77 { 78 return contentOffsetY_; 79 } 80 81 private: 82 double width_ = 0.0; 83 double height_ = 0.0; 84 double componentWidth_ = 0.0; 85 double componentHeight_ = 0.0; 86 int32_t loadingStatus_ = 1; // [0] means [done layout], [1] means [load success] 87 88 double contentWidth_ = 0.0; 89 double contentHeight_ = 0.0; 90 double contentOffsetX_ = 0.0; 91 double contentOffsetY_ = 0.0; 92 }; 93 94 class ACE_EXPORT LoadImageFailEvent : public BaseEventInfo { 95 DECLARE_RELATIONSHIP_OF_CLASSES(LoadImageFailEvent, BaseEventInfo); 96 97 public: LoadImageFailEvent(double componentWidth,double componentHeight,std::string errorMessage)98 LoadImageFailEvent(double componentWidth, double componentHeight, std::string errorMessage) 99 : BaseEventInfo("LoadImageFailEvent"), componentWidth_(componentWidth), componentHeight_(componentHeight), 100 errorMessage_(std::move(errorMessage)) {} 101 ~LoadImageFailEvent() override = default; 102 GetComponentWidth()103 double GetComponentWidth() const 104 { 105 return componentWidth_; 106 } 107 GetComponentHeight()108 double GetComponentHeight() const 109 { 110 return componentHeight_; 111 } 112 GetErrorMessage()113 const std::string& GetErrorMessage() const 114 { 115 return errorMessage_; 116 } 117 118 private: 119 double componentWidth_ = 0.0; 120 double componentHeight_ = 0.0; 121 std::string errorMessage_; 122 }; 123 124 } // namespace OHOS::Ace 125 126 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_IMAGE_IMAGE_EVENT_H 127