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_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->propProgressPaintDate_ = CloneProgressPaintDate(); 39 paintProperty->propColor_ = CloneColor(); 40 paintProperty->propBackgroundColor_ = CloneBackgroundColor(); 41 paintProperty->propProgressType_ = CloneProgressType(); 42 paintProperty->propBorderColor_ = CloneBorderColor(); 43 paintProperty->propGradientColor_ = CloneGradientColor(); 44 paintProperty->propPaintShadow_ = ClonePaintShadow(); 45 paintProperty->propProgressStatus_ = CloneProgressStatus(); 46 paintProperty->propEnableSmoothEffect_ = CloneEnableSmoothEffect(); 47 paintProperty->propIsSensitive_ = CloneIsSensitive(); 48 return paintProperty; 49 } 50 Reset()51 void Reset() override 52 { 53 PaintProperty::Reset(); 54 ResetProgressPaintDate(); 55 ResetColor(); 56 ResetBackgroundColor(); 57 ResetProgressType(); 58 ResetBorderColor(); 59 ResetGradientColor(); 60 ResetPaintShadow(); 61 ResetProgressStatus(); 62 ResetEnableSmoothEffect(); 63 ResetIsSensitive(); 64 } 65 66 void ToJsonValue(std::unique_ptr<JsonValue>& json, const InspectorFilter& filter) const override; 67 68 std::string ProgressOptions() const; 69 void ToJsonValueForCapsule(std::unique_ptr<JsonValue>& json, const InspectorFilter& filter) 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 91 ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(Color, Color, PROPERTY_UPDATE_MEASURE); 92 ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(BackgroundColor, Color, PROPERTY_UPDATE_MEASURE); 93 ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(ProgressType, ProgressType, PROPERTY_UPDATE_MEASURE); 94 ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(BorderColor, Color, PROPERTY_UPDATE_MEASURE); 95 ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(GradientColor, Gradient, PROPERTY_UPDATE_MEASURE); 96 ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(PaintShadow, bool, PROPERTY_UPDATE_MEASURE); 97 ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(ProgressStatus, ProgressStatus, PROPERTY_UPDATE_MEASURE); 98 ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(EnableSmoothEffect, bool, PROPERTY_UPDATE_MEASURE); 99 ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(IsSensitive, bool, PROPERTY_UPDATE_MEASURE); 100 }; 101 } // namespace OHOS::Ace::NG 102 103 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_PROGRESS_PROGRESS_PAINT_PROPERTY_H 104