Merge "Deprecate the public APIs taking Image as input" into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / transition-effects / cube-transition-effect.h
1 #ifndef DALI_TOOLKIT_CUBE_TRANSITION_EFFECT_H
2 #define DALI_TOOLKIT_CUBE_TRANSITION_EFFECT_H
3
4 /*
5  * Copyright (c) 2016 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
24 // EXTERNAL INCLUDES
25 #include <dali/public-api/rendering/texture.h>
26
27 namespace Dali
28 {
29
30 namespace Toolkit
31 {
32
33 namespace Internal DALI_INTERNAL
34 {
35
36 /**
37  * CubeTransitionEffect implementation class
38  */
39 class CubeTransitionEffect;
40
41 } // namespace Internal
42
43 /**
44  * CubeTransitionEffect is a base class of custom transition effect on Images
45  * The two images are partitioned into tiles and serves as two perpendicular faces of cubes
46  * By rotating these cubes to transit from one image to another
47  *
48  * Usage example:
49  *
50  * @code
51  *
52  * //create a new CubeTransitionEffect
53  * //use the New funtion of subclass ( CubeTransitionWaveEffect or CubeTransitionCrossEffect )
54  * CubeTransitionEffect cubeEffect = CubeTransitionWaveEffect::New(numRows, numColumns);
55  *
56  * //set the duration of transition animation
57  * cubeEffect.SetTransitionDuration( animationDuration );
58  *
59  * //set the displacement of bouncing movement during cube's rotation
60  * cubeEffect.SetCubeDisplacement( cubeDisplacement  );
61  *
62  * // Add to stage
63  * stage.Add( cubeEffect );
64  *
65  * // Set the current image,
66  * // only need to set at beginning or when the current image was transitioned to with no effect or other effect
67  * cubeEffect.SetCurrentImage( firstImage );
68  *
69  * // Set target image, paired with startTransition. These two steps would be repeated as needed
70  * cubeEffect.SetTargetimage( secondImage );
71  * // Activate the effect
72  * //   no param / param ture: default horizontally left panGesture
73  * //   or param false:  default horizontally right panGesture
74  * //   or params position & displacement: specified the panGesture
75  * cubeEffect.StartTransition( );
76  *
77  * @endcode
78  *
79  * Signals
80  * | %Signal Name        | Method                           |
81  * |---------------------|----------------------------------|
82  * | transitionCompleted | @ref TransitionCompletedSignal() |
83  */
84 class DALI_IMPORT_API CubeTransitionEffect : public Control
85 {
86 public:
87
88   /**
89    * Create an uninitialized CubeTransitionEffect;
90    * this can be initialized by New function of its subclass
91    */
92   CubeTransitionEffect();
93
94   /**
95    * Destructor
96    */
97   ~CubeTransitionEffect();
98
99   /**
100    * @brief Downcast an Object handle to a CubeTransitionEffect handle.
101    *
102    * If handle points to a CubeTransitionEffect object the downcast produces
103    * a valid handle. If not the returned handle is left uninitialized.
104    *
105    * @param[in] handle A handle to an object
106    * @return A handle to a CubeTransitionEffect object or an uninitialized handle
107    */
108   static CubeTransitionEffect DownCast( BaseHandle handle );
109
110   /**
111    * Set the duration of transition animation
112    * @param[in] duration The duration of transition animation
113    */
114   void SetTransitionDuration( float duration );
115
116   /**
117    * Get the duration of transition animation
118    * @return duration The duration of transition animation
119    */
120   float GetTransitionDuration() const;
121
122   /**
123    * Set the displacement of bouncing animation during cube's rotation
124    * @param[in] displacement The displacement of bouncing animation
125    */
126   void SetCubeDisplacement( float displacement );
127
128   /**
129    * Get the displacement of bouncing animation during cube's rotation
130    * @return displacement The displacement of bouncing animation
131    */
132   float GetCubeDisplacement() const;
133
134   /**
135    * Return the transition status
136    * @return True if the transition is under processing; false if finished
137    */
138   bool IsTransitioning();
139
140   /**
141    * Set the current texture to transition from
142    * if using this same effect continually, only need to set once
143    * @param[in] texture The current texture
144    */
145   void SetCurrentTexture( Texture texture );
146
147   /**
148    * Set the target texture to transit to
149    * @param[in] texture The new Texture showing on stage
150    */
151   void SetTargetTexture( Texture texture );
152
153   /**
154    * Activate the transition animation with horizontally left/right panGesture
155    * @pre target image is set
156    * @param[in] toNextImage Horizontally left panGesture if true, horizontally right if false
157    */
158   void StartTransition( bool toNextImage = true );
159
160   /**
161    * Activate the transition animation with specified panGesture
162    * @pre target image is set
163    * @param[in] panPosition The press down position of panGesture
164    * @param[in] panDisplacement The displacement vector of panGesture
165    */
166   void StartTransition( Vector2 panPosition, Vector2 panDisplacement );
167
168   /**
169    * Pause the transition animation.
170    * It does nothing if the animation is not running.
171    */
172   void PauseTransition();
173
174   /**
175    * Re-Activate the transition animation after it is paused by calling PauseTransition().
176    * It does nothing in other cases.
177    */
178   void ResumeTransition();
179
180   /**
181    * Inactivate the transition animation if it is running.
182    * Also set the rotation and position of cubes, colors of tile to the same as the start state when the animation if finished completely
183    * It does nothing if the animation is not running.
184    */
185   void StopTransition();
186
187 public: //Signal
188
189   //Transition animation completed signal
190   typedef Signal< void ( CubeTransitionEffect, Texture ) >  TransitionCompletedSignalType;
191
192   /**
193    * Signal emitted when the transition has completed animation
194    * A callback of the following type may be connected
195    * @code
196    *   void YourCallbackName( CubeTransitionEffect cubeEffect, Texture currentTexture );
197    * @endcode
198    * @return The Signal to connect to.
199    */
200   TransitionCompletedSignalType& TransitionCompletedSignal();
201
202 public: // Not intended for developer use
203
204   /**
205    * @brief Creates a handle using the Toolkit::Internal implementation.
206    *
207    * @param[in]  implementation  The Control implementation.
208    */
209   DALI_INTERNAL CubeTransitionEffect( Internal::CubeTransitionEffect& implementation );
210
211   /**
212    * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
213    *
214    * @param[in]  internal  A pointer to the internal CustomActor.
215    */
216   DALI_INTERNAL CubeTransitionEffect( Dali::Internal::CustomActor* internal );
217
218 }; //class CubeTransitionEffect
219
220 } // namespace Toolkit
221
222 } // namespace Dali
223
224 #endif // DALI_TOOLKIT_CUBE_TRANSITION_EFFECT_H