• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2020 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_ANALOG_CLOCK_COMPONENT_H
17 #define OHOS_ACELITE_ANALOG_CLOCK_COMPONENT_H
18 
19 #include "acelite_config.h"
20 
21 #if (FEATURE_COMPONENT_ANALOG_CLOCK == 1)
22 
23 #include "component.h"
24 #include "non_copyable.h"
25 #include "stylemgr/app_style.h"
26 #include "ui_analog_clock.h"
27 
28 namespace OHOS {
29 namespace ACELite {
30 class AnalogClockComponent final : public Component {
31 public:
32     ACE_DISALLOW_COPY_AND_MOVE(AnalogClockComponent);
33     AnalogClockComponent() = delete;
34     AnalogClockComponent(jerry_value_t options, jerry_value_t children, AppStyleManager* styleManager);
~AnalogClockComponent()35     ~AnalogClockComponent() {}
36 
37 protected:
38     bool CreateNativeViews() override;
39     void ReleaseNativeViews() override;
40     UIView *GetComponentRootView() const override;
41     bool SetPrivateAttribute(uint16_t attrKeyId, jerry_value_t attrValue) override;
42     bool ProcessChildren() override;
43 
44 private:
45     int32_t GetIntegerProperty(jerry_value_t obj, const char * const name);
46     bool GetBoolProperty(jerry_value_t obj, const char * const name);
47     void SetImageHand(uint16_t handType, jerry_value_t child, UIView* childView);
48     void SetRectHand(uint16_t handType, jerry_value_t child, UIView* childView);
49     void UpdateClock();
50 
51     uint8_t hour_;
52     uint8_t min_;
53     uint8_t sec_;
54     jerry_value_t children_;
55     UIAnalogClock* clockView_;
56     const char * const clockHandPivotX = "pivot-x";
57     const char * const clockHandPivotY = "pivot-y";
58 };
59 } // namespace ACELite
60 } // namespace OHOS
61 
62 #endif // OHOS_ACELITE_ANALOG_CLOCK_COMPONENT_H
63 
64 #endif // FEATURE_COMPONENT_ANALOG_CLOCK
65