Conversion to Apache 2.0 license
[platform/core/uifw/dali-toolkit.git] / optional / dali-toolkit / public-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) 2014 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/dali.h>
23
24 namespace Dali DALI_IMPORT_API
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 Image actors
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, viewAreaSize);
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.GetRoot() );
61  *
62  * // Set the current image,
63  * // only need to set at beginning or when the current image was transited to with no effect or other effect
64  * cubeEffect.SetCurrentImage( firstImageActor );
65  *
66  * // Set target image, paired with startTransition. These two steps would be repeated as needed
67  * cubeEffect.SetTargetimage( secondImageActor );
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 class CubeTransitionEffect : public BaseHandle
77 {
78 public:
79
80   /**
81    * Create an uninitialized CubeTransitionEffect;
82    * this can be initialized by New function of its subclass
83    */
84   CubeTransitionEffect();
85
86   /**
87    * Destructor
88    */
89   ~CubeTransitionEffect();
90
91   /**
92    * Set the duration of transition animation
93    * @param[in] duration The duration of transition animation
94    */
95   void SetTransitionDuration( float duration );
96
97   /**
98    * Get the duration of transition animation
99    * @return duration The duration of transition animation
100    */
101   float GetTransitionDuration() const;
102
103   /**
104    * Set the displacement of bouncing animation during cube's rotation
105    * @param[in] displacement The displacement of bouncing animation
106    */
107   void SetCubeDisplacement( float displacement );
108
109   /**
110    * Getet the displacement of bouncing animation during cube's rotation
111    * @return displacement The displacement of bouncing animation
112    */
113   float GetCubeDisplacement() const;
114
115   /**
116    * Return the transition effect root actor, should then be added to stage
117    * @return The transition effect root actor
118    */
119   Actor GetRoot();
120
121   /**
122    * Return the transition status
123    * @return True if the transition is under processing; false if finished
124    */
125   bool IsTransiting();
126
127   /**
128    * Set the current image to transite from
129    * if using this same effect continuely, only need to set once
130    * @param[in] imageActor The current imageActor
131    */
132   void SetCurrentImage(ImageActor imageActor);
133
134   /**
135    * Set the target image to transit to
136    * @param[in] imageActor The new imageActor showing on stage
137    */
138   void SetTargetImage(ImageActor imageActor);
139
140   /**
141    * Activate the transition animation with horizontally left/right panGesture
142    * @pre target image is set
143    * @param[in] toNextImage Horizontally left panGesture if ture, horizontally right if false
144    */
145   void StartTransition( bool toNextImage = true );
146
147   /**
148    * Activate the transition animation with specified panGesture
149    * @pre target image is set
150    * @param[in] panPosition The press down position of panGesture
151    * @param[in] panDisplacement The displacement vector of panGesture
152    */
153   void StartTransition( Vector2 panPosition, Vector2 panDisplacement );
154
155   /**
156    * Pause the transition animation.
157    * It does nothing if the animation is not running.
158    */
159   void PauseTransition();
160
161   /**
162    * Re-Activate the transition animation after it is paused by calling PauseTransition().
163    * It does nothing in other cases.
164    */
165   void ResumeTransition();
166
167   /**
168    * Inactivate the transition animation if it is running.
169    * Also set the rotation and position of cubes, colors of tile to the same as the final state when the animation if finished completely
170    * It does nothing if the animation is not running.
171    */
172   void StopTransition();
173
174 public: //Signal
175
176   //signal name
177   static const char* const SIGNAL_TRANSITION_COMPLETED;
178
179   //Transition animation completed signal
180   typedef SignalV2< void ( CubeTransitionEffect, ImageActor ) > TransitionCompletedSignalV2;
181
182   /**
183    * Signal emitted when the transition has completed animation
184    * A callback of the following type may be connected
185    * @code
186    *   void YourCallbackName( CubeTransitionEffect cubeEffect, ImageActor currentImage );
187    * @endcode
188    * @return The Signal to connect to.
189    */
190   TransitionCompletedSignalV2& TransitionCompletedSignal();
191
192 public: // Not intended for developer use
193
194   CubeTransitionEffect( Internal::CubeTransitionEffect* impl );
195
196 }; //class CubeTransitionEffect
197
198 } // namespace Toolkit
199
200 } // namespace Dali
201
202 #endif /* __DALI_TOOLKIT_CUBE_TRANSITION_EFFECT_H__ */