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_MANAGER_SHARED_OVERLAY_SHARED_OVERLAY_MANAGER_H
17  #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MANAGER_SHARED_OVERLAY_SHARED_OVERLAY_MANAGER_H
18  
19  #include "base/memory/ace_type.h"
20  #include "base/memory/referenced.h"
21  #include "base/utils/noncopyable.h"
22  #include "core/animation/animator.h"
23  #include "core/components_ng/manager/shared_overlay/shared_transition_effect.h"
24  
25  namespace OHOS::Ace::NG {
26  class FrameNode;
27  
28  // SharedOverlayManager is for root render node to perform shared transition.
29  class ACE_EXPORT SharedOverlayManager : public AceType {
30      DECLARE_ACE_TYPE(SharedOverlayManager, AceType);
31  
32  public:
SharedOverlayManager(const RefPtr<FrameNode> & sharedManager)33      explicit SharedOverlayManager(const RefPtr<FrameNode>& sharedManager) : sharedManager_(sharedManager) {};
34      ~SharedOverlayManager() override = default;
35  
36      void StartSharedTransition(const RefPtr<FrameNode>& pageSrc, const RefPtr<FrameNode>& pageDest);
37      void StopSharedTransition();
38      bool OnBackPressed();
39  
40  private:
41      void PrepareSharedTransition(const RefPtr<FrameNode>& pageSrc, const RefPtr<FrameNode>& pageDest);
42      void ClearAllEffects();
43      void CheckAndPrepareTransition(std::list<RefPtr<SharedTransitionEffect>>& effects,
44          std::list<RefPtr<SharedTransitionEffect>>& effectiveEffects);
45      bool PrepareEachTransition(const RefPtr<SharedTransitionEffect>& effect);
46      bool CheckIn(const RefPtr<SharedTransitionEffect>& effect);
47      bool AboardShuttle(const RefPtr<SharedTransitionEffect>& effect);
48      void GetOffShuttle(const RefPtr<SharedTransitionEffect>& effect);
49      void PassengerAboard(const RefPtr<SharedTransitionEffect>& effect, const RefPtr<FrameNode>& passenger);
50  
51      RefPtr<FrameNode> sharedManager_;
52      OffsetF pageOffset_;
53      std::list<RefPtr<SharedTransitionEffect>> effects_;
54  
55      ACE_DISALLOW_COPY_AND_MOVE(SharedOverlayManager);
56  };
57  } // namespace OHOS::Ace::NG
58  
59  #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MANAGER_SHARED_OVERLAY_SHARED_OVERLAY_MANAGER_H
60