• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2025 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_PATTERNS_PROGRESS_PROGRESS_PAINT_PROPERTY_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_PROGRESS_PROGRESS_PAINT_PROPERTY_H
18 
19 #include "base/geometry/dimension.h"
20 #include "core/components/common/properties/text_style.h"
21 #include "core/components_ng/pattern/progress/progress_date.h"
22 #include "core/components_ng/property/gradient_property.h"
23 #include "core/components_ng/property/property.h"
24 #include "core/components_ng/render/paint_property.h"
25 
26 namespace OHOS::Ace::NG {
27 class ACE_EXPORT ProgressPaintProperty : public PaintProperty {
28     DECLARE_ACE_TYPE(ProgressPaintProperty, PaintProperty);
29 
30 public:
31     ProgressPaintProperty() = default;
32 
33     ~ProgressPaintProperty() override = default;
34 
Clone()35     RefPtr<PaintProperty> Clone() const override
36     {
37         auto paintProperty = MakeRefPtr<ProgressPaintProperty>();
38         paintProperty->UpdatePaintPropertyHost(this);
39         paintProperty->propProgressPaintDate_ = CloneProgressPaintDate();
40         paintProperty->propColor_ = CloneColor();
41         paintProperty->propBackgroundColor_ = CloneBackgroundColor();
42         paintProperty->propProgressType_ = CloneProgressType();
43         paintProperty->propBorderColor_ = CloneBorderColor();
44         paintProperty->propGradientColor_ = CloneGradientColor();
45         paintProperty->propPaintShadow_ = ClonePaintShadow();
46         paintProperty->propProgressStatus_ = CloneProgressStatus();
47         paintProperty->propEnableSmoothEffect_ = CloneEnableSmoothEffect();
48         paintProperty->propIsSensitive_ = CloneIsSensitive();
49         return paintProperty;
50     }
51 
Reset()52     void Reset() override
53     {
54         PaintProperty::Reset();
55         ResetProgressPaintDate();
56         ResetColor();
57         ResetBackgroundColor();
58         ResetProgressType();
59         ResetBorderColor();
60         ResetGradientColor();
61         ResetPaintShadow();
62         ResetProgressStatus();
63         ResetEnableSmoothEffect();
64         ResetIsSensitive();
65     }
66 
67     void ToJsonValue(std::unique_ptr<JsonValue>& json, const InspectorFilter& filter) const override;
68 
69     std::string ProgressOptions() const;
70     std::string ToJsonGradientColor() const;
71 
72     ACE_DEFINE_PROPERTY_GROUP(ProgressPaintDate, ProgressDate);
73     ACE_DEFINE_PROPERTY_ITEM_WITH_GROUP(ProgressPaintDate, MaxValue, double, PROPERTY_UPDATE_MEASURE);
74     ACE_DEFINE_PROPERTY_ITEM_WITH_GROUP(ProgressPaintDate, Value, double, PROPERTY_UPDATE_MEASURE);
75     ACE_DEFINE_PROPERTY_ITEM_WITH_GROUP(ProgressPaintDate, ScaleCount, int32_t, PROPERTY_UPDATE_MEASURE);
76     ACE_DEFINE_PROPERTY_ITEM_WITH_GROUP(ProgressPaintDate, ScaleWidth, Dimension, PROPERTY_UPDATE_MEASURE);
77     ACE_DEFINE_PROPERTY_ITEM_WITH_GROUP(ProgressPaintDate, BorderWidth, Dimension, PROPERTY_UPDATE_MEASURE);
78     ACE_DEFINE_PROPERTY_ITEM_WITH_GROUP(ProgressPaintDate, TextSize, Dimension, PROPERTY_UPDATE_MEASURE);
79     ACE_DEFINE_PROPERTY_ITEM_WITH_GROUP(ProgressPaintDate, Text, std::string, PROPERTY_UPDATE_MEASURE);
80     ACE_DEFINE_PROPERTY_ITEM_WITH_GROUP(ProgressPaintDate, EnableScanEffect, bool, PROPERTY_UPDATE_MEASURE);
81     ACE_DEFINE_PROPERTY_ITEM_WITH_GROUP(ProgressPaintDate, FontWeight, FontWeight, PROPERTY_UPDATE_MEASURE);
82     ACE_DEFINE_PROPERTY_ITEM_WITH_GROUP(
83         ProgressPaintDate, FontFamily, std::vector<std::string>, PROPERTY_UPDATE_MEASURE);
84     ACE_DEFINE_PROPERTY_ITEM_WITH_GROUP(ProgressPaintDate, ItalicFontStyle, Ace::FontStyle, PROPERTY_UPDATE_MEASURE);
85     ACE_DEFINE_PROPERTY_ITEM_WITH_GROUP(ProgressPaintDate, TextColor, Color, PROPERTY_UPDATE_MEASURE);
86     ACE_DEFINE_PROPERTY_ITEM_WITH_GROUP(ProgressPaintDate, EnableRingScanEffect, bool, PROPERTY_UPDATE_MEASURE);
87     ACE_DEFINE_PROPERTY_ITEM_WITH_GROUP(ProgressPaintDate, EnableLinearScanEffect, bool, PROPERTY_UPDATE_MEASURE);
88     ACE_DEFINE_PROPERTY_ITEM_WITH_GROUP(ProgressPaintDate, EnableShowText, bool, PROPERTY_UPDATE_MEASURE);
89     ACE_DEFINE_PROPERTY_ITEM_WITH_GROUP(ProgressPaintDate, StrokeRadius, Dimension, PROPERTY_UPDATE_RENDER);
90     ACE_DEFINE_PROPERTY_ITEM_WITH_GROUP(ProgressPaintDate, BorderRadius, Dimension, PROPERTY_UPDATE_MEASURE);
91 
92     ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(Color, Color, PROPERTY_UPDATE_MEASURE);
93     ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(BackgroundColor, Color, PROPERTY_UPDATE_MEASURE);
94     ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(ProgressType, ProgressType, PROPERTY_UPDATE_MEASURE);
95     ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(BorderColor, Color, PROPERTY_UPDATE_MEASURE);
96     ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(GradientColor, Gradient, PROPERTY_UPDATE_MEASURE);
97     ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(PaintShadow, bool, PROPERTY_UPDATE_MEASURE);
98     ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(ProgressStatus, ProgressStatus, PROPERTY_UPDATE_MEASURE);
99     ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(EnableSmoothEffect, bool, PROPERTY_UPDATE_MEASURE);
100     ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(IsSensitive, bool, PROPERTY_UPDATE_MEASURE);
101 
102     int32_t GetThemeScopeId() const;
103 };
104 } // namespace OHOS::Ace::NG
105 
106 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_PROGRESS_PROGRESS_PAINT_PROPERTY_H
107