• 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 FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_SLIDER_BLOCK_COMPONENT_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_SLIDER_BLOCK_COMPONENT_H
18 
19 #include "base/geometry/dimension.h"
20 #include "core/components/common/properties/color.h"
21 #include "core/pipeline/base/component.h"
22 #include "core/pipeline/base/render_component.h"
23 
24 namespace OHOS::Ace {
25 
26 // The slider block in slider
27 class BlockComponent : public RenderComponent {
28     DECLARE_ACE_TYPE(BlockComponent, RenderComponent);
29 
30 public:
31     BlockComponent() = default;
32     ~BlockComponent() override = default;
33 
CreateElement()34     RefPtr<Element> CreateElement() override
35     {
36         // never use element to create element tree.
37         return nullptr;
38     }
39 
GetBlockColor()40     const Color& GetBlockColor() const
41     {
42         return blockColor_;
43     }
44 
SetBlockColor(const Color & color)45     void SetBlockColor(const Color& color)
46     {
47         blockColor_ = color;
48     }
49 
GetBlockSize()50     const Dimension& GetBlockSize() const
51     {
52         return blockSize_;
53     }
54 
GetHotRegionWidth()55     const Dimension& GetHotRegionWidth() const
56     {
57         return hotRegionWidth_;
58     }
59 
GetHotRegionHeight()60     const Dimension& GetHotRegionHeight() const
61     {
62         return hotRegionHeight_;
63     }
64 
SetBlockSize(const Dimension & size)65     void SetBlockSize(const Dimension& size)
66     {
67         blockSize_ = size;
68     }
69 
SetHotRegionWidth(const Dimension & width)70     void SetHotRegionWidth(const Dimension& width)
71     {
72         hotRegionWidth_ = width;
73     }
74 
SetHotRegionHeight(const Dimension & height)75     void SetHotRegionHeight(const Dimension& height)
76     {
77         hotRegionHeight_ = height;
78     }
79 
GetHoverColor()80     const Color& GetHoverColor() const
81     {
82         return hoverColor_;
83     }
84 
SetHoverColor(const Color & color)85     void SetHoverColor(const Color& color)
86     {
87         hoverColor_ = color;
88     }
89 
90 private:
91     Color hoverColor_;
92     Color blockColor_;
93     Dimension blockSize_;
94     Dimension hotRegionWidth_;
95     Dimension hotRegionHeight_;
96 };
97 
98 class CircleBlock : public BlockComponent {
99     DECLARE_ACE_TYPE(CircleBlock, BlockComponent);
100 
101 public:
102     CircleBlock() = default;
103     ~CircleBlock() override = default;
104 
105     RefPtr<RenderNode> CreateRenderNode() override;
106 };
107 
108 } // namespace OHOS::Ace
109 
110 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_SLIDER_BLOCK_COMPONENT_H
111