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_COVERAGE_COVERAGE_COMPONENT_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_COVERAGE_COVERAGE_COMPONENT_H 18 19 #include "base/geometry/dimension.h" 20 #include "base/utils/label_target.h" 21 #include "base/utils/macros.h" 22 #include "core/components/align/align_component.h" 23 #include "core/components/box/box_component.h" 24 #include "core/components/common/layout/constants.h" 25 #include "core/components/common/properties/color.h" 26 #include "core/components/text/text_component_v2.h" 27 #include "core/pipeline/base/component_group.h" 28 29 namespace OHOS::Ace { 30 31 class ACE_EXPORT CoverageComponent : public ComponentGroup { 32 DECLARE_ACE_TYPE(CoverageComponent, ComponentGroup); 33 34 public: 35 explicit CoverageComponent(const std::list<RefPtr<Component>>& children); 36 ~CoverageComponent() override = default; 37 38 RefPtr<RenderNode> CreateRenderNode() override; 39 SetTextVal(const std::string & val)40 void SetTextVal(const std::string& val) 41 { 42 textComponent_->SetData(val); 43 } 44 GetTextVal()45 const std::string GetTextVal() const 46 { 47 return textComponent_->GetData(); 48 } 49 SetAlignment(Alignment alignment)50 void SetAlignment(Alignment alignment) 51 { 52 alignComponent_->SetAlignment(alignment); 53 } 54 SetX(const Dimension & x)55 void SetX(const Dimension& x) 56 { 57 textComponent_->SetHasLeft(true); 58 textComponent_->SetLeft(x); 59 textComponent_->SetPositionType(PositionType::PTRELATIVE); 60 } 61 SetY(const Dimension & y)62 void SetY(const Dimension& y) 63 { 64 textComponent_->SetHasTop(true); 65 textComponent_->SetTop(y); 66 textComponent_->SetPositionType(PositionType::PTRELATIVE); 67 } 68 GetX()69 const Dimension& GetX() const 70 { 71 return textComponent_->GetLeft(); 72 } 73 GetAlignment()74 const Alignment& GetAlignment() const 75 { 76 return alignComponent_->GetAlignment(); 77 } 78 GetY()79 const Dimension& GetY() const 80 { 81 return textComponent_->GetTop(); 82 } 83 IsOverLay()84 bool IsOverLay() const 85 { 86 return isOverLay_; 87 } 88 SetIsOverLay(bool isOverLay)89 void SetIsOverLay(bool isOverLay) 90 { 91 isOverLay_ = isOverLay; 92 } 93 94 void Initialization(); 95 96 private: 97 RefPtr<TextComponent> textComponent_; 98 RefPtr<BoxComponent> textBoxComponent_; 99 RefPtr<AlignComponent> alignComponent_; 100 bool isOverLay_ = false; 101 }; 102 103 } // namespace OHOS::Ace 104 105 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_COVERAGE_COVERAGE_COMPONENT_H 106