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