• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_TEXT_TIMER_LAYOUT_PROPERTY_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_TEXT_TIMER_LAYOUT_PROPERTY_H
18 
19 #include <string>
20 
21 #include "core/components_ng/layout/layout_property.h"
22 #include "core/components_ng/pattern/text/text_layout_property.h"
23 #include "core/components_ng/property/property.h"
24 
25 namespace OHOS::Ace::NG {
26 class InspectorFilter;
27 
28 class ACE_EXPORT TextTimerLayoutProperty : public TextLayoutProperty {
29     DECLARE_ACE_TYPE(TextTimerLayoutProperty, TextLayoutProperty);
30 
31 public:
32     TextTimerLayoutProperty() = default;
33 
34     ~TextTimerLayoutProperty() override = default;
35 
Clone()36     RefPtr<LayoutProperty> Clone() const override
37     {
38         auto value = MakeRefPtr<TextTimerLayoutProperty>();
39         TextLayoutProperty::Clone(value);
40         value->LayoutProperty::UpdateLayoutProperty(DynamicCast<LayoutProperty>(this));
41         value->propFormat_ = CloneFormat();
42         value->propIsCountDown_ = CloneIsCountDown();
43         value->propInputCount_ = CloneInputCount();
44         value->propFontSize_ = CloneFontSize();
45         value->propTextColor_ = CloneTextColor();
46         value->propItalicFontStyle_ = CloneItalicFontStyle();
47         value->propFontWeight_ = CloneFontWeight();
48         value->propFontFamily_ = CloneFontFamily();
49         value->propTextShadow_ = CloneTextShadow();
50         return value;
51     }
52 
Reset()53     void Reset() override
54     {
55         TextLayoutProperty::Reset();
56         ResetFormat();
57         ResetIsCountDown();
58         ResetInputCount();
59         ResetFontSize();
60         ResetTextColor();
61         ResetItalicFontStyle();
62         ResetFontWeight();
63         ResetFontFamily();
64     }
65 
66     void ToJsonValue(std::unique_ptr<JsonValue>& json, const InspectorFilter& filter) const override;
67 
68     ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP_AND_USING_CALLBACK(Format, std::string, PROPERTY_UPDATE_MEASURE);
69     ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP_AND_USING_CALLBACK(IsCountDown, bool, PROPERTY_UPDATE_MEASURE);
70     ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP_AND_USING_CALLBACK(InputCount, double, PROPERTY_UPDATE_MEASURE);
71     ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(FontSize, Dimension, PROPERTY_UPDATE_MEASURE);
72     ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(TextColor, Color, PROPERTY_UPDATE_MEASURE_SELF);
73     ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(ItalicFontStyle, Ace::FontStyle, PROPERTY_UPDATE_MEASURE);
74     ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(FontWeight, FontWeight, PROPERTY_UPDATE_MEASURE);
75     ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(FontFamily, std::vector<std::string>, PROPERTY_UPDATE_MEASURE);
76     ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(TextShadow, std::vector<Shadow>, PROPERTY_UPDATE_MEASURE);
77     ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(TextColorSetByUser, bool, PROPERTY_UPDATE_MEASURE);
78     ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(TextFontSizeSetByUser, bool, PROPERTY_UPDATE_MEASURE);
79     ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(TextFontWeightSetByUser, bool, PROPERTY_UPDATE_MEASURE);
80     ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(TextFontFamilySetByUser, bool, PROPERTY_UPDATE_MEASURE);
81 
82 private:
83     void ResetCount();
OnFormatUpdate(const std::string & formateStr)84     void OnFormatUpdate(const std::string& formateStr)
85     {
86         ResetCount();
87     }
88 
OnIsCountDownUpdate(bool isCountDown)89     void OnIsCountDownUpdate(bool isCountDown)
90     {
91         ResetCount();
92     }
93 
OnInputCountUpdate(double inputCountUpdate)94     void OnInputCountUpdate(double inputCountUpdate)
95     {
96         ResetCount();
97     }
98     ACE_DISALLOW_COPY_AND_MOVE(TextTimerLayoutProperty);
99 };
100 } // namespace OHOS::Ace::NG
101 
102 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_TEXT_TIMER_LAYOUT_PROPERTY_H
103