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