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