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);
319 _elm_transit_effect_del(transit, effect_module);
322 while (transit->objs)
323 _elm_transit_object_remove(transit, eina_list_data_get(transit->objs));
325 transit->deleted = EINA_TRUE;
327 if (transit->del_data.func)
328 transit->del_data.func(transit->del_data.arg, transit);
330 eina_hash_free(transit->objs_data_hash);
332 EINA_MAGIC_SET(transit, EINA_MAGIC_NONE);
337 _chain_transits_go(Elm_Transit *transit)
339 Eina_List *elist, *elist_next;
340 Elm_Transit *chain_transit;
342 EINA_LIST_FOREACH_SAFE(transit->next_chain_transits, elist, elist_next, chain_transit)
343 elm_transit_go(chain_transit);
347 _transit_animate_op(Elm_Transit *transit, double progress)
349 Elm_Transit_Effect_Module *effect_module;
352 EINA_INLIST_FOREACH(transit->effect_list, effect_module)
354 if (transit->deleted) break;
355 if (!effect_module->deleted)
356 effect_module->transition_cb(effect_module->effect, transit, progress);
360 if (transit->walking) return;
362 if (transit->deleted) _elm_transit_del(transit);
363 else if (transit->effects_pending_del) _remove_dead_effects(transit);
367 _animator_animate_cb(void *data)
369 Elm_Transit *transit = data;
370 double elapsed_time, duration;
372 transit->time.current = ecore_loop_time_get();
373 elapsed_time = transit->time.current - transit->time.begin;
374 duration = transit->time.duration + transit->time.delayed;
376 if (elapsed_time > duration)
377 elapsed_time = duration;
379 transit->progress = elapsed_time / duration;
380 switch (transit->tween_mode)
382 case ELM_TRANSIT_TWEEN_MODE_ACCELERATE:
383 transit->progress = 1.0 - sin((ELM_PI / 2.0) + (transit->progress * ELM_PI / 2.0));
385 case ELM_TRANSIT_TWEEN_MODE_DECELERATE:
386 transit->progress = sin(transit->progress * ELM_PI / 2.0);
388 case ELM_TRANSIT_TWEEN_MODE_SINUSOIDAL:
389 transit->progress = (1.0 - cos(transit->progress * ELM_PI)) / 2.0;
396 if (transit->repeat.reverse) transit->progress = 1 - transit->progress;
398 if (transit->time.duration > 0) _transit_animate_op(transit, transit->progress);
400 /* Not end. Keep going. */
401 if (elapsed_time < duration) return ECORE_CALLBACK_RENEW;
403 /* Repeat and reverse and time done! */
404 if ((transit->repeat.count >= 0) &&
405 (transit->repeat.current == transit->repeat.count) &&
406 ((!transit->auto_reverse) || transit->repeat.reverse))
408 /* run chain transit */
409 if (transit->next_chain_transits)
410 _chain_transits_go(transit);
412 elm_transit_del(transit);
413 return ECORE_CALLBACK_CANCEL;
417 if (!transit->auto_reverse || transit->repeat.reverse)
419 transit->repeat.current++;
420 transit->repeat.reverse = EINA_FALSE;
422 else transit->repeat.reverse = EINA_TRUE;
424 transit->time.begin = ecore_loop_time_get();
426 return ECORE_CALLBACK_RENEW;
432 * @note Is not necessary to delete the transit object, it will be deleted at
433 * the end of its operation.
434 * @note The transit will start playing when the program enter in the main loop, is not
435 * necessary to give a start to the transit.
437 * @param duration The duration of the transit in seconds. When transit starts
438 * to run, it will last a @p duration time.
439 * @return The transit object.
444 elm_transit_add(void)
446 Elm_Transit *transit = ELM_NEW(Elm_Transit);
447 if (!transit) return NULL;
449 EINA_MAGIC_SET(transit, ELM_TRANSIT_MAGIC);
451 elm_transit_tween_mode_set(transit, ELM_TRANSIT_TWEEN_MODE_LINEAR);
453 transit->objs_data_hash = eina_hash_int32_new(NULL);
458 * Stops the animation and delete the @p transit object.
460 * Call this function if you wants to stop the animation before the duration
461 * time. Make sure the @p transit object is still alive with
462 * elm_transit_del_cb_set() function.
463 * All added effects will be deleted, calling its repective data_free_cb
464 * functions. The function setted by elm_transit_del_cb_set() will be called.
466 * @see elm_transit_del_cb_set()
468 * @param transit The transit object to be deleted.
471 * @warning Just call this function if you are sure the transit is alive.
474 elm_transit_del(Elm_Transit *transit)
476 ELM_TRANSIT_CHECK_OR_RETURN(transit);
478 if (transit->walking) transit->deleted = EINA_TRUE;
479 else _elm_transit_del(transit);
483 * Add a new effect to the transit.
485 * @note The cb function and the data are the key to the effect. If you try to
486 * add an already added effect, nothing is done.
487 * @note After the first addition of an effect in @p transit, if its
488 * effect list become empty again, the @p transit will be killed by
489 * elm_transit_del(transit) function.
493 * Elm_Transit *transit = elm_transit_add();
494 * elm_transit_effect_add(transit,
495 * elm_transit_effect_blend_op,
496 * elm_transit_effect_blend_context_new(),
497 * elm_transit_effect_blend_context_free);
500 * @param transit The transit object.
501 * @param cb The operation function. It is called when the animation begins,
502 * it is the function that actually performs the animation. It is called with
503 * the @p data, @p transit and the time progression of the animation (a double
504 * value between 0.0 and 1.0).
505 * @param data The context data of the effect.
506 * @param data_free_cb The function to free the context data, it will be called
507 * at the end of the effect, it must finalize the animation and free the
511 * @warning The transit free the context data at the and of the transition with
512 * the data_free_cb function, do not use the context data in another transit.
515 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)
517 ELM_TRANSIT_CHECK_OR_RETURN(transit);
518 EINA_SAFETY_ON_NULL_RETURN(transition_cb);
519 Elm_Transit_Effect_Module *effect_module;
521 EINA_INLIST_FOREACH(transit->effect_list, effect_module)
522 if ((effect_module->transition_cb == transition_cb) && (effect_module->effect == effect)) return;
524 effect_module = ELM_NEW(Elm_Transit_Effect_Module);
525 if (!effect_module) return;
527 effect_module->end_cb = end_cb;
528 effect_module->transition_cb = transition_cb;
529 effect_module->effect = effect;
531 transit->effect_list = eina_inlist_append(transit->effect_list, (Eina_Inlist*) effect_module);
535 * Delete an added effect.
537 * This function will remove the effect from the @p transit, calling the
538 * data_free_cb to free the @p data.
540 * @see elm_transit_effect_add()
542 * @note If the effect is not found, nothing is done.
543 * @note If the effect list become empty, this function will call
544 * elm_transit_del(transit), that is, it will kill the @p transit.
546 * @param transit The transit object.
547 * @param cb The operation function.
548 * @param data The context data of the effect.
553 elm_transit_effect_del(Elm_Transit *transit, Elm_Transit_Effect_Transition_Cb transition_cb, Elm_Transit_Effect *effect)
555 ELM_TRANSIT_CHECK_OR_RETURN(transit);
556 EINA_SAFETY_ON_NULL_RETURN(transition_cb);
557 Elm_Transit_Effect_Module *effect_module;
559 EINA_INLIST_FOREACH(transit->effect_list, effect_module)
561 if ((effect_module->transition_cb == transition_cb) && (effect_module->effect == effect))
563 if (transit->walking)
565 effect_module->deleted = EINA_TRUE;
566 transit->effects_pending_del++;
570 _elm_transit_effect_del(transit, effect_module);
571 if (!transit->effect_list) elm_transit_del(transit);
579 * Add new object to apply the effects.
581 * @note After the first addition of an object in @p transit, if its
582 * object list become empty again, the @p transit will be killed by
583 * elm_transit_del(transit) function.
584 * @note If the @p obj belongs to another transit, the @p obj will be
585 * removed from it and it will only belong to the @p transit. If the old
586 * transit stays without objects, it will die.
587 * @note When you add an object into the @p transit, its state from
588 * evas_object_pass_events_get(obj) is saved, and it is applied when the
589 * transit ends, if you change this state whith evas_object_pass_events_set()
590 * after add the object, this state will change again when @p transit stops to
593 * @param transit The transit object.
594 * @param obj Object to be animated.
597 * @warning It is not allowed to add a new object after transit begins to go.
600 elm_transit_object_add(Elm_Transit *transit, Evas_Object *obj)
602 ELM_TRANSIT_CHECK_OR_RETURN(transit);
603 EINA_SAFETY_ON_NULL_RETURN(obj);
604 Elm_Obj_Data *obj_data;
607 //TODO: Check the remove case of the same objects in this transit.
608 obj_data = ELM_NEW(Elm_Obj_Data);
609 obj_data->pass_events = evas_object_pass_events_get(obj);
610 if (!transit->event_enabled)
611 evas_object_pass_events_set(obj, EINA_TRUE);
613 evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
614 _elm_transit_object_remove_cb,
617 transit->objs = eina_list_append(transit->objs, obj);
618 list = eina_list_last(transit->objs);
619 eina_hash_add(transit->objs_data_hash, list, obj_data);
621 if (!transit->state_keep)
622 _elm_transit_obj_states_save(obj, obj_data);
626 * Removes an added object from the transit.
628 * @note If the @p obj is not in the @p transit, nothing is done.
629 * @note If the list become empty, this function will call
630 * elm_transit_del(transit), that is, it will kill the @p transit.
632 * @param transit The transit object.
633 * @param obj Object to be removed from @p transit.
636 * @warning It is not allowed to remove objects after transit begins to go.
639 elm_transit_object_remove(Elm_Transit *transit, Evas_Object *obj)
641 ELM_TRANSIT_CHECK_OR_RETURN(transit);
642 EINA_SAFETY_ON_NULL_RETURN(obj);
644 _elm_transit_object_remove(transit, obj);
645 if (!transit->objs) elm_transit_del(transit);
649 * Get the objects of the transit.
651 * @param transit The transit object.
652 * @return a Eina_List with the objects from the transit.
656 EAPI const Eina_List *
657 elm_transit_objects_get(const Elm_Transit *transit)
659 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
660 return transit->objs;
664 * Set the event enabled when transit is operating.
666 * If @p enabled is EINA_TRUE, the objects of the transit will receives
667 * events from mouse and keyboard during the animation.
668 * @note When you add an object with elm_transit_object_add(), its state from
669 * evas_object_pass_events_get(obj) is saved, and it is applied when the
670 * transit ends, if you change this state with evas_object_pass_events_set()
671 * after adding the object, this state will change again when @p transit stops
674 * @param transit The transit object.
675 * @param enabled Disable or enable.
680 elm_transit_event_enabled_set(Elm_Transit *transit, Eina_Bool enabled)
682 ELM_TRANSIT_CHECK_OR_RETURN(transit);
684 if (transit->event_enabled == enabled) return;
685 transit->event_enabled = !!enabled;
686 eina_hash_foreach(transit->objs_data_hash, _hash_foreach_pass_events_set, transit);
690 * Get the value of event enabled status.
692 * @see elm_transit_event_enabled_set()
694 * @param transit The Transit object
695 * @return EINA_TRUE, when event is enabled. If @p transit is NULL
696 * EINA_FALSE is returned
701 elm_transit_event_enabled_get(const Elm_Transit *transit)
703 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
704 return transit->event_enabled;
709 * Set the event enabled when transit is operating.
711 * If @p disabled is EINA_TRUE, the objects of the transit will receives
712 * events from mouse and keyboard during the animation.
713 * @note When you add an object with elm_transit_object_add(), its state from
714 * evas_object_pass_events_get(obj) is saved, and it is applied when the
715 * transit ends, if you change this state with evas_object_pass_events_set()
716 * after add the object, this state will change again when @p transit stops to
719 * @see elm_transit_event_enabled_set()
721 * @param transit The transit object.
722 * @param disabled Disable or enable.
726 EINA_DEPRECATED EAPI void
727 elm_transit_event_block_set(Elm_Transit *transit, Eina_Bool disabled)
729 elm_transit_event_enabled_set(transit, disabled);
734 * Get the value of event block enabled status.
736 * @see elm_transit_event_enabled_set(), elm_transit_event_enabled_get()
738 * @param transit The Transit object
739 * @return EINA_TRUE, when event is enabled. If @p transit is NULL
740 * EINA_FALSE is returned
744 EINA_DEPRECATED EAPI Eina_Bool
745 elm_transit_event_block_get(const Elm_Transit *transit)
747 return !elm_transit_event_enabled_get(transit);
751 * Set the user-callback function when the transit is deleted.
753 * @note Using this function twice will overwrite the first function setted.
754 * @note the @p transit object will be deleted after call @p cb function.
756 * @param transit The transit object.
757 * @param cb Callback function pointer. This function will be called before
758 * the deletion of the transit.
759 * @param data Callback funtion user data. It is the @p op parameter.
764 elm_transit_del_cb_set(Elm_Transit *transit, void (*cb) (void *data, Elm_Transit *transit), void *data)
766 ELM_TRANSIT_CHECK_OR_RETURN(transit);
767 transit->del_data.func = cb;
768 transit->del_data.arg = data;
772 * Set reverse effect automatically.
774 * If auto reverse is setted, after running the effects with the progress
775 * parameter from 0 to 1, it will call the effecs again with the progress
776 * from 1 to 0. The transit will last for a time iqual to (2 * duration * repeat),
777 * where the duration was setted with the function elm_transit_add and
778 * the repeat with the function elm_transit_repeat_times_set().
780 * @param transit The transit object.
781 * @param reverse EINA_TRUE means the auto_reverse is on.
786 elm_transit_auto_reverse_set(Elm_Transit *transit, Eina_Bool reverse)
788 ELM_TRANSIT_CHECK_OR_RETURN(transit);
789 transit->auto_reverse = reverse;
793 * Get if the auto reverse is on.
795 * @see elm_transit_auto_reverse_set()
797 * @param transit The transit object.
798 * @return EINA_TRUE means auto reverse is on. If @p transit is NULL
799 * EINA_FALSE is returned
804 elm_transit_auto_reverse_get(const Elm_Transit *transit)
806 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
807 return transit->auto_reverse;
811 * Set the transit repeat count. Effect will be repeated by repeat count.
813 * This function sets the number of repetition the transit will run after
814 * the first one, that is, if @p repeat is 1, the transit will run 2 times.
815 * If the @p repeat is a negative number, it will repeat infinite times.
817 * @note If this function is called during the transit execution, the transit
818 * will run @p repeat times, ignoring the times it already performed.
820 * @param transit The transit object
821 * @param repeat Repeat count
826 elm_transit_repeat_times_set(Elm_Transit *transit, int repeat)
828 ELM_TRANSIT_CHECK_OR_RETURN(transit);
829 transit->repeat.count = repeat;
830 transit->repeat.current = 0;
834 * Get the transit repeat count.
836 * @see elm_transit_repeat_times_set()
838 * @param transit The Transit object.
839 * @return The repeat count. If @p transit is NULL
845 elm_transit_repeat_times_get(const Elm_Transit *transit)
847 ELM_TRANSIT_CHECK_OR_RETURN(transit, 0);
848 return transit->repeat.count;
852 * Set the transit animation acceleration type.
854 * This function sets the tween mode of the transit that can be:
855 * ELM_TRANSIT_TWEEN_MODE_LINEAR - The default mode.
856 * ELM_TRANSIT_TWEEN_MODE_SINUSOIDAL - Starts in accelerate mode and ends decelerating.
857 * ELM_TRANSIT_TWEEN_MODE_DECELERATE - The animation will be slowed over time.
858 * ELM_TRANSIT_TWEEN_MODE_ACCELERATE - The animation will accelerate over time.
860 * @param transit The transit object.
861 * @param tween_mode The tween type.
866 elm_transit_tween_mode_set(Elm_Transit *transit, Elm_Transit_Tween_Mode tween_mode)
868 ELM_TRANSIT_CHECK_OR_RETURN(transit);
869 transit->tween_mode = tween_mode;
873 * Get the transit animation acceleration type.
875 * @note @p transit can not be NULL
877 * @param transit The transit object.
878 * @return The tween type. If @p transit is NULL
879 * ELM_TRANSIT_TWEEN_MODE_LINEAR is returned.
883 EAPI Elm_Transit_Tween_Mode
884 elm_transit_tween_mode_get(const Elm_Transit *transit)
886 ELM_TRANSIT_CHECK_OR_RETURN(transit, ELM_TRANSIT_TWEEN_MODE_LINEAR);
887 return transit->tween_mode;
891 * Set the transit animation time
893 * @note @p transit can not be NULL
895 * @param transit The transit object.
896 * @param duration The animation time.
901 elm_transit_duration_set(Elm_Transit *transit, double duration)
903 ELM_TRANSIT_CHECK_OR_RETURN(transit);
904 if (transit->animator) return;
905 transit->time.duration = duration;
909 * Get the transit animation time
911 * @note @p transit can not be NULL
913 * @param transit The transit object.
915 * @return The transit animation time.
920 elm_transit_duration_get(const Elm_Transit *transit)
922 ELM_TRANSIT_CHECK_OR_RETURN(transit, 0.0);
923 return transit->time.duration;
927 * Starts the transition.
928 * Once this API is called, the transit begins to measure the time.
930 * @note @p transit can not be NULL
932 * @param transit The transit object.
937 elm_transit_go(Elm_Transit *transit)
939 ELM_TRANSIT_CHECK_OR_RETURN(transit);
941 if (transit->animator)
942 ecore_animator_del(transit->animator);
944 transit->time.paused = 0;
945 transit->time.delayed = 0;
946 transit->time.begin = ecore_loop_time_get();
947 transit->animator = ecore_animator_add(_animator_animate_cb, transit);
951 * Pause/Resume the transition.
952 * If you call elm_transit_go again, paused states will affect no anymore.
954 * @note @p transit can not be NULL
956 * @param transit The transit object.
961 elm_transit_paused_set(Elm_Transit *transit, Eina_Bool paused)
963 ELM_TRANSIT_CHECK_OR_RETURN(transit);
965 if (!transit->animator) return;
969 if (transit->time.paused > 0)
971 ecore_animator_freeze(transit->animator);
972 transit->time.paused = ecore_loop_time_get();
976 if (transit->time.paused == 0)
978 ecore_animator_thaw(transit->animator);
979 transit->time.delayed += (ecore_loop_time_get() - transit->time.paused);
980 transit->time.paused = 0;
985 * Get the value of paused status.
987 * @see elm_transit_paused_set()
989 * @note @p transit can not be NULL
991 * @param transit The transit object.
992 * @return EINA_TRUE means transition is paused. If @p transit is NULL
993 * EINA_FALSE is returned
998 elm_transit_paused_get(const Elm_Transit *transit)
1000 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
1002 if (transit->time.paused == 0)
1009 * Get the time progression of the animation (a double value between 0.0 and 1.0).
1011 * @note @p transit can not be NULL
1013 * @param transit The transit object.
1015 * @return The time progression value. If @p transit is NULL
1021 elm_transit_progress_value_get(const Elm_Transit *transit)
1023 ELM_TRANSIT_CHECK_OR_RETURN(transit, 0);
1024 return transit->progress;
1030 * Enable/disable keeping up the objects states.
1031 * If it is not kept, the objects states will be reset when transition ends.
1033 * @note @p transit can not be NULL.
1034 * @note One state includes geometry, color, map data.
1036 * @param transit The transit object.
1037 * @param state_keep Keeping or Non Keeping.
1042 elm_transit_objects_final_state_keep_set(Elm_Transit *transit, Eina_Bool state_keep)
1044 ELM_TRANSIT_CHECK_OR_RETURN(transit);
1045 if (transit->state_keep == state_keep) return;
1046 if (transit->animator) return;
1047 transit->state_keep = !!state_keep;
1048 if (state_keep) return;
1049 eina_hash_foreach(transit->objs_data_hash, _hash_foreach_obj_states_save, NULL);
1053 * Get a value whether the objects states will be reset or not.
1055 * @note @p transit can not be NULL
1057 * @see elm_transit_objects_final_state_keep_set()
1059 * @param transit The transit object.
1060 * @return EINA_TRUE means the states of the objects will be reset.
1061 * If @p transit is NULL, EINA_FALSE is returned
1066 elm_transit_objects_final_state_keep_get(const Elm_Transit *transit)
1068 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
1069 return transit->state_keep;
1073 * Makes the chain relationship between two transits.
1075 * @note @p transit can not be NULL. Transit would have multiple chain transits.
1076 * @note @p chain_transit can not be NULL. Chain transits could be chained to the only one transit.
1078 * @param transit The transit object.
1079 * @param chain_transit The chain transit object. This transit will be operated
1080 * after transit is done.
1085 elm_transit_chain_transit_add(Elm_Transit *transit, Elm_Transit *chain_transit)
1087 ELM_TRANSIT_CHECK_OR_RETURN(transit);
1088 ELM_TRANSIT_CHECK_OR_RETURN(chain_transit);
1090 if (transit == chain_transit) return;
1091 if (transit == chain_transit->prev_chain_transit) return;
1093 if (chain_transit->prev_chain_transit)
1094 chain_transit->prev_chain_transit->next_chain_transits = eina_list_remove(chain_transit->prev_chain_transit->next_chain_transits, chain_transit);
1096 chain_transit->prev_chain_transit = transit;
1097 transit->next_chain_transits = eina_list_append(transit->next_chain_transits, chain_transit);
1101 * Get the current chain transit list.
1103 * @note @p transit can not be NULL.
1105 * @param transit The transit object.
1106 * @return chain transit list.
1111 elm_transit_chain_transits_get(const Elm_Transit * transit)
1113 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1114 return transit->next_chain_transits;
1117 ///////////////////////////////////////////////////////////////////////////////
1119 ///////////////////////////////////////////////////////////////////////////////
1120 typedef struct _Elm_Transit_Effect_Resizing Elm_Transit_Effect_Resizing;
1122 struct _Elm_Transit_Effect_Resizing
1130 _transit_effect_resizing_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
1132 Elm_Transit_Effect_Resizing *resizing = effect;
1137 _transit_effect_resizing_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
1139 EINA_SAFETY_ON_NULL_RETURN(effect);
1140 EINA_SAFETY_ON_NULL_RETURN(transit);
1144 Elm_Transit_Effect_Resizing *resizing = effect;
1146 w = resizing->from.w + (resizing->to.w * progress);
1147 h = resizing->from.h + (resizing->to.h * progress);
1149 EINA_LIST_FOREACH(transit->objs, elist, obj)
1150 evas_object_resize(obj, w, h);
1153 static Elm_Transit_Effect *
1154 _transit_effect_resizing_context_new(Evas_Coord from_w, Evas_Coord from_h, Evas_Coord to_w, Evas_Coord to_h)
1156 Elm_Transit_Effect_Resizing *resizing;
1158 resizing = ELM_NEW(Elm_Transit_Effect_Resizing);
1159 if (!resizing) return NULL;
1161 resizing->from.w = from_w;
1162 resizing->from.h = from_h;
1163 resizing->to.w = to_w - from_w;
1164 resizing->to.h = to_h - from_h;
1170 * Add the Resizing Effect to Elm_Transit.
1172 * @note This API is one of the facades. It creates resizing effect context
1173 * and add it's required APIs to elm_transit_effect_add.
1175 * @see elm_transit_effect_add()
1177 * @param transit Transit object.
1178 * @param from_w Object width size when effect begins.
1179 * @param from_h Object height size when effect begins.
1180 * @param to_w Object width size when effect ends.
1181 * @param to_h Object height size when effect ends.
1182 * @return Resizing effect context data.
1186 EAPI Elm_Transit_Effect *
1187 elm_transit_effect_resizing_add(Elm_Transit *transit, Evas_Coord from_w, Evas_Coord from_h, Evas_Coord to_w, Evas_Coord to_h)
1189 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1190 Elm_Transit_Effect *effect = _transit_effect_resizing_context_new(from_w, from_h, to_w, to_h);
1192 if (!effect) return NULL;
1193 elm_transit_effect_add(transit,
1194 _transit_effect_resizing_op, effect,
1195 _transit_effect_resizing_context_free);
1199 ///////////////////////////////////////////////////////////////////////////////
1200 //Translation Effect
1201 ///////////////////////////////////////////////////////////////////////////////
1202 typedef struct _Elm_Transit_Effect_Translation Elm_Transit_Effect_Translation;
1203 typedef struct _Elm_Transit_Effect_Translation_Node Elm_Transit_Effect_Translation_Node;
1205 struct _Elm_Transit_Effect_Translation_Node
1211 struct _Elm_Transit_Effect_Translation
1213 struct _position_variation {
1220 _translation_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1222 Elm_Transit_Effect_Translation *translation = data;
1224 Elm_Transit_Effect_Translation_Node *translation_node;
1226 EINA_LIST_FOREACH(translation->nodes, elist, translation_node)
1228 if (translation_node->obj != obj) continue;
1229 translation->nodes = eina_list_remove_list(translation->nodes, elist);
1230 free(translation_node);
1236 _translation_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Translation *translation)
1238 Elm_Transit_Effect_Translation_Node *translation_node;
1239 const Eina_List *elist;
1241 Eina_List *data_list = NULL;
1242 const Eina_List *objs = elm_transit_objects_get(transit);
1244 EINA_LIST_FOREACH(objs, elist, obj)
1246 translation_node = ELM_NEW(Elm_Transit_Effect_Translation_Node);
1247 if (!translation_node)
1249 eina_list_free(data_list);
1252 translation_node->obj = obj;
1253 evas_object_geometry_get(obj, &(translation_node->x),
1254 &(translation_node->y), NULL, NULL);
1255 data_list = eina_list_append(data_list, translation_node);
1256 evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
1257 _translation_object_del_cb, translation);
1263 _transit_effect_translation_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
1265 EINA_SAFETY_ON_NULL_RETURN(effect);
1266 Elm_Transit_Effect_Translation *translation = effect;
1267 Eina_List *elist, *elist_next;
1268 Elm_Transit_Effect_Translation_Node *translation_node;
1270 EINA_LIST_FOREACH_SAFE(translation->nodes,
1271 elist, elist_next, translation_node)
1273 evas_object_event_callback_del(translation_node->obj,
1274 EVAS_CALLBACK_DEL, _translation_object_del_cb);
1275 translation->nodes = eina_list_remove_list(translation->nodes, elist);
1276 free(translation_node);
1282 _transit_effect_translation_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress __UNUSED__)
1284 EINA_SAFETY_ON_NULL_RETURN(effect);
1285 EINA_SAFETY_ON_NULL_RETURN(transit);
1287 Elm_Transit_Effect_Translation *translation = effect;
1288 Elm_Transit_Effect_Translation_Node *translation_node;
1291 if (!translation->nodes)
1292 translation->nodes = _translation_nodes_build(transit, translation);
1294 EINA_LIST_FOREACH(translation->nodes, elist, translation_node)
1296 x = translation_node->x + translation->from.dx
1297 + (translation->to.dx * progress);
1298 y = translation_node->y + translation->from.dy
1299 + (translation->to.dy * progress);
1300 evas_object_move(translation_node->obj, x, y);
1304 static Elm_Transit_Effect *
1305 _transit_effect_translation_context_new(Evas_Coord from_dx, Evas_Coord from_dy, Evas_Coord to_dx, Evas_Coord to_dy)
1307 Elm_Transit_Effect_Translation *translation;
1309 translation = ELM_NEW(Elm_Transit_Effect_Translation);
1310 if (!translation) return NULL;
1312 translation->from.dx = from_dx;
1313 translation->from.dy = from_dy;
1314 translation->to.dx = to_dx - from_dx;
1315 translation->to.dy = to_dy - from_dy;
1321 * Add the Translation Effect to Elm_Transit.
1323 * @note This API is one of the facades. It creates translation effect context
1324 * and add it's required APIs to elm_transit_effect_add.
1326 * @see elm_transit_effect_add()
1328 * @param transit Transit object.
1329 * @param from_dx X Position variation when effect begins.
1330 * @param from_dy Y Position variation when effect begins.
1331 * @param to_dx X Position variation when effect ends.
1332 * @param to_dy Y Position variation when effect ends.
1333 * @return Translation effect context data.
1336 * @warning Is higher recommended just create a transit with this effect when
1337 * the window that the objects of the transit belongs has already been created.
1338 * This is because this effect needs the geometry information about the objects,
1339 * and if the window was not created yet, it can get a wrong information.
1341 EAPI Elm_Transit_Effect *
1342 elm_transit_effect_translation_add(Elm_Transit *transit, Evas_Coord from_dx, Evas_Coord from_dy, Evas_Coord to_dx, Evas_Coord to_dy)
1344 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1345 Elm_Transit_Effect *effect_context = _transit_effect_translation_context_new(from_dx, from_dy, to_dx, to_dy);
1347 if (!effect_context) return NULL;
1348 elm_transit_effect_add(transit,
1349 _transit_effect_translation_op, effect_context,
1350 _transit_effect_translation_context_free);
1351 return effect_context;
1355 ///////////////////////////////////////////////////////////////////////////////
1357 ///////////////////////////////////////////////////////////////////////////////
1358 typedef struct _Elm_Transit_Effect_Zoom Elm_Transit_Effect_Zoom;
1360 struct _Elm_Transit_Effect_Zoom
1366 _transit_effect_zoom_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
1368 Elm_Transit_Effect_Zoom *zoom = effect;
1373 _transit_effect_zoom_op(Elm_Transit_Effect *effect, Elm_Transit *transit , double progress)
1375 EINA_SAFETY_ON_NULL_RETURN(effect);
1376 EINA_SAFETY_ON_NULL_RETURN(transit);
1379 Elm_Transit_Effect_Zoom *zoom = effect;
1381 Evas_Coord x, y, w, h;
1383 map = evas_map_new(4);
1386 EINA_LIST_FOREACH(transit->objs, elist, obj)
1388 evas_object_geometry_get(obj, &x, &y, &w, &h);
1389 evas_map_util_points_populate_from_object_full(map, obj, zoom->from +
1390 (progress * zoom->to));
1391 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, _TRANSIT_FOCAL);
1392 evas_object_map_set(obj, map);
1393 evas_object_map_enable_set(obj, EINA_TRUE);
1398 static Elm_Transit_Effect *
1399 _transit_effect_zoom_context_new(float from_rate, float to_rate)
1401 Elm_Transit_Effect_Zoom *zoom;
1403 zoom = ELM_NEW(Elm_Transit_Effect_Zoom);
1404 if (!zoom) return NULL;
1406 zoom->from = (_TRANSIT_FOCAL - (from_rate * _TRANSIT_FOCAL)) * (1 / from_rate);
1407 zoom->to = ((_TRANSIT_FOCAL - (to_rate * _TRANSIT_FOCAL)) * (1 / to_rate)) - zoom->from;
1413 * Add the Zoom Effect to Elm_Transit.
1415 * @note This API is one of the facades. It creates zoom effect context
1416 * and add it's required APIs to elm_transit_effect_add.
1418 * @see elm_transit_effect_add()
1420 * @param transit Transit object.
1421 * @param from_rate Scale rate when effect begins (1 is current rate).
1422 * @param to_rate Scale rate when effect ends.
1423 * @return Zoom effect context data.
1426 * @warning Is higher recommended just create a transit with this effect when
1427 * the window that the objects of the transit belongs has already been created.
1428 * This is because this effect needs the geometry information about the objects,
1429 * and if the window was not created yet, it can get a wrong information.
1431 EAPI Elm_Transit_Effect *
1432 elm_transit_effect_zoom_add(Elm_Transit *transit, float from_rate, float to_rate)
1434 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1435 Elm_Transit_Effect *effect_context = _transit_effect_zoom_context_new(from_rate, to_rate);
1437 if (!effect_context) return NULL;
1438 elm_transit_effect_add(transit,
1439 _transit_effect_zoom_op, effect_context,
1440 _transit_effect_zoom_context_free);
1441 return effect_context;
1445 ///////////////////////////////////////////////////////////////////////////////
1447 ///////////////////////////////////////////////////////////////////////////////
1448 typedef struct _Elm_Transit_Effect_Flip Elm_Transit_Effect_Flip;
1450 struct _Elm_Transit_Effect_Flip
1452 Elm_Transit_Effect_Flip_Axis axis;
1457 _transit_effect_flip_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit)
1459 EINA_SAFETY_ON_NULL_RETURN(effect);
1460 EINA_SAFETY_ON_NULL_RETURN(transit);
1461 Elm_Transit_Effect_Flip *flip = effect;
1462 Evas_Object *front, *back;
1464 int count = eina_list_count(transit->objs);
1466 for (i = 0; i < (count - 1); i += 2)
1468 front = eina_list_nth(transit->objs, i);
1469 back = eina_list_nth(transit->objs, i+1);
1470 evas_object_map_enable_set(front, EINA_FALSE);
1471 evas_object_map_enable_set(back, EINA_FALSE);
1477 _transit_effect_flip_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
1479 EINA_SAFETY_ON_NULL_RETURN(effect);
1480 EINA_SAFETY_ON_NULL_RETURN(transit);
1481 Evas_Object *obj, *front, *back;
1483 Elm_Transit_Effect_Flip *flip = effect;
1486 Evas_Coord x, y, w, h;
1488 map = evas_map_new(4);
1491 if (flip->cw) degree = (float)(progress * 180);
1492 else degree = (float)(progress * -180);
1494 count = eina_list_count(transit->objs);
1496 for (i = 0; i < (count - 1); i += 2)
1498 Evas_Coord half_w, half_h;
1500 front = eina_list_nth(transit->objs, i);
1501 back = eina_list_nth(transit->objs, i+1);
1503 if ((degree < 90) && (degree > -90))
1508 evas_object_hide(back);
1509 evas_object_show(front);
1517 evas_object_hide(front);
1518 evas_object_show(back);
1522 evas_map_util_points_populate_from_object_full(map, obj, 0);
1523 evas_object_geometry_get(obj, &x, &y, &w, &h);
1527 if (flip->axis == ELM_TRANSIT_EFFECT_FLIP_AXIS_Y)
1529 if ((degree >= 90) || (degree <= -90))
1531 evas_map_point_image_uv_set(map, 0, w, 0);
1532 evas_map_point_image_uv_set(map, 1, 0, 0);
1533 evas_map_point_image_uv_set(map, 2, 0, h);
1534 evas_map_point_image_uv_set(map, 3, w, h);
1536 evas_map_util_3d_rotate(map, 0, degree,
1537 0, x + half_w, y + half_h, 0);
1541 if ((degree >= 90) || (degree <= -90))
1543 evas_map_point_image_uv_set(map, 0, 0, h);
1544 evas_map_point_image_uv_set(map, 1, w, h);
1545 evas_map_point_image_uv_set(map, 2, w, 0);
1546 evas_map_point_image_uv_set(map, 3, 0, 0);
1548 evas_map_util_3d_rotate(map, degree,
1549 0, 0, x + half_w, y + half_h, 0);
1551 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, _TRANSIT_FOCAL);
1552 evas_object_map_enable_set(front, EINA_TRUE);
1553 evas_object_map_enable_set(back, EINA_TRUE);
1554 evas_object_map_set(obj, map);
1559 static Elm_Transit_Effect *
1560 _transit_effect_flip_context_new(Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1562 Elm_Transit_Effect_Flip *flip;
1564 flip = ELM_NEW(Elm_Transit_Effect_Flip);
1565 if (!flip) return NULL;
1574 * Add the Flip Effect to Elm_Transit.
1576 * @note This API is one of the facades. It creates flip effect context
1577 * and add it's required APIs to elm_transit_effect_add.
1578 * @note This effect is applied to each pair of objects in the order they are listed
1579 * in the transit list of objects. The first object in the pair will be the
1580 * "front" object and the second will be the "back" object.
1582 * @see elm_transit_effect_add()
1584 * @param transit Transit object.
1585 * @param axis Flipping Axis(X or Y).
1586 * @param cw Flipping Direction. EINA_TRUE is clock-wise.
1587 * @return Flip effect context data.
1590 * @warning Is higher recommended just create a transit with this effect when
1591 * the window that the objects of the transit belongs has already been created.
1592 * This is because this effect needs the geometry information about the objects,
1593 * and if the window was not created yet, it can get a wrong information.
1595 EAPI Elm_Transit_Effect *
1596 elm_transit_effect_flip_add(Elm_Transit *transit, Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1598 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1599 Elm_Transit_Effect *effect_context = _transit_effect_flip_context_new(axis, cw);
1601 if (!effect_context) return NULL;
1602 elm_transit_effect_add(transit,
1603 _transit_effect_flip_op, effect_context,
1604 _transit_effect_flip_context_free);
1605 return effect_context;
1608 ///////////////////////////////////////////////////////////////////////////////
1609 //ResizableFlip Effect
1610 ///////////////////////////////////////////////////////////////////////////////
1611 typedef struct _Elm_Transit_Effect_Resizable_Flip Elm_Transit_Effect_ResizableFlip;
1612 typedef struct _Elm_Transit_Effect_Resizable_Flip_Node Elm_Transit_Effect_ResizableFlip_Node;
1614 struct _Elm_Transit_Effect_Resizable_Flip_Node
1620 } from_pos, from_size, to_pos, to_size;
1623 struct _Elm_Transit_Effect_Resizable_Flip
1627 Elm_Transit_Effect_Flip_Axis axis;
1631 _resizable_flip_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1633 Elm_Transit_Effect_ResizableFlip *resizable_flip = data;
1635 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1637 EINA_LIST_FOREACH(resizable_flip->nodes, elist, resizable_flip_node)
1639 if (resizable_flip_node->front == obj)
1640 evas_object_event_callback_del(resizable_flip_node->back,
1641 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1642 else if (resizable_flip_node->back == obj)
1643 evas_object_event_callback_del(resizable_flip_node->front,
1644 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1647 resizable_flip->nodes = eina_list_remove_list(resizable_flip->nodes,
1649 free(resizable_flip_node);
1655 _resizable_flip_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_ResizableFlip *resizable_flip)
1657 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1658 Eina_List *data_list = NULL;
1659 Evas_Coord front_x, front_y, front_w, front_h;
1660 Evas_Coord back_x, back_y, back_w, back_h;
1663 count = eina_list_count(transit->objs);
1664 for (i = 0; i < (count - 1); i += 2)
1666 resizable_flip_node = ELM_NEW(Elm_Transit_Effect_ResizableFlip_Node);
1667 if (!resizable_flip_node)
1669 eina_list_free(data_list);
1673 resizable_flip_node->front = eina_list_nth(transit->objs, i);
1674 resizable_flip_node->back = eina_list_nth(transit->objs, i+1);
1676 evas_object_geometry_get(resizable_flip_node->front,
1677 &front_x, &front_y, &front_w, &front_h);
1678 evas_object_geometry_get(resizable_flip_node->back,
1679 &back_x, &back_y, &back_w, &back_h);
1681 resizable_flip_node->from_pos.x = front_x;
1682 resizable_flip_node->from_pos.y = front_y;
1683 resizable_flip_node->to_pos.x = back_x - front_x;
1684 resizable_flip_node->to_pos.y = back_y - front_y;
1686 resizable_flip_node->from_size.x = front_w;
1687 resizable_flip_node->from_size.y = front_h;
1688 resizable_flip_node->to_size.x = back_w - front_w;
1689 resizable_flip_node->to_size.y = back_h - front_h;
1691 data_list = eina_list_append(data_list, resizable_flip_node);
1693 evas_object_event_callback_add(resizable_flip_node->back,
1694 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb, resizable_flip);
1695 evas_object_event_callback_add(resizable_flip_node->front,
1696 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb, resizable_flip);
1703 _set_image_uv_by_axis_y(Evas_Map *map, Elm_Transit_Effect_ResizableFlip_Node *flip, float degree)
1705 if ((degree >= 90) || (degree <= -90))
1707 evas_map_point_image_uv_set(map, 0,
1708 (flip->from_size.x * 2) + flip->to_size.x,
1710 evas_map_point_image_uv_set(map, 1, 0, 0);
1711 evas_map_point_image_uv_set(map, 2, 0,
1712 (flip->from_size.y * 2) + flip->to_size.y);
1713 evas_map_point_image_uv_set(map, 3,
1714 (flip->from_size.x * 2) + flip->to_size.x,
1715 (flip->from_size.y * 2) + flip->to_size.y);
1719 evas_map_point_image_uv_set(map, 0, 0, 0);
1720 evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
1721 evas_map_point_image_uv_set(map, 2, flip->from_size.x,
1723 evas_map_point_image_uv_set(map, 3, 0, flip->from_size.y);
1728 _set_image_uv_by_axis_x(Evas_Map *map, Elm_Transit_Effect_ResizableFlip_Node *flip, float degree)
1730 if ((degree >= 90) || (degree <= -90))
1732 evas_map_point_image_uv_set(map, 0, 0,
1733 (flip->from_size.y * 2) + flip->to_size.y);
1734 evas_map_point_image_uv_set(map, 1,
1735 (flip->from_size.x * 2) + flip->to_size.x,
1736 (flip->from_size.y * 2) + flip->to_size.y);
1737 evas_map_point_image_uv_set(map, 2,
1738 (flip->from_size.x * 2) + flip->to_size.x,
1740 evas_map_point_image_uv_set(map, 3, 0, 0);
1744 evas_map_point_image_uv_set(map, 0, 0, 0);
1745 evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
1746 evas_map_point_image_uv_set(map, 2, flip->from_size.x,
1748 evas_map_point_image_uv_set(map, 3, 0, flip->from_size.y);
1753 _transit_effect_resizable_flip_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
1755 EINA_SAFETY_ON_NULL_RETURN(effect);
1757 Elm_Transit_Effect_ResizableFlip *resizable_flip = effect;
1758 Eina_List *elist, *elist_next;
1759 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1761 EINA_LIST_FOREACH_SAFE(resizable_flip->nodes,
1762 elist, elist_next, resizable_flip_node)
1764 evas_object_map_enable_set(resizable_flip_node->front, EINA_FALSE);
1765 evas_object_map_enable_set(resizable_flip_node->back, EINA_FALSE);
1767 resizable_flip->nodes = eina_list_remove_list(resizable_flip->nodes,
1770 evas_object_event_callback_del(resizable_flip_node->back,
1771 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1772 evas_object_event_callback_del(resizable_flip_node->front,
1773 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1774 free(resizable_flip_node);
1776 free(resizable_flip);
1780 _transit_effect_resizable_flip_op(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__, double progress)
1782 EINA_SAFETY_ON_NULL_RETURN(effect);
1787 Evas_Coord half_w, half_h;
1788 Elm_Transit_Effect_ResizableFlip *resizable_flip = effect;
1789 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1792 map = evas_map_new(4);
1795 if (resizable_flip->cw) degree = (float)(progress * 180);
1796 else degree = (float)(progress * -180);
1798 if (!resizable_flip->nodes)
1799 resizable_flip->nodes = _resizable_flip_nodes_build(transit,
1802 EINA_LIST_FOREACH(resizable_flip->nodes, elist, resizable_flip_node)
1804 if ((degree < 90) && (degree > -90))
1806 obj = resizable_flip_node->front;
1807 if (resizable_flip_node->front != resizable_flip_node->back)
1809 evas_object_hide(resizable_flip_node->back);
1810 evas_object_show(resizable_flip_node->front);
1815 obj = resizable_flip_node->back;
1816 if (resizable_flip_node->front != resizable_flip_node->back)
1818 evas_object_hide(resizable_flip_node->front);
1819 evas_object_show(resizable_flip_node->back);
1823 x = resizable_flip_node->from_pos.x +
1824 (resizable_flip_node->to_pos.x * progress);
1825 y = resizable_flip_node->from_pos.y +
1826 (resizable_flip_node->to_pos.y * progress);
1827 w = resizable_flip_node->from_size.x +
1828 (resizable_flip_node->to_size.x * progress);
1829 h = resizable_flip_node->from_size.y +
1830 (resizable_flip_node->to_size.y * progress);
1831 evas_map_point_coord_set(map, 0, x, y, 0);
1832 evas_map_point_coord_set(map, 1, x + w, y, 0);
1833 evas_map_point_coord_set(map, 2, x + w, y + h, 0);
1834 evas_map_point_coord_set(map, 3, x, y + h, 0);
1836 half_w = (Evas_Coord)(w / 2);
1837 half_h = (Evas_Coord)(h / 2);
1839 if (resizable_flip->axis == ELM_TRANSIT_EFFECT_FLIP_AXIS_Y)
1841 _set_image_uv_by_axis_y(map, resizable_flip_node, degree);
1842 evas_map_util_3d_rotate(map, 0, degree,
1843 0, x + half_w, y + half_h, 0);
1847 _set_image_uv_by_axis_x(map, resizable_flip_node, degree);
1848 evas_map_util_3d_rotate(map, degree, 0,
1849 0, x + half_w, y + half_h, 0);
1852 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, _TRANSIT_FOCAL);
1853 evas_object_map_enable_set(resizable_flip_node->front, EINA_TRUE);
1854 evas_object_map_enable_set(resizable_flip_node->back, EINA_TRUE);
1855 evas_object_map_set(obj, map);
1860 static Elm_Transit_Effect *
1861 _transit_effect_resizable_flip_context_new(Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1863 Elm_Transit_Effect_ResizableFlip *resizable_flip;
1865 resizable_flip = ELM_NEW(Elm_Transit_Effect_ResizableFlip);
1866 if (!resizable_flip) return NULL;
1868 resizable_flip->cw = cw;
1869 resizable_flip->axis = axis;
1871 return resizable_flip;
1875 * Add the Resizable Flip Effect to Elm_Transit.
1877 * @note This API is one of the facades. It creates resizable flip effect context
1878 * and add it's required APIs to elm_transit_effect_add.
1879 * @note This effect is applied to each pair of objects in the order they are listed
1880 * in the transit list of objects. The first object in the pair will be the
1881 * "front" object and the second will be the "back" object.
1883 * @see elm_transit_effect_add()
1885 * @param transit Transit object.
1886 * @param axis Flipping Axis(X or Y).
1887 * @param cw Flipping Direction. EINA_TRUE is clock-wise.
1888 * @return Resizable flip effect context data.
1891 * @warning Is higher recommended just create a transit with this effect when
1892 * the window that the objects of the transit belongs has already been created.
1893 * This is because this effect needs the geometry information about the objects,
1894 * and if the window was not created yet, it can get a wrong information.
1896 EAPI Elm_Transit_Effect *
1897 elm_transit_effect_resizable_flip_add(Elm_Transit *transit, Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1899 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1900 Elm_Transit_Effect *effect_context = _transit_effect_resizable_flip_context_new(axis, cw);
1902 if (!effect_context) return NULL;
1903 elm_transit_effect_add(transit,
1904 _transit_effect_resizable_flip_op, effect_context,
1905 _transit_effect_resizable_flip_context_free);
1906 return effect_context;
1910 ///////////////////////////////////////////////////////////////////////////////
1912 ///////////////////////////////////////////////////////////////////////////////
1913 typedef struct _Elm_Transit_Effect_Wipe Elm_Transit_Effect_Wipe;
1915 struct _Elm_Transit_Effect_Wipe
1917 Elm_Transit_Effect_Wipe_Type type;
1918 Elm_Transit_Effect_Wipe_Dir dir;
1922 _elm_fx_wipe_hide(Evas_Map * map, Elm_Transit_Effect_Wipe_Dir dir, float x, float y, float w, float h, float progress)
1928 case ELM_TRANSIT_EFFECT_WIPE_DIR_LEFT:
1929 w2 = w - (w * progress);
1931 evas_map_point_image_uv_set(map, 0, 0, 0);
1932 evas_map_point_image_uv_set(map, 1, w2, 0);
1933 evas_map_point_image_uv_set(map, 2, w2, h);
1934 evas_map_point_image_uv_set(map, 3, 0, h);
1935 evas_map_point_coord_set(map, 0, x, y, 0);
1936 evas_map_point_coord_set(map, 1, x + w2, y, 0);
1937 evas_map_point_coord_set(map, 2, x + w2, h2, 0);
1938 evas_map_point_coord_set(map, 3, x, h2, 0);
1940 case ELM_TRANSIT_EFFECT_WIPE_DIR_RIGHT:
1941 w2 = (w * progress);
1943 evas_map_point_image_uv_set(map, 0, w2, 0);
1944 evas_map_point_image_uv_set(map, 1, w, 0);
1945 evas_map_point_image_uv_set(map, 2, w, h);
1946 evas_map_point_image_uv_set(map, 3, w2, h);
1947 evas_map_point_coord_set(map, 0, x + w2, y, 0);
1948 evas_map_point_coord_set(map, 1, x + w, y, 0);
1949 evas_map_point_coord_set(map, 2, x + w, h2, 0);
1950 evas_map_point_coord_set(map, 3, x + w2, h2, 0);
1952 case ELM_TRANSIT_EFFECT_WIPE_DIR_UP:
1954 h2 = h - (h * progress);
1955 evas_map_point_image_uv_set(map, 0, 0, 0);
1956 evas_map_point_image_uv_set(map, 1, w, 0);
1957 evas_map_point_image_uv_set(map, 2, w, h2);
1958 evas_map_point_image_uv_set(map, 3, 0, h2);
1959 evas_map_point_coord_set(map, 0, x, y, 0);
1960 evas_map_point_coord_set(map, 1, w2, y, 0);
1961 evas_map_point_coord_set(map, 2, w2, y+h2, 0);
1962 evas_map_point_coord_set(map, 3, x, y+h2, 0);
1964 case ELM_TRANSIT_EFFECT_WIPE_DIR_DOWN:
1966 h2 = (h * progress);
1967 evas_map_point_image_uv_set(map, 0, 0, h2);
1968 evas_map_point_image_uv_set(map, 1, w, h2);
1969 evas_map_point_image_uv_set(map, 2, w, h);
1970 evas_map_point_image_uv_set(map, 3, 0, h);
1971 evas_map_point_coord_set(map, 0, x, y + h2, 0);
1972 evas_map_point_coord_set(map, 1, w2, y + h2, 0);
1973 evas_map_point_coord_set(map, 2, w2, y + h, 0);
1974 evas_map_point_coord_set(map, 3, x, y + h, 0);
1979 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, _TRANSIT_FOCAL);
1983 _elm_fx_wipe_show(Evas_Map *map, Elm_Transit_Effect_Wipe_Dir dir, float x, float y, float w, float h, float progress)
1989 case ELM_TRANSIT_EFFECT_WIPE_DIR_LEFT:
1990 w2 = (w - (w * progress));
1992 evas_map_point_image_uv_set(map, 0, w2, 0);
1993 evas_map_point_image_uv_set(map, 1, w, 0);
1994 evas_map_point_image_uv_set(map, 2, w, h);
1995 evas_map_point_image_uv_set(map, 3, w2, h);
1996 evas_map_point_coord_set(map, 0, x + w2, y, 0);
1997 evas_map_point_coord_set(map, 1, w, y, 0);
1998 evas_map_point_coord_set(map, 2, w, h2, 0);
1999 evas_map_point_coord_set(map, 3, x + w2, h2, 0);
2001 case ELM_TRANSIT_EFFECT_WIPE_DIR_RIGHT:
2002 w2 = (w * progress);
2004 evas_map_point_image_uv_set(map, 0, 0, 0);
2005 evas_map_point_image_uv_set(map, 1, w2, 0);
2006 evas_map_point_image_uv_set(map, 2, w2, h);
2007 evas_map_point_image_uv_set(map, 3, 0, h);
2008 evas_map_point_coord_set(map, 0, x, y, 0);
2009 evas_map_point_coord_set(map, 1, x + w2, y, 0);
2010 evas_map_point_coord_set(map, 2, x + w2, h2, 0);
2011 evas_map_point_coord_set(map, 3, x, h2, 0);
2013 case ELM_TRANSIT_EFFECT_WIPE_DIR_UP:
2015 h2 = (h - (h * progress));
2016 evas_map_point_image_uv_set(map, 0, 0, h2);
2017 evas_map_point_image_uv_set(map, 1, w, h2);
2018 evas_map_point_image_uv_set(map, 2, w, h);
2019 evas_map_point_image_uv_set(map, 3, 0, h);
2020 evas_map_point_coord_set(map, 0, x, y + h2, 0);
2021 evas_map_point_coord_set(map, 1, w2, y + h2, 0);
2022 evas_map_point_coord_set(map, 2, w2, y + h, 0);
2023 evas_map_point_coord_set(map, 3, x, y + h, 0);
2025 case ELM_TRANSIT_EFFECT_WIPE_DIR_DOWN:
2027 h2 = (h * progress);
2028 evas_map_point_image_uv_set(map, 0, 0, 0);
2029 evas_map_point_image_uv_set(map, 1, w, 0);
2030 evas_map_point_image_uv_set(map, 2, w, h2);
2031 evas_map_point_image_uv_set(map, 3, 0, h2);
2032 evas_map_point_coord_set(map, 0, x, y, 0);
2033 evas_map_point_coord_set(map, 1, w2, y, 0);
2034 evas_map_point_coord_set(map, 2, w2, y + h2, 0);
2035 evas_map_point_coord_set(map, 3, x, y + h2, 0);
2040 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, _TRANSIT_FOCAL);
2044 _transit_effect_wipe_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit)
2046 EINA_SAFETY_ON_NULL_RETURN(effect);
2047 EINA_SAFETY_ON_NULL_RETURN(transit);
2050 Elm_Transit_Effect_Wipe *wipe = effect;
2051 Eina_Bool reverse = elm_transit_auto_reverse_get(transit);
2053 EINA_LIST_FOREACH(transit->objs, elist, obj)
2055 if ((wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_SHOW && !reverse)
2056 || (wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_HIDE && reverse))
2057 evas_object_show(obj);
2058 else evas_object_hide(obj);
2059 evas_object_map_enable_set(obj, EINA_FALSE);
2066 _transit_effect_wipe_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2068 EINA_SAFETY_ON_NULL_RETURN(effect);
2069 EINA_SAFETY_ON_NULL_RETURN(transit);
2070 Elm_Transit_Effect_Wipe *wipe = effect;
2072 Evas_Coord _x, _y, _w, _h;
2076 map = evas_map_new(4);
2079 EINA_LIST_FOREACH(transit->objs, elist, obj)
2081 evas_object_geometry_get(obj, &_x, &_y, &_w, &_h);
2083 if (wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_SHOW)
2084 _elm_fx_wipe_show(map, wipe->dir, _x, _y, _w, _h, (float)progress);
2086 _elm_fx_wipe_hide(map, wipe->dir, _x, _y, _w, _h, (float)progress);
2088 evas_object_map_enable_set(obj, EINA_TRUE);
2089 evas_object_map_set(obj, map);
2094 static Elm_Transit_Effect *
2095 _transit_effect_wipe_context_new(Elm_Transit_Effect_Wipe_Type type, Elm_Transit_Effect_Wipe_Dir dir)
2097 Elm_Transit_Effect_Wipe *wipe;
2099 wipe = ELM_NEW(Elm_Transit_Effect_Wipe);
2100 if (!wipe) return NULL;
2109 * Add the Wipe Effect to Elm_Transit.
2111 * @note This API is one of the facades. It creates wipe effect context
2112 * and add it's required APIs to elm_transit_effect_add.
2114 * @see elm_transit_effect_add()
2116 * @param transit Transit object.
2117 * @param type Wipe type. Hide or show.
2118 * @param dir Wipe Direction.
2119 * @return Wipe effect context data.
2122 * @warning Is higher recommended just create a transit with this effect when
2123 * the window that the objects of the transit belongs has already been created.
2124 * This is because this effect needs the geometry information about the objects,
2125 * and if the window was not created yet, it can get a wrong information.
2128 elm_transit_effect_wipe_add(Elm_Transit *transit, Elm_Transit_Effect_Wipe_Type type, Elm_Transit_Effect_Wipe_Dir dir)
2130 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2131 void *effect_context = _transit_effect_wipe_context_new(type, dir);
2133 if (!effect_context) return NULL;
2134 elm_transit_effect_add(transit,
2135 _transit_effect_wipe_op, effect_context,
2136 _transit_effect_wipe_context_free);
2137 return effect_context;
2141 ///////////////////////////////////////////////////////////////////////////////
2143 ///////////////////////////////////////////////////////////////////////////////
2144 typedef struct _Elm_Transit_Effect_Color Elm_Transit_Effect_Color;
2146 struct _Elm_Transit_Effect_Color
2148 struct _unsigned_color {
2149 unsigned int r, g, b, a;
2151 struct _signed_color {
2157 _transit_effect_color_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
2159 Elm_Transit_Effect_Color *color = effect;
2164 _transit_effect_color_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2166 EINA_SAFETY_ON_NULL_RETURN(effect);
2167 EINA_SAFETY_ON_NULL_RETURN(transit);
2168 Elm_Transit_Effect_Color *color = effect;
2171 unsigned int r, g, b, a;
2173 r = (color->from.r + (int)((float)color->to.r * progress));
2174 g = (color->from.g + (int)((float)color->to.g * progress));
2175 b = (color->from.b + (int)((float)color->to.b * progress));
2176 a = (color->from.a + (int)((float)color->to.a * progress));
2178 EINA_LIST_FOREACH(transit->objs, elist, obj)
2179 evas_object_color_set(obj, r, g, b, a);
2182 static Elm_Transit_Effect *
2183 _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)
2185 Elm_Transit_Effect_Color *color;
2187 color = ELM_NEW(Elm_Transit_Effect_Color);
2188 if (!color) return NULL;
2190 color->from.r = from_r;
2191 color->from.g = from_g;
2192 color->from.b = from_b;
2193 color->from.a = from_a;
2194 color->to.r = to_r - from_r;
2195 color->to.g = to_g - from_g;
2196 color->to.b = to_b - from_b;
2197 color->to.a = to_a - from_a;
2203 * Add the Color Effect to Elm_Transit.
2205 * @note This API is one of the facades. It creates color effect context
2206 * and add it's required APIs to elm_transit_effect_add.
2208 * @see elm_transit_effect_add()
2210 * @param transit Transit object.
2211 * @param from_r RGB R when effect begins.
2212 * @param from_g RGB G when effect begins.
2213 * @param from_b RGB B when effect begins.
2214 * @param from_a RGB A when effect begins.
2215 * @param to_r RGB R when effect ends.
2216 * @param to_g RGB G when effect ends.
2217 * @param to_b RGB B when effect ends.
2218 * @param to_a RGB A when effect ends.
2219 * @return Color effect context data.
2223 EAPI Elm_Transit_Effect *
2224 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)
2226 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2227 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);
2229 if (!effect_context) return NULL;
2230 elm_transit_effect_add(transit,
2231 _transit_effect_color_op, effect_context,
2232 _transit_effect_color_context_free);
2233 return effect_context;
2236 ///////////////////////////////////////////////////////////////////////////////
2238 ///////////////////////////////////////////////////////////////////////////////
2239 typedef struct _Elm_Transit_Effect_Fade Elm_Transit_Effect_Fade;
2240 typedef struct _Elm_Transit_Effect_Fade_Node Elm_Transit_Effect_Fade_Node;
2242 struct _Elm_Transit_Effect_Fade_Node
2244 Evas_Object *before;
2246 struct _signed_color before_color, after_color;
2249 Eina_Bool inversed : 1;
2252 struct _Elm_Transit_Effect_Fade
2258 _fade_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2260 Elm_Transit_Effect_Fade *fade = data;
2262 Elm_Transit_Effect_Fade_Node *fade_node;
2264 EINA_LIST_FOREACH(fade->nodes, elist, fade_node)
2266 if (fade_node->before == obj)
2267 evas_object_event_callback_del(fade_node->after,
2268 EVAS_CALLBACK_DEL, _fade_object_del_cb);
2269 else if (fade_node->after == obj)
2270 evas_object_event_callback_del(fade_node->before,
2271 EVAS_CALLBACK_DEL, _fade_object_del_cb);
2274 fade->nodes = eina_list_remove_list(fade->nodes, elist);
2281 _fade_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Fade *fade_data)
2283 Elm_Transit_Effect_Fade_Node *fade;
2284 Eina_List *data_list = NULL;
2287 count = eina_list_count(transit->objs);
2288 for (i = 0; i < count; i += 2)
2290 fade = ELM_NEW(Elm_Transit_Effect_Fade_Node);
2293 eina_list_free(data_list);
2297 fade->before = eina_list_nth(transit->objs, i);
2298 fade->after = eina_list_nth(transit->objs, i+1);
2300 evas_object_color_get(fade->before,
2301 &fade->before_color.r, &fade->before_color.g,
2302 &fade->before_color.b, &fade->before_color.a);
2303 evas_object_color_get(fade->after,
2304 &fade->after_color.r, &fade->after_color.g,
2305 &fade->after_color.b, &fade->after_color.a);
2307 fade->before_alpha = (255 - fade->before_color.a);
2308 fade->after_alpha = (255 - fade->after_color.a);
2310 data_list = eina_list_append(data_list, fade);
2312 evas_object_event_callback_add(fade->before,
2313 EVAS_CALLBACK_DEL, _fade_object_del_cb, fade_data);
2314 evas_object_event_callback_add(fade->after,
2315 EVAS_CALLBACK_DEL, _fade_object_del_cb, fade_data);
2321 _transit_effect_fade_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
2323 EINA_SAFETY_ON_NULL_RETURN(effect);
2324 Elm_Transit_Effect_Fade *fade = effect;
2325 Elm_Transit_Effect_Fade_Node *fade_node;
2326 Eina_List *elist, *elist_next;
2328 EINA_LIST_FOREACH_SAFE(fade->nodes, elist, elist_next, fade_node)
2330 evas_object_color_set(fade_node->before, fade_node->before_color.r,
2331 fade_node->before_color.g,
2332 fade_node->before_color.b,
2333 fade_node->before_color.a);
2334 evas_object_color_set(fade_node->after, fade_node->after_color.r,
2335 fade_node->after_color.g,
2336 fade_node->after_color.b,
2337 fade_node->after_color.a);
2339 fade->nodes = eina_list_remove_list(fade->nodes, elist);
2340 evas_object_event_callback_del(fade_node->before,
2341 EVAS_CALLBACK_DEL, _fade_object_del_cb);
2342 evas_object_event_callback_del(fade_node->after,
2343 EVAS_CALLBACK_DEL, _fade_object_del_cb);
2351 _transit_effect_fade_op(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__, double progress)
2353 EINA_SAFETY_ON_NULL_RETURN(effect);
2354 Elm_Transit_Effect_Fade *fade = effect;
2356 Elm_Transit_Effect_Fade_Node *fade_node;
2360 fade->nodes = _fade_nodes_build(transit, fade);
2362 EINA_LIST_FOREACH(fade->nodes, elist, fade_node)
2366 if (!fade_node->inversed)
2368 evas_object_hide(fade_node->after);
2369 evas_object_show(fade_node->before);
2370 fade_node->inversed = EINA_TRUE;
2373 _progress = (1 - (progress * 2));
2375 evas_object_color_set(fade_node->before,
2376 fade_node->before_color.r * _progress,
2377 fade_node->before_color.g * _progress,
2378 fade_node->before_color.b * _progress,
2379 fade_node->before_color.a +
2380 fade_node->before_alpha * (1 - _progress));
2384 if (fade_node->inversed)
2386 evas_object_hide(fade_node->before);
2387 evas_object_show(fade_node->after);
2388 fade_node->inversed = EINA_FALSE;
2391 _progress = ((progress - 0.5) * 2);
2393 evas_object_color_set(fade_node->after,
2394 fade_node->after_color.r * _progress,
2395 fade_node->after_color.g * _progress,
2396 fade_node->after_color.b * _progress,
2397 fade_node->after_color.a +
2398 fade_node->after_alpha * (1 - _progress));
2403 static Elm_Transit_Effect *
2404 _transit_effect_fade_context_new(void)
2406 Elm_Transit_Effect_Fade *fade;
2407 fade = ELM_NEW(Elm_Transit_Effect_Fade);
2408 if (!fade) return NULL;
2413 * Add the Fade Effect to Elm_Transit.
2415 * @note This API is one of the facades. It creates fade effect context
2416 * and add it's required APIs to elm_transit_effect_add.
2417 * @note This effect is applied to each pair of objects in the order they are listed
2418 * in the transit list of objects. The first object in the pair will be the
2419 * "before" object and the second will be the "after" object.
2421 * @see elm_transit_effect_add()
2423 * @param transit Transit object.
2424 * @return Fade effect context data.
2427 * @warning Is higher recommended just create a transit with this effect when
2428 * the window that the objects of the transit belongs has already been created.
2429 * This is because this effect needs the color information about the objects,
2430 * and if the window was not created yet, it can get a wrong information.
2432 EAPI Elm_Transit_Effect *
2433 elm_transit_effect_fade_add(Elm_Transit *transit)
2435 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2437 Elm_Transit_Effect *effect_context = _transit_effect_fade_context_new();
2438 if (!effect_context) return NULL;
2439 elm_transit_effect_add(transit,
2440 _transit_effect_fade_op, effect_context,
2441 _transit_effect_fade_context_free);
2442 return effect_context;
2446 ///////////////////////////////////////////////////////////////////////////////
2448 ///////////////////////////////////////////////////////////////////////////////
2449 typedef struct _Elm_Transit_Effect_Blend Elm_Transit_Effect_Blend;
2450 typedef struct _Elm_Transit_Effect_Blend_Node Elm_Transit_Effect_Blend_Node;
2452 struct _Elm_Transit_Effect_Blend_Node
2454 Evas_Object *before;
2456 struct _signed_color from, to;
2459 struct _Elm_Transit_Effect_Blend
2465 _blend_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2467 Elm_Transit_Effect_Blend *blend = data;
2469 Elm_Transit_Effect_Blend_Node *blend_node;
2471 EINA_LIST_FOREACH(blend->nodes, elist, blend_node)
2473 if (blend_node->after == obj)
2474 evas_object_event_callback_del(blend_node->before,
2475 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2476 else if (blend_node->before == obj)
2477 evas_object_event_callback_del(blend_node->after,
2478 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2481 blend->nodes = eina_list_remove_list(blend->nodes, elist);
2488 _blend_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Blend *blend)
2490 Elm_Transit_Effect_Blend_Node *blend_node;
2491 Eina_List *data_list = NULL;
2494 count = eina_list_count(transit->objs);
2495 for (i = 0; i < (count - 1); i += 2)
2497 blend_node = ELM_NEW(Elm_Transit_Effect_Blend_Node);
2500 eina_list_free(data_list);
2504 blend_node->before = eina_list_nth(transit->objs, i);
2505 blend_node->after = eina_list_nth(transit->objs, i + 1);
2506 evas_object_show(blend_node->before);
2507 evas_object_show(blend_node->after);
2509 evas_object_color_get(blend_node->before, &blend_node->from.r,
2510 &blend_node->from.g, &blend_node->from.b,
2511 &blend_node->from.a);
2512 evas_object_color_get(blend_node->after, &blend_node->to.r,
2513 &blend_node->to.g, &blend_node->to.b,
2516 data_list = eina_list_append(data_list, blend_node);
2518 evas_object_event_callback_add(blend_node->before,
2519 EVAS_CALLBACK_DEL, _blend_object_del_cb, blend);
2520 evas_object_event_callback_add(blend_node->after,
2521 EVAS_CALLBACK_DEL, _blend_object_del_cb, blend);
2527 _transit_effect_blend_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
2529 EINA_SAFETY_ON_NULL_RETURN(effect);
2530 Elm_Transit_Effect_Blend *blend = effect;
2531 Elm_Transit_Effect_Blend_Node *blend_node;
2532 Eina_List *elist, *elist_next;
2534 EINA_LIST_FOREACH_SAFE(blend->nodes, elist, elist_next, blend_node)
2536 evas_object_color_set(blend_node->before,
2537 blend_node->from.r, blend_node->from.g,
2538 blend_node->from.b, blend_node->from.a);
2539 evas_object_color_set(blend_node->after, blend_node->to.r,
2540 blend_node->to.g, blend_node->to.b,
2543 if (elm_transit_auto_reverse_get(transit))
2544 evas_object_hide(blend_node->after);
2546 evas_object_hide(blend_node->before);
2548 blend->nodes = eina_list_remove_list(blend->nodes, elist);
2550 evas_object_event_callback_del(blend_node->before,
2551 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2552 evas_object_event_callback_del(blend_node->after,
2553 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2560 _transit_effect_blend_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2562 EINA_SAFETY_ON_NULL_RETURN(effect);
2563 EINA_SAFETY_ON_NULL_RETURN(transit);
2564 Elm_Transit_Effect_Blend *blend = effect;
2565 Elm_Transit_Effect_Blend_Node *blend_node;
2568 if (!blend->nodes) blend->nodes = _blend_nodes_build(transit, blend);
2570 EINA_LIST_FOREACH(blend->nodes, elist, blend_node)
2572 evas_object_color_set(blend_node->before,
2573 (int)(blend_node->from.r * (1 - progress)),
2574 (int)(blend_node->from.g * (1 - progress)),
2575 (int)(blend_node->from.b * (1 - progress)),
2576 (int)(blend_node->from.a * (1 - progress)));
2577 evas_object_color_set(blend_node->after,
2578 (int)(blend_node->to.r * progress),
2579 (int)(blend_node->to.g * progress),
2580 (int)(blend_node->to.b * progress),
2581 (int)(blend_node->to.a * progress));
2585 static Elm_Transit_Effect *
2586 _transit_effect_blend_context_new(void)
2588 Elm_Transit_Effect_Blend *blend;
2590 blend = ELM_NEW(Elm_Transit_Effect_Blend);
2591 if (!blend) return NULL;
2596 * Add the Blend Effect to Elm_Transit.
2598 * @note This API is one of the facades. It creates blend effect context
2599 * and add it's required APIs to elm_transit_effect_add.
2600 * @note This effect is applied to each pair of objects in the order they are listed
2601 * in the transit list of objects. The first object in the pair will be the
2602 * "before" object and the second will be the "after" object.
2604 * @see elm_transit_effect_add()
2606 * @param transit Transit object.
2607 * @return Blend effect context data.
2610 * @warning Is higher recommended just create a transit with this effect when
2611 * the window that the objects of the transit belongs has already been created.
2612 * This is because this effect needs the color information about the objects,
2613 * and if the window was not created yet, it can get a wrong information.
2615 EAPI Elm_Transit_Effect *
2616 elm_transit_effect_blend_add(Elm_Transit *transit)
2618 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2619 Elm_Transit_Effect *effect_context = _transit_effect_blend_context_new();
2621 if (!effect_context) return NULL;
2622 elm_transit_effect_add(transit,
2623 _transit_effect_blend_op, effect_context,
2624 _transit_effect_blend_context_free);
2625 return effect_context;
2629 ///////////////////////////////////////////////////////////////////////////////
2631 ///////////////////////////////////////////////////////////////////////////////
2632 typedef struct _Elm_Transit_Effect_Rotation Elm_Transit_Effect_Rotation;
2634 struct _Elm_Transit_Effect_Rotation
2640 _transit_effect_rotation_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
2642 Elm_Transit_Effect_Rotation *rotation = effect;
2647 _transit_effect_rotation_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2649 EINA_SAFETY_ON_NULL_RETURN(effect);
2650 EINA_SAFETY_ON_NULL_RETURN(transit);
2651 Elm_Transit_Effect_Rotation *rotation = effect;
2653 Evas_Coord x, y, w, h;
2655 float half_w, half_h;
2659 map = evas_map_new(4);
2662 EINA_LIST_FOREACH(transit->objs, elist, obj)
2664 evas_map_util_points_populate_from_object_full(map, obj, 0);
2665 degree = rotation->from + (float)(progress * rotation->to);
2667 evas_object_geometry_get(obj, &x, &y, &w, &h);
2669 half_w = (float)w * 0.5;
2670 half_h = (float)h * 0.5;
2672 evas_map_util_3d_rotate(map, 0, 0, degree, x + half_w, y + half_h, 0);
2673 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, _TRANSIT_FOCAL);
2674 evas_object_map_enable_set(obj, EINA_TRUE);
2675 evas_object_map_set(obj, map);
2680 static Elm_Transit_Effect *
2681 _transit_effect_rotation_context_new(float from_degree, float to_degree)
2683 Elm_Transit_Effect_Rotation *rotation;
2685 rotation = ELM_NEW(Elm_Transit_Effect_Rotation);
2686 if (!rotation) return NULL;
2688 rotation->from = from_degree;
2689 rotation->to = to_degree - from_degree;
2695 * Add the Rotation Effect to Elm_Transit.
2697 * @note This API is one of the facades. It creates rotation effect context
2698 * and add it's required APIs to elm_transit_effect_add.
2700 * @see elm_transit_effect_add()
2702 * @param transit Transit object.
2703 * @param from_degree Degree when effect begins.
2704 * @param to_degree Degree when effect is ends.
2705 * @return Rotation effect context data.
2708 * @warning Is higher recommended just create a transit with this effect when
2709 * the window that the objects of the transit belongs has already been created.
2710 * This is because this effect needs the geometry information about the objects,
2711 * and if the window was not created yet, it can get a wrong information.
2713 EAPI Elm_Transit_Effect *
2714 elm_transit_effect_rotation_add(Elm_Transit *transit, float from_degree, float to_degree)
2716 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2717 Elm_Transit_Effect *effect_context = _transit_effect_rotation_context_new(from_degree, to_degree);
2719 if (!effect_context) return NULL;
2720 elm_transit_effect_add(transit,
2721 _transit_effect_rotation_op, effect_context,
2722 _transit_effect_rotation_context_free);
2723 return effect_context;
2727 ///////////////////////////////////////////////////////////////////////////////
2728 //ImageAnimation Effect
2729 ///////////////////////////////////////////////////////////////////////////////
2730 typedef struct _Elm_Transit_Effect_Image_Animation Elm_Transit_Effect_Image_Animation;
2732 struct _Elm_Transit_Effect_Image_Animation
2738 _transit_effect_image_animation_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
2740 EINA_SAFETY_ON_NULL_RETURN(effect);
2741 Elm_Transit_Effect_Image_Animation *image_animation = effect;
2743 Eina_List *elist, *elist_next;
2745 EINA_LIST_FOREACH_SAFE(image_animation->images, elist, elist_next, image)
2747 image_animation->images =
2748 eina_list_remove_list(image_animation->images, elist);
2749 eina_stringshare_del(image);
2752 free(image_animation);
2756 _transit_effect_image_animation_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2758 EINA_SAFETY_ON_NULL_RETURN(effect);
2759 EINA_SAFETY_ON_NULL_RETURN(transit);
2763 Elm_Transit_Effect_Image_Animation *image_animation = effect;
2764 unsigned int count = 0;
2767 type = eina_stringshare_add("icon");
2768 len = eina_list_count(image_animation->images);
2770 if (!len) count = floor(progress * len);
2771 else count = floor(progress * (len - 1));
2773 EINA_LIST_FOREACH(transit->objs, elist, obj)
2775 if (elm_widget_type_check(obj, type))
2776 elm_icon_file_set(obj,
2777 eina_list_nth(image_animation->images, count), NULL);
2780 eina_stringshare_del(type);
2783 static Elm_Transit_Effect *
2784 _transit_effect_image_animation_context_new(Eina_List *images)
2786 Elm_Transit_Effect_Image_Animation *image_animation;
2787 image_animation = ELM_NEW(Elm_Transit_Effect_Image_Animation);
2789 if (!image_animation) return NULL;
2790 image_animation->images = images;
2791 return image_animation;
2795 * Add the ImageAnimation Effect to Elm_Transit.
2797 * @note This API is one of the facades. It creates image animation effect context
2798 * and add it's required APIs to elm_transit_effect_add.
2799 * The @p images parameter is a list images paths. This list and
2800 * its contents will be deleted at the end of the effect by
2801 * elm_transit_effect_image_animation_context_free() function.
2805 * char buf[PATH_MAX];
2806 * Eina_List *images = NULL;
2807 * Elm_Transit *transi = elm_transit_add();
2809 * snprintf(buf, sizeof(buf), "%s/images/icon_11.png", PACKAGE_DATA_DIR);
2810 * images = eina_list_append(images, eina_stringshare_add(buf));
2812 * snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
2813 * images = eina_list_append(images, eina_stringshare_add(buf));
2814 * elm_transit_effect_image_animation_add(transi, images);
2818 * @see elm_transit_effect_add()
2820 * @param transit Transit object.
2821 * @param images Eina_List of images file paths. This list and
2822 * its contents will be deleted at the end of the effect by
2823 * elm_transit_effect_image_animation_context_free() function.
2824 * @return Image Animation effect context data.
2828 EAPI Elm_Transit_Effect *
2829 elm_transit_effect_image_animation_add(Elm_Transit *transit, Eina_List *images)
2831 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2832 Elm_Transit_Effect *effect = _transit_effect_image_animation_context_new(images);
2834 if (!effect) return NULL;
2835 elm_transit_effect_add(transit,
2836 _transit_effect_image_animation_op, effect,
2837 _transit_effect_image_animation_context_free);