1 /* 2 * Copyright (c) 2021 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_ANIMATION_CARD_TRANSITION_CONTROLLER_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_ANIMATION_CARD_TRANSITION_CONTROLLER_H 18 19 #include "base/memory/ace_type.h" 20 #include "core/animation/animation_pub.h" 21 #include "core/components/page/page_element.h" 22 #include "core/components/transform/render_transform.h" 23 #include "core/pipeline/pipeline_context.h" 24 25 namespace OHOS::Ace { 26 27 class Animator; 28 29 class CardTransitionController : public AceType { 30 DECLARE_ACE_TYPE(CardTransitionController, AceType); 31 32 public: 33 explicit CardTransitionController(const WeakPtr<PipelineContext>& context); 34 ~CardTransitionController() override = default; 35 void RegisterTransitionListener(); 36 RRect GetCardRect(const ComposeId& composeId) const; 37 GetAnimator()38 const RefPtr<Animator>& GetAnimator() const 39 { 40 return controller_; 41 } 42 43 private: 44 void PrepareTransition(); 45 void CreateCardAnimation(const RefPtr<Element>& cardComposeElement, const Offset& globalOffset, const RRect& rrect); 46 void CreateCardOpacityAnimation(RefPtr<RenderNode>& displayRender); 47 void CreateCardTranslateAnimation(const WeakPtr<RenderTransform>& weakTransform, const Offset& globalOffset, 48 const Offset& marginOffset); 49 void CreateCardScaleAnimation(const WeakPtr<RenderTransform>& weakTransform, const RRect& rrect); 50 void CreateCardListAnimation(const RefPtr<RenderNode>& renderNode); 51 void CreateExternalAnimation(double height, double cardOffsetY); 52 RefPtr<Element> GetCardTransformElement(const RefPtr<Element>& element); 53 void AddPrepareListener(const WeakPtr<RenderTransform>& weakTransform); 54 void AddStopListener(const WeakPtr<RenderTransform>& weakTransform); 55 56 WeakPtr<PipelineContext> context_; 57 WeakPtr<PageElement> pageDest_; 58 WeakPtr<PageElement> pageSrc_; 59 RefPtr<Animator> controller_; 60 TransitionEvent event_ { TransitionEvent::PUSH_START }; 61 uint64_t currentTimestamp_ = 0; 62 }; 63 64 } // namespace OHOS::Ace 65 66 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_ANIMATION_CARD_TRANSITION_CONTROLLER_H 67