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_Del_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;
57 Eina_Bool finished : 1;
60 struct _Elm_Transit_Effect_Module
63 Elm_Transit_Effect_Transition_Cb transition_cb;
64 Elm_Transit_Effect_End_Cb end_cb;
65 Elm_Transit_Effect *effect;
66 Eina_Bool deleted : 1;
69 struct _Elm_Transit_Obj_State
71 Evas_Coord x, y, w, h;
74 Eina_Bool map_enabled : 1;
75 Eina_Bool visible : 1;
78 struct _Elm_Transit_Obj_Data
80 struct _Elm_Transit_Obj_State *state;
81 Eina_Bool freeze_events : 1;
84 typedef struct _Elm_Transit_Effect_Module Elm_Transit_Effect_Module;
85 typedef struct _Elm_Transit_Obj_Data Elm_Transit_Obj_Data;
86 typedef struct _Elm_Transit_Obj_State Elm_Transit_Obj_State;
88 static void _transit_obj_data_update(Elm_Transit *transit, Evas_Object *obj);
89 static void _transit_obj_data_recover(Elm_Transit *transit, Evas_Object *obj);
90 static void _transit_obj_states_save(Evas_Object *obj, Elm_Transit_Obj_Data *obj_data);
91 static void _transit_obj_remove_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__);
92 static void _transit_obj_remove(Elm_Transit *transit, Evas_Object *obj);
93 static void _transit_effect_del(Elm_Transit *transit, Elm_Transit_Effect_Module *effect_module);
94 static void _transit_remove_dead_effects(Elm_Transit *transit);
95 static void _transit_chain_go(Elm_Transit *transit);
96 static void _transit_del(Elm_Transit *transit);
97 static Eina_Bool _transit_animate_op(Elm_Transit *transit, double progress);
98 static Eina_Bool _transit_animate_cb(void *data);
100 static char *_transit_key= "_elm_transit_key";
103 _transit_obj_data_update(Elm_Transit *transit, Evas_Object *obj)
105 Elm_Transit_Obj_Data *obj_data = evas_object_data_get(obj, _transit_key);
108 obj_data = ELM_NEW(Elm_Transit_Obj_Data);
110 obj_data->freeze_events = evas_object_freeze_events_get(obj);
112 if ((!transit->state_keep) && (obj_data->state))
114 free(obj_data->state);
115 obj_data->state = NULL;
119 _transit_obj_states_save(obj, obj_data);
122 evas_object_data_set(obj, _transit_key, obj_data);
126 _transit_obj_states_save(Evas_Object *obj, Elm_Transit_Obj_Data *obj_data)
128 Elm_Transit_Obj_State *state = obj_data->state;
131 state = calloc(1, sizeof(Elm_Transit_Obj_State));
134 evas_object_geometry_get(obj, &state->x, &state->y, &state->w, &state->h);
135 evas_object_color_get(obj, &state->r, &state->g, &state->b, &state->a);
136 state->visible = evas_object_visible_get(obj);
137 state->map_enabled = evas_object_map_enable_get(obj);
138 if (evas_object_map_get(obj))
139 state->map = evas_map_dup(evas_object_map_get(obj));
140 obj_data->state = state;
144 _remove_obj_from_list(Elm_Transit *transit, Evas_Object *obj)
146 //Remove duplicated objects
147 //TODO: Need to consider about optimizing here
150 if (!eina_list_data_find_list(transit->objs, obj))
152 transit->objs = eina_list_remove(transit->objs, obj);
153 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_DEL,
154 _transit_obj_remove_cb,
160 _transit_obj_remove_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
162 Elm_Transit *transit = data;
163 Elm_Transit_Obj_Data *obj_data = evas_object_data_get(obj, _transit_key);
167 free(obj_data->state);
170 _remove_obj_from_list(transit, obj);
171 if (!transit->objs) elm_transit_del(transit);
175 _transit_obj_data_recover(Elm_Transit *transit, Evas_Object *obj)
177 Elm_Transit_Obj_Data *obj_data;
178 Elm_Transit_Obj_State *state;
180 obj_data = evas_object_data_get(obj, _transit_key);
181 if (!obj_data) return;
182 evas_object_data_del(obj, _transit_key);
183 evas_object_freeze_events_set(obj, obj_data->freeze_events);
184 state = obj_data->state;
187 //recover the states of the object.
188 if (!transit->state_keep)
190 evas_object_move(obj, state->x, state->y);
191 evas_object_resize(obj, state->w, state->h);
192 evas_object_color_set(obj, state->r, state->g, state->b, state->a);
193 if (state->visible) evas_object_show(obj);
194 else evas_object_hide(obj);
195 if (state->map_enabled)
196 evas_object_map_enable_set(obj, EINA_TRUE);
198 evas_object_map_enable_set(obj, EINA_FALSE);
200 evas_object_map_set(obj, state->map);
208 _transit_obj_remove(Elm_Transit *transit, Evas_Object *obj)
210 _remove_obj_from_list(transit, obj);
211 _transit_obj_data_recover(transit, obj);
215 _transit_effect_del(Elm_Transit *transit, Elm_Transit_Effect_Module *effect_module)
217 if (effect_module->end_cb)
218 effect_module->end_cb(effect_module->effect, transit);
223 _transit_remove_dead_effects(Elm_Transit *transit)
225 Elm_Transit_Effect_Module *effect_module;
227 EINA_INLIST_FOREACH(transit->effect_list, effect_module)
229 if (effect_module->deleted)
231 _transit_effect_del(transit, effect_module);
232 transit->effects_pending_del--;
233 if (!transit->effects_pending_del) return;
239 _transit_chain_go(Elm_Transit *transit)
241 ELM_TRANSIT_CHECK_OR_RETURN(transit);
242 elm_transit_go(transit);
243 _transit_animate_cb(transit);
247 _transit_del(Elm_Transit *transit)
249 Elm_Transit_Effect_Module *effect_module;
250 Elm_Transit *chain_transit;
251 Eina_List *elist, *elist_next;
253 if (transit->animator)
254 ecore_animator_del(transit->animator);
257 while (transit->effect_list)
259 effect_module = EINA_INLIST_CONTAINER_GET(transit->effect_list, Elm_Transit_Effect_Module);
260 transit->effect_list = eina_inlist_remove(transit->effect_list, transit->effect_list);
261 _transit_effect_del(transit, effect_module);
265 while (transit->objs)
266 _transit_obj_remove(transit, eina_list_data_get(transit->objs));
268 transit->deleted = EINA_TRUE;
270 if (transit->del_data.func)
271 transit->del_data.func(transit->del_data.arg, transit);
273 //cut off the chain transit relationship
274 EINA_LIST_FOREACH_SAFE(transit->next_chain_transits, elist, elist_next, chain_transit)
275 chain_transit->prev_chain_transit = NULL;
277 if (transit->prev_chain_transit)
278 transit->prev_chain_transit->next_chain_transits =
279 eina_list_remove(transit->prev_chain_transit->next_chain_transits, transit);
281 // run chain transits
282 if (transit->finished && transit->next_chain_transits)
284 EINA_LIST_FOREACH_SAFE(transit->next_chain_transits, elist, elist_next, chain_transit)
285 _transit_chain_go(chain_transit);
289 eina_list_free(transit->next_chain_transits);
291 EINA_MAGIC_SET(transit, EINA_MAGIC_NONE);
295 //If the transit is deleted then EINA_FALSE is retruned.
297 _transit_animate_op(Elm_Transit *transit, double progress)
299 Elm_Transit_Effect_Module *effect_module;
302 EINA_INLIST_FOREACH(transit->effect_list, effect_module)
304 if (transit->deleted) break;
305 if (!effect_module->deleted)
306 effect_module->transition_cb(effect_module->effect, transit, progress);
310 if (transit->walking) return EINA_TRUE;
312 if (transit->deleted)
314 _transit_del(transit);
318 else if (transit->effects_pending_del) _transit_remove_dead_effects(transit);
324 _transit_animate_cb(void *data)
326 Elm_Transit *transit = data;
327 double elapsed_time, duration;
329 transit->time.current = ecore_loop_time_get();
330 elapsed_time = transit->time.current - transit->time.begin;
331 duration = transit->time.duration + transit->time.delayed;
333 if (elapsed_time > duration)
334 elapsed_time = duration;
336 transit->progress = elapsed_time / duration;
337 switch (transit->tween_mode)
339 case ELM_TRANSIT_TWEEN_MODE_ACCELERATE:
340 transit->progress = 1.0 - sin((ELM_PI / 2.0) + (transit->progress * ELM_PI / 2.0));
342 case ELM_TRANSIT_TWEEN_MODE_DECELERATE:
343 transit->progress = sin(transit->progress * ELM_PI / 2.0);
345 case ELM_TRANSIT_TWEEN_MODE_SINUSOIDAL:
346 transit->progress = (1.0 - cos(transit->progress * ELM_PI)) / 2.0;
353 if (transit->repeat.reverse) transit->progress = 1 - transit->progress;
355 if (transit->time.duration > 0)
357 if (!_transit_animate_op(transit, transit->progress))
358 return ECORE_CALLBACK_CANCEL;
361 /* Not end. Keep going. */
362 if (elapsed_time < duration) return ECORE_CALLBACK_RENEW;
364 /* Repeat and reverse and time done! */
365 if ((transit->repeat.count >= 0) &&
366 (transit->repeat.current == transit->repeat.count) &&
367 ((!transit->auto_reverse) || transit->repeat.reverse))
369 transit->finished = EINA_TRUE;
370 elm_transit_del(transit);
371 return ECORE_CALLBACK_CANCEL;
375 if (!transit->auto_reverse || transit->repeat.reverse)
377 transit->repeat.current++;
378 transit->repeat.reverse = EINA_FALSE;
380 else transit->repeat.reverse = EINA_TRUE;
382 transit->time.begin = ecore_loop_time_get();
384 return ECORE_CALLBACK_RENEW;
388 elm_transit_add(void)
390 Elm_Transit *transit = ELM_NEW(Elm_Transit);
393 ERR("Failed to allocate a elm_transit object!");
397 EINA_MAGIC_SET(transit, ELM_TRANSIT_MAGIC);
399 elm_transit_tween_mode_set(transit, ELM_TRANSIT_TWEEN_MODE_LINEAR);
405 elm_transit_del(Elm_Transit *transit)
407 ELM_TRANSIT_CHECK_OR_RETURN(transit);
409 if (transit->walking) transit->deleted = EINA_TRUE;
410 else _transit_del(transit);
414 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)
416 ELM_TRANSIT_CHECK_OR_RETURN(transit);
417 EINA_SAFETY_ON_NULL_RETURN(transition_cb);
418 Elm_Transit_Effect_Module *effect_module;
420 EINA_INLIST_FOREACH(transit->effect_list, effect_module)
421 if ((effect_module->transition_cb == transition_cb) && (effect_module->effect == effect))
423 WRN("elm_transit does not allow to add the duplicated effect! : transit=%p", transit);
427 effect_module = ELM_NEW(Elm_Transit_Effect_Module);
430 ERR("Failed to allocate a new effect!: transit=%p", transit);
434 effect_module->end_cb = end_cb;
435 effect_module->transition_cb = transition_cb;
436 effect_module->effect = effect;
438 transit->effect_list = eina_inlist_append(transit->effect_list, (Eina_Inlist*) effect_module);
442 elm_transit_effect_del(Elm_Transit *transit, Elm_Transit_Effect_Transition_Cb transition_cb, Elm_Transit_Effect *effect)
444 ELM_TRANSIT_CHECK_OR_RETURN(transit);
445 EINA_SAFETY_ON_NULL_RETURN(transition_cb);
446 Elm_Transit_Effect_Module *effect_module;
448 EINA_INLIST_FOREACH(transit->effect_list, effect_module)
450 if ((effect_module->transition_cb == transition_cb) && (effect_module->effect == effect))
452 if (transit->walking)
454 effect_module->deleted = EINA_TRUE;
455 transit->effects_pending_del++;
459 _transit_effect_del(transit, effect_module);
460 if (!transit->effect_list) elm_transit_del(transit);
468 elm_transit_object_add(Elm_Transit *transit, Evas_Object *obj)
470 ELM_TRANSIT_CHECK_OR_RETURN(transit);
471 EINA_SAFETY_ON_NULL_RETURN(obj);
473 if (transit->animator)
475 if (!evas_object_data_get(obj, _transit_key))
477 _transit_obj_data_update(transit, obj);
478 evas_object_freeze_events_set(obj, EINA_TRUE);
482 evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
483 _transit_obj_remove_cb,
486 transit->objs = eina_list_append(transit->objs, obj);
490 elm_transit_object_remove(Elm_Transit *transit, Evas_Object *obj)
492 ELM_TRANSIT_CHECK_OR_RETURN(transit);
493 EINA_SAFETY_ON_NULL_RETURN(obj);
495 _transit_obj_remove(transit, obj);
496 if (!transit->objs) elm_transit_del(transit);
499 EAPI const Eina_List *
500 elm_transit_objects_get(const Elm_Transit *transit)
502 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
503 return transit->objs;
507 elm_transit_event_enabled_set(Elm_Transit *transit, Eina_Bool enabled)
509 ELM_TRANSIT_CHECK_OR_RETURN(transit);
514 if (transit->event_enabled == enabled) return;
515 transit->event_enabled = !!enabled;
516 if (!transit->animator) return;
518 EINA_LIST_FOREACH(transit->objs, list, obj)
519 evas_object_freeze_events_set(obj, enabled);
523 elm_transit_event_enabled_get(const Elm_Transit *transit)
525 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
526 return transit->event_enabled;
530 elm_transit_del_cb_set(Elm_Transit *transit, void (*cb) (void *data, Elm_Transit *transit), void *data)
532 ELM_TRANSIT_CHECK_OR_RETURN(transit);
533 transit->del_data.func = cb;
534 transit->del_data.arg = data;
538 elm_transit_auto_reverse_set(Elm_Transit *transit, Eina_Bool reverse)
540 ELM_TRANSIT_CHECK_OR_RETURN(transit);
541 transit->auto_reverse = reverse;
545 elm_transit_auto_reverse_get(const Elm_Transit *transit)
547 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
548 return transit->auto_reverse;
552 elm_transit_repeat_times_set(Elm_Transit *transit, int repeat)
554 ELM_TRANSIT_CHECK_OR_RETURN(transit);
555 transit->repeat.count = repeat;
556 transit->repeat.current = 0;
560 elm_transit_repeat_times_get(const Elm_Transit *transit)
562 ELM_TRANSIT_CHECK_OR_RETURN(transit, 0);
563 return transit->repeat.count;
567 elm_transit_tween_mode_set(Elm_Transit *transit, Elm_Transit_Tween_Mode tween_mode)
569 ELM_TRANSIT_CHECK_OR_RETURN(transit);
570 transit->tween_mode = tween_mode;
573 EAPI Elm_Transit_Tween_Mode
574 elm_transit_tween_mode_get(const Elm_Transit *transit)
576 ELM_TRANSIT_CHECK_OR_RETURN(transit, ELM_TRANSIT_TWEEN_MODE_LINEAR);
577 return transit->tween_mode;
581 elm_transit_duration_set(Elm_Transit *transit, double duration)
583 ELM_TRANSIT_CHECK_OR_RETURN(transit);
584 if (transit->animator)
586 WRN("elm_transit does not allow to set the duration time in operating! : transit=%p", transit);
589 transit->time.duration = duration;
593 elm_transit_duration_get(const Elm_Transit *transit)
595 ELM_TRANSIT_CHECK_OR_RETURN(transit, 0.0);
596 return transit->time.duration;
600 elm_transit_go(Elm_Transit *transit)
602 ELM_TRANSIT_CHECK_OR_RETURN(transit);
607 if (transit->animator)
608 ecore_animator_del(transit->animator);
610 EINA_LIST_FOREACH(transit->objs, elist, obj)
611 _transit_obj_data_update(transit, obj);
613 if (!transit->event_enabled)
615 EINA_LIST_FOREACH(transit->objs, elist, obj)
616 evas_object_freeze_events_set(obj, EINA_TRUE);
619 transit->time.paused = 0;
620 transit->time.delayed = 0;
621 transit->time.begin = ecore_loop_time_get();
622 transit->animator = ecore_animator_add(_transit_animate_cb, transit);
626 elm_transit_paused_set(Elm_Transit *transit, Eina_Bool paused)
628 ELM_TRANSIT_CHECK_OR_RETURN(transit);
630 if (!transit->animator) return;
634 if (transit->time.paused > 0)
636 ecore_animator_freeze(transit->animator);
637 transit->time.paused = ecore_loop_time_get();
641 if (transit->time.paused == 0)
643 ecore_animator_thaw(transit->animator);
644 transit->time.delayed += (ecore_loop_time_get() - transit->time.paused);
645 transit->time.paused = 0;
650 elm_transit_paused_get(const Elm_Transit *transit)
652 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
654 if (transit->time.paused == 0)
661 elm_transit_progress_value_get(const Elm_Transit *transit)
663 ELM_TRANSIT_CHECK_OR_RETURN(transit, 0);
665 return transit->progress;
669 elm_transit_objects_final_state_keep_set(Elm_Transit *transit, Eina_Bool state_keep)
671 ELM_TRANSIT_CHECK_OR_RETURN(transit);
673 if (transit->state_keep == state_keep) return;
674 if (transit->animator)
676 WRN("elm_transit does not allow to change final state keep mode in operating! : transit=%p", transit);
679 transit->state_keep = !!state_keep;
683 elm_transit_objects_final_state_keep_get(const Elm_Transit *transit)
685 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
686 return transit->state_keep;
690 elm_transit_chain_transit_add(Elm_Transit *transit, Elm_Transit *chain_transit)
692 ELM_TRANSIT_CHECK_OR_RETURN(transit);
693 ELM_TRANSIT_CHECK_OR_RETURN(chain_transit);
695 if (transit == chain_transit)
697 WRN("You add a same transit as a chain transit! : transit=%p, chain_transit=%p", transit, chain_transit);
700 if (transit == chain_transit->prev_chain_transit)
703 if (chain_transit->prev_chain_transit)
704 chain_transit->prev_chain_transit->next_chain_transits = eina_list_remove(chain_transit->prev_chain_transit->next_chain_transits, chain_transit);
706 chain_transit->prev_chain_transit = transit;
707 transit->next_chain_transits = eina_list_append(transit->next_chain_transits, chain_transit);
711 elm_transit_chain_transit_del(Elm_Transit *transit, Elm_Transit *chain_transit)
713 ELM_TRANSIT_CHECK_OR_RETURN(transit);
714 ELM_TRANSIT_CHECK_OR_RETURN(chain_transit);
716 if (chain_transit->prev_chain_transit != transit)
718 WRN("A pair of transits does not have the chain relationship! : transit=%p, chain_transit=%p", transit, chain_transit);
722 chain_transit->prev_chain_transit = NULL;
723 transit->next_chain_transits = eina_list_remove(transit->next_chain_transits, chain_transit);
727 elm_transit_chain_transits_get(const Elm_Transit * transit)
729 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
730 return transit->next_chain_transits;
733 ///////////////////////////////////////////////////////////////////////////
735 ///////////////////////////////////////////////////////////////////////////
736 typedef struct _Elm_Transit_Effect_Resizing Elm_Transit_Effect_Resizing;
738 struct _Elm_Transit_Effect_Resizing
746 _transit_effect_resizing_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
748 Elm_Transit_Effect_Resizing *resizing = effect;
753 _transit_effect_resizing_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
755 EINA_SAFETY_ON_NULL_RETURN(effect);
756 EINA_SAFETY_ON_NULL_RETURN(transit);
760 Elm_Transit_Effect_Resizing *resizing = effect;
762 w = resizing->from.w + (resizing->to.w * progress);
763 h = resizing->from.h + (resizing->to.h * progress);
765 EINA_LIST_FOREACH(transit->objs, elist, obj)
766 evas_object_resize(obj, w, h);
769 static Elm_Transit_Effect *
770 _transit_effect_resizing_context_new(Evas_Coord from_w, Evas_Coord from_h, Evas_Coord to_w, Evas_Coord to_h)
772 Elm_Transit_Effect_Resizing *resizing;
774 resizing = ELM_NEW(Elm_Transit_Effect_Resizing);
775 if (!resizing) return NULL;
777 resizing->from.w = from_w;
778 resizing->from.h = from_h;
779 resizing->to.w = to_w - from_w;
780 resizing->to.h = to_h - from_h;
785 EAPI Elm_Transit_Effect *
786 elm_transit_effect_resizing_add(Elm_Transit *transit, Evas_Coord from_w, Evas_Coord from_h, Evas_Coord to_w, Evas_Coord to_h)
788 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
789 Elm_Transit_Effect *effect = _transit_effect_resizing_context_new(from_w, from_h, to_w, to_h);
793 ERR("Failed to allocate resizing effect! : transit=%p", transit);
796 elm_transit_effect_add(transit,
797 _transit_effect_resizing_op, effect,
798 _transit_effect_resizing_context_free);
802 ///////////////////////////////////////////////////////////////////////////
804 ///////////////////////////////////////////////////////////////////////////
805 typedef struct _Elm_Transit_Effect_Translation Elm_Transit_Effect_Translation;
806 typedef struct _Elm_Transit_Effect_Translation_Node Elm_Transit_Effect_Translation_Node;
808 struct _Elm_Transit_Effect_Translation_Node
814 struct _Elm_Transit_Effect_Translation
816 struct _position_variation {
823 _translation_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
825 Elm_Transit_Effect_Translation *translation = data;
827 Elm_Transit_Effect_Translation_Node *translation_node;
829 EINA_LIST_FOREACH(translation->nodes, elist, translation_node)
831 if (translation_node->obj != obj) continue;
832 translation->nodes = eina_list_remove_list(translation->nodes, elist);
833 free(translation_node);
839 _translation_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Translation *translation)
841 Elm_Transit_Effect_Translation_Node *translation_node;
842 const Eina_List *elist;
844 Eina_List *data_list = NULL;
845 const Eina_List *objs = elm_transit_objects_get(transit);
847 EINA_LIST_FOREACH(objs, elist, obj)
849 translation_node = ELM_NEW(Elm_Transit_Effect_Translation_Node);
850 if (!translation_node)
852 eina_list_free(data_list);
855 translation_node->obj = obj;
856 evas_object_geometry_get(obj, &(translation_node->x),
857 &(translation_node->y), NULL, NULL);
858 data_list = eina_list_append(data_list, translation_node);
859 evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
860 _translation_object_del_cb, translation);
866 _transit_effect_translation_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
868 EINA_SAFETY_ON_NULL_RETURN(effect);
869 Elm_Transit_Effect_Translation *translation = effect;
870 Eina_List *elist, *elist_next;
871 Elm_Transit_Effect_Translation_Node *translation_node;
873 EINA_LIST_FOREACH_SAFE(translation->nodes,
874 elist, elist_next, translation_node)
876 evas_object_event_callback_del(translation_node->obj,
877 EVAS_CALLBACK_DEL, _translation_object_del_cb);
878 translation->nodes = eina_list_remove_list(translation->nodes, elist);
879 free(translation_node);
885 _transit_effect_translation_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress __UNUSED__)
887 EINA_SAFETY_ON_NULL_RETURN(effect);
888 EINA_SAFETY_ON_NULL_RETURN(transit);
890 Elm_Transit_Effect_Translation *translation = effect;
891 Elm_Transit_Effect_Translation_Node *translation_node;
894 if (!translation->nodes)
895 translation->nodes = _translation_nodes_build(transit, translation);
897 EINA_LIST_FOREACH(translation->nodes, elist, translation_node)
899 x = translation_node->x + translation->from.dx
900 + (translation->to.dx * progress);
901 y = translation_node->y + translation->from.dy
902 + (translation->to.dy * progress);
903 evas_object_move(translation_node->obj, x, y);
907 static Elm_Transit_Effect *
908 _transit_effect_translation_context_new(Evas_Coord from_dx, Evas_Coord from_dy, Evas_Coord to_dx, Evas_Coord to_dy)
910 Elm_Transit_Effect_Translation *translation;
912 translation = ELM_NEW(Elm_Transit_Effect_Translation);
913 if (!translation) return NULL;
915 translation->from.dx = from_dx;
916 translation->from.dy = from_dy;
917 translation->to.dx = to_dx - from_dx;
918 translation->to.dy = to_dy - from_dy;
923 EAPI Elm_Transit_Effect *
924 elm_transit_effect_translation_add(Elm_Transit *transit, Evas_Coord from_dx, Evas_Coord from_dy, Evas_Coord to_dx, Evas_Coord to_dy)
926 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
927 Elm_Transit_Effect *effect = _transit_effect_translation_context_new(from_dx, from_dy, to_dx, to_dy);
931 ERR("Failed to allocate translation effect! : transit=%p", transit);
934 elm_transit_effect_add(transit,
935 _transit_effect_translation_op, effect,
936 _transit_effect_translation_context_free);
940 ///////////////////////////////////////////////////////////////////////////
942 ///////////////////////////////////////////////////////////////////////////
943 typedef struct _Elm_Transit_Effect_Zoom Elm_Transit_Effect_Zoom;
945 struct _Elm_Transit_Effect_Zoom
951 _transit_effect_zoom_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
953 Elm_Transit_Effect_Zoom *zoom = effect;
958 _transit_effect_zoom_op(Elm_Transit_Effect *effect, Elm_Transit *transit , double progress)
960 EINA_SAFETY_ON_NULL_RETURN(effect);
961 EINA_SAFETY_ON_NULL_RETURN(transit);
964 Elm_Transit_Effect_Zoom *zoom = effect;
966 Evas_Coord x, y, w, h;
968 map = evas_map_new(4);
971 EINA_LIST_FOREACH(transit->objs, elist, obj)
973 evas_object_geometry_get(obj, &x, &y, &w, &h);
974 evas_map_util_points_populate_from_object_full(map, obj, zoom->from +
975 (progress * zoom->to));
976 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, _TRANSIT_FOCAL);
977 evas_object_map_set(obj, map);
978 evas_object_map_enable_set(obj, EINA_TRUE);
983 static Elm_Transit_Effect *
984 _transit_effect_zoom_context_new(float from_rate, float to_rate)
986 Elm_Transit_Effect_Zoom *zoom;
988 zoom = ELM_NEW(Elm_Transit_Effect_Zoom);
989 if (!zoom) return NULL;
991 zoom->from = (_TRANSIT_FOCAL - (from_rate * _TRANSIT_FOCAL)) * (1 / from_rate);
992 zoom->to = ((_TRANSIT_FOCAL - (to_rate * _TRANSIT_FOCAL)) * (1 / to_rate)) - zoom->from;
997 EAPI Elm_Transit_Effect *
998 elm_transit_effect_zoom_add(Elm_Transit *transit, float from_rate, float to_rate)
1000 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1001 Elm_Transit_Effect *effect = _transit_effect_zoom_context_new(from_rate, to_rate);
1005 ERR("Failed to allocate zoom effect! : transit=%p", transit);
1008 elm_transit_effect_add(transit,
1009 _transit_effect_zoom_op, effect,
1010 _transit_effect_zoom_context_free);
1014 ///////////////////////////////////////////////////////////////////////////
1016 ///////////////////////////////////////////////////////////////////////////
1017 typedef struct _Elm_Transit_Effect_Flip Elm_Transit_Effect_Flip;
1019 struct _Elm_Transit_Effect_Flip
1021 Elm_Transit_Effect_Flip_Axis axis;
1026 _transit_effect_flip_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit)
1028 EINA_SAFETY_ON_NULL_RETURN(effect);
1029 EINA_SAFETY_ON_NULL_RETURN(transit);
1030 Elm_Transit_Effect_Flip *flip = effect;
1031 Evas_Object *front, *back;
1033 int count = eina_list_count(transit->objs);
1035 for (i = 0; i < (count - 1); i += 2)
1037 front = eina_list_nth(transit->objs, i);
1038 back = eina_list_nth(transit->objs, i+1);
1039 evas_object_map_enable_set(front, EINA_FALSE);
1040 evas_object_map_enable_set(back, EINA_FALSE);
1046 _transit_effect_flip_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
1048 EINA_SAFETY_ON_NULL_RETURN(effect);
1049 EINA_SAFETY_ON_NULL_RETURN(transit);
1050 Evas_Object *obj, *front, *back;
1052 Elm_Transit_Effect_Flip *flip = effect;
1055 Evas_Coord x, y, w, h;
1057 map = evas_map_new(4);
1060 if (flip->cw) degree = (float)(progress * 180);
1061 else degree = (float)(progress * -180);
1063 count = eina_list_count(transit->objs);
1065 for (i = 0; i < (count - 1); i += 2)
1067 Evas_Coord half_w, half_h;
1069 front = eina_list_nth(transit->objs, i);
1070 back = eina_list_nth(transit->objs, i+1);
1072 if ((degree < 90) && (degree > -90))
1077 evas_object_hide(back);
1078 evas_object_show(front);
1086 evas_object_hide(front);
1087 evas_object_show(back);
1091 evas_map_util_points_populate_from_object_full(map, obj, 0);
1092 evas_object_geometry_get(obj, &x, &y, &w, &h);
1096 if (flip->axis == ELM_TRANSIT_EFFECT_FLIP_AXIS_Y)
1098 if ((degree >= 90) || (degree <= -90))
1100 evas_map_point_image_uv_set(map, 0, w, 0);
1101 evas_map_point_image_uv_set(map, 1, 0, 0);
1102 evas_map_point_image_uv_set(map, 2, 0, h);
1103 evas_map_point_image_uv_set(map, 3, w, h);
1105 evas_map_util_3d_rotate(map, 0, degree,
1106 0, x + half_w, y + half_h, 0);
1110 if ((degree >= 90) || (degree <= -90))
1112 evas_map_point_image_uv_set(map, 0, 0, h);
1113 evas_map_point_image_uv_set(map, 1, w, h);
1114 evas_map_point_image_uv_set(map, 2, w, 0);
1115 evas_map_point_image_uv_set(map, 3, 0, 0);
1117 evas_map_util_3d_rotate(map, degree,
1118 0, 0, x + half_w, y + half_h, 0);
1120 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, _TRANSIT_FOCAL);
1121 evas_object_map_enable_set(front, EINA_TRUE);
1122 evas_object_map_enable_set(back, EINA_TRUE);
1123 evas_object_map_set(obj, map);
1128 static Elm_Transit_Effect *
1129 _transit_effect_flip_context_new(Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1131 Elm_Transit_Effect_Flip *flip;
1133 flip = ELM_NEW(Elm_Transit_Effect_Flip);
1134 if (!flip) return NULL;
1142 EAPI Elm_Transit_Effect *
1143 elm_transit_effect_flip_add(Elm_Transit *transit, Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1145 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1146 Elm_Transit_Effect *effect = _transit_effect_flip_context_new(axis, cw);
1150 ERR("Failed to allocate flip effect! : transit=%p", transit);
1153 elm_transit_effect_add(transit,
1154 _transit_effect_flip_op, effect,
1155 _transit_effect_flip_context_free);
1159 ///////////////////////////////////////////////////////////////////////////
1160 //ResizableFlip Effect
1161 ///////////////////////////////////////////////////////////////////////////
1162 typedef struct _Elm_Transit_Effect_Resizable_Flip Elm_Transit_Effect_ResizableFlip;
1163 typedef struct _Elm_Transit_Effect_Resizable_Flip_Node Elm_Transit_Effect_ResizableFlip_Node;
1165 struct _Elm_Transit_Effect_Resizable_Flip_Node
1171 } from_pos, from_size, to_pos, to_size;
1174 struct _Elm_Transit_Effect_Resizable_Flip
1178 Elm_Transit_Effect_Flip_Axis axis;
1182 _resizable_flip_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1184 Elm_Transit_Effect_ResizableFlip *resizable_flip = data;
1186 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1188 EINA_LIST_FOREACH(resizable_flip->nodes, elist, resizable_flip_node)
1190 if (resizable_flip_node->front == obj)
1191 evas_object_event_callback_del(resizable_flip_node->back,
1192 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1193 else if (resizable_flip_node->back == obj)
1194 evas_object_event_callback_del(resizable_flip_node->front,
1195 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1198 resizable_flip->nodes = eina_list_remove_list(resizable_flip->nodes,
1200 free(resizable_flip_node);
1206 _resizable_flip_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_ResizableFlip *resizable_flip)
1208 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1209 Eina_List *data_list = NULL;
1210 Evas_Coord front_x, front_y, front_w, front_h;
1211 Evas_Coord back_x, back_y, back_w, back_h;
1214 count = eina_list_count(transit->objs);
1215 for (i = 0; i < (count - 1); i += 2)
1217 resizable_flip_node = ELM_NEW(Elm_Transit_Effect_ResizableFlip_Node);
1218 if (!resizable_flip_node)
1220 eina_list_free(data_list);
1224 resizable_flip_node->front = eina_list_nth(transit->objs, i);
1225 resizable_flip_node->back = eina_list_nth(transit->objs, i+1);
1227 evas_object_geometry_get(resizable_flip_node->front,
1228 &front_x, &front_y, &front_w, &front_h);
1229 evas_object_geometry_get(resizable_flip_node->back,
1230 &back_x, &back_y, &back_w, &back_h);
1232 resizable_flip_node->from_pos.x = front_x;
1233 resizable_flip_node->from_pos.y = front_y;
1234 resizable_flip_node->to_pos.x = back_x - front_x;
1235 resizable_flip_node->to_pos.y = back_y - front_y;
1237 resizable_flip_node->from_size.x = front_w;
1238 resizable_flip_node->from_size.y = front_h;
1239 resizable_flip_node->to_size.x = back_w - front_w;
1240 resizable_flip_node->to_size.y = back_h - front_h;
1242 data_list = eina_list_append(data_list, resizable_flip_node);
1244 evas_object_event_callback_add(resizable_flip_node->back,
1245 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb, resizable_flip);
1246 evas_object_event_callback_add(resizable_flip_node->front,
1247 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb, resizable_flip);
1254 _set_image_uv_by_axis_y(Evas_Map *map, Elm_Transit_Effect_ResizableFlip_Node *flip, float degree)
1256 if ((degree >= 90) || (degree <= -90))
1258 evas_map_point_image_uv_set(map, 0,
1259 (flip->from_size.x * 2) + flip->to_size.x,
1261 evas_map_point_image_uv_set(map, 1, 0, 0);
1262 evas_map_point_image_uv_set(map, 2, 0,
1263 (flip->from_size.y * 2) + flip->to_size.y);
1264 evas_map_point_image_uv_set(map, 3,
1265 (flip->from_size.x * 2) + flip->to_size.x,
1266 (flip->from_size.y * 2) + flip->to_size.y);
1270 evas_map_point_image_uv_set(map, 0, 0, 0);
1271 evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
1272 evas_map_point_image_uv_set(map, 2, flip->from_size.x,
1274 evas_map_point_image_uv_set(map, 3, 0, flip->from_size.y);
1279 _set_image_uv_by_axis_x(Evas_Map *map, Elm_Transit_Effect_ResizableFlip_Node *flip, float degree)
1281 if ((degree >= 90) || (degree <= -90))
1283 evas_map_point_image_uv_set(map, 0, 0,
1284 (flip->from_size.y * 2) + flip->to_size.y);
1285 evas_map_point_image_uv_set(map, 1,
1286 (flip->from_size.x * 2) + flip->to_size.x,
1287 (flip->from_size.y * 2) + flip->to_size.y);
1288 evas_map_point_image_uv_set(map, 2,
1289 (flip->from_size.x * 2) + flip->to_size.x,
1291 evas_map_point_image_uv_set(map, 3, 0, 0);
1295 evas_map_point_image_uv_set(map, 0, 0, 0);
1296 evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
1297 evas_map_point_image_uv_set(map, 2, flip->from_size.x,
1299 evas_map_point_image_uv_set(map, 3, 0, flip->from_size.y);
1304 _transit_effect_resizable_flip_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
1306 EINA_SAFETY_ON_NULL_RETURN(effect);
1308 Elm_Transit_Effect_ResizableFlip *resizable_flip = effect;
1309 Eina_List *elist, *elist_next;
1310 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1312 EINA_LIST_FOREACH_SAFE(resizable_flip->nodes,
1313 elist, elist_next, resizable_flip_node)
1315 evas_object_map_enable_set(resizable_flip_node->front, EINA_FALSE);
1316 evas_object_map_enable_set(resizable_flip_node->back, EINA_FALSE);
1318 resizable_flip->nodes = eina_list_remove_list(resizable_flip->nodes,
1321 evas_object_event_callback_del(resizable_flip_node->back,
1322 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1323 evas_object_event_callback_del(resizable_flip_node->front,
1324 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1325 free(resizable_flip_node);
1327 free(resizable_flip);
1331 _transit_effect_resizable_flip_op(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__, double progress)
1333 EINA_SAFETY_ON_NULL_RETURN(effect);
1338 Evas_Coord half_w, half_h;
1339 Elm_Transit_Effect_ResizableFlip *resizable_flip = effect;
1340 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1343 map = evas_map_new(4);
1346 if (resizable_flip->cw) degree = (float)(progress * 180);
1347 else degree = (float)(progress * -180);
1349 if (!resizable_flip->nodes)
1350 resizable_flip->nodes = _resizable_flip_nodes_build(transit,
1353 EINA_LIST_FOREACH(resizable_flip->nodes, elist, resizable_flip_node)
1355 if ((degree < 90) && (degree > -90))
1357 obj = resizable_flip_node->front;
1358 if (resizable_flip_node->front != resizable_flip_node->back)
1360 evas_object_hide(resizable_flip_node->back);
1361 evas_object_show(resizable_flip_node->front);
1366 obj = resizable_flip_node->back;
1367 if (resizable_flip_node->front != resizable_flip_node->back)
1369 evas_object_hide(resizable_flip_node->front);
1370 evas_object_show(resizable_flip_node->back);
1374 x = resizable_flip_node->from_pos.x +
1375 (resizable_flip_node->to_pos.x * progress);
1376 y = resizable_flip_node->from_pos.y +
1377 (resizable_flip_node->to_pos.y * progress);
1378 w = resizable_flip_node->from_size.x +
1379 (resizable_flip_node->to_size.x * progress);
1380 h = resizable_flip_node->from_size.y +
1381 (resizable_flip_node->to_size.y * progress);
1382 evas_map_point_coord_set(map, 0, x, y, 0);
1383 evas_map_point_coord_set(map, 1, x + w, y, 0);
1384 evas_map_point_coord_set(map, 2, x + w, y + h, 0);
1385 evas_map_point_coord_set(map, 3, x, y + h, 0);
1387 half_w = (Evas_Coord)(w / 2);
1388 half_h = (Evas_Coord)(h / 2);
1390 if (resizable_flip->axis == ELM_TRANSIT_EFFECT_FLIP_AXIS_Y)
1392 _set_image_uv_by_axis_y(map, resizable_flip_node, degree);
1393 evas_map_util_3d_rotate(map, 0, degree,
1394 0, x + half_w, y + half_h, 0);
1398 _set_image_uv_by_axis_x(map, resizable_flip_node, degree);
1399 evas_map_util_3d_rotate(map, degree, 0,
1400 0, x + half_w, y + half_h, 0);
1403 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, _TRANSIT_FOCAL);
1404 evas_object_map_enable_set(resizable_flip_node->front, EINA_TRUE);
1405 evas_object_map_enable_set(resizable_flip_node->back, EINA_TRUE);
1406 evas_object_map_set(obj, map);
1411 static Elm_Transit_Effect *
1412 _transit_effect_resizable_flip_context_new(Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1414 Elm_Transit_Effect_ResizableFlip *resizable_flip;
1416 resizable_flip = ELM_NEW(Elm_Transit_Effect_ResizableFlip);
1417 if (!resizable_flip) return NULL;
1419 resizable_flip->cw = cw;
1420 resizable_flip->axis = axis;
1422 return resizable_flip;
1425 EAPI Elm_Transit_Effect *
1426 elm_transit_effect_resizable_flip_add(Elm_Transit *transit, Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1428 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1429 Elm_Transit_Effect *effect = _transit_effect_resizable_flip_context_new(axis, cw);
1433 ERR("Failed to allocate resizable_flip effect! : transit=%p", transit);
1436 elm_transit_effect_add(transit,
1437 _transit_effect_resizable_flip_op, effect,
1438 _transit_effect_resizable_flip_context_free);
1442 ///////////////////////////////////////////////////////////////////////////
1444 ///////////////////////////////////////////////////////////////////////////
1445 typedef struct _Elm_Transit_Effect_Wipe Elm_Transit_Effect_Wipe;
1447 struct _Elm_Transit_Effect_Wipe
1449 Elm_Transit_Effect_Wipe_Type type;
1450 Elm_Transit_Effect_Wipe_Dir dir;
1454 _elm_fx_wipe_hide(Evas_Map * map, Elm_Transit_Effect_Wipe_Dir dir, float x, float y, float w, float h, float progress)
1460 case ELM_TRANSIT_EFFECT_WIPE_DIR_LEFT:
1461 w2 = w - (w * progress);
1463 evas_map_point_image_uv_set(map, 0, 0, 0);
1464 evas_map_point_image_uv_set(map, 1, w2, 0);
1465 evas_map_point_image_uv_set(map, 2, w2, h);
1466 evas_map_point_image_uv_set(map, 3, 0, h);
1467 evas_map_point_coord_set(map, 0, x, y, 0);
1468 evas_map_point_coord_set(map, 1, x + w2, y, 0);
1469 evas_map_point_coord_set(map, 2, x + w2, h2, 0);
1470 evas_map_point_coord_set(map, 3, x, h2, 0);
1472 case ELM_TRANSIT_EFFECT_WIPE_DIR_RIGHT:
1473 w2 = (w * progress);
1475 evas_map_point_image_uv_set(map, 0, w2, 0);
1476 evas_map_point_image_uv_set(map, 1, w, 0);
1477 evas_map_point_image_uv_set(map, 2, w, h);
1478 evas_map_point_image_uv_set(map, 3, w2, h);
1479 evas_map_point_coord_set(map, 0, x + w2, y, 0);
1480 evas_map_point_coord_set(map, 1, x + w, y, 0);
1481 evas_map_point_coord_set(map, 2, x + w, h2, 0);
1482 evas_map_point_coord_set(map, 3, x + w2, h2, 0);
1484 case ELM_TRANSIT_EFFECT_WIPE_DIR_UP:
1486 h2 = h - (h * progress);
1487 evas_map_point_image_uv_set(map, 0, 0, 0);
1488 evas_map_point_image_uv_set(map, 1, w, 0);
1489 evas_map_point_image_uv_set(map, 2, w, h2);
1490 evas_map_point_image_uv_set(map, 3, 0, h2);
1491 evas_map_point_coord_set(map, 0, x, y, 0);
1492 evas_map_point_coord_set(map, 1, w2, y, 0);
1493 evas_map_point_coord_set(map, 2, w2, y+h2, 0);
1494 evas_map_point_coord_set(map, 3, x, y+h2, 0);
1496 case ELM_TRANSIT_EFFECT_WIPE_DIR_DOWN:
1498 h2 = (h * progress);
1499 evas_map_point_image_uv_set(map, 0, 0, h2);
1500 evas_map_point_image_uv_set(map, 1, w, h2);
1501 evas_map_point_image_uv_set(map, 2, w, h);
1502 evas_map_point_image_uv_set(map, 3, 0, h);
1503 evas_map_point_coord_set(map, 0, x, y + h2, 0);
1504 evas_map_point_coord_set(map, 1, w2, y + h2, 0);
1505 evas_map_point_coord_set(map, 2, w2, y + h, 0);
1506 evas_map_point_coord_set(map, 3, x, y + h, 0);
1511 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, _TRANSIT_FOCAL);
1515 _elm_fx_wipe_show(Evas_Map *map, Elm_Transit_Effect_Wipe_Dir dir, float x, float y, float w, float h, float progress)
1521 case ELM_TRANSIT_EFFECT_WIPE_DIR_LEFT:
1522 w2 = (w - (w * progress));
1524 evas_map_point_image_uv_set(map, 0, w2, 0);
1525 evas_map_point_image_uv_set(map, 1, w, 0);
1526 evas_map_point_image_uv_set(map, 2, w, h);
1527 evas_map_point_image_uv_set(map, 3, w2, h);
1528 evas_map_point_coord_set(map, 0, x + w2, y, 0);
1529 evas_map_point_coord_set(map, 1, w, y, 0);
1530 evas_map_point_coord_set(map, 2, w, h2, 0);
1531 evas_map_point_coord_set(map, 3, x + w2, h2, 0);
1533 case ELM_TRANSIT_EFFECT_WIPE_DIR_RIGHT:
1534 w2 = (w * progress);
1536 evas_map_point_image_uv_set(map, 0, 0, 0);
1537 evas_map_point_image_uv_set(map, 1, w2, 0);
1538 evas_map_point_image_uv_set(map, 2, w2, h);
1539 evas_map_point_image_uv_set(map, 3, 0, h);
1540 evas_map_point_coord_set(map, 0, x, y, 0);
1541 evas_map_point_coord_set(map, 1, x + w2, y, 0);
1542 evas_map_point_coord_set(map, 2, x + w2, h2, 0);
1543 evas_map_point_coord_set(map, 3, x, h2, 0);
1545 case ELM_TRANSIT_EFFECT_WIPE_DIR_UP:
1547 h2 = (h - (h * progress));
1548 evas_map_point_image_uv_set(map, 0, 0, h2);
1549 evas_map_point_image_uv_set(map, 1, w, h2);
1550 evas_map_point_image_uv_set(map, 2, w, h);
1551 evas_map_point_image_uv_set(map, 3, 0, h);
1552 evas_map_point_coord_set(map, 0, x, y + h2, 0);
1553 evas_map_point_coord_set(map, 1, w2, y + h2, 0);
1554 evas_map_point_coord_set(map, 2, w2, y + h, 0);
1555 evas_map_point_coord_set(map, 3, x, y + h, 0);
1557 case ELM_TRANSIT_EFFECT_WIPE_DIR_DOWN:
1559 h2 = (h * progress);
1560 evas_map_point_image_uv_set(map, 0, 0, 0);
1561 evas_map_point_image_uv_set(map, 1, w, 0);
1562 evas_map_point_image_uv_set(map, 2, w, h2);
1563 evas_map_point_image_uv_set(map, 3, 0, h2);
1564 evas_map_point_coord_set(map, 0, x, y, 0);
1565 evas_map_point_coord_set(map, 1, w2, y, 0);
1566 evas_map_point_coord_set(map, 2, w2, y + h2, 0);
1567 evas_map_point_coord_set(map, 3, x, y + h2, 0);
1572 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, _TRANSIT_FOCAL);
1576 _transit_effect_wipe_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit)
1578 EINA_SAFETY_ON_NULL_RETURN(effect);
1579 EINA_SAFETY_ON_NULL_RETURN(transit);
1582 Elm_Transit_Effect_Wipe *wipe = effect;
1583 Eina_Bool reverse = elm_transit_auto_reverse_get(transit);
1585 EINA_LIST_FOREACH(transit->objs, elist, obj)
1587 if ((wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_SHOW && !reverse)
1588 || (wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_HIDE && reverse))
1589 evas_object_show(obj);
1590 else evas_object_hide(obj);
1591 evas_object_map_enable_set(obj, EINA_FALSE);
1598 _transit_effect_wipe_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
1600 EINA_SAFETY_ON_NULL_RETURN(effect);
1601 EINA_SAFETY_ON_NULL_RETURN(transit);
1602 Elm_Transit_Effect_Wipe *wipe = effect;
1604 Evas_Coord _x, _y, _w, _h;
1608 map = evas_map_new(4);
1611 EINA_LIST_FOREACH(transit->objs, elist, obj)
1613 evas_object_geometry_get(obj, &_x, &_y, &_w, &_h);
1615 if (wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_SHOW)
1616 _elm_fx_wipe_show(map, wipe->dir, _x, _y, _w, _h, (float)progress);
1618 _elm_fx_wipe_hide(map, wipe->dir, _x, _y, _w, _h, (float)progress);
1620 evas_object_map_enable_set(obj, EINA_TRUE);
1621 evas_object_map_set(obj, map);
1626 static Elm_Transit_Effect *
1627 _transit_effect_wipe_context_new(Elm_Transit_Effect_Wipe_Type type, Elm_Transit_Effect_Wipe_Dir dir)
1629 Elm_Transit_Effect_Wipe *wipe;
1631 wipe = ELM_NEW(Elm_Transit_Effect_Wipe);
1632 if (!wipe) return NULL;
1641 elm_transit_effect_wipe_add(Elm_Transit *transit, Elm_Transit_Effect_Wipe_Type type, Elm_Transit_Effect_Wipe_Dir dir)
1643 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1644 void *effect = _transit_effect_wipe_context_new(type, dir);
1648 ERR("Failed to allocate wipe effect! : transit=%p", transit);
1651 elm_transit_effect_add(transit,
1652 _transit_effect_wipe_op, effect,
1653 _transit_effect_wipe_context_free);
1657 ///////////////////////////////////////////////////////////////////////////
1659 ///////////////////////////////////////////////////////////////////////////
1660 typedef struct _Elm_Transit_Effect_Color Elm_Transit_Effect_Color;
1662 struct _Elm_Transit_Effect_Color
1664 struct _unsigned_color {
1665 unsigned int r, g, b, a;
1667 struct _signed_color {
1673 _transit_effect_color_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
1675 Elm_Transit_Effect_Color *color = effect;
1680 _transit_effect_color_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
1682 EINA_SAFETY_ON_NULL_RETURN(effect);
1683 EINA_SAFETY_ON_NULL_RETURN(transit);
1684 Elm_Transit_Effect_Color *color = effect;
1687 unsigned int r, g, b, a;
1689 r = (color->from.r + (int)((float)color->to.r * progress));
1690 g = (color->from.g + (int)((float)color->to.g * progress));
1691 b = (color->from.b + (int)((float)color->to.b * progress));
1692 a = (color->from.a + (int)((float)color->to.a * progress));
1694 EINA_LIST_FOREACH(transit->objs, elist, obj)
1695 evas_object_color_set(obj, r, g, b, a);
1698 static Elm_Transit_Effect *
1699 _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)
1701 Elm_Transit_Effect_Color *color;
1703 color = ELM_NEW(Elm_Transit_Effect_Color);
1704 if (!color) return NULL;
1706 color->from.r = from_r;
1707 color->from.g = from_g;
1708 color->from.b = from_b;
1709 color->from.a = from_a;
1710 color->to.r = to_r - from_r;
1711 color->to.g = to_g - from_g;
1712 color->to.b = to_b - from_b;
1713 color->to.a = to_a - from_a;
1718 EAPI Elm_Transit_Effect *
1719 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)
1721 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1722 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);
1726 ERR("Failed to allocate color effect! : transit=%p", transit);
1729 elm_transit_effect_add(transit,
1730 _transit_effect_color_op, effect,
1731 _transit_effect_color_context_free);
1735 ///////////////////////////////////////////////////////////////////////////
1737 ///////////////////////////////////////////////////////////////////////////
1738 typedef struct _Elm_Transit_Effect_Fade Elm_Transit_Effect_Fade;
1739 typedef struct _Elm_Transit_Effect_Fade_Node Elm_Transit_Effect_Fade_Node;
1741 struct _Elm_Transit_Effect_Fade_Node
1743 Evas_Object *before;
1745 struct _signed_color before_color, after_color;
1748 Eina_Bool inversed : 1;
1751 struct _Elm_Transit_Effect_Fade
1757 _fade_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1759 Elm_Transit_Effect_Fade *fade = data;
1761 Elm_Transit_Effect_Fade_Node *fade_node;
1763 EINA_LIST_FOREACH(fade->nodes, elist, fade_node)
1765 if (fade_node->before == obj)
1766 evas_object_event_callback_del(fade_node->after,
1767 EVAS_CALLBACK_DEL, _fade_object_del_cb);
1768 else if (fade_node->after == obj)
1769 evas_object_event_callback_del(fade_node->before,
1770 EVAS_CALLBACK_DEL, _fade_object_del_cb);
1773 fade->nodes = eina_list_remove_list(fade->nodes, elist);
1780 _fade_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Fade *fade_data)
1782 Elm_Transit_Effect_Fade_Node *fade;
1783 Eina_List *data_list = NULL;
1786 count = eina_list_count(transit->objs);
1787 for (i = 0; i < count; i += 2)
1789 fade = ELM_NEW(Elm_Transit_Effect_Fade_Node);
1792 eina_list_free(data_list);
1796 fade->before = eina_list_nth(transit->objs, i);
1797 fade->after = eina_list_nth(transit->objs, i+1);
1799 evas_object_color_get(fade->before,
1800 &fade->before_color.r, &fade->before_color.g,
1801 &fade->before_color.b, &fade->before_color.a);
1802 evas_object_color_get(fade->after,
1803 &fade->after_color.r, &fade->after_color.g,
1804 &fade->after_color.b, &fade->after_color.a);
1806 fade->before_alpha = (255 - fade->before_color.a);
1807 fade->after_alpha = (255 - fade->after_color.a);
1809 data_list = eina_list_append(data_list, fade);
1811 evas_object_event_callback_add(fade->before,
1812 EVAS_CALLBACK_DEL, _fade_object_del_cb, fade_data);
1813 evas_object_event_callback_add(fade->after,
1814 EVAS_CALLBACK_DEL, _fade_object_del_cb, fade_data);
1820 _transit_effect_fade_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
1822 EINA_SAFETY_ON_NULL_RETURN(effect);
1823 Elm_Transit_Effect_Fade *fade = effect;
1824 Elm_Transit_Effect_Fade_Node *fade_node;
1825 Eina_List *elist, *elist_next;
1827 EINA_LIST_FOREACH_SAFE(fade->nodes, elist, elist_next, fade_node)
1829 evas_object_color_set(fade_node->before, fade_node->before_color.r,
1830 fade_node->before_color.g,
1831 fade_node->before_color.b,
1832 fade_node->before_color.a);
1833 evas_object_color_set(fade_node->after, fade_node->after_color.r,
1834 fade_node->after_color.g,
1835 fade_node->after_color.b,
1836 fade_node->after_color.a);
1838 fade->nodes = eina_list_remove_list(fade->nodes, elist);
1839 evas_object_event_callback_del(fade_node->before,
1840 EVAS_CALLBACK_DEL, _fade_object_del_cb);
1841 evas_object_event_callback_del(fade_node->after,
1842 EVAS_CALLBACK_DEL, _fade_object_del_cb);
1850 _transit_effect_fade_op(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__, double progress)
1852 EINA_SAFETY_ON_NULL_RETURN(effect);
1853 Elm_Transit_Effect_Fade *fade = effect;
1855 Elm_Transit_Effect_Fade_Node *fade_node;
1859 fade->nodes = _fade_nodes_build(transit, fade);
1861 EINA_LIST_FOREACH(fade->nodes, elist, fade_node)
1865 if (!fade_node->inversed)
1867 evas_object_hide(fade_node->after);
1868 evas_object_show(fade_node->before);
1869 fade_node->inversed = EINA_TRUE;
1872 _progress = (1 - (progress * 2));
1874 evas_object_color_set(fade_node->before,
1875 fade_node->before_color.r * _progress,
1876 fade_node->before_color.g * _progress,
1877 fade_node->before_color.b * _progress,
1878 fade_node->before_color.a +
1879 fade_node->before_alpha * (1 - _progress));
1883 if (fade_node->inversed)
1885 evas_object_hide(fade_node->before);
1886 evas_object_show(fade_node->after);
1887 fade_node->inversed = EINA_FALSE;
1890 _progress = ((progress - 0.5) * 2);
1892 evas_object_color_set(fade_node->after,
1893 fade_node->after_color.r * _progress,
1894 fade_node->after_color.g * _progress,
1895 fade_node->after_color.b * _progress,
1896 fade_node->after_color.a +
1897 fade_node->after_alpha * (1 - _progress));
1902 static Elm_Transit_Effect *
1903 _transit_effect_fade_context_new(void)
1905 Elm_Transit_Effect_Fade *fade;
1906 fade = ELM_NEW(Elm_Transit_Effect_Fade);
1907 if (!fade) return NULL;
1911 EAPI Elm_Transit_Effect *
1912 elm_transit_effect_fade_add(Elm_Transit *transit)
1914 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1916 Elm_Transit_Effect *effect = _transit_effect_fade_context_new();
1920 ERR("Failed to allocate fade effect! : transit=%p", transit);
1923 elm_transit_effect_add(transit,
1924 _transit_effect_fade_op, effect,
1925 _transit_effect_fade_context_free);
1929 ///////////////////////////////////////////////////////////////////////////
1931 ///////////////////////////////////////////////////////////////////////////
1932 typedef struct _Elm_Transit_Effect_Blend Elm_Transit_Effect_Blend;
1933 typedef struct _Elm_Transit_Effect_Blend_Node Elm_Transit_Effect_Blend_Node;
1935 struct _Elm_Transit_Effect_Blend_Node
1937 Evas_Object *before;
1939 struct _signed_color from, to;
1942 struct _Elm_Transit_Effect_Blend
1948 _blend_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1950 Elm_Transit_Effect_Blend *blend = data;
1952 Elm_Transit_Effect_Blend_Node *blend_node;
1954 EINA_LIST_FOREACH(blend->nodes, elist, blend_node)
1956 if (blend_node->after == obj)
1957 evas_object_event_callback_del(blend_node->before,
1958 EVAS_CALLBACK_DEL, _blend_object_del_cb);
1959 else if (blend_node->before == obj)
1960 evas_object_event_callback_del(blend_node->after,
1961 EVAS_CALLBACK_DEL, _blend_object_del_cb);
1964 blend->nodes = eina_list_remove_list(blend->nodes, elist);
1971 _blend_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Blend *blend)
1973 Elm_Transit_Effect_Blend_Node *blend_node;
1974 Eina_List *data_list = NULL;
1977 count = eina_list_count(transit->objs);
1978 for (i = 0; i < (count - 1); i += 2)
1980 blend_node = ELM_NEW(Elm_Transit_Effect_Blend_Node);
1983 eina_list_free(data_list);
1987 blend_node->before = eina_list_nth(transit->objs, i);
1988 blend_node->after = eina_list_nth(transit->objs, i + 1);
1989 evas_object_show(blend_node->before);
1990 evas_object_show(blend_node->after);
1992 evas_object_color_get(blend_node->before, &blend_node->from.r,
1993 &blend_node->from.g, &blend_node->from.b,
1994 &blend_node->from.a);
1995 evas_object_color_get(blend_node->after, &blend_node->to.r,
1996 &blend_node->to.g, &blend_node->to.b,
1999 data_list = eina_list_append(data_list, blend_node);
2001 evas_object_event_callback_add(blend_node->before,
2002 EVAS_CALLBACK_DEL, _blend_object_del_cb, blend);
2003 evas_object_event_callback_add(blend_node->after,
2004 EVAS_CALLBACK_DEL, _blend_object_del_cb, blend);
2010 _transit_effect_blend_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
2012 EINA_SAFETY_ON_NULL_RETURN(effect);
2013 Elm_Transit_Effect_Blend *blend = effect;
2014 Elm_Transit_Effect_Blend_Node *blend_node;
2015 Eina_List *elist, *elist_next;
2017 EINA_LIST_FOREACH_SAFE(blend->nodes, elist, elist_next, blend_node)
2019 evas_object_color_set(blend_node->before,
2020 blend_node->from.r, blend_node->from.g,
2021 blend_node->from.b, blend_node->from.a);
2022 evas_object_color_set(blend_node->after, blend_node->to.r,
2023 blend_node->to.g, blend_node->to.b,
2026 if (elm_transit_auto_reverse_get(transit))
2027 evas_object_hide(blend_node->after);
2029 evas_object_hide(blend_node->before);
2031 blend->nodes = eina_list_remove_list(blend->nodes, elist);
2033 evas_object_event_callback_del(blend_node->before,
2034 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2035 evas_object_event_callback_del(blend_node->after,
2036 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2043 _transit_effect_blend_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2045 EINA_SAFETY_ON_NULL_RETURN(effect);
2046 EINA_SAFETY_ON_NULL_RETURN(transit);
2047 Elm_Transit_Effect_Blend *blend = effect;
2048 Elm_Transit_Effect_Blend_Node *blend_node;
2051 if (!blend->nodes) blend->nodes = _blend_nodes_build(transit, blend);
2053 EINA_LIST_FOREACH(blend->nodes, elist, blend_node)
2055 evas_object_color_set(blend_node->before,
2056 (int)(blend_node->from.r * (1 - progress)),
2057 (int)(blend_node->from.g * (1 - progress)),
2058 (int)(blend_node->from.b * (1 - progress)),
2059 (int)(blend_node->from.a * (1 - progress)));
2060 evas_object_color_set(blend_node->after,
2061 (int)(blend_node->to.r * progress),
2062 (int)(blend_node->to.g * progress),
2063 (int)(blend_node->to.b * progress),
2064 (int)(blend_node->to.a * progress));
2068 static Elm_Transit_Effect *
2069 _transit_effect_blend_context_new(void)
2071 Elm_Transit_Effect_Blend *blend;
2073 blend = ELM_NEW(Elm_Transit_Effect_Blend);
2074 if (!blend) return NULL;
2078 EAPI Elm_Transit_Effect *
2079 elm_transit_effect_blend_add(Elm_Transit *transit)
2081 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2082 Elm_Transit_Effect *effect = _transit_effect_blend_context_new();
2086 ERR("Failed to allocate blend effect! : transit=%p", transit);
2089 elm_transit_effect_add(transit,
2090 _transit_effect_blend_op, effect,
2091 _transit_effect_blend_context_free);
2095 ///////////////////////////////////////////////////////////////////////////
2097 ///////////////////////////////////////////////////////////////////////////
2098 typedef struct _Elm_Transit_Effect_Rotation Elm_Transit_Effect_Rotation;
2100 struct _Elm_Transit_Effect_Rotation
2106 _transit_effect_rotation_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
2108 Elm_Transit_Effect_Rotation *rotation = effect;
2113 _transit_effect_rotation_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2115 EINA_SAFETY_ON_NULL_RETURN(effect);
2116 EINA_SAFETY_ON_NULL_RETURN(transit);
2117 Elm_Transit_Effect_Rotation *rotation = effect;
2119 Evas_Coord x, y, w, h;
2121 float half_w, half_h;
2125 map = evas_map_new(4);
2128 EINA_LIST_FOREACH(transit->objs, elist, obj)
2130 evas_map_util_points_populate_from_object_full(map, obj, 0);
2131 degree = rotation->from + (float)(progress * rotation->to);
2133 evas_object_geometry_get(obj, &x, &y, &w, &h);
2135 half_w = (float)w * 0.5;
2136 half_h = (float)h * 0.5;
2138 evas_map_util_rotate(map, degree, x + half_w, y + half_h);
2139 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, _TRANSIT_FOCAL);
2140 evas_object_map_enable_set(obj, EINA_TRUE);
2141 evas_object_map_set(obj, map);
2146 static Elm_Transit_Effect *
2147 _transit_effect_rotation_context_new(float from_degree, float to_degree)
2149 Elm_Transit_Effect_Rotation *rotation;
2151 rotation = ELM_NEW(Elm_Transit_Effect_Rotation);
2152 if (!rotation) return NULL;
2154 rotation->from = from_degree;
2155 rotation->to = to_degree - from_degree;
2160 EAPI Elm_Transit_Effect *
2161 elm_transit_effect_rotation_add(Elm_Transit *transit, float from_degree, float to_degree)
2163 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2164 Elm_Transit_Effect *effect = _transit_effect_rotation_context_new(from_degree, to_degree);
2168 ERR("Failed to allocate rotation effect! : transit=%p", transit);
2171 elm_transit_effect_add(transit,
2172 _transit_effect_rotation_op, effect,
2173 _transit_effect_rotation_context_free);
2177 ///////////////////////////////////////////////////////////////////////////
2178 //ImageAnimation Effect
2179 ///////////////////////////////////////////////////////////////////////////
2180 typedef struct _Elm_Transit_Effect_Image_Animation Elm_Transit_Effect_Image_Animation;
2182 struct _Elm_Transit_Effect_Image_Animation
2188 _transit_effect_image_animation_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
2190 EINA_SAFETY_ON_NULL_RETURN(effect);
2191 Elm_Transit_Effect_Image_Animation *image_animation = effect;
2193 Eina_List *elist, *elist_next;
2195 EINA_LIST_FOREACH_SAFE(image_animation->images, elist, elist_next, image)
2197 image_animation->images =
2198 eina_list_remove_list(image_animation->images, elist);
2199 eina_stringshare_del(image);
2202 free(image_animation);
2206 _transit_effect_image_animation_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2208 EINA_SAFETY_ON_NULL_RETURN(effect);
2209 EINA_SAFETY_ON_NULL_RETURN(transit);
2213 Elm_Transit_Effect_Image_Animation *image_animation = effect;
2214 unsigned int count = 0;
2217 type = eina_stringshare_add("icon");
2218 len = eina_list_count(image_animation->images);
2220 if (!len) count = floor(progress * len);
2221 else count = floor(progress * (len - 1));
2223 EINA_LIST_FOREACH(transit->objs, elist, obj)
2225 if (elm_widget_type_check(obj, type, __func__))
2226 elm_icon_file_set(obj,
2227 eina_list_nth(image_animation->images, count), NULL);
2230 eina_stringshare_del(type);
2233 static Elm_Transit_Effect *
2234 _transit_effect_image_animation_context_new(Eina_List *images)
2236 Elm_Transit_Effect_Image_Animation *image_animation;
2237 image_animation = ELM_NEW(Elm_Transit_Effect_Image_Animation);
2239 if (!image_animation) return NULL;
2240 image_animation->images = images;
2241 return image_animation;
2244 EAPI Elm_Transit_Effect *
2245 elm_transit_effect_image_animation_add(Elm_Transit *transit, Eina_List *images)
2247 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2248 Elm_Transit_Effect *effect = _transit_effect_image_animation_context_new(images);
2252 ERR("Failed to allocate image_animation effect! : transit=%p", transit);
2255 elm_transit_effect_add(transit,
2256 _transit_effect_image_animation_op, effect,
2257 _transit_effect_image_animation_context_free);