1 #ifndef DALI_TOOLKIT_CUBE_TRANSITION_EFFECT_H
2 #define DALI_TOOLKIT_CUBE_TRANSITION_EFFECT_H
5 * Copyright (c) 2020 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-toolkit/public-api/controls/control.h>
23 #include <dali-toolkit/public-api/dali-toolkit-common.h>
26 #include <dali/public-api/rendering/texture.h>
32 namespace Internal DALI_INTERNAL
35 * CubeTransitionEffect implementation class
37 class CubeTransitionEffect;
39 } // namespace DALI_INTERNAL
42 * CubeTransitionEffect is a base class of custom transition effect on Images
43 * The two images are partitioned into tiles and serves as two perpendicular faces of cubes
44 * By rotating these cubes to transit from one image to another
50 * //create a new CubeTransitionEffect
51 * //use the New funtion of subclass ( CubeTransitionWaveEffect or CubeTransitionCrossEffect )
52 * CubeTransitionEffect cubeEffect = CubeTransitionWaveEffect::New(numRows, numColumns);
54 * //set the duration of transition animation
55 * cubeEffect.SetTransitionDuration( animationDuration );
57 * //set the displacement of bouncing movement during cube's rotation
58 * cubeEffect.SetCubeDisplacement( cubeDisplacement );
61 * stage.Add( cubeEffect );
63 * // Set the current image,
64 * // only need to set at beginning or when the current image was transitioned to with no effect or other effect
65 * cubeEffect.SetCurrentImage( firstImage );
67 * // Set target image, paired with startTransition. These two steps would be repeated as needed
68 * cubeEffect.SetTargetimage( secondImage );
69 * // Activate the effect
70 * // no param / param ture: default horizontally left panGesture
71 * // or param false: default horizontally right panGesture
72 * // or params position & displacement: specified the panGesture
73 * cubeEffect.StartTransition( );
78 * | %Signal Name | Method |
79 * |---------------------|----------------------------------|
80 * | transitionCompleted | @ref TransitionCompletedSignal() |
82 class DALI_TOOLKIT_API CubeTransitionEffect : public Control
86 * Create an uninitialized CubeTransitionEffect;
87 * this can be initialized by New function of its subclass
89 CubeTransitionEffect();
94 ~CubeTransitionEffect();
97 * @brief Downcast an Object handle to a CubeTransitionEffect handle.
99 * If handle points to a CubeTransitionEffect object the downcast produces
100 * a valid handle. If not the returned handle is left uninitialized.
102 * @param[in] handle A handle to an object
103 * @return A handle to a CubeTransitionEffect object or an uninitialized handle
105 static CubeTransitionEffect DownCast(BaseHandle handle);
108 * Set the duration of transition animation
109 * @param[in] duration The duration of transition animation
111 void SetTransitionDuration(float duration);
114 * Get the duration of transition animation
115 * @return duration The duration of transition animation
117 float GetTransitionDuration() const;
120 * Set the displacement of bouncing animation during cube's rotation
121 * @param[in] displacement The displacement of bouncing animation
123 void SetCubeDisplacement(float displacement);
126 * Get the displacement of bouncing animation during cube's rotation
127 * @return displacement The displacement of bouncing animation
129 float GetCubeDisplacement() const;
132 * Return the transition status
133 * @return True if the transition is under processing; false if finished
135 bool IsTransitioning();
138 * Set the current texture to transition from
139 * if using this same effect continually, only need to set once
140 * @param[in] texture The current texture
142 void SetCurrentTexture(Texture texture);
145 * Set the target texture to transit to
146 * @param[in] texture The new Texture showing on stage
148 void SetTargetTexture(Texture texture);
151 * Activate the transition animation with horizontally left/right panGesture
152 * @pre target image is set
153 * @param[in] toNextImage Horizontally left panGesture if true, horizontally right if false
155 void StartTransition(bool toNextImage = true);
158 * Activate the transition animation with specified panGesture
159 * @pre target image is set
160 * @param[in] panPosition The press down position of panGesture
161 * @param[in] panDisplacement The displacement vector of panGesture
163 void StartTransition(Vector2 panPosition, Vector2 panDisplacement);
166 * Pause the transition animation.
167 * It does nothing if the animation is not running.
169 void PauseTransition();
172 * Re-Activate the transition animation after it is paused by calling PauseTransition().
173 * It does nothing in other cases.
175 void ResumeTransition();
178 * Inactivate the transition animation if it is running.
179 * Also set the rotation and position of cubes, colors of tile to the same as the start state when the animation if finished completely
180 * It does nothing if the animation is not running.
182 void StopTransition();
185 //Transition animation completed signal
186 typedef Signal<void(CubeTransitionEffect, Texture)> TransitionCompletedSignalType;
189 * Signal emitted when the transition has completed animation
190 * A callback of the following type may be connected
192 * void YourCallbackName( CubeTransitionEffect cubeEffect, Texture currentTexture );
194 * @return The Signal to connect to.
196 TransitionCompletedSignalType& TransitionCompletedSignal();
198 public: // Not intended for developer use
200 * @brief Creates a handle using the Toolkit::Internal implementation.
202 * @param[in] implementation The Control implementation.
204 DALI_INTERNAL CubeTransitionEffect(Internal::CubeTransitionEffect& implementation);
207 * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
209 * @param[in] internal A pointer to the internal CustomActor.
211 DALI_INTERNAL CubeTransitionEffect(Dali::Internal::CustomActor* internal);
213 }; //class CubeTransitionEffect
215 } // namespace Toolkit
219 #endif // DALI_TOOLKIT_CUBE_TRANSITION_EFFECT_H