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_remove(Elm_Transit *transit, Evas_Object *obj);
92 static void _transit_effect_del(Elm_Transit *transit, Elm_Transit_Effect_Module *effect_module);
93 static void _transit_remove_dead_effects(Elm_Transit *transit);
94 static void _transit_del(Elm_Transit *transit);
95 static void _transit_chain_transits_go(Elm_Transit *transit);
96 static void _transit_animate_op(Elm_Transit *transit, double progress);
97 static Eina_Bool _transit_animate_cb(void *data);
99 static char *_transit_key= "_elm_transit_key";
102 _transit_obj_data_update(Elm_Transit *transit, Evas_Object *obj)
104 Elm_Transit_Obj_Data *obj_data = evas_object_data_get(obj, _transit_key);
107 obj_data = ELM_NEW(Elm_Transit_Obj_Data);
109 obj_data->pass_events = evas_object_pass_events_get(obj);
111 if ((!transit->state_keep) && (obj_data->state))
113 free(obj_data->state);
114 obj_data->state = NULL;
118 _transit_obj_states_save(obj, obj_data);
121 evas_object_data_set(obj, _transit_key, obj_data);
125 _transit_obj_states_save(Evas_Object *obj, Elm_Transit_Obj_Data *obj_data)
127 Elm_Transit_Obj_State *state = obj_data->state;
130 state = calloc(1, sizeof(Elm_Transit_Obj_State));
133 evas_object_geometry_get(obj, &state->x, &state->y, &state->w, &state->h);
134 evas_object_color_get(obj, &state->r, &state->g, &state->b, &state->a);
135 state->visible = evas_object_visible_get(obj);
136 state->map_enabled = evas_object_map_enable_get(obj);
137 if (evas_object_map_get(obj))
138 state->map = evas_map_dup(evas_object_map_get(obj));
139 obj_data->state = state;
143 _remove_obj_from_list(Elm_Transit *transit, Evas_Object *obj)
145 //Remove duplicated objects
146 //TODO: Need to consider about optimizing here
149 if (!eina_list_data_find_list(transit->objs, obj))
151 transit->objs = eina_list_remove(transit->objs, obj);
152 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_DEL,
153 _transit_obj_remove_cb,
159 _transit_obj_remove_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
161 Elm_Transit *transit = data;
162 Elm_Transit_Obj_Data *obj_data = evas_object_data_get(obj, _transit_key);
166 free(obj_data->state);
169 _remove_obj_from_list(transit, obj);
170 if (!transit->objs) elm_transit_del(transit);
174 _transit_obj_data_recover(Elm_Transit *transit, Evas_Object *obj)
176 Elm_Transit_Obj_Data *obj_data;
177 Elm_Transit_Obj_State *state;
179 obj_data = evas_object_data_get(obj, _transit_key);
180 if (!obj_data) return;
181 evas_object_data_del(obj, _transit_key);
182 evas_object_pass_events_set(obj, obj_data->pass_events);
183 state = obj_data->state;
186 //recover the states of the object.
187 if (!transit->state_keep)
189 evas_object_move(obj, state->x, state->y);
190 evas_object_resize(obj, state->w, state->h);
191 evas_object_color_set(obj, state->r, state->g, state->b, state->a);
192 if (state->visible) evas_object_show(obj);
193 else evas_object_hide(obj);
194 if (state->map_enabled)
195 evas_object_map_enable_set(obj, EINA_TRUE);
197 evas_object_map_enable_set(obj, EINA_FALSE);
199 evas_object_map_set(obj, state->map);
207 _transit_obj_remove(Elm_Transit *transit, Evas_Object *obj)
209 _remove_obj_from_list(transit, obj);
210 _transit_obj_data_recover(transit, obj);
214 _transit_effect_del(Elm_Transit *transit, Elm_Transit_Effect_Module *effect_module)
216 if (effect_module->end_cb)
217 effect_module->end_cb(effect_module->effect, transit);
222 _transit_remove_dead_effects(Elm_Transit *transit)
224 Elm_Transit_Effect_Module *effect_module;
226 EINA_INLIST_FOREACH(transit->effect_list, effect_module)
228 if (effect_module->deleted)
230 _transit_effect_del(transit, effect_module);
231 transit->effects_pending_del--;
232 if (!transit->effects_pending_del) return;
238 _transit_del(Elm_Transit *transit)
240 Elm_Transit_Effect_Module *effect_module;
241 Elm_Transit *chain_transit;
242 Eina_List *elist, *elist_next;
244 EINA_LIST_FOREACH_SAFE(transit->next_chain_transits, elist, elist_next, chain_transit)
246 if (transit->prev_chain_transit)
247 transit->prev_chain_transit->next_chain_transits = eina_list_remove(transit->prev_chain_transit->next_chain_transits, transit);
248 chain_transit->prev_chain_transit = NULL;
251 eina_list_free(transit->next_chain_transits);
253 if (transit->animator)
254 ecore_animator_del(transit->animator);
256 while (transit->effect_list)
258 effect_module = EINA_INLIST_CONTAINER_GET(transit->effect_list, Elm_Transit_Effect_Module);
259 transit->effect_list = eina_inlist_remove(transit->effect_list, transit->effect_list);
260 _transit_effect_del(transit, effect_module);
263 while (transit->objs)
264 _transit_obj_remove(transit, eina_list_data_get(transit->objs));
266 transit->deleted = EINA_TRUE;
268 if (transit->del_data.func)
269 transit->del_data.func(transit->del_data.arg, transit);
271 EINA_MAGIC_SET(transit, EINA_MAGIC_NONE);
276 _transit_chain_transits_go(Elm_Transit *transit)
278 Eina_List *elist, *elist_next;
279 Elm_Transit *chain_transit;
282 EINA_LIST_FOREACH(transit->objs, elist, obj)
283 _transit_obj_data_recover(transit, obj);
285 EINA_LIST_FOREACH_SAFE(transit->next_chain_transits, elist, elist_next, chain_transit)
286 elm_transit_go(chain_transit);
290 _transit_animate_op(Elm_Transit *transit, double progress)
292 Elm_Transit_Effect_Module *effect_module;
295 EINA_INLIST_FOREACH(transit->effect_list, effect_module)
297 if (transit->deleted) break;
298 if (!effect_module->deleted)
299 effect_module->transition_cb(effect_module->effect, transit, progress);
303 if (transit->walking) return;
305 if (transit->deleted) _transit_del(transit);
306 else if (transit->effects_pending_del) _transit_remove_dead_effects(transit);
310 _transit_animate_cb(void *data)
312 Elm_Transit *transit = data;
313 double elapsed_time, duration;
315 transit->time.current = ecore_loop_time_get();
316 elapsed_time = transit->time.current - transit->time.begin;
317 duration = transit->time.duration + transit->time.delayed;
319 if (elapsed_time > duration)
320 elapsed_time = duration;
322 transit->progress = elapsed_time / duration;
323 switch (transit->tween_mode)
325 case ELM_TRANSIT_TWEEN_MODE_ACCELERATE:
326 transit->progress = 1.0 - sin((ELM_PI / 2.0) + (transit->progress * ELM_PI / 2.0));
328 case ELM_TRANSIT_TWEEN_MODE_DECELERATE:
329 transit->progress = sin(transit->progress * ELM_PI / 2.0);
331 case ELM_TRANSIT_TWEEN_MODE_SINUSOIDAL:
332 transit->progress = (1.0 - cos(transit->progress * ELM_PI)) / 2.0;
339 if (transit->repeat.reverse) transit->progress = 1 - transit->progress;
341 if (transit->time.duration > 0) _transit_animate_op(transit, transit->progress);
343 /* Not end. Keep going. */
344 if (elapsed_time < duration) return ECORE_CALLBACK_RENEW;
346 /* Repeat and reverse and time done! */
347 if ((transit->repeat.count >= 0) &&
348 (transit->repeat.current == transit->repeat.count) &&
349 ((!transit->auto_reverse) || transit->repeat.reverse))
351 /* run chain transit */
352 if (transit->next_chain_transits)
353 _transit_chain_transits_go(transit);
355 elm_transit_del(transit);
356 return ECORE_CALLBACK_CANCEL;
360 if (!transit->auto_reverse || transit->repeat.reverse)
362 transit->repeat.current++;
363 transit->repeat.reverse = EINA_FALSE;
365 else transit->repeat.reverse = EINA_TRUE;
367 transit->time.begin = ecore_loop_time_get();
369 return ECORE_CALLBACK_RENEW;
373 elm_transit_add(void)
375 Elm_Transit *transit = ELM_NEW(Elm_Transit);
378 ERR("Failed to allocate a elm_transit object!");
382 EINA_MAGIC_SET(transit, ELM_TRANSIT_MAGIC);
384 elm_transit_tween_mode_set(transit, ELM_TRANSIT_TWEEN_MODE_LINEAR);
390 elm_transit_del(Elm_Transit *transit)
392 ELM_TRANSIT_CHECK_OR_RETURN(transit);
394 if (transit->walking) transit->deleted = EINA_TRUE;
395 else _transit_del(transit);
399 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)
401 ELM_TRANSIT_CHECK_OR_RETURN(transit);
402 EINA_SAFETY_ON_NULL_RETURN(transition_cb);
403 Elm_Transit_Effect_Module *effect_module;
405 EINA_INLIST_FOREACH(transit->effect_list, effect_module)
406 if ((effect_module->transition_cb == transition_cb) && (effect_module->effect == effect))
408 WRN("elm_transit does not allow to add the duplicated effect! : transit=%p", transit);
412 effect_module = ELM_NEW(Elm_Transit_Effect_Module);
415 ERR("Failed to allocate a new effect!: transit=%p", transit);
419 effect_module->end_cb = end_cb;
420 effect_module->transition_cb = transition_cb;
421 effect_module->effect = effect;
423 transit->effect_list = eina_inlist_append(transit->effect_list, (Eina_Inlist*) effect_module);
427 elm_transit_effect_del(Elm_Transit *transit, Elm_Transit_Effect_Transition_Cb transition_cb, Elm_Transit_Effect *effect)
429 ELM_TRANSIT_CHECK_OR_RETURN(transit);
430 EINA_SAFETY_ON_NULL_RETURN(transition_cb);
431 Elm_Transit_Effect_Module *effect_module;
433 EINA_INLIST_FOREACH(transit->effect_list, effect_module)
435 if ((effect_module->transition_cb == transition_cb) && (effect_module->effect == effect))
437 if (transit->walking)
439 effect_module->deleted = EINA_TRUE;
440 transit->effects_pending_del++;
444 _transit_effect_del(transit, effect_module);
445 if (!transit->effect_list) elm_transit_del(transit);
453 elm_transit_object_add(Elm_Transit *transit, Evas_Object *obj)
455 ELM_TRANSIT_CHECK_OR_RETURN(transit);
456 EINA_SAFETY_ON_NULL_RETURN(obj);
458 if (transit->animator)
460 if (!evas_object_data_get(obj, _transit_key))
462 _transit_obj_data_update(transit, obj);
463 evas_object_pass_events_set(obj, EINA_TRUE);
467 evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
468 _transit_obj_remove_cb,
471 transit->objs = eina_list_append(transit->objs, obj);
475 elm_transit_object_remove(Elm_Transit *transit, Evas_Object *obj)
477 ELM_TRANSIT_CHECK_OR_RETURN(transit);
478 EINA_SAFETY_ON_NULL_RETURN(obj);
480 _transit_obj_remove(transit, obj);
481 if (!transit->objs) elm_transit_del(transit);
484 EAPI const Eina_List *
485 elm_transit_objects_get(const Elm_Transit *transit)
487 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
488 return transit->objs;
492 elm_transit_event_enabled_set(Elm_Transit *transit, Eina_Bool enabled)
494 ELM_TRANSIT_CHECK_OR_RETURN(transit);
499 if (transit->event_enabled == enabled) return;
500 transit->event_enabled = !!enabled;
501 if (!transit->animator) return;
503 EINA_LIST_FOREACH(transit->objs, list, obj)
504 evas_object_pass_events_set(obj, enabled);
508 elm_transit_event_enabled_get(const Elm_Transit *transit)
510 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
511 return transit->event_enabled;
515 elm_transit_del_cb_set(Elm_Transit *transit, void (*cb) (void *data, Elm_Transit *transit), void *data)
517 ELM_TRANSIT_CHECK_OR_RETURN(transit);
518 transit->del_data.func = cb;
519 transit->del_data.arg = data;
523 elm_transit_auto_reverse_set(Elm_Transit *transit, Eina_Bool reverse)
525 ELM_TRANSIT_CHECK_OR_RETURN(transit);
526 transit->auto_reverse = reverse;
530 elm_transit_auto_reverse_get(const Elm_Transit *transit)
532 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
533 return transit->auto_reverse;
537 elm_transit_repeat_times_set(Elm_Transit *transit, int repeat)
539 ELM_TRANSIT_CHECK_OR_RETURN(transit);
540 transit->repeat.count = repeat;
541 transit->repeat.current = 0;
545 elm_transit_repeat_times_get(const Elm_Transit *transit)
547 ELM_TRANSIT_CHECK_OR_RETURN(transit, 0);
548 return transit->repeat.count;
552 elm_transit_tween_mode_set(Elm_Transit *transit, Elm_Transit_Tween_Mode tween_mode)
554 ELM_TRANSIT_CHECK_OR_RETURN(transit);
555 transit->tween_mode = tween_mode;
558 EAPI Elm_Transit_Tween_Mode
559 elm_transit_tween_mode_get(const Elm_Transit *transit)
561 ELM_TRANSIT_CHECK_OR_RETURN(transit, ELM_TRANSIT_TWEEN_MODE_LINEAR);
562 return transit->tween_mode;
566 elm_transit_duration_set(Elm_Transit *transit, double duration)
568 ELM_TRANSIT_CHECK_OR_RETURN(transit);
569 if (transit->animator)
571 WRN("elm_transit does not allow to set the duration time in operating! : transit=%p", transit);
574 transit->time.duration = duration;
578 elm_transit_duration_get(const Elm_Transit *transit)
580 ELM_TRANSIT_CHECK_OR_RETURN(transit, 0.0);
581 return transit->time.duration;
585 elm_transit_go(Elm_Transit *transit)
587 ELM_TRANSIT_CHECK_OR_RETURN(transit);
592 if (transit->animator)
593 ecore_animator_del(transit->animator);
595 EINA_LIST_FOREACH(transit->objs, elist, obj)
596 _transit_obj_data_update(transit, obj);
598 if (!transit->event_enabled)
600 EINA_LIST_FOREACH(transit->objs, elist, obj)
601 evas_object_pass_events_set(obj, EINA_TRUE);
604 transit->time.paused = 0;
605 transit->time.delayed = 0;
606 transit->time.begin = ecore_loop_time_get();
607 transit->animator = ecore_animator_add(_transit_animate_cb, transit);
611 elm_transit_paused_set(Elm_Transit *transit, Eina_Bool paused)
613 ELM_TRANSIT_CHECK_OR_RETURN(transit);
615 if (!transit->animator) return;
619 if (transit->time.paused > 0)
621 ecore_animator_freeze(transit->animator);
622 transit->time.paused = ecore_loop_time_get();
626 if (transit->time.paused == 0)
628 ecore_animator_thaw(transit->animator);
629 transit->time.delayed += (ecore_loop_time_get() - transit->time.paused);
630 transit->time.paused = 0;
635 elm_transit_paused_get(const Elm_Transit *transit)
637 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
639 if (transit->time.paused == 0)
646 elm_transit_progress_value_get(const Elm_Transit *transit)
648 ELM_TRANSIT_CHECK_OR_RETURN(transit, 0);
650 return transit->progress;
654 elm_transit_objects_final_state_keep_set(Elm_Transit *transit, Eina_Bool state_keep)
656 ELM_TRANSIT_CHECK_OR_RETURN(transit);
658 if (transit->state_keep == state_keep) return;
659 if (transit->animator)
661 WRN("elm_transit does not allow to change final state keep mode in operating! : transit=%p", transit);
664 transit->state_keep = !!state_keep;
668 elm_transit_objects_final_state_keep_get(const Elm_Transit *transit)
670 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
671 return transit->state_keep;
675 elm_transit_chain_transit_add(Elm_Transit *transit, Elm_Transit *chain_transit)
677 ELM_TRANSIT_CHECK_OR_RETURN(transit);
678 ELM_TRANSIT_CHECK_OR_RETURN(chain_transit);
680 if (transit == chain_transit)
682 WRN("You add a same transit as a chain transit! : transit=%p, chain_transit=%p", transit, chain_transit);
685 if (transit == chain_transit->prev_chain_transit)
688 if (chain_transit->prev_chain_transit)
689 chain_transit->prev_chain_transit->next_chain_transits = eina_list_remove(chain_transit->prev_chain_transit->next_chain_transits, chain_transit);
691 chain_transit->prev_chain_transit = transit;
692 transit->next_chain_transits = eina_list_append(transit->next_chain_transits, chain_transit);
696 elm_transit_chain_transit_del(Elm_Transit *transit, Elm_Transit *chain_transit)
698 ELM_TRANSIT_CHECK_OR_RETURN(transit);
699 ELM_TRANSIT_CHECK_OR_RETURN(chain_transit);
701 if (chain_transit->prev_chain_transit != transit)
703 WRN("These two transit does not have the chain relationship! : transit=%p, chain_transit=%p", transit, chain_transit);
707 chain_transit->prev_chain_transit = NULL;
708 transit->next_chain_transits = eina_list_remove(transit->next_chain_transits, chain_transit);
712 elm_transit_chain_transits_get(const Elm_Transit * transit)
714 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
715 return transit->next_chain_transits;
718 ///////////////////////////////////////////////////////////////////////////
720 ///////////////////////////////////////////////////////////////////////////
721 typedef struct _Elm_Transit_Effect_Resizing Elm_Transit_Effect_Resizing;
723 struct _Elm_Transit_Effect_Resizing
731 _transit_effect_resizing_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
733 Elm_Transit_Effect_Resizing *resizing = effect;
738 _transit_effect_resizing_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
740 EINA_SAFETY_ON_NULL_RETURN(effect);
741 EINA_SAFETY_ON_NULL_RETURN(transit);
745 Elm_Transit_Effect_Resizing *resizing = effect;
747 w = resizing->from.w + (resizing->to.w * progress);
748 h = resizing->from.h + (resizing->to.h * progress);
750 EINA_LIST_FOREACH(transit->objs, elist, obj)
751 evas_object_resize(obj, w, h);
754 static Elm_Transit_Effect *
755 _transit_effect_resizing_context_new(Evas_Coord from_w, Evas_Coord from_h, Evas_Coord to_w, Evas_Coord to_h)
757 Elm_Transit_Effect_Resizing *resizing;
759 resizing = ELM_NEW(Elm_Transit_Effect_Resizing);
760 if (!resizing) return NULL;
762 resizing->from.w = from_w;
763 resizing->from.h = from_h;
764 resizing->to.w = to_w - from_w;
765 resizing->to.h = to_h - from_h;
770 EAPI Elm_Transit_Effect *
771 elm_transit_effect_resizing_add(Elm_Transit *transit, Evas_Coord from_w, Evas_Coord from_h, Evas_Coord to_w, Evas_Coord to_h)
773 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
774 Elm_Transit_Effect *effect = _transit_effect_resizing_context_new(from_w, from_h, to_w, to_h);
778 ERR("Failed to allocate resizing effect! : transit=%p", transit);
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 = _transit_effect_translation_context_new(from_dx, from_dy, to_dx, to_dy);
916 ERR("Failed to allocate translation effect! : transit=%p", transit);
919 elm_transit_effect_add(transit,
920 _transit_effect_translation_op, effect,
921 _transit_effect_translation_context_free);
925 ///////////////////////////////////////////////////////////////////////////
927 ///////////////////////////////////////////////////////////////////////////
928 typedef struct _Elm_Transit_Effect_Zoom Elm_Transit_Effect_Zoom;
930 struct _Elm_Transit_Effect_Zoom
936 _transit_effect_zoom_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
938 Elm_Transit_Effect_Zoom *zoom = effect;
943 _transit_effect_zoom_op(Elm_Transit_Effect *effect, Elm_Transit *transit , double progress)
945 EINA_SAFETY_ON_NULL_RETURN(effect);
946 EINA_SAFETY_ON_NULL_RETURN(transit);
949 Elm_Transit_Effect_Zoom *zoom = effect;
951 Evas_Coord x, y, w, h;
953 map = evas_map_new(4);
956 EINA_LIST_FOREACH(transit->objs, elist, obj)
958 evas_object_geometry_get(obj, &x, &y, &w, &h);
959 evas_map_util_points_populate_from_object_full(map, obj, zoom->from +
960 (progress * zoom->to));
961 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, _TRANSIT_FOCAL);
962 evas_object_map_set(obj, map);
963 evas_object_map_enable_set(obj, EINA_TRUE);
968 static Elm_Transit_Effect *
969 _transit_effect_zoom_context_new(float from_rate, float to_rate)
971 Elm_Transit_Effect_Zoom *zoom;
973 zoom = ELM_NEW(Elm_Transit_Effect_Zoom);
974 if (!zoom) return NULL;
976 zoom->from = (_TRANSIT_FOCAL - (from_rate * _TRANSIT_FOCAL)) * (1 / from_rate);
977 zoom->to = ((_TRANSIT_FOCAL - (to_rate * _TRANSIT_FOCAL)) * (1 / to_rate)) - zoom->from;
982 EAPI Elm_Transit_Effect *
983 elm_transit_effect_zoom_add(Elm_Transit *transit, float from_rate, float to_rate)
985 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
986 Elm_Transit_Effect *effect = _transit_effect_zoom_context_new(from_rate, to_rate);
990 ERR("Failed to allocate zoom effect! : transit=%p", transit);
993 elm_transit_effect_add(transit,
994 _transit_effect_zoom_op, effect,
995 _transit_effect_zoom_context_free);
999 ///////////////////////////////////////////////////////////////////////////
1001 ///////////////////////////////////////////////////////////////////////////
1002 typedef struct _Elm_Transit_Effect_Flip Elm_Transit_Effect_Flip;
1004 struct _Elm_Transit_Effect_Flip
1006 Elm_Transit_Effect_Flip_Axis axis;
1011 _transit_effect_flip_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit)
1013 EINA_SAFETY_ON_NULL_RETURN(effect);
1014 EINA_SAFETY_ON_NULL_RETURN(transit);
1015 Elm_Transit_Effect_Flip *flip = effect;
1016 Evas_Object *front, *back;
1018 int count = eina_list_count(transit->objs);
1020 for (i = 0; i < (count - 1); i += 2)
1022 front = eina_list_nth(transit->objs, i);
1023 back = eina_list_nth(transit->objs, i+1);
1024 evas_object_map_enable_set(front, EINA_FALSE);
1025 evas_object_map_enable_set(back, EINA_FALSE);
1031 _transit_effect_flip_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
1033 EINA_SAFETY_ON_NULL_RETURN(effect);
1034 EINA_SAFETY_ON_NULL_RETURN(transit);
1035 Evas_Object *obj, *front, *back;
1037 Elm_Transit_Effect_Flip *flip = effect;
1040 Evas_Coord x, y, w, h;
1042 map = evas_map_new(4);
1045 if (flip->cw) degree = (float)(progress * 180);
1046 else degree = (float)(progress * -180);
1048 count = eina_list_count(transit->objs);
1050 for (i = 0; i < (count - 1); i += 2)
1052 Evas_Coord half_w, half_h;
1054 front = eina_list_nth(transit->objs, i);
1055 back = eina_list_nth(transit->objs, i+1);
1057 if ((degree < 90) && (degree > -90))
1062 evas_object_hide(back);
1063 evas_object_show(front);
1071 evas_object_hide(front);
1072 evas_object_show(back);
1076 evas_map_util_points_populate_from_object_full(map, obj, 0);
1077 evas_object_geometry_get(obj, &x, &y, &w, &h);
1081 if (flip->axis == ELM_TRANSIT_EFFECT_FLIP_AXIS_Y)
1083 if ((degree >= 90) || (degree <= -90))
1085 evas_map_point_image_uv_set(map, 0, w, 0);
1086 evas_map_point_image_uv_set(map, 1, 0, 0);
1087 evas_map_point_image_uv_set(map, 2, 0, h);
1088 evas_map_point_image_uv_set(map, 3, w, h);
1090 evas_map_util_3d_rotate(map, 0, degree,
1091 0, x + half_w, y + half_h, 0);
1095 if ((degree >= 90) || (degree <= -90))
1097 evas_map_point_image_uv_set(map, 0, 0, h);
1098 evas_map_point_image_uv_set(map, 1, w, h);
1099 evas_map_point_image_uv_set(map, 2, w, 0);
1100 evas_map_point_image_uv_set(map, 3, 0, 0);
1102 evas_map_util_3d_rotate(map, degree,
1103 0, 0, x + half_w, y + half_h, 0);
1105 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, _TRANSIT_FOCAL);
1106 evas_object_map_enable_set(front, EINA_TRUE);
1107 evas_object_map_enable_set(back, EINA_TRUE);
1108 evas_object_map_set(obj, map);
1113 static Elm_Transit_Effect *
1114 _transit_effect_flip_context_new(Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1116 Elm_Transit_Effect_Flip *flip;
1118 flip = ELM_NEW(Elm_Transit_Effect_Flip);
1119 if (!flip) return NULL;
1127 EAPI Elm_Transit_Effect *
1128 elm_transit_effect_flip_add(Elm_Transit *transit, Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1130 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1131 Elm_Transit_Effect *effect = _transit_effect_flip_context_new(axis, cw);
1135 ERR("Failed to allocate flip effect! : transit=%p", transit);
1138 elm_transit_effect_add(transit,
1139 _transit_effect_flip_op, effect,
1140 _transit_effect_flip_context_free);
1144 ///////////////////////////////////////////////////////////////////////////
1145 //ResizableFlip Effect
1146 ///////////////////////////////////////////////////////////////////////////
1147 typedef struct _Elm_Transit_Effect_Resizable_Flip Elm_Transit_Effect_ResizableFlip;
1148 typedef struct _Elm_Transit_Effect_Resizable_Flip_Node Elm_Transit_Effect_ResizableFlip_Node;
1150 struct _Elm_Transit_Effect_Resizable_Flip_Node
1156 } from_pos, from_size, to_pos, to_size;
1159 struct _Elm_Transit_Effect_Resizable_Flip
1163 Elm_Transit_Effect_Flip_Axis axis;
1167 _resizable_flip_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1169 Elm_Transit_Effect_ResizableFlip *resizable_flip = data;
1171 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1173 EINA_LIST_FOREACH(resizable_flip->nodes, elist, resizable_flip_node)
1175 if (resizable_flip_node->front == obj)
1176 evas_object_event_callback_del(resizable_flip_node->back,
1177 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1178 else if (resizable_flip_node->back == obj)
1179 evas_object_event_callback_del(resizable_flip_node->front,
1180 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1183 resizable_flip->nodes = eina_list_remove_list(resizable_flip->nodes,
1185 free(resizable_flip_node);
1191 _resizable_flip_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_ResizableFlip *resizable_flip)
1193 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1194 Eina_List *data_list = NULL;
1195 Evas_Coord front_x, front_y, front_w, front_h;
1196 Evas_Coord back_x, back_y, back_w, back_h;
1199 count = eina_list_count(transit->objs);
1200 for (i = 0; i < (count - 1); i += 2)
1202 resizable_flip_node = ELM_NEW(Elm_Transit_Effect_ResizableFlip_Node);
1203 if (!resizable_flip_node)
1205 eina_list_free(data_list);
1209 resizable_flip_node->front = eina_list_nth(transit->objs, i);
1210 resizable_flip_node->back = eina_list_nth(transit->objs, i+1);
1212 evas_object_geometry_get(resizable_flip_node->front,
1213 &front_x, &front_y, &front_w, &front_h);
1214 evas_object_geometry_get(resizable_flip_node->back,
1215 &back_x, &back_y, &back_w, &back_h);
1217 resizable_flip_node->from_pos.x = front_x;
1218 resizable_flip_node->from_pos.y = front_y;
1219 resizable_flip_node->to_pos.x = back_x - front_x;
1220 resizable_flip_node->to_pos.y = back_y - front_y;
1222 resizable_flip_node->from_size.x = front_w;
1223 resizable_flip_node->from_size.y = front_h;
1224 resizable_flip_node->to_size.x = back_w - front_w;
1225 resizable_flip_node->to_size.y = back_h - front_h;
1227 data_list = eina_list_append(data_list, resizable_flip_node);
1229 evas_object_event_callback_add(resizable_flip_node->back,
1230 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb, resizable_flip);
1231 evas_object_event_callback_add(resizable_flip_node->front,
1232 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb, resizable_flip);
1239 _set_image_uv_by_axis_y(Evas_Map *map, Elm_Transit_Effect_ResizableFlip_Node *flip, float degree)
1241 if ((degree >= 90) || (degree <= -90))
1243 evas_map_point_image_uv_set(map, 0,
1244 (flip->from_size.x * 2) + flip->to_size.x,
1246 evas_map_point_image_uv_set(map, 1, 0, 0);
1247 evas_map_point_image_uv_set(map, 2, 0,
1248 (flip->from_size.y * 2) + flip->to_size.y);
1249 evas_map_point_image_uv_set(map, 3,
1250 (flip->from_size.x * 2) + flip->to_size.x,
1251 (flip->from_size.y * 2) + flip->to_size.y);
1255 evas_map_point_image_uv_set(map, 0, 0, 0);
1256 evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
1257 evas_map_point_image_uv_set(map, 2, flip->from_size.x,
1259 evas_map_point_image_uv_set(map, 3, 0, flip->from_size.y);
1264 _set_image_uv_by_axis_x(Evas_Map *map, Elm_Transit_Effect_ResizableFlip_Node *flip, float degree)
1266 if ((degree >= 90) || (degree <= -90))
1268 evas_map_point_image_uv_set(map, 0, 0,
1269 (flip->from_size.y * 2) + flip->to_size.y);
1270 evas_map_point_image_uv_set(map, 1,
1271 (flip->from_size.x * 2) + flip->to_size.x,
1272 (flip->from_size.y * 2) + flip->to_size.y);
1273 evas_map_point_image_uv_set(map, 2,
1274 (flip->from_size.x * 2) + flip->to_size.x,
1276 evas_map_point_image_uv_set(map, 3, 0, 0);
1280 evas_map_point_image_uv_set(map, 0, 0, 0);
1281 evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
1282 evas_map_point_image_uv_set(map, 2, flip->from_size.x,
1284 evas_map_point_image_uv_set(map, 3, 0, flip->from_size.y);
1289 _transit_effect_resizable_flip_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
1291 EINA_SAFETY_ON_NULL_RETURN(effect);
1293 Elm_Transit_Effect_ResizableFlip *resizable_flip = effect;
1294 Eina_List *elist, *elist_next;
1295 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1297 EINA_LIST_FOREACH_SAFE(resizable_flip->nodes,
1298 elist, elist_next, resizable_flip_node)
1300 evas_object_map_enable_set(resizable_flip_node->front, EINA_FALSE);
1301 evas_object_map_enable_set(resizable_flip_node->back, EINA_FALSE);
1303 resizable_flip->nodes = eina_list_remove_list(resizable_flip->nodes,
1306 evas_object_event_callback_del(resizable_flip_node->back,
1307 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1308 evas_object_event_callback_del(resizable_flip_node->front,
1309 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1310 free(resizable_flip_node);
1312 free(resizable_flip);
1316 _transit_effect_resizable_flip_op(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__, double progress)
1318 EINA_SAFETY_ON_NULL_RETURN(effect);
1323 Evas_Coord half_w, half_h;
1324 Elm_Transit_Effect_ResizableFlip *resizable_flip = effect;
1325 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1328 map = evas_map_new(4);
1331 if (resizable_flip->cw) degree = (float)(progress * 180);
1332 else degree = (float)(progress * -180);
1334 if (!resizable_flip->nodes)
1335 resizable_flip->nodes = _resizable_flip_nodes_build(transit,
1338 EINA_LIST_FOREACH(resizable_flip->nodes, elist, resizable_flip_node)
1340 if ((degree < 90) && (degree > -90))
1342 obj = resizable_flip_node->front;
1343 if (resizable_flip_node->front != resizable_flip_node->back)
1345 evas_object_hide(resizable_flip_node->back);
1346 evas_object_show(resizable_flip_node->front);
1351 obj = resizable_flip_node->back;
1352 if (resizable_flip_node->front != resizable_flip_node->back)
1354 evas_object_hide(resizable_flip_node->front);
1355 evas_object_show(resizable_flip_node->back);
1359 x = resizable_flip_node->from_pos.x +
1360 (resizable_flip_node->to_pos.x * progress);
1361 y = resizable_flip_node->from_pos.y +
1362 (resizable_flip_node->to_pos.y * progress);
1363 w = resizable_flip_node->from_size.x +
1364 (resizable_flip_node->to_size.x * progress);
1365 h = resizable_flip_node->from_size.y +
1366 (resizable_flip_node->to_size.y * progress);
1367 evas_map_point_coord_set(map, 0, x, y, 0);
1368 evas_map_point_coord_set(map, 1, x + w, y, 0);
1369 evas_map_point_coord_set(map, 2, x + w, y + h, 0);
1370 evas_map_point_coord_set(map, 3, x, y + h, 0);
1372 half_w = (Evas_Coord)(w / 2);
1373 half_h = (Evas_Coord)(h / 2);
1375 if (resizable_flip->axis == ELM_TRANSIT_EFFECT_FLIP_AXIS_Y)
1377 _set_image_uv_by_axis_y(map, resizable_flip_node, degree);
1378 evas_map_util_3d_rotate(map, 0, degree,
1379 0, x + half_w, y + half_h, 0);
1383 _set_image_uv_by_axis_x(map, resizable_flip_node, degree);
1384 evas_map_util_3d_rotate(map, degree, 0,
1385 0, x + half_w, y + half_h, 0);
1388 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, _TRANSIT_FOCAL);
1389 evas_object_map_enable_set(resizable_flip_node->front, EINA_TRUE);
1390 evas_object_map_enable_set(resizable_flip_node->back, EINA_TRUE);
1391 evas_object_map_set(obj, map);
1396 static Elm_Transit_Effect *
1397 _transit_effect_resizable_flip_context_new(Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1399 Elm_Transit_Effect_ResizableFlip *resizable_flip;
1401 resizable_flip = ELM_NEW(Elm_Transit_Effect_ResizableFlip);
1402 if (!resizable_flip) return NULL;
1404 resizable_flip->cw = cw;
1405 resizable_flip->axis = axis;
1407 return resizable_flip;
1410 EAPI Elm_Transit_Effect *
1411 elm_transit_effect_resizable_flip_add(Elm_Transit *transit, Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1413 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1414 Elm_Transit_Effect *effect = _transit_effect_resizable_flip_context_new(axis, cw);
1418 ERR("Failed to allocate resizable_flip effect! : transit=%p", transit);
1421 elm_transit_effect_add(transit,
1422 _transit_effect_resizable_flip_op, effect,
1423 _transit_effect_resizable_flip_context_free);
1427 ///////////////////////////////////////////////////////////////////////////
1429 ///////////////////////////////////////////////////////////////////////////
1430 typedef struct _Elm_Transit_Effect_Wipe Elm_Transit_Effect_Wipe;
1432 struct _Elm_Transit_Effect_Wipe
1434 Elm_Transit_Effect_Wipe_Type type;
1435 Elm_Transit_Effect_Wipe_Dir dir;
1439 _elm_fx_wipe_hide(Evas_Map * map, Elm_Transit_Effect_Wipe_Dir dir, float x, float y, float w, float h, float progress)
1445 case ELM_TRANSIT_EFFECT_WIPE_DIR_LEFT:
1446 w2 = w - (w * progress);
1448 evas_map_point_image_uv_set(map, 0, 0, 0);
1449 evas_map_point_image_uv_set(map, 1, w2, 0);
1450 evas_map_point_image_uv_set(map, 2, w2, h);
1451 evas_map_point_image_uv_set(map, 3, 0, h);
1452 evas_map_point_coord_set(map, 0, x, y, 0);
1453 evas_map_point_coord_set(map, 1, x + w2, y, 0);
1454 evas_map_point_coord_set(map, 2, x + w2, h2, 0);
1455 evas_map_point_coord_set(map, 3, x, h2, 0);
1457 case ELM_TRANSIT_EFFECT_WIPE_DIR_RIGHT:
1458 w2 = (w * progress);
1460 evas_map_point_image_uv_set(map, 0, w2, 0);
1461 evas_map_point_image_uv_set(map, 1, w, 0);
1462 evas_map_point_image_uv_set(map, 2, w, h);
1463 evas_map_point_image_uv_set(map, 3, w2, h);
1464 evas_map_point_coord_set(map, 0, x + w2, y, 0);
1465 evas_map_point_coord_set(map, 1, x + w, y, 0);
1466 evas_map_point_coord_set(map, 2, x + w, h2, 0);
1467 evas_map_point_coord_set(map, 3, x + w2, h2, 0);
1469 case ELM_TRANSIT_EFFECT_WIPE_DIR_UP:
1471 h2 = h - (h * progress);
1472 evas_map_point_image_uv_set(map, 0, 0, 0);
1473 evas_map_point_image_uv_set(map, 1, w, 0);
1474 evas_map_point_image_uv_set(map, 2, w, h2);
1475 evas_map_point_image_uv_set(map, 3, 0, h2);
1476 evas_map_point_coord_set(map, 0, x, y, 0);
1477 evas_map_point_coord_set(map, 1, w2, y, 0);
1478 evas_map_point_coord_set(map, 2, w2, y+h2, 0);
1479 evas_map_point_coord_set(map, 3, x, y+h2, 0);
1481 case ELM_TRANSIT_EFFECT_WIPE_DIR_DOWN:
1483 h2 = (h * progress);
1484 evas_map_point_image_uv_set(map, 0, 0, h2);
1485 evas_map_point_image_uv_set(map, 1, w, h2);
1486 evas_map_point_image_uv_set(map, 2, w, h);
1487 evas_map_point_image_uv_set(map, 3, 0, h);
1488 evas_map_point_coord_set(map, 0, x, y + h2, 0);
1489 evas_map_point_coord_set(map, 1, w2, y + h2, 0);
1490 evas_map_point_coord_set(map, 2, w2, y + h, 0);
1491 evas_map_point_coord_set(map, 3, x, y + h, 0);
1496 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, _TRANSIT_FOCAL);
1500 _elm_fx_wipe_show(Evas_Map *map, Elm_Transit_Effect_Wipe_Dir dir, float x, float y, float w, float h, float progress)
1506 case ELM_TRANSIT_EFFECT_WIPE_DIR_LEFT:
1507 w2 = (w - (w * progress));
1509 evas_map_point_image_uv_set(map, 0, w2, 0);
1510 evas_map_point_image_uv_set(map, 1, w, 0);
1511 evas_map_point_image_uv_set(map, 2, w, h);
1512 evas_map_point_image_uv_set(map, 3, w2, h);
1513 evas_map_point_coord_set(map, 0, x + w2, y, 0);
1514 evas_map_point_coord_set(map, 1, w, y, 0);
1515 evas_map_point_coord_set(map, 2, w, h2, 0);
1516 evas_map_point_coord_set(map, 3, x + w2, h2, 0);
1518 case ELM_TRANSIT_EFFECT_WIPE_DIR_RIGHT:
1519 w2 = (w * progress);
1521 evas_map_point_image_uv_set(map, 0, 0, 0);
1522 evas_map_point_image_uv_set(map, 1, w2, 0);
1523 evas_map_point_image_uv_set(map, 2, w2, h);
1524 evas_map_point_image_uv_set(map, 3, 0, h);
1525 evas_map_point_coord_set(map, 0, x, y, 0);
1526 evas_map_point_coord_set(map, 1, x + w2, y, 0);
1527 evas_map_point_coord_set(map, 2, x + w2, h2, 0);
1528 evas_map_point_coord_set(map, 3, x, h2, 0);
1530 case ELM_TRANSIT_EFFECT_WIPE_DIR_UP:
1532 h2 = (h - (h * progress));
1533 evas_map_point_image_uv_set(map, 0, 0, h2);
1534 evas_map_point_image_uv_set(map, 1, w, h2);
1535 evas_map_point_image_uv_set(map, 2, w, h);
1536 evas_map_point_image_uv_set(map, 3, 0, h);
1537 evas_map_point_coord_set(map, 0, x, y + h2, 0);
1538 evas_map_point_coord_set(map, 1, w2, y + h2, 0);
1539 evas_map_point_coord_set(map, 2, w2, y + h, 0);
1540 evas_map_point_coord_set(map, 3, x, y + h, 0);
1542 case ELM_TRANSIT_EFFECT_WIPE_DIR_DOWN:
1544 h2 = (h * progress);
1545 evas_map_point_image_uv_set(map, 0, 0, 0);
1546 evas_map_point_image_uv_set(map, 1, w, 0);
1547 evas_map_point_image_uv_set(map, 2, w, h2);
1548 evas_map_point_image_uv_set(map, 3, 0, h2);
1549 evas_map_point_coord_set(map, 0, x, y, 0);
1550 evas_map_point_coord_set(map, 1, w2, y, 0);
1551 evas_map_point_coord_set(map, 2, w2, y + h2, 0);
1552 evas_map_point_coord_set(map, 3, x, y + h2, 0);
1557 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, _TRANSIT_FOCAL);
1561 _transit_effect_wipe_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit)
1563 EINA_SAFETY_ON_NULL_RETURN(effect);
1564 EINA_SAFETY_ON_NULL_RETURN(transit);
1567 Elm_Transit_Effect_Wipe *wipe = effect;
1568 Eina_Bool reverse = elm_transit_auto_reverse_get(transit);
1570 EINA_LIST_FOREACH(transit->objs, elist, obj)
1572 if ((wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_SHOW && !reverse)
1573 || (wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_HIDE && reverse))
1574 evas_object_show(obj);
1575 else evas_object_hide(obj);
1576 evas_object_map_enable_set(obj, EINA_FALSE);
1583 _transit_effect_wipe_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
1585 EINA_SAFETY_ON_NULL_RETURN(effect);
1586 EINA_SAFETY_ON_NULL_RETURN(transit);
1587 Elm_Transit_Effect_Wipe *wipe = effect;
1589 Evas_Coord _x, _y, _w, _h;
1593 map = evas_map_new(4);
1596 EINA_LIST_FOREACH(transit->objs, elist, obj)
1598 evas_object_geometry_get(obj, &_x, &_y, &_w, &_h);
1600 if (wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_SHOW)
1601 _elm_fx_wipe_show(map, wipe->dir, _x, _y, _w, _h, (float)progress);
1603 _elm_fx_wipe_hide(map, wipe->dir, _x, _y, _w, _h, (float)progress);
1605 evas_object_map_enable_set(obj, EINA_TRUE);
1606 evas_object_map_set(obj, map);
1611 static Elm_Transit_Effect *
1612 _transit_effect_wipe_context_new(Elm_Transit_Effect_Wipe_Type type, Elm_Transit_Effect_Wipe_Dir dir)
1614 Elm_Transit_Effect_Wipe *wipe;
1616 wipe = ELM_NEW(Elm_Transit_Effect_Wipe);
1617 if (!wipe) return NULL;
1626 elm_transit_effect_wipe_add(Elm_Transit *transit, Elm_Transit_Effect_Wipe_Type type, Elm_Transit_Effect_Wipe_Dir dir)
1628 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1629 void *effect = _transit_effect_wipe_context_new(type, dir);
1633 ERR("Failed to allocate wipe effect! : transit=%p", transit);
1636 elm_transit_effect_add(transit,
1637 _transit_effect_wipe_op, effect,
1638 _transit_effect_wipe_context_free);
1642 ///////////////////////////////////////////////////////////////////////////
1644 ///////////////////////////////////////////////////////////////////////////
1645 typedef struct _Elm_Transit_Effect_Color Elm_Transit_Effect_Color;
1647 struct _Elm_Transit_Effect_Color
1649 struct _unsigned_color {
1650 unsigned int r, g, b, a;
1652 struct _signed_color {
1658 _transit_effect_color_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
1660 Elm_Transit_Effect_Color *color = effect;
1665 _transit_effect_color_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
1667 EINA_SAFETY_ON_NULL_RETURN(effect);
1668 EINA_SAFETY_ON_NULL_RETURN(transit);
1669 Elm_Transit_Effect_Color *color = effect;
1672 unsigned int r, g, b, a;
1674 r = (color->from.r + (int)((float)color->to.r * progress));
1675 g = (color->from.g + (int)((float)color->to.g * progress));
1676 b = (color->from.b + (int)((float)color->to.b * progress));
1677 a = (color->from.a + (int)((float)color->to.a * progress));
1679 EINA_LIST_FOREACH(transit->objs, elist, obj)
1680 evas_object_color_set(obj, r, g, b, a);
1683 static Elm_Transit_Effect *
1684 _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)
1686 Elm_Transit_Effect_Color *color;
1688 color = ELM_NEW(Elm_Transit_Effect_Color);
1689 if (!color) return NULL;
1691 color->from.r = from_r;
1692 color->from.g = from_g;
1693 color->from.b = from_b;
1694 color->from.a = from_a;
1695 color->to.r = to_r - from_r;
1696 color->to.g = to_g - from_g;
1697 color->to.b = to_b - from_b;
1698 color->to.a = to_a - from_a;
1703 EAPI Elm_Transit_Effect *
1704 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)
1706 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1707 Elm_Transit_Effect *effect = _transit_effect_color_context_new(from_r, from_g, from_b, from_a, to_r, to_g, to_b, to_a);
1711 ERR("Failed to allocate color effect! : transit=%p", transit);
1714 elm_transit_effect_add(transit,
1715 _transit_effect_color_op, effect,
1716 _transit_effect_color_context_free);
1720 ///////////////////////////////////////////////////////////////////////////
1722 ///////////////////////////////////////////////////////////////////////////
1723 typedef struct _Elm_Transit_Effect_Fade Elm_Transit_Effect_Fade;
1724 typedef struct _Elm_Transit_Effect_Fade_Node Elm_Transit_Effect_Fade_Node;
1726 struct _Elm_Transit_Effect_Fade_Node
1728 Evas_Object *before;
1730 struct _signed_color before_color, after_color;
1733 Eina_Bool inversed : 1;
1736 struct _Elm_Transit_Effect_Fade
1742 _fade_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1744 Elm_Transit_Effect_Fade *fade = data;
1746 Elm_Transit_Effect_Fade_Node *fade_node;
1748 EINA_LIST_FOREACH(fade->nodes, elist, fade_node)
1750 if (fade_node->before == obj)
1751 evas_object_event_callback_del(fade_node->after,
1752 EVAS_CALLBACK_DEL, _fade_object_del_cb);
1753 else if (fade_node->after == obj)
1754 evas_object_event_callback_del(fade_node->before,
1755 EVAS_CALLBACK_DEL, _fade_object_del_cb);
1758 fade->nodes = eina_list_remove_list(fade->nodes, elist);
1765 _fade_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Fade *fade_data)
1767 Elm_Transit_Effect_Fade_Node *fade;
1768 Eina_List *data_list = NULL;
1771 count = eina_list_count(transit->objs);
1772 for (i = 0; i < count; i += 2)
1774 fade = ELM_NEW(Elm_Transit_Effect_Fade_Node);
1777 eina_list_free(data_list);
1781 fade->before = eina_list_nth(transit->objs, i);
1782 fade->after = eina_list_nth(transit->objs, i+1);
1784 evas_object_color_get(fade->before,
1785 &fade->before_color.r, &fade->before_color.g,
1786 &fade->before_color.b, &fade->before_color.a);
1787 evas_object_color_get(fade->after,
1788 &fade->after_color.r, &fade->after_color.g,
1789 &fade->after_color.b, &fade->after_color.a);
1791 fade->before_alpha = (255 - fade->before_color.a);
1792 fade->after_alpha = (255 - fade->after_color.a);
1794 data_list = eina_list_append(data_list, fade);
1796 evas_object_event_callback_add(fade->before,
1797 EVAS_CALLBACK_DEL, _fade_object_del_cb, fade_data);
1798 evas_object_event_callback_add(fade->after,
1799 EVAS_CALLBACK_DEL, _fade_object_del_cb, fade_data);
1805 _transit_effect_fade_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
1807 EINA_SAFETY_ON_NULL_RETURN(effect);
1808 Elm_Transit_Effect_Fade *fade = effect;
1809 Elm_Transit_Effect_Fade_Node *fade_node;
1810 Eina_List *elist, *elist_next;
1812 EINA_LIST_FOREACH_SAFE(fade->nodes, elist, elist_next, fade_node)
1814 evas_object_color_set(fade_node->before, fade_node->before_color.r,
1815 fade_node->before_color.g,
1816 fade_node->before_color.b,
1817 fade_node->before_color.a);
1818 evas_object_color_set(fade_node->after, fade_node->after_color.r,
1819 fade_node->after_color.g,
1820 fade_node->after_color.b,
1821 fade_node->after_color.a);
1823 fade->nodes = eina_list_remove_list(fade->nodes, elist);
1824 evas_object_event_callback_del(fade_node->before,
1825 EVAS_CALLBACK_DEL, _fade_object_del_cb);
1826 evas_object_event_callback_del(fade_node->after,
1827 EVAS_CALLBACK_DEL, _fade_object_del_cb);
1835 _transit_effect_fade_op(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__, double progress)
1837 EINA_SAFETY_ON_NULL_RETURN(effect);
1838 Elm_Transit_Effect_Fade *fade = effect;
1840 Elm_Transit_Effect_Fade_Node *fade_node;
1844 fade->nodes = _fade_nodes_build(transit, fade);
1846 EINA_LIST_FOREACH(fade->nodes, elist, fade_node)
1850 if (!fade_node->inversed)
1852 evas_object_hide(fade_node->after);
1853 evas_object_show(fade_node->before);
1854 fade_node->inversed = EINA_TRUE;
1857 _progress = (1 - (progress * 2));
1859 evas_object_color_set(fade_node->before,
1860 fade_node->before_color.r * _progress,
1861 fade_node->before_color.g * _progress,
1862 fade_node->before_color.b * _progress,
1863 fade_node->before_color.a +
1864 fade_node->before_alpha * (1 - _progress));
1868 if (fade_node->inversed)
1870 evas_object_hide(fade_node->before);
1871 evas_object_show(fade_node->after);
1872 fade_node->inversed = EINA_FALSE;
1875 _progress = ((progress - 0.5) * 2);
1877 evas_object_color_set(fade_node->after,
1878 fade_node->after_color.r * _progress,
1879 fade_node->after_color.g * _progress,
1880 fade_node->after_color.b * _progress,
1881 fade_node->after_color.a +
1882 fade_node->after_alpha * (1 - _progress));
1887 static Elm_Transit_Effect *
1888 _transit_effect_fade_context_new(void)
1890 Elm_Transit_Effect_Fade *fade;
1891 fade = ELM_NEW(Elm_Transit_Effect_Fade);
1892 if (!fade) return NULL;
1896 EAPI Elm_Transit_Effect *
1897 elm_transit_effect_fade_add(Elm_Transit *transit)
1899 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1901 Elm_Transit_Effect *effect = _transit_effect_fade_context_new();
1905 ERR("Failed to allocate fade effect! : transit=%p", transit);
1908 elm_transit_effect_add(transit,
1909 _transit_effect_fade_op, effect,
1910 _transit_effect_fade_context_free);
1914 ///////////////////////////////////////////////////////////////////////////
1916 ///////////////////////////////////////////////////////////////////////////
1917 typedef struct _Elm_Transit_Effect_Blend Elm_Transit_Effect_Blend;
1918 typedef struct _Elm_Transit_Effect_Blend_Node Elm_Transit_Effect_Blend_Node;
1920 struct _Elm_Transit_Effect_Blend_Node
1922 Evas_Object *before;
1924 struct _signed_color from, to;
1927 struct _Elm_Transit_Effect_Blend
1933 _blend_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1935 Elm_Transit_Effect_Blend *blend = data;
1937 Elm_Transit_Effect_Blend_Node *blend_node;
1939 EINA_LIST_FOREACH(blend->nodes, elist, blend_node)
1941 if (blend_node->after == obj)
1942 evas_object_event_callback_del(blend_node->before,
1943 EVAS_CALLBACK_DEL, _blend_object_del_cb);
1944 else if (blend_node->before == obj)
1945 evas_object_event_callback_del(blend_node->after,
1946 EVAS_CALLBACK_DEL, _blend_object_del_cb);
1949 blend->nodes = eina_list_remove_list(blend->nodes, elist);
1956 _blend_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Blend *blend)
1958 Elm_Transit_Effect_Blend_Node *blend_node;
1959 Eina_List *data_list = NULL;
1962 count = eina_list_count(transit->objs);
1963 for (i = 0; i < (count - 1); i += 2)
1965 blend_node = ELM_NEW(Elm_Transit_Effect_Blend_Node);
1968 eina_list_free(data_list);
1972 blend_node->before = eina_list_nth(transit->objs, i);
1973 blend_node->after = eina_list_nth(transit->objs, i + 1);
1974 evas_object_show(blend_node->before);
1975 evas_object_show(blend_node->after);
1977 evas_object_color_get(blend_node->before, &blend_node->from.r,
1978 &blend_node->from.g, &blend_node->from.b,
1979 &blend_node->from.a);
1980 evas_object_color_get(blend_node->after, &blend_node->to.r,
1981 &blend_node->to.g, &blend_node->to.b,
1984 data_list = eina_list_append(data_list, blend_node);
1986 evas_object_event_callback_add(blend_node->before,
1987 EVAS_CALLBACK_DEL, _blend_object_del_cb, blend);
1988 evas_object_event_callback_add(blend_node->after,
1989 EVAS_CALLBACK_DEL, _blend_object_del_cb, blend);
1995 _transit_effect_blend_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
1997 EINA_SAFETY_ON_NULL_RETURN(effect);
1998 Elm_Transit_Effect_Blend *blend = effect;
1999 Elm_Transit_Effect_Blend_Node *blend_node;
2000 Eina_List *elist, *elist_next;
2002 EINA_LIST_FOREACH_SAFE(blend->nodes, elist, elist_next, blend_node)
2004 evas_object_color_set(blend_node->before,
2005 blend_node->from.r, blend_node->from.g,
2006 blend_node->from.b, blend_node->from.a);
2007 evas_object_color_set(blend_node->after, blend_node->to.r,
2008 blend_node->to.g, blend_node->to.b,
2011 if (elm_transit_auto_reverse_get(transit))
2012 evas_object_hide(blend_node->after);
2014 evas_object_hide(blend_node->before);
2016 blend->nodes = eina_list_remove_list(blend->nodes, elist);
2018 evas_object_event_callback_del(blend_node->before,
2019 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2020 evas_object_event_callback_del(blend_node->after,
2021 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2028 _transit_effect_blend_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2030 EINA_SAFETY_ON_NULL_RETURN(effect);
2031 EINA_SAFETY_ON_NULL_RETURN(transit);
2032 Elm_Transit_Effect_Blend *blend = effect;
2033 Elm_Transit_Effect_Blend_Node *blend_node;
2036 if (!blend->nodes) blend->nodes = _blend_nodes_build(transit, blend);
2038 EINA_LIST_FOREACH(blend->nodes, elist, blend_node)
2040 evas_object_color_set(blend_node->before,
2041 (int)(blend_node->from.r * (1 - progress)),
2042 (int)(blend_node->from.g * (1 - progress)),
2043 (int)(blend_node->from.b * (1 - progress)),
2044 (int)(blend_node->from.a * (1 - progress)));
2045 evas_object_color_set(blend_node->after,
2046 (int)(blend_node->to.r * progress),
2047 (int)(blend_node->to.g * progress),
2048 (int)(blend_node->to.b * progress),
2049 (int)(blend_node->to.a * progress));
2053 static Elm_Transit_Effect *
2054 _transit_effect_blend_context_new(void)
2056 Elm_Transit_Effect_Blend *blend;
2058 blend = ELM_NEW(Elm_Transit_Effect_Blend);
2059 if (!blend) return NULL;
2063 EAPI Elm_Transit_Effect *
2064 elm_transit_effect_blend_add(Elm_Transit *transit)
2066 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2067 Elm_Transit_Effect *effect = _transit_effect_blend_context_new();
2071 ERR("Failed to allocate blend effect! : transit=%p", transit);
2074 elm_transit_effect_add(transit,
2075 _transit_effect_blend_op, effect,
2076 _transit_effect_blend_context_free);
2080 ///////////////////////////////////////////////////////////////////////////
2082 ///////////////////////////////////////////////////////////////////////////
2083 typedef struct _Elm_Transit_Effect_Rotation Elm_Transit_Effect_Rotation;
2085 struct _Elm_Transit_Effect_Rotation
2091 _transit_effect_rotation_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
2093 Elm_Transit_Effect_Rotation *rotation = effect;
2098 _transit_effect_rotation_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2100 EINA_SAFETY_ON_NULL_RETURN(effect);
2101 EINA_SAFETY_ON_NULL_RETURN(transit);
2102 Elm_Transit_Effect_Rotation *rotation = effect;
2104 Evas_Coord x, y, w, h;
2106 float half_w, half_h;
2110 map = evas_map_new(4);
2113 EINA_LIST_FOREACH(transit->objs, elist, obj)
2115 evas_map_util_points_populate_from_object_full(map, obj, 0);
2116 degree = rotation->from + (float)(progress * rotation->to);
2118 evas_object_geometry_get(obj, &x, &y, &w, &h);
2120 half_w = (float)w * 0.5;
2121 half_h = (float)h * 0.5;
2123 evas_map_util_rotate(map, degree, x + half_w, y + half_h);
2124 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, _TRANSIT_FOCAL);
2125 evas_object_map_enable_set(obj, EINA_TRUE);
2126 evas_object_map_set(obj, map);
2131 static Elm_Transit_Effect *
2132 _transit_effect_rotation_context_new(float from_degree, float to_degree)
2134 Elm_Transit_Effect_Rotation *rotation;
2136 rotation = ELM_NEW(Elm_Transit_Effect_Rotation);
2137 if (!rotation) return NULL;
2139 rotation->from = from_degree;
2140 rotation->to = to_degree - from_degree;
2145 EAPI Elm_Transit_Effect *
2146 elm_transit_effect_rotation_add(Elm_Transit *transit, float from_degree, float to_degree)
2148 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2149 Elm_Transit_Effect *effect = _transit_effect_rotation_context_new(from_degree, to_degree);
2153 ERR("Failed to allocate rotation effect! : transit=%p", transit);
2156 elm_transit_effect_add(transit,
2157 _transit_effect_rotation_op, effect,
2158 _transit_effect_rotation_context_free);
2162 ///////////////////////////////////////////////////////////////////////////
2163 //ImageAnimation Effect
2164 ///////////////////////////////////////////////////////////////////////////
2165 typedef struct _Elm_Transit_Effect_Image_Animation Elm_Transit_Effect_Image_Animation;
2167 struct _Elm_Transit_Effect_Image_Animation
2173 _transit_effect_image_animation_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
2175 EINA_SAFETY_ON_NULL_RETURN(effect);
2176 Elm_Transit_Effect_Image_Animation *image_animation = effect;
2178 Eina_List *elist, *elist_next;
2180 EINA_LIST_FOREACH_SAFE(image_animation->images, elist, elist_next, image)
2182 image_animation->images =
2183 eina_list_remove_list(image_animation->images, elist);
2184 eina_stringshare_del(image);
2187 free(image_animation);
2191 _transit_effect_image_animation_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2193 EINA_SAFETY_ON_NULL_RETURN(effect);
2194 EINA_SAFETY_ON_NULL_RETURN(transit);
2198 Elm_Transit_Effect_Image_Animation *image_animation = effect;
2199 unsigned int count = 0;
2202 type = eina_stringshare_add("icon");
2203 len = eina_list_count(image_animation->images);
2205 if (!len) count = floor(progress * len);
2206 else count = floor(progress * (len - 1));
2208 EINA_LIST_FOREACH(transit->objs, elist, obj)
2210 if (elm_widget_type_check(obj, type))
2211 elm_icon_file_set(obj,
2212 eina_list_nth(image_animation->images, count), NULL);
2215 eina_stringshare_del(type);
2218 static Elm_Transit_Effect *
2219 _transit_effect_image_animation_context_new(Eina_List *images)
2221 Elm_Transit_Effect_Image_Animation *image_animation;
2222 image_animation = ELM_NEW(Elm_Transit_Effect_Image_Animation);
2224 if (!image_animation) return NULL;
2225 image_animation->images = images;
2226 return image_animation;
2229 EAPI Elm_Transit_Effect *
2230 elm_transit_effect_image_animation_add(Elm_Transit *transit, Eina_List *images)
2232 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2233 Elm_Transit_Effect *effect = _transit_effect_image_animation_context_new(images);
2237 ERR("Failed to allocate image_animation effect! : transit=%p", transit);
2240 elm_transit_effect_add(transit,
2241 _transit_effect_image_animation_op, effect,
2242 _transit_effect_image_animation_context_free);