Merge "Fix Ime Rotation" into tizen_2.1
[platform/framework/native/uifw.git] / inc / FUiAnimControlAnimator.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://floralicense.org/license/
10 //
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.
16 //
17
18 /**
19  * @file        FUiAnimControlAnimator.h
20  * @brief       This is the header file for the %ControlAnimator class.
21  *
22  * This header file contains the declarations of the %ControlAnimator class.
23  */
24
25 #ifndef _FUI_ANIM_CONTROL_ANIMATOR_H_
26 #define _FUI_ANIM_CONTROL_ANIMATOR_H_
27
28 #include <FBaseTypes.h>
29 #include <FBaseString.h>
30 #include <FBaseObject.h>
31 #include <FBaseColArrayList.h>
32 #include <FBaseColArrayListT.h>
33 #include <FGrpPoint.h>
34 #include <FGrpRectangle.h>
35 #include <FGrpDimension.h>
36 #include <FUiControl.h>
37 #include <FUiAnimAnimationBase.h>
38 #include <FUiAnimSequentialAnimationGroup.h>
39 #include <FUiAnimParallelAnimationGroup.h>
40 #include <FUiAnimIControlAnimatorEventListener.h>
41 #include <FUiAnimIControlAnimatorDetailedEventListener.h>
42
43 namespace Tizen { namespace Ui { namespace Animations
44 {
45
46 /**
47  * @class       ControlAnimator
48  * @brief       This class defines the animation methods for Tizen::Ui::Control.
49  *
50  * @since       2.0
51  *
52  * @final   This class is not intended for extension.
53  *
54  * @remarks This class doesn't support APIs for float type.
55  *
56  * The %ControlAnimator class is used to control the animations operated in Tizen::Ui::Controls.
57  *
58  * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/ui/animating_uicontrols.htm">Animating UI Controls</a>.
59  *
60  */
61 class _OSP_EXPORT_ ControlAnimator
62         : public Tizen::Base::Object
63 {
64 public:
65
66         /**
67          * This is the destructor for this class.
68          *
69          * @since       2.0
70          */
71         virtual ~ControlAnimator(void);
72
73
74         /**
75          * Starts an animation explicitly. @n
76          * If multiple controls need to be animated simultaneously, the controls must be part of the AnimationTransaction class. @n
77          * The %StartUserAnimation() method must be called after AnimationTransaction::Begin() and before AnimationTransaction::Commit().
78          *
79          * @since               2.0
80          *
81          * @return              An error code
82          * @param[in]   animTarget                      The property to animate
83          * @param[in]   animation                       An object of type AnimationBase
84          * @exception   E_SUCCESS                       The method is successful.
85          * @exception   E_INVALID_ARG           A specified input parameter is invalid.
86          * @exception   E_INVALID_OPERATION     The current state of the instance prohibits the execution of the specified operation.
87          * @exception   E_SYSTEM                        A system error has occurred.
88          * @remarks             An animation is deleted at the end of the animation playback. @n
89          *              RectangleAnimation is used to animate only one animation target at a time.
90          *              For example, if AnimationTarget is @c ANIMATION_TARGET_SIZE, RectangleAnimation performs only the dimension animation. @n
91          *              To perform animation using the @c ANIMATION_TARGET_POSITION and @c ANIMATION_TARGET_SIZE properties, AnimationTransaction must be used with
92          *                              a separate call for each animation target.
93          */
94         result StartUserAnimation(AnimationTargetType animTarget, const AnimationBase& animation);
95
96
97         /**
98          * Starts a group of animations explicitly. @n
99          * If multiple controls need to be animated simultaneously, the control must be part of the AnimationTransaction class.
100          * The %StartUserAnimation() method must be called after AnimationTransaction::Begin() and before AnimationTransaction::Commit().
101          *
102          * @since               2.0
103          *
104          * @return              An error code
105          * @param[in]   animGroup                       An animation group having a list of animations
106          * @exception   E_SUCCESS                       The method is successful.
107          * @exception   E_INVALID_ARG           The specified input parameter is invalid.
108          * @exception   E_INVALID_OPERATION     The current state of the instance prohibits the execution of the specified operation.
109          * @exception   E_SYSTEM                        A system error has occurred.
110          * @remarks             The animations are deleted at the end of the animation playback. @n
111          *              RectangleAnimation is used to animate only one animation target at a time.
112          */
113         result StartUserAnimation(const AnimationGroup& animGroup);
114
115
116         /**
117          * Stops all the animations that are currently playing and jumps to the final frame of the animation.
118          *
119          * @since               2.0
120          *
121          * @return              An error code
122          * @exception   E_SUCCESS                       The method is successful.
123          * @exception   E_SYSTEM                        A system error has occurred.
124          */
125         result StopAllAnimations(void);
126
127
128         /**
129          * Stops the animation with the specified trigger type.
130          *
131          * @since               2.0
132          *
133          * @return              An error code
134          * @param[in]   animTrigger                 The animator trigger type
135          * @exception   E_SUCCESS                       The method is successful.
136          * @exception   E_INVALID_ARG           The specified input parameter is invalid.
137          * @exception   E_SYSTEM                        A system error has occurred.
138          */
139         result StopAnimation(ControlAnimatorTriggerType animTrigger);
140
141
142         /**
143          * Gets the status of an animation with respect to a control.
144          *
145          * @since               2.0
146          *
147          * @return              The animation state
148          */
149         AnimatorStatus GetStatus(void) const;
150
151
152         /**
153          * Gets the status of an animation for the specified animation target type.
154          *
155          * @since               2.0
156          *
157          * @return              The state of an animation with type @c animTarget
158          * @param[in]   animTarget              The animation target type
159          */
160         AnimatorStatus GetStatus(AnimationTargetType animTarget) const;
161
162
163         /**
164          * Adds the IControlAnimatorEventListener listener instance to the current instance of the control. @n
165          * The %IControlAnimatorEventListener listener is called for status changes of animations associated with a control.
166          * The added listener listens to events on the specified event dispatcher's context when they are fired.
167          *
168          * @since               2.0
169          *
170          * @return              An error code
171          * @param[in]   listener                                The listener to add
172          * @exception   E_SUCCESS                               The method is successful.
173          * @exception   E_INVALID_ARG                   The specified input parameter is invalid.
174          * @exception   E_UNSUPPORTED_OPERATION The animation support is unavailable.
175          * @exception   E_OBJ_ALREADY_EXIST             The specified @c listener is already added.
176          * @exception   E_SYSTEM                                A system error has occurred.
177          * @remarks             For animations that are part of AnimationTransaction, the applications need to listen to IAnimationTransactionEventListener events. @n
178          *                              The IControlAnimatorEventListener events are not fired if the animation is part of a transaction.
179          */
180         result AddControlAnimatorEventListener(IControlAnimatorEventListener& listener);
181
182
183         /**
184          * Removes the IControlAnimatorEventListener listener instance from the current instance of the control. @n
185          * The removed listener cannot listen to events when they are fired.
186          *
187          * @since               2.0
188          *
189          * @return              An error code
190          * @param[in]   listener                                The listener to remove
191          * @exception   E_SUCCESS                               The method is successful.
192          * @exception   E_INVALID_ARG                   The specified input parameter is invalid.
193          * @exception   E_UNSUPPORTED_OPERATION The animation support is unavailable.
194          * @exception   E_SYSTEM                                A system error has occurred.
195          */
196         result RemoveControlAnimatorEventListener(IControlAnimatorEventListener& listener);
197
198
199         /**
200          * Adds a IControlAnimatorDetailedEventListener listener instance to the current instance of the control. @n
201          * The %IControlAnimatorDetailedEventListener listener is called for status changes of each animation associated with the control. @n
202          * The added listener listens to events on the specified event dispatcher's context when they are fired.
203          *
204          * @since               2.0
205          *
206          * @return              An error code
207          * @param[in]   listener                                The listener to add
208          * @exception   E_SUCCESS                               The method is successful.
209          * @exception   E_INVALID_ARG                   The specified input parameter is invalid.
210          * @exception   E_UNSUPPORTED_OPERATION The animation support is unavailable.
211          * @exception   E_OBJ_ALREADY_EXIST             The specified @c listener is already added.
212          * @exception   E_SYSTEM                                A system error has occurred.
213          * @remarks             For animations that are part of AnimationTransaction, the applications need to listen to the IAnimationTransactionEventListener events. @n
214          *                              The IControlAnimatorDetailedEventListener events are not fired if the animation is part of a transaction.
215          */
216         result AddControlAnimatorDetailedEventListener(IControlAnimatorDetailedEventListener& listener);
217
218
219         /**
220          * Removes an IControlAnimatorDetailedEventListener instance from the current instance of the control. @n
221          * The removed listener cannot listen to events when they are fired.
222          *
223          * @since               2.0
224          *
225          * @return              An error code
226          * @param[in]   listener                                The listener to remove
227          * @exception   E_SUCCESS                               The method is successful.
228          * @exception   E_INVALID_ARG                   The specified input parameter is invalid.
229          * @exception   E_UNSUPPORTED_OPERATION The animation support is unavailable.
230          * @exception   E_SYSTEM                                A system error has occurred.
231          */
232         result RemoveControlAnimatorDetailedEventListener(IControlAnimatorDetailedEventListener& listener);
233
234
235         /**
236          * Sets an animation group for the specified trigger type.
237          *
238          * @since               2.0
239          *
240          * @return              An error code
241          * @param[in]   animTrigger                             The animator trigger type to which the animation is applied
242          * @param[in]   pAnimation                              An object of type AnimationBase @n
243          *                                                                              If @c null is passed, the default animation values are used for animation with the specified trigger type.
244          * @exception   E_SUCCESS                               The method is successful.
245          * @exception   E_UNSUPPORTED_OPTION    The specified option is not supported.
246          * @exception   E_INVALID_ARG                   A specified input parameter is invalid.
247          * @exception   E_SYSTEM                                A system error has occurred.
248          * @remarks @c ANIMATION_TRIGGER_USER is not supported. @n
249          *          The @c holdEnd value and @c AutoReverse value are set to @c true and @c false respectively. @n
250          *          An exception is returned if the animation group does not contain an animation with the target type that is being animated for the specified
251          *                      trigger type. The start value of an animation object of the associated target type for the specified trigger type is overwritten by the
252          *                      current property value of the Tizen::Ui::Control instance and the end value is overwritten by the value that is being set by the user. @n
253          *          The associated target types for each trigger are as below: @n
254          *          \verbatim
255          *                      Animation Trigger                   -   Target Type
256          *                      ANIMATION_TRIGGER_POSITION_CHANGE   -   ANIMATION_TARGET_POSITION
257          *                      ANIMATION_TRIGGER_SIZE_CHANGE       -   ANIMATION_TARGET_SIZE
258          *                      ANIMATION_TRIGGER_SHOW_STATE_CHANGE -   ANIMATION_TARGET_ALPHA
259          *                      \endverbatim
260          */
261         result SetAnimation(ControlAnimatorTriggerType animTrigger, const AnimationGroup* pAnimation);
262
263
264         /**
265          * Gets a group of animations.
266          *
267          * @since               2.0
268          *
269          * @return      An animation group object at the specified animation trigger type, @n
270          *                              else @c null if the animation is empty or AnimationTriggerType is @c ANIMATION_TRIGGER_USER
271          * @param[in]   animTrigger                     The animator trigger type to get an animation group object
272          */
273         AnimationGroup* GetAnimationN(ControlAnimatorTriggerType animTrigger) const;
274
275
276         /**
277          * Sets the position of the control. @n
278          * An animation is played while changing the position of the control.
279          *
280          * @since               2.0
281          *
282          * @return              An error code
283          * @param[in]   x                       The new X position of the object
284          * @param[in]   y                       The new Y position of the object
285          * @exception   E_SUCCESS               The method is successful.
286          * @exception   E_INVALID_OPERATION     The current state of the instance prohibits the execution of the specified operation.
287          * @exception   E_UNSUPPORTED_OPERATION This operation is not supported.
288          * @exception   E_SYSTEM                        A system error has occurred.
289          * @remarks  The X and Y position of the object are relative to the top-left corner of its parent. @n
290          *           Control::Invalidate() need not be called to display the control. The animation uses linear interpolator and is played for a default duration if
291          *                       the user does not overwrite the values using SetAnimation().
292          * @see         SetBounds()
293          * @see     SetSize()
294          */
295         result SetPosition(int x, int y);
296
297
298         /**
299          * Sets the position of the control. @n
300          * An animation is played while changing the position of the control.
301          *
302          * @since               2.0
303          *
304          * @return      An error code
305          * @param[in]   Position                The new position
306          * @exception   E_SUCCESS                       The method is successful.
307          * @exception   E_INVALID_OPERATION     The current state of the instance prohibits the execution of the specified operation.
308          * @exception   E_UNSUPPORTED_OPERATION This operation is not supported.
309          * @exception   E_SYSTEM                A system error has occurred.
310          * @remarks             The position of the object is relative to the top-left corner of its parent. @n
311          *              Control::Invalidate() need not be called to display the control. @n
312          *                              The animation uses linear interpolator and is played for a default duration if the user does not overwrite the values using SetAnimation().
313          * @see         SetPosition()
314          * @see         SetBounds()
315          * @see         SetSize()
316          */
317         result SetPosition(const Tizen::Graphics::Point& Position);
318
319
320         /**
321          * Sets the size of the control. @n
322          * An animation is played while changing the size of the control. @n
323          * The @c width and @c height parameters contain the width and height values of the object, respectively.
324          *
325          * @since               2.0
326          *
327          * @return      An error code
328          * @param[in]   width                   The new width of the object
329          * @param[in]   height                  The new height of the object
330          * @exception   E_SUCCESS               The method is successful.
331          * @exception   E_INVALID_ARG           The specified input parameter is invalid. @n
332          *                                      The value of @c width or @c height is @c 0 or a negative value.
333          * @exception   E_INVALID_OPERATION     The current state of the instance prohibits the execution of the specified operation.
334          * @exception   E_UNSUPPORTED_OPERATION This operation is not supported.
335          * @exception   E_SYSTEM                A system error has occurred.
336          * @remarks             Control::Invalidate() need not be called to display the control. @n
337          *                              The animation uses linear interpolator and is played for a duration of @c 250 ms if the user does not overwrite the values using SetAnimation().
338          * @see         SetBounds()
339          * @see         SetPosition()
340          */
341         result SetSize(int width, int height);
342
343
344         /**
345          * Sets the size of the control. @n
346          * An animation is played while changing the size of the control. @n
347          * The @c width becomes @c size.width, and the @c height becomes @c size.height.
348          *
349          * @since               2.0
350          *
351          * @return              An error code
352          * @param[in]   size                    The new width and height
353          * @exception   E_SUCCESS               The method is successful.
354          * @exception   E_INVALID_ARG           The specified input parameter is invalid. @n
355          *                                      The value @c size.width or @c size.height is @c 0 or a negative value.
356          * @exception   E_INVALID_OPERATION     The current state of the instance prohibits the execution of the specified operation.
357          * @exception   E_UNSUPPORTED_OPERATION This operation is not supported.
358          * @exception   E_SYSTEM                        A system error has occurred.
359          * @remarks             Control::Invalidate() need not be called to display the control. @n
360          *                              The animation uses linear interpolator and is played for a duration of @c 250 ms if the user does not overwrite the values using SetAnimation().
361          * @see                 SetSize()
362          * @see         SetBounds()
363          * @see         SetPosition()
364          */
365         result SetSize(const Tizen::Graphics::Dimension& size);
366
367
368         /**
369          * Sets the position and size of the control. @n
370          * An animation is played while changing the position and size of the control. @n
371          * The position is set to (x, y), and the @c width and @c height parameters contain the width and height values of the object, respectively.
372          *
373          * @since               2.0
374          *
375          * @return              An error code
376          * @param[in]    x                      The new X position of the object
377          * @param[in]    y                      The new Y position of the object
378          * @param[in]   width                   The new width of the object
379          * @param[in]   height                  The new height of the object
380          * @exception   E_SUCCESS                               The method is successful.
381          * @exception   E_INVALID_ARG                   A specified input parameter is invalid. @n
382          *                                      The value of @c width or @c height is @c 0 or a negative value.
383          * @exception   E_SYSTEM                                A system error has occurred.
384          * @exception   E_INVALID_OPERATION             The current state of the instance prohibits the execution of the specified operation.
385          * @exception   E_UNSUPPORTED_OPERATION This operation is not supported.
386          * @remarks     Changing the position of a parent object does not change the position of its children, the top-left position that is relative to the
387          *                              top-left corner of the parent container. If calling this method causes re-positioning of an object or changes the size of the object, the
388          *                              system redraws the object and all its children. @n
389          *              Control::Invalidate() need not be called to display the control. @n
390          *                              The animation uses linear interpolator and is played for a duration of @c 250 ms if the user does not overwrite the values using SetAnimation().
391          * @see         SetPosition()
392          * @see         SetSize()
393          */
394         result SetBounds(int x, int y, int width, int height);
395
396
397         /**
398          * Sets the position and size of the control. @n
399          * An animation is played while changing the position and size of the control.
400          *
401          * @since               2.0
402          *
403          * @return              An error code
404          * @param[in]   rect                                    The new bounds of the object
405          * @exception   E_SUCCESS                               The method is successful.
406          * @exception   E_INVALID_ARG                   A specified input parameter is invalid. @n
407          *                                      The value of @c rect.width or @c rect.height is @c 0 or a negative value.
408          * @exception   E_SYSTEM                                A system error has occurred.
409          * @exception   E_INVALID_OPERATION             The current state of the instance prohibits the execution of the specified operation.
410          * @exception   E_UNSUPPORTED_OPERATION This operation is not supported.
411          * @remarks             Control::Invalidate() need not be called to display the control. @n
412          *                              The animation uses linear interpolator and is played for a duration of @c 250 ms if the user does not overwrite the values using SetAnimation().
413          * @see         SetBounds()
414          * @see         SetPosition()
415          * @see         SetSize()
416          */
417         result SetBounds(const Tizen::Graphics::Rectangle& rect);
418
419
420         /**
421          * Sets the show state of the control with animation.
422          *
423          * @since               2.0
424          *
425          * @return              An error code
426          * @param[in]   show                                    The show state of the object
427          * @exception   E_SUCCESS                               The method is successful.
428          * @exception   E_INVALID_OPERATION             The current state of the instance prohibits the execution of the specified operation.
429          * @exception   E_UNSUPPORTED_OPERATION This operation is not supported.
430          * @exception   E_SYSTEM                                A system error has occurred.
431          * @remarks             Control::Invalidate() need not be called to display the control. @n
432          *                              The animation uses linear interpolator and is played for a duration of @c 250 ms if the user does not overwrite the values using SetAnimation().
433          */
434         result SetShowState(bool show);
435
436
437         /**
438          * Checks whether animation is supported for the control with the specified target type.
439          *
440          * @since               2.0
441          *
442          * @return              @c true if animation is supported, @n
443          *                              else @c false
444          * @param[in]   animTarget      The animation target
445          */
446         bool IsAnimationSupported(AnimationTargetType animTarget) const;
447
448 protected:
449
450         friend class _ControlAnimatorImpl;
451
452
453         //
454         // This variable is for internal use only. Using this variable can cause behavioral, security-related,
455         // and consistency-related issues in the application.
456         //
457         // The variable for internal usage.
458         //
459         // @since  2.0
460         //
461         class _ControlAnimatorImpl* _pControlAnimatorImpl;
462
463
464 private:
465
466         //
467         // This method is for internal use only. Using this method can cause behavioral, security-related,
468         // and consistency-related issues in the application.
469         //
470         // This is the constructor for this class.
471         //
472         // @since       2.0
473         //
474         ControlAnimator(void);
475
476
477         //
478         // This method is for internal use only. Using this method can cause behavioral, security-related,
479         // and consistency-related issues in the application.
480         //
481         // Initializes this class.
482         //
483         // @since               2.0
484         // @return              An error code
485         // @param[in]   source                          An instance of control class
486         // @exception   E_SUCCESS                       The method is successful.
487         // @exception   E_SYSTEM                        A system error has occurred.
488         //
489         result Construct(const Tizen::Ui::Control& source);
490
491
492         //
493         // This method is for internal use only. Using this method can cause behavioral, security-related,
494         // and consistency-related issues in the application.
495         //
496         // This is the copy constructor for this class.
497         //
498         // @since       2.0
499         //
500         ControlAnimator(const ControlAnimator& animator);
501
502
503         //
504         // This method is for internal use only. Using this method can cause behavioral, security-related,
505         // and consistency-related issues in the application.
506         //
507         // Assigns the value of the specified instance to the current instance of %ControlAnimator.
508
509         //
510         // @since        2.0
511         //
512         ControlAnimator& operator =(const ControlAnimator& rhs);
513
514
515         friend class Tizen::Ui::_ControlImpl;
516         friend class FrameAnimator;
517 };              // ControlAnimator
518
519
520 }}}             // Tizen::Ui::Animations
521
522 #endif //_FUI_ANIM_CONTROL_ANIMATOR_H_