• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "core/components_ng/pattern/stage/stage_pattern.h"
27 
28 namespace OHOS::Ace::NG {
29 class FrameNode;
30 class OverlayManager;
31 
32 // StageManager is the base class for root render node to perform page switch.
33 class ACE_FORCE_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     // PushUrl and ReplaceUrl both use PushPage function
41     virtual bool PushPage(const RefPtr<FrameNode>& node, bool needHideLast = true, bool needTransition = true);
42     virtual bool PopPage(bool needShowNext = true, bool needTransition = true);
43     virtual bool PopPageToIndex(int32_t index, bool needShowNext = true, bool needTransition = true);
44     virtual bool CleanPageStack();
45     virtual bool MovePageToFront(const RefPtr<FrameNode>& node, bool needHideLast = true, bool needTransition = true);
46 
47     virtual void StartTransition(const RefPtr<FrameNode>& srcPage, const RefPtr<FrameNode>& destPage, RouteType type);
48 
49     void PageChangeCloseKeyboard();
50 
51     static void FirePageHide(const RefPtr<UINode>& node, PageTransitionType transitionType = PageTransitionType::NONE);
52     static void FirePageShow(const RefPtr<UINode>& node, PageTransitionType transitionType = PageTransitionType::NONE,
53         bool needFocus = true);
54 
55     virtual RefPtr<FrameNode> GetLastPage() const;
56     RefPtr<FrameNode> GetPageById(int32_t pageId);
GetStageNode()57     const RefPtr<FrameNode> GetStageNode() const
58     {
59         return stageNode_;
60     }
61 
62     void ReloadStage();
63 
64     virtual RefPtr<FrameNode> GetLastPageWithTransition() const;
65     virtual RefPtr<FrameNode> GetPrevPageWithTransition() const;
66 
GetFocusPage()67     virtual RefPtr<FrameNode> GetFocusPage() const
68     {
69         return nullptr;
70     }
71 
SetStageInTrasition(bool stageInTrasition)72     void SetStageInTrasition (bool stageInTrasition) {
73         stageInTrasition_ = stageInTrasition;
74     }
75 
76 #if defined(ENABLE_SPLIT_MODE)
IsNewPageReplacing()77     bool IsNewPageReplacing() const
78     {
79         return isNewPageReplacing_;
80     }
81 
SetIsNewPageReplacing(bool replacing)82     void SetIsNewPageReplacing(bool replacing)
83     {
84         isNewPageReplacing_ = replacing;
85     }
86 #endif
87 
88     virtual void SyncPageSafeArea(bool keyboardSafeArea);
89 
90     virtual bool CheckPageFocus();
91 
92 protected:
93     // ace performance check
94     void PerformanceCheck(const RefPtr<FrameNode>& pageNode, int64_t vsyncTimeout, std::string path);
95     void StopPageTransition();
96     void FireAutoSave(const RefPtr<FrameNode>& outPageNode, const RefPtr<FrameNode>& inPageNode);
97     void AddPageTransitionTrace(const RefPtr<FrameNode>& srcPage, const RefPtr<FrameNode>& destPage);
98 
99     RefPtr<FrameNode> stageNode_;
100     RefPtr<StagePattern> stagePattern_;
101     WeakPtr<FrameNode> destPageNode_;
102     WeakPtr<FrameNode> srcPageNode_;
103     bool stageInTrasition_ = false;
104 #if defined(ENABLE_SPLIT_MODE)
105     bool isNewPageReplacing_ = false;
106 #endif
107 
108     ACE_DISALLOW_COPY_AND_MOVE(StageManager);
109 };
110 } // namespace OHOS::Ace::NG
111 
112 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_STAGE_STAGE_MANAGER_H
113