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 = data;
154 Elm_Obj_Data *obj_data = eina_hash_find(transit->objs_data_hash, obj);
155 if (!obj_data) return;
156 eina_hash_del_by_key(transit->objs_data_hash, obj);
157 evas_object_pass_events_set(obj, obj_data->pass_events);
159 free(obj_data->state);
161 transit->objs = eina_list_remove(transit->objs, obj);
162 if (!transit->objs) elm_transit_del(transit);
166 //Since evas map have a afterimage bug for this time.
167 //This function is added temporary.
169 _obj_damage_area_set(Evas_Object *obj)
172 Evas_Coord_Point coords;
173 Evas_Coord_Point min, max;
176 map = evas_object_map_get(obj);
179 evas_map_point_coord_get(map, 0, &coords.x, &coords.y, NULL);
183 for (i = 1; i < 4; ++i)
185 evas_map_point_coord_get(map, i, &coords.x, &coords.y, NULL);
187 if (coords.x < min.x)
189 else if (coords.x > max.x)
192 if (coords.y < min.y)
194 else if (coords.y > max.y)
198 evas_damage_rectangle_add(evas_object_evas_get(obj),
200 max.x - min.x, max.y - min.y);
206 _elm_transit_object_remove(Elm_Transit *transit, Evas_Object *obj)
208 Elm_Obj_Data *obj_data = eina_hash_find(transit->objs_data_hash, obj);
209 if (!obj_data) return;
210 eina_hash_del_by_key(transit->objs_data_hash, obj);
211 Elm_Obj_State *state = obj_data->state;
213 evas_object_pass_events_set(obj, obj_data->pass_events);
217 //recover the states of the object.
218 if (!transit->state_keep)
220 evas_object_move(obj, state->x, state->y);
221 evas_object_resize(obj, state->w, state->h);
222 evas_object_color_set(obj, state->r, state->g, state->b, state->a);
223 if (state->visible) evas_object_show(obj);
224 else evas_object_hide(obj);
225 if (state->map_enabled)
226 evas_object_map_enable_set(obj, EINA_TRUE);
228 evas_object_map_enable_set(obj, EINA_FALSE);
230 evas_object_map_set(obj, state->map);
233 //Since evas map have a afterimage bug for this time.
234 //This line is added temporary.
235 _obj_damage_area_set(obj);
242 //remove duplicated objects
243 //TODO: Need to consider about optimizing here
246 if (!eina_list_data_find_list(transit->objs, obj))
248 transit->objs = eina_list_remove(transit->objs, obj);
251 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_DEL,
252 _elm_transit_object_remove_cb,
257 _elm_transit_effect_del(Elm_Transit *transit, Elm_Transit_Effect_Module *effect_module)
259 if (effect_module->end_cb)
260 effect_module->end_cb(effect_module->effect, transit);
265 _remove_dead_effects(Elm_Transit *transit)
267 Elm_Transit_Effect_Module *effect_module;
269 EINA_INLIST_FOREACH(transit->effect_list, effect_module)
271 if (effect_module->deleted)
273 _elm_transit_effect_del(transit, effect_module);
274 transit->effects_pending_del--;
275 if (!transit->effects_pending_del) return;
281 _elm_transit_del(Elm_Transit *transit)
283 Elm_Transit_Effect_Module *effect_module;
284 Elm_Transit *chain_transit;
285 Eina_List *elist, *elist_next;
287 EINA_LIST_FOREACH_SAFE(transit->next_chain_transits, elist, elist_next, chain_transit)
289 if (transit->prev_chain_transit)
290 transit->prev_chain_transit->next_chain_transits = eina_list_remove(transit->prev_chain_transit->next_chain_transits, transit);
291 chain_transit->prev_chain_transit = NULL;
294 eina_list_free(transit->next_chain_transits);
296 if (transit->animator)
297 ecore_animator_del(transit->animator);
299 while (transit->effect_list)
301 effect_module = EINA_INLIST_CONTAINER_GET(transit->effect_list, Elm_Transit_Effect_Module);
302 transit->effect_list = eina_inlist_remove(transit->effect_list, transit->effect_list);
305 while (transit->objs)
306 _elm_transit_object_remove(transit, eina_list_data_get(transit->objs));
308 transit->deleted = EINA_TRUE;
310 if (transit->del_data.func)
311 transit->del_data.func(transit->del_data.arg, transit);
313 eina_hash_free(transit->objs_data_hash);
315 EINA_MAGIC_SET(transit, EINA_MAGIC_NONE);
320 _chain_transits_go(Elm_Transit *transit)
322 Eina_List *elist, *elist_next;
323 Elm_Transit *chain_transit;
325 EINA_LIST_FOREACH_SAFE(transit->next_chain_transits, elist, elist_next, chain_transit)
326 elm_transit_go(chain_transit);
330 _transit_animate_op(Elm_Transit *transit, double progress)
332 Elm_Transit_Effect_Module *effect_module;
335 EINA_INLIST_FOREACH(transit->effect_list, effect_module)
337 if (transit->deleted) break;
338 if (!effect_module->deleted)
339 effect_module->transition_cb(effect_module->effect, transit, progress);
343 if (transit->walking) return;
345 if (transit->deleted) _elm_transit_del(transit);
346 else if (transit->effects_pending_del) _remove_dead_effects(transit);
350 _animator_animate_cb(void *data)
352 Elm_Transit *transit = data;
353 double elapsed_time, duration;
355 transit->time.current = ecore_loop_time_get();
356 elapsed_time = transit->time.current - transit->time.begin;
357 duration = transit->time.duration + transit->time.delayed;
359 if (elapsed_time > duration)
360 elapsed_time = duration;
362 transit->progress = elapsed_time / duration;
363 switch (transit->tween_mode)
365 case ELM_TRANSIT_TWEEN_MODE_ACCELERATE:
366 transit->progress = 1.0 - sin((ELM_PI / 2.0) + (transit->progress * ELM_PI / 2.0));
368 case ELM_TRANSIT_TWEEN_MODE_DECELERATE:
369 transit->progress = sin(transit->progress * ELM_PI / 2.0);
371 case ELM_TRANSIT_TWEEN_MODE_SINUSOIDAL:
372 transit->progress = (1.0 - cos(transit->progress * ELM_PI)) / 2.0;
379 if (transit->repeat.reverse) transit->progress = 1 - transit->progress;
381 if (transit->time.duration > 0) _transit_animate_op(transit, transit->progress);
383 /* Not end. Keep going. */
384 if (elapsed_time < duration) return ECORE_CALLBACK_RENEW;
386 /* Repeat and reverse and time done! */
387 if ((transit->repeat.count >= 0) &&
388 (transit->repeat.current == transit->repeat.count) &&
389 ((!transit->auto_reverse) || transit->repeat.reverse))
391 /* run chain transit */
392 if (transit->next_chain_transits)
393 _chain_transits_go(transit);
395 elm_transit_del(transit);
396 return ECORE_CALLBACK_CANCEL;
400 if (!transit->auto_reverse || transit->repeat.reverse)
402 transit->repeat.current++;
403 transit->repeat.reverse = EINA_FALSE;
405 else transit->repeat.reverse = EINA_TRUE;
407 transit->time.begin = ecore_loop_time_get();
409 return ECORE_CALLBACK_RENEW;
415 * @note Is not necessary to delete the transit object, it will be deleted at
416 * the end of its operation.
417 * @note The transit will start playing when the program enter in the main loop, is not
418 * necessary to give a start to the transit.
420 * @param duration The duration of the transit in seconds. When transit starts
421 * to run, it will last a @p duration time.
422 * @return The transit object.
427 elm_transit_add(void)
429 Elm_Transit *transit = ELM_NEW(Elm_Transit);
430 if (!transit) return NULL;
432 EINA_MAGIC_SET(transit, ELM_TRANSIT_MAGIC);
434 elm_transit_tween_mode_set(transit, ELM_TRANSIT_TWEEN_MODE_LINEAR);
436 transit->objs_data_hash = eina_hash_pointer_new(NULL);
441 * Stops the animation and delete the @p transit object.
443 * Call this function if you wants to stop the animation before the duration
444 * time. Make sure the @p transit object is still alive with
445 * elm_transit_del_cb_set() function.
446 * All added effects will be deleted, calling its repective data_free_cb
447 * functions. The function setted by elm_transit_del_cb_set() will be called.
449 * @see elm_transit_del_cb_set()
451 * @param transit The transit object to be deleted.
454 * @warning Just call this function if you are sure the transit is alive.
457 elm_transit_del(Elm_Transit *transit)
459 ELM_TRANSIT_CHECK_OR_RETURN(transit);
461 if (transit->walking) transit->deleted = EINA_TRUE;
462 else _elm_transit_del(transit);
466 * Add a new effect to the transit.
468 * @note The cb function and the data are the key to the effect. If you try to
469 * add an already added effect, nothing is done.
470 * @note After the first addition of an effect in @p transit, if its
471 * effect list become empty again, the @p transit will be killed by
472 * elm_transit_del(transit) function.
476 * Elm_Transit *transit = elm_transit_add();
477 * elm_transit_effect_add(transit,
478 * elm_transit_effect_blend_op,
479 * elm_transit_effect_blend_context_new(),
480 * elm_transit_effect_blend_context_free);
483 * @param transit The transit object.
484 * @param cb The operation function. It is called when the animation begins,
485 * it is the function that actually performs the animation. It is called with
486 * the @p data, @p transit and the time progression of the animation (a double
487 * value between 0.0 and 1.0).
488 * @param data The context data of the effect.
489 * @param data_free_cb The function to free the context data, it will be called
490 * at the end of the effect, it must finalize the animation and free the
494 * @warning The transit free the context data at the and of the transition with
495 * the data_free_cb function, do not use the context data in another transit.
498 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)
500 ELM_TRANSIT_CHECK_OR_RETURN(transit);
501 EINA_SAFETY_ON_NULL_RETURN(transition_cb);
502 Elm_Transit_Effect_Module *effect_module;
504 EINA_INLIST_FOREACH(transit->effect_list, effect_module)
505 if ((effect_module->transition_cb == transition_cb) && (effect_module->effect == effect)) return;
507 effect_module = ELM_NEW(Elm_Transit_Effect_Module);
508 if (!effect_module) return;
510 effect_module->end_cb = end_cb;
511 effect_module->transition_cb = transition_cb;
512 effect_module->effect = effect;
514 transit->effect_list = eina_inlist_append(transit->effect_list, (Eina_Inlist*) effect_module);
518 * Delete an added effect.
520 * This function will remove the effect from the @p transit, calling the
521 * data_free_cb to free the @p data.
523 * @see elm_transit_effect_add()
525 * @note If the effect is not found, nothing is done.
526 * @note If the effect list become empty, this function will call
527 * elm_transit_del(transit), that is, it will kill the @p transit.
529 * @param transit The transit object.
530 * @param cb The operation function.
531 * @param data The context data of the effect.
536 elm_transit_effect_del(Elm_Transit *transit, Elm_Transit_Effect_Transition_Cb transition_cb, Elm_Transit_Effect *effect)
538 ELM_TRANSIT_CHECK_OR_RETURN(transit);
539 EINA_SAFETY_ON_NULL_RETURN(transition_cb);
540 Elm_Transit_Effect_Module *effect_module;
542 EINA_INLIST_FOREACH(transit->effect_list, effect_module)
544 if ((effect_module->transition_cb == transition_cb) && (effect_module->effect == effect))
546 if (transit->walking)
548 effect_module->deleted = EINA_TRUE;
549 transit->effects_pending_del++;
553 _elm_transit_effect_del(transit, effect_module);
554 if (!transit->effect_list) elm_transit_del(transit);
562 * Add new object to apply the effects.
564 * @note After the first addition of an object in @p transit, if its
565 * object list become empty again, the @p transit will be killed by
566 * elm_transit_del(transit) function.
567 * @note If the @p obj belongs to another transit, the @p obj will be
568 * removed from it and it will only belong to the @p transit. If the old
569 * transit stays without objects, it will die.
570 * @note When you add an object into the @p transit, its state from
571 * evas_object_pass_events_get(obj) is saved, and it is applied when the
572 * transit ends, if you change this state whith evas_object_pass_events_set()
573 * after add the object, this state will change again when @p transit stops to
576 * @param transit The transit object.
577 * @param obj Object to be animated.
580 * @warning It is not allowed to add a new object after transit begins to go.
583 elm_transit_object_add(Elm_Transit *transit, Evas_Object *obj)
585 ELM_TRANSIT_CHECK_OR_RETURN(transit);
586 EINA_SAFETY_ON_NULL_RETURN(obj);
587 Elm_Obj_Data *obj_data;
589 obj_data = ELM_NEW(Elm_Obj_Data);
590 obj_data->pass_events = evas_object_pass_events_get(obj);
591 if (!transit->event_enabled)
592 evas_object_pass_events_set(obj, EINA_TRUE);
594 evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
595 _elm_transit_object_remove_cb,
598 transit->objs = eina_list_append(transit->objs, obj);
599 eina_hash_add(transit->objs_data_hash, obj, obj_data);
601 if (!transit->state_keep)
602 _elm_transit_obj_states_save(obj, obj_data);
606 * Removes an added object from the transit.
608 * @note If the @p obj is not in the @p transit, nothing is done.
609 * @note If the list become empty, this function will call
610 * elm_transit_del(transit), that is, it will kill the @p transit.
612 * @param transit The transit object.
613 * @param obj Object to be removed from @p transit.
616 * @warning It is not allowed to remove objects after transit begins to go.
619 elm_transit_object_remove(Elm_Transit *transit, Evas_Object *obj)
621 ELM_TRANSIT_CHECK_OR_RETURN(transit);
622 EINA_SAFETY_ON_NULL_RETURN(obj);
623 Elm_Obj_Data *obj_data;
625 obj_data = eina_hash_find(transit->objs_data_hash, obj);
626 if (!obj_data) return;
628 _elm_transit_object_remove(transit, obj);
629 if (!transit->objs) elm_transit_del(transit);
633 * Get the objects of the transit.
635 * @param transit The transit object.
636 * @return a Eina_List with the objects from the transit.
640 EAPI const Eina_List *
641 elm_transit_objects_get(const Elm_Transit *transit)
643 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
644 return transit->objs;
648 * Set the event enabled when transit is operating.
650 * If @p enabled is EINA_TRUE, the objects of the transit will receives
651 * events from mouse and keyboard during the animation.
652 * @note When you add an object with elm_transit_object_add(), its state from
653 * evas_object_pass_events_get(obj) is saved, and it is applied when the
654 * transit ends, if you change this state with evas_object_pass_events_set()
655 * after adding the object, this state will change again when @p transit stops
658 * @param transit The transit object.
659 * @param enabled Disable or enable.
664 elm_transit_event_enabled_set(Elm_Transit *transit, Eina_Bool enabled)
666 ELM_TRANSIT_CHECK_OR_RETURN(transit);
668 if (transit->event_enabled == enabled) return;
669 transit->event_enabled = !!enabled;
670 eina_hash_foreach(transit->objs_data_hash, _hash_foreach_pass_events_set, transit);
674 * Get the value of event enabled status.
676 * @see elm_transit_event_enabled_set()
678 * @param transit The Transit object
679 * @return EINA_TRUE, when event is enabled. If @p transit is NULL
680 * EINA_FALSE is returned
685 elm_transit_event_enabled_get(const Elm_Transit *transit)
687 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
688 return transit->event_enabled;
693 * Set the event enabled when transit is operating.
695 * If @p disabled is EINA_TRUE, the objects of the transit will receives
696 * events from mouse and keyboard during the animation.
697 * @note When you add an object with elm_transit_object_add(), its state from
698 * evas_object_pass_events_get(obj) is saved, and it is applied when the
699 * transit ends, if you change this state with evas_object_pass_events_set()
700 * after add the object, this state will change again when @p transit stops to
703 * @see elm_transit_event_enabled_set()
705 * @param transit The transit object.
706 * @param disabled Disable or enable.
710 EINA_DEPRECATED EAPI void
711 elm_transit_event_block_set(Elm_Transit *transit, Eina_Bool disabled)
713 elm_transit_event_enabled_set(transit, disabled);
718 * Get the value of event block enabled status.
720 * @see elm_transit_event_enabled_set(), elm_transit_event_enabled_get()
722 * @param transit The Transit object
723 * @return EINA_TRUE, when event is enabled. If @p transit is NULL
724 * EINA_FALSE is returned
728 EINA_DEPRECATED EAPI Eina_Bool
729 elm_transit_event_block_get(const Elm_Transit *transit)
731 return !elm_transit_event_enabled_get(transit);
735 * Set the user-callback function when the transit is deleted.
737 * @note Using this function twice will overwrite the first function setted.
738 * @note the @p transit object will be deleted after call @p cb function.
740 * @param transit The transit object.
741 * @param cb Callback function pointer. This function will be called before
742 * the deletion of the transit.
743 * @param data Callback funtion user data. It is the @p op parameter.
748 elm_transit_del_cb_set(Elm_Transit *transit, void (*cb) (void *data, Elm_Transit *transit), void *data)
750 ELM_TRANSIT_CHECK_OR_RETURN(transit);
751 transit->del_data.func = cb;
752 transit->del_data.arg = data;
756 * Set reverse effect automatically.
758 * If auto reverse is setted, after running the effects with the progress
759 * parameter from 0 to 1, it will call the effecs again with the progress
760 * from 1 to 0. The transit will last for a time iqual to (2 * duration * repeat),
761 * where the duration was setted with the function elm_transit_add and
762 * the repeat with the function elm_transit_repeat_times_set().
764 * @param transit The transit object.
765 * @param reverse EINA_TRUE means the auto_reverse is on.
770 elm_transit_auto_reverse_set(Elm_Transit *transit, Eina_Bool reverse)
772 ELM_TRANSIT_CHECK_OR_RETURN(transit);
773 transit->auto_reverse = reverse;
777 * Get if the auto reverse is on.
779 * @see elm_transit_auto_reverse_set()
781 * @param transit The transit object.
782 * @return EINA_TRUE means auto reverse is on. If @p transit is NULL
783 * EINA_FALSE is returned
788 elm_transit_auto_reverse_get(const Elm_Transit *transit)
790 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
791 return transit->auto_reverse;
795 * Set the transit repeat count. Effect will be repeated by repeat count.
797 * This function sets the number of repetition the transit will run after
798 * the first one, that is, if @p repeat is 1, the transit will run 2 times.
799 * If the @p repeat is a negative number, it will repeat infinite times.
801 * @note If this function is called during the transit execution, the transit
802 * will run @p repeat times, ignoring the times it already performed.
804 * @param transit The transit object
805 * @param repeat Repeat count
810 elm_transit_repeat_times_set(Elm_Transit *transit, int repeat)
812 ELM_TRANSIT_CHECK_OR_RETURN(transit);
813 transit->repeat.count = repeat;
814 transit->repeat.current = 0;
818 * Get the transit repeat count.
820 * @see elm_transit_repeat_times_set()
822 * @param transit The Transit object.
823 * @return The repeat count. If @p transit is NULL
829 elm_transit_repeat_times_get(const Elm_Transit *transit)
831 ELM_TRANSIT_CHECK_OR_RETURN(transit, 0);
832 return transit->repeat.count;
836 * Set the transit animation acceleration type.
838 * This function sets the tween mode of the transit that can be:
839 * ELM_TRANSIT_TWEEN_MODE_LINEAR - The default mode.
840 * ELM_TRANSIT_TWEEN_MODE_SINUSOIDAL - Starts in accelerate mode and ends decelerating.
841 * ELM_TRANSIT_TWEEN_MODE_DECELERATE - The animation will be slowed over time.
842 * ELM_TRANSIT_TWEEN_MODE_ACCELERATE - The animation will accelerate over time.
844 * @param transit The transit object.
845 * @param tween_mode The tween type.
850 elm_transit_tween_mode_set(Elm_Transit *transit, Elm_Transit_Tween_Mode tween_mode)
852 ELM_TRANSIT_CHECK_OR_RETURN(transit);
853 transit->tween_mode = tween_mode;
857 * Get the transit animation acceleration type.
859 * @note @p transit can not be NULL
861 * @param transit The transit object.
862 * @return The tween type. If @p transit is NULL
863 * ELM_TRANSIT_TWEEN_MODE_LINEAR is returned.
867 EAPI Elm_Transit_Tween_Mode
868 elm_transit_tween_mode_get(const Elm_Transit *transit)
870 ELM_TRANSIT_CHECK_OR_RETURN(transit, ELM_TRANSIT_TWEEN_MODE_LINEAR);
871 return transit->tween_mode;
875 * Set the transit animation time
877 * @note @p transit can not be NULL
879 * @param transit The transit object.
880 * @param duration The animation time.
885 elm_transit_duration_set(Elm_Transit *transit, double duration)
887 ELM_TRANSIT_CHECK_OR_RETURN(transit);
888 if (transit->animator) return;
889 transit->time.duration = duration;
893 * Get the transit animation time
895 * @note @p transit can not be NULL
897 * @param transit The transit object.
899 * @return The transit animation time.
904 elm_transit_duration_get(const Elm_Transit *transit)
906 ELM_TRANSIT_CHECK_OR_RETURN(transit, 0.0);
907 return transit->time.duration;
911 * Starts the transition.
912 * Once this API is called, the transit begins to measure the time.
914 * @note @p transit can not be NULL
916 * @param transit The transit object.
921 elm_transit_go(Elm_Transit *transit)
923 ELM_TRANSIT_CHECK_OR_RETURN(transit);
925 if (transit->animator)
926 ecore_animator_del(transit->animator);
928 transit->time.paused = 0;
929 transit->time.delayed = 0;
930 transit->time.begin = ecore_loop_time_get();
931 transit->animator = ecore_animator_add(_animator_animate_cb, transit);
935 * Pause/Resume the transition.
936 * If you call elm_transit_go again, paused states will affect no anymore.
938 * @note @p transit can not be NULL
940 * @param transit The transit object.
945 elm_transit_paused_set(Elm_Transit *transit, Eina_Bool paused)
947 ELM_TRANSIT_CHECK_OR_RETURN(transit);
949 if (!transit->animator) return;
953 if (transit->time.paused > 0)
955 ecore_animator_freeze(transit->animator);
956 transit->time.paused = ecore_loop_time_get();
960 if (transit->time.paused == 0)
962 ecore_animator_thaw(transit->animator);
963 transit->time.delayed += (ecore_loop_time_get() - transit->time.paused);
964 transit->time.paused = 0;
969 * Get the value of paused status.
971 * @see elm_transit_paused_set()
973 * @note @p transit can not be NULL
975 * @param transit The transit object.
976 * @return EINA_TRUE means transition is paused. If @p transit is NULL
977 * EINA_FALSE is returned
982 elm_transit_paused_get(const Elm_Transit *transit)
984 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
986 if (transit->time.paused == 0)
993 * Get the time progression of the animation (a double value between 0.0 and 1.0).
995 * @note @p transit can not be NULL
997 * @param transit The transit object.
999 * @return The time progression value. If @p transit is NULL
1005 elm_transit_progress_value_get(const Elm_Transit *transit)
1007 ELM_TRANSIT_CHECK_OR_RETURN(transit, 0);
1008 return transit->progress;
1014 * Enable/disable keeping up the objects states.
1015 * If it is not kept, the objects states will be reset when transition ends.
1017 * @note @p transit can not be NULL.
1018 * @note One state includes geometry, color, map data.
1020 * @param transit The transit object.
1021 * @param state_keep Keeping or Non Keeping.
1026 elm_transit_objects_final_state_keep_set(Elm_Transit *transit, Eina_Bool state_keep)
1028 ELM_TRANSIT_CHECK_OR_RETURN(transit);
1029 if (transit->state_keep == state_keep) return;
1030 if (transit->animator) return;
1031 transit->state_keep = !!state_keep;
1032 if (state_keep) return;
1033 eina_hash_foreach(transit->objs_data_hash, _hash_foreach_obj_states_save, NULL);
1037 * Get a value whether the objects states will be reset or not.
1039 * @note @p transit can not be NULL
1041 * @see elm_transit_objects_final_state_keep_set()
1043 * @param transit The transit object.
1044 * @return EINA_TRUE means the states of the objects will be reset.
1045 * If @p transit is NULL, EINA_FALSE is returned
1050 elm_transit_objects_final_state_keep_get(const Elm_Transit *transit)
1052 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
1053 return transit->state_keep;
1057 * Makes the chain relationship between two transits.
1059 * @note @p transit can not be NULL. Transit would have multiple chain transits.
1060 * @note @p chain_transit can not be NULL. Chain transits could be chained to the only one transit.
1062 * @param transit The transit object.
1063 * @param chain_transit The chain transit object. This transit will be operated * after transit is done.
1068 elm_transit_chain_transit_add(Elm_Transit *transit, Elm_Transit *chain_transit)
1070 ELM_TRANSIT_CHECK_OR_RETURN(transit);
1071 ELM_TRANSIT_CHECK_OR_RETURN(chain_transit);
1073 if (transit == chain_transit) return;
1074 if (transit == chain_transit->prev_chain_transit) return;
1076 if (chain_transit->prev_chain_transit)
1077 chain_transit->prev_chain_transit->next_chain_transits = eina_list_remove(chain_transit->prev_chain_transit->next_chain_transits, chain_transit);
1079 chain_transit->prev_chain_transit = transit;
1080 transit->next_chain_transits = eina_list_append(transit->next_chain_transits, chain_transit);
1084 * Get the current chain transit list.
1086 * @note @p transit can not be NULL.
1088 * @param transit The transit object.
1089 * @return chain transit list.
1094 elm_transit_chain_transits_get(const Elm_Transit * transit)
1096 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1097 return transit->next_chain_transits;
1100 ///////////////////////////////////////////////////////////////////////////////
1102 ///////////////////////////////////////////////////////////////////////////////
1103 typedef struct _Elm_Transit_Effect_Resizing Elm_Transit_Effect_Resizing;
1105 struct _Elm_Transit_Effect_Resizing
1113 _transit_effect_resizing_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
1115 Elm_Transit_Effect_Resizing *resizing = effect;
1120 _transit_effect_resizing_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
1122 EINA_SAFETY_ON_NULL_RETURN(effect);
1123 EINA_SAFETY_ON_NULL_RETURN(transit);
1127 Elm_Transit_Effect_Resizing *resizing = effect;
1129 w = resizing->from.w + (resizing->to.w * progress);
1130 h = resizing->from.h + (resizing->to.h * progress);
1132 EINA_LIST_FOREACH(transit->objs, elist, obj)
1133 evas_object_resize(obj, w, h);
1136 static Elm_Transit_Effect *
1137 _transit_effect_resizing_context_new(Evas_Coord from_w, Evas_Coord from_h, Evas_Coord to_w, Evas_Coord to_h)
1139 Elm_Transit_Effect_Resizing *resizing;
1141 resizing = ELM_NEW(Elm_Transit_Effect_Resizing);
1142 if (!resizing) return NULL;
1144 resizing->from.w = from_w;
1145 resizing->from.h = from_h;
1146 resizing->to.w = to_w - from_w;
1147 resizing->to.h = to_h - from_h;
1153 * Add the Resizing Effect to Elm_Transit.
1155 * @note This API is one of the facades. It creates resizing effect context
1156 * and add it's required APIs to elm_transit_effect_add.
1158 * @see elm_transit_effect_add()
1160 * @param transit Transit object.
1161 * @param from_w Object width size when effect begins.
1162 * @param from_h Object height size when effect begins.
1163 * @param to_w Object width size when effect ends.
1164 * @param to_h Object height size when effect ends.
1165 * @return Resizing effect context data.
1169 EAPI Elm_Transit_Effect *
1170 elm_transit_effect_resizing_add(Elm_Transit *transit, Evas_Coord from_w, Evas_Coord from_h, Evas_Coord to_w, Evas_Coord to_h)
1172 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1173 Elm_Transit_Effect *effect = _transit_effect_resizing_context_new(from_w, from_h, to_w, to_h);
1175 if (!effect) return NULL;
1176 elm_transit_effect_add(transit,
1177 _transit_effect_resizing_op, effect,
1178 _transit_effect_resizing_context_free);
1182 ///////////////////////////////////////////////////////////////////////////////
1183 //Translation Effect
1184 ///////////////////////////////////////////////////////////////////////////////
1185 typedef struct _Elm_Transit_Effect_Translation Elm_Transit_Effect_Translation;
1186 typedef struct _Elm_Transit_Effect_Translation_Node Elm_Transit_Effect_Translation_Node;
1188 struct _Elm_Transit_Effect_Translation_Node
1194 struct _Elm_Transit_Effect_Translation
1196 struct _position_variation {
1203 _translation_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1205 Elm_Transit_Effect_Translation *translation = data;
1207 Elm_Transit_Effect_Translation_Node *translation_node;
1209 EINA_LIST_FOREACH(translation->nodes, elist, translation_node)
1211 if (translation_node->obj != obj) continue;
1212 translation->nodes = eina_list_remove_list(translation->nodes, elist);
1213 free(translation_node);
1219 _translation_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Translation *translation)
1221 Elm_Transit_Effect_Translation_Node *translation_node;
1222 const Eina_List *elist;
1224 Eina_List *data_list = NULL;
1225 const Eina_List *objs = elm_transit_objects_get(transit);
1227 EINA_LIST_FOREACH(objs, elist, obj)
1229 translation_node = ELM_NEW(Elm_Transit_Effect_Translation_Node);
1230 if (!translation_node)
1232 eina_list_free(data_list);
1235 translation_node->obj = obj;
1236 evas_object_geometry_get(obj, &(translation_node->x),
1237 &(translation_node->y), NULL, NULL);
1238 data_list = eina_list_append(data_list, translation_node);
1239 evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
1240 _translation_object_del_cb, translation);
1246 _transit_effect_translation_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
1248 EINA_SAFETY_ON_NULL_RETURN(effect);
1249 Elm_Transit_Effect_Translation *translation = effect;
1250 Eina_List *elist, *elist_next;
1251 Elm_Transit_Effect_Translation_Node *translation_node;
1253 EINA_LIST_FOREACH_SAFE(translation->nodes,
1254 elist, elist_next, translation_node)
1256 evas_object_event_callback_del(translation_node->obj,
1257 EVAS_CALLBACK_DEL, _translation_object_del_cb);
1258 translation->nodes = eina_list_remove_list(translation->nodes, elist);
1259 free(translation_node);
1265 _transit_effect_translation_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress __UNUSED__)
1267 EINA_SAFETY_ON_NULL_RETURN(effect);
1268 EINA_SAFETY_ON_NULL_RETURN(transit);
1270 Elm_Transit_Effect_Translation *translation = effect;
1271 Elm_Transit_Effect_Translation_Node *translation_node;
1274 if (!translation->nodes)
1275 translation->nodes = _translation_nodes_build(transit, translation);
1277 EINA_LIST_FOREACH(translation->nodes, elist, translation_node)
1279 x = translation_node->x + translation->from.dx
1280 + (translation->to.dx * progress);
1281 y = translation_node->y + translation->from.dy
1282 + (translation->to.dy * progress);
1283 evas_object_move(translation_node->obj, x, y);
1287 static Elm_Transit_Effect *
1288 _transit_effect_translation_context_new(Evas_Coord from_dx, Evas_Coord from_dy, Evas_Coord to_dx, Evas_Coord to_dy)
1290 Elm_Transit_Effect_Translation *translation;
1292 translation = ELM_NEW(Elm_Transit_Effect_Translation);
1293 if (!translation) return NULL;
1295 translation->from.dx = from_dx;
1296 translation->from.dy = from_dy;
1297 translation->to.dx = to_dx - from_dx;
1298 translation->to.dy = to_dy - from_dy;
1304 * Add the Translation Effect to Elm_Transit.
1306 * @note This API is one of the facades. It creates translation effect context
1307 * and add it's required APIs to elm_transit_effect_add.
1309 * @see elm_transit_effect_add()
1311 * @param transit Transit object.
1312 * @param from_dx X Position variation when effect begins.
1313 * @param from_dy Y Position variation when effect begins.
1314 * @param to_dx X Position variation when effect ends.
1315 * @param to_dy Y Position variation when effect ends.
1316 * @return Translation effect context data.
1319 * @warning Is higher recommended just create a transit with this effect when
1320 * the window that the objects of the transit belongs has already been created.
1321 * This is because this effect needs the geometry information about the objects,
1322 * and if the window was not created yet, it can get a wrong information.
1324 EAPI Elm_Transit_Effect *
1325 elm_transit_effect_translation_add(Elm_Transit *transit, Evas_Coord from_dx, Evas_Coord from_dy, Evas_Coord to_dx, Evas_Coord to_dy)
1327 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1328 Elm_Transit_Effect *effect_context = _transit_effect_translation_context_new(from_dx, from_dy, to_dx, to_dy);
1330 if (!effect_context) return NULL;
1331 elm_transit_effect_add(transit,
1332 _transit_effect_translation_op, effect_context,
1333 _transit_effect_translation_context_free);
1334 return effect_context;
1338 ///////////////////////////////////////////////////////////////////////////////
1340 ///////////////////////////////////////////////////////////////////////////////
1341 typedef struct _Elm_Transit_Effect_Zoom Elm_Transit_Effect_Zoom;
1343 struct _Elm_Transit_Effect_Zoom
1349 _transit_effect_zoom_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
1351 Elm_Transit_Effect_Zoom *zoom = effect;
1356 _transit_effect_zoom_op(Elm_Transit_Effect *effect, Elm_Transit *transit , double progress)
1358 EINA_SAFETY_ON_NULL_RETURN(effect);
1359 EINA_SAFETY_ON_NULL_RETURN(transit);
1362 Elm_Transit_Effect_Zoom *zoom = effect;
1364 Evas_Coord x, y, w, h;
1366 map = evas_map_new(4);
1369 EINA_LIST_FOREACH(transit->objs, elist, obj)
1371 evas_object_geometry_get(obj, &x, &y, &w, &h);
1372 evas_map_util_points_populate_from_object_full(map, obj, zoom->from +
1373 (progress * zoom->to));
1374 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, _TRANSIT_FOCAL);
1375 evas_object_map_set(obj, map);
1376 evas_object_map_enable_set(obj, EINA_TRUE);
1381 static Elm_Transit_Effect *
1382 _transit_effect_zoom_context_new(float from_rate, float to_rate)
1384 Elm_Transit_Effect_Zoom *zoom;
1386 zoom = ELM_NEW(Elm_Transit_Effect_Zoom);
1387 if (!zoom) return NULL;
1389 zoom->from = (_TRANSIT_FOCAL - (from_rate * _TRANSIT_FOCAL)) * (1 / from_rate);
1390 zoom->to = ((_TRANSIT_FOCAL - (to_rate * _TRANSIT_FOCAL)) * (1 / to_rate)) - zoom->from;
1396 * Add the Zoom Effect to Elm_Transit.
1398 * @note This API is one of the facades. It creates zoom effect context
1399 * and add it's required APIs to elm_transit_effect_add.
1401 * @see elm_transit_effect_add()
1403 * @param transit Transit object.
1404 * @param from_rate Scale rate when effect begins (1 is current rate).
1405 * @param to_rate Scale rate when effect ends.
1406 * @return Zoom effect context data.
1409 * @warning Is higher recommended just create a transit with this effect when
1410 * the window that the objects of the transit belongs has already been created.
1411 * This is because this effect needs the geometry information about the objects,
1412 * and if the window was not created yet, it can get a wrong information.
1414 EAPI Elm_Transit_Effect *
1415 elm_transit_effect_zoom_add(Elm_Transit *transit, float from_rate, float to_rate)
1417 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1418 Elm_Transit_Effect *effect_context = _transit_effect_zoom_context_new(from_rate, to_rate);
1420 if (!effect_context) return NULL;
1421 elm_transit_effect_add(transit,
1422 _transit_effect_zoom_op, effect_context,
1423 _transit_effect_zoom_context_free);
1424 return effect_context;
1428 ///////////////////////////////////////////////////////////////////////////////
1430 ///////////////////////////////////////////////////////////////////////////////
1431 typedef struct _Elm_Transit_Effect_Flip Elm_Transit_Effect_Flip;
1433 struct _Elm_Transit_Effect_Flip
1435 Elm_Transit_Effect_Flip_Axis axis;
1440 _transit_effect_flip_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit)
1442 EINA_SAFETY_ON_NULL_RETURN(effect);
1443 EINA_SAFETY_ON_NULL_RETURN(transit);
1444 Elm_Transit_Effect_Flip *flip = effect;
1445 Evas_Object *front, *back;
1447 int count = eina_list_count(transit->objs);
1449 for (i = 0; i < (count - 1); i += 2)
1451 front = eina_list_nth(transit->objs, i);
1452 back = eina_list_nth(transit->objs, i+1);
1453 evas_object_map_enable_set(front, EINA_FALSE);
1454 evas_object_map_enable_set(back, EINA_FALSE);
1460 _transit_effect_flip_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
1462 EINA_SAFETY_ON_NULL_RETURN(effect);
1463 EINA_SAFETY_ON_NULL_RETURN(transit);
1464 Evas_Object *obj, *front, *back;
1466 Elm_Transit_Effect_Flip *flip = effect;
1469 Evas_Coord x, y, w, h;
1471 map = evas_map_new(4);
1474 if (flip->cw) degree = (float)(progress * 180);
1475 else degree = (float)(progress * -180);
1477 count = eina_list_count(transit->objs);
1479 for (i = 0; i < (count - 1); i += 2)
1481 Evas_Coord half_w, half_h;
1483 front = eina_list_nth(transit->objs, i);
1484 back = eina_list_nth(transit->objs, i+1);
1486 if ((degree < 90) && (degree > -90))
1491 evas_object_hide(back);
1492 evas_object_show(front);
1500 evas_object_hide(front);
1501 evas_object_show(back);
1505 evas_map_util_points_populate_from_object_full(map, obj, 0);
1506 evas_object_geometry_get(obj, &x, &y, &w, &h);
1510 if (flip->axis == ELM_TRANSIT_EFFECT_FLIP_AXIS_Y)
1512 if ((degree >= 90) || (degree <= -90))
1514 evas_map_point_image_uv_set(map, 0, w, 0);
1515 evas_map_point_image_uv_set(map, 1, 0, 0);
1516 evas_map_point_image_uv_set(map, 2, 0, h);
1517 evas_map_point_image_uv_set(map, 3, w, h);
1519 evas_map_util_3d_rotate(map, 0, degree,
1520 0, x + half_w, y + half_h, 0);
1524 if ((degree >= 90) || (degree <= -90))
1526 evas_map_point_image_uv_set(map, 0, 0, h);
1527 evas_map_point_image_uv_set(map, 1, w, h);
1528 evas_map_point_image_uv_set(map, 2, w, 0);
1529 evas_map_point_image_uv_set(map, 3, 0, 0);
1531 evas_map_util_3d_rotate(map, degree,
1532 0, 0, x + half_w, y + half_h, 0);
1534 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, _TRANSIT_FOCAL);
1535 evas_object_map_enable_set(front, EINA_TRUE);
1536 evas_object_map_enable_set(back, EINA_TRUE);
1537 evas_object_map_set(obj, map);
1542 static Elm_Transit_Effect *
1543 _transit_effect_flip_context_new(Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1545 Elm_Transit_Effect_Flip *flip;
1547 flip = ELM_NEW(Elm_Transit_Effect_Flip);
1548 if (!flip) return NULL;
1557 * Add the Flip Effect to Elm_Transit.
1559 * @note This API is one of the facades. It creates flip effect context
1560 * and add it's required APIs to elm_transit_effect_add.
1561 * @note This effect is applied to each pair of objects in the order they are listed
1562 * in the transit list of objects. The first object in the pair will be the
1563 * "front" object and the second will be the "back" object.
1565 * @see elm_transit_effect_add()
1567 * @param transit Transit object.
1568 * @param axis Flipping Axis(X or Y).
1569 * @param cw Flipping Direction. EINA_TRUE is clock-wise.
1570 * @return Flip effect context data.
1573 * @warning Is higher recommended just create a transit with this effect when
1574 * the window that the objects of the transit belongs has already been created.
1575 * This is because this effect needs the geometry information about the objects,
1576 * and if the window was not created yet, it can get a wrong information.
1578 EAPI Elm_Transit_Effect *
1579 elm_transit_effect_flip_add(Elm_Transit *transit, Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1581 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1582 Elm_Transit_Effect *effect_context = _transit_effect_flip_context_new(axis, cw);
1584 if (!effect_context) return NULL;
1585 elm_transit_effect_add(transit,
1586 _transit_effect_flip_op, effect_context,
1587 _transit_effect_flip_context_free);
1588 return effect_context;
1591 ///////////////////////////////////////////////////////////////////////////////
1592 //ResizableFlip Effect
1593 ///////////////////////////////////////////////////////////////////////////////
1594 typedef struct _Elm_Transit_Effect_Resizable_Flip Elm_Transit_Effect_ResizableFlip;
1595 typedef struct _Elm_Transit_Effect_Resizable_Flip_Node Elm_Transit_Effect_ResizableFlip_Node;
1597 struct _Elm_Transit_Effect_Resizable_Flip_Node
1603 } from_pos, from_size, to_pos, to_size;
1606 struct _Elm_Transit_Effect_Resizable_Flip
1610 Elm_Transit_Effect_Flip_Axis axis;
1614 _resizable_flip_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1616 Elm_Transit_Effect_ResizableFlip *resizable_flip = data;
1618 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1620 EINA_LIST_FOREACH(resizable_flip->nodes, elist, resizable_flip_node)
1622 if (resizable_flip_node->front == obj)
1623 evas_object_event_callback_del(resizable_flip_node->back,
1624 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1625 else if (resizable_flip_node->back == obj)
1626 evas_object_event_callback_del(resizable_flip_node->front,
1627 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1630 resizable_flip->nodes = eina_list_remove_list(resizable_flip->nodes,
1632 free(resizable_flip_node);
1638 _resizable_flip_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_ResizableFlip *resizable_flip)
1640 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1641 Eina_List *data_list = NULL;
1642 Evas_Coord front_x, front_y, front_w, front_h;
1643 Evas_Coord back_x, back_y, back_w, back_h;
1646 count = eina_list_count(transit->objs);
1647 for (i = 0; i < (count - 1); i += 2)
1649 resizable_flip_node = ELM_NEW(Elm_Transit_Effect_ResizableFlip_Node);
1650 if (!resizable_flip_node)
1652 eina_list_free(data_list);
1656 resizable_flip_node->front = eina_list_nth(transit->objs, i);
1657 resizable_flip_node->back = eina_list_nth(transit->objs, i+1);
1659 evas_object_geometry_get(resizable_flip_node->front,
1660 &front_x, &front_y, &front_w, &front_h);
1661 evas_object_geometry_get(resizable_flip_node->back,
1662 &back_x, &back_y, &back_w, &back_h);
1664 resizable_flip_node->from_pos.x = front_x;
1665 resizable_flip_node->from_pos.y = front_y;
1666 resizable_flip_node->to_pos.x = back_x - front_x;
1667 resizable_flip_node->to_pos.y = back_y - front_y;
1669 resizable_flip_node->from_size.x = front_w;
1670 resizable_flip_node->from_size.y = front_h;
1671 resizable_flip_node->to_size.x = back_w - front_w;
1672 resizable_flip_node->to_size.y = back_h - front_h;
1674 data_list = eina_list_append(data_list, resizable_flip_node);
1676 evas_object_event_callback_add(resizable_flip_node->back,
1677 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb, resizable_flip);
1678 evas_object_event_callback_add(resizable_flip_node->front,
1679 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb, resizable_flip);
1686 _set_image_uv_by_axis_y(Evas_Map *map, Elm_Transit_Effect_ResizableFlip_Node *flip, float degree)
1688 if ((degree >= 90) || (degree <= -90))
1690 evas_map_point_image_uv_set(map, 0,
1691 (flip->from_size.x * 2) + flip->to_size.x,
1693 evas_map_point_image_uv_set(map, 1, 0, 0);
1694 evas_map_point_image_uv_set(map, 2, 0,
1695 (flip->from_size.y * 2) + flip->to_size.y);
1696 evas_map_point_image_uv_set(map, 3,
1697 (flip->from_size.x * 2) + flip->to_size.x,
1698 (flip->from_size.y * 2) + flip->to_size.y);
1702 evas_map_point_image_uv_set(map, 0, 0, 0);
1703 evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
1704 evas_map_point_image_uv_set(map, 2, flip->from_size.x,
1706 evas_map_point_image_uv_set(map, 3, 0, flip->from_size.y);
1711 _set_image_uv_by_axis_x(Evas_Map *map, Elm_Transit_Effect_ResizableFlip_Node *flip, float degree)
1713 if ((degree >= 90) || (degree <= -90))
1715 evas_map_point_image_uv_set(map, 0, 0,
1716 (flip->from_size.y * 2) + flip->to_size.y);
1717 evas_map_point_image_uv_set(map, 1,
1718 (flip->from_size.x * 2) + flip->to_size.x,
1719 (flip->from_size.y * 2) + flip->to_size.y);
1720 evas_map_point_image_uv_set(map, 2,
1721 (flip->from_size.x * 2) + flip->to_size.x,
1723 evas_map_point_image_uv_set(map, 3, 0, 0);
1727 evas_map_point_image_uv_set(map, 0, 0, 0);
1728 evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
1729 evas_map_point_image_uv_set(map, 2, flip->from_size.x,
1731 evas_map_point_image_uv_set(map, 3, 0, flip->from_size.y);
1736 _transit_effect_resizable_flip_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
1738 EINA_SAFETY_ON_NULL_RETURN(effect);
1740 Elm_Transit_Effect_ResizableFlip *resizable_flip = effect;
1741 Eina_List *elist, *elist_next;
1742 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1744 EINA_LIST_FOREACH_SAFE(resizable_flip->nodes,
1745 elist, elist_next, resizable_flip_node)
1747 evas_object_map_enable_set(resizable_flip_node->front, EINA_FALSE);
1748 evas_object_map_enable_set(resizable_flip_node->back, EINA_FALSE);
1750 resizable_flip->nodes = eina_list_remove_list(resizable_flip->nodes,
1753 evas_object_event_callback_del(resizable_flip_node->back,
1754 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1755 evas_object_event_callback_del(resizable_flip_node->front,
1756 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1757 free(resizable_flip_node);
1759 free(resizable_flip);
1763 _transit_effect_resizable_flip_op(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__, double progress)
1765 EINA_SAFETY_ON_NULL_RETURN(effect);
1770 Evas_Coord half_w, half_h;
1771 Elm_Transit_Effect_ResizableFlip *resizable_flip = effect;
1772 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1775 map = evas_map_new(4);
1778 if (resizable_flip->cw) degree = (float)(progress * 180);
1779 else degree = (float)(progress * -180);
1781 if (!resizable_flip->nodes)
1782 resizable_flip->nodes = _resizable_flip_nodes_build(transit,
1785 EINA_LIST_FOREACH(resizable_flip->nodes, elist, resizable_flip_node)
1787 if ((degree < 90) && (degree > -90))
1789 obj = resizable_flip_node->front;
1790 if (resizable_flip_node->front != resizable_flip_node->back)
1792 evas_object_hide(resizable_flip_node->back);
1793 evas_object_show(resizable_flip_node->front);
1798 obj = resizable_flip_node->back;
1799 if (resizable_flip_node->front != resizable_flip_node->back)
1801 evas_object_hide(resizable_flip_node->front);
1802 evas_object_show(resizable_flip_node->back);
1806 x = resizable_flip_node->from_pos.x +
1807 (resizable_flip_node->to_pos.x * progress);
1808 y = resizable_flip_node->from_pos.y +
1809 (resizable_flip_node->to_pos.y * progress);
1810 w = resizable_flip_node->from_size.x +
1811 (resizable_flip_node->to_size.x * progress);
1812 h = resizable_flip_node->from_size.y +
1813 (resizable_flip_node->to_size.y * progress);
1814 evas_map_point_coord_set(map, 0, x, y, 0);
1815 evas_map_point_coord_set(map, 1, x + w, y, 0);
1816 evas_map_point_coord_set(map, 2, x + w, y + h, 0);
1817 evas_map_point_coord_set(map, 3, x, y + h, 0);
1819 half_w = (Evas_Coord)(w / 2);
1820 half_h = (Evas_Coord)(h / 2);
1822 if (resizable_flip->axis == ELM_TRANSIT_EFFECT_FLIP_AXIS_Y)
1824 _set_image_uv_by_axis_y(map, resizable_flip_node, degree);
1825 evas_map_util_3d_rotate(map, 0, degree,
1826 0, x + half_w, y + half_h, 0);
1830 _set_image_uv_by_axis_x(map, resizable_flip_node, degree);
1831 evas_map_util_3d_rotate(map, degree, 0,
1832 0, x + half_w, y + half_h, 0);
1835 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, _TRANSIT_FOCAL);
1836 evas_object_map_enable_set(resizable_flip_node->front, EINA_TRUE);
1837 evas_object_map_enable_set(resizable_flip_node->back, EINA_TRUE);
1838 evas_object_map_set(obj, map);
1843 static Elm_Transit_Effect *
1844 _transit_effect_resizable_flip_context_new(Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1846 Elm_Transit_Effect_ResizableFlip *resizable_flip;
1848 resizable_flip = ELM_NEW(Elm_Transit_Effect_ResizableFlip);
1849 if (!resizable_flip) return NULL;
1851 resizable_flip->cw = cw;
1852 resizable_flip->axis = axis;
1854 return resizable_flip;
1858 * Add the Resizable Flip Effect to Elm_Transit.
1860 * @note This API is one of the facades. It creates resizable flip effect context
1861 * and add it's required APIs to elm_transit_effect_add.
1862 * @note This effect is applied to each pair of objects in the order they are listed
1863 * in the transit list of objects. The first object in the pair will be the
1864 * "front" object and the second will be the "back" object.
1866 * @see elm_transit_effect_add()
1868 * @param transit Transit object.
1869 * @param axis Flipping Axis(X or Y).
1870 * @param cw Flipping Direction. EINA_TRUE is clock-wise.
1871 * @return Resizable flip effect context data.
1874 * @warning Is higher recommended just create a transit with this effect when
1875 * the window that the objects of the transit belongs has already been created.
1876 * This is because this effect needs the geometry information about the objects,
1877 * and if the window was not created yet, it can get a wrong information.
1879 EAPI Elm_Transit_Effect *
1880 elm_transit_effect_resizable_flip_add(Elm_Transit *transit, Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1882 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1883 Elm_Transit_Effect *effect_context = _transit_effect_resizable_flip_context_new(axis, cw);
1885 if (!effect_context) return NULL;
1886 elm_transit_effect_add(transit,
1887 _transit_effect_resizable_flip_op, effect_context,
1888 _transit_effect_resizable_flip_context_free);
1889 return effect_context;
1893 ///////////////////////////////////////////////////////////////////////////////
1895 ///////////////////////////////////////////////////////////////////////////////
1896 typedef struct _Elm_Transit_Effect_Wipe Elm_Transit_Effect_Wipe;
1898 struct _Elm_Transit_Effect_Wipe
1900 Elm_Transit_Effect_Wipe_Type type;
1901 Elm_Transit_Effect_Wipe_Dir dir;
1905 _elm_fx_wipe_hide(Evas_Map * map, Elm_Transit_Effect_Wipe_Dir dir, float x, float y, float w, float h, float progress)
1911 case ELM_TRANSIT_EFFECT_WIPE_DIR_LEFT:
1912 w2 = w - (w * progress);
1914 evas_map_point_image_uv_set(map, 0, 0, 0);
1915 evas_map_point_image_uv_set(map, 1, w2, 0);
1916 evas_map_point_image_uv_set(map, 2, w2, h);
1917 evas_map_point_image_uv_set(map, 3, 0, h);
1918 evas_map_point_coord_set(map, 0, x, y, 0);
1919 evas_map_point_coord_set(map, 1, x + w2, y, 0);
1920 evas_map_point_coord_set(map, 2, x + w2, h2, 0);
1921 evas_map_point_coord_set(map, 3, x, h2, 0);
1923 case ELM_TRANSIT_EFFECT_WIPE_DIR_RIGHT:
1924 w2 = (w * progress);
1926 evas_map_point_image_uv_set(map, 0, w2, 0);
1927 evas_map_point_image_uv_set(map, 1, w, 0);
1928 evas_map_point_image_uv_set(map, 2, w, h);
1929 evas_map_point_image_uv_set(map, 3, w2, h);
1930 evas_map_point_coord_set(map, 0, x + w2, y, 0);
1931 evas_map_point_coord_set(map, 1, x + w, y, 0);
1932 evas_map_point_coord_set(map, 2, x + w, h2, 0);
1933 evas_map_point_coord_set(map, 3, x + w2, h2, 0);
1935 case ELM_TRANSIT_EFFECT_WIPE_DIR_UP:
1937 h2 = h - (h * progress);
1938 evas_map_point_image_uv_set(map, 0, 0, 0);
1939 evas_map_point_image_uv_set(map, 1, w, 0);
1940 evas_map_point_image_uv_set(map, 2, w, h2);
1941 evas_map_point_image_uv_set(map, 3, 0, h2);
1942 evas_map_point_coord_set(map, 0, x, y, 0);
1943 evas_map_point_coord_set(map, 1, w2, y, 0);
1944 evas_map_point_coord_set(map, 2, w2, y+h2, 0);
1945 evas_map_point_coord_set(map, 3, x, y+h2, 0);
1947 case ELM_TRANSIT_EFFECT_WIPE_DIR_DOWN:
1949 h2 = (h * progress);
1950 evas_map_point_image_uv_set(map, 0, 0, h2);
1951 evas_map_point_image_uv_set(map, 1, w, h2);
1952 evas_map_point_image_uv_set(map, 2, w, h);
1953 evas_map_point_image_uv_set(map, 3, 0, h);
1954 evas_map_point_coord_set(map, 0, x, y + h2, 0);
1955 evas_map_point_coord_set(map, 1, w2, y + h2, 0);
1956 evas_map_point_coord_set(map, 2, w2, y + h, 0);
1957 evas_map_point_coord_set(map, 3, x, y + h, 0);
1962 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, _TRANSIT_FOCAL);
1966 _elm_fx_wipe_show(Evas_Map *map, Elm_Transit_Effect_Wipe_Dir dir, float x, float y, float w, float h, float progress)
1972 case ELM_TRANSIT_EFFECT_WIPE_DIR_LEFT:
1973 w2 = (w - (w * progress));
1975 evas_map_point_image_uv_set(map, 0, w2, 0);
1976 evas_map_point_image_uv_set(map, 1, w, 0);
1977 evas_map_point_image_uv_set(map, 2, w, h);
1978 evas_map_point_image_uv_set(map, 3, w2, h);
1979 evas_map_point_coord_set(map, 0, x + w2, y, 0);
1980 evas_map_point_coord_set(map, 1, w, y, 0);
1981 evas_map_point_coord_set(map, 2, w, h2, 0);
1982 evas_map_point_coord_set(map, 3, x + w2, h2, 0);
1984 case ELM_TRANSIT_EFFECT_WIPE_DIR_RIGHT:
1985 w2 = (w * progress);
1987 evas_map_point_image_uv_set(map, 0, 0, 0);
1988 evas_map_point_image_uv_set(map, 1, w2, 0);
1989 evas_map_point_image_uv_set(map, 2, w2, h);
1990 evas_map_point_image_uv_set(map, 3, 0, h);
1991 evas_map_point_coord_set(map, 0, x, y, 0);
1992 evas_map_point_coord_set(map, 1, x + w2, y, 0);
1993 evas_map_point_coord_set(map, 2, x + w2, h2, 0);
1994 evas_map_point_coord_set(map, 3, x, h2, 0);
1996 case ELM_TRANSIT_EFFECT_WIPE_DIR_UP:
1998 h2 = (h - (h * progress));
1999 evas_map_point_image_uv_set(map, 0, 0, h2);
2000 evas_map_point_image_uv_set(map, 1, w, h2);
2001 evas_map_point_image_uv_set(map, 2, w, h);
2002 evas_map_point_image_uv_set(map, 3, 0, h);
2003 evas_map_point_coord_set(map, 0, x, y + h2, 0);
2004 evas_map_point_coord_set(map, 1, w2, y + h2, 0);
2005 evas_map_point_coord_set(map, 2, w2, y + h, 0);
2006 evas_map_point_coord_set(map, 3, x, y + h, 0);
2008 case ELM_TRANSIT_EFFECT_WIPE_DIR_DOWN:
2010 h2 = (h * progress);
2011 evas_map_point_image_uv_set(map, 0, 0, 0);
2012 evas_map_point_image_uv_set(map, 1, w, 0);
2013 evas_map_point_image_uv_set(map, 2, w, h2);
2014 evas_map_point_image_uv_set(map, 3, 0, h2);
2015 evas_map_point_coord_set(map, 0, x, y, 0);
2016 evas_map_point_coord_set(map, 1, w2, y, 0);
2017 evas_map_point_coord_set(map, 2, w2, y + h2, 0);
2018 evas_map_point_coord_set(map, 3, x, y + h2, 0);
2023 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, _TRANSIT_FOCAL);
2027 _transit_effect_wipe_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit)
2029 EINA_SAFETY_ON_NULL_RETURN(effect);
2030 EINA_SAFETY_ON_NULL_RETURN(transit);
2033 Elm_Transit_Effect_Wipe *wipe = effect;
2034 Eina_Bool reverse = elm_transit_auto_reverse_get(transit);
2036 EINA_LIST_FOREACH(transit->objs, elist, obj)
2038 if ((wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_SHOW && !reverse)
2039 || (wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_HIDE && reverse))
2040 evas_object_show(obj);
2041 else evas_object_hide(obj);
2042 evas_object_map_enable_set(obj, EINA_FALSE);
2049 _transit_effect_wipe_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2051 EINA_SAFETY_ON_NULL_RETURN(effect);
2052 EINA_SAFETY_ON_NULL_RETURN(transit);
2053 Elm_Transit_Effect_Wipe *wipe = effect;
2055 Evas_Coord _x, _y, _w, _h;
2059 map = evas_map_new(4);
2062 EINA_LIST_FOREACH(transit->objs, elist, obj)
2064 evas_object_geometry_get(obj, &_x, &_y, &_w, &_h);
2066 if (wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_SHOW)
2067 _elm_fx_wipe_show(map, wipe->dir, _x, _y, _w, _h, (float)progress);
2069 _elm_fx_wipe_hide(map, wipe->dir, _x, _y, _w, _h, (float)progress);
2071 evas_object_map_enable_set(obj, EINA_TRUE);
2072 evas_object_map_set(obj, map);
2077 static Elm_Transit_Effect *
2078 _transit_effect_wipe_context_new(Elm_Transit_Effect_Wipe_Type type, Elm_Transit_Effect_Wipe_Dir dir)
2080 Elm_Transit_Effect_Wipe *wipe;
2082 wipe = ELM_NEW(Elm_Transit_Effect_Wipe);
2083 if (!wipe) return NULL;
2092 * Add the Wipe Effect to Elm_Transit.
2094 * @note This API is one of the facades. It creates wipe effect context
2095 * and add it's required APIs to elm_transit_effect_add.
2097 * @see elm_transit_effect_add()
2099 * @param transit Transit object.
2100 * @param type Wipe type. Hide or show.
2101 * @param dir Wipe Direction.
2102 * @return Wipe effect context data.
2105 * @warning Is higher recommended just create a transit with this effect when
2106 * the window that the objects of the transit belongs has already been created.
2107 * This is because this effect needs the geometry information about the objects,
2108 * and if the window was not created yet, it can get a wrong information.
2111 elm_transit_effect_wipe_add(Elm_Transit *transit, Elm_Transit_Effect_Wipe_Type type, Elm_Transit_Effect_Wipe_Dir dir)
2113 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2114 void *effect_context = _transit_effect_wipe_context_new(type, dir);
2116 if (!effect_context) return NULL;
2117 elm_transit_effect_add(transit,
2118 _transit_effect_wipe_op, effect_context,
2119 _transit_effect_wipe_context_free);
2120 return effect_context;
2124 ///////////////////////////////////////////////////////////////////////////////
2126 ///////////////////////////////////////////////////////////////////////////////
2127 typedef struct _Elm_Transit_Effect_Color Elm_Transit_Effect_Color;
2129 struct _Elm_Transit_Effect_Color
2131 struct _unsigned_color {
2132 unsigned int r, g, b, a;
2134 struct _signed_color {
2140 _transit_effect_color_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
2142 Elm_Transit_Effect_Color *color = effect;
2147 _transit_effect_color_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2149 EINA_SAFETY_ON_NULL_RETURN(effect);
2150 EINA_SAFETY_ON_NULL_RETURN(transit);
2151 Elm_Transit_Effect_Color *color = effect;
2154 unsigned int r, g, b, a;
2156 r = (color->from.r + (int)((float)color->to.r * progress));
2157 g = (color->from.g + (int)((float)color->to.g * progress));
2158 b = (color->from.b + (int)((float)color->to.b * progress));
2159 a = (color->from.a + (int)((float)color->to.a * progress));
2161 EINA_LIST_FOREACH(transit->objs, elist, obj)
2162 evas_object_color_set(obj, r, g, b, a);
2165 static Elm_Transit_Effect *
2166 _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)
2168 Elm_Transit_Effect_Color *color;
2170 color = ELM_NEW(Elm_Transit_Effect_Color);
2171 if (!color) return NULL;
2173 color->from.r = from_r;
2174 color->from.g = from_g;
2175 color->from.b = from_b;
2176 color->from.a = from_a;
2177 color->to.r = to_r - from_r;
2178 color->to.g = to_g - from_g;
2179 color->to.b = to_b - from_b;
2180 color->to.a = to_a - from_a;
2186 * Add the Color Effect to Elm_Transit.
2188 * @note This API is one of the facades. It creates color effect context
2189 * and add it's required APIs to elm_transit_effect_add.
2191 * @see elm_transit_effect_add()
2193 * @param transit Transit object.
2194 * @param from_r RGB R when effect begins.
2195 * @param from_g RGB G when effect begins.
2196 * @param from_b RGB B when effect begins.
2197 * @param from_a RGB A when effect begins.
2198 * @param to_r RGB R when effect ends.
2199 * @param to_g RGB G when effect ends.
2200 * @param to_b RGB B when effect ends.
2201 * @param to_a RGB A when effect ends.
2202 * @return Color effect context data.
2206 EAPI Elm_Transit_Effect *
2207 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)
2209 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2210 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);
2212 if (!effect_context) return NULL;
2213 elm_transit_effect_add(transit,
2214 _transit_effect_color_op, effect_context,
2215 _transit_effect_color_context_free);
2216 return effect_context;
2219 ///////////////////////////////////////////////////////////////////////////////
2221 ///////////////////////////////////////////////////////////////////////////////
2222 typedef struct _Elm_Transit_Effect_Fade Elm_Transit_Effect_Fade;
2223 typedef struct _Elm_Transit_Effect_Fade_Node Elm_Transit_Effect_Fade_Node;
2225 struct _Elm_Transit_Effect_Fade_Node
2227 Evas_Object *before;
2229 struct _signed_color before_color, after_color;
2232 Eina_Bool inversed : 1;
2235 struct _Elm_Transit_Effect_Fade
2241 _fade_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2243 Elm_Transit_Effect_Fade *fade = data;
2245 Elm_Transit_Effect_Fade_Node *fade_node;
2247 EINA_LIST_FOREACH(fade->nodes, elist, fade_node)
2249 if (fade_node->before == obj)
2250 evas_object_event_callback_del(fade_node->after,
2251 EVAS_CALLBACK_DEL, _fade_object_del_cb);
2252 else if (fade_node->after == obj)
2253 evas_object_event_callback_del(fade_node->before,
2254 EVAS_CALLBACK_DEL, _fade_object_del_cb);
2257 fade->nodes = eina_list_remove_list(fade->nodes, elist);
2264 _fade_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Fade *fade_data)
2266 Elm_Transit_Effect_Fade_Node *fade;
2267 Eina_List *data_list = NULL;
2270 count = eina_list_count(transit->objs);
2271 for (i = 0; i < count; i += 2)
2273 fade = ELM_NEW(Elm_Transit_Effect_Fade_Node);
2276 eina_list_free(data_list);
2280 fade->before = eina_list_nth(transit->objs, i);
2281 fade->after = eina_list_nth(transit->objs, i+1);
2283 evas_object_color_get(fade->before,
2284 &fade->before_color.r, &fade->before_color.g,
2285 &fade->before_color.b, &fade->before_color.a);
2286 evas_object_color_get(fade->after,
2287 &fade->after_color.r, &fade->after_color.g,
2288 &fade->after_color.b, &fade->after_color.a);
2290 fade->before_alpha = (255 - fade->before_color.a);
2291 fade->after_alpha = (255 - fade->after_color.a);
2293 data_list = eina_list_append(data_list, fade);
2295 evas_object_event_callback_add(fade->before,
2296 EVAS_CALLBACK_DEL, _fade_object_del_cb, fade_data);
2297 evas_object_event_callback_add(fade->after,
2298 EVAS_CALLBACK_DEL, _fade_object_del_cb, fade_data);
2304 _transit_effect_fade_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
2306 EINA_SAFETY_ON_NULL_RETURN(effect);
2307 Elm_Transit_Effect_Fade *fade = effect;
2308 Elm_Transit_Effect_Fade_Node *fade_node;
2309 Eina_List *elist, *elist_next;
2311 EINA_LIST_FOREACH_SAFE(fade->nodes, elist, elist_next, fade_node)
2313 evas_object_color_set(fade_node->before, fade_node->before_color.r,
2314 fade_node->before_color.g,
2315 fade_node->before_color.b,
2316 fade_node->before_color.a);
2317 evas_object_color_set(fade_node->after, fade_node->after_color.r,
2318 fade_node->after_color.g,
2319 fade_node->after_color.b,
2320 fade_node->after_color.a);
2322 fade->nodes = eina_list_remove_list(fade->nodes, elist);
2323 evas_object_event_callback_del(fade_node->before,
2324 EVAS_CALLBACK_DEL, _fade_object_del_cb);
2325 evas_object_event_callback_del(fade_node->after,
2326 EVAS_CALLBACK_DEL, _fade_object_del_cb);
2334 _transit_effect_fade_op(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__, double progress)
2336 EINA_SAFETY_ON_NULL_RETURN(effect);
2337 Elm_Transit_Effect_Fade *fade = effect;
2339 Elm_Transit_Effect_Fade_Node *fade_node;
2343 fade->nodes = _fade_nodes_build(transit, fade);
2345 EINA_LIST_FOREACH(fade->nodes, elist, fade_node)
2349 if (!fade_node->inversed)
2351 evas_object_hide(fade_node->after);
2352 evas_object_show(fade_node->before);
2353 fade_node->inversed = EINA_TRUE;
2356 _progress = (1 - (progress * 2));
2358 evas_object_color_set(fade_node->before,
2359 fade_node->before_color.r * _progress,
2360 fade_node->before_color.g * _progress,
2361 fade_node->before_color.b * _progress,
2362 fade_node->before_color.a +
2363 fade_node->before_alpha * (1 - _progress));
2367 if (fade_node->inversed)
2369 evas_object_hide(fade_node->before);
2370 evas_object_show(fade_node->after);
2371 fade_node->inversed = EINA_FALSE;
2374 _progress = ((progress - 0.5) * 2);
2376 evas_object_color_set(fade_node->after,
2377 fade_node->after_color.r * _progress,
2378 fade_node->after_color.g * _progress,
2379 fade_node->after_color.b * _progress,
2380 fade_node->after_color.a +
2381 fade_node->after_alpha * (1 - _progress));
2386 static Elm_Transit_Effect *
2387 _transit_effect_fade_context_new(void)
2389 Elm_Transit_Effect_Fade *fade;
2390 fade = ELM_NEW(Elm_Transit_Effect_Fade);
2391 if (!fade) return NULL;
2396 * Add the Fade Effect to Elm_Transit.
2398 * @note This API is one of the facades. It creates fade effect context
2399 * and add it's required APIs to elm_transit_effect_add.
2400 * @note This effect is applied to each pair of objects in the order they are listed
2401 * in the transit list of objects. The first object in the pair will be the
2402 * "before" object and the second will be the "after" object.
2404 * @see elm_transit_effect_add()
2406 * @param transit Transit object.
2407 * @return Fade effect context data.
2410 * @warning Is higher recommended just create a transit with this effect when
2411 * the window that the objects of the transit belongs has already been created.
2412 * This is because this effect needs the color information about the objects,
2413 * and if the window was not created yet, it can get a wrong information.
2415 EAPI Elm_Transit_Effect *
2416 elm_transit_effect_fade_add(Elm_Transit *transit)
2418 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2420 Elm_Transit_Effect *effect_context = _transit_effect_fade_context_new();
2421 if (!effect_context) return NULL;
2422 elm_transit_effect_add(transit,
2423 _transit_effect_fade_op, effect_context,
2424 _transit_effect_fade_context_free);
2425 return effect_context;
2429 ///////////////////////////////////////////////////////////////////////////////
2431 ///////////////////////////////////////////////////////////////////////////////
2432 typedef struct _Elm_Transit_Effect_Blend Elm_Transit_Effect_Blend;
2433 typedef struct _Elm_Transit_Effect_Blend_Node Elm_Transit_Effect_Blend_Node;
2435 struct _Elm_Transit_Effect_Blend_Node
2437 Evas_Object *before;
2439 struct _signed_color from, to;
2442 struct _Elm_Transit_Effect_Blend
2448 _blend_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2450 Elm_Transit_Effect_Blend *blend = data;
2452 Elm_Transit_Effect_Blend_Node *blend_node;
2454 EINA_LIST_FOREACH(blend->nodes, elist, blend_node)
2456 if (blend_node->after == obj)
2457 evas_object_event_callback_del(blend_node->before,
2458 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2459 else if (blend_node->before == obj)
2460 evas_object_event_callback_del(blend_node->after,
2461 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2464 blend->nodes = eina_list_remove_list(blend->nodes, elist);
2471 _blend_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Blend *blend)
2473 Elm_Transit_Effect_Blend_Node *blend_node;
2474 Eina_List *data_list = NULL;
2477 count = eina_list_count(transit->objs);
2478 for (i = 0; i < (count - 1); i += 2)
2480 blend_node = ELM_NEW(Elm_Transit_Effect_Blend_Node);
2483 eina_list_free(data_list);
2487 blend_node->before = eina_list_nth(transit->objs, i);
2488 blend_node->after = eina_list_nth(transit->objs, i + 1);
2489 evas_object_show(blend_node->before);
2490 evas_object_show(blend_node->after);
2492 evas_object_color_get(blend_node->before, &blend_node->from.r,
2493 &blend_node->from.g, &blend_node->from.b,
2494 &blend_node->from.a);
2495 evas_object_color_get(blend_node->after, &blend_node->to.r,
2496 &blend_node->to.g, &blend_node->to.b,
2499 data_list = eina_list_append(data_list, blend_node);
2501 evas_object_event_callback_add(blend_node->before,
2502 EVAS_CALLBACK_DEL, _blend_object_del_cb, blend);
2503 evas_object_event_callback_add(blend_node->after,
2504 EVAS_CALLBACK_DEL, _blend_object_del_cb, blend);
2510 _transit_effect_blend_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
2512 EINA_SAFETY_ON_NULL_RETURN(effect);
2513 Elm_Transit_Effect_Blend *blend = effect;
2514 Elm_Transit_Effect_Blend_Node *blend_node;
2515 Eina_List *elist, *elist_next;
2517 EINA_LIST_FOREACH_SAFE(blend->nodes, elist, elist_next, blend_node)
2519 evas_object_color_set(blend_node->before,
2520 blend_node->from.r, blend_node->from.g,
2521 blend_node->from.b, blend_node->from.a);
2522 evas_object_color_set(blend_node->after, blend_node->to.r,
2523 blend_node->to.g, blend_node->to.b,
2526 if (elm_transit_auto_reverse_get(transit))
2527 evas_object_hide(blend_node->after);
2529 evas_object_hide(blend_node->before);
2531 blend->nodes = eina_list_remove_list(blend->nodes, elist);
2533 evas_object_event_callback_del(blend_node->before,
2534 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2535 evas_object_event_callback_del(blend_node->after,
2536 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2543 _transit_effect_blend_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2545 EINA_SAFETY_ON_NULL_RETURN(effect);
2546 EINA_SAFETY_ON_NULL_RETURN(transit);
2547 Elm_Transit_Effect_Blend *blend = effect;
2548 Elm_Transit_Effect_Blend_Node *blend_node;
2551 if (!blend->nodes) blend->nodes = _blend_nodes_build(transit, blend);
2553 EINA_LIST_FOREACH(blend->nodes, elist, blend_node)
2555 evas_object_color_set(blend_node->before,
2556 (int)(blend_node->from.r * (1 - progress)),
2557 (int)(blend_node->from.g * (1 - progress)),
2558 (int)(blend_node->from.b * (1 - progress)),
2559 (int)(blend_node->from.a * (1 - progress)));
2560 evas_object_color_set(blend_node->after,
2561 (int)(blend_node->to.r * progress),
2562 (int)(blend_node->to.g * progress),
2563 (int)(blend_node->to.b * progress),
2564 (int)(blend_node->to.a * progress));
2568 static Elm_Transit_Effect *
2569 _transit_effect_blend_context_new(void)
2571 Elm_Transit_Effect_Blend *blend;
2573 blend = ELM_NEW(Elm_Transit_Effect_Blend);
2574 if (!blend) return NULL;
2579 * Add the Blend Effect to Elm_Transit.
2581 * @note This API is one of the facades. It creates blend effect context
2582 * and add it's required APIs to elm_transit_effect_add.
2583 * @note This effect is applied to each pair of objects in the order they are listed
2584 * in the transit list of objects. The first object in the pair will be the
2585 * "before" object and the second will be the "after" object.
2587 * @see elm_transit_effect_add()
2589 * @param transit Transit object.
2590 * @return Blend effect context data.
2593 * @warning Is higher recommended just create a transit with this effect when
2594 * the window that the objects of the transit belongs has already been created.
2595 * This is because this effect needs the color information about the objects,
2596 * and if the window was not created yet, it can get a wrong information.
2598 EAPI Elm_Transit_Effect *
2599 elm_transit_effect_blend_add(Elm_Transit *transit)
2601 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2602 Elm_Transit_Effect *effect_context = _transit_effect_blend_context_new();
2604 if (!effect_context) return NULL;
2605 elm_transit_effect_add(transit,
2606 _transit_effect_blend_op, effect_context,
2607 _transit_effect_blend_context_free);
2608 return effect_context;
2612 ///////////////////////////////////////////////////////////////////////////////
2614 ///////////////////////////////////////////////////////////////////////////////
2615 typedef struct _Elm_Transit_Effect_Rotation Elm_Transit_Effect_Rotation;
2617 struct _Elm_Transit_Effect_Rotation
2623 _transit_effect_rotation_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
2625 Elm_Transit_Effect_Rotation *rotation = effect;
2630 _transit_effect_rotation_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2632 EINA_SAFETY_ON_NULL_RETURN(effect);
2633 EINA_SAFETY_ON_NULL_RETURN(transit);
2634 Elm_Transit_Effect_Rotation *rotation = effect;
2636 Evas_Coord x, y, w, h;
2638 float half_w, half_h;
2642 map = evas_map_new(4);
2645 EINA_LIST_FOREACH(transit->objs, elist, obj)
2647 evas_map_util_points_populate_from_object_full(map, obj, 0);
2648 degree = rotation->from + (float)(progress * rotation->to);
2650 evas_object_geometry_get(obj, &x, &y, &w, &h);
2652 half_w = (float)w * 0.5;
2653 half_h = (float)h * 0.5;
2655 evas_map_util_3d_rotate(map, 0, 0, degree, x + half_w, y + half_h, 0);
2656 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, _TRANSIT_FOCAL);
2657 evas_object_map_enable_set(obj, EINA_TRUE);
2658 evas_object_map_set(obj, map);
2663 static Elm_Transit_Effect *
2664 _transit_effect_rotation_context_new(float from_degree, float to_degree)
2666 Elm_Transit_Effect_Rotation *rotation;
2668 rotation = ELM_NEW(Elm_Transit_Effect_Rotation);
2669 if (!rotation) return NULL;
2671 rotation->from = from_degree;
2672 rotation->to = to_degree - from_degree;
2678 * Add the Rotation Effect to Elm_Transit.
2680 * @note This API is one of the facades. It creates rotation effect context
2681 * and add it's required APIs to elm_transit_effect_add.
2683 * @see elm_transit_effect_add()
2685 * @param transit Transit object.
2686 * @param from_degree Degree when effect begins.
2687 * @param to_degree Degree when effect is ends.
2688 * @return Rotation effect context data.
2691 * @warning Is higher recommended just create a transit with this effect when
2692 * the window that the objects of the transit belongs has already been created.
2693 * This is because this effect needs the geometry information about the objects,
2694 * and if the window was not created yet, it can get a wrong information.
2696 EAPI Elm_Transit_Effect *
2697 elm_transit_effect_rotation_add(Elm_Transit *transit, float from_degree, float to_degree)
2699 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2700 Elm_Transit_Effect *effect_context = _transit_effect_rotation_context_new(from_degree, to_degree);
2702 if (!effect_context) return NULL;
2703 elm_transit_effect_add(transit,
2704 _transit_effect_rotation_op, effect_context,
2705 _transit_effect_rotation_context_free);
2706 return effect_context;
2710 ///////////////////////////////////////////////////////////////////////////////
2711 //ImageAnimation Effect
2712 ///////////////////////////////////////////////////////////////////////////////
2713 typedef struct _Elm_Transit_Effect_Image_Animation Elm_Transit_Effect_Image_Animation;
2715 struct _Elm_Transit_Effect_Image_Animation
2721 _transit_effect_image_animation_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
2723 EINA_SAFETY_ON_NULL_RETURN(effect);
2724 Elm_Transit_Effect_Image_Animation *image_animation = effect;
2726 Eina_List *elist, *elist_next;
2728 EINA_LIST_FOREACH_SAFE(image_animation->images, elist, elist_next, image)
2730 image_animation->images =
2731 eina_list_remove_list(image_animation->images, elist);
2732 eina_stringshare_del(image);
2735 free(image_animation);
2739 _transit_effect_image_animation_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2741 EINA_SAFETY_ON_NULL_RETURN(effect);
2742 EINA_SAFETY_ON_NULL_RETURN(transit);
2746 Elm_Transit_Effect_Image_Animation *image_animation = effect;
2747 unsigned int count = 0;
2750 type = eina_stringshare_add("icon");
2751 len = eina_list_count(image_animation->images);
2753 if (!len) count = floor(progress * len);
2754 else count = floor(progress * (len - 1));
2756 EINA_LIST_FOREACH(transit->objs, elist, obj)
2758 if (elm_widget_type_check(obj, type))
2759 elm_icon_file_set(obj,
2760 eina_list_nth(image_animation->images, count), NULL);
2763 eina_stringshare_del(type);
2766 static Elm_Transit_Effect *
2767 _transit_effect_image_animation_context_new(Eina_List *images)
2769 Elm_Transit_Effect_Image_Animation *image_animation;
2770 image_animation = ELM_NEW(Elm_Transit_Effect_Image_Animation);
2772 if (!image_animation) return NULL;
2773 image_animation->images = images;
2774 return image_animation;
2778 * Add the ImageAnimation Effect to Elm_Transit.
2780 * @note This API is one of the facades. It creates image animation effect context
2781 * and add it's required APIs to elm_transit_effect_add.
2782 * The @p images parameter is a list images paths. This list and
2783 * its contents will be deleted at the end of the effect by
2784 * elm_transit_effect_image_animation_context_free() function.
2788 * char buf[PATH_MAX];
2789 * Eina_List *images = NULL;
2790 * Elm_Transit *transi = elm_transit_add();
2792 * snprintf(buf, sizeof(buf), "%s/images/icon_11.png", PACKAGE_DATA_DIR);
2793 * images = eina_list_append(images, eina_stringshare_add(buf));
2795 * snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
2796 * images = eina_list_append(images, eina_stringshare_add(buf));
2797 * elm_transit_effect_image_animation_add(transi, images);
2801 * @see elm_transit_effect_add()
2803 * @param transit Transit object.
2804 * @param images Eina_List of images file paths. This list and
2805 * its contents will be deleted at the end of the effect by
2806 * elm_transit_effect_image_animation_context_free() function.
2807 * @return Image Animation effect context data.
2811 EAPI Elm_Transit_Effect *
2812 elm_transit_effect_image_animation_add(Elm_Transit *transit, Eina_List *images)
2814 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2815 Elm_Transit_Effect *effect = _transit_effect_image_animation_context_new(images);
2817 if (!effect) return NULL;
2818 elm_transit_effect_add(transit,
2819 _transit_effect_image_animation_op, effect,
2820 _transit_effect_image_animation_context_free);