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_DECLARATION_SVG_SVG_ELLIPSE_DECLARATION_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_DECLARATION_SVG_SVG_ELLIPSE_DECLARATION_H 18 19 #include "core/components/declaration/svg/svg_base_declaration.h" 20 21 namespace OHOS::Ace { 22 23 struct SvgEllipseAttribute : SvgBaseAttribute { 24 Dimension cx; 25 Dimension cy; 26 Dimension rx = -1.0_px; 27 Dimension ry = -1.0_px; 28 }; 29 30 class SvgEllipseDeclaration : public SvgBaseDeclaration { 31 DECLARE_ACE_TYPE(SvgEllipseDeclaration, SvgBaseDeclaration); 32 33 public: 34 SvgEllipseDeclaration() = default; 35 ~SvgEllipseDeclaration() override = default; 36 void InitializeStyle() override; 37 bool SetSpecializedAttr(const std::pair<std::string, std::string>& attr) override; 38 bool SetSpecializedStyle(const std::pair<std::string, std::string>& style) override; 39 SetCx(const Dimension & cx)40 void SetCx(const Dimension& cx) 41 { 42 auto& attribute = MaybeResetAttribute<SvgEllipseAttribute>(AttributeTag::SPECIALIZED_ATTR); 43 attribute.cx = cx; 44 } 45 GetCx()46 const Dimension& GetCx() const 47 { 48 auto& attribute = static_cast<SvgEllipseAttribute&>(GetAttribute(AttributeTag::SPECIALIZED_ATTR)); 49 return attribute.cx; 50 } 51 SetCy(const Dimension & cy)52 void SetCy(const Dimension& cy) 53 { 54 auto& attribute = MaybeResetAttribute<SvgEllipseAttribute>(AttributeTag::SPECIALIZED_ATTR); 55 attribute.cy = cy; 56 } 57 GetCy()58 const Dimension& GetCy() const 59 { 60 auto& attribute = static_cast<SvgEllipseAttribute&>(GetAttribute(AttributeTag::SPECIALIZED_ATTR)); 61 return attribute.cy; 62 } 63 SetRx(const Dimension & rx)64 void SetRx(const Dimension& rx) 65 { 66 auto& attribute = MaybeResetAttribute<SvgEllipseAttribute>(AttributeTag::SPECIALIZED_ATTR); 67 attribute.rx = rx; 68 } 69 GetRx()70 const Dimension& GetRx() const 71 { 72 auto& attribute = static_cast<SvgEllipseAttribute&>(GetAttribute(AttributeTag::SPECIALIZED_ATTR)); 73 return attribute.rx; 74 } 75 SetRy(const Dimension & ry)76 void SetRy(const Dimension& ry) 77 { 78 auto& attribute = MaybeResetAttribute<SvgEllipseAttribute>(AttributeTag::SPECIALIZED_ATTR); 79 attribute.ry = ry; 80 } 81 GetRy()82 const Dimension& GetRy() const 83 { 84 auto& attribute = static_cast<SvgEllipseAttribute&>(GetAttribute(AttributeTag::SPECIALIZED_ATTR)); 85 return attribute.ry; 86 } 87 88 protected: 89 void InitSpecialized() override; 90 91 private: 92 bool SetSpecializedValue(const std::pair<std::string, std::string>& attr); 93 }; 94 95 } // namespace OHOS::Ace 96 97 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_DECLARATION_SVG_SVG_ELLIPSE_DECLARATION_H 98