1 #include <Elementary.h>
4 #define ELM_TRANSIT_CHECK_OR_RETURN(transit, ...) \
7 CRITICAL("Elm_Transit " # transit " is NULL!"); \
10 if (!EINA_MAGIC_CHECK(transit, ELM_TRANSIT_MAGIC)) { \
11 EINA_MAGIC_FAIL(transit, ELM_TRANSIT_MAGIC); \
14 if (transit->deleted){ \
15 ERR("Elm_Transit " # transit " has already been deleted!"); \
21 #define _TRANSIT_FOCAL 2000
25 #define ELM_TRANSIT_MAGIC 0xd27f190a
28 Ecore_Animator *animator;
29 Eina_Inlist *effect_list;
31 Elm_Transit *prev_chain_transit;
32 Eina_List *next_chain_transits;
33 Elm_Transit_Tween_Mode tween_mode;
35 Elm_Transit_Effect_End_Cb func;
51 unsigned int effects_pending_del;
53 Eina_Bool auto_reverse : 1;
54 Eina_Bool event_enabled : 1;
55 Eina_Bool deleted : 1;
56 Eina_Bool state_keep : 1;
59 struct _Elm_Transit_Effect_Module
62 Elm_Transit_Effect_Transition_Cb transition_cb;
63 Elm_Transit_Effect_End_Cb end_cb;
64 Elm_Transit_Effect *effect;
65 Eina_Bool deleted : 1;
68 struct _Elm_Transit_Obj_State
70 Evas_Coord x, y, w, h;
73 Eina_Bool map_enabled : 1;
74 Eina_Bool visible : 1;
77 struct _Elm_Transit_Obj_Data
79 struct _Elm_Transit_Obj_State *state;
80 Eina_Bool pass_events : 1;
83 typedef struct _Elm_Transit_Effect_Module Elm_Transit_Effect_Module;
84 typedef struct _Elm_Transit_Obj_Data Elm_Transit_Obj_Data;
85 typedef struct _Elm_Transit_Obj_State Elm_Transit_Obj_State;
87 static void _transit_obj_data_update(Elm_Transit *transit, Evas_Object *obj);
88 static void _transit_obj_data_recover(Elm_Transit *transit, Evas_Object *obj);
89 static void _transit_obj_states_save(Evas_Object *obj, Elm_Transit_Obj_Data *obj_data);
90 static void _transit_obj_remove_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__);
91 static void _transit_obj_damage_area_set(Evas_Object *obj);
92 static void _transit_obj_remove(Elm_Transit *transit, Evas_Object *obj);
93 static void _transit_effect_del(Elm_Transit *transit, Elm_Transit_Effect_Module *effect_module);
94 static void _transit_remove_dead_effects(Elm_Transit *transit);
95 static void _transit_del(Elm_Transit *transit);
96 static void _transit_chain_transits_go(Elm_Transit *transit);
97 static void _transit_animate_op(Elm_Transit *transit, double progress);
98 static Eina_Bool _transit_animate_cb(void *data);
100 static char *_transit_key= "_elm_transit_key";
103 _transit_obj_data_update(Elm_Transit *transit, Evas_Object *obj)
105 Elm_Transit_Obj_Data *obj_data = evas_object_data_get(obj, _transit_key);
108 obj_data = ELM_NEW(Elm_Transit_Obj_Data);
110 obj_data->pass_events = evas_object_pass_events_get(obj);
112 if ((!transit->state_keep) && (obj_data->state))
114 free(obj_data->state);
115 obj_data->state = NULL;
119 _transit_obj_states_save(obj, obj_data);
122 evas_object_data_set(obj, _transit_key, obj_data);
126 _transit_obj_states_save(Evas_Object *obj, Elm_Transit_Obj_Data *obj_data)
128 Elm_Transit_Obj_State *state = obj_data->state;
131 state = calloc(1, sizeof(Elm_Transit_Obj_State));
134 evas_object_geometry_get(obj, &state->x, &state->y, &state->w, &state->h);
135 evas_object_color_get(obj, &state->r, &state->g, &state->b, &state->a);
136 state->visible = evas_object_visible_get(obj);
137 state->map_enabled = evas_object_map_enable_get(obj);
138 if (evas_object_map_get(obj))
139 state->map = evas_map_dup(evas_object_map_get(obj));
140 obj_data->state = state;
144 _remove_obj_from_list(Elm_Transit *transit, Evas_Object *obj)
146 //Remove duplicated objects
147 //TODO: Need to consider about optimizing here
150 if (!eina_list_data_find_list(transit->objs, obj))
152 transit->objs = eina_list_remove(transit->objs, obj);
153 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_DEL,
154 _transit_obj_remove_cb,
160 _transit_obj_remove_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
162 Elm_Transit *transit = data;
163 Elm_Transit_Obj_Data *obj_data = evas_object_data_get(obj, _transit_key);
167 free(obj_data->state);
170 _remove_obj_from_list(transit, obj);
171 if (!transit->objs) elm_transit_del(transit);
175 //Since evas map have a afterimage bug for this time.
176 //This function is added temporary.
178 _transit_obj_damage_area_set(Evas_Object *obj)
181 Evas_Coord_Point coords;
182 Evas_Coord_Point min, max;
185 map = evas_object_map_get(obj);
188 evas_map_point_coord_get(map, 0, &coords.x, &coords.y, NULL);
192 for (i = 1; i < 4; ++i)
194 evas_map_point_coord_get(map, i, &coords.x, &coords.y, NULL);
196 if (coords.x < min.x)
198 else if (coords.x > max.x)
201 if (coords.y < min.y)
203 else if (coords.y > max.y)
207 evas_damage_rectangle_add(evas_object_evas_get(obj),
209 max.x - min.x, max.y - min.y);
213 _transit_obj_data_recover(Elm_Transit *transit, Evas_Object *obj)
215 Elm_Transit_Obj_Data *obj_data;
216 Elm_Transit_Obj_State *state;
218 obj_data = evas_object_data_get(obj, _transit_key);
219 if (!obj_data) return;
220 evas_object_data_del(obj, _transit_key);
221 evas_object_pass_events_set(obj, obj_data->pass_events);
222 state = obj_data->state;
225 //recover the states of the object.
226 if (!transit->state_keep)
228 evas_object_move(obj, state->x, state->y);
229 evas_object_resize(obj, state->w, state->h);
230 evas_object_color_set(obj, state->r, state->g, state->b, state->a);
231 if (state->visible) evas_object_show(obj);
232 else evas_object_hide(obj);
233 if (state->map_enabled)
234 evas_object_map_enable_set(obj, EINA_TRUE);
236 evas_object_map_enable_set(obj, EINA_FALSE);
238 evas_object_map_set(obj, state->map);
241 //Since evas map have a afterimage bug for this time.
242 //This line is added temporary.
243 _transit_obj_damage_area_set(obj);
252 _transit_obj_remove(Elm_Transit *transit, Evas_Object *obj)
254 _remove_obj_from_list(transit, obj);
255 _transit_obj_data_recover(transit, obj);
259 _transit_effect_del(Elm_Transit *transit, Elm_Transit_Effect_Module *effect_module)
261 if (effect_module->end_cb)
262 effect_module->end_cb(effect_module->effect, transit);
267 _transit_remove_dead_effects(Elm_Transit *transit)
269 Elm_Transit_Effect_Module *effect_module;
271 EINA_INLIST_FOREACH(transit->effect_list, effect_module)
273 if (effect_module->deleted)
275 _transit_effect_del(transit, effect_module);
276 transit->effects_pending_del--;
277 if (!transit->effects_pending_del) return;
283 _transit_del(Elm_Transit *transit)
285 Elm_Transit_Effect_Module *effect_module;
286 Elm_Transit *chain_transit;
287 Eina_List *elist, *elist_next;
289 EINA_LIST_FOREACH_SAFE(transit->next_chain_transits, elist, elist_next, chain_transit)
291 if (transit->prev_chain_transit)
292 transit->prev_chain_transit->next_chain_transits = eina_list_remove(transit->prev_chain_transit->next_chain_transits, transit);
293 chain_transit->prev_chain_transit = NULL;
296 eina_list_free(transit->next_chain_transits);
298 if (transit->animator)
299 ecore_animator_del(transit->animator);
301 while (transit->effect_list)
303 effect_module = EINA_INLIST_CONTAINER_GET(transit->effect_list, Elm_Transit_Effect_Module);
304 transit->effect_list = eina_inlist_remove(transit->effect_list, transit->effect_list);
305 _transit_effect_del(transit, effect_module);
308 while (transit->objs)
309 _transit_obj_remove(transit, eina_list_data_get(transit->objs));
311 transit->deleted = EINA_TRUE;
313 if (transit->del_data.func)
314 transit->del_data.func(transit->del_data.arg, transit);
316 EINA_MAGIC_SET(transit, EINA_MAGIC_NONE);
321 _transit_chain_transits_go(Elm_Transit *transit)
323 Eina_List *elist, *elist_next;
324 Elm_Transit *chain_transit;
327 EINA_LIST_FOREACH(transit->objs, elist, obj)
328 _transit_obj_data_recover(transit, obj);
330 EINA_LIST_FOREACH_SAFE(transit->next_chain_transits, elist, elist_next, chain_transit)
331 elm_transit_go(chain_transit);
335 _transit_animate_op(Elm_Transit *transit, double progress)
337 Elm_Transit_Effect_Module *effect_module;
340 EINA_INLIST_FOREACH(transit->effect_list, effect_module)
342 if (transit->deleted) break;
343 if (!effect_module->deleted)
344 effect_module->transition_cb(effect_module->effect, transit, progress);
348 if (transit->walking) return;
350 if (transit->deleted) _transit_del(transit);
351 else if (transit->effects_pending_del) _transit_remove_dead_effects(transit);
355 _transit_animate_cb(void *data)
357 Elm_Transit *transit = data;
358 double elapsed_time, duration;
360 transit->time.current = ecore_loop_time_get();
361 elapsed_time = transit->time.current - transit->time.begin;
362 duration = transit->time.duration + transit->time.delayed;
364 if (elapsed_time > duration)
365 elapsed_time = duration;
367 transit->progress = elapsed_time / duration;
368 switch (transit->tween_mode)
370 case ELM_TRANSIT_TWEEN_MODE_ACCELERATE:
371 transit->progress = 1.0 - sin((ELM_PI / 2.0) + (transit->progress * ELM_PI / 2.0));
373 case ELM_TRANSIT_TWEEN_MODE_DECELERATE:
374 transit->progress = sin(transit->progress * ELM_PI / 2.0);
376 case ELM_TRANSIT_TWEEN_MODE_SINUSOIDAL:
377 transit->progress = (1.0 - cos(transit->progress * ELM_PI)) / 2.0;
384 if (transit->repeat.reverse) transit->progress = 1 - transit->progress;
386 if (transit->time.duration > 0) _transit_animate_op(transit, transit->progress);
388 /* Not end. Keep going. */
389 if (elapsed_time < duration) return ECORE_CALLBACK_RENEW;
391 /* Repeat and reverse and time done! */
392 if ((transit->repeat.count >= 0) &&
393 (transit->repeat.current == transit->repeat.count) &&
394 ((!transit->auto_reverse) || transit->repeat.reverse))
396 /* run chain transit */
397 if (transit->next_chain_transits)
398 _transit_chain_transits_go(transit);
400 elm_transit_del(transit);
401 return ECORE_CALLBACK_CANCEL;
405 if (!transit->auto_reverse || transit->repeat.reverse)
407 transit->repeat.current++;
408 transit->repeat.reverse = EINA_FALSE;
410 else transit->repeat.reverse = EINA_TRUE;
412 transit->time.begin = ecore_loop_time_get();
414 return ECORE_CALLBACK_RENEW;
418 elm_transit_add(void)
420 Elm_Transit *transit = ELM_NEW(Elm_Transit);
421 if (!transit) return NULL;
423 EINA_MAGIC_SET(transit, ELM_TRANSIT_MAGIC);
425 elm_transit_tween_mode_set(transit, ELM_TRANSIT_TWEEN_MODE_LINEAR);
431 elm_transit_del(Elm_Transit *transit)
433 ELM_TRANSIT_CHECK_OR_RETURN(transit);
435 if (transit->walking) transit->deleted = EINA_TRUE;
436 else _transit_del(transit);
440 elm_transit_effect_add(Elm_Transit *transit, Elm_Transit_Effect_Transition_Cb transition_cb, Elm_Transit_Effect *effect, Elm_Transit_Effect_End_Cb end_cb)
442 ELM_TRANSIT_CHECK_OR_RETURN(transit);
443 EINA_SAFETY_ON_NULL_RETURN(transition_cb);
444 Elm_Transit_Effect_Module *effect_module;
446 EINA_INLIST_FOREACH(transit->effect_list, effect_module)
447 if ((effect_module->transition_cb == transition_cb) && (effect_module->effect == effect)) return;
449 effect_module = ELM_NEW(Elm_Transit_Effect_Module);
450 if (!effect_module) return;
452 effect_module->end_cb = end_cb;
453 effect_module->transition_cb = transition_cb;
454 effect_module->effect = effect;
456 transit->effect_list = eina_inlist_append(transit->effect_list, (Eina_Inlist*) effect_module);
460 elm_transit_effect_del(Elm_Transit *transit, Elm_Transit_Effect_Transition_Cb transition_cb, Elm_Transit_Effect *effect)
462 ELM_TRANSIT_CHECK_OR_RETURN(transit);
463 EINA_SAFETY_ON_NULL_RETURN(transition_cb);
464 Elm_Transit_Effect_Module *effect_module;
466 EINA_INLIST_FOREACH(transit->effect_list, effect_module)
468 if ((effect_module->transition_cb == transition_cb) && (effect_module->effect == effect))
470 if (transit->walking)
472 effect_module->deleted = EINA_TRUE;
473 transit->effects_pending_del++;
477 _transit_effect_del(transit, effect_module);
478 if (!transit->effect_list) elm_transit_del(transit);
486 elm_transit_object_add(Elm_Transit *transit, Evas_Object *obj)
488 ELM_TRANSIT_CHECK_OR_RETURN(transit);
489 EINA_SAFETY_ON_NULL_RETURN(obj);
491 if (transit->animator)
493 if (!evas_object_data_get(obj, _transit_key))
495 _transit_obj_data_update(transit, obj);
496 evas_object_pass_events_set(obj, EINA_TRUE);
500 evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
501 _transit_obj_remove_cb,
504 transit->objs = eina_list_append(transit->objs, obj);
508 elm_transit_object_remove(Elm_Transit *transit, Evas_Object *obj)
510 ELM_TRANSIT_CHECK_OR_RETURN(transit);
511 EINA_SAFETY_ON_NULL_RETURN(obj);
513 _transit_obj_remove(transit, obj);
514 if (!transit->objs) elm_transit_del(transit);
517 EAPI const Eina_List *
518 elm_transit_objects_get(const Elm_Transit *transit)
520 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
521 return transit->objs;
525 elm_transit_event_enabled_set(Elm_Transit *transit, Eina_Bool enabled)
527 ELM_TRANSIT_CHECK_OR_RETURN(transit);
532 if (transit->event_enabled == enabled) return;
533 transit->event_enabled = !!enabled;
534 if (!transit->animator) return;
536 EINA_LIST_FOREACH(transit->objs, list, obj)
537 evas_object_pass_events_set(obj, enabled);
541 elm_transit_event_enabled_get(const Elm_Transit *transit)
543 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
544 return transit->event_enabled;
548 elm_transit_del_cb_set(Elm_Transit *transit, void (*cb) (void *data, Elm_Transit *transit), void *data)
550 ELM_TRANSIT_CHECK_OR_RETURN(transit);
551 transit->del_data.func = cb;
552 transit->del_data.arg = data;
556 elm_transit_auto_reverse_set(Elm_Transit *transit, Eina_Bool reverse)
558 ELM_TRANSIT_CHECK_OR_RETURN(transit);
559 transit->auto_reverse = reverse;
563 elm_transit_auto_reverse_get(const Elm_Transit *transit)
565 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
566 return transit->auto_reverse;
570 elm_transit_repeat_times_set(Elm_Transit *transit, int repeat)
572 ELM_TRANSIT_CHECK_OR_RETURN(transit);
573 transit->repeat.count = repeat;
574 transit->repeat.current = 0;
578 elm_transit_repeat_times_get(const Elm_Transit *transit)
580 ELM_TRANSIT_CHECK_OR_RETURN(transit, 0);
581 return transit->repeat.count;
585 elm_transit_tween_mode_set(Elm_Transit *transit, Elm_Transit_Tween_Mode tween_mode)
587 ELM_TRANSIT_CHECK_OR_RETURN(transit);
588 transit->tween_mode = tween_mode;
591 EAPI Elm_Transit_Tween_Mode
592 elm_transit_tween_mode_get(const Elm_Transit *transit)
594 ELM_TRANSIT_CHECK_OR_RETURN(transit, ELM_TRANSIT_TWEEN_MODE_LINEAR);
595 return transit->tween_mode;
599 elm_transit_duration_set(Elm_Transit *transit, double duration)
601 ELM_TRANSIT_CHECK_OR_RETURN(transit);
602 if (transit->animator) return;
603 transit->time.duration = duration;
607 elm_transit_duration_get(const Elm_Transit *transit)
609 ELM_TRANSIT_CHECK_OR_RETURN(transit, 0.0);
610 return transit->time.duration;
614 elm_transit_go(Elm_Transit *transit)
616 ELM_TRANSIT_CHECK_OR_RETURN(transit);
621 if (transit->animator)
622 ecore_animator_del(transit->animator);
624 EINA_LIST_FOREACH(transit->objs, elist, obj)
625 _transit_obj_data_update(transit, obj);
627 if (!transit->event_enabled)
629 EINA_LIST_FOREACH(transit->objs, elist, obj)
630 evas_object_pass_events_set(obj, EINA_TRUE);
633 transit->time.paused = 0;
634 transit->time.delayed = 0;
635 transit->time.begin = ecore_loop_time_get();
636 transit->animator = ecore_animator_add(_transit_animate_cb, transit);
640 elm_transit_paused_set(Elm_Transit *transit, Eina_Bool paused)
642 ELM_TRANSIT_CHECK_OR_RETURN(transit);
644 if (!transit->animator) return;
648 if (transit->time.paused > 0)
650 ecore_animator_freeze(transit->animator);
651 transit->time.paused = ecore_loop_time_get();
655 if (transit->time.paused == 0)
657 ecore_animator_thaw(transit->animator);
658 transit->time.delayed += (ecore_loop_time_get() - transit->time.paused);
659 transit->time.paused = 0;
664 elm_transit_paused_get(const Elm_Transit *transit)
666 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
668 if (transit->time.paused == 0)
675 elm_transit_progress_value_get(const Elm_Transit *transit)
677 ELM_TRANSIT_CHECK_OR_RETURN(transit, 0);
679 return transit->progress;
683 elm_transit_objects_final_state_keep_set(Elm_Transit *transit, Eina_Bool state_keep)
685 ELM_TRANSIT_CHECK_OR_RETURN(transit);
687 if (transit->state_keep == state_keep) return;
688 if (transit->animator) return;
689 transit->state_keep = !!state_keep;
693 elm_transit_objects_final_state_keep_get(const Elm_Transit *transit)
695 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
696 return transit->state_keep;
700 elm_transit_chain_transit_add(Elm_Transit *transit, Elm_Transit *chain_transit)
702 ELM_TRANSIT_CHECK_OR_RETURN(transit);
703 ELM_TRANSIT_CHECK_OR_RETURN(chain_transit);
705 if (transit == chain_transit) return;
706 if (transit == chain_transit->prev_chain_transit) return;
708 if (chain_transit->prev_chain_transit)
709 chain_transit->prev_chain_transit->next_chain_transits = eina_list_remove(chain_transit->prev_chain_transit->next_chain_transits, chain_transit);
711 chain_transit->prev_chain_transit = transit;
712 transit->next_chain_transits = eina_list_append(transit->next_chain_transits, chain_transit);
716 elm_transit_chain_transits_get(const Elm_Transit * transit)
718 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
719 return transit->next_chain_transits;
722 ///////////////////////////////////////////////////////////////////////////////
724 ///////////////////////////////////////////////////////////////////////////////
725 typedef struct _Elm_Transit_Effect_Resizing Elm_Transit_Effect_Resizing;
727 struct _Elm_Transit_Effect_Resizing
735 _transit_effect_resizing_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
737 Elm_Transit_Effect_Resizing *resizing = effect;
742 _transit_effect_resizing_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
744 EINA_SAFETY_ON_NULL_RETURN(effect);
745 EINA_SAFETY_ON_NULL_RETURN(transit);
749 Elm_Transit_Effect_Resizing *resizing = effect;
751 w = resizing->from.w + (resizing->to.w * progress);
752 h = resizing->from.h + (resizing->to.h * progress);
754 EINA_LIST_FOREACH(transit->objs, elist, obj)
755 evas_object_resize(obj, w, h);
758 static Elm_Transit_Effect *
759 _transit_effect_resizing_context_new(Evas_Coord from_w, Evas_Coord from_h, Evas_Coord to_w, Evas_Coord to_h)
761 Elm_Transit_Effect_Resizing *resizing;
763 resizing = ELM_NEW(Elm_Transit_Effect_Resizing);
764 if (!resizing) return NULL;
766 resizing->from.w = from_w;
767 resizing->from.h = from_h;
768 resizing->to.w = to_w - from_w;
769 resizing->to.h = to_h - from_h;
774 EAPI Elm_Transit_Effect *
775 elm_transit_effect_resizing_add(Elm_Transit *transit, Evas_Coord from_w, Evas_Coord from_h, Evas_Coord to_w, Evas_Coord to_h)
777 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
778 Elm_Transit_Effect *effect = _transit_effect_resizing_context_new(from_w, from_h, to_w, to_h);
780 if (!effect) return NULL;
781 elm_transit_effect_add(transit,
782 _transit_effect_resizing_op, effect,
783 _transit_effect_resizing_context_free);
787 ///////////////////////////////////////////////////////////////////////////////
789 ///////////////////////////////////////////////////////////////////////////////
790 typedef struct _Elm_Transit_Effect_Translation Elm_Transit_Effect_Translation;
791 typedef struct _Elm_Transit_Effect_Translation_Node Elm_Transit_Effect_Translation_Node;
793 struct _Elm_Transit_Effect_Translation_Node
799 struct _Elm_Transit_Effect_Translation
801 struct _position_variation {
808 _translation_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
810 Elm_Transit_Effect_Translation *translation = data;
812 Elm_Transit_Effect_Translation_Node *translation_node;
814 EINA_LIST_FOREACH(translation->nodes, elist, translation_node)
816 if (translation_node->obj != obj) continue;
817 translation->nodes = eina_list_remove_list(translation->nodes, elist);
818 free(translation_node);
824 _translation_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Translation *translation)
826 Elm_Transit_Effect_Translation_Node *translation_node;
827 const Eina_List *elist;
829 Eina_List *data_list = NULL;
830 const Eina_List *objs = elm_transit_objects_get(transit);
832 EINA_LIST_FOREACH(objs, elist, obj)
834 translation_node = ELM_NEW(Elm_Transit_Effect_Translation_Node);
835 if (!translation_node)
837 eina_list_free(data_list);
840 translation_node->obj = obj;
841 evas_object_geometry_get(obj, &(translation_node->x),
842 &(translation_node->y), NULL, NULL);
843 data_list = eina_list_append(data_list, translation_node);
844 evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
845 _translation_object_del_cb, translation);
851 _transit_effect_translation_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
853 EINA_SAFETY_ON_NULL_RETURN(effect);
854 Elm_Transit_Effect_Translation *translation = effect;
855 Eina_List *elist, *elist_next;
856 Elm_Transit_Effect_Translation_Node *translation_node;
858 EINA_LIST_FOREACH_SAFE(translation->nodes,
859 elist, elist_next, translation_node)
861 evas_object_event_callback_del(translation_node->obj,
862 EVAS_CALLBACK_DEL, _translation_object_del_cb);
863 translation->nodes = eina_list_remove_list(translation->nodes, elist);
864 free(translation_node);
870 _transit_effect_translation_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress __UNUSED__)
872 EINA_SAFETY_ON_NULL_RETURN(effect);
873 EINA_SAFETY_ON_NULL_RETURN(transit);
875 Elm_Transit_Effect_Translation *translation = effect;
876 Elm_Transit_Effect_Translation_Node *translation_node;
879 if (!translation->nodes)
880 translation->nodes = _translation_nodes_build(transit, translation);
882 EINA_LIST_FOREACH(translation->nodes, elist, translation_node)
884 x = translation_node->x + translation->from.dx
885 + (translation->to.dx * progress);
886 y = translation_node->y + translation->from.dy
887 + (translation->to.dy * progress);
888 evas_object_move(translation_node->obj, x, y);
892 static Elm_Transit_Effect *
893 _transit_effect_translation_context_new(Evas_Coord from_dx, Evas_Coord from_dy, Evas_Coord to_dx, Evas_Coord to_dy)
895 Elm_Transit_Effect_Translation *translation;
897 translation = ELM_NEW(Elm_Transit_Effect_Translation);
898 if (!translation) return NULL;
900 translation->from.dx = from_dx;
901 translation->from.dy = from_dy;
902 translation->to.dx = to_dx - from_dx;
903 translation->to.dy = to_dy - from_dy;
908 EAPI Elm_Transit_Effect *
909 elm_transit_effect_translation_add(Elm_Transit *transit, Evas_Coord from_dx, Evas_Coord from_dy, Evas_Coord to_dx, Evas_Coord to_dy)
911 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
912 Elm_Transit_Effect *effect_context = _transit_effect_translation_context_new(from_dx, from_dy, to_dx, to_dy);
914 if (!effect_context) return NULL;
915 elm_transit_effect_add(transit,
916 _transit_effect_translation_op, effect_context,
917 _transit_effect_translation_context_free);
918 return effect_context;
922 ///////////////////////////////////////////////////////////////////////////////
924 ///////////////////////////////////////////////////////////////////////////////
925 typedef struct _Elm_Transit_Effect_Zoom Elm_Transit_Effect_Zoom;
927 struct _Elm_Transit_Effect_Zoom
933 _transit_effect_zoom_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
935 Elm_Transit_Effect_Zoom *zoom = effect;
940 _transit_effect_zoom_op(Elm_Transit_Effect *effect, Elm_Transit *transit , double progress)
942 EINA_SAFETY_ON_NULL_RETURN(effect);
943 EINA_SAFETY_ON_NULL_RETURN(transit);
946 Elm_Transit_Effect_Zoom *zoom = effect;
948 Evas_Coord x, y, w, h;
950 map = evas_map_new(4);
953 EINA_LIST_FOREACH(transit->objs, elist, obj)
955 evas_object_geometry_get(obj, &x, &y, &w, &h);
956 evas_map_util_points_populate_from_object_full(map, obj, zoom->from +
957 (progress * zoom->to));
958 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, _TRANSIT_FOCAL);
959 evas_object_map_set(obj, map);
960 evas_object_map_enable_set(obj, EINA_TRUE);
965 static Elm_Transit_Effect *
966 _transit_effect_zoom_context_new(float from_rate, float to_rate)
968 Elm_Transit_Effect_Zoom *zoom;
970 zoom = ELM_NEW(Elm_Transit_Effect_Zoom);
971 if (!zoom) return NULL;
973 zoom->from = (_TRANSIT_FOCAL - (from_rate * _TRANSIT_FOCAL)) * (1 / from_rate);
974 zoom->to = ((_TRANSIT_FOCAL - (to_rate * _TRANSIT_FOCAL)) * (1 / to_rate)) - zoom->from;
979 EAPI Elm_Transit_Effect *
980 elm_transit_effect_zoom_add(Elm_Transit *transit, float from_rate, float to_rate)
982 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
983 Elm_Transit_Effect *effect_context = _transit_effect_zoom_context_new(from_rate, to_rate);
985 if (!effect_context) return NULL;
986 elm_transit_effect_add(transit,
987 _transit_effect_zoom_op, effect_context,
988 _transit_effect_zoom_context_free);
989 return effect_context;
993 ///////////////////////////////////////////////////////////////////////////////
995 ///////////////////////////////////////////////////////////////////////////////
996 typedef struct _Elm_Transit_Effect_Flip Elm_Transit_Effect_Flip;
998 struct _Elm_Transit_Effect_Flip
1000 Elm_Transit_Effect_Flip_Axis axis;
1005 _transit_effect_flip_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit)
1007 EINA_SAFETY_ON_NULL_RETURN(effect);
1008 EINA_SAFETY_ON_NULL_RETURN(transit);
1009 Elm_Transit_Effect_Flip *flip = effect;
1010 Evas_Object *front, *back;
1012 int count = eina_list_count(transit->objs);
1014 for (i = 0; i < (count - 1); i += 2)
1016 front = eina_list_nth(transit->objs, i);
1017 back = eina_list_nth(transit->objs, i+1);
1018 evas_object_map_enable_set(front, EINA_FALSE);
1019 evas_object_map_enable_set(back, EINA_FALSE);
1025 _transit_effect_flip_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
1027 EINA_SAFETY_ON_NULL_RETURN(effect);
1028 EINA_SAFETY_ON_NULL_RETURN(transit);
1029 Evas_Object *obj, *front, *back;
1031 Elm_Transit_Effect_Flip *flip = effect;
1034 Evas_Coord x, y, w, h;
1036 map = evas_map_new(4);
1039 if (flip->cw) degree = (float)(progress * 180);
1040 else degree = (float)(progress * -180);
1042 count = eina_list_count(transit->objs);
1044 for (i = 0; i < (count - 1); i += 2)
1046 Evas_Coord half_w, half_h;
1048 front = eina_list_nth(transit->objs, i);
1049 back = eina_list_nth(transit->objs, i+1);
1051 if ((degree < 90) && (degree > -90))
1056 evas_object_hide(back);
1057 evas_object_show(front);
1065 evas_object_hide(front);
1066 evas_object_show(back);
1070 evas_map_util_points_populate_from_object_full(map, obj, 0);
1071 evas_object_geometry_get(obj, &x, &y, &w, &h);
1075 if (flip->axis == ELM_TRANSIT_EFFECT_FLIP_AXIS_Y)
1077 if ((degree >= 90) || (degree <= -90))
1079 evas_map_point_image_uv_set(map, 0, w, 0);
1080 evas_map_point_image_uv_set(map, 1, 0, 0);
1081 evas_map_point_image_uv_set(map, 2, 0, h);
1082 evas_map_point_image_uv_set(map, 3, w, h);
1084 evas_map_util_3d_rotate(map, 0, degree,
1085 0, x + half_w, y + half_h, 0);
1089 if ((degree >= 90) || (degree <= -90))
1091 evas_map_point_image_uv_set(map, 0, 0, h);
1092 evas_map_point_image_uv_set(map, 1, w, h);
1093 evas_map_point_image_uv_set(map, 2, w, 0);
1094 evas_map_point_image_uv_set(map, 3, 0, 0);
1096 evas_map_util_3d_rotate(map, degree,
1097 0, 0, x + half_w, y + half_h, 0);
1099 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, _TRANSIT_FOCAL);
1100 evas_object_map_enable_set(front, EINA_TRUE);
1101 evas_object_map_enable_set(back, EINA_TRUE);
1102 evas_object_map_set(obj, map);
1107 static Elm_Transit_Effect *
1108 _transit_effect_flip_context_new(Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1110 Elm_Transit_Effect_Flip *flip;
1112 flip = ELM_NEW(Elm_Transit_Effect_Flip);
1113 if (!flip) return NULL;
1121 EAPI Elm_Transit_Effect *
1122 elm_transit_effect_flip_add(Elm_Transit *transit, Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1124 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1125 Elm_Transit_Effect *effect_context = _transit_effect_flip_context_new(axis, cw);
1127 if (!effect_context) return NULL;
1128 elm_transit_effect_add(transit,
1129 _transit_effect_flip_op, effect_context,
1130 _transit_effect_flip_context_free);
1131 return effect_context;
1134 ///////////////////////////////////////////////////////////////////////////////
1135 //ResizableFlip Effect
1136 ///////////////////////////////////////////////////////////////////////////////
1137 typedef struct _Elm_Transit_Effect_Resizable_Flip Elm_Transit_Effect_ResizableFlip;
1138 typedef struct _Elm_Transit_Effect_Resizable_Flip_Node Elm_Transit_Effect_ResizableFlip_Node;
1140 struct _Elm_Transit_Effect_Resizable_Flip_Node
1146 } from_pos, from_size, to_pos, to_size;
1149 struct _Elm_Transit_Effect_Resizable_Flip
1153 Elm_Transit_Effect_Flip_Axis axis;
1157 _resizable_flip_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1159 Elm_Transit_Effect_ResizableFlip *resizable_flip = data;
1161 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1163 EINA_LIST_FOREACH(resizable_flip->nodes, elist, resizable_flip_node)
1165 if (resizable_flip_node->front == obj)
1166 evas_object_event_callback_del(resizable_flip_node->back,
1167 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1168 else if (resizable_flip_node->back == obj)
1169 evas_object_event_callback_del(resizable_flip_node->front,
1170 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1173 resizable_flip->nodes = eina_list_remove_list(resizable_flip->nodes,
1175 free(resizable_flip_node);
1181 _resizable_flip_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_ResizableFlip *resizable_flip)
1183 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1184 Eina_List *data_list = NULL;
1185 Evas_Coord front_x, front_y, front_w, front_h;
1186 Evas_Coord back_x, back_y, back_w, back_h;
1189 count = eina_list_count(transit->objs);
1190 for (i = 0; i < (count - 1); i += 2)
1192 resizable_flip_node = ELM_NEW(Elm_Transit_Effect_ResizableFlip_Node);
1193 if (!resizable_flip_node)
1195 eina_list_free(data_list);
1199 resizable_flip_node->front = eina_list_nth(transit->objs, i);
1200 resizable_flip_node->back = eina_list_nth(transit->objs, i+1);
1202 evas_object_geometry_get(resizable_flip_node->front,
1203 &front_x, &front_y, &front_w, &front_h);
1204 evas_object_geometry_get(resizable_flip_node->back,
1205 &back_x, &back_y, &back_w, &back_h);
1207 resizable_flip_node->from_pos.x = front_x;
1208 resizable_flip_node->from_pos.y = front_y;
1209 resizable_flip_node->to_pos.x = back_x - front_x;
1210 resizable_flip_node->to_pos.y = back_y - front_y;
1212 resizable_flip_node->from_size.x = front_w;
1213 resizable_flip_node->from_size.y = front_h;
1214 resizable_flip_node->to_size.x = back_w - front_w;
1215 resizable_flip_node->to_size.y = back_h - front_h;
1217 data_list = eina_list_append(data_list, resizable_flip_node);
1219 evas_object_event_callback_add(resizable_flip_node->back,
1220 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb, resizable_flip);
1221 evas_object_event_callback_add(resizable_flip_node->front,
1222 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb, resizable_flip);
1229 _set_image_uv_by_axis_y(Evas_Map *map, Elm_Transit_Effect_ResizableFlip_Node *flip, float degree)
1231 if ((degree >= 90) || (degree <= -90))
1233 evas_map_point_image_uv_set(map, 0,
1234 (flip->from_size.x * 2) + flip->to_size.x,
1236 evas_map_point_image_uv_set(map, 1, 0, 0);
1237 evas_map_point_image_uv_set(map, 2, 0,
1238 (flip->from_size.y * 2) + flip->to_size.y);
1239 evas_map_point_image_uv_set(map, 3,
1240 (flip->from_size.x * 2) + flip->to_size.x,
1241 (flip->from_size.y * 2) + flip->to_size.y);
1245 evas_map_point_image_uv_set(map, 0, 0, 0);
1246 evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
1247 evas_map_point_image_uv_set(map, 2, flip->from_size.x,
1249 evas_map_point_image_uv_set(map, 3, 0, flip->from_size.y);
1254 _set_image_uv_by_axis_x(Evas_Map *map, Elm_Transit_Effect_ResizableFlip_Node *flip, float degree)
1256 if ((degree >= 90) || (degree <= -90))
1258 evas_map_point_image_uv_set(map, 0, 0,
1259 (flip->from_size.y * 2) + flip->to_size.y);
1260 evas_map_point_image_uv_set(map, 1,
1261 (flip->from_size.x * 2) + flip->to_size.x,
1262 (flip->from_size.y * 2) + flip->to_size.y);
1263 evas_map_point_image_uv_set(map, 2,
1264 (flip->from_size.x * 2) + flip->to_size.x,
1266 evas_map_point_image_uv_set(map, 3, 0, 0);
1270 evas_map_point_image_uv_set(map, 0, 0, 0);
1271 evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
1272 evas_map_point_image_uv_set(map, 2, flip->from_size.x,
1274 evas_map_point_image_uv_set(map, 3, 0, flip->from_size.y);
1279 _transit_effect_resizable_flip_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
1281 EINA_SAFETY_ON_NULL_RETURN(effect);
1283 Elm_Transit_Effect_ResizableFlip *resizable_flip = effect;
1284 Eina_List *elist, *elist_next;
1285 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1287 EINA_LIST_FOREACH_SAFE(resizable_flip->nodes,
1288 elist, elist_next, resizable_flip_node)
1290 evas_object_map_enable_set(resizable_flip_node->front, EINA_FALSE);
1291 evas_object_map_enable_set(resizable_flip_node->back, EINA_FALSE);
1293 resizable_flip->nodes = eina_list_remove_list(resizable_flip->nodes,
1296 evas_object_event_callback_del(resizable_flip_node->back,
1297 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1298 evas_object_event_callback_del(resizable_flip_node->front,
1299 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1300 free(resizable_flip_node);
1302 free(resizable_flip);
1306 _transit_effect_resizable_flip_op(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__, double progress)
1308 EINA_SAFETY_ON_NULL_RETURN(effect);
1313 Evas_Coord half_w, half_h;
1314 Elm_Transit_Effect_ResizableFlip *resizable_flip = effect;
1315 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1318 map = evas_map_new(4);
1321 if (resizable_flip->cw) degree = (float)(progress * 180);
1322 else degree = (float)(progress * -180);
1324 if (!resizable_flip->nodes)
1325 resizable_flip->nodes = _resizable_flip_nodes_build(transit,
1328 EINA_LIST_FOREACH(resizable_flip->nodes, elist, resizable_flip_node)
1330 if ((degree < 90) && (degree > -90))
1332 obj = resizable_flip_node->front;
1333 if (resizable_flip_node->front != resizable_flip_node->back)
1335 evas_object_hide(resizable_flip_node->back);
1336 evas_object_show(resizable_flip_node->front);
1341 obj = resizable_flip_node->back;
1342 if (resizable_flip_node->front != resizable_flip_node->back)
1344 evas_object_hide(resizable_flip_node->front);
1345 evas_object_show(resizable_flip_node->back);
1349 x = resizable_flip_node->from_pos.x +
1350 (resizable_flip_node->to_pos.x * progress);
1351 y = resizable_flip_node->from_pos.y +
1352 (resizable_flip_node->to_pos.y * progress);
1353 w = resizable_flip_node->from_size.x +
1354 (resizable_flip_node->to_size.x * progress);
1355 h = resizable_flip_node->from_size.y +
1356 (resizable_flip_node->to_size.y * progress);
1357 evas_map_point_coord_set(map, 0, x, y, 0);
1358 evas_map_point_coord_set(map, 1, x + w, y, 0);
1359 evas_map_point_coord_set(map, 2, x + w, y + h, 0);
1360 evas_map_point_coord_set(map, 3, x, y + h, 0);
1362 half_w = (Evas_Coord)(w / 2);
1363 half_h = (Evas_Coord)(h / 2);
1365 if (resizable_flip->axis == ELM_TRANSIT_EFFECT_FLIP_AXIS_Y)
1367 _set_image_uv_by_axis_y(map, resizable_flip_node, degree);
1368 evas_map_util_3d_rotate(map, 0, degree,
1369 0, x + half_w, y + half_h, 0);
1373 _set_image_uv_by_axis_x(map, resizable_flip_node, degree);
1374 evas_map_util_3d_rotate(map, degree, 0,
1375 0, x + half_w, y + half_h, 0);
1378 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, _TRANSIT_FOCAL);
1379 evas_object_map_enable_set(resizable_flip_node->front, EINA_TRUE);
1380 evas_object_map_enable_set(resizable_flip_node->back, EINA_TRUE);
1381 evas_object_map_set(obj, map);
1386 static Elm_Transit_Effect *
1387 _transit_effect_resizable_flip_context_new(Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1389 Elm_Transit_Effect_ResizableFlip *resizable_flip;
1391 resizable_flip = ELM_NEW(Elm_Transit_Effect_ResizableFlip);
1392 if (!resizable_flip) return NULL;
1394 resizable_flip->cw = cw;
1395 resizable_flip->axis = axis;
1397 return resizable_flip;
1400 EAPI Elm_Transit_Effect *
1401 elm_transit_effect_resizable_flip_add(Elm_Transit *transit, Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1403 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1404 Elm_Transit_Effect *effect_context = _transit_effect_resizable_flip_context_new(axis, cw);
1406 if (!effect_context) return NULL;
1407 elm_transit_effect_add(transit,
1408 _transit_effect_resizable_flip_op, effect_context,
1409 _transit_effect_resizable_flip_context_free);
1410 return effect_context;
1414 ///////////////////////////////////////////////////////////////////////////////
1416 ///////////////////////////////////////////////////////////////////////////////
1417 typedef struct _Elm_Transit_Effect_Wipe Elm_Transit_Effect_Wipe;
1419 struct _Elm_Transit_Effect_Wipe
1421 Elm_Transit_Effect_Wipe_Type type;
1422 Elm_Transit_Effect_Wipe_Dir dir;
1426 _elm_fx_wipe_hide(Evas_Map * map, Elm_Transit_Effect_Wipe_Dir dir, float x, float y, float w, float h, float progress)
1432 case ELM_TRANSIT_EFFECT_WIPE_DIR_LEFT:
1433 w2 = w - (w * progress);
1435 evas_map_point_image_uv_set(map, 0, 0, 0);
1436 evas_map_point_image_uv_set(map, 1, w2, 0);
1437 evas_map_point_image_uv_set(map, 2, w2, h);
1438 evas_map_point_image_uv_set(map, 3, 0, h);
1439 evas_map_point_coord_set(map, 0, x, y, 0);
1440 evas_map_point_coord_set(map, 1, x + w2, y, 0);
1441 evas_map_point_coord_set(map, 2, x + w2, h2, 0);
1442 evas_map_point_coord_set(map, 3, x, h2, 0);
1444 case ELM_TRANSIT_EFFECT_WIPE_DIR_RIGHT:
1445 w2 = (w * progress);
1447 evas_map_point_image_uv_set(map, 0, w2, 0);
1448 evas_map_point_image_uv_set(map, 1, w, 0);
1449 evas_map_point_image_uv_set(map, 2, w, h);
1450 evas_map_point_image_uv_set(map, 3, w2, h);
1451 evas_map_point_coord_set(map, 0, x + w2, y, 0);
1452 evas_map_point_coord_set(map, 1, x + w, y, 0);
1453 evas_map_point_coord_set(map, 2, x + w, h2, 0);
1454 evas_map_point_coord_set(map, 3, x + w2, h2, 0);
1456 case ELM_TRANSIT_EFFECT_WIPE_DIR_UP:
1458 h2 = h - (h * progress);
1459 evas_map_point_image_uv_set(map, 0, 0, 0);
1460 evas_map_point_image_uv_set(map, 1, w, 0);
1461 evas_map_point_image_uv_set(map, 2, w, h2);
1462 evas_map_point_image_uv_set(map, 3, 0, h2);
1463 evas_map_point_coord_set(map, 0, x, y, 0);
1464 evas_map_point_coord_set(map, 1, w2, y, 0);
1465 evas_map_point_coord_set(map, 2, w2, y+h2, 0);
1466 evas_map_point_coord_set(map, 3, x, y+h2, 0);
1468 case ELM_TRANSIT_EFFECT_WIPE_DIR_DOWN:
1470 h2 = (h * progress);
1471 evas_map_point_image_uv_set(map, 0, 0, h2);
1472 evas_map_point_image_uv_set(map, 1, w, h2);
1473 evas_map_point_image_uv_set(map, 2, w, h);
1474 evas_map_point_image_uv_set(map, 3, 0, h);
1475 evas_map_point_coord_set(map, 0, x, y + h2, 0);
1476 evas_map_point_coord_set(map, 1, w2, y + h2, 0);
1477 evas_map_point_coord_set(map, 2, w2, y + h, 0);
1478 evas_map_point_coord_set(map, 3, x, y + h, 0);
1483 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, _TRANSIT_FOCAL);
1487 _elm_fx_wipe_show(Evas_Map *map, Elm_Transit_Effect_Wipe_Dir dir, float x, float y, float w, float h, float progress)
1493 case ELM_TRANSIT_EFFECT_WIPE_DIR_LEFT:
1494 w2 = (w - (w * progress));
1496 evas_map_point_image_uv_set(map, 0, w2, 0);
1497 evas_map_point_image_uv_set(map, 1, w, 0);
1498 evas_map_point_image_uv_set(map, 2, w, h);
1499 evas_map_point_image_uv_set(map, 3, w2, h);
1500 evas_map_point_coord_set(map, 0, x + w2, y, 0);
1501 evas_map_point_coord_set(map, 1, w, y, 0);
1502 evas_map_point_coord_set(map, 2, w, h2, 0);
1503 evas_map_point_coord_set(map, 3, x + w2, h2, 0);
1505 case ELM_TRANSIT_EFFECT_WIPE_DIR_RIGHT:
1506 w2 = (w * progress);
1508 evas_map_point_image_uv_set(map, 0, 0, 0);
1509 evas_map_point_image_uv_set(map, 1, w2, 0);
1510 evas_map_point_image_uv_set(map, 2, w2, h);
1511 evas_map_point_image_uv_set(map, 3, 0, h);
1512 evas_map_point_coord_set(map, 0, x, y, 0);
1513 evas_map_point_coord_set(map, 1, x + w2, y, 0);
1514 evas_map_point_coord_set(map, 2, x + w2, h2, 0);
1515 evas_map_point_coord_set(map, 3, x, h2, 0);
1517 case ELM_TRANSIT_EFFECT_WIPE_DIR_UP:
1519 h2 = (h - (h * progress));
1520 evas_map_point_image_uv_set(map, 0, 0, h2);
1521 evas_map_point_image_uv_set(map, 1, w, h2);
1522 evas_map_point_image_uv_set(map, 2, w, h);
1523 evas_map_point_image_uv_set(map, 3, 0, h);
1524 evas_map_point_coord_set(map, 0, x, y + h2, 0);
1525 evas_map_point_coord_set(map, 1, w2, y + h2, 0);
1526 evas_map_point_coord_set(map, 2, w2, y + h, 0);
1527 evas_map_point_coord_set(map, 3, x, y + h, 0);
1529 case ELM_TRANSIT_EFFECT_WIPE_DIR_DOWN:
1531 h2 = (h * progress);
1532 evas_map_point_image_uv_set(map, 0, 0, 0);
1533 evas_map_point_image_uv_set(map, 1, w, 0);
1534 evas_map_point_image_uv_set(map, 2, w, h2);
1535 evas_map_point_image_uv_set(map, 3, 0, h2);
1536 evas_map_point_coord_set(map, 0, x, y, 0);
1537 evas_map_point_coord_set(map, 1, w2, y, 0);
1538 evas_map_point_coord_set(map, 2, w2, y + h2, 0);
1539 evas_map_point_coord_set(map, 3, x, y + h2, 0);
1544 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, _TRANSIT_FOCAL);
1548 _transit_effect_wipe_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit)
1550 EINA_SAFETY_ON_NULL_RETURN(effect);
1551 EINA_SAFETY_ON_NULL_RETURN(transit);
1554 Elm_Transit_Effect_Wipe *wipe = effect;
1555 Eina_Bool reverse = elm_transit_auto_reverse_get(transit);
1557 EINA_LIST_FOREACH(transit->objs, elist, obj)
1559 if ((wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_SHOW && !reverse)
1560 || (wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_HIDE && reverse))
1561 evas_object_show(obj);
1562 else evas_object_hide(obj);
1563 evas_object_map_enable_set(obj, EINA_FALSE);
1570 _transit_effect_wipe_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
1572 EINA_SAFETY_ON_NULL_RETURN(effect);
1573 EINA_SAFETY_ON_NULL_RETURN(transit);
1574 Elm_Transit_Effect_Wipe *wipe = effect;
1576 Evas_Coord _x, _y, _w, _h;
1580 map = evas_map_new(4);
1583 EINA_LIST_FOREACH(transit->objs, elist, obj)
1585 evas_object_geometry_get(obj, &_x, &_y, &_w, &_h);
1587 if (wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_SHOW)
1588 _elm_fx_wipe_show(map, wipe->dir, _x, _y, _w, _h, (float)progress);
1590 _elm_fx_wipe_hide(map, wipe->dir, _x, _y, _w, _h, (float)progress);
1592 evas_object_map_enable_set(obj, EINA_TRUE);
1593 evas_object_map_set(obj, map);
1598 static Elm_Transit_Effect *
1599 _transit_effect_wipe_context_new(Elm_Transit_Effect_Wipe_Type type, Elm_Transit_Effect_Wipe_Dir dir)
1601 Elm_Transit_Effect_Wipe *wipe;
1603 wipe = ELM_NEW(Elm_Transit_Effect_Wipe);
1604 if (!wipe) return NULL;
1613 elm_transit_effect_wipe_add(Elm_Transit *transit, Elm_Transit_Effect_Wipe_Type type, Elm_Transit_Effect_Wipe_Dir dir)
1615 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1616 void *effect_context = _transit_effect_wipe_context_new(type, dir);
1618 if (!effect_context) return NULL;
1619 elm_transit_effect_add(transit,
1620 _transit_effect_wipe_op, effect_context,
1621 _transit_effect_wipe_context_free);
1622 return effect_context;
1626 ///////////////////////////////////////////////////////////////////////////////
1628 ///////////////////////////////////////////////////////////////////////////////
1629 typedef struct _Elm_Transit_Effect_Color Elm_Transit_Effect_Color;
1631 struct _Elm_Transit_Effect_Color
1633 struct _unsigned_color {
1634 unsigned int r, g, b, a;
1636 struct _signed_color {
1642 _transit_effect_color_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
1644 Elm_Transit_Effect_Color *color = effect;
1649 _transit_effect_color_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
1651 EINA_SAFETY_ON_NULL_RETURN(effect);
1652 EINA_SAFETY_ON_NULL_RETURN(transit);
1653 Elm_Transit_Effect_Color *color = effect;
1656 unsigned int r, g, b, a;
1658 r = (color->from.r + (int)((float)color->to.r * progress));
1659 g = (color->from.g + (int)((float)color->to.g * progress));
1660 b = (color->from.b + (int)((float)color->to.b * progress));
1661 a = (color->from.a + (int)((float)color->to.a * progress));
1663 EINA_LIST_FOREACH(transit->objs, elist, obj)
1664 evas_object_color_set(obj, r, g, b, a);
1667 static Elm_Transit_Effect *
1668 _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)
1670 Elm_Transit_Effect_Color *color;
1672 color = ELM_NEW(Elm_Transit_Effect_Color);
1673 if (!color) return NULL;
1675 color->from.r = from_r;
1676 color->from.g = from_g;
1677 color->from.b = from_b;
1678 color->from.a = from_a;
1679 color->to.r = to_r - from_r;
1680 color->to.g = to_g - from_g;
1681 color->to.b = to_b - from_b;
1682 color->to.a = to_a - from_a;
1687 EAPI Elm_Transit_Effect *
1688 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)
1690 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1691 Elm_Transit_Effect *effect_context = _transit_effect_color_context_new(from_r, from_g, from_b, from_a, to_r, to_g, to_b, to_a);
1693 if (!effect_context) return NULL;
1694 elm_transit_effect_add(transit,
1695 _transit_effect_color_op, effect_context,
1696 _transit_effect_color_context_free);
1697 return effect_context;
1700 ///////////////////////////////////////////////////////////////////////////////
1702 ///////////////////////////////////////////////////////////////////////////////
1703 typedef struct _Elm_Transit_Effect_Fade Elm_Transit_Effect_Fade;
1704 typedef struct _Elm_Transit_Effect_Fade_Node Elm_Transit_Effect_Fade_Node;
1706 struct _Elm_Transit_Effect_Fade_Node
1708 Evas_Object *before;
1710 struct _signed_color before_color, after_color;
1713 Eina_Bool inversed : 1;
1716 struct _Elm_Transit_Effect_Fade
1722 _fade_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1724 Elm_Transit_Effect_Fade *fade = data;
1726 Elm_Transit_Effect_Fade_Node *fade_node;
1728 EINA_LIST_FOREACH(fade->nodes, elist, fade_node)
1730 if (fade_node->before == obj)
1731 evas_object_event_callback_del(fade_node->after,
1732 EVAS_CALLBACK_DEL, _fade_object_del_cb);
1733 else if (fade_node->after == obj)
1734 evas_object_event_callback_del(fade_node->before,
1735 EVAS_CALLBACK_DEL, _fade_object_del_cb);
1738 fade->nodes = eina_list_remove_list(fade->nodes, elist);
1745 _fade_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Fade *fade_data)
1747 Elm_Transit_Effect_Fade_Node *fade;
1748 Eina_List *data_list = NULL;
1751 count = eina_list_count(transit->objs);
1752 for (i = 0; i < count; i += 2)
1754 fade = ELM_NEW(Elm_Transit_Effect_Fade_Node);
1757 eina_list_free(data_list);
1761 fade->before = eina_list_nth(transit->objs, i);
1762 fade->after = eina_list_nth(transit->objs, i+1);
1764 evas_object_color_get(fade->before,
1765 &fade->before_color.r, &fade->before_color.g,
1766 &fade->before_color.b, &fade->before_color.a);
1767 evas_object_color_get(fade->after,
1768 &fade->after_color.r, &fade->after_color.g,
1769 &fade->after_color.b, &fade->after_color.a);
1771 fade->before_alpha = (255 - fade->before_color.a);
1772 fade->after_alpha = (255 - fade->after_color.a);
1774 data_list = eina_list_append(data_list, fade);
1776 evas_object_event_callback_add(fade->before,
1777 EVAS_CALLBACK_DEL, _fade_object_del_cb, fade_data);
1778 evas_object_event_callback_add(fade->after,
1779 EVAS_CALLBACK_DEL, _fade_object_del_cb, fade_data);
1785 _transit_effect_fade_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
1787 EINA_SAFETY_ON_NULL_RETURN(effect);
1788 Elm_Transit_Effect_Fade *fade = effect;
1789 Elm_Transit_Effect_Fade_Node *fade_node;
1790 Eina_List *elist, *elist_next;
1792 EINA_LIST_FOREACH_SAFE(fade->nodes, elist, elist_next, fade_node)
1794 evas_object_color_set(fade_node->before, fade_node->before_color.r,
1795 fade_node->before_color.g,
1796 fade_node->before_color.b,
1797 fade_node->before_color.a);
1798 evas_object_color_set(fade_node->after, fade_node->after_color.r,
1799 fade_node->after_color.g,
1800 fade_node->after_color.b,
1801 fade_node->after_color.a);
1803 fade->nodes = eina_list_remove_list(fade->nodes, elist);
1804 evas_object_event_callback_del(fade_node->before,
1805 EVAS_CALLBACK_DEL, _fade_object_del_cb);
1806 evas_object_event_callback_del(fade_node->after,
1807 EVAS_CALLBACK_DEL, _fade_object_del_cb);
1815 _transit_effect_fade_op(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__, double progress)
1817 EINA_SAFETY_ON_NULL_RETURN(effect);
1818 Elm_Transit_Effect_Fade *fade = effect;
1820 Elm_Transit_Effect_Fade_Node *fade_node;
1824 fade->nodes = _fade_nodes_build(transit, fade);
1826 EINA_LIST_FOREACH(fade->nodes, elist, fade_node)
1830 if (!fade_node->inversed)
1832 evas_object_hide(fade_node->after);
1833 evas_object_show(fade_node->before);
1834 fade_node->inversed = EINA_TRUE;
1837 _progress = (1 - (progress * 2));
1839 evas_object_color_set(fade_node->before,
1840 fade_node->before_color.r * _progress,
1841 fade_node->before_color.g * _progress,
1842 fade_node->before_color.b * _progress,
1843 fade_node->before_color.a +
1844 fade_node->before_alpha * (1 - _progress));
1848 if (fade_node->inversed)
1850 evas_object_hide(fade_node->before);
1851 evas_object_show(fade_node->after);
1852 fade_node->inversed = EINA_FALSE;
1855 _progress = ((progress - 0.5) * 2);
1857 evas_object_color_set(fade_node->after,
1858 fade_node->after_color.r * _progress,
1859 fade_node->after_color.g * _progress,
1860 fade_node->after_color.b * _progress,
1861 fade_node->after_color.a +
1862 fade_node->after_alpha * (1 - _progress));
1867 static Elm_Transit_Effect *
1868 _transit_effect_fade_context_new(void)
1870 Elm_Transit_Effect_Fade *fade;
1871 fade = ELM_NEW(Elm_Transit_Effect_Fade);
1872 if (!fade) return NULL;
1876 EAPI Elm_Transit_Effect *
1877 elm_transit_effect_fade_add(Elm_Transit *transit)
1879 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1881 Elm_Transit_Effect *effect_context = _transit_effect_fade_context_new();
1882 if (!effect_context) return NULL;
1883 elm_transit_effect_add(transit,
1884 _transit_effect_fade_op, effect_context,
1885 _transit_effect_fade_context_free);
1886 return effect_context;
1890 ///////////////////////////////////////////////////////////////////////////////
1892 ///////////////////////////////////////////////////////////////////////////////
1893 typedef struct _Elm_Transit_Effect_Blend Elm_Transit_Effect_Blend;
1894 typedef struct _Elm_Transit_Effect_Blend_Node Elm_Transit_Effect_Blend_Node;
1896 struct _Elm_Transit_Effect_Blend_Node
1898 Evas_Object *before;
1900 struct _signed_color from, to;
1903 struct _Elm_Transit_Effect_Blend
1909 _blend_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1911 Elm_Transit_Effect_Blend *blend = data;
1913 Elm_Transit_Effect_Blend_Node *blend_node;
1915 EINA_LIST_FOREACH(blend->nodes, elist, blend_node)
1917 if (blend_node->after == obj)
1918 evas_object_event_callback_del(blend_node->before,
1919 EVAS_CALLBACK_DEL, _blend_object_del_cb);
1920 else if (blend_node->before == obj)
1921 evas_object_event_callback_del(blend_node->after,
1922 EVAS_CALLBACK_DEL, _blend_object_del_cb);
1925 blend->nodes = eina_list_remove_list(blend->nodes, elist);
1932 _blend_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Blend *blend)
1934 Elm_Transit_Effect_Blend_Node *blend_node;
1935 Eina_List *data_list = NULL;
1938 count = eina_list_count(transit->objs);
1939 for (i = 0; i < (count - 1); i += 2)
1941 blend_node = ELM_NEW(Elm_Transit_Effect_Blend_Node);
1944 eina_list_free(data_list);
1948 blend_node->before = eina_list_nth(transit->objs, i);
1949 blend_node->after = eina_list_nth(transit->objs, i + 1);
1950 evas_object_show(blend_node->before);
1951 evas_object_show(blend_node->after);
1953 evas_object_color_get(blend_node->before, &blend_node->from.r,
1954 &blend_node->from.g, &blend_node->from.b,
1955 &blend_node->from.a);
1956 evas_object_color_get(blend_node->after, &blend_node->to.r,
1957 &blend_node->to.g, &blend_node->to.b,
1960 data_list = eina_list_append(data_list, blend_node);
1962 evas_object_event_callback_add(blend_node->before,
1963 EVAS_CALLBACK_DEL, _blend_object_del_cb, blend);
1964 evas_object_event_callback_add(blend_node->after,
1965 EVAS_CALLBACK_DEL, _blend_object_del_cb, blend);
1971 _transit_effect_blend_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
1973 EINA_SAFETY_ON_NULL_RETURN(effect);
1974 Elm_Transit_Effect_Blend *blend = effect;
1975 Elm_Transit_Effect_Blend_Node *blend_node;
1976 Eina_List *elist, *elist_next;
1978 EINA_LIST_FOREACH_SAFE(blend->nodes, elist, elist_next, blend_node)
1980 evas_object_color_set(blend_node->before,
1981 blend_node->from.r, blend_node->from.g,
1982 blend_node->from.b, blend_node->from.a);
1983 evas_object_color_set(blend_node->after, blend_node->to.r,
1984 blend_node->to.g, blend_node->to.b,
1987 if (elm_transit_auto_reverse_get(transit))
1988 evas_object_hide(blend_node->after);
1990 evas_object_hide(blend_node->before);
1992 blend->nodes = eina_list_remove_list(blend->nodes, elist);
1994 evas_object_event_callback_del(blend_node->before,
1995 EVAS_CALLBACK_DEL, _blend_object_del_cb);
1996 evas_object_event_callback_del(blend_node->after,
1997 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2004 _transit_effect_blend_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2006 EINA_SAFETY_ON_NULL_RETURN(effect);
2007 EINA_SAFETY_ON_NULL_RETURN(transit);
2008 Elm_Transit_Effect_Blend *blend = effect;
2009 Elm_Transit_Effect_Blend_Node *blend_node;
2012 if (!blend->nodes) blend->nodes = _blend_nodes_build(transit, blend);
2014 EINA_LIST_FOREACH(blend->nodes, elist, blend_node)
2016 evas_object_color_set(blend_node->before,
2017 (int)(blend_node->from.r * (1 - progress)),
2018 (int)(blend_node->from.g * (1 - progress)),
2019 (int)(blend_node->from.b * (1 - progress)),
2020 (int)(blend_node->from.a * (1 - progress)));
2021 evas_object_color_set(blend_node->after,
2022 (int)(blend_node->to.r * progress),
2023 (int)(blend_node->to.g * progress),
2024 (int)(blend_node->to.b * progress),
2025 (int)(blend_node->to.a * progress));
2029 static Elm_Transit_Effect *
2030 _transit_effect_blend_context_new(void)
2032 Elm_Transit_Effect_Blend *blend;
2034 blend = ELM_NEW(Elm_Transit_Effect_Blend);
2035 if (!blend) return NULL;
2039 EAPI Elm_Transit_Effect *
2040 elm_transit_effect_blend_add(Elm_Transit *transit)
2042 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2043 Elm_Transit_Effect *effect_context = _transit_effect_blend_context_new();
2045 if (!effect_context) return NULL;
2046 elm_transit_effect_add(transit,
2047 _transit_effect_blend_op, effect_context,
2048 _transit_effect_blend_context_free);
2049 return effect_context;
2053 ///////////////////////////////////////////////////////////////////////////////
2055 ///////////////////////////////////////////////////////////////////////////////
2056 typedef struct _Elm_Transit_Effect_Rotation Elm_Transit_Effect_Rotation;
2058 struct _Elm_Transit_Effect_Rotation
2064 _transit_effect_rotation_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
2066 Elm_Transit_Effect_Rotation *rotation = effect;
2071 _transit_effect_rotation_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2073 EINA_SAFETY_ON_NULL_RETURN(effect);
2074 EINA_SAFETY_ON_NULL_RETURN(transit);
2075 Elm_Transit_Effect_Rotation *rotation = effect;
2077 Evas_Coord x, y, w, h;
2079 float half_w, half_h;
2083 map = evas_map_new(4);
2086 EINA_LIST_FOREACH(transit->objs, elist, obj)
2088 evas_map_util_points_populate_from_object_full(map, obj, 0);
2089 degree = rotation->from + (float)(progress * rotation->to);
2091 evas_object_geometry_get(obj, &x, &y, &w, &h);
2093 half_w = (float)w * 0.5;
2094 half_h = (float)h * 0.5;
2096 evas_map_util_rotate(map, degree, x + half_w, y + half_h);
2097 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, _TRANSIT_FOCAL);
2098 evas_object_map_enable_set(obj, EINA_TRUE);
2099 evas_object_map_set(obj, map);
2104 static Elm_Transit_Effect *
2105 _transit_effect_rotation_context_new(float from_degree, float to_degree)
2107 Elm_Transit_Effect_Rotation *rotation;
2109 rotation = ELM_NEW(Elm_Transit_Effect_Rotation);
2110 if (!rotation) return NULL;
2112 rotation->from = from_degree;
2113 rotation->to = to_degree - from_degree;
2118 EAPI Elm_Transit_Effect *
2119 elm_transit_effect_rotation_add(Elm_Transit *transit, float from_degree, float to_degree)
2121 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2122 Elm_Transit_Effect *effect_context = _transit_effect_rotation_context_new(from_degree, to_degree);
2124 if (!effect_context) return NULL;
2125 elm_transit_effect_add(transit,
2126 _transit_effect_rotation_op, effect_context,
2127 _transit_effect_rotation_context_free);
2128 return effect_context;
2132 ///////////////////////////////////////////////////////////////////////////////
2133 //ImageAnimation Effect
2134 ///////////////////////////////////////////////////////////////////////////////
2135 typedef struct _Elm_Transit_Effect_Image_Animation Elm_Transit_Effect_Image_Animation;
2137 struct _Elm_Transit_Effect_Image_Animation
2143 _transit_effect_image_animation_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
2145 EINA_SAFETY_ON_NULL_RETURN(effect);
2146 Elm_Transit_Effect_Image_Animation *image_animation = effect;
2148 Eina_List *elist, *elist_next;
2150 EINA_LIST_FOREACH_SAFE(image_animation->images, elist, elist_next, image)
2152 image_animation->images =
2153 eina_list_remove_list(image_animation->images, elist);
2154 eina_stringshare_del(image);
2157 free(image_animation);
2161 _transit_effect_image_animation_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2163 EINA_SAFETY_ON_NULL_RETURN(effect);
2164 EINA_SAFETY_ON_NULL_RETURN(transit);
2168 Elm_Transit_Effect_Image_Animation *image_animation = effect;
2169 unsigned int count = 0;
2172 type = eina_stringshare_add("icon");
2173 len = eina_list_count(image_animation->images);
2175 if (!len) count = floor(progress * len);
2176 else count = floor(progress * (len - 1));
2178 EINA_LIST_FOREACH(transit->objs, elist, obj)
2180 if (elm_widget_type_check(obj, type))
2181 elm_icon_file_set(obj,
2182 eina_list_nth(image_animation->images, count), NULL);
2185 eina_stringshare_del(type);
2188 static Elm_Transit_Effect *
2189 _transit_effect_image_animation_context_new(Eina_List *images)
2191 Elm_Transit_Effect_Image_Animation *image_animation;
2192 image_animation = ELM_NEW(Elm_Transit_Effect_Image_Animation);
2194 if (!image_animation) return NULL;
2195 image_animation->images = images;
2196 return image_animation;
2199 EAPI Elm_Transit_Effect *
2200 elm_transit_effect_image_animation_add(Elm_Transit *transit, Eina_List *images)
2202 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2203 Elm_Transit_Effect *effect = _transit_effect_image_animation_context_new(images);
2205 if (!effect) return NULL;
2206 elm_transit_effect_add(transit,
2207 _transit_effect_image_animation_op, effect,
2208 _transit_effect_image_animation_context_free);