1 /*
2  * Copyright (c) 2022-2023 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_GAUGE_MODEL_NG_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_GAUGE_MODEL_NG_H
18 
19 #include "core/components_ng/base/common_configuration.h"
20 #include "core/components_ng/pattern/gauge/gauge_model.h"
21 
22 namespace OHOS::Ace::NG {
23 class GaugeConfiguration : public CommonConfiguration {
24     public:
GaugeConfiguration(float value,float min,float max,bool enabled)25         GaugeConfiguration(float value, float min, float max, bool enabled)
26             : CommonConfiguration(enabled), value_(value), min_(min), max_(max)
27         {}
28         float value_;
29         float min_;
30         float max_;
31 };
32 using GaugeMakeCallback =
33     std::function<RefPtr<FrameNode>(const GaugeConfiguration& gaugeConfiguration)>;
34 class ACE_EXPORT GaugeModelNG : public OHOS::Ace::GaugeModel {
35 public:
36     void Create(float values, float min, float max) override;
37     void SetValue(float value) override;
38     void SetStartAngle(float startAngle) override;
39     void SetEndAngle(float endAngle) override;
40     void SetColors(const std::vector<Color>& colors, const std::vector<float>& values) override;
41     void SetGradientColors(
42         const std::vector<ColorStopArray>& colors, const std::vector<float>& values, const GaugeType& type) override;
43     void SetStrokeWidth(const Dimension& strokeWidth) override;
44     void SetLabelMarkedText(const std::string labelTextString) override;
45     void SetMarkedTextColor(const Color& color) override;
46     void SetDescription(const RefPtr<AceType>& customNode) override;
47     void SetIsShowLimitValue(bool isShowLimitValue) override;
48     void SetIsShowDescription(bool isShowDescription) override;
49     void SetShadowOptions(const GaugeShadowOptions& shadowOptions) override;
50     void SetIsShowIndicator(bool isShowIndicator) override;
51     void SetIndicatorIconPath(
52         const std::string& iconPath, const std::string& bundleName, const std::string& moduleName) override;
53     void SetIndicatorSpace(const Dimension& space) override;
54     void ResetGradientColors() override;
55     void ResetShadowOptions() override;
56     void ResetIndicatorIconPath() override;
57     void ResetIndicatorSpace() override;
58 
59     static void SetValue(FrameNode* frameNode, float value);
60     static void SetStartAngle(FrameNode* frameNode, float value);
61     static void SetEndAngle(FrameNode* frameNode, float value);
62     static void SetGaugeStrokeWidth(FrameNode* frameNode, const Dimension& strokeWidth);
63     static void SetShadowOptions(FrameNode* frameNode, const GaugeShadowOptions& shadowOptions);
64     static void ResetShadowOptions(FrameNode* frameNode);
65     static void SetIsShowIndicator(FrameNode* frameNode, bool isShowIndicator);
66     static void SetIndicatorIconPath(FrameNode* frameNode,
67         const std::string& iconPath, const std::string& bundleName, const std::string& moduleName);
68     static void ResetIndicatorIconPath(FrameNode* frameNode);
69     static void SetIndicatorSpace(FrameNode* frameNode, const Dimension& space);
70     static void ResetIndicatorSpace(FrameNode* frameNode);
71     static void SetColors(FrameNode* frameNode, const std::vector<Color>& colors, const std::vector<float>& values);
72     static void SetGradientColors(FrameNode* frameNode, const std::vector<ColorStopArray>& colors,
73         const std::vector<float>& values, const GaugeType& type);
74     static void ResetGradientColors(FrameNode* frameNode);
75     static void SetBuilderFunc(FrameNode* frameNode, NG::GaugeMakeCallback&& jsMake);
76 };
77 } // namespace OHOS::Ace::NG
78 
79 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_GAUGE_MODEL_NG_H