1 /* 2 * Copyright (c) 2022-2023 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_STAGE_STAGE_MANAGER_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_STAGE_STAGE_MANAGER_H 18 19 #include <cstdint> 20 21 #include "base/memory/ace_type.h" 22 #include "base/memory/referenced.h" 23 #include "base/utils/noncopyable.h" 24 #include "core/animation/page_transition_common.h" 25 #include "core/components_ng/base/ui_node.h" 26 27 namespace OHOS::Ace::NG { 28 class FrameNode; 29 class StagePattern; 30 class OverlayManager; 31 32 // StageManager is the base class for root render node to perform page switch. 33 class ACE_EXPORT StageManager : public virtual AceType { 34 DECLARE_ACE_TYPE(StageManager, AceType); 35 36 public: 37 explicit StageManager(const RefPtr<FrameNode>& stage); 38 ~StageManager() override = default; 39 40 bool PushPage(const RefPtr<FrameNode>& node, bool needHideLast = true, bool needTransition = true); 41 bool PopPage(bool needShowNext = true, bool needTransition = true); 42 bool PopPageToIndex(int32_t index, bool needShowNext = true, bool needTransition = true); 43 bool CleanPageStack(); 44 bool MovePageToFront(const RefPtr<FrameNode>& node, bool needHideLast = true, bool needTransition = true); 45 46 void StartTransition(const RefPtr<FrameNode>& srcPage, const RefPtr<FrameNode>& destPage, RouteType type); 47 48 static void FirePageHide(const RefPtr<UINode>& node, PageTransitionType transitionType = PageTransitionType::NONE); 49 static void FirePageShow(const RefPtr<UINode>& node, PageTransitionType transitionType = PageTransitionType::NONE); 50 51 RefPtr<FrameNode> GetLastPage(); 52 RefPtr<FrameNode> GetPageById(int32_t pageId); GetStageNode()53 const RefPtr<FrameNode> GetStageNode() const 54 { 55 return stageNode_; 56 } 57 58 void ReloadStage(); 59 60 private: 61 // ace performance check 62 void PerformanceCheck(const RefPtr<FrameNode>& pageNode, int64_t vsyncTimeout); 63 void StopPageTransition(); 64 65 RefPtr<FrameNode> stageNode_; 66 RefPtr<StagePattern> stagePattern_; 67 WeakPtr<FrameNode> destPageNode_; 68 WeakPtr<FrameNode> srcPageNode_; 69 70 ACE_DISALLOW_COPY_AND_MOVE(StageManager); 71 }; 72 } // namespace OHOS::Ace::NG 73 74 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_STAGE_STAGE_MANAGER_H 75