• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_BASE_PROPERTIES_PAGE_TRANSITION_OPTION_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_BASE_PROPERTIES_PAGE_TRANSITION_OPTION_H
18 
19 #include "base/utils/device_type.h"
20 #include "core/animation/curves.h"
21 #include "core/animation/interpolator.h"
22 #include "core/animation/keyframe.h"
23 #include "core/animation/keyframe_animation.h"
24 #include "core/animation/page_transition_listener.h"
25 #include "core/animation/shared_transition_effect.h"
26 #include "core/components/common/properties/tween_option.h"
27 #include "core/components/page_transition/page_transition_info.h"
28 #include "core/pipeline/pipeline_context.h"
29 
30 namespace OHOS::Ace {
31 
32 extern const int32_t TRANSITION_PHONE_DURATION;
33 extern const int32_t TRANSITION_WATCH_DURATION;
34 extern const int32_t TRANSITION_TV_DURATION;
35 extern const double TRANSITION_DEFAULT_WIDTH;
36 extern const double TRANSITION_DEFAULT_HEIGHT;
37 
38 enum class TransitionDirection {
39     TRANSITION_IN,
40     TRANSITION_OUT,
41 };
42 
43 class TransitionTweenOption : public AceType {
44 public:
45     TransitionTweenOption(bool isRightToLeft, const WeakPtr<PipelineContext>& context);
46     ~TransitionTweenOption() override = default;
47     const TweenOption& GetTransitionContentInOption() const;
48     const TweenOption& GetTransitionContentOutOption() const;
49     const TweenOption& GetTransitionBackgroundInOption() const;
50     const TweenOption& GetTransitionBackgroundOutOption() const;
51     const TweenOption& GetTransitionFrontDecorationOption() const;
52     const TweenOption& GetSharedTransitionFrontDecorationOption() const;
53     const TweenOption& GetSharedInOption() const;
54     const TweenOption& GetSharedOutOption() const;
55 
56 protected:
57     double deviceWidth_ = TRANSITION_DEFAULT_WIDTH;   // default device width
58     double deviceHeight_ = TRANSITION_DEFAULT_HEIGHT;   // default device height
59     double deviceViewScale_ = 1.0; // default device view scale
60     bool isRightToLeft_ = false; // default RTL config
61     WindowModal windowModal_ = WindowModal::NORMAL;
62     TweenOption contentInOption_;
63     TweenOption contentOutOption_;
64     TweenOption backgroundInOption_;
65     TweenOption backgroundOutOption_;
66     TweenOption frontDecorationOption_;
67     TweenOption sharedFrontDecorationOption_;
68     TweenOption sharedTransitionInOption_;
69     TweenOption sharedTransitionOutOption_;
70 };
71 
72 class TransitionTvTweenOption : public TransitionTweenOption {
73 public:
74     TransitionTvTweenOption(bool isRightToLeft, const WeakPtr<PipelineContext>& context);
75     ~TransitionTvTweenOption() override = default;
76 
77 private:
78     void CreateTransitionInOption();
79     void CreateTransitionInContentOption();
80     void CreateTransitionInBackgroundOption();
81     void CreateTransitionOutOption();
82     void CreateTransitionOutContentOption();
83     void CreateTransitionOutBackgroundOption();
84     static void CreatTransitionOutOption(TweenOption& option);
85 };
86 
87 class TransitionPhoneTweenOption : public TransitionTweenOption {
88 public:
89     TransitionPhoneTweenOption(TransitionEvent event, bool isRightToLeft, const WeakPtr<PipelineContext>& context);
90     TransitionPhoneTweenOption(TransitionEvent event, bool isRightToLeft, const RRect& rrect,
91         const WeakPtr<PipelineContext>& context);
92     ~TransitionPhoneTweenOption() override = default;
93 
94 private:
95     void CreateTransitionInOption(TransitionEvent event);
96     void CreateTransitionOutOption(TransitionEvent event);
97     void CreateDialogModalTransitionInOption(TransitionEvent event);
98     void CreateDialogModalTransitionOutOption(TransitionEvent event);
99     void CreateCardTransitionOutOption(TransitionEvent event);
100     void CreateCardTransitionInOption(TransitionEvent event, const RRect& rrect);
101     void CreateCornerAnimationInOption(TransitionEvent event, const RRect& rrect);
102     void CreateCardOpacityAnimationInOption(TransitionEvent event);
103 };
104 
105 class TransitionWatchTweenOption : public TransitionTweenOption {
106 public:
107     TransitionWatchTweenOption(TransitionEvent event, bool isRightToLeft, const WeakPtr<PipelineContext>& context);
108     ~TransitionWatchTweenOption() override = default;
109 
110 private:
111     void CreateTransitionInOption(TransitionEvent event);
112     void CreateTransitionOutOption(TransitionEvent event);
113 };
114 
115 class TransitionDeclarativeTweenOption final : public TransitionTweenOption {
116 public:
TransitionDeclarativeTweenOption(bool isRightToLeft,const WeakPtr<PipelineContext> & context)117     TransitionDeclarativeTweenOption(bool isRightToLeft, const WeakPtr<PipelineContext>& context)
118         : TransitionTweenOption(isRightToLeft, context)
119     {}
120     virtual ~TransitionDeclarativeTweenOption() = default;
121 
122     void CreateSlideEffectAnimation(
123         TweenOption& tweenOption, SlideEffect effect, PageTransitionType type, TransitionDirection direction);
124 };
125 
126 class TransitionTweenOptionFactory {
127 public:
128     static void CreateSharedTweenOption(SharedTransitionEffectType type, TweenOption& option);
129     static RefPtr<TransitionTweenOption> CreateTransitionTweenOption(DeviceType deviceType, TransitionEvent event,
130         bool isRightToLeft, const RRect& rect, const WeakPtr<PipelineContext>& context);
131 };
132 
133 } // namespace OHOS::Ace
134 
135 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_BASE_PROPERTIES_PAGE_TRANSITION_OPTION_H
136