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