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_COMPONENTS_PAGE_TRANSITION_PAGE_TRANSITION_ELEMENT_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_PAGE_TRANSITION_PAGE_TRANSITION_ELEMENT_H 18 19 #include "core/components/box/box_element.h" 20 #include "core/components/common/properties/page_transition_option.h" 21 #include "core/components/page_transition/page_transition_info.h" 22 #include "core/components/stack/stack_component.h" 23 #include "core/components/stack/stack_element.h" 24 #include "core/components/transition/transition_element.h" 25 #include "core/components/tween/tween_element.h" 26 27 namespace OHOS::Ace { 28 29 class ACE_EXPORT PageTransitionElement : public StackElement { 30 DECLARE_ACE_TYPE(PageTransitionElement, StackElement); 31 32 public: 33 void Update() override; 34 void PerformBuild() override; 35 36 void SetTransitionDirection(TransitionEvent event, TransitionDirection direction); 37 void SetTransitionController(); 38 const RefPtr<Animator>& GetTransitionController() const; 39 void LoadTransition(); 40 void ResetPageTransitionAnimation(); 41 void SetTransition(DeviceType deviceType, TransitionEvent event, TransitionDirection direction, 42 const RRect& rrect); 43 void SetWrapHidden(bool hidden); 44 void AddPreFlush(); 45 void SkipPostFlush(); 46 void InitController(TransitionDirection direction, TransitionEvent event); 47 RefPtr<Element> GetContentElement() const; 48 const RefPtr<TransitionElement>& GetContentTransitionElement() const; 49 const RefPtr<TransitionElement>& GetBackgroundTransitionElement() const; 50 void SetTouchable(bool enable); 51 void InitTransitionClip(); 52 TweenOption ProcessPageTransition(const RefPtr<PageTransition>& pageTransition, TransitionEvent event); 53 RefPtr<PageTransition> GetCurrentPageTransition(TransitionEvent event, TransitionDirection direction) const; SetDeclarativeDirection(TransitionDirection direction)54 void SetDeclarativeDirection(TransitionDirection direction) 55 { 56 direction_ = direction; 57 } GetIsCustomOption()58 bool GetIsCustomOption() const 59 { 60 return isCustomOption_; 61 } 62 63 // element only support page now 64 static RefPtr<PageTransitionElement> GetTransitionElement(const RefPtr<Element>& element); 65 static PageTransitionType GetPageTransitionType(TransitionEvent event, TransitionDirection direction); 66 67 private: 68 void UpdateTransitionOption(); 69 void BuildSeparatedChild(const RefPtr<StackComponent>& component); 70 void BuildCombinedChild(const RefPtr<StackComponent>& component); 71 72 RefPtr<TransitionElement> contentTransition_; // element to animate page content 73 RefPtr<TransitionElement> backgroundTransition_; // element to animate background 74 RefPtr<TransitionElement> frontDecorationTransition_; // element to animate front decoration opacity 75 RefPtr<Animator> controller_; // animator for content and background 76 TweenOption contentInOption_; 77 TweenOption contentOutOption_; 78 TweenOption sharedInOption_; 79 TweenOption sharedOutOption_; 80 bool isRightToLeft_ = false; 81 bool isCustomOptionOut_ = false; 82 bool isCustomOptionIn_ = false; 83 std::unordered_map<PageTransitionType, RefPtr<PageTransition>> pageTransitions_; 84 TransitionDirection direction_ = TransitionDirection::TRANSITION_IN; 85 bool isCustomOption_ = false; 86 RefPtr<Animation<float>> floatAnimation_; 87 }; 88 89 } // namespace OHOS::Ace 90 91 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_PAGE_TRANSITION_PAGE_TRANSITION_ELEMENT_H 92