1 /*
2  * Copyright (c) 2022 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_NG_PATTERN_SHAPE_PATH_PAINT_PROPERTY_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_SHAPE_PATH_PAINT_PROPERTY_H
18 
19 #include <string>
20 
21 #include "core/components_ng/base/inspector_filter.h"
22 #include "core/components_ng/layout/layout_property.h"
23 #include "core/components_ng/pattern/shape/shape_paint_property.h"
24 #include "core/components_ng/property/property.h"
25 #include "core/components_ng/render/paint_property.h"
26 
27 namespace OHOS::Ace::NG {
28 
29 class ACE_EXPORT PathPaintProperty : public ShapePaintProperty {
30     DECLARE_ACE_TYPE(PathPaintProperty, ShapePaintProperty);
31 
32 public:
33     PathPaintProperty() = default;
34     ~PathPaintProperty() override = default;
Clone()35     RefPtr<PaintProperty> Clone() const override
36     {
37         auto value = MakeRefPtr<PathPaintProperty>();
38         value->PaintProperty::UpdatePaintProperty(DynamicCast<PaintProperty>(this));
39         value->propCommands_ = CloneCommands();
40         value->propFill_ = CloneFill();
41         value->propFillOpacity_ = CloneFillOpacity();
42         value->propStroke_ = CloneStroke();
43         value->propStrokeWidth_ = CloneStrokeWidth();
44         value->propStrokeOpacity_ = CloneStrokeOpacity();
45         value->propStrokeDashArray_ = CloneStrokeDashArray();
46         value->propStrokeDashOffset_ = CloneStrokeDashOffset();
47         value->propStrokeLineCap_ = CloneStrokeLineCap();
48         value->propStrokeLineJoin_ = CloneStrokeLineJoin();
49         value->propStrokeMiterLimit_ = CloneStrokeMiterLimit();
50         value->propAntiAlias_ = CloneAntiAlias();
51         return value;
52     }
53 
Reset()54     void Reset() override
55     {
56         ShapePaintProperty::Reset();
57         ResetCommands();
58     }
59 
ToJsonValue(std::unique_ptr<JsonValue> & json,const InspectorFilter & filter)60     void ToJsonValue(std::unique_ptr<JsonValue>& json, const InspectorFilter& filter) const override
61     {
62         ShapePaintProperty::ToJsonValue(json, filter);
63         /* no fixed attr below, just return */
64         if (filter.IsFastFilter()) {
65             return;
66         }
67         if (propCommands_.has_value()) {
68             json->PutExtAttr("commands", propCommands_.value().c_str(), filter);
69         }
70     }
71 
72     ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(Commands, std::string, PROPERTY_UPDATE_RENDER);
73 
74 private:
75     ACE_DISALLOW_COPY_AND_MOVE(PathPaintProperty);
76 };
77 } // namespace OHOS::Ace::NG
78 
79 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_SHAPE_PATH_PAINT_PROPERTY_H
80