1 #ifndef DALI_TOOLKIT_INTERNAL_CUBE_TRANSITION_EFFECT_H
2 #define DALI_TOOLKIT_INTERNAL_CUBE_TRANSITION_EFFECT_H
5 * Copyright (c) 2021 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>
33 class CubeTransitionEffect;
38 * CubeTransitionEffect implementation class
40 class CubeTransitionEffect : public Control
46 ~CubeTransitionEffect();
49 * @copydoc Toolkit::CubeTransitionEffect::SetTransitionDuration
51 void SetTransitionDuration(float duration);
54 * @copydoc Toolkit::CubeTransitionEffect::GetTransitionDuration
56 float GetTransitionDuration() const;
59 * @copydoc Toolkit::CubeTransitionEffect::SetCubeDisplacement
61 void SetCubeDisplacement(float displacement);
64 * @copydoc Toolkit::CubeTransitionEffect::GetCubeDisplacement
66 float GetCubeDisplacement() const;
69 * @copydoc Toolkit::CubeTransitionEffect::IsTransitioning
71 bool IsTransitioning();
74 * @copydoc Toolkit::CubeTransitionEffect::SetCurrentTexture
76 void SetCurrentTexture(Texture texture);
79 * @copydoc Toolkit::CubeTransitionEffect::SetTargetTexture
81 void SetTargetTexture(Texture texture);
84 * @copydoc Toolkit::CubeTransitionEffect::StartTransition(bool)
86 void StartTransition(bool toNextImage = true);
89 * @copydoc Toolkit::CubeTransitionEffect::StartTransition(Vector2, Vector2)
91 void StartTransition(Vector2 panPosition, Vector2 panDisplacement);
94 * @copydoc Toolkit::CubeTransitionEffect::PauseTransition()
96 void PauseTransition();
99 * @copydoc Toolkit::CubeTransitionEffect::ResumeTransition()
101 void ResumeTransition();
104 * @copydoc Toolkit::CubeTransitionEffect::StopTransition()
106 void StopTransition();
110 * @copydoc Toolkit::CubeTransitionEffect::TransitionCompletedSignal()
112 Toolkit::CubeTransitionEffect::TransitionCompletedSignalType& TransitionCompletedSignal();
115 * Connects a callback function with the object's signals.
116 * @param[in] object The object providing the signal.
117 * @param[in] tracker Used to disconnect the signal.
118 * @param[in] signalName The signal to connect to.
119 * @param[in] functor A newly allocated FunctorDelegate.
120 * @return True if the signal was connected.
121 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
123 static bool DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor);
127 * @copydoc CustomActorImpl::OnSceneConnection()
129 void OnSceneConnection(int depth) override;
132 * @copydoc CustomActorImpl::OnSceneDisconnection()
134 void OnSceneDisconnection() override;
138 * Construct a new CubeTransitionEffect object
139 * Called in the constructor of subclasses
140 * @param[in] numRows How many rows of cubes
141 * @param[in] numColumns How many columns of cubes
143 CubeTransitionEffect(unsigned int numRows, unsigned int numColumns);
146 * Initialization steps: creating a layer, two groups of tiles,
147 * and one group of actors (cubes) serving as parents of every two tiles (one from each image).
152 void SetTargetLeft(unsigned int idx);
153 void SetTargetRight(unsigned int idx);
154 void SetTargetTop(unsigned int idx);
155 void SetTargetBottom(unsigned int idx);
159 * Callback function of transition animation finished
160 * Hide transition layer, show current image, and set isAnimating flag to false
161 * @param[in] source The cube transition animation
163 void OnTransitionFinished(Animation& source);
166 * This method is called after the CubeTransitionEffect has been initialized. Derived classes should do
167 * any second phase initialization by overriding this method.
169 virtual void OnInitialize()
174 * This method is called after the a new transition is activated.
175 * Derived classes should do any specialized transition process by overriding this method.
176 * @param[in] panPosition The press down position of panGesture
177 * @param[in] panDisplacement The displacement vector of panGesture
179 virtual void OnStartTransition(Vector2 panPosition, Vector2 panDisplacement)
184 * This method is called when the transition is forced stop in the middle of animation.
185 * Derived classed should set the rotation status of the cubes to the same as the final state when the animation is finished completely.
186 * So that the next transition would be started correctly.
188 virtual void OnStopTransition()
192 void OnRelayout(const Vector2& size, RelayoutContainer& container) override;
194 void ResetToInitialState();
197 typedef std::vector<Actor> ActorArray;
207 Vector<FACE> mBoxType;
208 ActorArray mCurrentTiles;
209 ActorArray mTargetTiles;
214 unsigned int mColumns;
216 Renderer mCurrentRenderer;
217 Renderer mTargetRenderer;
219 Texture mCurrentTexture;
220 Texture mTargetTexture;
222 Animation mAnimation;
229 float mAnimationDuration;
230 float mCubeDisplacement;
232 static const Vector4 FULL_BRIGHTNESS;
233 static const Vector4 HALF_BRIGHTNESS;
236 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