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_PATTERNS_NAVIGATION_TITLE_BAR_NODE_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_NAVIGATION_TITLE_BAR_NODE_H 18 19 #include "core/components_ng/base/frame_node.h" 20 #include "core/components_ng/pattern/navigation/navigation_declaration.h" 21 #include "core/components_ng/property/property.h" 22 23 namespace OHOS::Ace::NG { 24 25 class ACE_EXPORT TitleBarNode : public FrameNode { 26 DECLARE_ACE_TYPE(TitleBarNode, FrameNode) 27 public: 28 TitleBarNode(const std::string& tag, int32_t nodeId); TitleBarNode(const std::string & tag,int32_t nodeId,const RefPtr<Pattern> & pattern)29 TitleBarNode(const std::string& tag, int32_t nodeId, const RefPtr<Pattern>& pattern) 30 : FrameNode(tag, nodeId, pattern) {} 31 ~TitleBarNode() override; 32 static RefPtr<TitleBarNode> GetOrCreateTitleBarNode( 33 const std::string& tag, int32_t nodeId, const std::function<RefPtr<Pattern>(void)>& patternCreator); 34 IsAtomicNode()35 bool IsAtomicNode() const override 36 { 37 return false; 38 } 39 SetBackButton(const RefPtr<UINode> & button)40 void SetBackButton(const RefPtr<UINode>& button) 41 { 42 backButton_ = button; 43 } 44 GetBackButton()45 const RefPtr<UINode>& GetBackButton() const 46 { 47 return backButton_; 48 } 49 SetTitle(const RefPtr<UINode> & title)50 void SetTitle(const RefPtr<UINode>& title) 51 { 52 title_ = title; 53 } 54 GetTitle()55 const RefPtr<UINode>& GetTitle() const 56 { 57 return title_; 58 } 59 SetSubtitle(const RefPtr<UINode> & subtitle)60 void SetSubtitle(const RefPtr<UINode>& subtitle) 61 { 62 subtitle_ = subtitle; 63 } 64 GetSubtitle()65 const RefPtr<UINode>& GetSubtitle() const 66 { 67 return subtitle_; 68 } 69 SetMenu(const RefPtr<UINode> & menu)70 void SetMenu(const RefPtr<UINode>& menu) 71 { 72 menu_ = menu; 73 } 74 GetMenu()75 const RefPtr<UINode>& GetMenu() const 76 { 77 return menu_; 78 } 79 SetInnerParentId(const std::string & id)80 void SetInnerParentId(const std::string& id) 81 { 82 innerChildId_ = id; 83 } 84 GetInnerParentId()85 std::string GetInnerParentId() const 86 { 87 return innerChildId_; 88 } 89 90 // The function is only used for fast preview. 91 void FastPreviewUpdateChild(int32_t slot, const RefPtr<UINode>& newChild) override; 92 93 void MarkIsInitialTitle(bool isInitialTitle); 94 95 private: 96 RefPtr<UINode> backButton_; 97 RefPtr<UINode> title_; 98 RefPtr<UINode> subtitle_; 99 RefPtr<UINode> menu_; 100 std::string innerChildId_; 101 }; 102 103 } // namespace OHOS::Ace::NG 104 105 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_NAVIGATION_TITLE_BAR_NODE_H 106