1 #ifndef DALI_TOOLKIT_INTERNAL_CUBE_TRANSITION_EFFECT_H
2 #define DALI_TOOLKIT_INTERNAL_CUBE_TRANSITION_EFFECT_H
5 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali/public-api/animation/animation.h>
23 #include <dali/public-api/rendering/renderer.h>
26 #include <dali-toolkit/devel-api/transition-effects/cube-transition-effect.h>
27 #include <dali-toolkit/public-api/controls/control-impl.h>
35 class CubeTransitionEffect;
41 * CubeTransitionEffect implementation class
43 class CubeTransitionEffect : public Control
51 ~CubeTransitionEffect();
54 * @copydoc Toolkit::CubeTransitionEffect::SetTransitionDuration
56 void SetTransitionDuration( float duration );
59 * @copydoc Toolkit::CubeTransitionEffect::GetTransitionDuration
61 float GetTransitionDuration() const;
64 * @copydoc Toolkit::CubeTransitionEffect::SetCubeDisplacement
66 void SetCubeDisplacement( float displacement );
69 * @copydoc Toolkit::CubeTransitionEffect::GetCubeDisplacement
71 float GetCubeDisplacement() const;
74 * @copydoc Toolkit::CubeTransitionEffect::IsTransitioning
76 bool IsTransitioning();
79 * @copydoc Toolkit::CubeTransitionEffect::SetCurrentTexture
81 void SetCurrentTexture( Texture texture );
84 * @copydoc Toolkit::CubeTransitionEffect::SetTargetTexture
86 void SetTargetTexture( Texture texture );
89 * @copydoc Toolkit::CubeTransitionEffect::StartTransition(bool)
91 void StartTransition( bool toNextImage = true );
94 * @copydoc Toolkit::CubeTransitionEffect::StartTransition(Vector2, Vector2)
96 void StartTransition( Vector2 panPosition, Vector2 panDisplacement );
99 * @copydoc Toolkit::CubeTransitionEffect::PauseTransition()
101 void PauseTransition();
104 * @copydoc Toolkit::CubeTransitionEffect::ResumeTransition()
106 void ResumeTransition();
109 * @copydoc Toolkit::CubeTransitionEffect::StopTransition()
111 void StopTransition();
116 * @copydoc Toolkit::CubeTransitionEffect::TransitionCompletedSignal()
118 Toolkit::CubeTransitionEffect::TransitionCompletedSignalType& TransitionCompletedSignal();
121 * Connects a callback function with the object's signals.
122 * @param[in] object The object providing the signal.
123 * @param[in] tracker Used to disconnect the signal.
124 * @param[in] signalName The signal to connect to.
125 * @param[in] functor A newly allocated FunctorDelegate.
126 * @return True if the signal was connected.
127 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
129 static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
133 * @copydoc CustomActorImpl::OnStageConnection()
135 virtual void OnStageConnection( int depth );
138 * @copydoc CustomActorImpl::OnStageDisconnection()
140 virtual void OnStageDisconnection();
145 * Construct a new CubeTransitionEffect object
146 * Called in the constructor of subclasses
147 * @param[in] numRows How many rows of cubes
148 * @param[in] numColumns How many columns of cubes
150 CubeTransitionEffect( unsigned int numRows, unsigned int numColumns );
153 * Initialization steps: creating a layer, two groups of tiles,
154 * and one group of actors (cubes) serving as parents of every two tiles (one from each image).
160 void SetTargetLeft( unsigned int idx );
161 void SetTargetRight( unsigned int idx );
162 void SetTargetTop( unsigned int idx );
163 void SetTargetBottom( unsigned int idx );
168 * Callback function of transition animation finished
169 * Hide transition layer, show current image, and set isAnimating flag to false
170 * @param[in] source The cube transition animation
172 void OnTransitionFinished(Animation& source);
175 * This method is called after the CubeTransitionEffect has been initialized. Derived classes should do
176 * any second phase initialization by overriding this method.
178 virtual void OnInitialize() { }
181 * This method is called after the a new transition is activated.
182 * Derived classes should do any specialized transition process by overriding this method.
183 * @param[in] panPosition The press down position of panGesture
184 * @param[in] panDisplacement The displacement vector of panGesture
186 virtual void OnStartTransition( Vector2 panPosition, Vector2 panDisplacement ) {}
189 * This method is called when the transition is forced stop in the middle of animation.
190 * Derived classed should set the rotation status of the cubes to the same as the final state when the animation is finished completely.
191 * So that the next transition would be started correctly.
193 virtual void OnStopTransition() {}
195 virtual void OnRelayout( const Vector2& size, RelayoutContainer& container );
197 void ResetToInitialState();
201 typedef std::vector< Actor > ActorArray;
202 enum FACE { TOP, BOTTOM, LEFT, RIGHT };
205 Vector< FACE > mBoxType;
206 ActorArray mCurrentTiles;
207 ActorArray mTargetTiles;
212 unsigned int mColumns;
214 Renderer mCurrentRenderer;
215 Renderer mTargetRenderer;
217 Texture mCurrentTexture;
218 Texture mTargetTexture;
220 Animation mAnimation;
227 float mAnimationDuration;
228 float mCubeDisplacement;
230 static const Vector4 FULL_BRIGHTNESS;
231 static const Vector4 HALF_BRIGHTNESS;
235 Toolkit::CubeTransitionEffect::TransitionCompletedSignalType mTransitionCompletedSignal;
239 } // namespace Internal
241 // Helpers for public-api forwarding methods
243 inline Internal::CubeTransitionEffect& GetImpl(Dali::Toolkit::CubeTransitionEffect& obj)
245 DALI_ASSERT_ALWAYS(obj);
247 Dali::RefObject& handle = obj.GetImplementation();
249 return static_cast<Internal::CubeTransitionEffect&>(handle);
252 inline const Internal::CubeTransitionEffect& GetImpl(const Dali::Toolkit::CubeTransitionEffect& obj)
254 DALI_ASSERT_ALWAYS(obj);
256 const Dali::RefObject& handle = obj.GetImplementation();
258 return static_cast<const Internal::CubeTransitionEffect&>(handle);
261 } // namespace Toolkit
265 #endif // DALI_TOOLKIT_INTERNAL_CUBE_TRANSITION_EFFECT_H