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