• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_BASE_CUSTOM_NODE_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_BASE_CUSTOM_NODE_H
18 
19 #include <functional>
20 #include <string>
21 
22 #include "base/utils/macros.h"
23 #include "core/components_ng/base/frame_node.h"
24 #include "core/components_ng/pattern/custom/custom_node_base.h"
25 #include "core/components_ng/pattern/custom/custom_node_pattern.h"
26 
27 namespace OHOS::Ace::NG {
28 // CustomNode is the frame node of @Component struct.
29 class ACE_EXPORT CustomNode : public UINode, public CustomNodeBase {
30     DECLARE_ACE_TYPE(CustomNode, UINode, CustomNodeBase);
31 
32 public:
33     static RefPtr<CustomNode> CreateCustomNode(int32_t nodeId, const std::string& viewKey);
34 
35     CustomNode(int32_t nodeId, const std::string& viewKey);
36     ~CustomNode() override = default;
37 
38     void AdjustLayoutWrapperTree(const RefPtr<LayoutWrapper>& parent, bool forceMeasure, bool forceLayout) override;
39 
IsAtomicNode()40     bool IsAtomicNode() const override
41     {
42         return true;
43     }
44 
SetRenderFunction(const RenderFunction & renderFunction)45     void SetRenderFunction(const RenderFunction& renderFunction) override
46     {
47         renderFunction_ = renderFunction;
48     }
49 
50     void Build() override;
51 
FrameCount()52     int32_t FrameCount() const override
53     {
54         return 1;
55     }
56 
57 private:
58     std::string viewKey_;
59     RenderFunction renderFunction_;
60 };
61 } // namespace OHOS::Ace::NG
62 
63 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_BASE_CUSTOM_NODE_H
64