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