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!"); \
22 * @defgroup Transit Transit
25 * Transit (see Warning below) is designed to set the various effects for the
26 * Evas_Object such like translation, rotation, etc. For using Effects, Create
27 * transit and insert effects which are interesting.
28 * Once effects are inserted into transit, transit will manage those effects.
33 * Elm_Transit *trans = elm_transit_add();
34 * elm_transit_object_add(trans, obj);
35 * void *effect_context = elm_transit_effect_translation_context_new(0.0, 0.0,
37 * elm_transit_effect_add(transit,
38 * elm_transit_effect_translation_op, effect_context,
39 * elm_transit_effect_translation_context_free);
40 * elm_transit_duration_set(transit, 1);
41 * elm_transit_auto_reverse_set(transit, EINA_TRUE);
42 * elm_transit_tween_mode_set(transit, ELM_TRANSIT_TWEEN_MODE_DECELERATE);
43 * elm_transit_repeat_times_set(transit, 3);
46 * @warning We strongly recomend to use elm_transit just when edje can not do
47 * the trick. Edje has more advantage than Elm_Transit, it has more flexibility and
48 * animations can be manipulated inside the theme.
51 #define _TRANSIT_FOCAL 2000
55 #define ELM_TRANSIT_MAGIC 0xd27f190a
58 Ecore_Animator *animator;
59 Eina_Inlist *effect_list;
61 Eina_Hash *objs_data_hash;
62 Elm_Transit *prev_chain_transit;
63 Eina_List *next_chain_transits;
64 Elm_Transit_Tween_Mode tween_mode;
66 Elm_Transit_Effect_End_Cb func;
82 unsigned int effects_pending_del;
84 Eina_Bool auto_reverse : 1;
85 Eina_Bool event_enabled : 1;
86 Eina_Bool deleted : 1;
87 Eina_Bool state_keep : 1;
90 struct _Elm_Transit_Effect_Module
93 Elm_Transit_Effect_Transition_Cb transition_cb;
94 Elm_Transit_Effect_End_Cb end_cb;
95 Elm_Transit_Effect *effect;
96 Eina_Bool deleted : 1;
101 Evas_Coord x, y, w, h;
104 Eina_Bool map_enabled : 1;
105 Eina_Bool visible : 1;
110 struct _Elm_Obj_State *state;
111 Eina_Bool pass_events : 1;
114 typedef struct _Elm_Transit_Effect_Module Elm_Transit_Effect_Module;
115 typedef struct _Elm_Obj_Data Elm_Obj_Data;
116 typedef struct _Elm_Obj_State Elm_Obj_State;
119 _elm_transit_obj_states_save(Evas_Object *obj, Elm_Obj_Data *obj_data)
121 Elm_Obj_State *state;
123 if (obj_data->state) return;
124 state = calloc(1, sizeof(Elm_Obj_State));
126 evas_object_geometry_get(obj, &state->x, &state->y, &state->w, &state->h);
127 evas_object_color_get(obj, &state->r, &state->g, &state->b, &state->a);
128 state->visible = evas_object_visible_get(obj);
129 state->map_enabled = evas_object_map_enable_get(obj);
130 if (evas_object_map_get(obj))
131 state->map = evas_map_dup(evas_object_map_get(obj));
132 obj_data->state = state;
136 _hash_foreach_pass_events_set(const Eina_Hash *hash __UNUSED__, const void *key, void *data __UNUSED__, void *fdata)
138 Elm_Transit *transit = fdata;
139 evas_object_pass_events_set((Evas_Object*) key, transit->event_enabled);
144 _hash_foreach_obj_states_save(const Eina_Hash *hash __UNUSED__, const void *key, void *data, void *fdata __UNUSED__)
146 _elm_transit_obj_states_save((Evas_Object *) key, (Elm_Obj_Data *) data);
151 _elm_transit_object_remove_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
153 Elm_Transit *transit;
154 Elm_Obj_Data *obj_data;
158 list = eina_list_data_find_list(transit->objs, obj);
159 obj_data = eina_hash_find(transit->objs_data_hash, list);
160 if (!obj_data) return;
161 eina_hash_del_by_key(transit->objs_data_hash, list);
162 evas_object_pass_events_set(obj, obj_data->pass_events);
164 free(obj_data->state);
166 transit->objs = eina_list_remove(transit->objs, obj);
167 if (!transit->objs) elm_transit_del(transit);
171 //Since evas map have a afterimage bug for this time.
172 //This function is added temporary.
174 _obj_damage_area_set(Evas_Object *obj)
177 Evas_Coord_Point coords;
178 Evas_Coord_Point min, max;
181 map = evas_object_map_get(obj);
184 evas_map_point_coord_get(map, 0, &coords.x, &coords.y, NULL);
188 for (i = 1; i < 4; ++i)
190 evas_map_point_coord_get(map, i, &coords.x, &coords.y, NULL);
192 if (coords.x < min.x)
194 else if (coords.x > max.x)
197 if (coords.y < min.y)
199 else if (coords.y > max.y)
203 evas_damage_rectangle_add(evas_object_evas_get(obj),
205 max.x - min.x, max.y - min.y);
209 _remove_obj_from_list(Elm_Transit *transit, Evas_Object *obj)
211 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_DEL,
212 _elm_transit_object_remove_cb,
215 //Remove duplicated objects
216 //TODO: Need to consider about optimizing here
219 if (!eina_list_data_find_list(transit->objs, obj))
221 transit->objs = eina_list_remove(transit->objs, obj);
226 _elm_transit_object_remove(Elm_Transit *transit, Evas_Object *obj)
228 Elm_Obj_Data *obj_data;
229 Elm_Obj_State *state;
232 list = eina_list_data_find_list(transit->objs, obj);
233 obj_data = eina_hash_find(transit->objs_data_hash, list);
236 _remove_obj_from_list(transit, obj);
239 eina_hash_del_by_key(transit->objs_data_hash, list);
240 _remove_obj_from_list(transit, obj);
241 evas_object_pass_events_set(obj, obj_data->pass_events);
242 state = obj_data->state;
245 //recover the states of the object.
246 if (!transit->state_keep)
248 evas_object_move(obj, state->x, state->y);
249 evas_object_resize(obj, state->w, state->h);
250 evas_object_color_set(obj, state->r, state->g, state->b, state->a);
251 if (state->visible) evas_object_show(obj);
252 else evas_object_hide(obj);
253 if (state->map_enabled)
254 evas_object_map_enable_set(obj, EINA_TRUE);
256 evas_object_map_enable_set(obj, EINA_FALSE);
258 evas_object_map_set(obj, state->map);
261 //Since evas map have a afterimage bug for this time.
262 //This line is added temporary.
263 _obj_damage_area_set(obj);
273 _elm_transit_effect_del(Elm_Transit *transit, Elm_Transit_Effect_Module *effect_module)
275 if (effect_module->end_cb)
276 effect_module->end_cb(effect_module->effect, transit);
281 _remove_dead_effects(Elm_Transit *transit)
283 Elm_Transit_Effect_Module *effect_module;
285 EINA_INLIST_FOREACH(transit->effect_list, effect_module)
287 if (effect_module->deleted)
289 _elm_transit_effect_del(transit, effect_module);
290 transit->effects_pending_del--;
291 if (!transit->effects_pending_del) return;
297 _elm_transit_del(Elm_Transit *transit)
299 Elm_Transit_Effect_Module *effect_module;
300 Elm_Transit *chain_transit;
301 Eina_List *elist, *elist_next;
303 EINA_LIST_FOREACH_SAFE(transit->next_chain_transits, elist, elist_next, chain_transit)
305 if (transit->prev_chain_transit)
306 transit->prev_chain_transit->next_chain_transits = eina_list_remove(transit->prev_chain_transit->next_chain_transits, transit);
307 chain_transit->prev_chain_transit = NULL;
310 eina_list_free(transit->next_chain_transits);
312 if (transit->animator)
313 ecore_animator_del(transit->animator);
315 while (transit->effect_list)
317 effect_module = EINA_INLIST_CONTAINER_GET(transit->effect_list, Elm_Transit_Effect_Module);
318 transit->effect_list = eina_inlist_remove(transit->effect_list, transit->effect_list);
321 while (transit->objs)
322 _elm_transit_object_remove(transit, eina_list_data_get(transit->objs));
324 transit->deleted = EINA_TRUE;
326 if (transit->del_data.func)
327 transit->del_data.func(transit->del_data.arg, transit);
329 eina_hash_free(transit->objs_data_hash);
331 EINA_MAGIC_SET(transit, EINA_MAGIC_NONE);
336 _chain_transits_go(Elm_Transit *transit)
338 Eina_List *elist, *elist_next;
339 Elm_Transit *chain_transit;
341 EINA_LIST_FOREACH_SAFE(transit->next_chain_transits, elist, elist_next, chain_transit)
342 elm_transit_go(chain_transit);
346 _transit_animate_op(Elm_Transit *transit, double progress)
348 Elm_Transit_Effect_Module *effect_module;
351 EINA_INLIST_FOREACH(transit->effect_list, effect_module)
353 if (transit->deleted) break;
354 if (!effect_module->deleted)
355 effect_module->transition_cb(effect_module->effect, transit, progress);
359 if (transit->walking) return;
361 if (transit->deleted) _elm_transit_del(transit);
362 else if (transit->effects_pending_del) _remove_dead_effects(transit);
366 _animator_animate_cb(void *data)
368 Elm_Transit *transit = data;
369 double elapsed_time, duration;
371 transit->time.current = ecore_loop_time_get();
372 elapsed_time = transit->time.current - transit->time.begin;
373 duration = transit->time.duration + transit->time.delayed;
375 if (elapsed_time > duration)
376 elapsed_time = duration;
378 transit->progress = elapsed_time / duration;
379 switch (transit->tween_mode)
381 case ELM_TRANSIT_TWEEN_MODE_ACCELERATE:
382 transit->progress = 1.0 - sin((ELM_PI / 2.0) + (transit->progress * ELM_PI / 2.0));
384 case ELM_TRANSIT_TWEEN_MODE_DECELERATE:
385 transit->progress = sin(transit->progress * ELM_PI / 2.0);
387 case ELM_TRANSIT_TWEEN_MODE_SINUSOIDAL:
388 transit->progress = (1.0 - cos(transit->progress * ELM_PI)) / 2.0;
395 if (transit->repeat.reverse) transit->progress = 1 - transit->progress;
397 if (transit->time.duration > 0) _transit_animate_op(transit, transit->progress);
399 /* Not end. Keep going. */
400 if (elapsed_time < duration) return ECORE_CALLBACK_RENEW;
402 /* Repeat and reverse and time done! */
403 if ((transit->repeat.count >= 0) &&
404 (transit->repeat.current == transit->repeat.count) &&
405 ((!transit->auto_reverse) || transit->repeat.reverse))
407 /* run chain transit */
408 if (transit->next_chain_transits)
409 _chain_transits_go(transit);
411 elm_transit_del(transit);
412 return ECORE_CALLBACK_CANCEL;
416 if (!transit->auto_reverse || transit->repeat.reverse)
418 transit->repeat.current++;
419 transit->repeat.reverse = EINA_FALSE;
421 else transit->repeat.reverse = EINA_TRUE;
423 transit->time.begin = ecore_loop_time_get();
425 return ECORE_CALLBACK_RENEW;
431 * @note Is not necessary to delete the transit object, it will be deleted at
432 * the end of its operation.
433 * @note The transit will start playing when the program enter in the main loop, is not
434 * necessary to give a start to the transit.
436 * @param duration The duration of the transit in seconds. When transit starts
437 * to run, it will last a @p duration time.
438 * @return The transit object.
443 elm_transit_add(void)
445 Elm_Transit *transit = ELM_NEW(Elm_Transit);
446 if (!transit) return NULL;
448 EINA_MAGIC_SET(transit, ELM_TRANSIT_MAGIC);
450 elm_transit_tween_mode_set(transit, ELM_TRANSIT_TWEEN_MODE_LINEAR);
452 transit->objs_data_hash = eina_hash_int32_new(NULL);
457 * Stops the animation and delete the @p transit object.
459 * Call this function if you wants to stop the animation before the duration
460 * time. Make sure the @p transit object is still alive with
461 * elm_transit_del_cb_set() function.
462 * All added effects will be deleted, calling its repective data_free_cb
463 * functions. The function setted by elm_transit_del_cb_set() will be called.
465 * @see elm_transit_del_cb_set()
467 * @param transit The transit object to be deleted.
470 * @warning Just call this function if you are sure the transit is alive.
473 elm_transit_del(Elm_Transit *transit)
475 ELM_TRANSIT_CHECK_OR_RETURN(transit);
477 if (transit->walking) transit->deleted = EINA_TRUE;
478 else _elm_transit_del(transit);
482 * Add a new effect to the transit.
484 * @note The cb function and the data are the key to the effect. If you try to
485 * add an already added effect, nothing is done.
486 * @note After the first addition of an effect in @p transit, if its
487 * effect list become empty again, the @p transit will be killed by
488 * elm_transit_del(transit) function.
492 * Elm_Transit *transit = elm_transit_add();
493 * elm_transit_effect_add(transit,
494 * elm_transit_effect_blend_op,
495 * elm_transit_effect_blend_context_new(),
496 * elm_transit_effect_blend_context_free);
499 * @param transit The transit object.
500 * @param cb The operation function. It is called when the animation begins,
501 * it is the function that actually performs the animation. It is called with
502 * the @p data, @p transit and the time progression of the animation (a double
503 * value between 0.0 and 1.0).
504 * @param data The context data of the effect.
505 * @param data_free_cb The function to free the context data, it will be called
506 * at the end of the effect, it must finalize the animation and free the
510 * @warning The transit free the context data at the and of the transition with
511 * the data_free_cb function, do not use the context data in another transit.
514 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)
516 ELM_TRANSIT_CHECK_OR_RETURN(transit);
517 EINA_SAFETY_ON_NULL_RETURN(transition_cb);
518 Elm_Transit_Effect_Module *effect_module;
520 EINA_INLIST_FOREACH(transit->effect_list, effect_module)
521 if ((effect_module->transition_cb == transition_cb) && (effect_module->effect == effect)) return;
523 effect_module = ELM_NEW(Elm_Transit_Effect_Module);
524 if (!effect_module) return;
526 effect_module->end_cb = end_cb;
527 effect_module->transition_cb = transition_cb;
528 effect_module->effect = effect;
530 transit->effect_list = eina_inlist_append(transit->effect_list, (Eina_Inlist*) effect_module);
534 * Delete an added effect.
536 * This function will remove the effect from the @p transit, calling the
537 * data_free_cb to free the @p data.
539 * @see elm_transit_effect_add()
541 * @note If the effect is not found, nothing is done.
542 * @note If the effect list become empty, this function will call
543 * elm_transit_del(transit), that is, it will kill the @p transit.
545 * @param transit The transit object.
546 * @param cb The operation function.
547 * @param data The context data of the effect.
552 elm_transit_effect_del(Elm_Transit *transit, Elm_Transit_Effect_Transition_Cb transition_cb, Elm_Transit_Effect *effect)
554 ELM_TRANSIT_CHECK_OR_RETURN(transit);
555 EINA_SAFETY_ON_NULL_RETURN(transition_cb);
556 Elm_Transit_Effect_Module *effect_module;
558 EINA_INLIST_FOREACH(transit->effect_list, effect_module)
560 if ((effect_module->transition_cb == transition_cb) && (effect_module->effect == effect))
562 if (transit->walking)
564 effect_module->deleted = EINA_TRUE;
565 transit->effects_pending_del++;
569 _elm_transit_effect_del(transit, effect_module);
570 if (!transit->effect_list) elm_transit_del(transit);
578 * Add new object to apply the effects.
580 * @note After the first addition of an object in @p transit, if its
581 * object list become empty again, the @p transit will be killed by
582 * elm_transit_del(transit) function.
583 * @note If the @p obj belongs to another transit, the @p obj will be
584 * removed from it and it will only belong to the @p transit. If the old
585 * transit stays without objects, it will die.
586 * @note When you add an object into the @p transit, its state from
587 * evas_object_pass_events_get(obj) is saved, and it is applied when the
588 * transit ends, if you change this state whith evas_object_pass_events_set()
589 * after add the object, this state will change again when @p transit stops to
592 * @param transit The transit object.
593 * @param obj Object to be animated.
596 * @warning It is not allowed to add a new object after transit begins to go.
599 elm_transit_object_add(Elm_Transit *transit, Evas_Object *obj)
601 ELM_TRANSIT_CHECK_OR_RETURN(transit);
602 EINA_SAFETY_ON_NULL_RETURN(obj);
603 Elm_Obj_Data *obj_data;
606 //TODO: Check the remove case of the same objects in this transit.
607 obj_data = ELM_NEW(Elm_Obj_Data);
608 obj_data->pass_events = evas_object_pass_events_get(obj);
609 if (!transit->event_enabled)
610 evas_object_pass_events_set(obj, EINA_TRUE);
612 evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
613 _elm_transit_object_remove_cb,
616 transit->objs = eina_list_append(transit->objs, obj);
617 list = eina_list_last(transit->objs);
618 eina_hash_add(transit->objs_data_hash, list, obj_data);
620 if (!transit->state_keep)
621 _elm_transit_obj_states_save(obj, obj_data);
625 * Removes an added object from the transit.
627 * @note If the @p obj is not in the @p transit, nothing is done.
628 * @note If the list become empty, this function will call
629 * elm_transit_del(transit), that is, it will kill the @p transit.
631 * @param transit The transit object.
632 * @param obj Object to be removed from @p transit.
635 * @warning It is not allowed to remove objects after transit begins to go.
638 elm_transit_object_remove(Elm_Transit *transit, Evas_Object *obj)
640 ELM_TRANSIT_CHECK_OR_RETURN(transit);
641 EINA_SAFETY_ON_NULL_RETURN(obj);
643 _elm_transit_object_remove(transit, obj);
644 if (!transit->objs) elm_transit_del(transit);
648 * Get the objects of the transit.
650 * @param transit The transit object.
651 * @return a Eina_List with the objects from the transit.
655 EAPI const Eina_List *
656 elm_transit_objects_get(const Elm_Transit *transit)
658 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
659 return transit->objs;
663 * Set the event enabled when transit is operating.
665 * If @p enabled is EINA_TRUE, the objects of the transit will receives
666 * events from mouse and keyboard during the animation.
667 * @note When you add an object with elm_transit_object_add(), its state from
668 * evas_object_pass_events_get(obj) is saved, and it is applied when the
669 * transit ends, if you change this state with evas_object_pass_events_set()
670 * after adding the object, this state will change again when @p transit stops
673 * @param transit The transit object.
674 * @param enabled Disable or enable.
679 elm_transit_event_enabled_set(Elm_Transit *transit, Eina_Bool enabled)
681 ELM_TRANSIT_CHECK_OR_RETURN(transit);
683 if (transit->event_enabled == enabled) return;
684 transit->event_enabled = !!enabled;
685 eina_hash_foreach(transit->objs_data_hash, _hash_foreach_pass_events_set, transit);
689 * Get the value of event enabled status.
691 * @see elm_transit_event_enabled_set()
693 * @param transit The Transit object
694 * @return EINA_TRUE, when event is enabled. If @p transit is NULL
695 * EINA_FALSE is returned
700 elm_transit_event_enabled_get(const Elm_Transit *transit)
702 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
703 return transit->event_enabled;
708 * Set the event enabled when transit is operating.
710 * If @p disabled is EINA_TRUE, the objects of the transit will receives
711 * events from mouse and keyboard during the animation.
712 * @note When you add an object with elm_transit_object_add(), its state from
713 * evas_object_pass_events_get(obj) is saved, and it is applied when the
714 * transit ends, if you change this state with evas_object_pass_events_set()
715 * after add the object, this state will change again when @p transit stops to
718 * @see elm_transit_event_enabled_set()
720 * @param transit The transit object.
721 * @param disabled Disable or enable.
725 EINA_DEPRECATED EAPI void
726 elm_transit_event_block_set(Elm_Transit *transit, Eina_Bool disabled)
728 elm_transit_event_enabled_set(transit, disabled);
733 * Get the value of event block enabled status.
735 * @see elm_transit_event_enabled_set(), elm_transit_event_enabled_get()
737 * @param transit The Transit object
738 * @return EINA_TRUE, when event is enabled. If @p transit is NULL
739 * EINA_FALSE is returned
743 EINA_DEPRECATED EAPI Eina_Bool
744 elm_transit_event_block_get(const Elm_Transit *transit)
746 return !elm_transit_event_enabled_get(transit);
750 * Set the user-callback function when the transit is deleted.
752 * @note Using this function twice will overwrite the first function setted.
753 * @note the @p transit object will be deleted after call @p cb function.
755 * @param transit The transit object.
756 * @param cb Callback function pointer. This function will be called before
757 * the deletion of the transit.
758 * @param data Callback funtion user data. It is the @p op parameter.
763 elm_transit_del_cb_set(Elm_Transit *transit, void (*cb) (void *data, Elm_Transit *transit), void *data)
765 ELM_TRANSIT_CHECK_OR_RETURN(transit);
766 transit->del_data.func = cb;
767 transit->del_data.arg = data;
771 * Set reverse effect automatically.
773 * If auto reverse is setted, after running the effects with the progress
774 * parameter from 0 to 1, it will call the effecs again with the progress
775 * from 1 to 0. The transit will last for a time iqual to (2 * duration * repeat),
776 * where the duration was setted with the function elm_transit_add and
777 * the repeat with the function elm_transit_repeat_times_set().
779 * @param transit The transit object.
780 * @param reverse EINA_TRUE means the auto_reverse is on.
785 elm_transit_auto_reverse_set(Elm_Transit *transit, Eina_Bool reverse)
787 ELM_TRANSIT_CHECK_OR_RETURN(transit);
788 transit->auto_reverse = reverse;
792 * Get if the auto reverse is on.
794 * @see elm_transit_auto_reverse_set()
796 * @param transit The transit object.
797 * @return EINA_TRUE means auto reverse is on. If @p transit is NULL
798 * EINA_FALSE is returned
803 elm_transit_auto_reverse_get(const Elm_Transit *transit)
805 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
806 return transit->auto_reverse;
810 * Set the transit repeat count. Effect will be repeated by repeat count.
812 * This function sets the number of repetition the transit will run after
813 * the first one, that is, if @p repeat is 1, the transit will run 2 times.
814 * If the @p repeat is a negative number, it will repeat infinite times.
816 * @note If this function is called during the transit execution, the transit
817 * will run @p repeat times, ignoring the times it already performed.
819 * @param transit The transit object
820 * @param repeat Repeat count
825 elm_transit_repeat_times_set(Elm_Transit *transit, int repeat)
827 ELM_TRANSIT_CHECK_OR_RETURN(transit);
828 transit->repeat.count = repeat;
829 transit->repeat.current = 0;
833 * Get the transit repeat count.
835 * @see elm_transit_repeat_times_set()
837 * @param transit The Transit object.
838 * @return The repeat count. If @p transit is NULL
844 elm_transit_repeat_times_get(const Elm_Transit *transit)
846 ELM_TRANSIT_CHECK_OR_RETURN(transit, 0);
847 return transit->repeat.count;
851 * Set the transit animation acceleration type.
853 * This function sets the tween mode of the transit that can be:
854 * ELM_TRANSIT_TWEEN_MODE_LINEAR - The default mode.
855 * ELM_TRANSIT_TWEEN_MODE_SINUSOIDAL - Starts in accelerate mode and ends decelerating.
856 * ELM_TRANSIT_TWEEN_MODE_DECELERATE - The animation will be slowed over time.
857 * ELM_TRANSIT_TWEEN_MODE_ACCELERATE - The animation will accelerate over time.
859 * @param transit The transit object.
860 * @param tween_mode The tween type.
865 elm_transit_tween_mode_set(Elm_Transit *transit, Elm_Transit_Tween_Mode tween_mode)
867 ELM_TRANSIT_CHECK_OR_RETURN(transit);
868 transit->tween_mode = tween_mode;
872 * Get the transit animation acceleration type.
874 * @note @p transit can not be NULL
876 * @param transit The transit object.
877 * @return The tween type. If @p transit is NULL
878 * ELM_TRANSIT_TWEEN_MODE_LINEAR is returned.
882 EAPI Elm_Transit_Tween_Mode
883 elm_transit_tween_mode_get(const Elm_Transit *transit)
885 ELM_TRANSIT_CHECK_OR_RETURN(transit, ELM_TRANSIT_TWEEN_MODE_LINEAR);
886 return transit->tween_mode;
890 * Set the transit animation time
892 * @note @p transit can not be NULL
894 * @param transit The transit object.
895 * @param duration The animation time.
900 elm_transit_duration_set(Elm_Transit *transit, double duration)
902 ELM_TRANSIT_CHECK_OR_RETURN(transit);
903 if (transit->animator) return;
904 transit->time.duration = duration;
908 * Get the transit animation time
910 * @note @p transit can not be NULL
912 * @param transit The transit object.
914 * @return The transit animation time.
919 elm_transit_duration_get(const Elm_Transit *transit)
921 ELM_TRANSIT_CHECK_OR_RETURN(transit, 0.0);
922 return transit->time.duration;
926 * Starts the transition.
927 * Once this API is called, the transit begins to measure the time.
929 * @note @p transit can not be NULL
931 * @param transit The transit object.
936 elm_transit_go(Elm_Transit *transit)
938 ELM_TRANSIT_CHECK_OR_RETURN(transit);
940 if (transit->animator)
941 ecore_animator_del(transit->animator);
943 transit->time.paused = 0;
944 transit->time.delayed = 0;
945 transit->time.begin = ecore_loop_time_get();
946 transit->animator = ecore_animator_add(_animator_animate_cb, transit);
950 * Pause/Resume the transition.
951 * If you call elm_transit_go again, paused states will affect no anymore.
953 * @note @p transit can not be NULL
955 * @param transit The transit object.
960 elm_transit_paused_set(Elm_Transit *transit, Eina_Bool paused)
962 ELM_TRANSIT_CHECK_OR_RETURN(transit);
964 if (!transit->animator) return;
968 if (transit->time.paused > 0)
970 ecore_animator_freeze(transit->animator);
971 transit->time.paused = ecore_loop_time_get();
975 if (transit->time.paused == 0)
977 ecore_animator_thaw(transit->animator);
978 transit->time.delayed += (ecore_loop_time_get() - transit->time.paused);
979 transit->time.paused = 0;
984 * Get the value of paused status.
986 * @see elm_transit_paused_set()
988 * @note @p transit can not be NULL
990 * @param transit The transit object.
991 * @return EINA_TRUE means transition is paused. If @p transit is NULL
992 * EINA_FALSE is returned
997 elm_transit_paused_get(const Elm_Transit *transit)
999 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
1001 if (transit->time.paused == 0)
1008 * Get the time progression of the animation (a double value between 0.0 and 1.0).
1010 * @note @p transit can not be NULL
1012 * @param transit The transit object.
1014 * @return The time progression value. If @p transit is NULL
1020 elm_transit_progress_value_get(const Elm_Transit *transit)
1022 ELM_TRANSIT_CHECK_OR_RETURN(transit, 0);
1023 return transit->progress;
1029 * Enable/disable keeping up the objects states.
1030 * If it is not kept, the objects states will be reset when transition ends.
1032 * @note @p transit can not be NULL.
1033 * @note One state includes geometry, color, map data.
1035 * @param transit The transit object.
1036 * @param state_keep Keeping or Non Keeping.
1041 elm_transit_objects_final_state_keep_set(Elm_Transit *transit, Eina_Bool state_keep)
1043 ELM_TRANSIT_CHECK_OR_RETURN(transit);
1044 if (transit->state_keep == state_keep) return;
1045 if (transit->animator) return;
1046 transit->state_keep = !!state_keep;
1047 if (state_keep) return;
1048 eina_hash_foreach(transit->objs_data_hash, _hash_foreach_obj_states_save, NULL);
1052 * Get a value whether the objects states will be reset or not.
1054 * @note @p transit can not be NULL
1056 * @see elm_transit_objects_final_state_keep_set()
1058 * @param transit The transit object.
1059 * @return EINA_TRUE means the states of the objects will be reset.
1060 * If @p transit is NULL, EINA_FALSE is returned
1065 elm_transit_objects_final_state_keep_get(const Elm_Transit *transit)
1067 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
1068 return transit->state_keep;
1072 * Makes the chain relationship between two transits.
1074 * @note @p transit can not be NULL. Transit would have multiple chain transits.
1075 * @note @p chain_transit can not be NULL. Chain transits could be chained to the only one transit.
1077 * @param transit The transit object.
1078 * @param chain_transit The chain transit object. This transit will be operated
1079 * after transit is done.
1084 elm_transit_chain_transit_add(Elm_Transit *transit, Elm_Transit *chain_transit)
1086 ELM_TRANSIT_CHECK_OR_RETURN(transit);
1087 ELM_TRANSIT_CHECK_OR_RETURN(chain_transit);
1089 if (transit == chain_transit) return;
1090 if (transit == chain_transit->prev_chain_transit) return;
1092 if (chain_transit->prev_chain_transit)
1093 chain_transit->prev_chain_transit->next_chain_transits = eina_list_remove(chain_transit->prev_chain_transit->next_chain_transits, chain_transit);
1095 chain_transit->prev_chain_transit = transit;
1096 transit->next_chain_transits = eina_list_append(transit->next_chain_transits, chain_transit);
1100 * Get the current chain transit list.
1102 * @note @p transit can not be NULL.
1104 * @param transit The transit object.
1105 * @return chain transit list.
1110 elm_transit_chain_transits_get(const Elm_Transit * transit)
1112 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1113 return transit->next_chain_transits;
1116 ///////////////////////////////////////////////////////////////////////////////
1118 ///////////////////////////////////////////////////////////////////////////////
1119 typedef struct _Elm_Transit_Effect_Resizing Elm_Transit_Effect_Resizing;
1121 struct _Elm_Transit_Effect_Resizing
1129 _transit_effect_resizing_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
1131 Elm_Transit_Effect_Resizing *resizing = effect;
1136 _transit_effect_resizing_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
1138 EINA_SAFETY_ON_NULL_RETURN(effect);
1139 EINA_SAFETY_ON_NULL_RETURN(transit);
1143 Elm_Transit_Effect_Resizing *resizing = effect;
1145 w = resizing->from.w + (resizing->to.w * progress);
1146 h = resizing->from.h + (resizing->to.h * progress);
1148 EINA_LIST_FOREACH(transit->objs, elist, obj)
1149 evas_object_resize(obj, w, h);
1152 static Elm_Transit_Effect *
1153 _transit_effect_resizing_context_new(Evas_Coord from_w, Evas_Coord from_h, Evas_Coord to_w, Evas_Coord to_h)
1155 Elm_Transit_Effect_Resizing *resizing;
1157 resizing = ELM_NEW(Elm_Transit_Effect_Resizing);
1158 if (!resizing) return NULL;
1160 resizing->from.w = from_w;
1161 resizing->from.h = from_h;
1162 resizing->to.w = to_w - from_w;
1163 resizing->to.h = to_h - from_h;
1169 * Add the Resizing Effect to Elm_Transit.
1171 * @note This API is one of the facades. It creates resizing effect context
1172 * and add it's required APIs to elm_transit_effect_add.
1174 * @see elm_transit_effect_add()
1176 * @param transit Transit object.
1177 * @param from_w Object width size when effect begins.
1178 * @param from_h Object height size when effect begins.
1179 * @param to_w Object width size when effect ends.
1180 * @param to_h Object height size when effect ends.
1181 * @return Resizing effect context data.
1185 EAPI Elm_Transit_Effect *
1186 elm_transit_effect_resizing_add(Elm_Transit *transit, Evas_Coord from_w, Evas_Coord from_h, Evas_Coord to_w, Evas_Coord to_h)
1188 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1189 Elm_Transit_Effect *effect = _transit_effect_resizing_context_new(from_w, from_h, to_w, to_h);
1191 if (!effect) return NULL;
1192 elm_transit_effect_add(transit,
1193 _transit_effect_resizing_op, effect,
1194 _transit_effect_resizing_context_free);
1198 ///////////////////////////////////////////////////////////////////////////////
1199 //Translation Effect
1200 ///////////////////////////////////////////////////////////////////////////////
1201 typedef struct _Elm_Transit_Effect_Translation Elm_Transit_Effect_Translation;
1202 typedef struct _Elm_Transit_Effect_Translation_Node Elm_Transit_Effect_Translation_Node;
1204 struct _Elm_Transit_Effect_Translation_Node
1210 struct _Elm_Transit_Effect_Translation
1212 struct _position_variation {
1219 _translation_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1221 Elm_Transit_Effect_Translation *translation = data;
1223 Elm_Transit_Effect_Translation_Node *translation_node;
1225 EINA_LIST_FOREACH(translation->nodes, elist, translation_node)
1227 if (translation_node->obj != obj) continue;
1228 translation->nodes = eina_list_remove_list(translation->nodes, elist);
1229 free(translation_node);
1235 _translation_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Translation *translation)
1237 Elm_Transit_Effect_Translation_Node *translation_node;
1238 const Eina_List *elist;
1240 Eina_List *data_list = NULL;
1241 const Eina_List *objs = elm_transit_objects_get(transit);
1243 EINA_LIST_FOREACH(objs, elist, obj)
1245 translation_node = ELM_NEW(Elm_Transit_Effect_Translation_Node);
1246 if (!translation_node)
1248 eina_list_free(data_list);
1251 translation_node->obj = obj;
1252 evas_object_geometry_get(obj, &(translation_node->x),
1253 &(translation_node->y), NULL, NULL);
1254 data_list = eina_list_append(data_list, translation_node);
1255 evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
1256 _translation_object_del_cb, translation);
1262 _transit_effect_translation_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
1264 EINA_SAFETY_ON_NULL_RETURN(effect);
1265 Elm_Transit_Effect_Translation *translation = effect;
1266 Eina_List *elist, *elist_next;
1267 Elm_Transit_Effect_Translation_Node *translation_node;
1269 EINA_LIST_FOREACH_SAFE(translation->nodes,
1270 elist, elist_next, translation_node)
1272 evas_object_event_callback_del(translation_node->obj,
1273 EVAS_CALLBACK_DEL, _translation_object_del_cb);
1274 translation->nodes = eina_list_remove_list(translation->nodes, elist);
1275 free(translation_node);
1281 _transit_effect_translation_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress __UNUSED__)
1283 EINA_SAFETY_ON_NULL_RETURN(effect);
1284 EINA_SAFETY_ON_NULL_RETURN(transit);
1286 Elm_Transit_Effect_Translation *translation = effect;
1287 Elm_Transit_Effect_Translation_Node *translation_node;
1290 if (!translation->nodes)
1291 translation->nodes = _translation_nodes_build(transit, translation);
1293 EINA_LIST_FOREACH(translation->nodes, elist, translation_node)
1295 x = translation_node->x + translation->from.dx
1296 + (translation->to.dx * progress);
1297 y = translation_node->y + translation->from.dy
1298 + (translation->to.dy * progress);
1299 evas_object_move(translation_node->obj, x, y);
1303 static Elm_Transit_Effect *
1304 _transit_effect_translation_context_new(Evas_Coord from_dx, Evas_Coord from_dy, Evas_Coord to_dx, Evas_Coord to_dy)
1306 Elm_Transit_Effect_Translation *translation;
1308 translation = ELM_NEW(Elm_Transit_Effect_Translation);
1309 if (!translation) return NULL;
1311 translation->from.dx = from_dx;
1312 translation->from.dy = from_dy;
1313 translation->to.dx = to_dx - from_dx;
1314 translation->to.dy = to_dy - from_dy;
1320 * Add the Translation Effect to Elm_Transit.
1322 * @note This API is one of the facades. It creates translation effect context
1323 * and add it's required APIs to elm_transit_effect_add.
1325 * @see elm_transit_effect_add()
1327 * @param transit Transit object.
1328 * @param from_dx X Position variation when effect begins.
1329 * @param from_dy Y Position variation when effect begins.
1330 * @param to_dx X Position variation when effect ends.
1331 * @param to_dy Y Position variation when effect ends.
1332 * @return Translation effect context data.
1335 * @warning Is higher recommended just create a transit with this effect when
1336 * the window that the objects of the transit belongs has already been created.
1337 * This is because this effect needs the geometry information about the objects,
1338 * and if the window was not created yet, it can get a wrong information.
1340 EAPI Elm_Transit_Effect *
1341 elm_transit_effect_translation_add(Elm_Transit *transit, Evas_Coord from_dx, Evas_Coord from_dy, Evas_Coord to_dx, Evas_Coord to_dy)
1343 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1344 Elm_Transit_Effect *effect_context = _transit_effect_translation_context_new(from_dx, from_dy, to_dx, to_dy);
1346 if (!effect_context) return NULL;
1347 elm_transit_effect_add(transit,
1348 _transit_effect_translation_op, effect_context,
1349 _transit_effect_translation_context_free);
1350 return effect_context;
1354 ///////////////////////////////////////////////////////////////////////////////
1356 ///////////////////////////////////////////////////////////////////////////////
1357 typedef struct _Elm_Transit_Effect_Zoom Elm_Transit_Effect_Zoom;
1359 struct _Elm_Transit_Effect_Zoom
1365 _transit_effect_zoom_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
1367 Elm_Transit_Effect_Zoom *zoom = effect;
1372 _transit_effect_zoom_op(Elm_Transit_Effect *effect, Elm_Transit *transit , double progress)
1374 EINA_SAFETY_ON_NULL_RETURN(effect);
1375 EINA_SAFETY_ON_NULL_RETURN(transit);
1378 Elm_Transit_Effect_Zoom *zoom = effect;
1380 Evas_Coord x, y, w, h;
1382 map = evas_map_new(4);
1385 EINA_LIST_FOREACH(transit->objs, elist, obj)
1387 evas_object_geometry_get(obj, &x, &y, &w, &h);
1388 evas_map_util_points_populate_from_object_full(map, obj, zoom->from +
1389 (progress * zoom->to));
1390 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, _TRANSIT_FOCAL);
1391 evas_object_map_set(obj, map);
1392 evas_object_map_enable_set(obj, EINA_TRUE);
1397 static Elm_Transit_Effect *
1398 _transit_effect_zoom_context_new(float from_rate, float to_rate)
1400 Elm_Transit_Effect_Zoom *zoom;
1402 zoom = ELM_NEW(Elm_Transit_Effect_Zoom);
1403 if (!zoom) return NULL;
1405 zoom->from = (_TRANSIT_FOCAL - (from_rate * _TRANSIT_FOCAL)) * (1 / from_rate);
1406 zoom->to = ((_TRANSIT_FOCAL - (to_rate * _TRANSIT_FOCAL)) * (1 / to_rate)) - zoom->from;
1412 * Add the Zoom Effect to Elm_Transit.
1414 * @note This API is one of the facades. It creates zoom effect context
1415 * and add it's required APIs to elm_transit_effect_add.
1417 * @see elm_transit_effect_add()
1419 * @param transit Transit object.
1420 * @param from_rate Scale rate when effect begins (1 is current rate).
1421 * @param to_rate Scale rate when effect ends.
1422 * @return Zoom effect context data.
1425 * @warning Is higher recommended just create a transit with this effect when
1426 * the window that the objects of the transit belongs has already been created.
1427 * This is because this effect needs the geometry information about the objects,
1428 * and if the window was not created yet, it can get a wrong information.
1430 EAPI Elm_Transit_Effect *
1431 elm_transit_effect_zoom_add(Elm_Transit *transit, float from_rate, float to_rate)
1433 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1434 Elm_Transit_Effect *effect_context = _transit_effect_zoom_context_new(from_rate, to_rate);
1436 if (!effect_context) return NULL;
1437 elm_transit_effect_add(transit,
1438 _transit_effect_zoom_op, effect_context,
1439 _transit_effect_zoom_context_free);
1440 return effect_context;
1444 ///////////////////////////////////////////////////////////////////////////////
1446 ///////////////////////////////////////////////////////////////////////////////
1447 typedef struct _Elm_Transit_Effect_Flip Elm_Transit_Effect_Flip;
1449 struct _Elm_Transit_Effect_Flip
1451 Elm_Transit_Effect_Flip_Axis axis;
1456 _transit_effect_flip_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit)
1458 EINA_SAFETY_ON_NULL_RETURN(effect);
1459 EINA_SAFETY_ON_NULL_RETURN(transit);
1460 Elm_Transit_Effect_Flip *flip = effect;
1461 Evas_Object *front, *back;
1463 int count = eina_list_count(transit->objs);
1465 for (i = 0; i < (count - 1); i += 2)
1467 front = eina_list_nth(transit->objs, i);
1468 back = eina_list_nth(transit->objs, i+1);
1469 evas_object_map_enable_set(front, EINA_FALSE);
1470 evas_object_map_enable_set(back, EINA_FALSE);
1476 _transit_effect_flip_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
1478 EINA_SAFETY_ON_NULL_RETURN(effect);
1479 EINA_SAFETY_ON_NULL_RETURN(transit);
1480 Evas_Object *obj, *front, *back;
1482 Elm_Transit_Effect_Flip *flip = effect;
1485 Evas_Coord x, y, w, h;
1487 map = evas_map_new(4);
1490 if (flip->cw) degree = (float)(progress * 180);
1491 else degree = (float)(progress * -180);
1493 count = eina_list_count(transit->objs);
1495 for (i = 0; i < (count - 1); i += 2)
1497 Evas_Coord half_w, half_h;
1499 front = eina_list_nth(transit->objs, i);
1500 back = eina_list_nth(transit->objs, i+1);
1502 if ((degree < 90) && (degree > -90))
1507 evas_object_hide(back);
1508 evas_object_show(front);
1516 evas_object_hide(front);
1517 evas_object_show(back);
1521 evas_map_util_points_populate_from_object_full(map, obj, 0);
1522 evas_object_geometry_get(obj, &x, &y, &w, &h);
1526 if (flip->axis == ELM_TRANSIT_EFFECT_FLIP_AXIS_Y)
1528 if ((degree >= 90) || (degree <= -90))
1530 evas_map_point_image_uv_set(map, 0, w, 0);
1531 evas_map_point_image_uv_set(map, 1, 0, 0);
1532 evas_map_point_image_uv_set(map, 2, 0, h);
1533 evas_map_point_image_uv_set(map, 3, w, h);
1535 evas_map_util_3d_rotate(map, 0, degree,
1536 0, x + half_w, y + half_h, 0);
1540 if ((degree >= 90) || (degree <= -90))
1542 evas_map_point_image_uv_set(map, 0, 0, h);
1543 evas_map_point_image_uv_set(map, 1, w, h);
1544 evas_map_point_image_uv_set(map, 2, w, 0);
1545 evas_map_point_image_uv_set(map, 3, 0, 0);
1547 evas_map_util_3d_rotate(map, degree,
1548 0, 0, x + half_w, y + half_h, 0);
1550 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, _TRANSIT_FOCAL);
1551 evas_object_map_enable_set(front, EINA_TRUE);
1552 evas_object_map_enable_set(back, EINA_TRUE);
1553 evas_object_map_set(obj, map);
1558 static Elm_Transit_Effect *
1559 _transit_effect_flip_context_new(Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1561 Elm_Transit_Effect_Flip *flip;
1563 flip = ELM_NEW(Elm_Transit_Effect_Flip);
1564 if (!flip) return NULL;
1573 * Add the Flip Effect to Elm_Transit.
1575 * @note This API is one of the facades. It creates flip effect context
1576 * and add it's required APIs to elm_transit_effect_add.
1577 * @note This effect is applied to each pair of objects in the order they are listed
1578 * in the transit list of objects. The first object in the pair will be the
1579 * "front" object and the second will be the "back" object.
1581 * @see elm_transit_effect_add()
1583 * @param transit Transit object.
1584 * @param axis Flipping Axis(X or Y).
1585 * @param cw Flipping Direction. EINA_TRUE is clock-wise.
1586 * @return Flip effect context data.
1589 * @warning Is higher recommended just create a transit with this effect when
1590 * the window that the objects of the transit belongs has already been created.
1591 * This is because this effect needs the geometry information about the objects,
1592 * and if the window was not created yet, it can get a wrong information.
1594 EAPI Elm_Transit_Effect *
1595 elm_transit_effect_flip_add(Elm_Transit *transit, Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1597 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1598 Elm_Transit_Effect *effect_context = _transit_effect_flip_context_new(axis, cw);
1600 if (!effect_context) return NULL;
1601 elm_transit_effect_add(transit,
1602 _transit_effect_flip_op, effect_context,
1603 _transit_effect_flip_context_free);
1604 return effect_context;
1607 ///////////////////////////////////////////////////////////////////////////////
1608 //ResizableFlip Effect
1609 ///////////////////////////////////////////////////////////////////////////////
1610 typedef struct _Elm_Transit_Effect_Resizable_Flip Elm_Transit_Effect_ResizableFlip;
1611 typedef struct _Elm_Transit_Effect_Resizable_Flip_Node Elm_Transit_Effect_ResizableFlip_Node;
1613 struct _Elm_Transit_Effect_Resizable_Flip_Node
1619 } from_pos, from_size, to_pos, to_size;
1622 struct _Elm_Transit_Effect_Resizable_Flip
1626 Elm_Transit_Effect_Flip_Axis axis;
1630 _resizable_flip_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1632 Elm_Transit_Effect_ResizableFlip *resizable_flip = data;
1634 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1636 EINA_LIST_FOREACH(resizable_flip->nodes, elist, resizable_flip_node)
1638 if (resizable_flip_node->front == obj)
1639 evas_object_event_callback_del(resizable_flip_node->back,
1640 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1641 else if (resizable_flip_node->back == obj)
1642 evas_object_event_callback_del(resizable_flip_node->front,
1643 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1646 resizable_flip->nodes = eina_list_remove_list(resizable_flip->nodes,
1648 free(resizable_flip_node);
1654 _resizable_flip_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_ResizableFlip *resizable_flip)
1656 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1657 Eina_List *data_list = NULL;
1658 Evas_Coord front_x, front_y, front_w, front_h;
1659 Evas_Coord back_x, back_y, back_w, back_h;
1662 count = eina_list_count(transit->objs);
1663 for (i = 0; i < (count - 1); i += 2)
1665 resizable_flip_node = ELM_NEW(Elm_Transit_Effect_ResizableFlip_Node);
1666 if (!resizable_flip_node)
1668 eina_list_free(data_list);
1672 resizable_flip_node->front = eina_list_nth(transit->objs, i);
1673 resizable_flip_node->back = eina_list_nth(transit->objs, i+1);
1675 evas_object_geometry_get(resizable_flip_node->front,
1676 &front_x, &front_y, &front_w, &front_h);
1677 evas_object_geometry_get(resizable_flip_node->back,
1678 &back_x, &back_y, &back_w, &back_h);
1680 resizable_flip_node->from_pos.x = front_x;
1681 resizable_flip_node->from_pos.y = front_y;
1682 resizable_flip_node->to_pos.x = back_x - front_x;
1683 resizable_flip_node->to_pos.y = back_y - front_y;
1685 resizable_flip_node->from_size.x = front_w;
1686 resizable_flip_node->from_size.y = front_h;
1687 resizable_flip_node->to_size.x = back_w - front_w;
1688 resizable_flip_node->to_size.y = back_h - front_h;
1690 data_list = eina_list_append(data_list, resizable_flip_node);
1692 evas_object_event_callback_add(resizable_flip_node->back,
1693 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb, resizable_flip);
1694 evas_object_event_callback_add(resizable_flip_node->front,
1695 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb, resizable_flip);
1702 _set_image_uv_by_axis_y(Evas_Map *map, Elm_Transit_Effect_ResizableFlip_Node *flip, float degree)
1704 if ((degree >= 90) || (degree <= -90))
1706 evas_map_point_image_uv_set(map, 0,
1707 (flip->from_size.x * 2) + flip->to_size.x,
1709 evas_map_point_image_uv_set(map, 1, 0, 0);
1710 evas_map_point_image_uv_set(map, 2, 0,
1711 (flip->from_size.y * 2) + flip->to_size.y);
1712 evas_map_point_image_uv_set(map, 3,
1713 (flip->from_size.x * 2) + flip->to_size.x,
1714 (flip->from_size.y * 2) + flip->to_size.y);
1718 evas_map_point_image_uv_set(map, 0, 0, 0);
1719 evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
1720 evas_map_point_image_uv_set(map, 2, flip->from_size.x,
1722 evas_map_point_image_uv_set(map, 3, 0, flip->from_size.y);
1727 _set_image_uv_by_axis_x(Evas_Map *map, Elm_Transit_Effect_ResizableFlip_Node *flip, float degree)
1729 if ((degree >= 90) || (degree <= -90))
1731 evas_map_point_image_uv_set(map, 0, 0,
1732 (flip->from_size.y * 2) + flip->to_size.y);
1733 evas_map_point_image_uv_set(map, 1,
1734 (flip->from_size.x * 2) + flip->to_size.x,
1735 (flip->from_size.y * 2) + flip->to_size.y);
1736 evas_map_point_image_uv_set(map, 2,
1737 (flip->from_size.x * 2) + flip->to_size.x,
1739 evas_map_point_image_uv_set(map, 3, 0, 0);
1743 evas_map_point_image_uv_set(map, 0, 0, 0);
1744 evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
1745 evas_map_point_image_uv_set(map, 2, flip->from_size.x,
1747 evas_map_point_image_uv_set(map, 3, 0, flip->from_size.y);
1752 _transit_effect_resizable_flip_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
1754 EINA_SAFETY_ON_NULL_RETURN(effect);
1756 Elm_Transit_Effect_ResizableFlip *resizable_flip = effect;
1757 Eina_List *elist, *elist_next;
1758 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1760 EINA_LIST_FOREACH_SAFE(resizable_flip->nodes,
1761 elist, elist_next, resizable_flip_node)
1763 evas_object_map_enable_set(resizable_flip_node->front, EINA_FALSE);
1764 evas_object_map_enable_set(resizable_flip_node->back, EINA_FALSE);
1766 resizable_flip->nodes = eina_list_remove_list(resizable_flip->nodes,
1769 evas_object_event_callback_del(resizable_flip_node->back,
1770 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1771 evas_object_event_callback_del(resizable_flip_node->front,
1772 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1773 free(resizable_flip_node);
1775 free(resizable_flip);
1779 _transit_effect_resizable_flip_op(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__, double progress)
1781 EINA_SAFETY_ON_NULL_RETURN(effect);
1786 Evas_Coord half_w, half_h;
1787 Elm_Transit_Effect_ResizableFlip *resizable_flip = effect;
1788 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1791 map = evas_map_new(4);
1794 if (resizable_flip->cw) degree = (float)(progress * 180);
1795 else degree = (float)(progress * -180);
1797 if (!resizable_flip->nodes)
1798 resizable_flip->nodes = _resizable_flip_nodes_build(transit,
1801 EINA_LIST_FOREACH(resizable_flip->nodes, elist, resizable_flip_node)
1803 if ((degree < 90) && (degree > -90))
1805 obj = resizable_flip_node->front;
1806 if (resizable_flip_node->front != resizable_flip_node->back)
1808 evas_object_hide(resizable_flip_node->back);
1809 evas_object_show(resizable_flip_node->front);
1814 obj = resizable_flip_node->back;
1815 if (resizable_flip_node->front != resizable_flip_node->back)
1817 evas_object_hide(resizable_flip_node->front);
1818 evas_object_show(resizable_flip_node->back);
1822 x = resizable_flip_node->from_pos.x +
1823 (resizable_flip_node->to_pos.x * progress);
1824 y = resizable_flip_node->from_pos.y +
1825 (resizable_flip_node->to_pos.y * progress);
1826 w = resizable_flip_node->from_size.x +
1827 (resizable_flip_node->to_size.x * progress);
1828 h = resizable_flip_node->from_size.y +
1829 (resizable_flip_node->to_size.y * progress);
1830 evas_map_point_coord_set(map, 0, x, y, 0);
1831 evas_map_point_coord_set(map, 1, x + w, y, 0);
1832 evas_map_point_coord_set(map, 2, x + w, y + h, 0);
1833 evas_map_point_coord_set(map, 3, x, y + h, 0);
1835 half_w = (Evas_Coord)(w / 2);
1836 half_h = (Evas_Coord)(h / 2);
1838 if (resizable_flip->axis == ELM_TRANSIT_EFFECT_FLIP_AXIS_Y)
1840 _set_image_uv_by_axis_y(map, resizable_flip_node, degree);
1841 evas_map_util_3d_rotate(map, 0, degree,
1842 0, x + half_w, y + half_h, 0);
1846 _set_image_uv_by_axis_x(map, resizable_flip_node, degree);
1847 evas_map_util_3d_rotate(map, degree, 0,
1848 0, x + half_w, y + half_h, 0);
1851 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, _TRANSIT_FOCAL);
1852 evas_object_map_enable_set(resizable_flip_node->front, EINA_TRUE);
1853 evas_object_map_enable_set(resizable_flip_node->back, EINA_TRUE);
1854 evas_object_map_set(obj, map);
1859 static Elm_Transit_Effect *
1860 _transit_effect_resizable_flip_context_new(Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1862 Elm_Transit_Effect_ResizableFlip *resizable_flip;
1864 resizable_flip = ELM_NEW(Elm_Transit_Effect_ResizableFlip);
1865 if (!resizable_flip) return NULL;
1867 resizable_flip->cw = cw;
1868 resizable_flip->axis = axis;
1870 return resizable_flip;
1874 * Add the Resizable Flip Effect to Elm_Transit.
1876 * @note This API is one of the facades. It creates resizable flip effect context
1877 * and add it's required APIs to elm_transit_effect_add.
1878 * @note This effect is applied to each pair of objects in the order they are listed
1879 * in the transit list of objects. The first object in the pair will be the
1880 * "front" object and the second will be the "back" object.
1882 * @see elm_transit_effect_add()
1884 * @param transit Transit object.
1885 * @param axis Flipping Axis(X or Y).
1886 * @param cw Flipping Direction. EINA_TRUE is clock-wise.
1887 * @return Resizable flip effect context data.
1890 * @warning Is higher recommended just create a transit with this effect when
1891 * the window that the objects of the transit belongs has already been created.
1892 * This is because this effect needs the geometry information about the objects,
1893 * and if the window was not created yet, it can get a wrong information.
1895 EAPI Elm_Transit_Effect *
1896 elm_transit_effect_resizable_flip_add(Elm_Transit *transit, Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1898 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1899 Elm_Transit_Effect *effect_context = _transit_effect_resizable_flip_context_new(axis, cw);
1901 if (!effect_context) return NULL;
1902 elm_transit_effect_add(transit,
1903 _transit_effect_resizable_flip_op, effect_context,
1904 _transit_effect_resizable_flip_context_free);
1905 return effect_context;
1909 ///////////////////////////////////////////////////////////////////////////////
1911 ///////////////////////////////////////////////////////////////////////////////
1912 typedef struct _Elm_Transit_Effect_Wipe Elm_Transit_Effect_Wipe;
1914 struct _Elm_Transit_Effect_Wipe
1916 Elm_Transit_Effect_Wipe_Type type;
1917 Elm_Transit_Effect_Wipe_Dir dir;
1921 _elm_fx_wipe_hide(Evas_Map * map, Elm_Transit_Effect_Wipe_Dir dir, float x, float y, float w, float h, float progress)
1927 case ELM_TRANSIT_EFFECT_WIPE_DIR_LEFT:
1928 w2 = w - (w * progress);
1930 evas_map_point_image_uv_set(map, 0, 0, 0);
1931 evas_map_point_image_uv_set(map, 1, w2, 0);
1932 evas_map_point_image_uv_set(map, 2, w2, h);
1933 evas_map_point_image_uv_set(map, 3, 0, h);
1934 evas_map_point_coord_set(map, 0, x, y, 0);
1935 evas_map_point_coord_set(map, 1, x + w2, y, 0);
1936 evas_map_point_coord_set(map, 2, x + w2, h2, 0);
1937 evas_map_point_coord_set(map, 3, x, h2, 0);
1939 case ELM_TRANSIT_EFFECT_WIPE_DIR_RIGHT:
1940 w2 = (w * progress);
1942 evas_map_point_image_uv_set(map, 0, w2, 0);
1943 evas_map_point_image_uv_set(map, 1, w, 0);
1944 evas_map_point_image_uv_set(map, 2, w, h);
1945 evas_map_point_image_uv_set(map, 3, w2, h);
1946 evas_map_point_coord_set(map, 0, x + w2, y, 0);
1947 evas_map_point_coord_set(map, 1, x + w, y, 0);
1948 evas_map_point_coord_set(map, 2, x + w, h2, 0);
1949 evas_map_point_coord_set(map, 3, x + w2, h2, 0);
1951 case ELM_TRANSIT_EFFECT_WIPE_DIR_UP:
1953 h2 = h - (h * progress);
1954 evas_map_point_image_uv_set(map, 0, 0, 0);
1955 evas_map_point_image_uv_set(map, 1, w, 0);
1956 evas_map_point_image_uv_set(map, 2, w, h2);
1957 evas_map_point_image_uv_set(map, 3, 0, h2);
1958 evas_map_point_coord_set(map, 0, x, y, 0);
1959 evas_map_point_coord_set(map, 1, w2, y, 0);
1960 evas_map_point_coord_set(map, 2, w2, y+h2, 0);
1961 evas_map_point_coord_set(map, 3, x, y+h2, 0);
1963 case ELM_TRANSIT_EFFECT_WIPE_DIR_DOWN:
1965 h2 = (h * progress);
1966 evas_map_point_image_uv_set(map, 0, 0, h2);
1967 evas_map_point_image_uv_set(map, 1, w, h2);
1968 evas_map_point_image_uv_set(map, 2, w, h);
1969 evas_map_point_image_uv_set(map, 3, 0, h);
1970 evas_map_point_coord_set(map, 0, x, y + h2, 0);
1971 evas_map_point_coord_set(map, 1, w2, y + h2, 0);
1972 evas_map_point_coord_set(map, 2, w2, y + h, 0);
1973 evas_map_point_coord_set(map, 3, x, y + h, 0);
1978 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, _TRANSIT_FOCAL);
1982 _elm_fx_wipe_show(Evas_Map *map, Elm_Transit_Effect_Wipe_Dir dir, float x, float y, float w, float h, float progress)
1988 case ELM_TRANSIT_EFFECT_WIPE_DIR_LEFT:
1989 w2 = (w - (w * progress));
1991 evas_map_point_image_uv_set(map, 0, w2, 0);
1992 evas_map_point_image_uv_set(map, 1, w, 0);
1993 evas_map_point_image_uv_set(map, 2, w, h);
1994 evas_map_point_image_uv_set(map, 3, w2, h);
1995 evas_map_point_coord_set(map, 0, x + w2, y, 0);
1996 evas_map_point_coord_set(map, 1, w, y, 0);
1997 evas_map_point_coord_set(map, 2, w, h2, 0);
1998 evas_map_point_coord_set(map, 3, x + w2, h2, 0);
2000 case ELM_TRANSIT_EFFECT_WIPE_DIR_RIGHT:
2001 w2 = (w * progress);
2003 evas_map_point_image_uv_set(map, 0, 0, 0);
2004 evas_map_point_image_uv_set(map, 1, w2, 0);
2005 evas_map_point_image_uv_set(map, 2, w2, h);
2006 evas_map_point_image_uv_set(map, 3, 0, h);
2007 evas_map_point_coord_set(map, 0, x, y, 0);
2008 evas_map_point_coord_set(map, 1, x + w2, y, 0);
2009 evas_map_point_coord_set(map, 2, x + w2, h2, 0);
2010 evas_map_point_coord_set(map, 3, x, h2, 0);
2012 case ELM_TRANSIT_EFFECT_WIPE_DIR_UP:
2014 h2 = (h - (h * progress));
2015 evas_map_point_image_uv_set(map, 0, 0, h2);
2016 evas_map_point_image_uv_set(map, 1, w, h2);
2017 evas_map_point_image_uv_set(map, 2, w, h);
2018 evas_map_point_image_uv_set(map, 3, 0, h);
2019 evas_map_point_coord_set(map, 0, x, y + h2, 0);
2020 evas_map_point_coord_set(map, 1, w2, y + h2, 0);
2021 evas_map_point_coord_set(map, 2, w2, y + h, 0);
2022 evas_map_point_coord_set(map, 3, x, y + h, 0);
2024 case ELM_TRANSIT_EFFECT_WIPE_DIR_DOWN:
2026 h2 = (h * progress);
2027 evas_map_point_image_uv_set(map, 0, 0, 0);
2028 evas_map_point_image_uv_set(map, 1, w, 0);
2029 evas_map_point_image_uv_set(map, 2, w, h2);
2030 evas_map_point_image_uv_set(map, 3, 0, h2);
2031 evas_map_point_coord_set(map, 0, x, y, 0);
2032 evas_map_point_coord_set(map, 1, w2, y, 0);
2033 evas_map_point_coord_set(map, 2, w2, y + h2, 0);
2034 evas_map_point_coord_set(map, 3, x, y + h2, 0);
2039 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, _TRANSIT_FOCAL);
2043 _transit_effect_wipe_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit)
2045 EINA_SAFETY_ON_NULL_RETURN(effect);
2046 EINA_SAFETY_ON_NULL_RETURN(transit);
2049 Elm_Transit_Effect_Wipe *wipe = effect;
2050 Eina_Bool reverse = elm_transit_auto_reverse_get(transit);
2052 EINA_LIST_FOREACH(transit->objs, elist, obj)
2054 if ((wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_SHOW && !reverse)
2055 || (wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_HIDE && reverse))
2056 evas_object_show(obj);
2057 else evas_object_hide(obj);
2058 evas_object_map_enable_set(obj, EINA_FALSE);
2065 _transit_effect_wipe_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2067 EINA_SAFETY_ON_NULL_RETURN(effect);
2068 EINA_SAFETY_ON_NULL_RETURN(transit);
2069 Elm_Transit_Effect_Wipe *wipe = effect;
2071 Evas_Coord _x, _y, _w, _h;
2075 map = evas_map_new(4);
2078 EINA_LIST_FOREACH(transit->objs, elist, obj)
2080 evas_object_geometry_get(obj, &_x, &_y, &_w, &_h);
2082 if (wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_SHOW)
2083 _elm_fx_wipe_show(map, wipe->dir, _x, _y, _w, _h, (float)progress);
2085 _elm_fx_wipe_hide(map, wipe->dir, _x, _y, _w, _h, (float)progress);
2087 evas_object_map_enable_set(obj, EINA_TRUE);
2088 evas_object_map_set(obj, map);
2093 static Elm_Transit_Effect *
2094 _transit_effect_wipe_context_new(Elm_Transit_Effect_Wipe_Type type, Elm_Transit_Effect_Wipe_Dir dir)
2096 Elm_Transit_Effect_Wipe *wipe;
2098 wipe = ELM_NEW(Elm_Transit_Effect_Wipe);
2099 if (!wipe) return NULL;
2108 * Add the Wipe Effect to Elm_Transit.
2110 * @note This API is one of the facades. It creates wipe effect context
2111 * and add it's required APIs to elm_transit_effect_add.
2113 * @see elm_transit_effect_add()
2115 * @param transit Transit object.
2116 * @param type Wipe type. Hide or show.
2117 * @param dir Wipe Direction.
2118 * @return Wipe effect context data.
2121 * @warning Is higher recommended just create a transit with this effect when
2122 * the window that the objects of the transit belongs has already been created.
2123 * This is because this effect needs the geometry information about the objects,
2124 * and if the window was not created yet, it can get a wrong information.
2127 elm_transit_effect_wipe_add(Elm_Transit *transit, Elm_Transit_Effect_Wipe_Type type, Elm_Transit_Effect_Wipe_Dir dir)
2129 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2130 void *effect_context = _transit_effect_wipe_context_new(type, dir);
2132 if (!effect_context) return NULL;
2133 elm_transit_effect_add(transit,
2134 _transit_effect_wipe_op, effect_context,
2135 _transit_effect_wipe_context_free);
2136 return effect_context;
2140 ///////////////////////////////////////////////////////////////////////////////
2142 ///////////////////////////////////////////////////////////////////////////////
2143 typedef struct _Elm_Transit_Effect_Color Elm_Transit_Effect_Color;
2145 struct _Elm_Transit_Effect_Color
2147 struct _unsigned_color {
2148 unsigned int r, g, b, a;
2150 struct _signed_color {
2156 _transit_effect_color_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
2158 Elm_Transit_Effect_Color *color = effect;
2163 _transit_effect_color_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2165 EINA_SAFETY_ON_NULL_RETURN(effect);
2166 EINA_SAFETY_ON_NULL_RETURN(transit);
2167 Elm_Transit_Effect_Color *color = effect;
2170 unsigned int r, g, b, a;
2172 r = (color->from.r + (int)((float)color->to.r * progress));
2173 g = (color->from.g + (int)((float)color->to.g * progress));
2174 b = (color->from.b + (int)((float)color->to.b * progress));
2175 a = (color->from.a + (int)((float)color->to.a * progress));
2177 EINA_LIST_FOREACH(transit->objs, elist, obj)
2178 evas_object_color_set(obj, r, g, b, a);
2181 static Elm_Transit_Effect *
2182 _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)
2184 Elm_Transit_Effect_Color *color;
2186 color = ELM_NEW(Elm_Transit_Effect_Color);
2187 if (!color) return NULL;
2189 color->from.r = from_r;
2190 color->from.g = from_g;
2191 color->from.b = from_b;
2192 color->from.a = from_a;
2193 color->to.r = to_r - from_r;
2194 color->to.g = to_g - from_g;
2195 color->to.b = to_b - from_b;
2196 color->to.a = to_a - from_a;
2202 * Add the Color Effect to Elm_Transit.
2204 * @note This API is one of the facades. It creates color effect context
2205 * and add it's required APIs to elm_transit_effect_add.
2207 * @see elm_transit_effect_add()
2209 * @param transit Transit object.
2210 * @param from_r RGB R when effect begins.
2211 * @param from_g RGB G when effect begins.
2212 * @param from_b RGB B when effect begins.
2213 * @param from_a RGB A when effect begins.
2214 * @param to_r RGB R when effect ends.
2215 * @param to_g RGB G when effect ends.
2216 * @param to_b RGB B when effect ends.
2217 * @param to_a RGB A when effect ends.
2218 * @return Color effect context data.
2222 EAPI Elm_Transit_Effect *
2223 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)
2225 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2226 Elm_Transit_Effect *effect_context = _transit_effect_color_context_new(from_r, from_g, from_b, from_a, to_r, to_g, to_b, to_a);
2228 if (!effect_context) return NULL;
2229 elm_transit_effect_add(transit,
2230 _transit_effect_color_op, effect_context,
2231 _transit_effect_color_context_free);
2232 return effect_context;
2235 ///////////////////////////////////////////////////////////////////////////////
2237 ///////////////////////////////////////////////////////////////////////////////
2238 typedef struct _Elm_Transit_Effect_Fade Elm_Transit_Effect_Fade;
2239 typedef struct _Elm_Transit_Effect_Fade_Node Elm_Transit_Effect_Fade_Node;
2241 struct _Elm_Transit_Effect_Fade_Node
2243 Evas_Object *before;
2245 struct _signed_color before_color, after_color;
2248 Eina_Bool inversed : 1;
2251 struct _Elm_Transit_Effect_Fade
2257 _fade_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2259 Elm_Transit_Effect_Fade *fade = data;
2261 Elm_Transit_Effect_Fade_Node *fade_node;
2263 EINA_LIST_FOREACH(fade->nodes, elist, fade_node)
2265 if (fade_node->before == obj)
2266 evas_object_event_callback_del(fade_node->after,
2267 EVAS_CALLBACK_DEL, _fade_object_del_cb);
2268 else if (fade_node->after == obj)
2269 evas_object_event_callback_del(fade_node->before,
2270 EVAS_CALLBACK_DEL, _fade_object_del_cb);
2273 fade->nodes = eina_list_remove_list(fade->nodes, elist);
2280 _fade_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Fade *fade_data)
2282 Elm_Transit_Effect_Fade_Node *fade;
2283 Eina_List *data_list = NULL;
2286 count = eina_list_count(transit->objs);
2287 for (i = 0; i < count; i += 2)
2289 fade = ELM_NEW(Elm_Transit_Effect_Fade_Node);
2292 eina_list_free(data_list);
2296 fade->before = eina_list_nth(transit->objs, i);
2297 fade->after = eina_list_nth(transit->objs, i+1);
2299 evas_object_color_get(fade->before,
2300 &fade->before_color.r, &fade->before_color.g,
2301 &fade->before_color.b, &fade->before_color.a);
2302 evas_object_color_get(fade->after,
2303 &fade->after_color.r, &fade->after_color.g,
2304 &fade->after_color.b, &fade->after_color.a);
2306 fade->before_alpha = (255 - fade->before_color.a);
2307 fade->after_alpha = (255 - fade->after_color.a);
2309 data_list = eina_list_append(data_list, fade);
2311 evas_object_event_callback_add(fade->before,
2312 EVAS_CALLBACK_DEL, _fade_object_del_cb, fade_data);
2313 evas_object_event_callback_add(fade->after,
2314 EVAS_CALLBACK_DEL, _fade_object_del_cb, fade_data);
2320 _transit_effect_fade_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
2322 EINA_SAFETY_ON_NULL_RETURN(effect);
2323 Elm_Transit_Effect_Fade *fade = effect;
2324 Elm_Transit_Effect_Fade_Node *fade_node;
2325 Eina_List *elist, *elist_next;
2327 EINA_LIST_FOREACH_SAFE(fade->nodes, elist, elist_next, fade_node)
2329 evas_object_color_set(fade_node->before, fade_node->before_color.r,
2330 fade_node->before_color.g,
2331 fade_node->before_color.b,
2332 fade_node->before_color.a);
2333 evas_object_color_set(fade_node->after, fade_node->after_color.r,
2334 fade_node->after_color.g,
2335 fade_node->after_color.b,
2336 fade_node->after_color.a);
2338 fade->nodes = eina_list_remove_list(fade->nodes, elist);
2339 evas_object_event_callback_del(fade_node->before,
2340 EVAS_CALLBACK_DEL, _fade_object_del_cb);
2341 evas_object_event_callback_del(fade_node->after,
2342 EVAS_CALLBACK_DEL, _fade_object_del_cb);
2350 _transit_effect_fade_op(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__, double progress)
2352 EINA_SAFETY_ON_NULL_RETURN(effect);
2353 Elm_Transit_Effect_Fade *fade = effect;
2355 Elm_Transit_Effect_Fade_Node *fade_node;
2359 fade->nodes = _fade_nodes_build(transit, fade);
2361 EINA_LIST_FOREACH(fade->nodes, elist, fade_node)
2365 if (!fade_node->inversed)
2367 evas_object_hide(fade_node->after);
2368 evas_object_show(fade_node->before);
2369 fade_node->inversed = EINA_TRUE;
2372 _progress = (1 - (progress * 2));
2374 evas_object_color_set(fade_node->before,
2375 fade_node->before_color.r * _progress,
2376 fade_node->before_color.g * _progress,
2377 fade_node->before_color.b * _progress,
2378 fade_node->before_color.a +
2379 fade_node->before_alpha * (1 - _progress));
2383 if (fade_node->inversed)
2385 evas_object_hide(fade_node->before);
2386 evas_object_show(fade_node->after);
2387 fade_node->inversed = EINA_FALSE;
2390 _progress = ((progress - 0.5) * 2);
2392 evas_object_color_set(fade_node->after,
2393 fade_node->after_color.r * _progress,
2394 fade_node->after_color.g * _progress,
2395 fade_node->after_color.b * _progress,
2396 fade_node->after_color.a +
2397 fade_node->after_alpha * (1 - _progress));
2402 static Elm_Transit_Effect *
2403 _transit_effect_fade_context_new(void)
2405 Elm_Transit_Effect_Fade *fade;
2406 fade = ELM_NEW(Elm_Transit_Effect_Fade);
2407 if (!fade) return NULL;
2412 * Add the Fade Effect to Elm_Transit.
2414 * @note This API is one of the facades. It creates fade effect context
2415 * and add it's required APIs to elm_transit_effect_add.
2416 * @note This effect is applied to each pair of objects in the order they are listed
2417 * in the transit list of objects. The first object in the pair will be the
2418 * "before" object and the second will be the "after" object.
2420 * @see elm_transit_effect_add()
2422 * @param transit Transit object.
2423 * @return Fade effect context data.
2426 * @warning Is higher recommended just create a transit with this effect when
2427 * the window that the objects of the transit belongs has already been created.
2428 * This is because this effect needs the color information about the objects,
2429 * and if the window was not created yet, it can get a wrong information.
2431 EAPI Elm_Transit_Effect *
2432 elm_transit_effect_fade_add(Elm_Transit *transit)
2434 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2436 Elm_Transit_Effect *effect_context = _transit_effect_fade_context_new();
2437 if (!effect_context) return NULL;
2438 elm_transit_effect_add(transit,
2439 _transit_effect_fade_op, effect_context,
2440 _transit_effect_fade_context_free);
2441 return effect_context;
2445 ///////////////////////////////////////////////////////////////////////////////
2447 ///////////////////////////////////////////////////////////////////////////////
2448 typedef struct _Elm_Transit_Effect_Blend Elm_Transit_Effect_Blend;
2449 typedef struct _Elm_Transit_Effect_Blend_Node Elm_Transit_Effect_Blend_Node;
2451 struct _Elm_Transit_Effect_Blend_Node
2453 Evas_Object *before;
2455 struct _signed_color from, to;
2458 struct _Elm_Transit_Effect_Blend
2464 _blend_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2466 Elm_Transit_Effect_Blend *blend = data;
2468 Elm_Transit_Effect_Blend_Node *blend_node;
2470 EINA_LIST_FOREACH(blend->nodes, elist, blend_node)
2472 if (blend_node->after == obj)
2473 evas_object_event_callback_del(blend_node->before,
2474 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2475 else if (blend_node->before == obj)
2476 evas_object_event_callback_del(blend_node->after,
2477 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2480 blend->nodes = eina_list_remove_list(blend->nodes, elist);
2487 _blend_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Blend *blend)
2489 Elm_Transit_Effect_Blend_Node *blend_node;
2490 Eina_List *data_list = NULL;
2493 count = eina_list_count(transit->objs);
2494 for (i = 0; i < (count - 1); i += 2)
2496 blend_node = ELM_NEW(Elm_Transit_Effect_Blend_Node);
2499 eina_list_free(data_list);
2503 blend_node->before = eina_list_nth(transit->objs, i);
2504 blend_node->after = eina_list_nth(transit->objs, i + 1);
2505 evas_object_show(blend_node->before);
2506 evas_object_show(blend_node->after);
2508 evas_object_color_get(blend_node->before, &blend_node->from.r,
2509 &blend_node->from.g, &blend_node->from.b,
2510 &blend_node->from.a);
2511 evas_object_color_get(blend_node->after, &blend_node->to.r,
2512 &blend_node->to.g, &blend_node->to.b,
2515 data_list = eina_list_append(data_list, blend_node);
2517 evas_object_event_callback_add(blend_node->before,
2518 EVAS_CALLBACK_DEL, _blend_object_del_cb, blend);
2519 evas_object_event_callback_add(blend_node->after,
2520 EVAS_CALLBACK_DEL, _blend_object_del_cb, blend);
2526 _transit_effect_blend_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
2528 EINA_SAFETY_ON_NULL_RETURN(effect);
2529 Elm_Transit_Effect_Blend *blend = effect;
2530 Elm_Transit_Effect_Blend_Node *blend_node;
2531 Eina_List *elist, *elist_next;
2533 EINA_LIST_FOREACH_SAFE(blend->nodes, elist, elist_next, blend_node)
2535 evas_object_color_set(blend_node->before,
2536 blend_node->from.r, blend_node->from.g,
2537 blend_node->from.b, blend_node->from.a);
2538 evas_object_color_set(blend_node->after, blend_node->to.r,
2539 blend_node->to.g, blend_node->to.b,
2542 if (elm_transit_auto_reverse_get(transit))
2543 evas_object_hide(blend_node->after);
2545 evas_object_hide(blend_node->before);
2547 blend->nodes = eina_list_remove_list(blend->nodes, elist);
2549 evas_object_event_callback_del(blend_node->before,
2550 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2551 evas_object_event_callback_del(blend_node->after,
2552 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2559 _transit_effect_blend_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2561 EINA_SAFETY_ON_NULL_RETURN(effect);
2562 EINA_SAFETY_ON_NULL_RETURN(transit);
2563 Elm_Transit_Effect_Blend *blend = effect;
2564 Elm_Transit_Effect_Blend_Node *blend_node;
2567 if (!blend->nodes) blend->nodes = _blend_nodes_build(transit, blend);
2569 EINA_LIST_FOREACH(blend->nodes, elist, blend_node)
2571 evas_object_color_set(blend_node->before,
2572 (int)(blend_node->from.r * (1 - progress)),
2573 (int)(blend_node->from.g * (1 - progress)),
2574 (int)(blend_node->from.b * (1 - progress)),
2575 (int)(blend_node->from.a * (1 - progress)));
2576 evas_object_color_set(blend_node->after,
2577 (int)(blend_node->to.r * progress),
2578 (int)(blend_node->to.g * progress),
2579 (int)(blend_node->to.b * progress),
2580 (int)(blend_node->to.a * progress));
2584 static Elm_Transit_Effect *
2585 _transit_effect_blend_context_new(void)
2587 Elm_Transit_Effect_Blend *blend;
2589 blend = ELM_NEW(Elm_Transit_Effect_Blend);
2590 if (!blend) return NULL;
2595 * Add the Blend Effect to Elm_Transit.
2597 * @note This API is one of the facades. It creates blend effect context
2598 * and add it's required APIs to elm_transit_effect_add.
2599 * @note This effect is applied to each pair of objects in the order they are listed
2600 * in the transit list of objects. The first object in the pair will be the
2601 * "before" object and the second will be the "after" object.
2603 * @see elm_transit_effect_add()
2605 * @param transit Transit object.
2606 * @return Blend effect context data.
2609 * @warning Is higher recommended just create a transit with this effect when
2610 * the window that the objects of the transit belongs has already been created.
2611 * This is because this effect needs the color information about the objects,
2612 * and if the window was not created yet, it can get a wrong information.
2614 EAPI Elm_Transit_Effect *
2615 elm_transit_effect_blend_add(Elm_Transit *transit)
2617 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2618 Elm_Transit_Effect *effect_context = _transit_effect_blend_context_new();
2620 if (!effect_context) return NULL;
2621 elm_transit_effect_add(transit,
2622 _transit_effect_blend_op, effect_context,
2623 _transit_effect_blend_context_free);
2624 return effect_context;
2628 ///////////////////////////////////////////////////////////////////////////////
2630 ///////////////////////////////////////////////////////////////////////////////
2631 typedef struct _Elm_Transit_Effect_Rotation Elm_Transit_Effect_Rotation;
2633 struct _Elm_Transit_Effect_Rotation
2639 _transit_effect_rotation_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
2641 Elm_Transit_Effect_Rotation *rotation = effect;
2646 _transit_effect_rotation_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2648 EINA_SAFETY_ON_NULL_RETURN(effect);
2649 EINA_SAFETY_ON_NULL_RETURN(transit);
2650 Elm_Transit_Effect_Rotation *rotation = effect;
2652 Evas_Coord x, y, w, h;
2654 float half_w, half_h;
2658 map = evas_map_new(4);
2661 EINA_LIST_FOREACH(transit->objs, elist, obj)
2663 evas_map_util_points_populate_from_object_full(map, obj, 0);
2664 degree = rotation->from + (float)(progress * rotation->to);
2666 evas_object_geometry_get(obj, &x, &y, &w, &h);
2668 half_w = (float)w * 0.5;
2669 half_h = (float)h * 0.5;
2671 evas_map_util_rotate(map, degree, x + half_w, y + half_h);
2672 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, _TRANSIT_FOCAL);
2673 evas_object_map_enable_set(obj, EINA_TRUE);
2674 evas_object_map_set(obj, map);
2679 static Elm_Transit_Effect *
2680 _transit_effect_rotation_context_new(float from_degree, float to_degree)
2682 Elm_Transit_Effect_Rotation *rotation;
2684 rotation = ELM_NEW(Elm_Transit_Effect_Rotation);
2685 if (!rotation) return NULL;
2687 rotation->from = from_degree;
2688 rotation->to = to_degree - from_degree;
2694 * Add the Rotation Effect to Elm_Transit.
2696 * @note This API is one of the facades. It creates rotation effect context
2697 * and add it's required APIs to elm_transit_effect_add.
2699 * @see elm_transit_effect_add()
2701 * @param transit Transit object.
2702 * @param from_degree Degree when effect begins.
2703 * @param to_degree Degree when effect is ends.
2704 * @return Rotation effect context data.
2707 * @warning Is higher recommended just create a transit with this effect when
2708 * the window that the objects of the transit belongs has already been created.
2709 * This is because this effect needs the geometry information about the objects,
2710 * and if the window was not created yet, it can get a wrong information.
2712 EAPI Elm_Transit_Effect *
2713 elm_transit_effect_rotation_add(Elm_Transit *transit, float from_degree, float to_degree)
2715 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2716 Elm_Transit_Effect *effect_context = _transit_effect_rotation_context_new(from_degree, to_degree);
2718 if (!effect_context) return NULL;
2719 elm_transit_effect_add(transit,
2720 _transit_effect_rotation_op, effect_context,
2721 _transit_effect_rotation_context_free);
2722 return effect_context;
2726 ///////////////////////////////////////////////////////////////////////////////
2727 //ImageAnimation Effect
2728 ///////////////////////////////////////////////////////////////////////////////
2729 typedef struct _Elm_Transit_Effect_Image_Animation Elm_Transit_Effect_Image_Animation;
2731 struct _Elm_Transit_Effect_Image_Animation
2737 _transit_effect_image_animation_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
2739 EINA_SAFETY_ON_NULL_RETURN(effect);
2740 Elm_Transit_Effect_Image_Animation *image_animation = effect;
2742 Eina_List *elist, *elist_next;
2744 EINA_LIST_FOREACH_SAFE(image_animation->images, elist, elist_next, image)
2746 image_animation->images =
2747 eina_list_remove_list(image_animation->images, elist);
2748 eina_stringshare_del(image);
2751 free(image_animation);
2755 _transit_effect_image_animation_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2757 EINA_SAFETY_ON_NULL_RETURN(effect);
2758 EINA_SAFETY_ON_NULL_RETURN(transit);
2762 Elm_Transit_Effect_Image_Animation *image_animation = effect;
2763 unsigned int count = 0;
2766 type = eina_stringshare_add("icon");
2767 len = eina_list_count(image_animation->images);
2769 if (!len) count = floor(progress * len);
2770 else count = floor(progress * (len - 1));
2772 EINA_LIST_FOREACH(transit->objs, elist, obj)
2774 if (elm_widget_type_check(obj, type))
2775 elm_icon_file_set(obj,
2776 eina_list_nth(image_animation->images, count), NULL);
2779 eina_stringshare_del(type);
2782 static Elm_Transit_Effect *
2783 _transit_effect_image_animation_context_new(Eina_List *images)
2785 Elm_Transit_Effect_Image_Animation *image_animation;
2786 image_animation = ELM_NEW(Elm_Transit_Effect_Image_Animation);
2788 if (!image_animation) return NULL;
2789 image_animation->images = images;
2790 return image_animation;
2794 * Add the ImageAnimation Effect to Elm_Transit.
2796 * @note This API is one of the facades. It creates image animation effect context
2797 * and add it's required APIs to elm_transit_effect_add.
2798 * The @p images parameter is a list images paths. This list and
2799 * its contents will be deleted at the end of the effect by
2800 * elm_transit_effect_image_animation_context_free() function.
2804 * char buf[PATH_MAX];
2805 * Eina_List *images = NULL;
2806 * Elm_Transit *transi = elm_transit_add();
2808 * snprintf(buf, sizeof(buf), "%s/images/icon_11.png", PACKAGE_DATA_DIR);
2809 * images = eina_list_append(images, eina_stringshare_add(buf));
2811 * snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
2812 * images = eina_list_append(images, eina_stringshare_add(buf));
2813 * elm_transit_effect_image_animation_add(transi, images);
2817 * @see elm_transit_effect_add()
2819 * @param transit Transit object.
2820 * @param images Eina_List of images file paths. This list and
2821 * its contents will be deleted at the end of the effect by
2822 * elm_transit_effect_image_animation_context_free() function.
2823 * @return Image Animation effect context data.
2827 EAPI Elm_Transit_Effect *
2828 elm_transit_effect_image_animation_add(Elm_Transit *transit, Eina_List *images)
2830 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2831 Elm_Transit_Effect *effect = _transit_effect_image_animation_context_new(images);
2833 if (!effect) return NULL;
2834 elm_transit_effect_add(transit,
2835 _transit_effect_image_animation_op, effect,
2836 _transit_effect_image_animation_context_free);