Slide transition for Page transition
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / public-api / transition / slide-transition.h
1 #ifndef DALI_TOOLKIT_SLIDE_TRANSITION_H
2 #define DALI_TOOLKIT_SLIDE_TRANSITION_H
3
4 /*
5  * Copyright (c) 2021 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <dali-toolkit/public-api/controls/control.h>
23 #include <dali-toolkit/public-api/transition/transition-base.h>
24
25 namespace Dali
26 {
27 namespace Toolkit
28 {
29 namespace Internal DALI_INTERNAL
30 {
31 class SlideTransition;
32 }
33
34 /**
35  * @brief Pre-defined directions to define where the control is comming from or going to.
36  */
37 namespace SlideTransitionDirection
38 {
39   static constexpr Vector2 TOP(0, -1); // TOP
40   static constexpr Vector2 BOTTOM(0,  1); // BOTTOM
41   static constexpr Vector2 LEFT(-1, 0); // LEFT
42   static constexpr Vector2 RIGHT(1,  0); // RIGHT
43 }
44
45 /**
46  * @brief SlideTransition provides smoothly appearing/disappearing effects for target Control.
47  * The direction the target Control is comming from or going to can be selected in the pre-defined directions. {UP, DOWN, LEFT, RIGHT}
48  * And, to use custom direction, the direction can be set CUSTOM and use SetDirection(Vector2) method.
49  */
50 class DALI_TOOLKIT_API SlideTransition : public TransitionBase
51 {
52 public:
53
54   /**
55    * @brief Creates an uninitialized SlideTransition; this can be initialized with SlideTransition::New().
56    *
57    * Calling member functions with an uninitialized SlideTransition handle is not allowed.
58    */
59   SlideTransition();
60
61   /**
62    * @brief Creates an initialized SlideTransition.
63    *
64    * @param[in] control A control of this transition.
65    * @param[in] direction Relative direction that the control is comming from or going to.
66    * @param[in] timePeriod The duration of the animation.
67    * @return A handle to a newly allocated Dali resource
68    */
69   static SlideTransition New(Dali::Toolkit::Control control, const Vector2& direction, TimePeriod timePeriod);
70
71   /**
72    * @brief Downcasts a handle to SlideTransition handle.
73    *
74    * If handle points to an SlideTransition object, the downcast produces valid handle.
75    * If not, the returned handle is left uninitialized.
76    *
77    * @param[in] handle Handle to an object
78    * @return Handle to an SlideTransition object or an uninitialized handle
79    */
80   static SlideTransition DownCast(BaseHandle handle);
81
82   /**
83    * @brief Destructor.
84    *
85    * This is non-virtual since derived Handle types must not contain data or virtual methods.
86    */
87   ~SlideTransition();
88
89   /**
90    * @brief This copy constructor is required for (smart) pointer semantics.
91    *
92    * @param[in] handle A reference to the copied handle
93    */
94   SlideTransition(const SlideTransition& handle);
95
96   /**
97    * @brief This assignment operator is required for (smart) pointer semantics.
98    *
99    * @param[in] rhs A reference to the copied handle
100    * @return A reference to this
101    */
102   SlideTransition& operator=(const SlideTransition& rhs);
103
104   /**
105    * @brief Move constructor.
106    *
107    * @param[in] rhs A reference to the moved handle
108    */
109   SlideTransition(SlideTransition&& rhs);
110
111   /**
112    * @brief Move assignment operator.
113    *
114    * @param[in] rhs A reference to the moved handle
115    * @return A reference to this handle
116    */
117   SlideTransition& operator=(SlideTransition&& rhs);
118
119   /**
120    * @brief Sets direction to be used to move target Control
121    *
122    * @param[in] direction Relative direction that the control is comming from or going to.
123    */
124   void SetDirection(const Vector2& direction);
125
126   /**
127    * @brief Retrieves direction to be used to move target Control
128    * 
129    * @note The direction is normalized Vector.
130    */
131   Vector2 GetDirection() const;
132
133 public: // Not intended for use by Application developers
134   /// @cond internal
135   /**
136    * @brief This constructor is used by SlideTransition::New() methods.
137    * @param[in] slideTransition A pointer to a newly allocated Dali resource
138    */
139   explicit DALI_INTERNAL SlideTransition(Internal::SlideTransition* slideTransition);
140   /// @endcond
141 };
142
143 } // namespace Toolkit
144
145 } // namespace Dali
146
147 #endif // DALI_TOOLKIT_SLIDE_TRANSITION_H