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