• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 OHOS_ACELITE_CIRCLE_PROGRESS_COMPONENT_H
17 #define OHOS_ACELITE_CIRCLE_PROGRESS_COMPONENT_H
18 
19 
20 #include "component.h"
21 #include "non_copyable.h"
22 #include "ui_circle_progress.h"
23 
24 namespace OHOS {
25 namespace ACELite {
26 constexpr int16_t DEFAULT_START_ANGLE = 240;
27 constexpr int16_t DEFAULT_TOTAL_ANGLE = 240;
28 constexpr int16_t DEFAULT_STROKE_WIDTH = 32;
29 
30 class CircleProgressComponent final : public Component {
31 public:
32     ACE_DISALLOW_COPY_AND_MOVE(CircleProgressComponent);
33     CircleProgressComponent() = delete;
34     CircleProgressComponent(jerry_value_t options, jerry_value_t children, AppStyleManager* styleManager);
~CircleProgressComponent()35     ~CircleProgressComponent() override {}
36 
37 protected:
38     UIView *GetComponentRootView() const override;
39     bool SetPrivateAttribute(uint16_t attrKeyId, jerry_value_t attrValue) override;
40     bool ApplyPrivateStyle(const AppStyleItem* style) override;
41     void PostUpdate(uint16_t attrKeyId) override;
42     void OnViewAttached() override;
43     void HandleExtraUpdate();
44     bool CreateNativeViews() override;
45 
46 private:
47     void SetAngles();
48     bool SetArcProgressStyle(const AppStyleItem* style);
49     void SetStartAngle(const AppStyleItem *style);
50     void SetTotalAngle(const AppStyleItem *style);
51     bool SetArcColor(const AppStyleItem *style);
52     bool SetArcBackgroundColor(const AppStyleItem *style);
53     UICircleProgress progressView_;
54     int16_t centerX_;
55     int16_t centerY_;
56     int16_t radius_;
57     int16_t startAngle_;
58     int16_t totalAngle_;
59 };
60 } // namespace ACELite
61 } // namespace OHOS
62 
63 #endif // OHOS_ACELITE_CIRCLE_PROGRESS_COMPONENT_H
64