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_transits_get(const Elm_Transit * transit)
698 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
699 return transit->next_chain_transits;
702 ///////////////////////////////////////////////////////////////////////////////
704 ///////////////////////////////////////////////////////////////////////////////
705 typedef struct _Elm_Transit_Effect_Resizing Elm_Transit_Effect_Resizing;
707 struct _Elm_Transit_Effect_Resizing
715 _transit_effect_resizing_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
717 Elm_Transit_Effect_Resizing *resizing = effect;
722 _transit_effect_resizing_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
724 EINA_SAFETY_ON_NULL_RETURN(effect);
725 EINA_SAFETY_ON_NULL_RETURN(transit);
729 Elm_Transit_Effect_Resizing *resizing = effect;
731 w = resizing->from.w + (resizing->to.w * progress);
732 h = resizing->from.h + (resizing->to.h * progress);
734 EINA_LIST_FOREACH(transit->objs, elist, obj)
735 evas_object_resize(obj, w, h);
738 static Elm_Transit_Effect *
739 _transit_effect_resizing_context_new(Evas_Coord from_w, Evas_Coord from_h, Evas_Coord to_w, Evas_Coord to_h)
741 Elm_Transit_Effect_Resizing *resizing;
743 resizing = ELM_NEW(Elm_Transit_Effect_Resizing);
744 if (!resizing) return NULL;
746 resizing->from.w = from_w;
747 resizing->from.h = from_h;
748 resizing->to.w = to_w - from_w;
749 resizing->to.h = to_h - from_h;
754 EAPI Elm_Transit_Effect *
755 elm_transit_effect_resizing_add(Elm_Transit *transit, Evas_Coord from_w, Evas_Coord from_h, Evas_Coord to_w, Evas_Coord to_h)
757 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
758 Elm_Transit_Effect *effect = _transit_effect_resizing_context_new(from_w, from_h, to_w, to_h);
762 ERR("Failed to allocate resizing effect! : transit=%p", transit);
765 elm_transit_effect_add(transit,
766 _transit_effect_resizing_op, effect,
767 _transit_effect_resizing_context_free);
771 ///////////////////////////////////////////////////////////////////////////////
773 ///////////////////////////////////////////////////////////////////////////////
774 typedef struct _Elm_Transit_Effect_Translation Elm_Transit_Effect_Translation;
775 typedef struct _Elm_Transit_Effect_Translation_Node Elm_Transit_Effect_Translation_Node;
777 struct _Elm_Transit_Effect_Translation_Node
783 struct _Elm_Transit_Effect_Translation
785 struct _position_variation {
792 _translation_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
794 Elm_Transit_Effect_Translation *translation = data;
796 Elm_Transit_Effect_Translation_Node *translation_node;
798 EINA_LIST_FOREACH(translation->nodes, elist, translation_node)
800 if (translation_node->obj != obj) continue;
801 translation->nodes = eina_list_remove_list(translation->nodes, elist);
802 free(translation_node);
808 _translation_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Translation *translation)
810 Elm_Transit_Effect_Translation_Node *translation_node;
811 const Eina_List *elist;
813 Eina_List *data_list = NULL;
814 const Eina_List *objs = elm_transit_objects_get(transit);
816 EINA_LIST_FOREACH(objs, elist, obj)
818 translation_node = ELM_NEW(Elm_Transit_Effect_Translation_Node);
819 if (!translation_node)
821 eina_list_free(data_list);
824 translation_node->obj = obj;
825 evas_object_geometry_get(obj, &(translation_node->x),
826 &(translation_node->y), NULL, NULL);
827 data_list = eina_list_append(data_list, translation_node);
828 evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
829 _translation_object_del_cb, translation);
835 _transit_effect_translation_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
837 EINA_SAFETY_ON_NULL_RETURN(effect);
838 Elm_Transit_Effect_Translation *translation = effect;
839 Eina_List *elist, *elist_next;
840 Elm_Transit_Effect_Translation_Node *translation_node;
842 EINA_LIST_FOREACH_SAFE(translation->nodes,
843 elist, elist_next, translation_node)
845 evas_object_event_callback_del(translation_node->obj,
846 EVAS_CALLBACK_DEL, _translation_object_del_cb);
847 translation->nodes = eina_list_remove_list(translation->nodes, elist);
848 free(translation_node);
854 _transit_effect_translation_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress __UNUSED__)
856 EINA_SAFETY_ON_NULL_RETURN(effect);
857 EINA_SAFETY_ON_NULL_RETURN(transit);
859 Elm_Transit_Effect_Translation *translation = effect;
860 Elm_Transit_Effect_Translation_Node *translation_node;
863 if (!translation->nodes)
864 translation->nodes = _translation_nodes_build(transit, translation);
866 EINA_LIST_FOREACH(translation->nodes, elist, translation_node)
868 x = translation_node->x + translation->from.dx
869 + (translation->to.dx * progress);
870 y = translation_node->y + translation->from.dy
871 + (translation->to.dy * progress);
872 evas_object_move(translation_node->obj, x, y);
876 static Elm_Transit_Effect *
877 _transit_effect_translation_context_new(Evas_Coord from_dx, Evas_Coord from_dy, Evas_Coord to_dx, Evas_Coord to_dy)
879 Elm_Transit_Effect_Translation *translation;
881 translation = ELM_NEW(Elm_Transit_Effect_Translation);
882 if (!translation) return NULL;
884 translation->from.dx = from_dx;
885 translation->from.dy = from_dy;
886 translation->to.dx = to_dx - from_dx;
887 translation->to.dy = to_dy - from_dy;
892 EAPI Elm_Transit_Effect *
893 elm_transit_effect_translation_add(Elm_Transit *transit, Evas_Coord from_dx, Evas_Coord from_dy, Evas_Coord to_dx, Evas_Coord to_dy)
895 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
896 Elm_Transit_Effect *effect_context = _transit_effect_translation_context_new(from_dx, from_dy, to_dx, to_dy);
900 ERR("Failed to allocate translation effect! : transit=%p", transit);
903 elm_transit_effect_add(transit,
904 _transit_effect_translation_op, effect_context,
905 _transit_effect_translation_context_free);
906 return effect_context;
910 ///////////////////////////////////////////////////////////////////////////////
912 ///////////////////////////////////////////////////////////////////////////////
913 typedef struct _Elm_Transit_Effect_Zoom Elm_Transit_Effect_Zoom;
915 struct _Elm_Transit_Effect_Zoom
921 _transit_effect_zoom_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
923 Elm_Transit_Effect_Zoom *zoom = effect;
928 _transit_effect_zoom_op(Elm_Transit_Effect *effect, Elm_Transit *transit , double progress)
930 EINA_SAFETY_ON_NULL_RETURN(effect);
931 EINA_SAFETY_ON_NULL_RETURN(transit);
934 Elm_Transit_Effect_Zoom *zoom = effect;
936 Evas_Coord x, y, w, h;
938 map = evas_map_new(4);
941 EINA_LIST_FOREACH(transit->objs, elist, obj)
943 evas_object_geometry_get(obj, &x, &y, &w, &h);
944 evas_map_util_points_populate_from_object_full(map, obj, zoom->from +
945 (progress * zoom->to));
946 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, _TRANSIT_FOCAL);
947 evas_object_map_set(obj, map);
948 evas_object_map_enable_set(obj, EINA_TRUE);
953 static Elm_Transit_Effect *
954 _transit_effect_zoom_context_new(float from_rate, float to_rate)
956 Elm_Transit_Effect_Zoom *zoom;
958 zoom = ELM_NEW(Elm_Transit_Effect_Zoom);
959 if (!zoom) return NULL;
961 zoom->from = (_TRANSIT_FOCAL - (from_rate * _TRANSIT_FOCAL)) * (1 / from_rate);
962 zoom->to = ((_TRANSIT_FOCAL - (to_rate * _TRANSIT_FOCAL)) * (1 / to_rate)) - zoom->from;
967 EAPI Elm_Transit_Effect *
968 elm_transit_effect_zoom_add(Elm_Transit *transit, float from_rate, float to_rate)
970 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
971 Elm_Transit_Effect *effect_context = _transit_effect_zoom_context_new(from_rate, to_rate);
975 ERR("Failed to allocate zoom effect! : transit=%p", transit);
978 elm_transit_effect_add(transit,
979 _transit_effect_zoom_op, effect_context,
980 _transit_effect_zoom_context_free);
981 return effect_context;
985 ///////////////////////////////////////////////////////////////////////////////
987 ///////////////////////////////////////////////////////////////////////////////
988 typedef struct _Elm_Transit_Effect_Flip Elm_Transit_Effect_Flip;
990 struct _Elm_Transit_Effect_Flip
992 Elm_Transit_Effect_Flip_Axis axis;
997 _transit_effect_flip_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit)
999 EINA_SAFETY_ON_NULL_RETURN(effect);
1000 EINA_SAFETY_ON_NULL_RETURN(transit);
1001 Elm_Transit_Effect_Flip *flip = effect;
1002 Evas_Object *front, *back;
1004 int count = eina_list_count(transit->objs);
1006 for (i = 0; i < (count - 1); i += 2)
1008 front = eina_list_nth(transit->objs, i);
1009 back = eina_list_nth(transit->objs, i+1);
1010 evas_object_map_enable_set(front, EINA_FALSE);
1011 evas_object_map_enable_set(back, EINA_FALSE);
1017 _transit_effect_flip_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
1019 EINA_SAFETY_ON_NULL_RETURN(effect);
1020 EINA_SAFETY_ON_NULL_RETURN(transit);
1021 Evas_Object *obj, *front, *back;
1023 Elm_Transit_Effect_Flip *flip = effect;
1026 Evas_Coord x, y, w, h;
1028 map = evas_map_new(4);
1031 if (flip->cw) degree = (float)(progress * 180);
1032 else degree = (float)(progress * -180);
1034 count = eina_list_count(transit->objs);
1036 for (i = 0; i < (count - 1); i += 2)
1038 Evas_Coord half_w, half_h;
1040 front = eina_list_nth(transit->objs, i);
1041 back = eina_list_nth(transit->objs, i+1);
1043 if ((degree < 90) && (degree > -90))
1048 evas_object_hide(back);
1049 evas_object_show(front);
1057 evas_object_hide(front);
1058 evas_object_show(back);
1062 evas_map_util_points_populate_from_object_full(map, obj, 0);
1063 evas_object_geometry_get(obj, &x, &y, &w, &h);
1067 if (flip->axis == ELM_TRANSIT_EFFECT_FLIP_AXIS_Y)
1069 if ((degree >= 90) || (degree <= -90))
1071 evas_map_point_image_uv_set(map, 0, w, 0);
1072 evas_map_point_image_uv_set(map, 1, 0, 0);
1073 evas_map_point_image_uv_set(map, 2, 0, h);
1074 evas_map_point_image_uv_set(map, 3, w, h);
1076 evas_map_util_3d_rotate(map, 0, degree,
1077 0, x + half_w, y + half_h, 0);
1081 if ((degree >= 90) || (degree <= -90))
1083 evas_map_point_image_uv_set(map, 0, 0, h);
1084 evas_map_point_image_uv_set(map, 1, w, h);
1085 evas_map_point_image_uv_set(map, 2, w, 0);
1086 evas_map_point_image_uv_set(map, 3, 0, 0);
1088 evas_map_util_3d_rotate(map, degree,
1089 0, 0, x + half_w, y + half_h, 0);
1091 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, _TRANSIT_FOCAL);
1092 evas_object_map_enable_set(front, EINA_TRUE);
1093 evas_object_map_enable_set(back, EINA_TRUE);
1094 evas_object_map_set(obj, map);
1099 static Elm_Transit_Effect *
1100 _transit_effect_flip_context_new(Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1102 Elm_Transit_Effect_Flip *flip;
1104 flip = ELM_NEW(Elm_Transit_Effect_Flip);
1105 if (!flip) return NULL;
1113 EAPI Elm_Transit_Effect *
1114 elm_transit_effect_flip_add(Elm_Transit *transit, Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1116 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1117 Elm_Transit_Effect *effect_context = _transit_effect_flip_context_new(axis, cw);
1119 if (!effect_context)
1121 ERR("Failed to allocate flip effect! : transit=%p", transit);
1124 elm_transit_effect_add(transit,
1125 _transit_effect_flip_op, effect_context,
1126 _transit_effect_flip_context_free);
1127 return effect_context;
1130 ///////////////////////////////////////////////////////////////////////////////
1131 //ResizableFlip Effect
1132 ///////////////////////////////////////////////////////////////////////////////
1133 typedef struct _Elm_Transit_Effect_Resizable_Flip Elm_Transit_Effect_ResizableFlip;
1134 typedef struct _Elm_Transit_Effect_Resizable_Flip_Node Elm_Transit_Effect_ResizableFlip_Node;
1136 struct _Elm_Transit_Effect_Resizable_Flip_Node
1142 } from_pos, from_size, to_pos, to_size;
1145 struct _Elm_Transit_Effect_Resizable_Flip
1149 Elm_Transit_Effect_Flip_Axis axis;
1153 _resizable_flip_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1155 Elm_Transit_Effect_ResizableFlip *resizable_flip = data;
1157 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1159 EINA_LIST_FOREACH(resizable_flip->nodes, elist, resizable_flip_node)
1161 if (resizable_flip_node->front == obj)
1162 evas_object_event_callback_del(resizable_flip_node->back,
1163 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1164 else if (resizable_flip_node->back == obj)
1165 evas_object_event_callback_del(resizable_flip_node->front,
1166 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1169 resizable_flip->nodes = eina_list_remove_list(resizable_flip->nodes,
1171 free(resizable_flip_node);
1177 _resizable_flip_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_ResizableFlip *resizable_flip)
1179 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1180 Eina_List *data_list = NULL;
1181 Evas_Coord front_x, front_y, front_w, front_h;
1182 Evas_Coord back_x, back_y, back_w, back_h;
1185 count = eina_list_count(transit->objs);
1186 for (i = 0; i < (count - 1); i += 2)
1188 resizable_flip_node = ELM_NEW(Elm_Transit_Effect_ResizableFlip_Node);
1189 if (!resizable_flip_node)
1191 eina_list_free(data_list);
1195 resizable_flip_node->front = eina_list_nth(transit->objs, i);
1196 resizable_flip_node->back = eina_list_nth(transit->objs, i+1);
1198 evas_object_geometry_get(resizable_flip_node->front,
1199 &front_x, &front_y, &front_w, &front_h);
1200 evas_object_geometry_get(resizable_flip_node->back,
1201 &back_x, &back_y, &back_w, &back_h);
1203 resizable_flip_node->from_pos.x = front_x;
1204 resizable_flip_node->from_pos.y = front_y;
1205 resizable_flip_node->to_pos.x = back_x - front_x;
1206 resizable_flip_node->to_pos.y = back_y - front_y;
1208 resizable_flip_node->from_size.x = front_w;
1209 resizable_flip_node->from_size.y = front_h;
1210 resizable_flip_node->to_size.x = back_w - front_w;
1211 resizable_flip_node->to_size.y = back_h - front_h;
1213 data_list = eina_list_append(data_list, resizable_flip_node);
1215 evas_object_event_callback_add(resizable_flip_node->back,
1216 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb, resizable_flip);
1217 evas_object_event_callback_add(resizable_flip_node->front,
1218 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb, resizable_flip);
1225 _set_image_uv_by_axis_y(Evas_Map *map, Elm_Transit_Effect_ResizableFlip_Node *flip, float degree)
1227 if ((degree >= 90) || (degree <= -90))
1229 evas_map_point_image_uv_set(map, 0,
1230 (flip->from_size.x * 2) + flip->to_size.x,
1232 evas_map_point_image_uv_set(map, 1, 0, 0);
1233 evas_map_point_image_uv_set(map, 2, 0,
1234 (flip->from_size.y * 2) + flip->to_size.y);
1235 evas_map_point_image_uv_set(map, 3,
1236 (flip->from_size.x * 2) + flip->to_size.x,
1237 (flip->from_size.y * 2) + flip->to_size.y);
1241 evas_map_point_image_uv_set(map, 0, 0, 0);
1242 evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
1243 evas_map_point_image_uv_set(map, 2, flip->from_size.x,
1245 evas_map_point_image_uv_set(map, 3, 0, flip->from_size.y);
1250 _set_image_uv_by_axis_x(Evas_Map *map, Elm_Transit_Effect_ResizableFlip_Node *flip, float degree)
1252 if ((degree >= 90) || (degree <= -90))
1254 evas_map_point_image_uv_set(map, 0, 0,
1255 (flip->from_size.y * 2) + flip->to_size.y);
1256 evas_map_point_image_uv_set(map, 1,
1257 (flip->from_size.x * 2) + flip->to_size.x,
1258 (flip->from_size.y * 2) + flip->to_size.y);
1259 evas_map_point_image_uv_set(map, 2,
1260 (flip->from_size.x * 2) + flip->to_size.x,
1262 evas_map_point_image_uv_set(map, 3, 0, 0);
1266 evas_map_point_image_uv_set(map, 0, 0, 0);
1267 evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
1268 evas_map_point_image_uv_set(map, 2, flip->from_size.x,
1270 evas_map_point_image_uv_set(map, 3, 0, flip->from_size.y);
1275 _transit_effect_resizable_flip_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
1277 EINA_SAFETY_ON_NULL_RETURN(effect);
1279 Elm_Transit_Effect_ResizableFlip *resizable_flip = effect;
1280 Eina_List *elist, *elist_next;
1281 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1283 EINA_LIST_FOREACH_SAFE(resizable_flip->nodes,
1284 elist, elist_next, resizable_flip_node)
1286 evas_object_map_enable_set(resizable_flip_node->front, EINA_FALSE);
1287 evas_object_map_enable_set(resizable_flip_node->back, EINA_FALSE);
1289 resizable_flip->nodes = eina_list_remove_list(resizable_flip->nodes,
1292 evas_object_event_callback_del(resizable_flip_node->back,
1293 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1294 evas_object_event_callback_del(resizable_flip_node->front,
1295 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1296 free(resizable_flip_node);
1298 free(resizable_flip);
1302 _transit_effect_resizable_flip_op(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__, double progress)
1304 EINA_SAFETY_ON_NULL_RETURN(effect);
1309 Evas_Coord half_w, half_h;
1310 Elm_Transit_Effect_ResizableFlip *resizable_flip = effect;
1311 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1314 map = evas_map_new(4);
1317 if (resizable_flip->cw) degree = (float)(progress * 180);
1318 else degree = (float)(progress * -180);
1320 if (!resizable_flip->nodes)
1321 resizable_flip->nodes = _resizable_flip_nodes_build(transit,
1324 EINA_LIST_FOREACH(resizable_flip->nodes, elist, resizable_flip_node)
1326 if ((degree < 90) && (degree > -90))
1328 obj = resizable_flip_node->front;
1329 if (resizable_flip_node->front != resizable_flip_node->back)
1331 evas_object_hide(resizable_flip_node->back);
1332 evas_object_show(resizable_flip_node->front);
1337 obj = resizable_flip_node->back;
1338 if (resizable_flip_node->front != resizable_flip_node->back)
1340 evas_object_hide(resizable_flip_node->front);
1341 evas_object_show(resizable_flip_node->back);
1345 x = resizable_flip_node->from_pos.x +
1346 (resizable_flip_node->to_pos.x * progress);
1347 y = resizable_flip_node->from_pos.y +
1348 (resizable_flip_node->to_pos.y * progress);
1349 w = resizable_flip_node->from_size.x +
1350 (resizable_flip_node->to_size.x * progress);
1351 h = resizable_flip_node->from_size.y +
1352 (resizable_flip_node->to_size.y * progress);
1353 evas_map_point_coord_set(map, 0, x, y, 0);
1354 evas_map_point_coord_set(map, 1, x + w, y, 0);
1355 evas_map_point_coord_set(map, 2, x + w, y + h, 0);
1356 evas_map_point_coord_set(map, 3, x, y + h, 0);
1358 half_w = (Evas_Coord)(w / 2);
1359 half_h = (Evas_Coord)(h / 2);
1361 if (resizable_flip->axis == ELM_TRANSIT_EFFECT_FLIP_AXIS_Y)
1363 _set_image_uv_by_axis_y(map, resizable_flip_node, degree);
1364 evas_map_util_3d_rotate(map, 0, degree,
1365 0, x + half_w, y + half_h, 0);
1369 _set_image_uv_by_axis_x(map, resizable_flip_node, degree);
1370 evas_map_util_3d_rotate(map, degree, 0,
1371 0, x + half_w, y + half_h, 0);
1374 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, _TRANSIT_FOCAL);
1375 evas_object_map_enable_set(resizable_flip_node->front, EINA_TRUE);
1376 evas_object_map_enable_set(resizable_flip_node->back, EINA_TRUE);
1377 evas_object_map_set(obj, map);
1382 static Elm_Transit_Effect *
1383 _transit_effect_resizable_flip_context_new(Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1385 Elm_Transit_Effect_ResizableFlip *resizable_flip;
1387 resizable_flip = ELM_NEW(Elm_Transit_Effect_ResizableFlip);
1388 if (!resizable_flip) return NULL;
1390 resizable_flip->cw = cw;
1391 resizable_flip->axis = axis;
1393 return resizable_flip;
1396 EAPI Elm_Transit_Effect *
1397 elm_transit_effect_resizable_flip_add(Elm_Transit *transit, Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1399 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1400 Elm_Transit_Effect *effect_context = _transit_effect_resizable_flip_context_new(axis, cw);
1402 if (!effect_context)
1404 ERR("Failed to allocate resizable_flip effect! : transit=%p", transit);
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)
1620 ERR("Failed to allocate wipe effect! : transit=%p", transit);
1623 elm_transit_effect_add(transit,
1624 _transit_effect_wipe_op, effect_context,
1625 _transit_effect_wipe_context_free);
1626 return effect_context;
1630 ///////////////////////////////////////////////////////////////////////////////
1632 ///////////////////////////////////////////////////////////////////////////////
1633 typedef struct _Elm_Transit_Effect_Color Elm_Transit_Effect_Color;
1635 struct _Elm_Transit_Effect_Color
1637 struct _unsigned_color {
1638 unsigned int r, g, b, a;
1640 struct _signed_color {
1646 _transit_effect_color_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
1648 Elm_Transit_Effect_Color *color = effect;
1653 _transit_effect_color_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
1655 EINA_SAFETY_ON_NULL_RETURN(effect);
1656 EINA_SAFETY_ON_NULL_RETURN(transit);
1657 Elm_Transit_Effect_Color *color = effect;
1660 unsigned int r, g, b, a;
1662 r = (color->from.r + (int)((float)color->to.r * progress));
1663 g = (color->from.g + (int)((float)color->to.g * progress));
1664 b = (color->from.b + (int)((float)color->to.b * progress));
1665 a = (color->from.a + (int)((float)color->to.a * progress));
1667 EINA_LIST_FOREACH(transit->objs, elist, obj)
1668 evas_object_color_set(obj, r, g, b, a);
1671 static Elm_Transit_Effect *
1672 _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)
1674 Elm_Transit_Effect_Color *color;
1676 color = ELM_NEW(Elm_Transit_Effect_Color);
1677 if (!color) return NULL;
1679 color->from.r = from_r;
1680 color->from.g = from_g;
1681 color->from.b = from_b;
1682 color->from.a = from_a;
1683 color->to.r = to_r - from_r;
1684 color->to.g = to_g - from_g;
1685 color->to.b = to_b - from_b;
1686 color->to.a = to_a - from_a;
1691 EAPI Elm_Transit_Effect *
1692 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)
1694 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1695 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);
1697 if (!effect_context)
1699 ERR("Failed to allocate color effect! : transit=%p", transit);
1702 elm_transit_effect_add(transit,
1703 _transit_effect_color_op, effect_context,
1704 _transit_effect_color_context_free);
1705 return effect_context;
1708 ///////////////////////////////////////////////////////////////////////////////
1710 ///////////////////////////////////////////////////////////////////////////////
1711 typedef struct _Elm_Transit_Effect_Fade Elm_Transit_Effect_Fade;
1712 typedef struct _Elm_Transit_Effect_Fade_Node Elm_Transit_Effect_Fade_Node;
1714 struct _Elm_Transit_Effect_Fade_Node
1716 Evas_Object *before;
1718 struct _signed_color before_color, after_color;
1721 Eina_Bool inversed : 1;
1724 struct _Elm_Transit_Effect_Fade
1730 _fade_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1732 Elm_Transit_Effect_Fade *fade = data;
1734 Elm_Transit_Effect_Fade_Node *fade_node;
1736 EINA_LIST_FOREACH(fade->nodes, elist, fade_node)
1738 if (fade_node->before == obj)
1739 evas_object_event_callback_del(fade_node->after,
1740 EVAS_CALLBACK_DEL, _fade_object_del_cb);
1741 else if (fade_node->after == obj)
1742 evas_object_event_callback_del(fade_node->before,
1743 EVAS_CALLBACK_DEL, _fade_object_del_cb);
1746 fade->nodes = eina_list_remove_list(fade->nodes, elist);
1753 _fade_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Fade *fade_data)
1755 Elm_Transit_Effect_Fade_Node *fade;
1756 Eina_List *data_list = NULL;
1759 count = eina_list_count(transit->objs);
1760 for (i = 0; i < count; i += 2)
1762 fade = ELM_NEW(Elm_Transit_Effect_Fade_Node);
1765 eina_list_free(data_list);
1769 fade->before = eina_list_nth(transit->objs, i);
1770 fade->after = eina_list_nth(transit->objs, i+1);
1772 evas_object_color_get(fade->before,
1773 &fade->before_color.r, &fade->before_color.g,
1774 &fade->before_color.b, &fade->before_color.a);
1775 evas_object_color_get(fade->after,
1776 &fade->after_color.r, &fade->after_color.g,
1777 &fade->after_color.b, &fade->after_color.a);
1779 fade->before_alpha = (255 - fade->before_color.a);
1780 fade->after_alpha = (255 - fade->after_color.a);
1782 data_list = eina_list_append(data_list, fade);
1784 evas_object_event_callback_add(fade->before,
1785 EVAS_CALLBACK_DEL, _fade_object_del_cb, fade_data);
1786 evas_object_event_callback_add(fade->after,
1787 EVAS_CALLBACK_DEL, _fade_object_del_cb, fade_data);
1793 _transit_effect_fade_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
1795 EINA_SAFETY_ON_NULL_RETURN(effect);
1796 Elm_Transit_Effect_Fade *fade = effect;
1797 Elm_Transit_Effect_Fade_Node *fade_node;
1798 Eina_List *elist, *elist_next;
1800 EINA_LIST_FOREACH_SAFE(fade->nodes, elist, elist_next, fade_node)
1802 evas_object_color_set(fade_node->before, fade_node->before_color.r,
1803 fade_node->before_color.g,
1804 fade_node->before_color.b,
1805 fade_node->before_color.a);
1806 evas_object_color_set(fade_node->after, fade_node->after_color.r,
1807 fade_node->after_color.g,
1808 fade_node->after_color.b,
1809 fade_node->after_color.a);
1811 fade->nodes = eina_list_remove_list(fade->nodes, elist);
1812 evas_object_event_callback_del(fade_node->before,
1813 EVAS_CALLBACK_DEL, _fade_object_del_cb);
1814 evas_object_event_callback_del(fade_node->after,
1815 EVAS_CALLBACK_DEL, _fade_object_del_cb);
1823 _transit_effect_fade_op(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__, double progress)
1825 EINA_SAFETY_ON_NULL_RETURN(effect);
1826 Elm_Transit_Effect_Fade *fade = effect;
1828 Elm_Transit_Effect_Fade_Node *fade_node;
1832 fade->nodes = _fade_nodes_build(transit, fade);
1834 EINA_LIST_FOREACH(fade->nodes, elist, fade_node)
1838 if (!fade_node->inversed)
1840 evas_object_hide(fade_node->after);
1841 evas_object_show(fade_node->before);
1842 fade_node->inversed = EINA_TRUE;
1845 _progress = (1 - (progress * 2));
1847 evas_object_color_set(fade_node->before,
1848 fade_node->before_color.r * _progress,
1849 fade_node->before_color.g * _progress,
1850 fade_node->before_color.b * _progress,
1851 fade_node->before_color.a +
1852 fade_node->before_alpha * (1 - _progress));
1856 if (fade_node->inversed)
1858 evas_object_hide(fade_node->before);
1859 evas_object_show(fade_node->after);
1860 fade_node->inversed = EINA_FALSE;
1863 _progress = ((progress - 0.5) * 2);
1865 evas_object_color_set(fade_node->after,
1866 fade_node->after_color.r * _progress,
1867 fade_node->after_color.g * _progress,
1868 fade_node->after_color.b * _progress,
1869 fade_node->after_color.a +
1870 fade_node->after_alpha * (1 - _progress));
1875 static Elm_Transit_Effect *
1876 _transit_effect_fade_context_new(void)
1878 Elm_Transit_Effect_Fade *fade;
1879 fade = ELM_NEW(Elm_Transit_Effect_Fade);
1880 if (!fade) return NULL;
1884 EAPI Elm_Transit_Effect *
1885 elm_transit_effect_fade_add(Elm_Transit *transit)
1887 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1889 Elm_Transit_Effect *effect_context = _transit_effect_fade_context_new();
1891 if (!effect_context)
1893 ERR("Failed to allocate fade effect! : transit=%p", transit);
1896 elm_transit_effect_add(transit,
1897 _transit_effect_fade_op, effect_context,
1898 _transit_effect_fade_context_free);
1899 return effect_context;
1903 ///////////////////////////////////////////////////////////////////////////////
1905 ///////////////////////////////////////////////////////////////////////////////
1906 typedef struct _Elm_Transit_Effect_Blend Elm_Transit_Effect_Blend;
1907 typedef struct _Elm_Transit_Effect_Blend_Node Elm_Transit_Effect_Blend_Node;
1909 struct _Elm_Transit_Effect_Blend_Node
1911 Evas_Object *before;
1913 struct _signed_color from, to;
1916 struct _Elm_Transit_Effect_Blend
1922 _blend_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1924 Elm_Transit_Effect_Blend *blend = data;
1926 Elm_Transit_Effect_Blend_Node *blend_node;
1928 EINA_LIST_FOREACH(blend->nodes, elist, blend_node)
1930 if (blend_node->after == obj)
1931 evas_object_event_callback_del(blend_node->before,
1932 EVAS_CALLBACK_DEL, _blend_object_del_cb);
1933 else if (blend_node->before == obj)
1934 evas_object_event_callback_del(blend_node->after,
1935 EVAS_CALLBACK_DEL, _blend_object_del_cb);
1938 blend->nodes = eina_list_remove_list(blend->nodes, elist);
1945 _blend_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Blend *blend)
1947 Elm_Transit_Effect_Blend_Node *blend_node;
1948 Eina_List *data_list = NULL;
1951 count = eina_list_count(transit->objs);
1952 for (i = 0; i < (count - 1); i += 2)
1954 blend_node = ELM_NEW(Elm_Transit_Effect_Blend_Node);
1957 eina_list_free(data_list);
1961 blend_node->before = eina_list_nth(transit->objs, i);
1962 blend_node->after = eina_list_nth(transit->objs, i + 1);
1963 evas_object_show(blend_node->before);
1964 evas_object_show(blend_node->after);
1966 evas_object_color_get(blend_node->before, &blend_node->from.r,
1967 &blend_node->from.g, &blend_node->from.b,
1968 &blend_node->from.a);
1969 evas_object_color_get(blend_node->after, &blend_node->to.r,
1970 &blend_node->to.g, &blend_node->to.b,
1973 data_list = eina_list_append(data_list, blend_node);
1975 evas_object_event_callback_add(blend_node->before,
1976 EVAS_CALLBACK_DEL, _blend_object_del_cb, blend);
1977 evas_object_event_callback_add(blend_node->after,
1978 EVAS_CALLBACK_DEL, _blend_object_del_cb, blend);
1984 _transit_effect_blend_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
1986 EINA_SAFETY_ON_NULL_RETURN(effect);
1987 Elm_Transit_Effect_Blend *blend = effect;
1988 Elm_Transit_Effect_Blend_Node *blend_node;
1989 Eina_List *elist, *elist_next;
1991 EINA_LIST_FOREACH_SAFE(blend->nodes, elist, elist_next, blend_node)
1993 evas_object_color_set(blend_node->before,
1994 blend_node->from.r, blend_node->from.g,
1995 blend_node->from.b, blend_node->from.a);
1996 evas_object_color_set(blend_node->after, blend_node->to.r,
1997 blend_node->to.g, blend_node->to.b,
2000 if (elm_transit_auto_reverse_get(transit))
2001 evas_object_hide(blend_node->after);
2003 evas_object_hide(blend_node->before);
2005 blend->nodes = eina_list_remove_list(blend->nodes, elist);
2007 evas_object_event_callback_del(blend_node->before,
2008 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2009 evas_object_event_callback_del(blend_node->after,
2010 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2017 _transit_effect_blend_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2019 EINA_SAFETY_ON_NULL_RETURN(effect);
2020 EINA_SAFETY_ON_NULL_RETURN(transit);
2021 Elm_Transit_Effect_Blend *blend = effect;
2022 Elm_Transit_Effect_Blend_Node *blend_node;
2025 if (!blend->nodes) blend->nodes = _blend_nodes_build(transit, blend);
2027 EINA_LIST_FOREACH(blend->nodes, elist, blend_node)
2029 evas_object_color_set(blend_node->before,
2030 (int)(blend_node->from.r * (1 - progress)),
2031 (int)(blend_node->from.g * (1 - progress)),
2032 (int)(blend_node->from.b * (1 - progress)),
2033 (int)(blend_node->from.a * (1 - progress)));
2034 evas_object_color_set(blend_node->after,
2035 (int)(blend_node->to.r * progress),
2036 (int)(blend_node->to.g * progress),
2037 (int)(blend_node->to.b * progress),
2038 (int)(blend_node->to.a * progress));
2042 static Elm_Transit_Effect *
2043 _transit_effect_blend_context_new(void)
2045 Elm_Transit_Effect_Blend *blend;
2047 blend = ELM_NEW(Elm_Transit_Effect_Blend);
2048 if (!blend) return NULL;
2052 EAPI Elm_Transit_Effect *
2053 elm_transit_effect_blend_add(Elm_Transit *transit)
2055 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2056 Elm_Transit_Effect *effect_context = _transit_effect_blend_context_new();
2058 if (!effect_context) return NULL;
2059 elm_transit_effect_add(transit,
2060 _transit_effect_blend_op, effect_context,
2061 _transit_effect_blend_context_free);
2062 return effect_context;
2066 ///////////////////////////////////////////////////////////////////////////////
2068 ///////////////////////////////////////////////////////////////////////////////
2069 typedef struct _Elm_Transit_Effect_Rotation Elm_Transit_Effect_Rotation;
2071 struct _Elm_Transit_Effect_Rotation
2077 _transit_effect_rotation_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
2079 Elm_Transit_Effect_Rotation *rotation = effect;
2084 _transit_effect_rotation_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2086 EINA_SAFETY_ON_NULL_RETURN(effect);
2087 EINA_SAFETY_ON_NULL_RETURN(transit);
2088 Elm_Transit_Effect_Rotation *rotation = effect;
2090 Evas_Coord x, y, w, h;
2092 float half_w, half_h;
2096 map = evas_map_new(4);
2099 EINA_LIST_FOREACH(transit->objs, elist, obj)
2101 evas_map_util_points_populate_from_object_full(map, obj, 0);
2102 degree = rotation->from + (float)(progress * rotation->to);
2104 evas_object_geometry_get(obj, &x, &y, &w, &h);
2106 half_w = (float)w * 0.5;
2107 half_h = (float)h * 0.5;
2109 evas_map_util_rotate(map, degree, x + half_w, y + half_h);
2110 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, _TRANSIT_FOCAL);
2111 evas_object_map_enable_set(obj, EINA_TRUE);
2112 evas_object_map_set(obj, map);
2117 static Elm_Transit_Effect *
2118 _transit_effect_rotation_context_new(float from_degree, float to_degree)
2120 Elm_Transit_Effect_Rotation *rotation;
2122 rotation = ELM_NEW(Elm_Transit_Effect_Rotation);
2123 if (!rotation) return NULL;
2125 rotation->from = from_degree;
2126 rotation->to = to_degree - from_degree;
2131 EAPI Elm_Transit_Effect *
2132 elm_transit_effect_rotation_add(Elm_Transit *transit, float from_degree, float to_degree)
2134 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2135 Elm_Transit_Effect *effect_context = _transit_effect_rotation_context_new(from_degree, to_degree);
2137 if (!effect_context) return NULL;
2138 elm_transit_effect_add(transit,
2139 _transit_effect_rotation_op, effect_context,
2140 _transit_effect_rotation_context_free);
2141 return effect_context;
2145 ///////////////////////////////////////////////////////////////////////////////
2146 //ImageAnimation Effect
2147 ///////////////////////////////////////////////////////////////////////////////
2148 typedef struct _Elm_Transit_Effect_Image_Animation Elm_Transit_Effect_Image_Animation;
2150 struct _Elm_Transit_Effect_Image_Animation
2156 _transit_effect_image_animation_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
2158 EINA_SAFETY_ON_NULL_RETURN(effect);
2159 Elm_Transit_Effect_Image_Animation *image_animation = effect;
2161 Eina_List *elist, *elist_next;
2163 EINA_LIST_FOREACH_SAFE(image_animation->images, elist, elist_next, image)
2165 image_animation->images =
2166 eina_list_remove_list(image_animation->images, elist);
2167 eina_stringshare_del(image);
2170 free(image_animation);
2174 _transit_effect_image_animation_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2176 EINA_SAFETY_ON_NULL_RETURN(effect);
2177 EINA_SAFETY_ON_NULL_RETURN(transit);
2181 Elm_Transit_Effect_Image_Animation *image_animation = effect;
2182 unsigned int count = 0;
2185 type = eina_stringshare_add("icon");
2186 len = eina_list_count(image_animation->images);
2188 if (!len) count = floor(progress * len);
2189 else count = floor(progress * (len - 1));
2191 EINA_LIST_FOREACH(transit->objs, elist, obj)
2193 if (elm_widget_type_check(obj, type))
2194 elm_icon_file_set(obj,
2195 eina_list_nth(image_animation->images, count), NULL);
2198 eina_stringshare_del(type);
2201 static Elm_Transit_Effect *
2202 _transit_effect_image_animation_context_new(Eina_List *images)
2204 Elm_Transit_Effect_Image_Animation *image_animation;
2205 image_animation = ELM_NEW(Elm_Transit_Effect_Image_Animation);
2207 if (!image_animation) return NULL;
2208 image_animation->images = images;
2209 return image_animation;
2212 EAPI Elm_Transit_Effect *
2213 elm_transit_effect_image_animation_add(Elm_Transit *transit, Eina_List *images)
2215 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2216 Elm_Transit_Effect *effect = _transit_effect_image_animation_context_new(images);
2220 ERR("Failed to allocate image_animation effect! : transit=%p", transit);
2223 elm_transit_effect_add(transit,
2224 _transit_effect_image_animation_op, effect,
2225 _transit_effect_image_animation_context_free);