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
168 * @remarks When the animation which is listening to an animation status event is removed before starting, the platform skips to call @n
169 * the IVisualElementAnimationStatusEventListener::OnVisualElementAnimationStarted() method and directly calls the IVisualElementAnimationStatusEventListener::OnVisualElementAnimationFinished() method.
171 void SetVisualElementAnimationStatusEventListener(IVisualElementAnimationStatusEventListener* pListener);
175 * Gets the IVisualElementAnimationStatusEventListener listener.
179 * @return A pointer to the IVisualElementAnimationStatusEventListener instance @n
180 * If listener has not been set, @c null is returned.
181 * @see SetVisualElementAnimationStatusEventListener()
183 IVisualElementAnimationStatusEventListener* GetVisualElementAnimationStatusEventListener(void) const;
187 * Sets the timing function to calculate the animation pace.
191 * @param[in] pTimingFunction The timing function instance to set
192 * @remarks If @c pTimingFunction is @c null, the default timing function is used which is pre-defined by the UI framework.
193 * @see GetTimingFunction()
195 void SetTimingFunction(const IVisualElementAnimationTimingFunction* pTimingFunction);
199 * Gets the timing function.
203 * @return A pointer to the timing function instance
204 * If timing function has not been set, the default timing function is returned.
205 * @see SetTimingFunction()
207 const IVisualElementAnimationTimingFunction* GetTimingFunction(void) const;
211 * Sets the interpolator to calculate the current value for the specific time during the animation.
215 * @param[in] pInterpolator The interpolator instance to set
216 * @remarks If @c pInterpolator is @c null, the default interpolator is used which is pre-defined by the UI framework.
217 * @see GetValueInterpolator()
219 void SetValueInterpolator(const IVisualElementAnimationValueInterpolator* pInterpolator);
223 * Gets the value interpolator.
227 * @return A pointer to the interpolator instance
228 * If interpolator has not been set, the default interpolator is returned.
229 * @see SetValueInterpolator()
231 const IVisualElementAnimationValueInterpolator* GetValueInterpolator(void) const;
235 * Sets the duration of the animation.
239 * @return An error code
240 * @param[in] milliseconds The duration of the animation in milliseconds
241 * @exception E_SUCCESS The method is successful.
242 * @exception E_INVALID_ARG The value of the specified parameter is negative or lesser than the offset of the animation.
245 result SetDuration(long milliseconds);
249 * Gets the duration of the animation in milliseconds.
253 * @return The duration value of the animation
256 long GetDuration(void) const;
260 * Sets the offset value of the animation. @n
261 * Additionally, the %SetOffset() alters the start value and duration for which an animation is played.
265 * @return An error code
266 * @param[in] milliseconds The offset of the animation in milliseconds
267 * @exception E_SUCCESS The method is successful.
268 * @exception E_INVALID_ARG The value of the specified parameter is negative or greater than the duration of the animation.
269 * @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,
270 * the actual animation starts at @c 0th ms and plays for @c 80 ms with a start value of @c 0.2. @n
271 * If @c autoReverse is set to @c true, the backward animation plays for @c 100ms, from @c 1.0 to @c 0.0.
274 result SetOffset(long milliseconds);
278 * Gets the offset value in milliseconds after the animation starts.
282 * @return The offset value of the animation in milliseconds @n
283 * The default value of the offset is @c 0.
286 long GetOffset(void) const;
290 * Sets the delay for the animation. @n
291 * The animation starts after the duration of delay has passed.
295 * @return An error code
296 * @param[in] milliseconds The delay for the animation to start in milliseconds
297 * @exception E_SUCCESS The method is successful.
298 * @exception E_INVALID_ARG The value of the specified parameter is negative.
299 * @remarks This method does not alter the start, end, and duration values of the animation.
302 result SetDelay(long milliseconds);
306 * Gets the delay value in milliseconds before the animation starts.
310 * @return The delay value in milliseconds @n
311 * The default value of the delay is @c 0.
314 long GetDelay(void) const;
318 * Sets the repeat count for the animation. @n
319 * Repeats an animation for the specified number of times.
323 * @return An error code
324 * @param[in] count The number of times the animation is repeated
325 * @exception E_SUCCESS The method is successful.
326 * @exception E_INVALID_ARG The value of the specified parameter is negative.
327 * @remarks A delay and offset is applied to an animation only when the animation is played for the first time.
328 * If @c count is set to @c 0, the animation is repeated indefinitely.
329 * @see GetRepeatCount()
331 result SetRepeatCount(long count);
335 * Gets the repeat count value of the animation.
339 * @return The repeat count value of the animation @n
340 * The default value of the repeat count is @c 1.
341 * @see SetRepeatCount()
343 long GetRepeatCount(void) const;
347 * Sets the @c autoReverse property of the animation. @n
348 * If enabled, the forward and backward animation can also be played.
352 * @param[in] autoReverse Set to @c true to enable the @c autoReverse property of the animation, @n
354 * @remarks If @c autoReverse is set to @c true, the duration of the animation is doubled.
355 * If the repeat count is more than @c 1, @c autoReverse is applied to each iteration. @n
356 * Note that if @c autoReverse is set to @c true, one forward animation play and
357 * one backward animation play is one iteration.
358 * @see IsAutoReverseEnabled()
360 void SetAutoReverseEnabled(bool autoReverse);
364 * Checks whether auto reverse is enabled.
368 * @return @c true if auto reverse is enabled, @n
370 * The default auto reverse value is @c false.
371 * @see SetAutoReverseEnabled()
373 bool IsAutoReverseEnabled(void) const;
377 * Sets the scale ratio of the animation.
381 * @return An error code
382 * @param[in] scaleRatio The scale ratio value of the animation
383 * @exception E_SUCCESS The method is successful.
384 * @exception E_INVALID_ARG The value of the specified parameter is below @c 0.
385 * @remarks If @c scaleRatio is @c 0.5, then the animation speed is 2 times faster.
386 * @see GetScaleRatio()
388 result SetScaleRatio(float scaleRatio);
392 * Gets the scale ratio value of the animation.
396 * @return The scale ratio value of the animation @n
397 * The default value of scale ratio is @c 1.0f.
398 * @see SetScaleRatio()
400 float GetScaleRatio(void) const;
404 * Sets the custom data of the animation.
408 * @param[in] pUserData The user data associated with this instance
411 void SetUserData(void* pUserData);
415 * Gets the custom data of the animation.
419 * @return The user data associated with this instance
422 void* GetUserData(void) const;
426 * Gets the predefined timing function by name.
430 * @return The specified timing function
431 * @param[in] name The timing function name
432 * @exception E_SUCCESS The method is successful.
433 * @exception E_INVALID_ARG The specified input parameter is invalid.
434 * @remarks The parameter @c name must be "Linear", "EaseIn", "EaseOut", "EaseInOut", "EaseOutIn", "Discrete", "Bezier", "ExpIn", "ExpOut", "EaseElasticIn", or "EaseElasticOut".
435 * The specific error code can be accessed using the GetLastResult() method.
437 static const IVisualElementAnimationTimingFunction* GetTimingFunctionByName(const Tizen::Base::String& name);
443 // This variable is for internal use only. Using this variable can cause behavioral, security-related,
444 // and consistency-related issues in the application.
446 // This is the constructor for derived classes.
450 VisualElementAnimation(_VisualElementAnimationImpl* pImpl);
454 // This variable is for internal use only. Using this variable can cause behavioral, security-related,
455 // and consistency-related issues in the application.
459 _VisualElementAnimationImpl* _pAnimationImpl;
461 friend class _VisualElementAnimationImpl;
462 }; // VisualElementAnimation
465 }}} // Tizen::Ui::Animations
467 #endif // _FUI_ANIM_VISUAL_ELEMENT_ANIMATION_H_