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 pass_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_del(Elm_Transit *transit);
96 static Eina_Bool _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 if (transit->animator)
245 ecore_animator_del(transit->animator);
248 while (transit->effect_list)
250 effect_module = EINA_INLIST_CONTAINER_GET(transit->effect_list, Elm_Transit_Effect_Module);
251 transit->effect_list = eina_inlist_remove(transit->effect_list, transit->effect_list);
252 _transit_effect_del(transit, effect_module);
256 while (transit->objs)
257 _transit_obj_remove(transit, eina_list_data_get(transit->objs));
259 transit->deleted = EINA_TRUE;
261 if (transit->del_data.func)
262 transit->del_data.func(transit->del_data.arg, transit);
264 //cut off the chain transit relationship
265 EINA_LIST_FOREACH_SAFE(transit->next_chain_transits, elist, elist_next, chain_transit)
266 chain_transit->prev_chain_transit = NULL;
268 if (transit->prev_chain_transit)
269 transit->prev_chain_transit->next_chain_transits =
270 eina_list_remove(transit->prev_chain_transit->next_chain_transits, transit);
272 // run chain transits
273 if (transit->finished && transit->next_chain_transits)
275 EINA_LIST_FOREACH_SAFE(transit->next_chain_transits, elist, elist_next, chain_transit)
276 elm_transit_go(chain_transit);
279 eina_list_free(transit->next_chain_transits);
281 EINA_MAGIC_SET(transit, EINA_MAGIC_NONE);
285 //If the transit is deleted then EINA_FALSE is retruned.
287 _transit_animate_op(Elm_Transit *transit, double progress)
289 Elm_Transit_Effect_Module *effect_module;
292 EINA_INLIST_FOREACH(transit->effect_list, effect_module)
294 if (transit->deleted) break;
295 if (!effect_module->deleted)
296 effect_module->transition_cb(effect_module->effect, transit, progress);
300 if (transit->walking) return EINA_TRUE;
302 if (transit->deleted)
304 _transit_del(transit);
308 else if (transit->effects_pending_del) _transit_remove_dead_effects(transit);
314 _transit_animate_cb(void *data)
316 Elm_Transit *transit = data;
317 double elapsed_time, duration;
319 transit->time.current = ecore_loop_time_get();
320 elapsed_time = transit->time.current - transit->time.begin;
321 duration = transit->time.duration + transit->time.delayed;
323 if (elapsed_time > duration)
324 elapsed_time = duration;
326 transit->progress = elapsed_time / duration;
327 switch (transit->tween_mode)
329 case ELM_TRANSIT_TWEEN_MODE_ACCELERATE:
330 transit->progress = 1.0 - sin((ELM_PI / 2.0) + (transit->progress * ELM_PI / 2.0));
332 case ELM_TRANSIT_TWEEN_MODE_DECELERATE:
333 transit->progress = sin(transit->progress * ELM_PI / 2.0);
335 case ELM_TRANSIT_TWEEN_MODE_SINUSOIDAL:
336 transit->progress = (1.0 - cos(transit->progress * ELM_PI)) / 2.0;
343 if (transit->repeat.reverse) transit->progress = 1 - transit->progress;
345 if (transit->time.duration > 0)
347 if (!_transit_animate_op(transit, transit->progress))
348 return ECORE_CALLBACK_CANCEL;
351 /* Not end. Keep going. */
352 if (elapsed_time < duration) return ECORE_CALLBACK_RENEW;
354 /* Repeat and reverse and time done! */
355 if ((transit->repeat.count >= 0) &&
356 (transit->repeat.current == transit->repeat.count) &&
357 ((!transit->auto_reverse) || transit->repeat.reverse))
359 transit->finished = EINA_TRUE;
360 elm_transit_del(transit);
361 return ECORE_CALLBACK_CANCEL;
365 if (!transit->auto_reverse || transit->repeat.reverse)
367 transit->repeat.current++;
368 transit->repeat.reverse = EINA_FALSE;
370 else transit->repeat.reverse = EINA_TRUE;
372 transit->time.begin = ecore_loop_time_get();
374 return ECORE_CALLBACK_RENEW;
378 elm_transit_add(void)
380 Elm_Transit *transit = ELM_NEW(Elm_Transit);
383 ERR("Failed to allocate a elm_transit object!");
387 EINA_MAGIC_SET(transit, ELM_TRANSIT_MAGIC);
389 elm_transit_tween_mode_set(transit, ELM_TRANSIT_TWEEN_MODE_LINEAR);
395 elm_transit_del(Elm_Transit *transit)
397 ELM_TRANSIT_CHECK_OR_RETURN(transit);
399 if (transit->walking) transit->deleted = EINA_TRUE;
400 else _transit_del(transit);
404 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)
406 ELM_TRANSIT_CHECK_OR_RETURN(transit);
407 EINA_SAFETY_ON_NULL_RETURN(transition_cb);
408 Elm_Transit_Effect_Module *effect_module;
410 EINA_INLIST_FOREACH(transit->effect_list, effect_module)
411 if ((effect_module->transition_cb == transition_cb) && (effect_module->effect == effect))
413 WRN("elm_transit does not allow to add the duplicated effect! : transit=%p", transit);
417 effect_module = ELM_NEW(Elm_Transit_Effect_Module);
420 ERR("Failed to allocate a new effect!: transit=%p", transit);
424 effect_module->end_cb = end_cb;
425 effect_module->transition_cb = transition_cb;
426 effect_module->effect = effect;
428 transit->effect_list = eina_inlist_append(transit->effect_list, (Eina_Inlist*) effect_module);
432 elm_transit_effect_del(Elm_Transit *transit, Elm_Transit_Effect_Transition_Cb transition_cb, Elm_Transit_Effect *effect)
434 ELM_TRANSIT_CHECK_OR_RETURN(transit);
435 EINA_SAFETY_ON_NULL_RETURN(transition_cb);
436 Elm_Transit_Effect_Module *effect_module;
438 EINA_INLIST_FOREACH(transit->effect_list, effect_module)
440 if ((effect_module->transition_cb == transition_cb) && (effect_module->effect == effect))
442 if (transit->walking)
444 effect_module->deleted = EINA_TRUE;
445 transit->effects_pending_del++;
449 _transit_effect_del(transit, effect_module);
450 if (!transit->effect_list) elm_transit_del(transit);
458 elm_transit_object_add(Elm_Transit *transit, Evas_Object *obj)
460 ELM_TRANSIT_CHECK_OR_RETURN(transit);
461 EINA_SAFETY_ON_NULL_RETURN(obj);
463 if (transit->animator)
465 if (!evas_object_data_get(obj, _transit_key))
467 _transit_obj_data_update(transit, obj);
468 evas_object_pass_events_set(obj, EINA_TRUE);
472 evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
473 _transit_obj_remove_cb,
476 transit->objs = eina_list_append(transit->objs, obj);
480 elm_transit_object_remove(Elm_Transit *transit, Evas_Object *obj)
482 ELM_TRANSIT_CHECK_OR_RETURN(transit);
483 EINA_SAFETY_ON_NULL_RETURN(obj);
485 _transit_obj_remove(transit, obj);
486 if (!transit->objs) elm_transit_del(transit);
489 EAPI const Eina_List *
490 elm_transit_objects_get(const Elm_Transit *transit)
492 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
493 return transit->objs;
497 elm_transit_event_enabled_set(Elm_Transit *transit, Eina_Bool enabled)
499 ELM_TRANSIT_CHECK_OR_RETURN(transit);
504 if (transit->event_enabled == enabled) return;
505 transit->event_enabled = !!enabled;
506 if (!transit->animator) return;
508 EINA_LIST_FOREACH(transit->objs, list, obj)
509 evas_object_pass_events_set(obj, enabled);
513 elm_transit_event_enabled_get(const Elm_Transit *transit)
515 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
516 return transit->event_enabled;
520 elm_transit_del_cb_set(Elm_Transit *transit, void (*cb) (void *data, Elm_Transit *transit), void *data)
522 ELM_TRANSIT_CHECK_OR_RETURN(transit);
523 transit->del_data.func = cb;
524 transit->del_data.arg = data;
528 elm_transit_auto_reverse_set(Elm_Transit *transit, Eina_Bool reverse)
530 ELM_TRANSIT_CHECK_OR_RETURN(transit);
531 transit->auto_reverse = reverse;
535 elm_transit_auto_reverse_get(const Elm_Transit *transit)
537 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
538 return transit->auto_reverse;
542 elm_transit_repeat_times_set(Elm_Transit *transit, int repeat)
544 ELM_TRANSIT_CHECK_OR_RETURN(transit);
545 transit->repeat.count = repeat;
546 transit->repeat.current = 0;
550 elm_transit_repeat_times_get(const Elm_Transit *transit)
552 ELM_TRANSIT_CHECK_OR_RETURN(transit, 0);
553 return transit->repeat.count;
557 elm_transit_tween_mode_set(Elm_Transit *transit, Elm_Transit_Tween_Mode tween_mode)
559 ELM_TRANSIT_CHECK_OR_RETURN(transit);
560 transit->tween_mode = tween_mode;
563 EAPI Elm_Transit_Tween_Mode
564 elm_transit_tween_mode_get(const Elm_Transit *transit)
566 ELM_TRANSIT_CHECK_OR_RETURN(transit, ELM_TRANSIT_TWEEN_MODE_LINEAR);
567 return transit->tween_mode;
571 elm_transit_duration_set(Elm_Transit *transit, double duration)
573 ELM_TRANSIT_CHECK_OR_RETURN(transit);
574 if (transit->animator)
576 WRN("elm_transit does not allow to set the duration time in operating! : transit=%p", transit);
579 transit->time.duration = duration;
583 elm_transit_duration_get(const Elm_Transit *transit)
585 ELM_TRANSIT_CHECK_OR_RETURN(transit, 0.0);
586 return transit->time.duration;
590 elm_transit_go(Elm_Transit *transit)
592 ELM_TRANSIT_CHECK_OR_RETURN(transit);
597 if (transit->animator)
598 ecore_animator_del(transit->animator);
600 EINA_LIST_FOREACH(transit->objs, elist, obj)
601 _transit_obj_data_update(transit, obj);
603 if (!transit->event_enabled)
605 EINA_LIST_FOREACH(transit->objs, elist, obj)
606 evas_object_pass_events_set(obj, EINA_TRUE);
609 transit->time.paused = 0;
610 transit->time.delayed = 0;
611 transit->time.begin = ecore_loop_time_get();
612 transit->animator = ecore_animator_add(_transit_animate_cb, transit);
616 elm_transit_paused_set(Elm_Transit *transit, Eina_Bool paused)
618 ELM_TRANSIT_CHECK_OR_RETURN(transit);
620 if (!transit->animator) return;
624 if (transit->time.paused > 0)
626 ecore_animator_freeze(transit->animator);
627 transit->time.paused = ecore_loop_time_get();
631 if (transit->time.paused == 0)
633 ecore_animator_thaw(transit->animator);
634 transit->time.delayed += (ecore_loop_time_get() - transit->time.paused);
635 transit->time.paused = 0;
640 elm_transit_paused_get(const Elm_Transit *transit)
642 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
644 if (transit->time.paused == 0)
651 elm_transit_progress_value_get(const Elm_Transit *transit)
653 ELM_TRANSIT_CHECK_OR_RETURN(transit, 0);
655 return transit->progress;
659 elm_transit_objects_final_state_keep_set(Elm_Transit *transit, Eina_Bool state_keep)
661 ELM_TRANSIT_CHECK_OR_RETURN(transit);
663 if (transit->state_keep == state_keep) return;
664 if (transit->animator)
666 WRN("elm_transit does not allow to change final state keep mode in operating! : transit=%p", transit);
669 transit->state_keep = !!state_keep;
673 elm_transit_objects_final_state_keep_get(const Elm_Transit *transit)
675 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
676 return transit->state_keep;
680 elm_transit_chain_transit_add(Elm_Transit *transit, Elm_Transit *chain_transit)
682 ELM_TRANSIT_CHECK_OR_RETURN(transit);
683 ELM_TRANSIT_CHECK_OR_RETURN(chain_transit);
685 if (transit == chain_transit)
687 WRN("You add a same transit as a chain transit! : transit=%p, chain_transit=%p", transit, chain_transit);
690 if (transit == chain_transit->prev_chain_transit)
693 if (chain_transit->prev_chain_transit)
694 chain_transit->prev_chain_transit->next_chain_transits = eina_list_remove(chain_transit->prev_chain_transit->next_chain_transits, chain_transit);
696 chain_transit->prev_chain_transit = transit;
697 transit->next_chain_transits = eina_list_append(transit->next_chain_transits, chain_transit);
701 elm_transit_chain_transit_del(Elm_Transit *transit, Elm_Transit *chain_transit)
703 ELM_TRANSIT_CHECK_OR_RETURN(transit);
704 ELM_TRANSIT_CHECK_OR_RETURN(chain_transit);
706 if (chain_transit->prev_chain_transit != transit)
708 WRN("A pair of transits does not have the chain relationship! : transit=%p, chain_transit=%p", transit, chain_transit);
712 chain_transit->prev_chain_transit = NULL;
713 transit->next_chain_transits = eina_list_remove(transit->next_chain_transits, chain_transit);
717 elm_transit_chain_transits_get(const Elm_Transit * transit)
719 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
720 return transit->next_chain_transits;
723 ///////////////////////////////////////////////////////////////////////////
725 ///////////////////////////////////////////////////////////////////////////
726 typedef struct _Elm_Transit_Effect_Resizing Elm_Transit_Effect_Resizing;
728 struct _Elm_Transit_Effect_Resizing
736 _transit_effect_resizing_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
738 Elm_Transit_Effect_Resizing *resizing = effect;
743 _transit_effect_resizing_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
745 EINA_SAFETY_ON_NULL_RETURN(effect);
746 EINA_SAFETY_ON_NULL_RETURN(transit);
750 Elm_Transit_Effect_Resizing *resizing = effect;
752 w = resizing->from.w + (resizing->to.w * progress);
753 h = resizing->from.h + (resizing->to.h * progress);
755 EINA_LIST_FOREACH(transit->objs, elist, obj)
756 evas_object_resize(obj, w, h);
759 static Elm_Transit_Effect *
760 _transit_effect_resizing_context_new(Evas_Coord from_w, Evas_Coord from_h, Evas_Coord to_w, Evas_Coord to_h)
762 Elm_Transit_Effect_Resizing *resizing;
764 resizing = ELM_NEW(Elm_Transit_Effect_Resizing);
765 if (!resizing) return NULL;
767 resizing->from.w = from_w;
768 resizing->from.h = from_h;
769 resizing->to.w = to_w - from_w;
770 resizing->to.h = to_h - from_h;
775 EAPI Elm_Transit_Effect *
776 elm_transit_effect_resizing_add(Elm_Transit *transit, Evas_Coord from_w, Evas_Coord from_h, Evas_Coord to_w, Evas_Coord to_h)
778 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
779 Elm_Transit_Effect *effect = _transit_effect_resizing_context_new(from_w, from_h, to_w, to_h);
783 ERR("Failed to allocate resizing effect! : transit=%p", transit);
786 elm_transit_effect_add(transit,
787 _transit_effect_resizing_op, effect,
788 _transit_effect_resizing_context_free);
792 ///////////////////////////////////////////////////////////////////////////
794 ///////////////////////////////////////////////////////////////////////////
795 typedef struct _Elm_Transit_Effect_Translation Elm_Transit_Effect_Translation;
796 typedef struct _Elm_Transit_Effect_Translation_Node Elm_Transit_Effect_Translation_Node;
798 struct _Elm_Transit_Effect_Translation_Node
804 struct _Elm_Transit_Effect_Translation
806 struct _position_variation {
813 _translation_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
815 Elm_Transit_Effect_Translation *translation = data;
817 Elm_Transit_Effect_Translation_Node *translation_node;
819 EINA_LIST_FOREACH(translation->nodes, elist, translation_node)
821 if (translation_node->obj != obj) continue;
822 translation->nodes = eina_list_remove_list(translation->nodes, elist);
823 free(translation_node);
829 _translation_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Translation *translation)
831 Elm_Transit_Effect_Translation_Node *translation_node;
832 const Eina_List *elist;
834 Eina_List *data_list = NULL;
835 const Eina_List *objs = elm_transit_objects_get(transit);
837 EINA_LIST_FOREACH(objs, elist, obj)
839 translation_node = ELM_NEW(Elm_Transit_Effect_Translation_Node);
840 if (!translation_node)
842 eina_list_free(data_list);
845 translation_node->obj = obj;
846 evas_object_geometry_get(obj, &(translation_node->x),
847 &(translation_node->y), NULL, NULL);
848 data_list = eina_list_append(data_list, translation_node);
849 evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
850 _translation_object_del_cb, translation);
856 _transit_effect_translation_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
858 EINA_SAFETY_ON_NULL_RETURN(effect);
859 Elm_Transit_Effect_Translation *translation = effect;
860 Eina_List *elist, *elist_next;
861 Elm_Transit_Effect_Translation_Node *translation_node;
863 EINA_LIST_FOREACH_SAFE(translation->nodes,
864 elist, elist_next, translation_node)
866 evas_object_event_callback_del(translation_node->obj,
867 EVAS_CALLBACK_DEL, _translation_object_del_cb);
868 translation->nodes = eina_list_remove_list(translation->nodes, elist);
869 free(translation_node);
875 _transit_effect_translation_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress __UNUSED__)
877 EINA_SAFETY_ON_NULL_RETURN(effect);
878 EINA_SAFETY_ON_NULL_RETURN(transit);
880 Elm_Transit_Effect_Translation *translation = effect;
881 Elm_Transit_Effect_Translation_Node *translation_node;
884 if (!translation->nodes)
885 translation->nodes = _translation_nodes_build(transit, translation);
887 EINA_LIST_FOREACH(translation->nodes, elist, translation_node)
889 x = translation_node->x + translation->from.dx
890 + (translation->to.dx * progress);
891 y = translation_node->y + translation->from.dy
892 + (translation->to.dy * progress);
893 evas_object_move(translation_node->obj, x, y);
897 static Elm_Transit_Effect *
898 _transit_effect_translation_context_new(Evas_Coord from_dx, Evas_Coord from_dy, Evas_Coord to_dx, Evas_Coord to_dy)
900 Elm_Transit_Effect_Translation *translation;
902 translation = ELM_NEW(Elm_Transit_Effect_Translation);
903 if (!translation) return NULL;
905 translation->from.dx = from_dx;
906 translation->from.dy = from_dy;
907 translation->to.dx = to_dx - from_dx;
908 translation->to.dy = to_dy - from_dy;
913 EAPI Elm_Transit_Effect *
914 elm_transit_effect_translation_add(Elm_Transit *transit, Evas_Coord from_dx, Evas_Coord from_dy, Evas_Coord to_dx, Evas_Coord to_dy)
916 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
917 Elm_Transit_Effect *effect = _transit_effect_translation_context_new(from_dx, from_dy, to_dx, to_dy);
921 ERR("Failed to allocate translation effect! : transit=%p", transit);
924 elm_transit_effect_add(transit,
925 _transit_effect_translation_op, effect,
926 _transit_effect_translation_context_free);
930 ///////////////////////////////////////////////////////////////////////////
932 ///////////////////////////////////////////////////////////////////////////
933 typedef struct _Elm_Transit_Effect_Zoom Elm_Transit_Effect_Zoom;
935 struct _Elm_Transit_Effect_Zoom
941 _transit_effect_zoom_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
943 Elm_Transit_Effect_Zoom *zoom = effect;
948 _transit_effect_zoom_op(Elm_Transit_Effect *effect, Elm_Transit *transit , double progress)
950 EINA_SAFETY_ON_NULL_RETURN(effect);
951 EINA_SAFETY_ON_NULL_RETURN(transit);
954 Elm_Transit_Effect_Zoom *zoom = effect;
956 Evas_Coord x, y, w, h;
958 map = evas_map_new(4);
961 EINA_LIST_FOREACH(transit->objs, elist, obj)
963 evas_object_geometry_get(obj, &x, &y, &w, &h);
964 evas_map_util_points_populate_from_object_full(map, obj, zoom->from +
965 (progress * zoom->to));
966 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, _TRANSIT_FOCAL);
967 evas_object_map_set(obj, map);
968 evas_object_map_enable_set(obj, EINA_TRUE);
973 static Elm_Transit_Effect *
974 _transit_effect_zoom_context_new(float from_rate, float to_rate)
976 Elm_Transit_Effect_Zoom *zoom;
978 zoom = ELM_NEW(Elm_Transit_Effect_Zoom);
979 if (!zoom) return NULL;
981 zoom->from = (_TRANSIT_FOCAL - (from_rate * _TRANSIT_FOCAL)) * (1 / from_rate);
982 zoom->to = ((_TRANSIT_FOCAL - (to_rate * _TRANSIT_FOCAL)) * (1 / to_rate)) - zoom->from;
987 EAPI Elm_Transit_Effect *
988 elm_transit_effect_zoom_add(Elm_Transit *transit, float from_rate, float to_rate)
990 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
991 Elm_Transit_Effect *effect = _transit_effect_zoom_context_new(from_rate, to_rate);
995 ERR("Failed to allocate zoom effect! : transit=%p", transit);
998 elm_transit_effect_add(transit,
999 _transit_effect_zoom_op, effect,
1000 _transit_effect_zoom_context_free);
1004 ///////////////////////////////////////////////////////////////////////////
1006 ///////////////////////////////////////////////////////////////////////////
1007 typedef struct _Elm_Transit_Effect_Flip Elm_Transit_Effect_Flip;
1009 struct _Elm_Transit_Effect_Flip
1011 Elm_Transit_Effect_Flip_Axis axis;
1016 _transit_effect_flip_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit)
1018 EINA_SAFETY_ON_NULL_RETURN(effect);
1019 EINA_SAFETY_ON_NULL_RETURN(transit);
1020 Elm_Transit_Effect_Flip *flip = effect;
1021 Evas_Object *front, *back;
1023 int count = eina_list_count(transit->objs);
1025 for (i = 0; i < (count - 1); i += 2)
1027 front = eina_list_nth(transit->objs, i);
1028 back = eina_list_nth(transit->objs, i+1);
1029 evas_object_map_enable_set(front, EINA_FALSE);
1030 evas_object_map_enable_set(back, EINA_FALSE);
1036 _transit_effect_flip_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
1038 EINA_SAFETY_ON_NULL_RETURN(effect);
1039 EINA_SAFETY_ON_NULL_RETURN(transit);
1040 Evas_Object *obj, *front, *back;
1042 Elm_Transit_Effect_Flip *flip = effect;
1045 Evas_Coord x, y, w, h;
1047 map = evas_map_new(4);
1050 if (flip->cw) degree = (float)(progress * 180);
1051 else degree = (float)(progress * -180);
1053 count = eina_list_count(transit->objs);
1055 for (i = 0; i < (count - 1); i += 2)
1057 Evas_Coord half_w, half_h;
1059 front = eina_list_nth(transit->objs, i);
1060 back = eina_list_nth(transit->objs, i+1);
1062 if ((degree < 90) && (degree > -90))
1067 evas_object_hide(back);
1068 evas_object_show(front);
1076 evas_object_hide(front);
1077 evas_object_show(back);
1081 evas_map_util_points_populate_from_object_full(map, obj, 0);
1082 evas_object_geometry_get(obj, &x, &y, &w, &h);
1086 if (flip->axis == ELM_TRANSIT_EFFECT_FLIP_AXIS_Y)
1088 if ((degree >= 90) || (degree <= -90))
1090 evas_map_point_image_uv_set(map, 0, w, 0);
1091 evas_map_point_image_uv_set(map, 1, 0, 0);
1092 evas_map_point_image_uv_set(map, 2, 0, h);
1093 evas_map_point_image_uv_set(map, 3, w, h);
1095 evas_map_util_3d_rotate(map, 0, degree,
1096 0, x + half_w, y + half_h, 0);
1100 if ((degree >= 90) || (degree <= -90))
1102 evas_map_point_image_uv_set(map, 0, 0, h);
1103 evas_map_point_image_uv_set(map, 1, w, h);
1104 evas_map_point_image_uv_set(map, 2, w, 0);
1105 evas_map_point_image_uv_set(map, 3, 0, 0);
1107 evas_map_util_3d_rotate(map, degree,
1108 0, 0, x + half_w, y + half_h, 0);
1110 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, _TRANSIT_FOCAL);
1111 evas_object_map_enable_set(front, EINA_TRUE);
1112 evas_object_map_enable_set(back, EINA_TRUE);
1113 evas_object_map_set(obj, map);
1118 static Elm_Transit_Effect *
1119 _transit_effect_flip_context_new(Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1121 Elm_Transit_Effect_Flip *flip;
1123 flip = ELM_NEW(Elm_Transit_Effect_Flip);
1124 if (!flip) return NULL;
1132 EAPI Elm_Transit_Effect *
1133 elm_transit_effect_flip_add(Elm_Transit *transit, Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1135 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1136 Elm_Transit_Effect *effect = _transit_effect_flip_context_new(axis, cw);
1140 ERR("Failed to allocate flip effect! : transit=%p", transit);
1143 elm_transit_effect_add(transit,
1144 _transit_effect_flip_op, effect,
1145 _transit_effect_flip_context_free);
1149 ///////////////////////////////////////////////////////////////////////////
1150 //ResizableFlip Effect
1151 ///////////////////////////////////////////////////////////////////////////
1152 typedef struct _Elm_Transit_Effect_Resizable_Flip Elm_Transit_Effect_ResizableFlip;
1153 typedef struct _Elm_Transit_Effect_Resizable_Flip_Node Elm_Transit_Effect_ResizableFlip_Node;
1155 struct _Elm_Transit_Effect_Resizable_Flip_Node
1161 } from_pos, from_size, to_pos, to_size;
1164 struct _Elm_Transit_Effect_Resizable_Flip
1168 Elm_Transit_Effect_Flip_Axis axis;
1172 _resizable_flip_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1174 Elm_Transit_Effect_ResizableFlip *resizable_flip = data;
1176 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1178 EINA_LIST_FOREACH(resizable_flip->nodes, elist, resizable_flip_node)
1180 if (resizable_flip_node->front == obj)
1181 evas_object_event_callback_del(resizable_flip_node->back,
1182 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1183 else if (resizable_flip_node->back == obj)
1184 evas_object_event_callback_del(resizable_flip_node->front,
1185 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1188 resizable_flip->nodes = eina_list_remove_list(resizable_flip->nodes,
1190 free(resizable_flip_node);
1196 _resizable_flip_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_ResizableFlip *resizable_flip)
1198 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1199 Eina_List *data_list = NULL;
1200 Evas_Coord front_x, front_y, front_w, front_h;
1201 Evas_Coord back_x, back_y, back_w, back_h;
1204 count = eina_list_count(transit->objs);
1205 for (i = 0; i < (count - 1); i += 2)
1207 resizable_flip_node = ELM_NEW(Elm_Transit_Effect_ResizableFlip_Node);
1208 if (!resizable_flip_node)
1210 eina_list_free(data_list);
1214 resizable_flip_node->front = eina_list_nth(transit->objs, i);
1215 resizable_flip_node->back = eina_list_nth(transit->objs, i+1);
1217 evas_object_geometry_get(resizable_flip_node->front,
1218 &front_x, &front_y, &front_w, &front_h);
1219 evas_object_geometry_get(resizable_flip_node->back,
1220 &back_x, &back_y, &back_w, &back_h);
1222 resizable_flip_node->from_pos.x = front_x;
1223 resizable_flip_node->from_pos.y = front_y;
1224 resizable_flip_node->to_pos.x = back_x - front_x;
1225 resizable_flip_node->to_pos.y = back_y - front_y;
1227 resizable_flip_node->from_size.x = front_w;
1228 resizable_flip_node->from_size.y = front_h;
1229 resizable_flip_node->to_size.x = back_w - front_w;
1230 resizable_flip_node->to_size.y = back_h - front_h;
1232 data_list = eina_list_append(data_list, resizable_flip_node);
1234 evas_object_event_callback_add(resizable_flip_node->back,
1235 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb, resizable_flip);
1236 evas_object_event_callback_add(resizable_flip_node->front,
1237 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb, resizable_flip);
1244 _set_image_uv_by_axis_y(Evas_Map *map, Elm_Transit_Effect_ResizableFlip_Node *flip, float degree)
1246 if ((degree >= 90) || (degree <= -90))
1248 evas_map_point_image_uv_set(map, 0,
1249 (flip->from_size.x * 2) + flip->to_size.x,
1251 evas_map_point_image_uv_set(map, 1, 0, 0);
1252 evas_map_point_image_uv_set(map, 2, 0,
1253 (flip->from_size.y * 2) + flip->to_size.y);
1254 evas_map_point_image_uv_set(map, 3,
1255 (flip->from_size.x * 2) + flip->to_size.x,
1256 (flip->from_size.y * 2) + flip->to_size.y);
1260 evas_map_point_image_uv_set(map, 0, 0, 0);
1261 evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
1262 evas_map_point_image_uv_set(map, 2, flip->from_size.x,
1264 evas_map_point_image_uv_set(map, 3, 0, flip->from_size.y);
1269 _set_image_uv_by_axis_x(Evas_Map *map, Elm_Transit_Effect_ResizableFlip_Node *flip, float degree)
1271 if ((degree >= 90) || (degree <= -90))
1273 evas_map_point_image_uv_set(map, 0, 0,
1274 (flip->from_size.y * 2) + flip->to_size.y);
1275 evas_map_point_image_uv_set(map, 1,
1276 (flip->from_size.x * 2) + flip->to_size.x,
1277 (flip->from_size.y * 2) + flip->to_size.y);
1278 evas_map_point_image_uv_set(map, 2,
1279 (flip->from_size.x * 2) + flip->to_size.x,
1281 evas_map_point_image_uv_set(map, 3, 0, 0);
1285 evas_map_point_image_uv_set(map, 0, 0, 0);
1286 evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
1287 evas_map_point_image_uv_set(map, 2, flip->from_size.x,
1289 evas_map_point_image_uv_set(map, 3, 0, flip->from_size.y);
1294 _transit_effect_resizable_flip_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
1296 EINA_SAFETY_ON_NULL_RETURN(effect);
1298 Elm_Transit_Effect_ResizableFlip *resizable_flip = effect;
1299 Eina_List *elist, *elist_next;
1300 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1302 EINA_LIST_FOREACH_SAFE(resizable_flip->nodes,
1303 elist, elist_next, resizable_flip_node)
1305 evas_object_map_enable_set(resizable_flip_node->front, EINA_FALSE);
1306 evas_object_map_enable_set(resizable_flip_node->back, EINA_FALSE);
1308 resizable_flip->nodes = eina_list_remove_list(resizable_flip->nodes,
1311 evas_object_event_callback_del(resizable_flip_node->back,
1312 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1313 evas_object_event_callback_del(resizable_flip_node->front,
1314 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1315 free(resizable_flip_node);
1317 free(resizable_flip);
1321 _transit_effect_resizable_flip_op(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__, double progress)
1323 EINA_SAFETY_ON_NULL_RETURN(effect);
1328 Evas_Coord half_w, half_h;
1329 Elm_Transit_Effect_ResizableFlip *resizable_flip = effect;
1330 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1333 map = evas_map_new(4);
1336 if (resizable_flip->cw) degree = (float)(progress * 180);
1337 else degree = (float)(progress * -180);
1339 if (!resizable_flip->nodes)
1340 resizable_flip->nodes = _resizable_flip_nodes_build(transit,
1343 EINA_LIST_FOREACH(resizable_flip->nodes, elist, resizable_flip_node)
1345 if ((degree < 90) && (degree > -90))
1347 obj = resizable_flip_node->front;
1348 if (resizable_flip_node->front != resizable_flip_node->back)
1350 evas_object_hide(resizable_flip_node->back);
1351 evas_object_show(resizable_flip_node->front);
1356 obj = resizable_flip_node->back;
1357 if (resizable_flip_node->front != resizable_flip_node->back)
1359 evas_object_hide(resizable_flip_node->front);
1360 evas_object_show(resizable_flip_node->back);
1364 x = resizable_flip_node->from_pos.x +
1365 (resizable_flip_node->to_pos.x * progress);
1366 y = resizable_flip_node->from_pos.y +
1367 (resizable_flip_node->to_pos.y * progress);
1368 w = resizable_flip_node->from_size.x +
1369 (resizable_flip_node->to_size.x * progress);
1370 h = resizable_flip_node->from_size.y +
1371 (resizable_flip_node->to_size.y * progress);
1372 evas_map_point_coord_set(map, 0, x, y, 0);
1373 evas_map_point_coord_set(map, 1, x + w, y, 0);
1374 evas_map_point_coord_set(map, 2, x + w, y + h, 0);
1375 evas_map_point_coord_set(map, 3, x, y + h, 0);
1377 half_w = (Evas_Coord)(w / 2);
1378 half_h = (Evas_Coord)(h / 2);
1380 if (resizable_flip->axis == ELM_TRANSIT_EFFECT_FLIP_AXIS_Y)
1382 _set_image_uv_by_axis_y(map, resizable_flip_node, degree);
1383 evas_map_util_3d_rotate(map, 0, degree,
1384 0, x + half_w, y + half_h, 0);
1388 _set_image_uv_by_axis_x(map, resizable_flip_node, degree);
1389 evas_map_util_3d_rotate(map, degree, 0,
1390 0, x + half_w, y + half_h, 0);
1393 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, _TRANSIT_FOCAL);
1394 evas_object_map_enable_set(resizable_flip_node->front, EINA_TRUE);
1395 evas_object_map_enable_set(resizable_flip_node->back, EINA_TRUE);
1396 evas_object_map_set(obj, map);
1401 static Elm_Transit_Effect *
1402 _transit_effect_resizable_flip_context_new(Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1404 Elm_Transit_Effect_ResizableFlip *resizable_flip;
1406 resizable_flip = ELM_NEW(Elm_Transit_Effect_ResizableFlip);
1407 if (!resizable_flip) return NULL;
1409 resizable_flip->cw = cw;
1410 resizable_flip->axis = axis;
1412 return resizable_flip;
1415 EAPI Elm_Transit_Effect *
1416 elm_transit_effect_resizable_flip_add(Elm_Transit *transit, Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1418 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1419 Elm_Transit_Effect *effect = _transit_effect_resizable_flip_context_new(axis, cw);
1423 ERR("Failed to allocate resizable_flip effect! : transit=%p", transit);
1426 elm_transit_effect_add(transit,
1427 _transit_effect_resizable_flip_op, effect,
1428 _transit_effect_resizable_flip_context_free);
1432 ///////////////////////////////////////////////////////////////////////////
1434 ///////////////////////////////////////////////////////////////////////////
1435 typedef struct _Elm_Transit_Effect_Wipe Elm_Transit_Effect_Wipe;
1437 struct _Elm_Transit_Effect_Wipe
1439 Elm_Transit_Effect_Wipe_Type type;
1440 Elm_Transit_Effect_Wipe_Dir dir;
1444 _elm_fx_wipe_hide(Evas_Map * map, Elm_Transit_Effect_Wipe_Dir dir, float x, float y, float w, float h, float progress)
1450 case ELM_TRANSIT_EFFECT_WIPE_DIR_LEFT:
1451 w2 = w - (w * progress);
1453 evas_map_point_image_uv_set(map, 0, 0, 0);
1454 evas_map_point_image_uv_set(map, 1, w2, 0);
1455 evas_map_point_image_uv_set(map, 2, w2, h);
1456 evas_map_point_image_uv_set(map, 3, 0, h);
1457 evas_map_point_coord_set(map, 0, x, y, 0);
1458 evas_map_point_coord_set(map, 1, x + w2, y, 0);
1459 evas_map_point_coord_set(map, 2, x + w2, h2, 0);
1460 evas_map_point_coord_set(map, 3, x, h2, 0);
1462 case ELM_TRANSIT_EFFECT_WIPE_DIR_RIGHT:
1463 w2 = (w * progress);
1465 evas_map_point_image_uv_set(map, 0, w2, 0);
1466 evas_map_point_image_uv_set(map, 1, w, 0);
1467 evas_map_point_image_uv_set(map, 2, w, h);
1468 evas_map_point_image_uv_set(map, 3, w2, h);
1469 evas_map_point_coord_set(map, 0, x + w2, y, 0);
1470 evas_map_point_coord_set(map, 1, x + w, y, 0);
1471 evas_map_point_coord_set(map, 2, x + w, h2, 0);
1472 evas_map_point_coord_set(map, 3, x + w2, h2, 0);
1474 case ELM_TRANSIT_EFFECT_WIPE_DIR_UP:
1476 h2 = h - (h * progress);
1477 evas_map_point_image_uv_set(map, 0, 0, 0);
1478 evas_map_point_image_uv_set(map, 1, w, 0);
1479 evas_map_point_image_uv_set(map, 2, w, h2);
1480 evas_map_point_image_uv_set(map, 3, 0, h2);
1481 evas_map_point_coord_set(map, 0, x, y, 0);
1482 evas_map_point_coord_set(map, 1, w2, y, 0);
1483 evas_map_point_coord_set(map, 2, w2, y+h2, 0);
1484 evas_map_point_coord_set(map, 3, x, y+h2, 0);
1486 case ELM_TRANSIT_EFFECT_WIPE_DIR_DOWN:
1488 h2 = (h * progress);
1489 evas_map_point_image_uv_set(map, 0, 0, h2);
1490 evas_map_point_image_uv_set(map, 1, w, h2);
1491 evas_map_point_image_uv_set(map, 2, w, h);
1492 evas_map_point_image_uv_set(map, 3, 0, h);
1493 evas_map_point_coord_set(map, 0, x, y + h2, 0);
1494 evas_map_point_coord_set(map, 1, w2, y + h2, 0);
1495 evas_map_point_coord_set(map, 2, w2, y + h, 0);
1496 evas_map_point_coord_set(map, 3, x, y + h, 0);
1501 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, _TRANSIT_FOCAL);
1505 _elm_fx_wipe_show(Evas_Map *map, Elm_Transit_Effect_Wipe_Dir dir, float x, float y, float w, float h, float progress)
1511 case ELM_TRANSIT_EFFECT_WIPE_DIR_LEFT:
1512 w2 = (w - (w * progress));
1514 evas_map_point_image_uv_set(map, 0, w2, 0);
1515 evas_map_point_image_uv_set(map, 1, w, 0);
1516 evas_map_point_image_uv_set(map, 2, w, h);
1517 evas_map_point_image_uv_set(map, 3, w2, h);
1518 evas_map_point_coord_set(map, 0, x + w2, y, 0);
1519 evas_map_point_coord_set(map, 1, w, y, 0);
1520 evas_map_point_coord_set(map, 2, w, h2, 0);
1521 evas_map_point_coord_set(map, 3, x + w2, h2, 0);
1523 case ELM_TRANSIT_EFFECT_WIPE_DIR_RIGHT:
1524 w2 = (w * progress);
1526 evas_map_point_image_uv_set(map, 0, 0, 0);
1527 evas_map_point_image_uv_set(map, 1, w2, 0);
1528 evas_map_point_image_uv_set(map, 2, w2, h);
1529 evas_map_point_image_uv_set(map, 3, 0, h);
1530 evas_map_point_coord_set(map, 0, x, y, 0);
1531 evas_map_point_coord_set(map, 1, x + w2, y, 0);
1532 evas_map_point_coord_set(map, 2, x + w2, h2, 0);
1533 evas_map_point_coord_set(map, 3, x, h2, 0);
1535 case ELM_TRANSIT_EFFECT_WIPE_DIR_UP:
1537 h2 = (h - (h * progress));
1538 evas_map_point_image_uv_set(map, 0, 0, h2);
1539 evas_map_point_image_uv_set(map, 1, w, h2);
1540 evas_map_point_image_uv_set(map, 2, w, h);
1541 evas_map_point_image_uv_set(map, 3, 0, h);
1542 evas_map_point_coord_set(map, 0, x, y + h2, 0);
1543 evas_map_point_coord_set(map, 1, w2, y + h2, 0);
1544 evas_map_point_coord_set(map, 2, w2, y + h, 0);
1545 evas_map_point_coord_set(map, 3, x, y + h, 0);
1547 case ELM_TRANSIT_EFFECT_WIPE_DIR_DOWN:
1549 h2 = (h * progress);
1550 evas_map_point_image_uv_set(map, 0, 0, 0);
1551 evas_map_point_image_uv_set(map, 1, w, 0);
1552 evas_map_point_image_uv_set(map, 2, w, h2);
1553 evas_map_point_image_uv_set(map, 3, 0, h2);
1554 evas_map_point_coord_set(map, 0, x, y, 0);
1555 evas_map_point_coord_set(map, 1, w2, y, 0);
1556 evas_map_point_coord_set(map, 2, w2, y + h2, 0);
1557 evas_map_point_coord_set(map, 3, x, y + h2, 0);
1562 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, _TRANSIT_FOCAL);
1566 _transit_effect_wipe_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit)
1568 EINA_SAFETY_ON_NULL_RETURN(effect);
1569 EINA_SAFETY_ON_NULL_RETURN(transit);
1572 Elm_Transit_Effect_Wipe *wipe = effect;
1573 Eina_Bool reverse = elm_transit_auto_reverse_get(transit);
1575 EINA_LIST_FOREACH(transit->objs, elist, obj)
1577 if ((wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_SHOW && !reverse)
1578 || (wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_HIDE && reverse))
1579 evas_object_show(obj);
1580 else evas_object_hide(obj);
1581 evas_object_map_enable_set(obj, EINA_FALSE);
1588 _transit_effect_wipe_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
1590 EINA_SAFETY_ON_NULL_RETURN(effect);
1591 EINA_SAFETY_ON_NULL_RETURN(transit);
1592 Elm_Transit_Effect_Wipe *wipe = effect;
1594 Evas_Coord _x, _y, _w, _h;
1598 map = evas_map_new(4);
1601 EINA_LIST_FOREACH(transit->objs, elist, obj)
1603 evas_object_geometry_get(obj, &_x, &_y, &_w, &_h);
1605 if (wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_SHOW)
1606 _elm_fx_wipe_show(map, wipe->dir, _x, _y, _w, _h, (float)progress);
1608 _elm_fx_wipe_hide(map, wipe->dir, _x, _y, _w, _h, (float)progress);
1610 evas_object_map_enable_set(obj, EINA_TRUE);
1611 evas_object_map_set(obj, map);
1616 static Elm_Transit_Effect *
1617 _transit_effect_wipe_context_new(Elm_Transit_Effect_Wipe_Type type, Elm_Transit_Effect_Wipe_Dir dir)
1619 Elm_Transit_Effect_Wipe *wipe;
1621 wipe = ELM_NEW(Elm_Transit_Effect_Wipe);
1622 if (!wipe) return NULL;
1631 elm_transit_effect_wipe_add(Elm_Transit *transit, Elm_Transit_Effect_Wipe_Type type, Elm_Transit_Effect_Wipe_Dir dir)
1633 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1634 void *effect = _transit_effect_wipe_context_new(type, dir);
1638 ERR("Failed to allocate wipe effect! : transit=%p", transit);
1641 elm_transit_effect_add(transit,
1642 _transit_effect_wipe_op, effect,
1643 _transit_effect_wipe_context_free);
1647 ///////////////////////////////////////////////////////////////////////////
1649 ///////////////////////////////////////////////////////////////////////////
1650 typedef struct _Elm_Transit_Effect_Color Elm_Transit_Effect_Color;
1652 struct _Elm_Transit_Effect_Color
1654 struct _unsigned_color {
1655 unsigned int r, g, b, a;
1657 struct _signed_color {
1663 _transit_effect_color_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
1665 Elm_Transit_Effect_Color *color = effect;
1670 _transit_effect_color_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
1672 EINA_SAFETY_ON_NULL_RETURN(effect);
1673 EINA_SAFETY_ON_NULL_RETURN(transit);
1674 Elm_Transit_Effect_Color *color = effect;
1677 unsigned int r, g, b, a;
1679 r = (color->from.r + (int)((float)color->to.r * progress));
1680 g = (color->from.g + (int)((float)color->to.g * progress));
1681 b = (color->from.b + (int)((float)color->to.b * progress));
1682 a = (color->from.a + (int)((float)color->to.a * progress));
1684 EINA_LIST_FOREACH(transit->objs, elist, obj)
1685 evas_object_color_set(obj, r, g, b, a);
1688 static Elm_Transit_Effect *
1689 _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)
1691 Elm_Transit_Effect_Color *color;
1693 color = ELM_NEW(Elm_Transit_Effect_Color);
1694 if (!color) return NULL;
1696 color->from.r = from_r;
1697 color->from.g = from_g;
1698 color->from.b = from_b;
1699 color->from.a = from_a;
1700 color->to.r = to_r - from_r;
1701 color->to.g = to_g - from_g;
1702 color->to.b = to_b - from_b;
1703 color->to.a = to_a - from_a;
1708 EAPI Elm_Transit_Effect *
1709 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)
1711 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1712 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);
1716 ERR("Failed to allocate color effect! : transit=%p", transit);
1719 elm_transit_effect_add(transit,
1720 _transit_effect_color_op, effect,
1721 _transit_effect_color_context_free);
1725 ///////////////////////////////////////////////////////////////////////////
1727 ///////////////////////////////////////////////////////////////////////////
1728 typedef struct _Elm_Transit_Effect_Fade Elm_Transit_Effect_Fade;
1729 typedef struct _Elm_Transit_Effect_Fade_Node Elm_Transit_Effect_Fade_Node;
1731 struct _Elm_Transit_Effect_Fade_Node
1733 Evas_Object *before;
1735 struct _signed_color before_color, after_color;
1738 Eina_Bool inversed : 1;
1741 struct _Elm_Transit_Effect_Fade
1747 _fade_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1749 Elm_Transit_Effect_Fade *fade = data;
1751 Elm_Transit_Effect_Fade_Node *fade_node;
1753 EINA_LIST_FOREACH(fade->nodes, elist, fade_node)
1755 if (fade_node->before == obj)
1756 evas_object_event_callback_del(fade_node->after,
1757 EVAS_CALLBACK_DEL, _fade_object_del_cb);
1758 else if (fade_node->after == obj)
1759 evas_object_event_callback_del(fade_node->before,
1760 EVAS_CALLBACK_DEL, _fade_object_del_cb);
1763 fade->nodes = eina_list_remove_list(fade->nodes, elist);
1770 _fade_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Fade *fade_data)
1772 Elm_Transit_Effect_Fade_Node *fade;
1773 Eina_List *data_list = NULL;
1776 count = eina_list_count(transit->objs);
1777 for (i = 0; i < count; i += 2)
1779 fade = ELM_NEW(Elm_Transit_Effect_Fade_Node);
1782 eina_list_free(data_list);
1786 fade->before = eina_list_nth(transit->objs, i);
1787 fade->after = eina_list_nth(transit->objs, i+1);
1789 evas_object_color_get(fade->before,
1790 &fade->before_color.r, &fade->before_color.g,
1791 &fade->before_color.b, &fade->before_color.a);
1792 evas_object_color_get(fade->after,
1793 &fade->after_color.r, &fade->after_color.g,
1794 &fade->after_color.b, &fade->after_color.a);
1796 fade->before_alpha = (255 - fade->before_color.a);
1797 fade->after_alpha = (255 - fade->after_color.a);
1799 data_list = eina_list_append(data_list, fade);
1801 evas_object_event_callback_add(fade->before,
1802 EVAS_CALLBACK_DEL, _fade_object_del_cb, fade_data);
1803 evas_object_event_callback_add(fade->after,
1804 EVAS_CALLBACK_DEL, _fade_object_del_cb, fade_data);
1810 _transit_effect_fade_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
1812 EINA_SAFETY_ON_NULL_RETURN(effect);
1813 Elm_Transit_Effect_Fade *fade = effect;
1814 Elm_Transit_Effect_Fade_Node *fade_node;
1815 Eina_List *elist, *elist_next;
1817 EINA_LIST_FOREACH_SAFE(fade->nodes, elist, elist_next, fade_node)
1819 evas_object_color_set(fade_node->before, fade_node->before_color.r,
1820 fade_node->before_color.g,
1821 fade_node->before_color.b,
1822 fade_node->before_color.a);
1823 evas_object_color_set(fade_node->after, fade_node->after_color.r,
1824 fade_node->after_color.g,
1825 fade_node->after_color.b,
1826 fade_node->after_color.a);
1828 fade->nodes = eina_list_remove_list(fade->nodes, elist);
1829 evas_object_event_callback_del(fade_node->before,
1830 EVAS_CALLBACK_DEL, _fade_object_del_cb);
1831 evas_object_event_callback_del(fade_node->after,
1832 EVAS_CALLBACK_DEL, _fade_object_del_cb);
1840 _transit_effect_fade_op(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__, double progress)
1842 EINA_SAFETY_ON_NULL_RETURN(effect);
1843 Elm_Transit_Effect_Fade *fade = effect;
1845 Elm_Transit_Effect_Fade_Node *fade_node;
1849 fade->nodes = _fade_nodes_build(transit, fade);
1851 EINA_LIST_FOREACH(fade->nodes, elist, fade_node)
1855 if (!fade_node->inversed)
1857 evas_object_hide(fade_node->after);
1858 evas_object_show(fade_node->before);
1859 fade_node->inversed = EINA_TRUE;
1862 _progress = (1 - (progress * 2));
1864 evas_object_color_set(fade_node->before,
1865 fade_node->before_color.r * _progress,
1866 fade_node->before_color.g * _progress,
1867 fade_node->before_color.b * _progress,
1868 fade_node->before_color.a +
1869 fade_node->before_alpha * (1 - _progress));
1873 if (fade_node->inversed)
1875 evas_object_hide(fade_node->before);
1876 evas_object_show(fade_node->after);
1877 fade_node->inversed = EINA_FALSE;
1880 _progress = ((progress - 0.5) * 2);
1882 evas_object_color_set(fade_node->after,
1883 fade_node->after_color.r * _progress,
1884 fade_node->after_color.g * _progress,
1885 fade_node->after_color.b * _progress,
1886 fade_node->after_color.a +
1887 fade_node->after_alpha * (1 - _progress));
1892 static Elm_Transit_Effect *
1893 _transit_effect_fade_context_new(void)
1895 Elm_Transit_Effect_Fade *fade;
1896 fade = ELM_NEW(Elm_Transit_Effect_Fade);
1897 if (!fade) return NULL;
1901 EAPI Elm_Transit_Effect *
1902 elm_transit_effect_fade_add(Elm_Transit *transit)
1904 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1906 Elm_Transit_Effect *effect = _transit_effect_fade_context_new();
1910 ERR("Failed to allocate fade effect! : transit=%p", transit);
1913 elm_transit_effect_add(transit,
1914 _transit_effect_fade_op, effect,
1915 _transit_effect_fade_context_free);
1919 ///////////////////////////////////////////////////////////////////////////
1921 ///////////////////////////////////////////////////////////////////////////
1922 typedef struct _Elm_Transit_Effect_Blend Elm_Transit_Effect_Blend;
1923 typedef struct _Elm_Transit_Effect_Blend_Node Elm_Transit_Effect_Blend_Node;
1925 struct _Elm_Transit_Effect_Blend_Node
1927 Evas_Object *before;
1929 struct _signed_color from, to;
1932 struct _Elm_Transit_Effect_Blend
1938 _blend_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1940 Elm_Transit_Effect_Blend *blend = data;
1942 Elm_Transit_Effect_Blend_Node *blend_node;
1944 EINA_LIST_FOREACH(blend->nodes, elist, blend_node)
1946 if (blend_node->after == obj)
1947 evas_object_event_callback_del(blend_node->before,
1948 EVAS_CALLBACK_DEL, _blend_object_del_cb);
1949 else if (blend_node->before == obj)
1950 evas_object_event_callback_del(blend_node->after,
1951 EVAS_CALLBACK_DEL, _blend_object_del_cb);
1954 blend->nodes = eina_list_remove_list(blend->nodes, elist);
1961 _blend_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Blend *blend)
1963 Elm_Transit_Effect_Blend_Node *blend_node;
1964 Eina_List *data_list = NULL;
1967 count = eina_list_count(transit->objs);
1968 for (i = 0; i < (count - 1); i += 2)
1970 blend_node = ELM_NEW(Elm_Transit_Effect_Blend_Node);
1973 eina_list_free(data_list);
1977 blend_node->before = eina_list_nth(transit->objs, i);
1978 blend_node->after = eina_list_nth(transit->objs, i + 1);
1979 evas_object_show(blend_node->before);
1980 evas_object_show(blend_node->after);
1982 evas_object_color_get(blend_node->before, &blend_node->from.r,
1983 &blend_node->from.g, &blend_node->from.b,
1984 &blend_node->from.a);
1985 evas_object_color_get(blend_node->after, &blend_node->to.r,
1986 &blend_node->to.g, &blend_node->to.b,
1989 data_list = eina_list_append(data_list, blend_node);
1991 evas_object_event_callback_add(blend_node->before,
1992 EVAS_CALLBACK_DEL, _blend_object_del_cb, blend);
1993 evas_object_event_callback_add(blend_node->after,
1994 EVAS_CALLBACK_DEL, _blend_object_del_cb, blend);
2000 _transit_effect_blend_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
2002 EINA_SAFETY_ON_NULL_RETURN(effect);
2003 Elm_Transit_Effect_Blend *blend = effect;
2004 Elm_Transit_Effect_Blend_Node *blend_node;
2005 Eina_List *elist, *elist_next;
2007 EINA_LIST_FOREACH_SAFE(blend->nodes, elist, elist_next, blend_node)
2009 evas_object_color_set(blend_node->before,
2010 blend_node->from.r, blend_node->from.g,
2011 blend_node->from.b, blend_node->from.a);
2012 evas_object_color_set(blend_node->after, blend_node->to.r,
2013 blend_node->to.g, blend_node->to.b,
2016 if (elm_transit_auto_reverse_get(transit))
2017 evas_object_hide(blend_node->after);
2019 evas_object_hide(blend_node->before);
2021 blend->nodes = eina_list_remove_list(blend->nodes, elist);
2023 evas_object_event_callback_del(blend_node->before,
2024 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2025 evas_object_event_callback_del(blend_node->after,
2026 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2033 _transit_effect_blend_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2035 EINA_SAFETY_ON_NULL_RETURN(effect);
2036 EINA_SAFETY_ON_NULL_RETURN(transit);
2037 Elm_Transit_Effect_Blend *blend = effect;
2038 Elm_Transit_Effect_Blend_Node *blend_node;
2041 if (!blend->nodes) blend->nodes = _blend_nodes_build(transit, blend);
2043 EINA_LIST_FOREACH(blend->nodes, elist, blend_node)
2045 evas_object_color_set(blend_node->before,
2046 (int)(blend_node->from.r * (1 - progress)),
2047 (int)(blend_node->from.g * (1 - progress)),
2048 (int)(blend_node->from.b * (1 - progress)),
2049 (int)(blend_node->from.a * (1 - progress)));
2050 evas_object_color_set(blend_node->after,
2051 (int)(blend_node->to.r * progress),
2052 (int)(blend_node->to.g * progress),
2053 (int)(blend_node->to.b * progress),
2054 (int)(blend_node->to.a * progress));
2058 static Elm_Transit_Effect *
2059 _transit_effect_blend_context_new(void)
2061 Elm_Transit_Effect_Blend *blend;
2063 blend = ELM_NEW(Elm_Transit_Effect_Blend);
2064 if (!blend) return NULL;
2068 EAPI Elm_Transit_Effect *
2069 elm_transit_effect_blend_add(Elm_Transit *transit)
2071 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2072 Elm_Transit_Effect *effect = _transit_effect_blend_context_new();
2076 ERR("Failed to allocate blend effect! : transit=%p", transit);
2079 elm_transit_effect_add(transit,
2080 _transit_effect_blend_op, effect,
2081 _transit_effect_blend_context_free);
2085 ///////////////////////////////////////////////////////////////////////////
2087 ///////////////////////////////////////////////////////////////////////////
2088 typedef struct _Elm_Transit_Effect_Rotation Elm_Transit_Effect_Rotation;
2090 struct _Elm_Transit_Effect_Rotation
2096 _transit_effect_rotation_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
2098 Elm_Transit_Effect_Rotation *rotation = effect;
2103 _transit_effect_rotation_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2105 EINA_SAFETY_ON_NULL_RETURN(effect);
2106 EINA_SAFETY_ON_NULL_RETURN(transit);
2107 Elm_Transit_Effect_Rotation *rotation = effect;
2109 Evas_Coord x, y, w, h;
2111 float half_w, half_h;
2115 map = evas_map_new(4);
2118 EINA_LIST_FOREACH(transit->objs, elist, obj)
2120 evas_map_util_points_populate_from_object_full(map, obj, 0);
2121 degree = rotation->from + (float)(progress * rotation->to);
2123 evas_object_geometry_get(obj, &x, &y, &w, &h);
2125 half_w = (float)w * 0.5;
2126 half_h = (float)h * 0.5;
2128 evas_map_util_rotate(map, degree, x + half_w, y + half_h);
2129 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, _TRANSIT_FOCAL);
2130 evas_object_map_enable_set(obj, EINA_TRUE);
2131 evas_object_map_set(obj, map);
2136 static Elm_Transit_Effect *
2137 _transit_effect_rotation_context_new(float from_degree, float to_degree)
2139 Elm_Transit_Effect_Rotation *rotation;
2141 rotation = ELM_NEW(Elm_Transit_Effect_Rotation);
2142 if (!rotation) return NULL;
2144 rotation->from = from_degree;
2145 rotation->to = to_degree - from_degree;
2150 EAPI Elm_Transit_Effect *
2151 elm_transit_effect_rotation_add(Elm_Transit *transit, float from_degree, float to_degree)
2153 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2154 Elm_Transit_Effect *effect = _transit_effect_rotation_context_new(from_degree, to_degree);
2158 ERR("Failed to allocate rotation effect! : transit=%p", transit);
2161 elm_transit_effect_add(transit,
2162 _transit_effect_rotation_op, effect,
2163 _transit_effect_rotation_context_free);
2167 ///////////////////////////////////////////////////////////////////////////
2168 //ImageAnimation Effect
2169 ///////////////////////////////////////////////////////////////////////////
2170 typedef struct _Elm_Transit_Effect_Image_Animation Elm_Transit_Effect_Image_Animation;
2172 struct _Elm_Transit_Effect_Image_Animation
2178 _transit_effect_image_animation_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
2180 EINA_SAFETY_ON_NULL_RETURN(effect);
2181 Elm_Transit_Effect_Image_Animation *image_animation = effect;
2183 Eina_List *elist, *elist_next;
2185 EINA_LIST_FOREACH_SAFE(image_animation->images, elist, elist_next, image)
2187 image_animation->images =
2188 eina_list_remove_list(image_animation->images, elist);
2189 eina_stringshare_del(image);
2192 free(image_animation);
2196 _transit_effect_image_animation_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2198 EINA_SAFETY_ON_NULL_RETURN(effect);
2199 EINA_SAFETY_ON_NULL_RETURN(transit);
2203 Elm_Transit_Effect_Image_Animation *image_animation = effect;
2204 unsigned int count = 0;
2207 type = eina_stringshare_add("icon");
2208 len = eina_list_count(image_animation->images);
2210 if (!len) count = floor(progress * len);
2211 else count = floor(progress * (len - 1));
2213 EINA_LIST_FOREACH(transit->objs, elist, obj)
2215 if (elm_widget_type_check(obj, type))
2216 elm_icon_file_set(obj,
2217 eina_list_nth(image_animation->images, count), NULL);
2220 eina_stringshare_del(type);
2223 static Elm_Transit_Effect *
2224 _transit_effect_image_animation_context_new(Eina_List *images)
2226 Elm_Transit_Effect_Image_Animation *image_animation;
2227 image_animation = ELM_NEW(Elm_Transit_Effect_Image_Animation);
2229 if (!image_animation) return NULL;
2230 image_animation->images = images;
2231 return image_animation;
2234 EAPI Elm_Transit_Effect *
2235 elm_transit_effect_image_animation_add(Elm_Transit *transit, Eina_List *images)
2237 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2238 Elm_Transit_Effect *effect = _transit_effect_image_animation_context_new(images);
2242 ERR("Failed to allocate image_animation effect! : transit=%p", transit);
2245 elm_transit_effect_add(transit,
2246 _transit_effect_image_animation_op, effect,
2247 _transit_effect_image_animation_context_free);