1 /*
2  * Copyright (c) 2022 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_NG_PATTERN_PANEL_PANEL_NODE_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_PANEL_PANEL_NODE_H
18 
19 #include <optional>
20 
21 #include "core/components_ng/base/group_node.h"
22 #include "core/components_ng/pattern/panel/sliding_panel_pattern.h"
23 
24 namespace OHOS::Ace::NG {
25 
26 class ACE_EXPORT SlidingPanelNode : public GroupNode {
27     DECLARE_ACE_TYPE(SlidingPanelNode, GroupNode);
28 
29 public:
30     SlidingPanelNode() = delete;
31     SlidingPanelNode(const std::string& tag, int32_t nodeId, const RefPtr<Pattern>& pattern, bool isRoot = false)
32         : GroupNode(tag, nodeId, pattern, isRoot)
33     {}
34     ~SlidingPanelNode() override = default;
35     void AddChildToGroup(const RefPtr<UINode>& child, int32_t slot = DEFAULT_NODE_SLOT) override;
HasColumnNode()36     bool HasColumnNode() const
37     {
38         return columnId_.has_value();
39     }
40 
GetColumnId()41     int32_t GetColumnId()
42     {
43         if (!columnId_.has_value()) {
44             columnId_ = ElementRegister::GetInstance()->MakeUniqueId();
45         }
46         return columnId_.value();
47     }
48 
GetDragBarId()49     int32_t GetDragBarId()
50     {
51         if (!dragBarId_.has_value()) {
52             dragBarId_ = ElementRegister::GetInstance()->MakeUniqueId();
53         }
54         return dragBarId_.value();
55     }
56 
GetContentId()57     int32_t GetContentId()
58     {
59         if (!contentId_.has_value()) {
60             contentId_ = ElementRegister::GetInstance()->MakeUniqueId();
61         }
62         return contentId_.value();
63     }
64 
65 private:
66     std::optional<int32_t> columnId_;
67     std::optional<int32_t> dragBarId_;
68     std::optional<int32_t> contentId_;
69     std::set<int32_t> columnChildren_;
70     std::map<int32_t, RefPtr<UINode>> builderNode_;
71 
72     ACE_DISALLOW_COPY_AND_MOVE(SlidingPanelNode);
73 };
74 
75 } // namespace OHOS::Ace::NG
76 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_PANEL_PANEL_NODE_H