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_TOOL_BAR_TOOL_BAR_ITEM_COMPONENT_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_TOOL_BAR_TOOL_BAR_ITEM_COMPONENT_H
18 
19 #include "core/pipeline/base/component_group.h"
20 #include "core/pipeline/base/sole_child_component.h"
21 
22 namespace OHOS::Ace {
23 
24 class ToolBarItemComponent : public SoleChildComponent {
25     DECLARE_ACE_TYPE(ToolBarItemComponent, SoleChildComponent);
26 
27 public:
28     using OptionChildrenCallBack = std::function<std::list<RefPtr<Component>>()>;
29     using EventCallback = std::function<void()>;
30 
31     ToolBarItemComponent() = default;
32     ~ToolBarItemComponent() override = default;
33 
34     RefPtr<RenderNode> CreateRenderNode() override;
35     RefPtr<Element> CreateElement() override;
36 
SetIsEndItem(bool isEndItem)37     void SetIsEndItem(bool isEndItem)
38     {
39         isEndItem_ = isEndItem;
40     }
41 
GetIsEndItem()42     bool GetIsEndItem()
43     {
44         return isEndItem_;
45     }
46 
SetOptionChildrenCallBack(OptionChildrenCallBack && optionChildrenCallBack)47     void SetOptionChildrenCallBack(OptionChildrenCallBack&& optionChildrenCallBack)
48     {
49         optionChildrenCallBack_ = std::move(optionChildrenCallBack);
50     }
51 
GetOptionChildrenCallBack()52     const OptionChildrenCallBack& GetOptionChildrenCallBack() const
53     {
54         return optionChildrenCallBack_;
55     }
56 
SetMenuMinWidth(const Dimension & menuMinWidth)57     void SetMenuMinWidth(const Dimension& menuMinWidth)
58     {
59         menuMinWidth_ = menuMinWidth;
60     }
61 
GetMenuMinWidth()62     const Dimension& GetMenuMinWidth() const
63     {
64         return menuMinWidth_;
65     }
66 
SetPressColor(const Color & pressColor)67     void SetPressColor(const Color& pressColor)
68     {
69         pressColor_ = pressColor;
70     }
71 
GetPressColor()72     const Color& GetPressColor()
73     {
74         return pressColor_;
75     }
76 
SetClickedEventId(const EventMarker & eventId)77     void SetClickedEventId(const EventMarker& eventId)
78     {
79         clickEventId_ = eventId;
80     }
81 
GetClickedEventId()82     const EventMarker& GetClickedEventId() const
83     {
84         return clickEventId_;
85     }
86 
SetRadius(const Dimension & rrectRadius)87     void SetRadius(const Dimension& rrectRadius)
88     {
89         rrectRadius_ = rrectRadius;
90     }
91 
GetRadius()92     const Dimension& GetRadius()
93     {
94         return rrectRadius_;
95     }
96 
SetFocusColor(const Color & focusColor)97     void SetFocusColor(const Color& focusColor)
98     {
99         focusColor_ = focusColor;
100     }
101 
GetFocusColor()102     const Color& GetFocusColor()
103     {
104         return focusColor_;
105     }
106 
SetHoverColor(const Color & hoverColor)107     void SetHoverColor(const Color& hoverColor)
108     {
109         hoverColor_ = hoverColor;
110     }
111 
GetHoverColor()112     const Color& GetHoverColor()
113     {
114         return hoverColor_;
115     }
116 
117 private:
118     OptionChildrenCallBack optionChildrenCallBack_;
119     EventMarker clickEventId_;
120 
121     Dimension menuMinWidth_;
122     bool isEndItem_ = false;
123     Dimension rrectRadius_;
124 
125     Color pressColor_;
126     Color hoverColor_;
127     Color focusColor_;
128 };
129 
130 } // namespace OHOS::Ace
131 
132 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_TOOL_BAR_TOOL_BAR_ITEM_COMPONENT_H
133