• 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_CLOCK_HAND_COMPONENT_H
17 #define OHOS_ACELITE_CLOCK_HAND_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 
27 namespace OHOS {
28 namespace ACELite {
29 class ClockHandComponent final : public Component {
30 public:
31     ACE_DISALLOW_COPY_AND_MOVE(ClockHandComponent);
32     ClockHandComponent() = delete;
33     ClockHandComponent(jerry_value_t options, jerry_value_t children, AppStyleManager* styleManager);
~ClockHandComponent()34     ~ClockHandComponent() {}
35 
36 protected:
37     bool CreateNativeViews() override;
38     void ReleaseNativeViews() override;
39     UIView *GetComponentRootView() const override;
40     bool SetPrivateAttribute(uint16_t attrKeyId, jerry_value_t attrValue) override;
41     bool ApplyPrivateStyle(const AppStyleItem* style) override;
42     void PostRender() override;
43 
44     /**
45     * @enum    LayoutType
46     *
47     * @brief   Values that represent different clock-hand layout types
48     */
49     enum class LayoutType : uint8_t {
50         // UIImageView layout
51         IMAGE,
52         // Rectangle layout
53         RECT
54     };
55 
56 private:
57     char* GetStringAttrByName(const char * const name);
58     void SetNamedProperty(jerry_value_t obj, const char * const name, jerry_value_t value);
59     LayoutType GetLayoutType();
60 
61     jerry_value_t options_;
62     const AppStyle* combinedStyle_;
63     LayoutType layoutType_;
64     UIView* clockHandView_;
65     int16_t pivotX_;
66     int16_t pivotY_;
67     int32_t fillColor_;
68     uint16_t opacity_;
69     char* handType_;
70 };
71 } // namespace ACELite
72 } // namespace OHOS
73 #endif // FEATURE_COMPONENT_ANALOG_CLOCK
74 #endif // OHOS_ACELITE_CLOCK_HAND_COMPONENT_H
75