2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://floralicense.org/license/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FUiAnimAnimationTransaction.h
20 * @brief This is the header file for the %AnimationTransaction class.
22 * This header file contains the declarations of the %AnimationTransaction class.
25 #ifndef _FUI_ANIM_ANIMATION_TRANSACTION_H_
26 #define _FUI_ANIM_ANIMATION_TRANSACTION_H_
28 #include <FBaseTypes.h>
29 #include <FBaseObject.h>
31 #include <FUiAnimAnimationBase.h>
32 #include <FUiAnimVisualElementAnimation.h>
33 #include <FUiAnimIAnimationTransactionEventListener.h>
36 namespace Tizen { namespace Ui { namespace Animations
39 class IVisualElementAnimationTimingFunction;
40 class IVisualElementAnimationValueInterpolator;
43 * @class AnimationTransaction
44 * @brief This class defines the transaction operations of the animation.
48 * The %AnimationTransaction class enables the applications to define animation transactions that make a set of animations on one or more animators to start or stop at the same time.
50 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/ui/transactions.htm">Transactions</a>.
53 class _OSP_EXPORT_ AnimationTransaction
58 * Initializes a transaction set. @n
59 * Calls ControlAnimator::StartUserAnimation() or calls VisualElement::AddAnimation()
60 * after calling the %Begin() method and before calling the CommitTransaction() method.
61 * Nesting of the transaction set is allowed.
65 * @return An error code
66 * @exception E_SUCCESS The method is successful.
67 * @exception E_OUT_OF_MEMORY The memory is insufficient.
69 static result Begin(void);
73 * Initializes a transaction set. @n
74 * Calls ControlAnimator::StartUserAnimation() or calls VisualElement::AddAnimation()
75 * after calling the %Begin() method and before calling the CommitTransaction() method.
76 * Nesting of the transaction set is allowed.
80 * @return An error code
81 * @param[out] transactionId The transaction ID @n
82 * Use this transaction ID for further operations related to this transaction.
83 * @exception E_SUCCESS The method is successful.
84 * @exception E_OUT_OF_MEMORY The memory is insufficient.
86 static result Begin(int& transactionId);
90 * Commits a set of animation start commands that are added during the current transaction.
94 * @return An error code
95 * @exception E_SUCCESS The method is successful.
96 * @exception E_OUT_OF_MEMORY The memory is insufficient.
98 static result Commit(void);
102 * Stops the transaction. @n
103 * All the nested transactions also will be stopped.
107 * @return An error code
108 * @param[in] transactionId The transaction ID
109 * @exception E_SUCCESS The method is successful.
110 * @exception E_INVALID_ARG The specified input parameter is invalid.
112 static result Stop(int transactionId);
116 * Discards all inactive transactions.
120 * @return An error code
121 * @exception E_SUCCESS The method is successful.
122 * @exception E_INVALID_OPERATION An uncommitted transaction does not exist.
125 static result Discard(void);
129 * Gets the status of the specified transaction.
133 * @return The state of the transaction
134 * @param[in] transactionId The transaction ID
135 * @exception E_SUCCESS The method is successful.
136 * @exception E_INVALID_ARG The specified input parameter is invalid.
137 * @remarks The specific error code can be accessed using the GetLastResult() method.
139 static AnimationTransactionStatus GetStatus(int transactionId);
143 * Sets a default event listener to listen to the events of transactions. @n
144 * The set listener can listen to the events on the specified event dispatcher's context when they are fired.
148 * @return An error code
149 * @param[in] pListener The listener to add
150 * @exception E_SUCCESS The method is successful.
151 * @remarks Only one event listener can be set. @n
152 * If @c pListener is @c null, the listener already set is unregistered. @n
153 * An application must deregister the registered listener if the listener object needs to be deleted.
154 * @see SetCurrentTransactionEventListener()
156 static result SetTransactionEventListener(IAnimationTransactionEventListener* pListener);
160 * Sets a listener instance to listen to the events of a current transaction. @n
161 * The set listener can listen to the events on the specified event dispatcher's context when they are fired.
165 * @return An error code
166 * @param[in] pListener The listener to set
167 * @exception E_SUCCESS The method is successful.
168 * @exception E_INVALID_OPERATION An uncommitted transaction does not exist.
169 * @remarks If the listener is set using this method, the set default listener is not called.
170 * @see SetTransactionEventListener()
172 static result SetCurrentTransactionEventListener(IAnimationTransactionEventListener* pListener);
176 * Enables or disables the implicit animation on the current transaction. @n
177 * If enabled, implicit animations may be created whenever animatable properties of this instance change.
181 * @return An error code
182 * @param[in] enable Set to @c true to enable the implicit animation, @n
184 * @exception E_SUCCESS The method is successful.
185 * @exception E_INVALID_OPERATION An uncommitted transaction does not exist.
186 * @remarks The nested transaction created after invoking this method will inherit @c enable as the default value.
187 * @remarks Deciding whether to enable implicit animation depends on both the flag of transaction and the flag of VisualElement.
188 * If both SetVisualElementImplicitAnimationEnabled() and VisualElement::SetImplicitAnimationEnabled() are set to @c true, @n
189 * implicit animation is enabled.
191 static result SetVisualElementImplicitAnimationEnabled(bool enable);
195 * Sets a default event listener to get the status of an animation. @n
196 * The IVisualElementAnimationStatusEventListener listener is called for status changes of animation.
197 * The added listener listens to events on the specified event dispatcher's context when they are fired.
201 * @return An error code
202 * @param[in] pListener The pointer of listener instance to set
203 * @exception E_SUCCESS The method is successful.
204 * @exception E_INVALID_OPERATION An uncommitted transaction does not exist.
205 * @remarks This is used as the default value for the newly created VisualElementAnimation class or its descendant classes in the current transaction.
207 static result SetVisualElementAnimationStatusEventListener(IVisualElementAnimationStatusEventListener* pListener);
211 * Sets the default timing function of an animation.
215 * @return An error code
216 * @param[in] pTimingFunction The reference of interpolator instance to set
217 * @exception E_SUCCESS The method is successful.
218 * @exception E_INVALID_OPERATION An uncommitted transaction does not exist.
219 * @remarks This is used as the default value for the newly created VisualElementAnimation class or its descendant classes in the current transaction.
221 static result SetVisualElementAnimationTimingFunction(const IVisualElementAnimationTimingFunction* pTimingFunction);
225 * Sets the default value interpolator of an animation.
229 * @return An error code
230 * @param[in] pValueInterpolator The reference of InterpolatorFunction instance to set
231 * @exception E_SUCCESS The method is successful.
232 * @exception E_INVALID_OPERATION An uncommitted transaction does not exist.
233 * @remarks This is used as the default value for the newly created VisualElementAnimation class or its descendant classes in the current transaction.
235 static result SetVisualElementAnimationValueInterpolator(const IVisualElementAnimationValueInterpolator* pValueInterpolator);
239 * Sets the default duration of an animation in the current transaction.
243 * @return An error code
244 * @param[in] milliseconds The duration of the animation in milliseconds
245 * @exception E_SUCCESS The method is successful.
246 * @exception E_INVALID_OPERATION An uncommitted transaction does not exist.
247 * @exception E_INVALID_ARG The value of the specified parameter is negative or lesser than the offset of the animation.
248 * @remarks This is used as the default value for the newly created VisualElementAnimation class or its descendant classes in the current transaction.
249 * @see GetVisualElementAnimationDuration()
251 static result SetVisualElementAnimationDuration(long milliseconds);
255 * Gets the default duration of an animation in milliseconds in the current transaction.
259 * @return The duration value of the animation
260 * @exception E_SUCCESS The method is successful.
261 * @exception E_INVALID_OPERATION An uncommitted transaction does not exist.
262 * @remarks The specific error code can be accessed using the GetLastResult() method.
263 * @remarks This is used as the default value for the newly created VisualElementAnimation class or its descendant classes in the current transaction.
264 * @see SetVisualElementAnimationDuration()
266 static long GetVisualElementAnimationDuration(void);
270 * Sets the default offset value of an animation. @n
271 * Additionally, the %SetVisualElementAnimationOffset() method alters the start value and duration for which an animation is played.
275 * @return An error code
276 * @param[in] milliseconds The offset value of the animation in milliseconds
277 * @exception E_SUCCESS The method is successful.
278 * @exception E_INVALID_OPERATION An uncommitted transaction does not exist.
279 * @exception E_INVALID_ARG The value of the specified parameter is negative or greater than the duration of the animation.
280 * @remarks If the start value of the animation is @c 0.0, the end value is @c 1.0, the duration is @c 100 ms and the offset value is @c 20 ms,
281 * the actual animation starts at @c 0th ms and plays for @c 80 ms with a start value of @c 0.2. @n
282 * If @c autoReverse is set to @c true, the Backward animation plays for @c 100ms, from @c 1.0 to @c 0.0.
283 * @remarks This is used as the default value for the newly created VisualElementAnimation class or its descendant classes in the current transaction.
284 * @see GetVisualElementAnimationOffset()
286 static result SetVisualElementAnimationOffset(long milliseconds);
290 * Gets the default offset value in milliseconds after an animation starts.
294 * @return The offset value of the animation in milliseconds @n
295 * The default value of the offset is @c 0.
296 * @exception E_SUCCESS The method is successful.
297 * @exception E_INVALID_OPERATION An uncommitted transaction does not exist.
298 * @remarks The specific error code can be accessed using the GetLastResult() method.
299 * @remarks This is used as the default value for newly created VisualElementAnimation class or its descendant classes in the current transaction.
300 * @see SetVisualElementAnimationOffset()
302 static long GetVisualElementAnimationOffset(void);
306 * Sets the default delay for an animation. @n
307 * The animation starts after the duration of delay has passed.
311 * @return An error code
312 * @param[in] milliseconds The delay for the animation to start in milliseconds
313 * @exception E_SUCCESS The method is successful.
314 * @exception E_INVALID_OPERATION An uncommitted transaction does not exist.
315 * @exception E_INVALID_ARG The value of the specified parameter is negative.
316 * @remarks This method does not alter the start, end, and duration values of the animation.
317 * @remarks This is used as the default value for the newly created VisualElementAnimation class or its descendant classes in the current transaction.
318 * @see GetVisualElementAnimationDelay()
320 static result SetVisualElementAnimationDelay(long milliseconds);
324 * Gets the default delay value in milliseconds before an animation starts.
328 * @return The delay value in milliseconds @n
329 * The default value of the delay is @c 0.
330 * @exception E_SUCCESS The method is successful.
331 * @exception E_INVALID_OPERATION An uncommitted transaction does not exist.
332 * @remarks The specific error code can be accessed using the GetLastResult() method.
333 * @remarks This is used as the default value for the newly created VisualElementAnimation class or its descendant classes in the current transaction.
334 * @see SetVisualElementAnimationDelay()
336 static long GetVisualElementAnimationDelay(void);
340 * Sets the default repeat count for an animation. @n
341 * Repeats an animation for the specified number of times.
345 * @return An error code
346 * @param[in] count The number of times the animation has to repeat
347 * @exception E_SUCCESS The method is successful.
348 * @exception E_INVALID_OPERATION An uncommitted transaction does not exist.
349 * @exception E_INVALID_ARG The value of the specified parameter is negative.
350 * @remarks A delay and offset is applied to an animation only when the animation is played for the first time.
351 * @remarks This is used as the default value for the newly created VisualElementAnimation class or its descendant classes in the current transaction.
352 * @see GetVisualElementAnimationRepeatCount()
354 static result SetVisualElementAnimationRepeatCount(long count);
358 * Gets the default repeat count value of an animation.
362 * @return The repeat count value of the animation @n
363 * The default value of the repeat count is @c 1.
364 * @exception E_SUCCESS The method is successful.
365 * @exception E_INVALID_OPERATION An uncommitted transaction does not exist.
366 * @remarks The specific error code can be accessed using the GetLastResult() method.
367 * @remarks This is used as the default value for the newly created VisualElementAnimation class or its descendant classes in the current transaction.
368 * @see SetVisualElementAnimationRepeatCount()
370 static long GetVisualElementAnimationRepeatCount(void);
374 * Sets the default AutoReverse property of an animation. @n
375 * If enabled, the forward and backward animation can also be played.
379 * @param[in] autoReverse Set to @c true to enable the AutoReverse property of the animation, @n
381 * @exception E_SUCCESS The method is successful.
382 * @exception E_INVALID_OPERATION An uncommitted transaction does not exist.
383 * @remarks If @c autoReverse is set to @c true, the duration of the animation is doubled.
384 * If the repeat count is more than @c 1, @c autoReverse is applied to each iteration.
385 * Note that if @c autoReverse is set to @c true, one forward animation play
386 * and one backward animation play is one iteration.
387 * @remarks This is used as the default value for the newly created VisualElementAnimation class or its descendant classes in the current transaction.
388 * @see IsVisualElementAnimationAutoReverseEnabled()
390 static result SetVisualElementAnimationAutoReverseEnabled(bool autoReverse);
394 * Checks whether the auto reverse is enabled.
398 * @return @c true if the auto reverse is enabled, @n
400 * The default auto reverse value is @c false.
401 * @exception E_SUCCESS The method is successful.
402 * @exception E_INVALID_OPERATION An uncommitted transaction does not exist.
403 * @remarks The specific error code can be accessed using the GetLastResult() method.
404 * @remarks This is used as the default value for the newly created VisualElementAnimation class or its descendant classes in the current transaction.
405 * @see SetVisualElementAnimationAutoReverseEnabled()
407 static bool IsVisualElementAnimationAutoReverseEnabled(void);
411 * Sets the default scale ratio of an animation. @n
412 * The %SetVisualElementAnimationScaleRatio() method multiplies the duration, offset and delay using the scale ratio.
416 * @return An error code
417 * @param[in] scaleRatio The scale ratio property of the animation
418 * @exception E_SUCCESS The method is successful.
419 * @exception E_INVALID_OPERATION An uncommitted transaction does not exist.
420 * @exception E_INVALID_ARG The value of the specified parameter is negative.
421 * @remarks This is used as the default value for the newly created VisualElementAnimation or its descendant classes in the current transaction.
422 * @see GetVisualElementAnimationScaleRatio()
424 static result SetVisualElementAnimationScaleRatio(float scaleRatio);
428 * Gets the default scale ratio value of an animation.
432 * @return The scale ratio value of the animation @n
433 * The default value of scale ratio is @c 1.0f.
434 * @exception E_SUCCESS The method is successful.
435 * @exception E_INVALID_OPERATION An uncommitted transaction does not exist.
436 * @remarks The specific error code can be accessed using the GetLastResult() method.
437 * @remarks This is used as the default value for the newly created VisualElementAnimation class or its descendant classes in the current transaction.
438 * @see SetVisualElementAnimationScaleRatio()
440 static float GetVisualElementAnimationScaleRatio(void);
446 // This method is for internal use only. Using this method can cause behavioral, security-related,
447 // and consistency-related issues in the application.
449 // This is the default constructor for this class.
453 AnimationTransaction(void);
457 // This method is for internal use only. Using this method can cause behavioral, security-related,
458 // and consistency-related issues in the application.
460 // This is the destructor for this class.
464 ~AnimationTransaction(void);
468 // This method is for internal use only. Using this method can cause behavioral, security-related,
469 // and consistency-related issues in the application.
471 // This is the copy constructor for the %AnimationTransaction class.
474 // @param[in] transaction An instance of %AnimationTransaction
476 AnimationTransaction(const AnimationTransaction& transaction);
480 // This method is for internal use only. Using this method can cause behavioral, security-related,
481 // and consistency-related issues in the application.
483 // Assigns the value of the specified instance to the current instance of %AnimationTransaction.
487 // @param[in] rhs An instance of %AnimationTransaction
489 AnimationTransaction& operator =(const AnimationTransaction& rhs);
490 }; // AnimationTransaction
493 }}} // Tizen::Ui::Animations
495 #endif // _FUI_ANIM_ANIMATION_TRANSACTION_H_