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