move elementary to trunk base. out of TMP/st.
[framework/uifw/elementary.git] / src / lib / elm_transit.c
1 #include <Elementary.h>
2 #include "elm_priv.h"
3
4 #define ELM_TRANSIT_CHECK_OR_RETURN(transit, ...) \
5    do { \
6       if (!transit) { \
7          CRITICAL("Elm_Transit " # transit " is NULL!"); \
8          return __VA_ARGS__; \
9       } \
10       if (!EINA_MAGIC_CHECK(transit, ELM_TRANSIT_MAGIC)) { \
11          EINA_MAGIC_FAIL(transit, ELM_TRANSIT_MAGIC); \
12          return __VA_ARGS__; \
13       } \
14       if (transit->deleted){ \
15          ERR("Elm_Transit " # transit " has already been deleted!"); \
16          return __VA_ARGS__; \
17       } \
18    } while (0)
19
20 /**
21  *
22  * @defgroup Transit Transit
23  * @ingroup Elementary
24  *
25  * Transit (see Warning below) is designed to set the various effects for the
26  * Evas_Object such like translation, rotation, etc. For using Effects, Create
27  * transit and insert effects which are interesting.
28  * Once effects are inserted into transit, transit will manage those effects.
29  * (ex deleting).
30  *
31  * Example:
32  * @code
33  * Elm_Transit *trans = elm_transit_add();
34  * elm_transit_object_add(trans, obj);
35  * void *effect_context = elm_transit_effect_translation_context_new(0.0, 0.0,
36  *                                                               280.0, 280.0);
37  * elm_transit_effect_add(transit,
38  *                        elm_transit_effect_translation_op, effect_context,
39  *                        elm_transit_effect_translation_context_free);
40  * elm_transit_duration_set(transit, 5);
41  * elm_transit_auto_reverse_set(transit, EINA_TRUE);
42  * elm_transit_tween_mode_set(transit, ELM_TRANSIT_TWEEN_MODE_DECELERATE);
43  * elm_transit_repeat_times_set(transit, -1);
44  * @endcode
45  *
46  * @warning We strongly recomend to use elm_transit just when edje can not do
47  * the trick. Edje has more advantage than Elm_Transit, it has more flexibility and
48  * animations can be manipulated inside the theme.
49  */
50
51 static const char _transit_key[] = "_elm_transit";
52
53 #define FOCAL 2000
54
55 struct _Elm_Transit
56 {
57 #define ELM_TRANSIT_MAGIC 0xd27f190a
58    EINA_MAGIC;
59
60    Ecore_Animator *animator;
61    Eina_List *effect_list;
62    Eina_List *objs;
63    Elm_Transit_Tween_Mode tween_mode;
64    struct {
65       void (*func) (void *data, Elm_Transit *transit);
66       void *arg;
67    } del_data;
68    struct {
69       double delayed;
70       double paused;
71       double duration;
72       double begin;
73       double current;
74    } time;
75    struct {
76       int count;
77       int current;
78       Eina_Bool reverse;
79    } repeat;
80    double progress;
81    unsigned int effects_pending_del;
82    int walking;
83    Eina_Bool auto_reverse : 1;
84    Eina_Bool event_enabled : 1;
85    Eina_Bool deleted : 1;
86 };
87
88 struct _Elm_Transit_Effect
89 {
90    void (*animation_op) (void *data, Elm_Transit *transit, double progress);
91    void (*user_data_free) (void *data, Elm_Transit *transit);
92    void *user_data;
93    Eina_Bool deleted : 1;
94 };
95
96 struct _Elm_Obj_Data
97 {
98    Eina_Bool state;
99    Elm_Transit *transit;
100 };
101
102 typedef struct _Elm_Transit_Effect Elm_Transit_Effect;
103 typedef struct _Elm_Obj_Data Elm_Obj_Data;
104
105 static void
106 _elm_transit_object_remove_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
107 {
108    Elm_Transit *transit = data;
109
110    Elm_Obj_Data *obj_data = evas_object_data_del(obj, _transit_key);
111    evas_object_pass_events_set(obj, obj_data->state);
112    free(obj_data);
113    transit->objs = eina_list_remove(transit->objs, obj);
114    if (!transit->objs) elm_transit_del(transit);
115 }
116
117 static void
118 _elm_transit_object_remove(Elm_Transit *transit, Evas_Object *obj)
119 {
120    Elm_Obj_Data *obj_data = evas_object_data_del(obj, _transit_key);
121    
122    evas_object_pass_events_set(obj, obj_data->state);
123    free(obj_data);
124    transit->objs = eina_list_remove(transit->objs, obj);
125    evas_object_event_callback_del(obj, EVAS_CALLBACK_DEL,
126                                   _elm_transit_object_remove_cb);
127 }
128
129 static void
130 _elm_transit_effect_del(Elm_Transit *transit, Elm_Transit_Effect *effect, Eina_List *elist)
131 {
132    if (effect->user_data_free)
133       effect->user_data_free(effect->user_data, transit);
134
135    transit->effect_list = eina_list_remove_list(transit->effect_list, elist);
136    free(effect);
137 }
138
139 static void
140 _remove_dead_effects(Elm_Transit *transit)
141 {
142    Eina_List *elist, *elist_next;
143    Elm_Transit_Effect *effect;
144
145    EINA_LIST_FOREACH_SAFE(transit->effect_list, elist, elist_next, effect)
146      {
147         if (effect->deleted)
148           {
149              _elm_transit_effect_del(transit, effect, elist);
150              transit->effects_pending_del--;
151              if (!transit->effects_pending_del) return;
152           }
153      }
154 }
155
156 static void
157 _elm_transit_del(Elm_Transit *transit)
158 {
159    Eina_List *elist, *elist_next;
160    Elm_Transit_Effect *effect;
161
162    if (transit->animator)
163       ecore_animator_del(transit->animator);
164
165    if (transit->del_data.func)
166       transit->del_data.func(transit->del_data.arg, transit);
167
168    EINA_LIST_FOREACH_SAFE(transit->effect_list, elist, elist_next, effect)
169       _elm_transit_effect_del(transit, effect, elist);
170    
171    while (transit->objs)
172       _elm_transit_object_remove(transit, eina_list_data_get(transit->objs));
173    
174    EINA_MAGIC_SET(transit, EINA_MAGIC_NONE);
175    free(transit);
176 }
177
178 static void
179 _transit_animate_op(Elm_Transit *transit, double progress)
180 {
181    Eina_List *elist;
182    Elm_Transit_Effect *effect;
183
184    transit->walking++;
185    EINA_LIST_FOREACH(transit->effect_list, elist, effect)
186      {
187         if (transit->deleted) break;
188         if (!effect->deleted)
189            effect->animation_op(effect->user_data, transit, progress);
190      }
191    transit->walking--;
192    
193    if (transit->walking) return;
194    
195    if (transit->deleted) _elm_transit_del(transit);
196    else if (transit->effects_pending_del) _remove_dead_effects(transit);
197 }
198
199 static Eina_Bool
200 _animator_animate_cb(void *data)
201 {
202    Elm_Transit *transit = data;
203    double elapsed_time, duration;
204
205    transit->time.current = ecore_loop_time_get();
206    elapsed_time = transit->time.current - transit->time.begin;
207    duration = transit->time.duration + transit->time.delayed; 
208
209    if (elapsed_time > duration) 
210       elapsed_time = duration;
211
212    transit->progress = elapsed_time / duration;
213    switch (transit->tween_mode)
214      {
215       case ELM_TRANSIT_TWEEN_MODE_ACCELERATE:
216         transit->progress = 1.0 - sin((ELM_PI / 2.0) + (transit->progress * ELM_PI / 2.0));
217         break;
218       case ELM_TRANSIT_TWEEN_MODE_DECELERATE:
219         transit->progress = sin(transit->progress * ELM_PI / 2.0);
220         break;
221       case ELM_TRANSIT_TWEEN_MODE_SINUSOIDAL:
222         transit->progress = (1.0 - cos(transit->progress * ELM_PI)) / 2.0;
223         break;
224       default:
225         break;
226      }
227    
228    /* Reverse? */
229    if (transit->repeat.reverse) transit->progress = 1 - transit->progress;
230    
231    if (transit->time.duration > 0) _transit_animate_op(transit, transit->progress);
232    
233    /* Not end. Keep going. */
234    if (elapsed_time < duration) return ECORE_CALLBACK_RENEW;
235
236    /* Repeat and reverse and time done! */
237    if ((transit->repeat.current == transit->repeat.count)
238        && (!transit->auto_reverse || transit->repeat.reverse))
239      {
240         elm_transit_del(transit);
241         return ECORE_CALLBACK_CANCEL;
242      }
243    
244    /* Repeat Case */
245    if (!transit->auto_reverse || transit->repeat.reverse)
246      {
247         transit->repeat.current++;
248         transit->repeat.reverse = EINA_FALSE;
249      }
250    else transit->repeat.reverse = EINA_TRUE;
251    
252    transit->time.begin = ecore_loop_time_get();
253    
254    return ECORE_CALLBACK_RENEW;
255 }
256
257 /**
258  * Add new transit.
259  *
260  * @note Is not necessary to delete the transit object, it will be deleted at
261  * the end of its operation.
262  * @note The transit will start playing when the program enter in the main loop, is not
263  * necessary to give a start to the transit.
264  *
265  * @param duration The duration of the transit in seconds. When transit starts
266  * to run, it will last a @p duration time.
267  * @return The transit object.
268  *
269  * @ingroup Transit
270  */
271 EAPI Elm_Transit *
272 elm_transit_add(void)
273 {
274    Elm_Transit *transit = ELM_NEW(Elm_Transit);
275    if (!transit) return NULL;
276    
277    EINA_MAGIC_SET(transit, ELM_TRANSIT_MAGIC);
278
279    elm_transit_tween_mode_set(transit, ELM_TRANSIT_TWEEN_MODE_LINEAR);
280         
281    return transit;
282 }
283 /**
284  * Stops the animation and delete the @p transit object.
285  *
286  * Call this function if you wants to stop the animation before the duration
287  * time. Make sure the @p transit object is still alive with
288  * elm_transit_del_cb_set() function.
289  * All added effects will be deleted, calling its repective data_free_cb
290  * functions. The function setted by elm_tansit_del_cb_set() will be called.
291  *
292  * @see elm_transit_del_cb_set()
293  *
294  * @param transit The transit object to be deleted.
295  *
296  * @ingroup Transit
297  * @warning Just call this function if you are sure the transit is alive.
298  */
299 EAPI void
300 elm_transit_del(Elm_Transit *transit)
301 {
302    ELM_TRANSIT_CHECK_OR_RETURN(transit);
303
304    if (transit->walking) transit->deleted = EINA_TRUE;
305    else _elm_transit_del(transit);
306 }
307
308 /**
309  * Add a new effect to the transit.
310  *
311  * @note The cb function and the data are the key to the effect. If you try to
312  * add an already added effect, nothing is done.
313  * @note After the first addition of an effect in @p transit, if its
314  * effect list become empty again, the @p transit will be killed by
315  * elm_transit_del(transit) function.
316  *
317  * Exemple:
318  * @code
319  * Elm_Transit *transit = elm_transit_add();
320  * elm_transit_effect_add(transit,
321  *                        elm_transit_effect_blend_op,
322  *                        elm_transit_effect_blend_context_new(),
323  *                        elm_transit_effect_blend_context_free);
324  * @endcode
325  *
326  * @param transit The transit object.
327  * @param cb The operation function. It is called when the animation begins,
328  * it is the function that actually performs the animation. It is called with
329  * the @p data, @p transit and the time progression of the animation (a double
330  * value between 0.0 and 1.0).
331  * @param data The context data of the effect.
332  * @param data_free_cb The function to free the context data, it will be called
333  * at the end of the effect, it must finalize the animation and free the
334  * @p data.
335  *
336  * @ingroup Transit
337  * @warning The transit free the context data at the and of the transition with
338  * the data_free_cb function, do not use the context data in another transit.
339  */
340 EAPI void
341 elm_transit_effect_add(Elm_Transit *transit, void (*cb)(void *data, Elm_Transit *transit, double progress), void *data, void (*data_free_cb)(void *data, Elm_Transit *transit))
342 {
343    ELM_TRANSIT_CHECK_OR_RETURN(transit);
344    EINA_SAFETY_ON_NULL_RETURN(cb);
345    Elm_Transit_Effect *effect;
346    Eina_List *elist;
347
348    EINA_LIST_FOREACH(transit->effect_list, elist, effect)
349      {
350         if ((effect->animation_op == cb) && (effect->user_data == data)) return;
351      }
352
353    effect = ELM_NEW(Elm_Transit_Effect);
354    if (!effect) return;
355    
356    effect->user_data_free = data_free_cb;
357    effect->animation_op = cb;
358    effect->user_data = data;
359
360    transit->effect_list = eina_list_append(transit->effect_list, effect);
361 }
362
363 /**
364  * Delete an added effect.
365  *
366  * This function will remove the effect from the @p transit, calling the
367  * data_free_cb to free the @p data.
368  *
369  * @see elm_transit_effect_add()
370  *
371  * @note If the effect is not found, nothing is done.
372  * @note If the effect list become empty, this function will call
373  * elm_transit_del(transit), that is, it will kill the @p transit.
374  *
375  * @param transit The transit object.
376  * @param cb The operation function.
377  * @param data The context data of the effect.
378  *
379  * @ingroup Transit
380  */
381 EAPI void
382 elm_transit_effect_del(Elm_Transit *transit, void (*cb)(void *data, Elm_Transit *transit, double progress), void *data)
383 {
384    ELM_TRANSIT_CHECK_OR_RETURN(transit);
385    EINA_SAFETY_ON_NULL_RETURN(cb);
386    Eina_List *elist, *elist_next;
387    Elm_Transit_Effect *effect;
388
389    EINA_LIST_FOREACH_SAFE(transit->effect_list, elist, elist_next, effect)
390      {
391         if ((effect->animation_op == cb) && (effect->user_data == data))
392           {
393              if (transit->walking)
394                {
395                   effect->deleted = EINA_TRUE;
396                   transit->effects_pending_del++;
397                }
398              else
399                {
400                   _elm_transit_effect_del(transit, effect, elist);
401                   if (!transit->effect_list) elm_transit_del(transit);
402                }
403              return;
404           }
405      }
406 }
407
408 /**
409  * Add new object to apply the effects.
410  *
411  * @note After the first addition of an object in @p transit, if its
412  * object list become empty again, the @p transit will be killed by
413  * elm_transit_del(transit) function.
414  * @note If the @p obj belongs to another transit, the @p obj will be
415  * removed from it and it will only belong to the @p transit. If the old
416  * transit stays without objects, it will die.
417  * @note When you add an object into the @p transit, its state from
418  * evas_object_pass_events_get(obj) is saved, and it is applied when the
419  * transit ends, if you change this state whith evas_object_pass_events_set()
420  * after add the object, this state will change again when @p transit stops to
421  * run.
422  *
423  * @param transit The transit object.
424  * @param obj Object to be animated.
425  *
426  * @ingroup Transit
427  * @warning See the documentation of the effect if is safe add or remove
428  * an object after @p transit begins to run.
429  */
430 EAPI void
431 elm_transit_object_add(Elm_Transit *transit, Evas_Object *obj)
432 {
433    ELM_TRANSIT_CHECK_OR_RETURN(transit);
434    EINA_SAFETY_ON_NULL_RETURN(obj);
435    Elm_Obj_Data *obj_data = evas_object_data_get(obj, _transit_key);
436
437    if (obj_data)
438      {
439         if (obj_data->transit == transit) return;
440         elm_transit_object_remove(obj_data->transit, obj);
441      }
442    
443    obj_data = ELM_NEW(Elm_Obj_Data);
444    obj_data->state = evas_object_pass_events_get(obj);
445    obj_data->transit = transit;
446    evas_object_data_set(obj, _transit_key, obj_data);
447    
448    transit->objs = eina_list_append(transit->objs, obj);
449    
450    if (!transit->event_enabled) 
451       evas_object_pass_events_set(obj, EINA_TRUE);
452    
453    evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
454                                   _elm_transit_object_remove_cb, transit);
455 }
456
457 /**
458  * Removes an added object from the transit.
459  *
460  * @note If the @p obj is not in the @p transit, nothing is done.
461  * @note If the list become empty, this function will call
462  * elm_transit_del(transit), that is, it will kill the @p transit.
463  *
464  * @param transit The transit object.
465  * @param obj Object to be removed from @p transit.
466  *
467  * @ingroup Transit
468  * @warning See the documentation of the effect if is safe add or remove
469  * an object after @p transit begins to run.
470  */
471 EAPI void
472 elm_transit_object_remove(Elm_Transit *transit, Evas_Object *obj)
473 {
474    ELM_TRANSIT_CHECK_OR_RETURN(transit);
475    EINA_SAFETY_ON_NULL_RETURN(obj);
476    Elm_Obj_Data *obj_data = evas_object_data_get(obj, _transit_key);
477    if ((!obj_data) || (obj_data->transit != transit)) return;
478
479    _elm_transit_object_remove(transit, obj);
480    if (!transit->objs) elm_transit_del(transit);
481 }
482
483 /**
484  * Get the objects of the transit.
485  *
486  * @param transit The transit object.
487  * @return a Eina_List with the objects from the transit.
488  *
489  * @ingroup Transit
490  */
491 EAPI const Eina_List *
492 elm_transit_objects_get(const Elm_Transit *transit)
493 {
494    ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
495    return transit->objs;
496 }
497
498 /**
499  * Set the event enabled when transit is operating.
500  *
501  * If @p enabled is EINA_TRUE, the objects of the transit will receives
502  * events from mouse and keyboard during the animation.
503  * @note When you add an object with elm_transit_object_add(), its state from
504  * evas_object_pass_events_get(obj) is saved, and it is applied when the
505  * transit ends, if you change this state with evas_object_pass_events_set()
506  * after add the object, this state will change again when @p transit stops to
507  * run.
508  *
509  * @param transit The transit object.
510  * @param enabled Disable or enable.
511  *
512  * @ingroup Transit
513  */
514 EAPI void
515 elm_transit_event_enabled_set(Elm_Transit *transit, Eina_Bool enabled)
516 {
517    ELM_TRANSIT_CHECK_OR_RETURN(transit);
518    Evas_Object *obj;
519    Eina_List *elist;
520    Elm_Obj_Data *obj_data;
521
522    if (transit->event_enabled == enabled) return;
523
524    transit->event_enabled = enabled;
525
526    if (enabled)
527      {
528         EINA_LIST_FOREACH(transit->objs, elist, obj)
529           {
530              obj_data = evas_object_data_get(obj, _transit_key);
531              evas_object_pass_events_set(obj, obj_data->state);
532           }
533      }
534    else
535      {
536         EINA_LIST_FOREACH(transit->objs, elist, obj)
537            evas_object_pass_events_set(obj, EINA_TRUE);
538      }
539 }
540
541 /**
542  * Get the value of event enabled status.
543  *
544  * @see elm_transit_event_enabled_set()
545  *
546  * @param transit The Transit object
547  * @return EINA_TRUE, when event is enabled. If @p transit is NULL
548  * EINA_FALSE is returned
549  *
550  * @ingroup Transit
551  */
552 EAPI Eina_Bool
553 elm_transit_event_enabled_get(const Elm_Transit *transit)
554 {
555    ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
556
557    return transit->event_enabled;
558 }
559
560
561 /**
562  * Set the event enabled when transit is operating.
563  *
564  * If @p disabled is EINA_TRUE, the objects of the transit will receives
565  * events from mouse and keyboard during the animation.
566  * @note When you add an object with elm_transit_object_add(), its state from
567  * evas_object_pass_events_get(obj) is saved, and it is applied when the
568  * transit ends, if you change this state with evas_object_pass_events_set()
569  * after add the object, this state will change again when @p transit stops to
570  * run.
571  *
572  * @see elm_transit_event_enabled_set()
573  *
574  * @param transit The transit object.
575  * @param disabled Disable or enable.
576  *
577  * @ingroup Transit
578  */
579 EINA_DEPRECATED EAPI void
580 elm_transit_event_block_set(Elm_Transit *transit, Eina_Bool disabled)
581 {
582    elm_transit_event_enabled_set(transit, disabled);
583 }
584
585
586 /**
587  * Get the value of event block enabled  status.
588  *
589  * @see elm_transit_event_enabled_set(), elm_transit_event_enabled_get()
590  *
591  * @param transit The Transit object
592  * @return EINA_TRUE, when event is enabled. If @p transit is NULL
593  * EINA_FALSE is returned
594  *
595  * @ingroup Transit
596  */
597 EINA_DEPRECATED EAPI Eina_Bool
598 elm_transit_event_block_get(const Elm_Transit *transit)
599 {
600    return !elm_transit_event_enabled_get(transit);
601 }
602
603 /**
604  * Set the user-callback function when the transit is deleted.
605  *
606  * @note Using this function twice will overwrite the first function setted.
607  * @note the @p transit object will be deleted after call @p cb function.
608  *
609  * @param transit The transit object.
610  * @param cb Callback function pointer. This function will be called before
611  * the deletion of the transit.
612  * @param data Callback funtion user data. It is the @p op parameter.
613  *
614  * @ingroup Transit
615  */
616 EAPI void
617 elm_transit_del_cb_set(Elm_Transit *transit, void (*cb) (void *data, Elm_Transit *transit), void *data)
618 {
619    ELM_TRANSIT_CHECK_OR_RETURN(transit);
620    transit->del_data.func = cb;
621    transit->del_data.arg = data;
622 }
623
624 /**
625  * Set reverse effect automatically.
626  *
627  * If auto reverse is setted, after running the effects with the progress
628  * parameter from 0 to 1, it will call the effecs again with the progress
629  * from 1 to 0. The transit will last for a time iqual to (2 * duration * repeat),
630  * where the duration was setted with the function elm_transit_add and
631  * the repeat with the function elm_transit_repeat_times_set().
632  *
633  * @param transit The transit object.
634  * @param reverse EINA_TRUE means the auto_reverse is on.
635  *
636  * @ingroup Transit
637  */
638 EAPI void
639 elm_transit_auto_reverse_set(Elm_Transit *transit, Eina_Bool reverse)
640 {
641    ELM_TRANSIT_CHECK_OR_RETURN(transit);
642    transit->auto_reverse = reverse;
643 }
644
645 /**
646  * Get if the auto reverse is on.
647  *
648  * @see elm_transit_auto_reverse_set()
649  *
650  * @param transit The transit object.
651  * @return EINA_TRUE means auto reverse is on. If @p transit is NULL
652  * EINA_FALSE is returned
653  *
654  * @ingroup Transit
655  */
656 EAPI Eina_Bool
657 elm_transit_auto_reverse_get(Elm_Transit *transit)
658 {
659    ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
660    return transit->auto_reverse;
661 }
662
663 /**
664  * Set the transit repeat count. Effect will be repeated by repeat count.
665  *
666  * This function sets the number of repetition the transit will run after
667  * the first one, that is, if @p repeat is 1, the transit will run 2 times.
668  * If the @p repeat is a negative number, it will repeat infinite times.
669  *
670  * @note If this function is called during the transit execution, the transit
671  * will run @p repeat times, ignoring the times it already performed.
672  *
673  * @param transit The transit object
674  * @param repeat Repeat count
675  *
676  * @ingroup Transit
677  */
678 EAPI void
679 elm_transit_repeat_times_set(Elm_Transit *transit, int repeat)
680 {
681    ELM_TRANSIT_CHECK_OR_RETURN(transit);
682    transit->repeat.count = repeat;
683    transit->repeat.current = 0;
684 }
685
686 /**
687  * Get the transit repeat count.
688  *
689  * @see elm_transit_repeat_times_set()
690  *
691  * @param transit The Transit object.
692  * @return The repeat count. If @p transit is NULL
693  * 0 is returned
694  *
695  * @ingroup Transit
696  */
697 EAPI int
698 elm_transit_repeat_times_get(Elm_Transit *transit)
699 {
700    ELM_TRANSIT_CHECK_OR_RETURN(transit, 0);
701    return transit->repeat.count;
702 }
703
704 /**
705  * Set the transit animation acceleration type.
706  *
707  * This function sets the tween mode of the transit that can be:
708  * ELM_TRANSIT_TWEEN_MODE_LINEAR - The default mode.
709  * ELM_TRANSIT_TWEEN_MODE_SINUSOIDAL - Starts in accelerate mode and ends decelerating.
710  * ELM_TRANSIT_TWEEN_MODE_DECELERATE - The animation will be slowed over time.
711  * ELM_TRANSIT_TWEEN_MODE_ACCELERATE - The animation will accelerate over time.
712  *
713  * @param transit The transit object.
714  * @param tween_mode The tween type.
715  *
716  * @ingroup Transit
717  */
718 EAPI void
719 elm_transit_tween_mode_set(Elm_Transit *transit, Elm_Transit_Tween_Mode tween_mode)
720 {
721    ELM_TRANSIT_CHECK_OR_RETURN(transit);
722
723    transit->tween_mode = tween_mode;
724 }
725
726 /**
727  * Get the transit animation acceleration type.
728  *
729  * @note @p transit can not be NULL
730  *
731  * @param transit The transit object.
732  * @return The tween type. If @p transit is NULL
733  * ELM_TRANSIT_TWEEN_MODE_LINEAR is returned.
734  *
735  * @ingroup Transit
736  */
737 EAPI Elm_Transit_Tween_Mode
738 elm_transit_tween_mode_get(const Elm_Transit *transit)
739 {
740    ELM_TRANSIT_CHECK_OR_RETURN(transit, ELM_TRANSIT_TWEEN_MODE_LINEAR);
741    return transit->tween_mode;
742 }
743
744 /**
745  * Set the transit animation time
746  *
747  * @note @p transit can not be NULL
748  *
749  * @param transit The transit object.
750  * @param duration The animation time.
751  *
752  * @ingroup Transit
753  */
754 EAPI void
755 elm_transit_duration_set(Elm_Transit *transit, double duration)
756 {
757    ELM_TRANSIT_CHECK_OR_RETURN(transit);
758    if (transit->animator) return;
759    transit->time.duration = duration;
760 }
761
762 /**
763  * Get the transit animation time
764  *
765  * @note @p transit can not be NULL
766  *
767  * @param transit The transit object.
768  *
769  * @return The transit animation time.
770  *
771  * @ingroup Transit
772  */
773 EAPI double 
774 elm_transit_duration_get(const Elm_Transit *transit)
775 {
776    ELM_TRANSIT_CHECK_OR_RETURN(transit, 0.0);
777    return transit->time.duration;
778 }
779
780 /**
781  * Starts the transition. 
782  * Once this API is called, the transit begins to measure the time.
783  *
784  * @note @p transit can not be NULL
785  *
786  * @param transit The transit object.
787  *
788  * @ingroup Transit
789  */
790 EAPI void
791 elm_transit_go(Elm_Transit *transit)
792 {
793    ELM_TRANSIT_CHECK_OR_RETURN(transit);
794
795    if (transit->animator)
796       ecore_animator_del(transit->animator);
797
798    transit->time.paused = 0;
799    transit->time.delayed = 0;
800    transit->time.begin = ecore_loop_time_get();
801    transit->animator = ecore_animator_add(_animator_animate_cb, transit);
802 }
803
804 /**
805  * Pause/Resume the transition. 
806  * If you call elm_transit_go again, paused states will affect no anymore. 
807  *
808  * @note @p transit can not be NULL
809  *
810  * @param transit The transit object.
811  *
812  * @ingroup Transit
813  */
814 EAPI void
815 elm_transit_paused_set(Elm_Transit *transit, Eina_Bool paused)
816 {
817    ELM_TRANSIT_CHECK_OR_RETURN(transit);
818
819    if (!transit->animator) return;
820
821    if (paused)
822      {
823         if (transit->time.paused > 0) 
824            return;
825         ecore_animator_freeze(transit->animator);
826         transit->time.paused = ecore_loop_time_get();
827      }
828    else
829      {
830         if (transit->time.paused == 0) 
831            return;
832         ecore_animator_thaw(transit->animator);
833         transit->time.delayed += (ecore_loop_time_get() - transit->time.paused);
834         transit->time.paused = 0;
835      }
836 }
837
838 /**
839  * Get the value of paused status. 
840  *
841  * @see elm_transit_paused_set()
842  *
843  * @note @p transit can not be NULL
844  *
845  * @param transit The transit object.
846  * @return EINA_TRUE means transition is paused. If @p transit is NULL
847  * EINA_FALSE is returned
848  *
849  * @ingroup Transit
850  */
851 EAPI Eina_Bool
852 elm_transit_paused_get(const Elm_Transit *transit)
853 {
854    ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
855
856    if (transit->time.paused == 0) 
857       return EINA_FALSE;
858
859    return EINA_TRUE;
860 }
861
862 /**
863  * Get the time progression of the animation (a double value between 0.0 and 1.0).
864  *
865  * @note @p transit can not be NULL
866  *
867  * @param transit The transit object.
868  *
869  * @return The time progression value. If @p transit is NULL
870  * 0 is returned
871  *
872  * @ingroup Transit
873  */
874 EAPI double
875 elm_transit_progress_value_get(const Elm_Transit *transit)
876 {
877    ELM_TRANSIT_CHECK_OR_RETURN(transit, 0);
878
879    return transit->progress;
880 }
881
882 ///////////////////////////////////////////////////////////////////////////////
883 //Resizing FX
884 ///////////////////////////////////////////////////////////////////////////////
885 typedef struct _Elm_Transit_Effect_Resizing Elm_Transit_Effect_Resizing;
886
887 struct _Elm_Transit_Effect_Resizing
888 {
889    struct _size {
890       Evas_Coord w, h;
891    } from, to;
892 };
893
894 static void
895 _transit_effect_resizing_context_free(void *data, Elm_Transit *transit __UNUSED__)
896 {
897    free(data);
898 }
899
900 static void
901 _transit_effect_resizing_op(void *data, Elm_Transit *transit, double progress)
902 {
903    EINA_SAFETY_ON_NULL_RETURN(data);
904    EINA_SAFETY_ON_NULL_RETURN(transit);
905    Evas_Coord w, h;
906    Evas_Object *obj;
907    Eina_List *elist;
908    Elm_Transit_Effect_Resizing *resizing = data;
909
910    w = resizing->from.w + (resizing->to.w * progress);
911    h = resizing->from.h + (resizing->to.h * progress);
912    
913    EINA_LIST_FOREACH(transit->objs, elist, obj)
914       evas_object_resize(obj, w, h);
915 }
916
917 static void *
918 _transit_effect_resizing_context_new(Evas_Coord from_w, Evas_Coord from_h, Evas_Coord to_w, Evas_Coord to_h)
919 {
920    Elm_Transit_Effect_Resizing *resizing;
921
922    resizing = ELM_NEW(Elm_Transit_Effect_Resizing);
923    if (!resizing) return NULL;
924
925    resizing->from.w = from_w;
926    resizing->from.h = from_h;
927    resizing->to.w = to_w - from_w;
928    resizing->to.h = to_h - from_h;
929
930    return resizing;
931 }
932
933 /**
934  * Add the Resizing Effect to Elm_Transit.
935  *
936  * @note This API is one of the facades. It creates resizing effect context 
937  * and add it's required APIs to elm_transit_effect_add. 
938  * @note This effect will be applied to the objects that are in the transit,
939  * @note If you change the set of objects in the transit with  elm_transit_object_add()
940  * or elm_transit_object_remove(), the set of objects affected by this effect
941  * will be changed too.
942  *
943  * @see elm_transit_effect_add()
944  *
945  * @param transit Transit object.
946  * @param from_w Object width size when effect begins.
947  * @param from_h Object height size when effect begins.
948  * @param to_w Object width size when effect ends.
949  * @param to_h Object height size when effect ends.
950  * @return Resizing effect context data.
951  *
952  * @ingroup Transit
953 */
954 EAPI void *
955 elm_transit_effect_resizing_add(Elm_Transit *transit, Evas_Coord from_w, Evas_Coord from_h, Evas_Coord to_w, Evas_Coord to_h)
956 {
957    ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
958    void *effect_context = _transit_effect_resizing_context_new(from_w, from_h, to_w, to_h);
959    
960    if (!effect_context) return NULL;
961    elm_transit_effect_add(transit, 
962                           _transit_effect_resizing_op, effect_context,
963                           _transit_effect_resizing_context_free);
964    return effect_context;
965 }
966
967 ///////////////////////////////////////////////////////////////////////////////
968 //Translation FX
969 ///////////////////////////////////////////////////////////////////////////////
970 typedef struct _Elm_Transit_Effect_Translation Elm_Transit_Effect_Translation;
971 typedef struct _Elm_Transit_Effect_Translation_Node Elm_Transit_Effect_Translation_Node;
972
973 struct _Elm_Transit_Effect_Translation_Node
974 {
975    Evas_Object *obj;
976    Evas_Coord x, y;
977 };
978
979 struct _Elm_Transit_Effect_Translation
980 {
981    struct _position_variation {
982       Evas_Coord dx, dy;
983    } from, to;
984    Eina_List *nodes;
985 };
986
987 static void
988 _translation_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
989 {
990    Elm_Transit_Effect_Translation *translation = data;
991    Eina_List *elist;
992    Elm_Transit_Effect_Translation_Node *translation_node;
993    
994    EINA_LIST_FOREACH(translation->nodes, elist, translation_node)
995      {
996         if (translation_node->obj != obj) continue;
997         translation->nodes = eina_list_remove_list(translation->nodes, elist);
998         free(translation_node);
999         break;
1000      }
1001 }
1002
1003 static Eina_List *
1004 _translation_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Translation *translation)
1005 {
1006    Elm_Transit_Effect_Translation_Node *translation_node;
1007    const Eina_List *elist;
1008    Evas_Object *obj;
1009    Eina_List *data_list = NULL;
1010    const Eina_List *objs = elm_transit_objects_get(transit);
1011    
1012    EINA_LIST_FOREACH(objs, elist, obj)
1013      {
1014         translation_node = ELM_NEW(Elm_Transit_Effect_Translation_Node);
1015         if (!translation_node)
1016           {
1017              eina_list_free(data_list);
1018              return NULL;
1019           }
1020         translation_node->obj = obj;
1021         evas_object_geometry_get(obj, &(translation_node->x),
1022                                  &(translation_node->y), NULL, NULL);
1023         data_list = eina_list_append(data_list, translation_node);
1024         evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
1025                                        _translation_object_del_cb, translation);
1026      }
1027    return data_list;
1028 }
1029
1030 void
1031 _transit_effect_translation_context_free(void *data, Elm_Transit *transit __UNUSED__)
1032 {
1033    EINA_SAFETY_ON_NULL_RETURN(data);
1034    Elm_Transit_Effect_Translation *translation = data;
1035    Eina_List *elist, *elist_next;
1036    Elm_Transit_Effect_Translation_Node *translation_node;
1037
1038    EINA_LIST_FOREACH_SAFE(translation->nodes,
1039                           elist, elist_next, translation_node)
1040      {
1041         evas_object_event_callback_del(translation_node->obj,
1042                                        EVAS_CALLBACK_DEL, _translation_object_del_cb);
1043         translation->nodes = eina_list_remove_list(translation->nodes, elist);
1044         free(translation_node);
1045      }
1046    free(translation);
1047 }
1048
1049 void
1050 _transit_effect_translation_op(void *data, Elm_Transit *transit, double progress __UNUSED__)
1051 {
1052    EINA_SAFETY_ON_NULL_RETURN(data);
1053    EINA_SAFETY_ON_NULL_RETURN(transit);
1054    Evas_Coord x, y;
1055    Elm_Transit_Effect_Translation *translation = data;
1056    Elm_Transit_Effect_Translation_Node *translation_node;
1057    Eina_List *elist;
1058    
1059    if (!translation->nodes)
1060       translation->nodes = _translation_nodes_build(transit, translation);
1061    
1062    EINA_LIST_FOREACH(translation->nodes, elist, translation_node)
1063      {
1064         x = translation_node->x + translation->from.dx
1065            + (translation->to.dx * progress);
1066         y = translation_node->y + translation->from.dy
1067            + (translation->to.dy * progress);
1068         evas_object_move(translation_node->obj, x, y);
1069      }
1070 }
1071
1072 static void *
1073 _transit_effect_translation_context_new(Evas_Coord from_dx, Evas_Coord from_dy, Evas_Coord to_dx, Evas_Coord to_dy)
1074 {
1075    Elm_Transit_Effect_Translation *translation;
1076
1077    translation = ELM_NEW(Elm_Transit_Effect_Translation);
1078    if (!translation) return NULL;
1079
1080    translation->from.dx = from_dx;
1081    translation->from.dy = from_dy;
1082    translation->to.dx = to_dx - from_dx;
1083    translation->to.dy = to_dy - from_dy;
1084
1085    return translation;
1086 }
1087
1088 /**
1089  * Add the Translation Effect to Elm_Transit.
1090  *
1091  * @note This API is one of the facades. It creates translation effect context 
1092  * and add it's required APIs to elm_transit_effect_add. 
1093  * @note When this function is called, it gets the current objects in
1094  * the transit, that is, elm_transit_object_remove() and elm_transit_object_add()
1095  * will not cause any changes in the set of objects that this effect is being
1096  * applied.
1097  *
1098  * @see elm_transit_effect_add()
1099  *
1100  * @param transit Transit object.
1101  * @param from_dx X Position variation when effect begins.
1102  * @param from_dy Y Position variation when effect begins.
1103  * @param to_dx X Position variation when effect ends.
1104  * @param to_dy Y Position variation when effect ends.
1105  * @return Translation effect context data.
1106  *
1107  * @ingroup Transit
1108  * @warning Is higher recommended just create a transit with this effect when
1109  * the window that the objects of the transit belongs has already been created.
1110  * This is because this effect needs the geometry information about the objects,
1111  * and if the window was not created yet, it can get a wrong information.
1112  * @warning Is not recommended remove or add an object after the transit begins
1113  * to run, because the order of the objects will be affected.
1114  */
1115 EAPI void *
1116 elm_transit_effect_translation_add(Elm_Transit *transit, Evas_Coord from_dx, Evas_Coord from_dy, Evas_Coord to_dx, Evas_Coord to_dy)
1117 {
1118    ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1119    void *effect_context = _transit_effect_translation_context_new(from_dx, from_dy, to_dx, to_dy);
1120    
1121    if (!effect_context) return NULL;
1122    elm_transit_effect_add(transit, 
1123                           _transit_effect_translation_op, effect_context,
1124                           _transit_effect_translation_context_free);
1125    return effect_context;
1126 }
1127
1128
1129 ///////////////////////////////////////////////////////////////////////////////
1130 //Zoom FX
1131 ///////////////////////////////////////////////////////////////////////////////
1132 typedef struct _Elm_Transit_Effect_Zoom Elm_Transit_Effect_Zoom;
1133
1134 struct _Elm_Transit_Effect_Zoom
1135 {
1136    float from, to;
1137 };
1138
1139 void
1140 _transit_effect_zoom_context_free(void *data, Elm_Transit *transit __UNUSED__)
1141 {
1142    free(data);
1143 }
1144
1145 static void
1146 _transit_effect_zoom_op(void *data, Elm_Transit *transit , double progress)
1147 {
1148    EINA_SAFETY_ON_NULL_RETURN(data);
1149    EINA_SAFETY_ON_NULL_RETURN(transit);
1150    Evas_Object *obj;
1151    Eina_List *elist;
1152    Elm_Transit_Effect_Zoom *zoom = data;
1153    Evas_Map *map;
1154    Evas_Coord x, y, w, h;
1155
1156    map = evas_map_new(4);
1157    if (!map) return;
1158
1159    EINA_LIST_FOREACH(transit->objs, elist, obj)
1160      {
1161         evas_object_geometry_get(obj, &x, &y, &w, &h);
1162         evas_map_smooth_set(map, EINA_TRUE);
1163         evas_map_util_points_populate_from_object_full(map, obj, zoom->from +
1164                                                        (progress * zoom->to));
1165         evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, FOCAL);
1166         evas_object_map_set(obj, map);
1167         evas_object_map_enable_set(obj, EINA_TRUE);
1168      }
1169    evas_map_free(map);
1170 }
1171
1172 static void *
1173 _transit_effect_zoom_context_new(float from_rate, float to_rate)
1174 {
1175    Elm_Transit_Effect_Zoom *zoom;
1176
1177    zoom = ELM_NEW(Elm_Transit_Effect_Zoom);
1178    if (!zoom) return NULL;
1179
1180    zoom->from = (FOCAL - (from_rate * FOCAL)) * (1 / from_rate);
1181    zoom->to = ((FOCAL - (to_rate * FOCAL)) * (1 / to_rate)) - zoom->from;
1182
1183    return zoom;
1184 }
1185
1186 /**
1187  * Add the Zoom Effect to Elm_Transit.
1188  *
1189  * @note This API is one of the facades. It creates zoom effect context 
1190  * and add it's required APIs to elm_transit_effect_add. 
1191  * @note If you change the set of objects in the transit with  elm_transit_object_add()
1192  * or elm_transit_object_remove(), the set of objects affected by this effect
1193  * will be changed too.
1194  *
1195  * @see elm_transit_effect_add()
1196  *
1197  * @param transit Transit object.
1198  * @param from_rate Scale rate when effect begins (1 is current rate).
1199  * @param to_rate Scale rate when effect ends.
1200  * @return Zoom effect context data.
1201  *
1202  * @ingroup Transit
1203  * @warning Is higher recommended just create a transit with this effect when
1204  * the window that the objects of the transit belongs has already been created.
1205  * This is because this effect needs the geometry information about the objects,
1206  * and if the window was not created yet, it can get a wrong information.
1207  * @warning Is not recommended remove or add an object after the transit begins
1208  * to run, because the order of the objects will be affected.
1209  */
1210 EAPI void *
1211 elm_transit_effect_zoom_add(Elm_Transit *transit, float from_rate, float to_rate)
1212 {
1213    ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1214    void *effect_context = _transit_effect_zoom_context_new(from_rate, to_rate);
1215    
1216    if (!effect_context) return NULL;
1217    elm_transit_effect_add(transit, 
1218                           _transit_effect_zoom_op, effect_context,
1219                           _transit_effect_zoom_context_free);
1220    return effect_context;
1221 }
1222
1223
1224 ///////////////////////////////////////////////////////////////////////////////
1225 //Flip FX
1226 ///////////////////////////////////////////////////////////////////////////////
1227 typedef struct _Elm_Transit_Effect_Flip Elm_Transit_Effect_Flip;
1228
1229 struct _Elm_Transit_Effect_Flip
1230 {
1231    Elm_Transit_Effect_Flip_Axis axis;
1232    Eina_Bool cw : 1;
1233 };
1234
1235 static void
1236 _transit_effect_flip_context_free(void *data, Elm_Transit *transit)
1237 {
1238    EINA_SAFETY_ON_NULL_RETURN(data);
1239    EINA_SAFETY_ON_NULL_RETURN(transit);
1240    Evas_Object *front, *back;
1241    int i;
1242    int count = eina_list_count(transit->objs);
1243    
1244    for (i = 0; i < (count - 1); i += 2)
1245      {
1246         front = eina_list_nth(transit->objs, i);
1247         back = eina_list_nth(transit->objs, i+1);
1248         evas_object_map_enable_set(front, EINA_FALSE);
1249         evas_object_map_enable_set(back, EINA_FALSE);
1250      }
1251    free(data);
1252 }
1253
1254 static void
1255 _transit_effect_flip_op(void *data, Elm_Transit *transit, double progress)
1256 {
1257    EINA_SAFETY_ON_NULL_RETURN(data);
1258    EINA_SAFETY_ON_NULL_RETURN(transit);
1259    Evas_Object *obj, *front, *back;
1260    int count, i;
1261    Elm_Transit_Effect_Flip *flip = data;
1262    Evas_Map *map;
1263    float degree;
1264    Evas_Coord x, y, w, h;
1265
1266    map = evas_map_new(4);
1267    if (!map) return;
1268
1269    if (flip->cw) degree = (float)(progress * 180);
1270    else degree = (float)(progress * -180);
1271    
1272    count = eina_list_count(transit->objs);
1273    for (i = 0; i < (count - 1); i += 2)
1274      {
1275         Evas_Coord half_w, half_h;
1276         
1277         front = eina_list_nth(transit->objs, i);
1278         back = eina_list_nth(transit->objs, i+1);
1279         
1280         if ((degree < 90) && (degree > -90))
1281           {
1282              obj = front;
1283              if (front != back) 
1284                {
1285                   evas_object_hide(back);
1286                   evas_object_show(front);
1287                }
1288           }
1289         else
1290           {
1291              obj = back;
1292              if (front != back)
1293                {
1294                   evas_object_hide(front);
1295                   evas_object_show(back);
1296                }
1297           }
1298         
1299         evas_map_smooth_set(map, EINA_TRUE);
1300         evas_map_util_points_populate_from_object_full(map, obj, 0);
1301         evas_object_geometry_get(obj, &x, &y, &w, &h);
1302         half_w = (w / 2);
1303         half_h = (h / 2);
1304         
1305         if (flip->axis == ELM_TRANSIT_EFFECT_FLIP_AXIS_Y)
1306           {
1307              if ((degree >= 90) || (degree <= -90))
1308                {
1309                   evas_map_point_image_uv_set(map, 0, w, 0);
1310                   evas_map_point_image_uv_set(map, 1, 0, 0);
1311                   evas_map_point_image_uv_set(map, 2, 0, h);
1312                   evas_map_point_image_uv_set(map, 3, w, h);
1313                }
1314              evas_map_util_3d_rotate(map, 0, degree,
1315                                      0, x + half_w, y + half_h, 0);
1316           }
1317         else
1318           {
1319              if ((degree >= 90) || (degree <= -90))
1320                {
1321                   evas_map_point_image_uv_set(map, 0, 0, h);
1322                   evas_map_point_image_uv_set(map, 1, w, h);
1323                   evas_map_point_image_uv_set(map, 2, w, 0);
1324                   evas_map_point_image_uv_set(map, 3, 0, 0);
1325                }
1326              evas_map_util_3d_rotate(map, degree,
1327                                      0, 0, x + half_w, y + half_h, 0);
1328           }
1329         evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, FOCAL);
1330         evas_object_map_enable_set(front, EINA_TRUE);
1331         evas_object_map_enable_set(back, EINA_TRUE);
1332         evas_object_map_set(obj, map);
1333      }
1334    evas_map_free(map);
1335 }
1336
1337 static void *
1338 _transit_effect_flip_context_new(Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1339 {
1340    Elm_Transit_Effect_Flip *flip;
1341
1342    flip = ELM_NEW(Elm_Transit_Effect_Flip);
1343    if (!flip) return NULL;
1344
1345    flip->cw = cw;
1346    flip->axis = axis;
1347
1348    return flip;
1349 }
1350
1351 /**
1352  * Add the Flip Effect to Elm_Transit.
1353  *
1354  * @note This API is one of the facades. It creates flip effect context 
1355  * and add it's required APIs to elm_transit_effect_add. 
1356  * @note This effect is applied to each pair of objects in the order they are listed
1357  * in the transit list of objects. The first object in the pair will be the
1358  * "front" object and the second will be the "back" object.
1359  * @note If you change the set of objects in the transit with  elm_transit_object_add()
1360  * or elm_transit_object_remove(), the set of objects affected by this effect
1361  * will be changed too.
1362  * 
1363  * @see elm_transit_effect_add()
1364  *
1365  * @param transit Transit object.
1366  * @param axis Flipping Axis(X or Y).
1367  * @param cw Flipping Direction. EINA_TRUE is clock-wise.
1368  * @return Flip effect context data.
1369  *
1370  * @ingroup Transit
1371  * @warning Is higher recommended just create a transit with this effect when
1372  * the window that the objects of the transit belongs has already been created.
1373  * This is because this effect needs the geometry information about the objects,
1374  * and if the window was not created yet, it can get a wrong information.
1375  * @warning Is not recommended remove or add an object after the transit begins
1376  * to run, because the order of the objects will be affected.
1377  */
1378 EAPI void *
1379 elm_transit_effect_flip_add(Elm_Transit *transit, Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1380 {
1381    ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1382    void *effect_context = _transit_effect_flip_context_new(axis, cw);
1383    
1384    if (!effect_context) return NULL;
1385    elm_transit_effect_add(transit, 
1386                           _transit_effect_flip_op, effect_context,
1387                           _transit_effect_flip_context_free);
1388    return effect_context;
1389 }
1390
1391 ///////////////////////////////////////////////////////////////////////////////
1392 //ResizableFlip FX
1393 ///////////////////////////////////////////////////////////////////////////////
1394 typedef struct _Elm_Transit_Effect_Resizable_Flip Elm_Transit_Effect_ResizableFlip;
1395 typedef struct _Elm_Transit_Effect_Resizable_Flip_Node Elm_Transit_Effect_ResizableFlip_Node;
1396
1397 struct _Elm_Transit_Effect_Resizable_Flip_Node
1398 {
1399    Evas_Object *front;
1400    Evas_Object *back;
1401    struct _vector2d {
1402       float x, y;
1403    } from_pos, from_size, to_pos, to_size;
1404 };
1405
1406 struct _Elm_Transit_Effect_Resizable_Flip
1407 {
1408    Eina_List *nodes;
1409    Eina_Bool cw : 1;
1410    Elm_Transit_Effect_Flip_Axis axis;
1411 };
1412
1413 static void
1414 _resizable_flip_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1415 {
1416    Elm_Transit_Effect_ResizableFlip *resizable_flip = data;
1417    Eina_List *elist;
1418    Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1419
1420    EINA_LIST_FOREACH(resizable_flip->nodes, elist, resizable_flip_node)
1421      {
1422         if (resizable_flip_node->front == obj)
1423           evas_object_event_callback_del(resizable_flip_node->back,
1424                              EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1425         else if (resizable_flip_node->back == obj)
1426           evas_object_event_callback_del(resizable_flip_node->front,
1427                              EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1428         else continue;
1429
1430         resizable_flip->nodes = eina_list_remove_list(resizable_flip->nodes,
1431                                                       elist);
1432         free(resizable_flip_node);
1433         break;
1434      }
1435 }
1436
1437 static Eina_List *
1438 _resizable_flip_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_ResizableFlip *resizable_flip)
1439 {
1440    Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1441    Eina_List *data_list = NULL;
1442    Evas_Coord front_x, front_y, front_w, front_h;
1443    Evas_Coord back_x, back_y, back_w, back_h;
1444    int i, count;
1445
1446    count = eina_list_count(transit->objs);
1447    for (i = 0; i < (count - 1); i += 2)
1448      {
1449         resizable_flip_node = ELM_NEW(Elm_Transit_Effect_ResizableFlip_Node);
1450         if (!resizable_flip_node)
1451           {
1452              eina_list_free(data_list);
1453              return NULL;
1454           }
1455         
1456         resizable_flip_node->front = eina_list_nth(transit->objs, i);
1457         resizable_flip_node->back = eina_list_nth(transit->objs, i+1);
1458         
1459         evas_object_geometry_get(resizable_flip_node->front,
1460                                  &front_x, &front_y, &front_w, &front_h);
1461         evas_object_geometry_get(resizable_flip_node->back,
1462                                  &back_x, &back_y, &back_w, &back_h);
1463         
1464         resizable_flip_node->from_pos.x = front_x;
1465         resizable_flip_node->from_pos.y = front_y;
1466         resizable_flip_node->to_pos.x = back_x - front_x;
1467         resizable_flip_node->to_pos.y = back_y - front_y;
1468         
1469         resizable_flip_node->from_size.x = front_w;
1470         resizable_flip_node->from_size.y = front_h;
1471         resizable_flip_node->to_size.x = back_w - front_w;
1472         resizable_flip_node->to_size.y = back_h - front_h;
1473         
1474         data_list = eina_list_append(data_list, resizable_flip_node);
1475         
1476         evas_object_event_callback_add(resizable_flip_node->back,
1477                                        EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb, resizable_flip);
1478         evas_object_event_callback_add(resizable_flip_node->front,
1479                                        EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb, resizable_flip);
1480      }
1481    
1482    return data_list;
1483 }
1484
1485 static void
1486 _set_image_uv_by_axis_y(Evas_Map *map, Elm_Transit_Effect_ResizableFlip_Node *flip, float degree)
1487 {
1488    if ((degree >= 90) || (degree <= -90))
1489      {
1490         evas_map_point_image_uv_set(map, 0,
1491                                     (flip->from_size.x * 2) + flip->to_size.x,
1492                                     0);
1493         evas_map_point_image_uv_set(map, 1, 0, 0);
1494         evas_map_point_image_uv_set(map, 2, 0,
1495                                     (flip->from_size.y * 2) + flip->to_size.y);
1496         evas_map_point_image_uv_set(map, 3,
1497                                     (flip->from_size.x * 2) + flip->to_size.x,
1498                                     (flip->from_size.y * 2) + flip->to_size.y);
1499      }
1500    else
1501      {
1502         evas_map_point_image_uv_set(map, 0, 0, 0);
1503         evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
1504         evas_map_point_image_uv_set(map, 2, flip->from_size.x,
1505                                     flip->from_size.y);
1506         evas_map_point_image_uv_set(map, 3, 0, flip->from_size.y);
1507      }
1508 }
1509
1510 static void
1511 _set_image_uv_by_axis_x(Evas_Map *map, Elm_Transit_Effect_ResizableFlip_Node *flip, float degree)
1512 {
1513    if ((degree >= 90) || (degree <= -90))
1514      {
1515         evas_map_point_image_uv_set(map, 0, 0,
1516                                     (flip->from_size.y * 2) + flip->to_size.y);
1517         evas_map_point_image_uv_set(map, 1,
1518                                     (flip->from_size.x * 2) + flip->to_size.x,
1519                                     (flip->from_size.y * 2) + flip->to_size.y);
1520         evas_map_point_image_uv_set(map, 2,
1521                                     (flip->from_size.x * 2) + flip->to_size.x,
1522                                     0);
1523         evas_map_point_image_uv_set(map, 3, 0, 0);
1524      }
1525    else
1526      {
1527         evas_map_point_image_uv_set(map, 0, 0, 0);
1528         evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
1529         evas_map_point_image_uv_set(map, 2, flip->from_size.x,
1530                                     flip->from_size.y);
1531         evas_map_point_image_uv_set(map, 3, 0, flip->from_size.y);
1532      }
1533 }
1534
1535 void
1536 _transit_effect_resizable_flip_context_free(void *data, Elm_Transit *transit __UNUSED__)
1537 {
1538    EINA_SAFETY_ON_NULL_RETURN(data);
1539
1540    Elm_Transit_Effect_ResizableFlip *resizable_flip = data;
1541    Eina_List *elist, *elist_next;
1542    Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1543
1544    EINA_LIST_FOREACH_SAFE(resizable_flip->nodes,
1545                           elist, elist_next, resizable_flip_node)
1546      {
1547         evas_object_map_enable_set(resizable_flip_node->front, EINA_FALSE);
1548         evas_object_map_enable_set(resizable_flip_node->back, EINA_FALSE);
1549
1550         resizable_flip->nodes = eina_list_remove_list(resizable_flip->nodes,
1551                                                       elist);
1552
1553         evas_object_event_callback_del(resizable_flip_node->back,
1554                              EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1555         evas_object_event_callback_del(resizable_flip_node->front,
1556                              EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1557         free(resizable_flip_node);
1558      }
1559    free(resizable_flip);
1560 }
1561
1562 void
1563 _transit_effect_resizable_flip_op(void *data, Elm_Transit *transit __UNUSED__, double progress)
1564 {
1565    EINA_SAFETY_ON_NULL_RETURN(data);
1566    Evas_Map *map;
1567    Evas_Object *obj;
1568    float x, y, w, h;
1569    float degree;
1570    Evas_Coord half_w, half_h;
1571    Elm_Transit_Effect_ResizableFlip *resizable_flip = data;
1572    Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1573    Eina_List *elist;
1574
1575    map = evas_map_new(4);
1576    if (!map) return;
1577
1578    if (resizable_flip->cw) degree = (float)(progress * 180);
1579    else degree = (float)(progress * -180);
1580    
1581    if (!resizable_flip->nodes)
1582       resizable_flip->nodes = _resizable_flip_nodes_build(transit,
1583                                                           resizable_flip);
1584    
1585    EINA_LIST_FOREACH(resizable_flip->nodes, elist, resizable_flip_node)
1586      {
1587         if ((degree < 90) && (degree > -90))
1588           {
1589              obj = resizable_flip_node->front;
1590              if (resizable_flip_node->front != resizable_flip_node->back)
1591                {
1592                   evas_object_hide(resizable_flip_node->back);
1593                   evas_object_show(resizable_flip_node->front);
1594                }
1595           }
1596         else
1597           {
1598              obj = resizable_flip_node->back;
1599              if (resizable_flip_node->front != resizable_flip_node->back)
1600                {
1601                   evas_object_hide(resizable_flip_node->front);
1602                   evas_object_show(resizable_flip_node->back);
1603                }
1604           }
1605         
1606         evas_map_smooth_set(map, EINA_TRUE);
1607         
1608         x = resizable_flip_node->from_pos.x +
1609            (resizable_flip_node->to_pos.x * progress);
1610         y = resizable_flip_node->from_pos.y +
1611            (resizable_flip_node->to_pos.y * progress);
1612         w = resizable_flip_node->from_size.x +
1613            (resizable_flip_node->to_size.x * progress);
1614         h = resizable_flip_node->from_size.y +
1615            (resizable_flip_node->to_size.y * progress);
1616         evas_map_point_coord_set(map, 0, x, y, 0);
1617         evas_map_point_coord_set(map, 1, x + w, y, 0);
1618         evas_map_point_coord_set(map, 2, x + w, y + h, 0);
1619         evas_map_point_coord_set(map, 3, x, y + h, 0);
1620         
1621         half_w = (Evas_Coord)(w / 2);
1622         half_h = (Evas_Coord)(h / 2);
1623         
1624         if (resizable_flip->axis == ELM_TRANSIT_EFFECT_FLIP_AXIS_Y)
1625           {
1626              _set_image_uv_by_axis_y(map, resizable_flip_node, degree);
1627              evas_map_util_3d_rotate(map, 0, degree,
1628                                      0, x + half_w, y + half_h, 0);
1629           }
1630         else
1631           {
1632              _set_image_uv_by_axis_x(map, resizable_flip_node, degree);
1633              evas_map_util_3d_rotate(map, degree, 0,
1634                                      0, x + half_w, y + half_h, 0);
1635           }
1636         
1637         evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, FOCAL);
1638         evas_object_map_enable_set(resizable_flip_node->front, EINA_TRUE);
1639         evas_object_map_enable_set(resizable_flip_node->back, EINA_TRUE);
1640         evas_object_map_set(obj, map);
1641      }
1642    evas_map_free(map);
1643 }
1644
1645 static void *
1646 _transit_effect_resizable_flip_context_new(Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1647 {
1648    Elm_Transit_Effect_ResizableFlip *resizable_flip;
1649    
1650    resizable_flip = ELM_NEW(Elm_Transit_Effect_ResizableFlip);
1651    if (!resizable_flip) return NULL;
1652
1653    resizable_flip->cw = cw;
1654    resizable_flip->axis = axis;
1655
1656    return resizable_flip;
1657 }
1658
1659 /**
1660  * Add the Resizable Flip Effect to Elm_Transit.
1661  *
1662  * @note This API is one of the facades. It creates resizable flip effect context 
1663  * and add it's required APIs to elm_transit_effect_add. 
1664  * @note This effect is applied to each pair of objects in the order they are listed
1665  * in the transit list of objects. The first object in the pair will be the
1666  * "front" object and the second will be the "back" object.
1667  * @note When this function is called, it gets the current objects in
1668  * the transit, that is, elm_transit_object_remove() and elm_transit_object_add()
1669  * will not cause any changes in the set of objects that this effect is being
1670  * applied.
1671  * 
1672  * @see elm_transit_effect_add()
1673  *
1674  * @param transit Transit object.
1675  * @param axis Flipping Axis(X or Y).
1676  * @param cw Flipping Direction. EINA_TRUE is clock-wise.
1677  * @return Resizable flip effect context data.
1678  *
1679  * @ingroup Transit
1680  * @warning Is higher recommended just create a transit with this effect when
1681  * the window that the objects of the transit belongs has already been created.
1682  * This is because this effect needs the geometry information about the objects,
1683  * and if the window was not created yet, it can get a wrong information.
1684  * @warning Is not recommended remove or add an object after the transit begins
1685  * to run, because the order of the objects will be affected.
1686  */
1687 EAPI void *
1688 elm_transit_effect_resizable_flip_add(Elm_Transit *transit, Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1689 {
1690    ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1691    void *effect_context = _transit_effect_resizable_flip_context_new(axis, cw);
1692    
1693    if (!effect_context) return NULL;
1694    elm_transit_effect_add(transit, 
1695                           _transit_effect_resizable_flip_op, effect_context,
1696                           _transit_effect_resizable_flip_context_free);
1697    return effect_context;
1698 }
1699
1700
1701 ///////////////////////////////////////////////////////////////////////////////
1702 //Wipe FX
1703 ///////////////////////////////////////////////////////////////////////////////
1704 typedef struct _Elm_Transit_Effect_Wipe Elm_Transit_Effect_Wipe;
1705
1706 struct _Elm_Transit_Effect_Wipe
1707 {
1708    Elm_Transit_Effect_Wipe_Type type;
1709    Elm_Transit_Effect_Wipe_Dir dir;
1710 };
1711
1712 static void
1713 _elm_fx_wipe_hide(Evas_Map * map, Elm_Transit_Effect_Wipe_Dir dir, float x, float y, float w, float h, float progress)
1714 {
1715    float w2, h2;
1716
1717    switch (dir)
1718      {
1719       case ELM_TRANSIT_EFFECT_WIPE_DIR_LEFT:
1720          w2 = w - (w * progress);
1721          h2 = (y + h);
1722          evas_map_point_image_uv_set(map, 0, 0, 0);
1723          evas_map_point_image_uv_set(map, 1, w2, 0);
1724          evas_map_point_image_uv_set(map, 2, w2, h);
1725          evas_map_point_image_uv_set(map, 3, 0, h);
1726          evas_map_point_coord_set(map, 0, x, y, 0);
1727          evas_map_point_coord_set(map, 1, x + w2, y, 0);
1728          evas_map_point_coord_set(map, 2, x + w2, h2, 0);
1729          evas_map_point_coord_set(map, 3, x, h2, 0);
1730          break;
1731       case ELM_TRANSIT_EFFECT_WIPE_DIR_RIGHT:
1732          w2 = (w * progress);
1733          h2 = (y + h);
1734          evas_map_point_image_uv_set(map, 0, w2, 0);
1735          evas_map_point_image_uv_set(map, 1, w, 0);
1736          evas_map_point_image_uv_set(map, 2, w, h);
1737          evas_map_point_image_uv_set(map, 3, w2, h);
1738          evas_map_point_coord_set(map, 0, x + w2, y, 0);
1739          evas_map_point_coord_set(map, 1, x + w, y, 0);
1740          evas_map_point_coord_set(map, 2, x + w, h2, 0);
1741          evas_map_point_coord_set(map, 3, x + w2, h2, 0);
1742          break;
1743       case ELM_TRANSIT_EFFECT_WIPE_DIR_UP:
1744          w2 = (x + w);
1745          h2 = h - (h * progress);
1746          evas_map_point_image_uv_set(map, 0, 0, 0);
1747          evas_map_point_image_uv_set(map, 1, w, 0);
1748          evas_map_point_image_uv_set(map, 2, w, h2);
1749          evas_map_point_image_uv_set(map, 3, 0, h2);
1750          evas_map_point_coord_set(map, 0, x, y, 0);
1751          evas_map_point_coord_set(map, 1, w2, y, 0);
1752          evas_map_point_coord_set(map, 2, w2, y+h2, 0);
1753          evas_map_point_coord_set(map, 3, x, y+h2, 0);
1754          break;
1755       case ELM_TRANSIT_EFFECT_WIPE_DIR_DOWN:
1756          w2 = (x + w);
1757          h2 = (h * progress);
1758          evas_map_point_image_uv_set(map, 0, 0, h2);
1759          evas_map_point_image_uv_set(map, 1, w, h2);
1760          evas_map_point_image_uv_set(map, 2, w, h);
1761          evas_map_point_image_uv_set(map, 3, 0, h);
1762          evas_map_point_coord_set(map, 0, x, y + h2, 0);
1763          evas_map_point_coord_set(map, 1, w2, y + h2, 0);
1764          evas_map_point_coord_set(map, 2, w2, y + h, 0);
1765          evas_map_point_coord_set(map, 3, x, y + h, 0);
1766          break;
1767       default:
1768          break;
1769      }
1770    evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, FOCAL);
1771 }
1772
1773 static void
1774 _elm_fx_wipe_show(Evas_Map *map, Elm_Transit_Effect_Wipe_Dir dir, float x, float y, float w, float h, float progress)
1775 {
1776    float w2, h2;
1777
1778    switch (dir)
1779      {
1780       case ELM_TRANSIT_EFFECT_WIPE_DIR_LEFT:
1781          w2 = (w - (w * progress));
1782          h2 = (y + h);
1783          evas_map_point_image_uv_set(map, 0, w2, 0);
1784          evas_map_point_image_uv_set(map, 1, w, 0);
1785          evas_map_point_image_uv_set(map, 2, w, h);
1786          evas_map_point_image_uv_set(map, 3, w2, h);
1787          evas_map_point_coord_set(map, 0, x + w2, y, 0);
1788          evas_map_point_coord_set(map, 1, w, y, 0);
1789          evas_map_point_coord_set(map, 2, w, h2, 0);
1790          evas_map_point_coord_set(map, 3, x + w2, h2, 0);
1791          break;
1792       case ELM_TRANSIT_EFFECT_WIPE_DIR_RIGHT:
1793          w2 = (w * progress);
1794          h2 = (y + h);
1795          evas_map_point_image_uv_set(map, 0, 0, 0);
1796          evas_map_point_image_uv_set(map, 1, w2, 0);
1797          evas_map_point_image_uv_set(map, 2, w2, h);
1798          evas_map_point_image_uv_set(map, 3, 0, h);
1799          evas_map_point_coord_set(map, 0, x, y, 0);
1800          evas_map_point_coord_set(map, 1, x + w2, y, 0);
1801          evas_map_point_coord_set(map, 2, x + w2, h2, 0);
1802          evas_map_point_coord_set(map, 3, x, h2, 0);
1803          break;
1804       case ELM_TRANSIT_EFFECT_WIPE_DIR_UP:
1805          w2 = (x + w);
1806          h2 = (h - (h * progress));
1807          evas_map_point_image_uv_set(map, 0, 0, h2);
1808          evas_map_point_image_uv_set(map, 1, w, h2);
1809          evas_map_point_image_uv_set(map, 2, w, h);
1810          evas_map_point_image_uv_set(map, 3, 0, h);
1811          evas_map_point_coord_set(map, 0, x, y + h2, 0);
1812          evas_map_point_coord_set(map, 1, w2, y + h2, 0);
1813          evas_map_point_coord_set(map, 2, w2, y + h, 0);
1814          evas_map_point_coord_set(map, 3, x, y + h, 0);
1815          break;
1816       case ELM_TRANSIT_EFFECT_WIPE_DIR_DOWN:
1817          w2 = (x + w);
1818          h2 = (h * progress);
1819          evas_map_point_image_uv_set(map, 0, 0, 0);
1820          evas_map_point_image_uv_set(map, 1, w, 0);
1821          evas_map_point_image_uv_set(map, 2, w, h2);
1822          evas_map_point_image_uv_set(map, 3, 0, h2);
1823          evas_map_point_coord_set(map, 0, x, y, 0);
1824          evas_map_point_coord_set(map, 1, w2, y, 0);
1825          evas_map_point_coord_set(map, 2, w2, y + h2, 0);
1826          evas_map_point_coord_set(map, 3, x, y + h2, 0);
1827          break;
1828       default:
1829          break;
1830      }
1831    evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, FOCAL);
1832 }
1833
1834 static void
1835 _transit_effect_wipe_context_free(void *data, Elm_Transit *transit)
1836 {
1837    EINA_SAFETY_ON_NULL_RETURN(data);
1838    EINA_SAFETY_ON_NULL_RETURN(transit);
1839    Eina_List *elist;
1840    Evas_Object *obj;
1841    Elm_Transit_Effect_Wipe *wipe = data;
1842    Eina_Bool reverse = elm_transit_auto_reverse_get(transit);
1843
1844    EINA_LIST_FOREACH(transit->objs, elist, obj)
1845      {
1846         if ((wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_SHOW && !reverse)
1847             || (wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_HIDE && reverse))
1848            evas_object_show(obj);
1849         else evas_object_hide(obj);
1850         evas_object_map_enable_set(obj, EINA_FALSE);
1851      }
1852
1853    free(wipe);
1854 }
1855
1856 static void
1857 _transit_effect_wipe_op(void *data, Elm_Transit *transit, double progress)
1858 {
1859    EINA_SAFETY_ON_NULL_RETURN(data);
1860    EINA_SAFETY_ON_NULL_RETURN(transit);
1861    Elm_Transit_Effect_Wipe *wipe = data;
1862    Evas_Map *map;
1863    Evas_Coord _x, _y, _w, _h;
1864    Eina_List *elist;
1865    Evas_Object *obj;
1866
1867    map = evas_map_new(4);
1868    if (!map) return;
1869    
1870    evas_map_smooth_set(map, EINA_TRUE);
1871    
1872    EINA_LIST_FOREACH(transit->objs, elist, obj)
1873      {
1874         evas_object_geometry_get(obj, &_x, &_y, &_w, &_h);
1875         
1876         if (wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_SHOW)
1877            _elm_fx_wipe_show(map, wipe->dir, _x, _y, _w, _h, (float)progress);
1878         else
1879            _elm_fx_wipe_hide(map, wipe->dir, _x, _y, _w, _h, (float)progress);
1880         
1881         evas_object_map_enable_set(obj, EINA_TRUE);
1882         evas_object_map_set(obj, map);
1883      }
1884    evas_map_free(map);
1885 }
1886
1887 static void *
1888 _transit_effect_wipe_context_new(Elm_Transit_Effect_Wipe_Type type, Elm_Transit_Effect_Wipe_Dir dir)
1889 {
1890    Elm_Transit_Effect_Wipe *wipe;
1891    
1892    wipe = ELM_NEW(Elm_Transit_Effect_Wipe);
1893    if (!wipe) return NULL;
1894
1895    wipe->type = type;
1896    wipe->dir = dir;
1897
1898    return wipe;
1899 }
1900
1901 /**
1902  * Add the Wipe Effect to Elm_Transit.
1903  *
1904  * @note This API is one of the facades. It creates wipe effect context 
1905  * and add it's required APIs to elm_transit_effect_add. 
1906  * @note This effect will be applied to the objects that are in the transit,
1907  * If you change the set of objects in the transit with  elm_transit_object_add()
1908  * or elm_transit_object_remove(), the set of objects affected by this effect
1909  * will be changed too.
1910  * 
1911  * @see elm_transit_effect_add()
1912  *
1913  * @param transit Transit object.
1914  * @param type Wipe type. Hide or show.
1915  * @param dir Wipe Direction.
1916  * @return Wipe effect context data.
1917  *
1918  * @ingroup Transit
1919  * @warning Is higher recommended just create a transit with this effect when
1920  * the window that the objects of the transit belongs has already been created.
1921  * This is because this effect needs the geometry information about the objects,
1922  * and if the window was not created yet, it can get a wrong information.
1923  * @warning Is not recommended remove or add an object after the transit begins
1924  * to run, because the order of the objects will be affected.
1925  */
1926 EAPI void *
1927 elm_transit_effect_wipe_add(Elm_Transit *transit, Elm_Transit_Effect_Wipe_Type type, Elm_Transit_Effect_Wipe_Dir dir)
1928 {
1929    ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1930    void *effect_context = _transit_effect_wipe_context_new(type, dir);
1931    
1932    if (!effect_context) return NULL;
1933    elm_transit_effect_add(transit, 
1934                           _transit_effect_wipe_op, effect_context,
1935                           _transit_effect_wipe_context_free);
1936    return effect_context;
1937 }
1938
1939
1940 ///////////////////////////////////////////////////////////////////////////////
1941 //Color FX
1942 ///////////////////////////////////////////////////////////////////////////////
1943 typedef struct _Elm_Transit_Effect_Color Elm_Transit_Effect_Color;
1944
1945 struct _Elm_Transit_Effect_Color
1946 {
1947    struct _unsigned_color {
1948       unsigned int r, g, b, a;
1949    } from;
1950    struct _signed_color {
1951       int r, g, b, a;
1952    } to;
1953 };
1954
1955 static void
1956 _transit_effect_color_context_free(void *data, Elm_Transit *transit __UNUSED__)
1957 {
1958    free(data);
1959 }
1960
1961 static void
1962 _transit_effect_color_op(void *data, Elm_Transit *transit, double progress)
1963 {
1964    EINA_SAFETY_ON_NULL_RETURN(data);
1965    EINA_SAFETY_ON_NULL_RETURN(transit);
1966    Elm_Transit_Effect_Color *color = data;
1967    Evas_Object *obj;
1968    Eina_List *elist;
1969    unsigned int r, g, b, a;
1970    
1971    r = (color->from.r + (int)((float)color->to.r * progress));
1972    g = (color->from.g + (int)((float)color->to.g * progress));
1973    b = (color->from.b + (int)((float)color->to.b * progress));
1974    a = (color->from.a + (int)((float)color->to.a * progress));
1975    
1976    EINA_LIST_FOREACH(transit->objs, elist, obj)
1977       evas_object_color_set(obj, r, g, b, a);
1978 }
1979
1980 static void *
1981 _transit_effect_color_context_new(unsigned int from_r, unsigned int from_g, unsigned int from_b, unsigned int from_a, unsigned int to_r, unsigned int to_g, unsigned int to_b, unsigned int to_a)
1982 {
1983    Elm_Transit_Effect_Color *color;
1984    
1985    color = ELM_NEW(Elm_Transit_Effect_Color);
1986    if (!color) return NULL;
1987    
1988    color->from.r = from_r;
1989    color->from.g = from_g;
1990    color->from.b = from_b;
1991    color->from.a = from_a;
1992    color->to.r = to_r - from_r;
1993    color->to.g = to_g - from_g;
1994    color->to.b = to_b - from_b;
1995    color->to.a = to_a - from_a;
1996    
1997    return color;
1998 }
1999
2000 /**
2001  * Add the Color Effect to Elm_Transit.
2002  *
2003  * @note This API is one of the facades. It creates color effect context 
2004  * and add it's required APIs to elm_transit_effect_add. 
2005  * @note This effect will be applied to the objects that are in the transit,
2006  * If you change the set of objects in the transit with  elm_transit_object_add()
2007  * or elm_transit_object_remove(), the set of objects affected by this effect
2008  * will be changed too.
2009  * 
2010  * @see elm_transit_effect_add()
2011  *
2012  * @param transit        Transit object.
2013  * @param  from_r        RGB R when effect begins.
2014  * @param  from_g        RGB G when effect begins.
2015  * @param  from_b        RGB B when effect begins.
2016  * @param  from_a        RGB A when effect begins.
2017  * @param  to_r          RGB R when effect ends.
2018  * @param  to_g          RGB G when effect ends.
2019  * @param  to_b          RGB B when effect ends.
2020  * @param  to_a          RGB A when effect ends.
2021  * @return               Color effect context data.
2022  *
2023  * @ingroup Transit
2024  */
2025 EAPI void *
2026 elm_transit_effect_color_add(Elm_Transit *transit, unsigned int from_r, unsigned int from_g, unsigned int from_b, unsigned int from_a, unsigned int to_r, unsigned int to_g, unsigned int to_b, unsigned int to_a)
2027 {
2028    ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2029    void *effect_context = _transit_effect_color_context_new(from_r, from_g, from_b, from_a, to_r, to_g, to_b, to_a);
2030    
2031    if (!effect_context) return NULL;
2032    elm_transit_effect_add(transit, 
2033                           _transit_effect_color_op, effect_context,
2034                           _transit_effect_color_context_free);
2035    return effect_context;
2036 }
2037
2038 ///////////////////////////////////////////////////////////////////////////////
2039 //Fade FX
2040 ///////////////////////////////////////////////////////////////////////////////
2041 typedef struct _Elm_Transit_Effect_Fade Elm_Transit_Effect_Fade;
2042 typedef struct _Elm_Transit_Effect_Fade_Node Elm_Transit_Effect_Fade_Node;
2043
2044 struct _Elm_Transit_Effect_Fade_Node
2045 {
2046    Evas_Object *before;
2047    Evas_Object *after;
2048    struct _signed_color before_color, after_color;
2049    int before_alpha;
2050    int after_alpha;
2051    Eina_Bool inversed : 1;
2052 };
2053
2054 struct _Elm_Transit_Effect_Fade
2055 {
2056    Eina_List *nodes;
2057 };
2058
2059 static void
2060 _fade_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2061 {
2062    Elm_Transit_Effect_Fade *fade = data;
2063    Eina_List *elist;
2064    Elm_Transit_Effect_Fade_Node *fade_node;
2065
2066    EINA_LIST_FOREACH(fade->nodes, elist, fade_node)
2067      {
2068         if (fade_node->before == obj)
2069            evas_object_event_callback_del(fade_node->after,
2070                                           EVAS_CALLBACK_DEL, _fade_object_del_cb);
2071         else if (fade_node->after == obj)
2072            evas_object_event_callback_del(fade_node->before,
2073                                           EVAS_CALLBACK_DEL, _fade_object_del_cb);
2074         else continue;
2075         
2076         fade->nodes = eina_list_remove_list(fade->nodes, elist);
2077         free(fade_node);
2078         break;
2079      }
2080 }
2081
2082 static Eina_List *
2083 _fade_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Fade *fade_data)
2084 {
2085    Elm_Transit_Effect_Fade_Node *fade;
2086    Eina_List *data_list = NULL;
2087    int i, count;
2088
2089    count = eina_list_count(transit->objs);
2090    for (i = 0; i < (count - 1); i += 2)
2091      {
2092         fade = ELM_NEW(Elm_Transit_Effect_Fade_Node);
2093         if (!fade)
2094           {
2095              eina_list_free(data_list);
2096              return NULL;
2097           }
2098         
2099         fade->before = eina_list_nth(transit->objs, i);
2100         fade->after = eina_list_nth(transit->objs, i+1);
2101         
2102         evas_object_color_get(fade->before,
2103                               &fade->before_color.r, &fade->before_color.g,
2104                               &fade->before_color.b, &fade->before_color.a);
2105         evas_object_color_get(fade->after,
2106                               &fade->after_color.r, &fade->after_color.g,
2107                               &fade->after_color.b, &fade->after_color.a);
2108         
2109         fade->before_alpha = (255 - fade->before_color.a);
2110         fade->after_alpha = (255 - fade->after_color.a);
2111         
2112         data_list = eina_list_append(data_list, fade);
2113         
2114         evas_object_event_callback_add(fade->before,
2115                                        EVAS_CALLBACK_DEL, _fade_object_del_cb, fade_data);
2116         evas_object_event_callback_add(fade->after,
2117                                        EVAS_CALLBACK_DEL, _fade_object_del_cb, fade_data);
2118      }
2119    return data_list;
2120 }
2121
2122 static void
2123 _transit_effect_fade_context_free(void *data, Elm_Transit *transit __UNUSED__)
2124 {
2125    EINA_SAFETY_ON_NULL_RETURN(data);
2126    Elm_Transit_Effect_Fade *fade = data;
2127    Elm_Transit_Effect_Fade_Node *fade_node;
2128    Eina_List *elist, *elist_next;
2129    
2130    EINA_LIST_FOREACH_SAFE(fade->nodes, elist, elist_next, fade_node)
2131      {
2132         evas_object_color_set(fade_node->before, fade_node->before_color.r,
2133                               fade_node->before_color.g,
2134                               fade_node->before_color.b,
2135                               fade_node->before_color.a);
2136         evas_object_color_set(fade_node->after, fade_node->after_color.r,
2137                               fade_node->after_color.g,
2138                               fade_node->after_color.b,
2139                               fade_node->after_color.a);
2140
2141         fade->nodes = eina_list_remove_list(fade->nodes, elist);
2142         evas_object_event_callback_del(fade_node->before,
2143                              EVAS_CALLBACK_DEL, _fade_object_del_cb);
2144         evas_object_event_callback_del(fade_node->after,
2145                              EVAS_CALLBACK_DEL, _fade_object_del_cb);
2146         free(fade_node);
2147      }
2148
2149    free(fade);
2150 }
2151
2152 static void
2153 _transit_effect_fade_op(void *data, Elm_Transit *transit __UNUSED__, double progress)
2154 {
2155    EINA_SAFETY_ON_NULL_RETURN(data);
2156    Elm_Transit_Effect_Fade *fade = data;
2157    Eina_List *elist;
2158    Elm_Transit_Effect_Fade_Node *fade_node;
2159    float _progress;
2160    
2161    if (!fade->nodes)
2162       fade->nodes = _fade_nodes_build(transit, fade);
2163    
2164    EINA_LIST_FOREACH(fade->nodes, elist, fade_node)
2165      {
2166         if (progress < 0.5)
2167           {
2168              if (!fade_node->inversed)
2169                {
2170                   evas_object_hide(fade_node->after);
2171                   evas_object_show(fade_node->before);
2172                   fade_node->inversed = EINA_TRUE;
2173                }
2174              
2175              _progress = (1 - (progress * 2));
2176              
2177              evas_object_color_set(fade_node->before,
2178                                    fade_node->before_color.r * _progress,
2179                                    fade_node->before_color.g * _progress,
2180                                    fade_node->before_color.b * _progress,
2181                                    fade_node->before_color.a +
2182                                    fade_node->before_alpha * (1 - _progress));
2183           }
2184         else
2185           {
2186              if (fade_node->inversed)
2187                {
2188                   evas_object_hide(fade_node->before);
2189                   evas_object_show(fade_node->after);
2190                   fade_node->inversed = EINA_FALSE;
2191                }
2192              
2193              _progress = ((progress - 0.5) * 2);
2194              
2195              evas_object_color_set(fade_node->after,
2196                                    fade_node->after_color.r * _progress,
2197                                    fade_node->after_color.g * _progress,
2198                                    fade_node->after_color.b * _progress,
2199                                    fade_node->after_color.a +
2200                                    fade_node->after_alpha * (1 - _progress));
2201           }
2202      }
2203 }
2204
2205 static void *
2206 _transit_effect_fade_context_new(void)
2207 {
2208    Elm_Transit_Effect_Fade *fade;
2209    fade = ELM_NEW(Elm_Transit_Effect_Fade);
2210    if (!fade) return NULL;
2211    return fade;
2212 }
2213
2214 /**
2215  * Add the Fade Effect to Elm_Transit.
2216  *
2217  * @note This API is one of the facades. It creates fade effect context 
2218  * and add it's required APIs to elm_transit_effect_add. 
2219  * @note This effect is applied to each pair of objects in the order they are listed
2220  * in the transit list of objects. The first object in the pair will be the
2221  * "before" object and the second will be the "after" object.
2222  * @note When this function is called, it gets the current objects in
2223  * the transit, that is, elm_transit_object_remove() and elm_transit_object_add()
2224  * will not cause any changes in the set of objects that this effect is being
2225  * applied.
2226  * 
2227  * @see elm_transit_effect_add()
2228  *
2229  * @param transit Transit object.
2230  * @return Fade effect context data.
2231  * 
2232  * @ingroup Transit
2233  * @warning Is higher recommended just create a transit with this effect when
2234  * the window that the objects of the transit belongs has already been created.
2235  * This is because this effect needs the color information about the objects,
2236  * and if the window was not created yet, it can get a wrong information.
2237  * @warning Is not recommended remove or add an object after the transit begins
2238  * to run, because the order of the objects will be affected.
2239  */
2240 EAPI void *
2241 elm_transit_effect_fade_add(Elm_Transit *transit)
2242 {
2243    ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2244    
2245    void *effect_context = _transit_effect_fade_context_new();
2246    if (!effect_context) return NULL;
2247    elm_transit_effect_add(transit, 
2248                           _transit_effect_fade_op, effect_context,
2249                           _transit_effect_fade_context_free);
2250    return effect_context;
2251 }
2252
2253
2254 ///////////////////////////////////////////////////////////////////////////////
2255 //Blend FX
2256 ///////////////////////////////////////////////////////////////////////////////
2257 typedef struct _Elm_Transit_Effect_Blend Elm_Transit_Effect_Blend;
2258 typedef struct _Elm_Transit_Effect_Blend_Node Elm_Transit_Effect_Blend_Node;
2259
2260 struct _Elm_Transit_Effect_Blend_Node
2261 {
2262    Evas_Object *before;
2263    Evas_Object *after;
2264    struct _signed_color from, to;
2265 };
2266
2267 struct _Elm_Transit_Effect_Blend
2268 {
2269    Eina_List *nodes;
2270 };
2271
2272 static void
2273 _blend_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2274 {
2275    Elm_Transit_Effect_Blend *blend = data;
2276    Eina_List *elist;
2277    Elm_Transit_Effect_Blend_Node *blend_node;
2278    
2279    EINA_LIST_FOREACH(blend->nodes, elist, blend_node)
2280      {
2281         if (blend_node->after == obj)
2282            evas_object_event_callback_del(blend_node->before,
2283                                           EVAS_CALLBACK_DEL, _blend_object_del_cb);
2284         else if (blend_node->before == obj)
2285            evas_object_event_callback_del(blend_node->after,
2286                                           EVAS_CALLBACK_DEL, _blend_object_del_cb);
2287         else continue;
2288         
2289         blend->nodes = eina_list_remove_list(blend->nodes, elist);
2290         free(blend_node);
2291         break;
2292      }
2293 }
2294
2295 static Eina_List *
2296 _blend_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Blend *blend)
2297 {
2298    Elm_Transit_Effect_Blend_Node *blend_node;
2299    Eina_List *data_list = NULL;
2300    int i, count;
2301
2302    count = eina_list_count(transit->objs);
2303    for (i = 0; i < (count - 1); i += 2)
2304      {
2305         blend_node = ELM_NEW(Elm_Transit_Effect_Blend_Node);
2306         if (!blend_node)
2307           {
2308              eina_list_free(data_list);
2309              return NULL;
2310           }
2311         
2312         blend_node->before = eina_list_nth(transit->objs, i);
2313         blend_node->after = eina_list_nth(transit->objs, i + 1);
2314         evas_object_show(blend_node->before);
2315         evas_object_show(blend_node->after);
2316         
2317         evas_object_color_get(blend_node->before, &blend_node->from.r,
2318                               &blend_node->from.g, &blend_node->from.b,
2319                               &blend_node->from.a);
2320         evas_object_color_get(blend_node->after, &blend_node->to.r,
2321                               &blend_node->to.g, &blend_node->to.b,
2322                               &blend_node->to.a);
2323         
2324         data_list = eina_list_append(data_list, blend_node);
2325         
2326         evas_object_event_callback_add(blend_node->before,
2327                                        EVAS_CALLBACK_DEL, _blend_object_del_cb, blend);
2328         evas_object_event_callback_add(blend_node->after,
2329                                        EVAS_CALLBACK_DEL, _blend_object_del_cb, blend);
2330      }
2331    return data_list;
2332 }
2333
2334 void
2335 _transit_effect_blend_context_free(void *data, Elm_Transit *transit __UNUSED__)
2336 {
2337    EINA_SAFETY_ON_NULL_RETURN(data);
2338    Elm_Transit_Effect_Blend *blend = data;
2339    Elm_Transit_Effect_Blend_Node *blend_node;
2340    Eina_List *elist, *elist_next;
2341
2342    EINA_LIST_FOREACH_SAFE(blend->nodes, elist, elist_next, blend_node)
2343      {
2344         evas_object_color_set(blend_node->before,
2345                               blend_node->from.r, blend_node->from.g,
2346                               blend_node->from.b, blend_node->from.a);
2347         evas_object_color_set(blend_node->after, blend_node->to.r,
2348                               blend_node->to.g, blend_node->to.b,
2349                               blend_node->to.a);
2350         
2351         if (elm_transit_auto_reverse_get(transit))
2352            evas_object_hide(blend_node->after);
2353         else
2354            evas_object_hide(blend_node->before);
2355         
2356         blend->nodes = eina_list_remove_list(blend->nodes, elist);
2357         
2358         evas_object_event_callback_del(blend_node->before,
2359                                        EVAS_CALLBACK_DEL, _blend_object_del_cb);
2360         evas_object_event_callback_del(blend_node->after,
2361                                        EVAS_CALLBACK_DEL, _blend_object_del_cb);
2362         free(blend_node);
2363      }
2364    free(data);
2365 }
2366
2367 void
2368 _transit_effect_blend_op(void *data, Elm_Transit *transit, double progress)
2369 {
2370    EINA_SAFETY_ON_NULL_RETURN(data);
2371    EINA_SAFETY_ON_NULL_RETURN(transit);
2372    Elm_Transit_Effect_Blend *blend = data;
2373    Elm_Transit_Effect_Blend_Node *blend_node;
2374    Eina_List *elist;
2375
2376    if (!blend->nodes) blend->nodes = _blend_nodes_build(transit, blend);
2377    
2378    EINA_LIST_FOREACH(blend->nodes, elist, blend_node)
2379      {
2380         evas_object_color_set(blend_node->before,
2381                               (int)(blend_node->from.r * (1 - progress)),
2382                               (int)(blend_node->from.g * (1 - progress)),
2383                               (int)(blend_node->from.b * (1 - progress)),
2384                               (int)(blend_node->from.a * (1 - progress)));
2385         evas_object_color_set(blend_node->after,
2386                               (int)(blend_node->to.r * progress),
2387                               (int)(blend_node->to.g * progress),
2388                               (int)(blend_node->to.b * progress),
2389                               (int)(blend_node->to.a * progress));
2390      }
2391 }
2392
2393 static void *
2394 _transit_effect_blend_context_new(void)
2395 {
2396    Elm_Transit_Effect_Blend *blend;
2397    
2398    blend = ELM_NEW(Elm_Transit_Effect_Blend);
2399    if (!blend) return NULL;
2400    return blend;
2401 }
2402
2403 /**
2404  * Add the Blend Effect to Elm_Transit.
2405  *
2406  * @note This API is one of the facades. It creates blend effect context 
2407  * and add it's required APIs to elm_transit_effect_add. 
2408  * @note This effect is applied to each pair of objects in the order they are listed
2409  * in the transit list of objects. The first object in the pair will be the
2410  * "before" object and the second will be the "after" object.
2411  * @note When this function be called, it gets the current objects in
2412  * the transit, that is, elm_transit_object_remove() and elm_transit_object_add()
2413  * will not cause any changes in the set of objects that this effect is being
2414  * applied.
2415  * 
2416  * @see elm_transit_effect_add()
2417  *
2418  * @param transit Transit object.
2419  * @return Blend effect context data.
2420  * 
2421  * @ingroup Transit
2422  * @warning Is higher recommended just create a transit with this effect when
2423  * the window that the objects of the transit belongs has already been created.
2424  * This is because this effect needs the color information about the objects,
2425  * and if the window was not created yet, it can get a wrong information.
2426  * @warning Is not recommended remove or add an object after the transit begins
2427  * to run, because the order of the objects will be affected.
2428  */
2429 EAPI void *
2430 elm_transit_effect_blend_add(Elm_Transit *transit)
2431 {
2432    ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2433    void *effect_context = _transit_effect_blend_context_new();
2434    
2435    if (!effect_context) return NULL;
2436    elm_transit_effect_add(transit, 
2437                           _transit_effect_blend_op, effect_context,
2438                           _transit_effect_blend_context_free);
2439    return effect_context;
2440 }
2441
2442
2443 ///////////////////////////////////////////////////////////////////////////////
2444 //Rotation FX
2445 ///////////////////////////////////////////////////////////////////////////////
2446 typedef struct _Elm_Transit_Effect_Rotation Elm_Transit_Effect_Rotation;
2447
2448 struct _Elm_Transit_Effect_Rotation
2449 {
2450    float from, to;
2451 };
2452
2453 static void
2454 _transit_effect_rotation_context_free(void *data, Elm_Transit *transit __UNUSED__)
2455 {
2456    free(data);
2457 }
2458
2459 static void
2460 _transit_effect_rotation_op(void *data, Elm_Transit *transit, double progress)
2461 {
2462    EINA_SAFETY_ON_NULL_RETURN(data);
2463    EINA_SAFETY_ON_NULL_RETURN(transit);
2464    Elm_Transit_Effect_Rotation *rotation = data;
2465    Evas_Map *map;
2466    Evas_Coord x, y, w, h;
2467    float degree;
2468    float half_w, half_h;
2469    Eina_List *elist;
2470    Evas_Object *obj;
2471
2472    map = evas_map_new(4);
2473    if (!map) return;
2474
2475    evas_map_smooth_set(map, EINA_TRUE);
2476
2477    EINA_LIST_FOREACH(transit->objs, elist, obj)
2478      {
2479         evas_map_util_points_populate_from_object_full(map, obj, 0);
2480         degree = rotation->from + (float)(progress * rotation->to);
2481
2482         evas_object_geometry_get(obj, &x, &y, &w, &h);
2483
2484         half_w = (float)w * 0.5;
2485         half_h = (float)h * 0.5;
2486
2487         evas_map_util_3d_rotate(map, 0, 0, degree, x + half_w, y + half_h, 0);
2488         evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, FOCAL);
2489         evas_object_map_enable_set(obj, EINA_TRUE);
2490         evas_object_map_set(obj, map);
2491      }
2492    evas_map_free(map);
2493 }
2494
2495 static void *
2496 _transit_effect_rotation_context_new(float from_degree, float to_degree)
2497 {
2498    Elm_Transit_Effect_Rotation *rotation;
2499
2500    rotation = ELM_NEW(Elm_Transit_Effect_Rotation);
2501    if (!rotation) return NULL;
2502
2503    rotation->from = from_degree;
2504    rotation->to = to_degree - from_degree;
2505
2506    return rotation;
2507 }
2508
2509 /**
2510  * Add the Rotation Effect to Elm_Transit.
2511  *
2512  * @note This API is one of the facades. It creates rotation effect context 
2513  * and add it's required APIs to elm_transit_effect_add. 
2514  * @note This effect will be applied to the objects that are in the transit,
2515  * If you change the set of objects in the transit with  elm_transit_object_add()
2516  * or elm_transit_object_remove(), the set of objects affected by this effect
2517  * will be changed too.
2518  * 
2519  * @see elm_transit_effect_add()
2520  *
2521  * @param transit Transit object.
2522  * @param from_degree Degree when effect begins.
2523  * @param to_degree Degree when effect is ends.
2524  * @return Rotation effect context data.
2525  * 
2526  * @ingroup Transit
2527  * @warning Is higher recommended just create a transit with this effect when
2528  * the window that the objects of the transit belongs has already been created.
2529  * This is because this effect needs the geometry information about the objects,
2530  * and if the window was not created yet, it can get a wrong information.
2531  * @warning Is not recommended remove or add an object after the transit begins
2532  * to run, because the order of the objects will be affected.
2533  */
2534 EAPI void *
2535 elm_transit_effect_rotation_add(Elm_Transit *transit, float from_degree, float to_degree)
2536 {
2537    ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2538    void *effect_context = _transit_effect_rotation_context_new(from_degree, to_degree);
2539    
2540    if (!effect_context) return NULL;
2541    elm_transit_effect_add(transit, 
2542                           _transit_effect_rotation_op, effect_context,
2543                           _transit_effect_rotation_context_free);
2544    return effect_context;
2545 }
2546
2547
2548 ///////////////////////////////////////////////////////////////////////////////
2549 // ImageAnimation FX
2550 ///////////////////////////////////////////////////////////////////////////////
2551 typedef struct _Elm_Transit_Effect_Image_Animation Elm_Transit_Effect_Image_Animation;
2552
2553 struct _Elm_Transit_Effect_Image_Animation
2554 {
2555    Eina_List *images;
2556 };
2557
2558 static void
2559 _transit_effect_image_animation_context_free(void *data, Elm_Transit *transit __UNUSED__)
2560 {
2561    EINA_SAFETY_ON_NULL_RETURN(data);
2562    Elm_Transit_Effect_Image_Animation *image_animation = data;
2563    const char *image;
2564    Eina_List *elist, *elist_next;
2565
2566    EINA_LIST_FOREACH_SAFE(image_animation->images, elist, elist_next, image)
2567      {
2568         image_animation->images =
2569            eina_list_remove_list(image_animation->images, elist);
2570         eina_stringshare_del(image);
2571      }
2572
2573    free(data);
2574 }
2575
2576 static void
2577 _transit_effect_image_animation_op(void *data, Elm_Transit *transit, double progress)
2578 {
2579    EINA_SAFETY_ON_NULL_RETURN(data);
2580    EINA_SAFETY_ON_NULL_RETURN(transit);
2581    Eina_List *elist;
2582    Evas_Object *obj;
2583    const char *type;
2584    Elm_Transit_Effect_Image_Animation *image_animation = data;
2585    unsigned int count = 0;
2586    int len;
2587
2588    type = eina_stringshare_add("icon");
2589    len = eina_list_count(image_animation->images);
2590    
2591    if (!len) count = floor(progress * len);
2592    else count = floor(progress * (len - 1));
2593    
2594    EINA_LIST_FOREACH(transit->objs, elist, obj)
2595      {
2596         if (elm_widget_type_check(obj, type))
2597            elm_icon_file_set(obj,
2598                              eina_list_nth(image_animation->images, count), NULL);
2599      }
2600
2601    eina_stringshare_del(type);
2602 }
2603
2604 static void *
2605 _transit_effect_image_animation_context_new(Eina_List *images)
2606 {
2607    Elm_Transit_Effect_Image_Animation *image_animation;
2608    image_animation = ELM_NEW(Elm_Transit_Effect_Image_Animation);
2609
2610    if (!image_animation) return NULL;
2611    image_animation->images = images;
2612    return image_animation;
2613 }
2614
2615 /**
2616  * Add the Rotation Effect to Elm_Transit.
2617  *
2618  * @note This API is one of the facades. It creates image animation effect context 
2619  * and add it's required APIs to elm_transit_effect_add. 
2620  * The @p images parameter is a list images paths. This list and
2621  * its contents will be deleted at the end of the effect by
2622  * elm_transit_effect_image_animation_context_free() function.
2623  * @note This effect will be applied to the objects that are in the transit,
2624  * If you change the set of objects in the transit with  elm_transit_object_add()
2625  * or elm_transit_object_remove(), the set of objects affected by this effect
2626  * will be changed too.
2627  *
2628  * Example:
2629  * @code
2630  * char buf[PATH_MAX];
2631  * Eina_List *images = NULL;
2632  * Elm_Transit *transi = elm_transit_add();
2633  *
2634  * snprintf(buf, sizeof(buf), "%s/images/icon_11.png", PACKAGE_DATA_DIR);
2635  * images = eina_list_append(images, eina_stringshare_add(buf));
2636  *
2637  * snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
2638  * images = eina_list_append(images, eina_stringshare_add(buf));
2639  * elm_transit_effect_image_animation_add(transi, images);
2640  *
2641  * @endcode
2642  * 
2643  * @see elm_transit_effect_add()
2644  *
2645  * @param transit Transit object.
2646  * @param images Eina_List of images file paths. This list and
2647  * its contents will be deleted at the end of the effect by
2648  * elm_transit_effect_image_animation_context_free() function.
2649  * @return Image Animation effect context data.
2650  * 
2651  * @ingroup Transit
2652  */
2653 EAPI void *
2654 elm_transit_effect_image_animation_add(Elm_Transit *transit, Eina_List *images)
2655 {
2656    ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2657    void *effect_context = _transit_effect_image_animation_context_new(images);
2658    
2659    if (!effect_context) return NULL;
2660    elm_transit_effect_add(transit, 
2661                           _transit_effect_image_animation_op, effect_context,
2662                           _transit_effect_image_animation_context_free);
2663    return effect_context;
2664 }