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 FUiAnimVisualElementAnimation.h
20 * @brief This is the header file for the %VisualElementAnimation class.
22 * This header file contains the declarations of the %VisualElementAnimation class.
25 #ifndef _FUI_ANIM_VISUAL_ELEMENT_ANIMATION_H_
26 #define _FUI_ANIM_VISUAL_ELEMENT_ANIMATION_H_
28 #include <FBaseObject.h>
30 namespace Tizen { namespace Ui { namespace Animations
34 class IVisualElementAnimationStatusEventListener;
35 class IVisualElementAnimationTimingFunction;
36 class IVisualElementAnimationValueInterpolator;
37 class _VisualElementAnimationImpl;
40 * @class VisualElementAnimation
41 * @brief This class is the base class for all the %VisualElementAnimation classes.
45 * The %VisualElementAnimation class defines the basic animation properties, such as the interpolator to be used,
46 * the duration of the animation in milliseconds, the delay before the animation is started in milliseconds, and the repeat count.
48 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/ui/visual_element_animations.htm">Visual Element Animations</a>.
51 class _OSP_EXPORT_ VisualElementAnimation
52 : public Tizen::Base::Object
57 * This is the default constructor for this class.
61 * @exception E_SUCCESS The method is successful.
62 * @exception E_OUT_OF_MEMORY The memory is insufficient.
63 * @remarks The specific error code can be accessed using the GetLastResult() method.
65 VisualElementAnimation(void);
69 * This is the destructor for this class.
73 virtual ~VisualElementAnimation(void);
77 * This is the copy constructor for the %VisualElementAnimation class.
81 * @param[in] animation An instance of %VisualElementAnimation
82 * @exception E_SUCCESS The method is successful.
83 * @exception E_OUT_OF_MEMORY The memory is insufficient.
84 * @remarks The specific error code can be accessed using the GetLastResult() method.
86 VisualElementAnimation(const VisualElementAnimation& animation);
90 * Assigns the value of the specified instance to the current instance of %VisualElementAnimation.
94 * @param[in] rhs An instance of %VisualElementAnimation
96 VisualElementAnimation& operator =(const VisualElementAnimation& rhs);
100 * Checks whether the specified instance and current instance of %VisualElementAnimation have equal animation values.
104 * @return @c true if the animation of the two instances of %VisualElementAnimation are equal, @n
106 * @param[in] rhs An instance of %VisualElementAnimation
108 bool operator ==(const VisualElementAnimation& rhs) const;
112 * Checks whether the specified instance and current instance of %VisualElementAnimation have different animation values.
116 * @return @c true if the values of the animations of the two instances of %VisualElementAnimation are not equal, @n
118 * @param[in] rhs An instance of %VisualElementAnimation
120 bool operator !=(const VisualElementAnimation& rhs) const;
124 * Checks whether the value of the current instance of %VisualElementAnimation equals the value of the specified instance.
128 * @return @c true if the value of the current instance equals the value of the specified instance, @n
130 * @param[in] obj An instance of %VisualElementAnimation
131 * @remarks The %VisualElementAnimation class has a semantic value which means that this method checks whether the two instances have the same animation.
133 virtual bool Equals(const Tizen::Base::Object& obj) const;
137 * Gets the hash value of the current instance.
141 * @return The hash value of the current instance
142 * @remarks The two equal instances must return the same hash value.
143 * For better performance, the used hash function must generate a random distribution for all inputs.
145 virtual int GetHashCode(void) const;
149 * Gets the copied instance of the class.
153 * @return An instance of %VisualElementAnimation
154 * @exception E_SUCCESS The method is successful.
155 * @exception E_OUT_OF_MEMORY The memory is insufficient.
156 * @remarks The specific error code can be accessed using the GetLastResult() method.
158 virtual VisualElementAnimation* CloneN(void) const;
162 * Sets an IVisualElementAnimationStatusEventListener listener instance to listen to the events of a particular animation. @n
163 * The added listener, %IVisualElementAnimationStatusEventListener, can listen to events on the specified event dispatcher's context when they are fired.
167 * @param[in] pListener The listener instance to set
169 void SetVisualElementAnimationStatusEventListener(IVisualElementAnimationStatusEventListener* pListener);
173 * Gets the IVisualElementAnimationStatusEventListener listener.
177 * @return A pointer to the IVisualElementAnimationStatusEventListener instance @n
178 * If listener has not been set, @c null is returned.
179 * @see SetVisualElementAnimationStatusEventListener()
181 IVisualElementAnimationStatusEventListener* GetVisualElementAnimationStatusEventListener(void) const;
185 * Sets the timing function to calculate the animation pace.
189 * @param[in] pTimingFunction The timing function instance to set
190 * @remarks If @c pTimingFunction is @c null, the default timing function is used which is pre-defined by the UI framework.
191 * @see GetTimingFunction()
193 void SetTimingFunction(const IVisualElementAnimationTimingFunction* pTimingFunction);
197 * Gets the timing function.
201 * @return A pointer to the timing function instance
202 * If timing function has not been set, the default timing function is returned.
203 * @see SetTimingFunction()
205 const IVisualElementAnimationTimingFunction* GetTimingFunction(void) const;
209 * Sets the interpolator to calculate the current value for the specific time during the animation.
213 * @param[in] pInterpolator The interpolator instance to set
214 * @remarks If @c pInterpolator is @c null, the default interpolator is used which is pre-defined by the UI framework.
215 * @see GetValueInterpolator()
217 void SetValueInterpolator(const IVisualElementAnimationValueInterpolator* pInterpolator);
221 * Gets the value interpolator.
225 * @return A pointer to the interpolator instance
226 * If interpolator has not been set, the default interpolator is returned.
227 * @see SetValueInterpolator()
229 const IVisualElementAnimationValueInterpolator* GetValueInterpolator(void) const;
233 * Sets the duration of the animation.
237 * @return An error code
238 * @param[in] milliseconds The duration of the animation in milliseconds
239 * @exception E_SUCCESS The method is successful.
240 * @exception E_INVALID_ARG The value of the specified parameter is negative or lesser than the offset of the animation.
243 result SetDuration(long milliseconds);
247 * Gets the duration of the animation in milliseconds.
251 * @return The duration value of the animation
254 long GetDuration(void) const;
258 * Sets the offset value of the animation. @n
259 * Additionally, the %SetOffset() alters the start value and duration for which an animation is played.
263 * @return An error code
264 * @param[in] milliseconds The offset of the animation in milliseconds
265 * @exception E_SUCCESS The method is successful.
266 * @exception E_INVALID_ARG The value of the specified parameter is negative or greater than the duration of the animation.
267 * @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,
268 * the actual animation starts at @c 0th ms and plays for @c 80 ms with a start value of @c 0.2. @n
269 * If @c autoReverse is set to @c true, the backward animation plays for @c 100ms, from @c 1.0 to @c 0.0.
272 result SetOffset(long milliseconds);
276 * Gets the offset value in milliseconds after the animation starts.
280 * @return The offset value of the animation in milliseconds @n
281 * The default value of the offset is @c 0.
284 long GetOffset(void) const;
288 * Sets the delay for the animation. @n
289 * The animation starts after the duration of delay has passed.
293 * @return An error code
294 * @param[in] milliseconds The delay for the animation to start in milliseconds
295 * @exception E_SUCCESS The method is successful.
296 * @exception E_INVALID_ARG The value of the specified parameter is negative.
297 * @remarks This method does not alter the start, end, and duration values of the animation.
300 result SetDelay(long milliseconds);
304 * Gets the delay value in milliseconds before the animation starts.
308 * @return The delay value in milliseconds @n
309 * The default value of the delay is @c 0.
312 long GetDelay(void) const;
316 * Sets the repeat count for the animation. @n
317 * Repeats an animation for the specified number of times.
321 * @return An error code
322 * @param[in] count The number of times the animation is repeated
323 * @exception E_SUCCESS The method is successful.
324 * @exception E_INVALID_ARG The value of the specified parameter is negative.
325 * @remarks A delay and offset is applied to an animation only when the animation is played for the first time.
326 * If @c count is set to @c 0, the animation is repeated indefinitely.
327 * @see GetRepeatCount()
329 result SetRepeatCount(long count);
333 * Gets the repeat count value of the animation.
337 * @return The repeat count value of the animation @n
338 * The default value of the repeat count is @c 1.
339 * @see SetRepeatCount()
341 long GetRepeatCount(void) const;
345 * Sets the @c autoReverse property of the animation. @n
346 * If enabled, the forward and backward animation can also be played.
350 * @param[in] autoReverse Set to @c true to enable the @c autoReverse property of the animation, @n
352 * @remarks If @c autoReverse is set to @c true, the duration of the animation is doubled.
353 * If the repeat count is more than @c 1, @c autoReverse is applied to each iteration. @n
354 * Note that if @c autoReverse is set to @c true, one forward animation play and
355 * one backward animation play is one iteration.
356 * @see IsAutoReverseEnabled()
358 void SetAutoReverseEnabled(bool autoReverse);
362 * Checks whether auto reverse is enabled.
366 * @return @c true if auto reverse is enabled, @n
368 * The default auto reverse value is @c false.
369 * @see SetAutoReverseEnabled()
371 bool IsAutoReverseEnabled(void) const;
375 * Sets the scale ratio of the animation.
379 * @return An error code
380 * @param[in] scaleRatio The scale ratio value of the animation
381 * @exception E_SUCCESS The method is successful.
382 * @exception E_INVALID_ARG The value of the specified parameter is below @c 0.
383 * @remarks If @c scaleRatio is @c 0.5, then the animation speed is 2 times faster.
384 * @see GetScaleRatio()
386 result SetScaleRatio(float scaleRatio);
390 * Gets the scale ratio value of the animation.
394 * @return The scale ratio value of the animation @n
395 * The default value of scale ratio is @c 1.0f.
396 * @see SetScaleRatio()
398 float GetScaleRatio(void) const;
402 * Sets the custom data of the animation.
406 * @param[in] pUserData The user data associated with this instance
409 void SetUserData(void* pUserData);
413 * Gets the custom data of the animation.
417 * @return The user data associated with this instance
420 void* GetUserData(void) const;
424 * Gets the predefined timing function by name.
428 * @return The specified timing function
429 * @param[in] name The timing function name
430 * @exception E_SUCCESS The method is successful.
431 * @exception E_INVALID_ARG The specified input parameter is invalid.
432 * @remarks The parameter @c name must be "Linear", "EaseIn", "EaseOut", "EaseInOut", "EaseOutIn", "Discrete", "Bezier", "ExpIn", "ExpOut", "EaseElasticIn", or "EaseElasticOut".
433 * The specific error code can be accessed using the GetLastResult() method.
435 static const IVisualElementAnimationTimingFunction* GetTimingFunctionByName(const Tizen::Base::String& name);
441 // This variable is for internal use only. Using this variable can cause behavioral, security-related,
442 // and consistency-related issues in the application.
444 // This is the constructor for derived classes.
448 VisualElementAnimation(_VisualElementAnimationImpl* pImpl);
452 // This variable is for internal use only. Using this variable can cause behavioral, security-related,
453 // and consistency-related issues in the application.
457 _VisualElementAnimationImpl* _pAnimationImpl;
459 friend class _VisualElementAnimationImpl;
460 }; // VisualElementAnimation
463 }}} // Tizen::Ui::Animations
465 #endif // _FUI_ANIM_VISUAL_ELEMENT_ANIMATION_H_