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 _elm_transit_object_remove(Elm_Transit *transit, Evas_Object *obj)
168 Elm_Obj_Data *obj_data = eina_hash_find(transit->objs_data_hash, obj);
169 if (!obj_data) return;
170 eina_hash_del_by_key(transit->objs_data_hash, obj);
171 Elm_Obj_State *state = obj_data->state;
173 evas_object_pass_events_set(obj, obj_data->pass_events);
177 //recover the states of the object.
178 if (!transit->state_keep)
180 evas_object_move(obj, state->x, state->y);
181 evas_object_resize(obj, state->w, state->h);
182 evas_object_color_set(obj, state->r, state->g, state->b, state->a);
183 if (state->visible) evas_object_show(obj);
184 else evas_object_hide(obj);
185 if (state->map_enabled)
186 evas_object_map_enable_set(obj, EINA_TRUE);
188 evas_object_map_enable_set(obj, EINA_FALSE);
190 evas_object_map_set(obj, state->map);
197 //remove duplicated objects
198 //TODO: Need to consider about optimizing here
201 if (!eina_list_data_find_list(transit->objs, obj))
203 transit->objs = eina_list_remove(transit->objs, obj);
206 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_DEL,
207 _elm_transit_object_remove_cb,
212 _elm_transit_effect_del(Elm_Transit *transit, Elm_Transit_Effect_Module *effect_module)
214 if (effect_module->end_cb)
215 effect_module->end_cb(effect_module->effect, transit);
220 _remove_dead_effects(Elm_Transit *transit)
222 Elm_Transit_Effect_Module *effect_module;
224 EINA_INLIST_FOREACH(transit->effect_list, effect_module)
226 if (effect_module->deleted)
228 _elm_transit_effect_del(transit, effect_module);
229 transit->effects_pending_del--;
230 if (!transit->effects_pending_del) return;
236 _elm_transit_del(Elm_Transit *transit)
238 Elm_Transit_Effect_Module *effect_module;
239 Elm_Transit *chain_transit;
240 Eina_List *elist, *elist_next;
242 EINA_LIST_FOREACH_SAFE(transit->next_chain_transits, elist, elist_next, chain_transit)
244 if (transit->prev_chain_transit)
245 transit->prev_chain_transit->next_chain_transits = eina_list_remove(transit->prev_chain_transit->next_chain_transits, transit);
246 chain_transit->prev_chain_transit = NULL;
249 eina_list_free(transit->next_chain_transits);
251 if (transit->animator)
252 ecore_animator_del(transit->animator);
254 while (transit->effect_list)
256 effect_module = EINA_INLIST_CONTAINER_GET(transit->effect_list, Elm_Transit_Effect_Module);
257 transit->effect_list = eina_inlist_remove(transit->effect_list, transit->effect_list);
260 while (transit->objs)
261 _elm_transit_object_remove(transit, eina_list_data_get(transit->objs));
263 transit->deleted = EINA_TRUE;
265 if (transit->del_data.func)
266 transit->del_data.func(transit->del_data.arg, transit);
268 eina_hash_free(transit->objs_data_hash);
270 EINA_MAGIC_SET(transit, EINA_MAGIC_NONE);
275 _chain_transits_go(Elm_Transit *transit)
277 Eina_List *elist, *elist_next;
278 Elm_Transit *chain_transit;
280 EINA_LIST_FOREACH_SAFE(transit->next_chain_transits, elist, elist_next, chain_transit)
281 elm_transit_go(chain_transit);
285 _transit_animate_op(Elm_Transit *transit, double progress)
287 Elm_Transit_Effect_Module *effect_module;
290 EINA_INLIST_FOREACH(transit->effect_list, effect_module)
292 if (transit->deleted) break;
293 if (!effect_module->deleted)
294 effect_module->transition_cb(effect_module->effect, transit, progress);
298 if (transit->walking) return;
300 if (transit->deleted) _elm_transit_del(transit);
301 else if (transit->effects_pending_del) _remove_dead_effects(transit);
305 _animator_animate_cb(void *data)
307 Elm_Transit *transit = data;
308 double elapsed_time, duration;
310 transit->time.current = ecore_loop_time_get();
311 elapsed_time = transit->time.current - transit->time.begin;
312 duration = transit->time.duration + transit->time.delayed;
314 if (elapsed_time > duration)
315 elapsed_time = duration;
317 transit->progress = elapsed_time / duration;
318 switch (transit->tween_mode)
320 case ELM_TRANSIT_TWEEN_MODE_ACCELERATE:
321 transit->progress = 1.0 - sin((ELM_PI / 2.0) + (transit->progress * ELM_PI / 2.0));
323 case ELM_TRANSIT_TWEEN_MODE_DECELERATE:
324 transit->progress = sin(transit->progress * ELM_PI / 2.0);
326 case ELM_TRANSIT_TWEEN_MODE_SINUSOIDAL:
327 transit->progress = (1.0 - cos(transit->progress * ELM_PI)) / 2.0;
334 if (transit->repeat.reverse) transit->progress = 1 - transit->progress;
336 if (transit->time.duration > 0) _transit_animate_op(transit, transit->progress);
338 /* Not end. Keep going. */
339 if (elapsed_time < duration) return ECORE_CALLBACK_RENEW;
341 /* Repeat and reverse and time done! */
342 if ((transit->repeat.count >= 0) &&
343 (transit->repeat.current == transit->repeat.count) &&
344 ((!transit->auto_reverse) || transit->repeat.reverse))
346 /* run chain transit */
347 if (transit->next_chain_transits)
348 _chain_transits_go(transit);
350 elm_transit_del(transit);
351 return ECORE_CALLBACK_CANCEL;
355 if (!transit->auto_reverse || transit->repeat.reverse)
357 transit->repeat.current++;
358 transit->repeat.reverse = EINA_FALSE;
360 else transit->repeat.reverse = EINA_TRUE;
362 transit->time.begin = ecore_loop_time_get();
364 return ECORE_CALLBACK_RENEW;
370 * @note Is not necessary to delete the transit object, it will be deleted at
371 * the end of its operation.
372 * @note The transit will start playing when the program enter in the main loop, is not
373 * necessary to give a start to the transit.
375 * @param duration The duration of the transit in seconds. When transit starts
376 * to run, it will last a @p duration time.
377 * @return The transit object.
382 elm_transit_add(void)
384 Elm_Transit *transit = ELM_NEW(Elm_Transit);
385 if (!transit) return NULL;
387 EINA_MAGIC_SET(transit, ELM_TRANSIT_MAGIC);
389 elm_transit_tween_mode_set(transit, ELM_TRANSIT_TWEEN_MODE_LINEAR);
391 transit->objs_data_hash = eina_hash_pointer_new(NULL);
396 * Stops the animation and delete the @p transit object.
398 * Call this function if you wants to stop the animation before the duration
399 * time. Make sure the @p transit object is still alive with
400 * elm_transit_del_cb_set() function.
401 * All added effects will be deleted, calling its repective data_free_cb
402 * functions. The function setted by elm_transit_del_cb_set() will be called.
404 * @see elm_transit_del_cb_set()
406 * @param transit The transit object to be deleted.
409 * @warning Just call this function if you are sure the transit is alive.
412 elm_transit_del(Elm_Transit *transit)
414 ELM_TRANSIT_CHECK_OR_RETURN(transit);
416 if (transit->walking) transit->deleted = EINA_TRUE;
417 else _elm_transit_del(transit);
421 * Add a new effect to the transit.
423 * @note The cb function and the data are the key to the effect. If you try to
424 * add an already added effect, nothing is done.
425 * @note After the first addition of an effect in @p transit, if its
426 * effect list become empty again, the @p transit will be killed by
427 * elm_transit_del(transit) function.
431 * Elm_Transit *transit = elm_transit_add();
432 * elm_transit_effect_add(transit,
433 * elm_transit_effect_blend_op,
434 * elm_transit_effect_blend_context_new(),
435 * elm_transit_effect_blend_context_free);
438 * @param transit The transit object.
439 * @param cb The operation function. It is called when the animation begins,
440 * it is the function that actually performs the animation. It is called with
441 * the @p data, @p transit and the time progression of the animation (a double
442 * value between 0.0 and 1.0).
443 * @param data The context data of the effect.
444 * @param data_free_cb The function to free the context data, it will be called
445 * at the end of the effect, it must finalize the animation and free the
449 * @warning The transit free the context data at the and of the transition with
450 * the data_free_cb function, do not use the context data in another transit.
453 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)
455 ELM_TRANSIT_CHECK_OR_RETURN(transit);
456 EINA_SAFETY_ON_NULL_RETURN(transition_cb);
457 Elm_Transit_Effect_Module *effect_module;
459 EINA_INLIST_FOREACH(transit->effect_list, effect_module)
460 if ((effect_module->transition_cb == transition_cb) && (effect_module->effect == effect)) return;
462 effect_module = ELM_NEW(Elm_Transit_Effect_Module);
463 if (!effect_module) return;
465 effect_module->end_cb = end_cb;
466 effect_module->transition_cb = transition_cb;
467 effect_module->effect = effect;
469 transit->effect_list = eina_inlist_append(transit->effect_list, (Eina_Inlist*) effect_module);
473 * Delete an added effect.
475 * This function will remove the effect from the @p transit, calling the
476 * data_free_cb to free the @p data.
478 * @see elm_transit_effect_add()
480 * @note If the effect is not found, nothing is done.
481 * @note If the effect list become empty, this function will call
482 * elm_transit_del(transit), that is, it will kill the @p transit.
484 * @param transit The transit object.
485 * @param cb The operation function.
486 * @param data The context data of the effect.
491 elm_transit_effect_del(Elm_Transit *transit, Elm_Transit_Effect_Transition_Cb transition_cb, Elm_Transit_Effect *effect)
493 ELM_TRANSIT_CHECK_OR_RETURN(transit);
494 EINA_SAFETY_ON_NULL_RETURN(transition_cb);
495 Elm_Transit_Effect_Module *effect_module;
497 EINA_INLIST_FOREACH(transit->effect_list, effect_module)
499 if ((effect_module->transition_cb == transition_cb) && (effect_module->effect == effect))
501 if (transit->walking)
503 effect_module->deleted = EINA_TRUE;
504 transit->effects_pending_del++;
508 _elm_transit_effect_del(transit, effect_module);
509 if (!transit->effect_list) elm_transit_del(transit);
517 * Add new object to apply the effects.
519 * @note After the first addition of an object in @p transit, if its
520 * object list become empty again, the @p transit will be killed by
521 * elm_transit_del(transit) function.
522 * @note If the @p obj belongs to another transit, the @p obj will be
523 * removed from it and it will only belong to the @p transit. If the old
524 * transit stays without objects, it will die.
525 * @note When you add an object into the @p transit, its state from
526 * evas_object_pass_events_get(obj) is saved, and it is applied when the
527 * transit ends, if you change this state whith evas_object_pass_events_set()
528 * after add the object, this state will change again when @p transit stops to
531 * @param transit The transit object.
532 * @param obj Object to be animated.
535 * @warning It is not allowed to add a new object after transit begins to go.
538 elm_transit_object_add(Elm_Transit *transit, Evas_Object *obj)
540 ELM_TRANSIT_CHECK_OR_RETURN(transit);
541 EINA_SAFETY_ON_NULL_RETURN(obj);
542 Elm_Obj_Data *obj_data;
544 obj_data = ELM_NEW(Elm_Obj_Data);
545 obj_data->pass_events = evas_object_pass_events_get(obj);
546 if (!transit->event_enabled)
547 evas_object_pass_events_set(obj, EINA_TRUE);
549 evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
550 _elm_transit_object_remove_cb,
553 transit->objs = eina_list_append(transit->objs, obj);
554 eina_hash_add(transit->objs_data_hash, obj, obj_data);
556 if (!transit->state_keep)
557 _elm_transit_obj_states_save(obj, obj_data);
561 * Removes an added object from the transit.
563 * @note If the @p obj is not in the @p transit, nothing is done.
564 * @note If the list become empty, this function will call
565 * elm_transit_del(transit), that is, it will kill the @p transit.
567 * @param transit The transit object.
568 * @param obj Object to be removed from @p transit.
571 * @warning It is not allowed to remove objects after transit begins to go.
574 elm_transit_object_remove(Elm_Transit *transit, Evas_Object *obj)
576 ELM_TRANSIT_CHECK_OR_RETURN(transit);
577 EINA_SAFETY_ON_NULL_RETURN(obj);
578 Elm_Obj_Data *obj_data;
580 obj_data = eina_hash_find(transit->objs_data_hash, obj);
581 if (!obj_data) return;
583 _elm_transit_object_remove(transit, obj);
584 if (!transit->objs) elm_transit_del(transit);
588 * Get the objects of the transit.
590 * @param transit The transit object.
591 * @return a Eina_List with the objects from the transit.
595 EAPI const Eina_List *
596 elm_transit_objects_get(const Elm_Transit *transit)
598 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
599 return transit->objs;
603 * Set the event enabled when transit is operating.
605 * If @p enabled is EINA_TRUE, the objects of the transit will receives
606 * events from mouse and keyboard during the animation.
607 * @note When you add an object with elm_transit_object_add(), its state from
608 * evas_object_pass_events_get(obj) is saved, and it is applied when the
609 * transit ends, if you change this state with evas_object_pass_events_set()
610 * after adding the object, this state will change again when @p transit stops
613 * @param transit The transit object.
614 * @param enabled Disable or enable.
619 elm_transit_event_enabled_set(Elm_Transit *transit, Eina_Bool enabled)
621 ELM_TRANSIT_CHECK_OR_RETURN(transit);
623 if (transit->event_enabled == enabled) return;
624 transit->event_enabled = !!enabled;
625 eina_hash_foreach(transit->objs_data_hash, _hash_foreach_pass_events_set, transit);
629 * Get the value of event enabled status.
631 * @see elm_transit_event_enabled_set()
633 * @param transit The Transit object
634 * @return EINA_TRUE, when event is enabled. If @p transit is NULL
635 * EINA_FALSE is returned
640 elm_transit_event_enabled_get(const Elm_Transit *transit)
642 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
643 return transit->event_enabled;
648 * Set the event enabled when transit is operating.
650 * If @p disabled 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 add the object, this state will change again when @p transit stops to
658 * @see elm_transit_event_enabled_set()
660 * @param transit The transit object.
661 * @param disabled Disable or enable.
665 EINA_DEPRECATED EAPI void
666 elm_transit_event_block_set(Elm_Transit *transit, Eina_Bool disabled)
668 elm_transit_event_enabled_set(transit, disabled);
673 * Get the value of event block enabled status.
675 * @see elm_transit_event_enabled_set(), elm_transit_event_enabled_get()
677 * @param transit The Transit object
678 * @return EINA_TRUE, when event is enabled. If @p transit is NULL
679 * EINA_FALSE is returned
683 EINA_DEPRECATED EAPI Eina_Bool
684 elm_transit_event_block_get(const Elm_Transit *transit)
686 return !elm_transit_event_enabled_get(transit);
690 * Set the user-callback function when the transit is deleted.
692 * @note Using this function twice will overwrite the first function setted.
693 * @note the @p transit object will be deleted after call @p cb function.
695 * @param transit The transit object.
696 * @param cb Callback function pointer. This function will be called before
697 * the deletion of the transit.
698 * @param data Callback funtion user data. It is the @p op parameter.
703 elm_transit_del_cb_set(Elm_Transit *transit, void (*cb) (void *data, Elm_Transit *transit), void *data)
705 ELM_TRANSIT_CHECK_OR_RETURN(transit);
706 transit->del_data.func = cb;
707 transit->del_data.arg = data;
711 * Set reverse effect automatically.
713 * If auto reverse is setted, after running the effects with the progress
714 * parameter from 0 to 1, it will call the effecs again with the progress
715 * from 1 to 0. The transit will last for a time iqual to (2 * duration * repeat),
716 * where the duration was setted with the function elm_transit_add and
717 * the repeat with the function elm_transit_repeat_times_set().
719 * @param transit The transit object.
720 * @param reverse EINA_TRUE means the auto_reverse is on.
725 elm_transit_auto_reverse_set(Elm_Transit *transit, Eina_Bool reverse)
727 ELM_TRANSIT_CHECK_OR_RETURN(transit);
728 transit->auto_reverse = reverse;
732 * Get if the auto reverse is on.
734 * @see elm_transit_auto_reverse_set()
736 * @param transit The transit object.
737 * @return EINA_TRUE means auto reverse is on. If @p transit is NULL
738 * EINA_FALSE is returned
743 elm_transit_auto_reverse_get(const Elm_Transit *transit)
745 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
746 return transit->auto_reverse;
750 * Set the transit repeat count. Effect will be repeated by repeat count.
752 * This function sets the number of repetition the transit will run after
753 * the first one, that is, if @p repeat is 1, the transit will run 2 times.
754 * If the @p repeat is a negative number, it will repeat infinite times.
756 * @note If this function is called during the transit execution, the transit
757 * will run @p repeat times, ignoring the times it already performed.
759 * @param transit The transit object
760 * @param repeat Repeat count
765 elm_transit_repeat_times_set(Elm_Transit *transit, int repeat)
767 ELM_TRANSIT_CHECK_OR_RETURN(transit);
768 transit->repeat.count = repeat;
769 transit->repeat.current = 0;
773 * Get the transit repeat count.
775 * @see elm_transit_repeat_times_set()
777 * @param transit The Transit object.
778 * @return The repeat count. If @p transit is NULL
784 elm_transit_repeat_times_get(const Elm_Transit *transit)
786 ELM_TRANSIT_CHECK_OR_RETURN(transit, 0);
787 return transit->repeat.count;
791 * Set the transit animation acceleration type.
793 * This function sets the tween mode of the transit that can be:
794 * ELM_TRANSIT_TWEEN_MODE_LINEAR - The default mode.
795 * ELM_TRANSIT_TWEEN_MODE_SINUSOIDAL - Starts in accelerate mode and ends decelerating.
796 * ELM_TRANSIT_TWEEN_MODE_DECELERATE - The animation will be slowed over time.
797 * ELM_TRANSIT_TWEEN_MODE_ACCELERATE - The animation will accelerate over time.
799 * @param transit The transit object.
800 * @param tween_mode The tween type.
805 elm_transit_tween_mode_set(Elm_Transit *transit, Elm_Transit_Tween_Mode tween_mode)
807 ELM_TRANSIT_CHECK_OR_RETURN(transit);
808 transit->tween_mode = tween_mode;
812 * Get the transit animation acceleration type.
814 * @note @p transit can not be NULL
816 * @param transit The transit object.
817 * @return The tween type. If @p transit is NULL
818 * ELM_TRANSIT_TWEEN_MODE_LINEAR is returned.
822 EAPI Elm_Transit_Tween_Mode
823 elm_transit_tween_mode_get(const Elm_Transit *transit)
825 ELM_TRANSIT_CHECK_OR_RETURN(transit, ELM_TRANSIT_TWEEN_MODE_LINEAR);
826 return transit->tween_mode;
830 * Set the transit animation time
832 * @note @p transit can not be NULL
834 * @param transit The transit object.
835 * @param duration The animation time.
840 elm_transit_duration_set(Elm_Transit *transit, double duration)
842 ELM_TRANSIT_CHECK_OR_RETURN(transit);
843 if (transit->animator) return;
844 transit->time.duration = duration;
848 * Get the transit animation time
850 * @note @p transit can not be NULL
852 * @param transit The transit object.
854 * @return The transit animation time.
859 elm_transit_duration_get(const Elm_Transit *transit)
861 ELM_TRANSIT_CHECK_OR_RETURN(transit, 0.0);
862 return transit->time.duration;
866 * Starts the transition.
867 * Once this API is called, the transit begins to measure the time.
869 * @note @p transit can not be NULL
871 * @param transit The transit object.
876 elm_transit_go(Elm_Transit *transit)
878 ELM_TRANSIT_CHECK_OR_RETURN(transit);
880 if (transit->animator)
881 ecore_animator_del(transit->animator);
883 transit->time.paused = 0;
884 transit->time.delayed = 0;
885 transit->time.begin = ecore_loop_time_get();
886 transit->animator = ecore_animator_add(_animator_animate_cb, transit);
890 * Pause/Resume the transition.
891 * If you call elm_transit_go again, paused states will affect no anymore.
893 * @note @p transit can not be NULL
895 * @param transit The transit object.
900 elm_transit_paused_set(Elm_Transit *transit, Eina_Bool paused)
902 ELM_TRANSIT_CHECK_OR_RETURN(transit);
904 if (!transit->animator) return;
908 if (transit->time.paused > 0)
910 ecore_animator_freeze(transit->animator);
911 transit->time.paused = ecore_loop_time_get();
915 if (transit->time.paused == 0)
917 ecore_animator_thaw(transit->animator);
918 transit->time.delayed += (ecore_loop_time_get() - transit->time.paused);
919 transit->time.paused = 0;
924 * Get the value of paused status.
926 * @see elm_transit_paused_set()
928 * @note @p transit can not be NULL
930 * @param transit The transit object.
931 * @return EINA_TRUE means transition is paused. If @p transit is NULL
932 * EINA_FALSE is returned
937 elm_transit_paused_get(const Elm_Transit *transit)
939 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
941 if (transit->time.paused == 0)
948 * Get the time progression of the animation (a double value between 0.0 and 1.0).
950 * @note @p transit can not be NULL
952 * @param transit The transit object.
954 * @return The time progression value. If @p transit is NULL
960 elm_transit_progress_value_get(const Elm_Transit *transit)
962 ELM_TRANSIT_CHECK_OR_RETURN(transit, 0);
963 return transit->progress;
969 * Enable/disable keeping up the objects states.
970 * If it is not kept, the objects states will be reset when transition ends.
972 * @note @p transit can not be NULL.
973 * @note One state includes geometry, color, map data.
975 * @param transit The transit object.
976 * @param state_keep Keeping or Non Keeping.
981 elm_transit_objects_final_state_keep_set(Elm_Transit *transit, Eina_Bool state_keep)
983 ELM_TRANSIT_CHECK_OR_RETURN(transit);
984 if (transit->state_keep == state_keep) return;
985 if (transit->animator) return;
986 transit->state_keep = !!state_keep;
987 if (state_keep) return;
988 eina_hash_foreach(transit->objs_data_hash, _hash_foreach_obj_states_save, NULL);
992 * Get a value whether the objects states will be reset or not.
994 * @note @p transit can not be NULL
996 * @see elm_transit_objects_final_state_keep_set()
998 * @param transit The transit object.
999 * @return EINA_TRUE means the states of the objects will be reset.
1000 * If @p transit is NULL, EINA_FALSE is returned
1005 elm_transit_objects_final_state_keep_get(const Elm_Transit *transit)
1007 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
1008 return transit->state_keep;
1012 * Makes the chain relationship between two transits.
1014 * @note @p transit can not be NULL. Transit would have multiple chain transits.
1015 * @note @p chain_transit can not be NULL. Chain transits could be chained to the only one transit.
1017 * @param transit The transit object.
1018 * @param chain_transit The chain transit object. This transit will be operated * after transit is done.
1023 elm_transit_chain_transit_add(Elm_Transit *transit, Elm_Transit *chain_transit)
1025 ELM_TRANSIT_CHECK_OR_RETURN(transit);
1026 ELM_TRANSIT_CHECK_OR_RETURN(chain_transit);
1028 if (transit == chain_transit) return;
1029 if (transit == chain_transit->prev_chain_transit) return;
1031 if (chain_transit->prev_chain_transit)
1032 chain_transit->prev_chain_transit->next_chain_transits = eina_list_remove(chain_transit->prev_chain_transit->next_chain_transits, chain_transit);
1034 chain_transit->prev_chain_transit = transit;
1035 transit->next_chain_transits = eina_list_append(transit->next_chain_transits, chain_transit);
1039 * Get the current chain transit list.
1041 * @note @p transit can not be NULL.
1043 * @param transit The transit object.
1044 * @return chain transit list.
1049 elm_transit_chain_transits_get(const Elm_Transit * transit)
1051 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1052 return transit->next_chain_transits;
1055 ///////////////////////////////////////////////////////////////////////////////
1057 ///////////////////////////////////////////////////////////////////////////////
1058 typedef struct _Elm_Transit_Effect_Resizing Elm_Transit_Effect_Resizing;
1060 struct _Elm_Transit_Effect_Resizing
1068 _transit_effect_resizing_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
1070 Elm_Transit_Effect_Resizing *resizing = effect;
1075 _transit_effect_resizing_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
1077 EINA_SAFETY_ON_NULL_RETURN(effect);
1078 EINA_SAFETY_ON_NULL_RETURN(transit);
1082 Elm_Transit_Effect_Resizing *resizing = effect;
1084 w = resizing->from.w + (resizing->to.w * progress);
1085 h = resizing->from.h + (resizing->to.h * progress);
1087 EINA_LIST_FOREACH(transit->objs, elist, obj)
1088 evas_object_resize(obj, w, h);
1091 static Elm_Transit_Effect *
1092 _transit_effect_resizing_context_new(Evas_Coord from_w, Evas_Coord from_h, Evas_Coord to_w, Evas_Coord to_h)
1094 Elm_Transit_Effect_Resizing *resizing;
1096 resizing = ELM_NEW(Elm_Transit_Effect_Resizing);
1097 if (!resizing) return NULL;
1099 resizing->from.w = from_w;
1100 resizing->from.h = from_h;
1101 resizing->to.w = to_w - from_w;
1102 resizing->to.h = to_h - from_h;
1108 * Add the Resizing Effect to Elm_Transit.
1110 * @note This API is one of the facades. It creates resizing effect context
1111 * and add it's required APIs to elm_transit_effect_add.
1113 * @see elm_transit_effect_add()
1115 * @param transit Transit object.
1116 * @param from_w Object width size when effect begins.
1117 * @param from_h Object height size when effect begins.
1118 * @param to_w Object width size when effect ends.
1119 * @param to_h Object height size when effect ends.
1120 * @return Resizing effect context data.
1124 EAPI Elm_Transit_Effect *
1125 elm_transit_effect_resizing_add(Elm_Transit *transit, Evas_Coord from_w, Evas_Coord from_h, Evas_Coord to_w, Evas_Coord to_h)
1127 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1128 Elm_Transit_Effect *effect = _transit_effect_resizing_context_new(from_w, from_h, to_w, to_h);
1130 if (!effect) return NULL;
1131 elm_transit_effect_add(transit,
1132 _transit_effect_resizing_op, effect,
1133 _transit_effect_resizing_context_free);
1137 ///////////////////////////////////////////////////////////////////////////////
1138 //Translation Effect
1139 ///////////////////////////////////////////////////////////////////////////////
1140 typedef struct _Elm_Transit_Effect_Translation Elm_Transit_Effect_Translation;
1141 typedef struct _Elm_Transit_Effect_Translation_Node Elm_Transit_Effect_Translation_Node;
1143 struct _Elm_Transit_Effect_Translation_Node
1149 struct _Elm_Transit_Effect_Translation
1151 struct _position_variation {
1158 _translation_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1160 Elm_Transit_Effect_Translation *translation = data;
1162 Elm_Transit_Effect_Translation_Node *translation_node;
1164 EINA_LIST_FOREACH(translation->nodes, elist, translation_node)
1166 if (translation_node->obj != obj) continue;
1167 translation->nodes = eina_list_remove_list(translation->nodes, elist);
1168 free(translation_node);
1174 _translation_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Translation *translation)
1176 Elm_Transit_Effect_Translation_Node *translation_node;
1177 const Eina_List *elist;
1179 Eina_List *data_list = NULL;
1180 const Eina_List *objs = elm_transit_objects_get(transit);
1182 EINA_LIST_FOREACH(objs, elist, obj)
1184 translation_node = ELM_NEW(Elm_Transit_Effect_Translation_Node);
1185 if (!translation_node)
1187 eina_list_free(data_list);
1190 translation_node->obj = obj;
1191 evas_object_geometry_get(obj, &(translation_node->x),
1192 &(translation_node->y), NULL, NULL);
1193 data_list = eina_list_append(data_list, translation_node);
1194 evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
1195 _translation_object_del_cb, translation);
1201 _transit_effect_translation_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
1203 EINA_SAFETY_ON_NULL_RETURN(effect);
1204 Elm_Transit_Effect_Translation *translation = effect;
1205 Eina_List *elist, *elist_next;
1206 Elm_Transit_Effect_Translation_Node *translation_node;
1208 EINA_LIST_FOREACH_SAFE(translation->nodes,
1209 elist, elist_next, translation_node)
1211 evas_object_event_callback_del(translation_node->obj,
1212 EVAS_CALLBACK_DEL, _translation_object_del_cb);
1213 translation->nodes = eina_list_remove_list(translation->nodes, elist);
1214 free(translation_node);
1220 _transit_effect_translation_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress __UNUSED__)
1222 EINA_SAFETY_ON_NULL_RETURN(effect);
1223 EINA_SAFETY_ON_NULL_RETURN(transit);
1225 Elm_Transit_Effect_Translation *translation = effect;
1226 Elm_Transit_Effect_Translation_Node *translation_node;
1229 if (!translation->nodes)
1230 translation->nodes = _translation_nodes_build(transit, translation);
1232 EINA_LIST_FOREACH(translation->nodes, elist, translation_node)
1234 x = translation_node->x + translation->from.dx
1235 + (translation->to.dx * progress);
1236 y = translation_node->y + translation->from.dy
1237 + (translation->to.dy * progress);
1238 evas_object_move(translation_node->obj, x, y);
1242 static Elm_Transit_Effect *
1243 _transit_effect_translation_context_new(Evas_Coord from_dx, Evas_Coord from_dy, Evas_Coord to_dx, Evas_Coord to_dy)
1245 Elm_Transit_Effect_Translation *translation;
1247 translation = ELM_NEW(Elm_Transit_Effect_Translation);
1248 if (!translation) return NULL;
1250 translation->from.dx = from_dx;
1251 translation->from.dy = from_dy;
1252 translation->to.dx = to_dx - from_dx;
1253 translation->to.dy = to_dy - from_dy;
1259 * Add the Translation Effect to Elm_Transit.
1261 * @note This API is one of the facades. It creates translation effect context
1262 * and add it's required APIs to elm_transit_effect_add.
1264 * @see elm_transit_effect_add()
1266 * @param transit Transit object.
1267 * @param from_dx X Position variation when effect begins.
1268 * @param from_dy Y Position variation when effect begins.
1269 * @param to_dx X Position variation when effect ends.
1270 * @param to_dy Y Position variation when effect ends.
1271 * @return Translation effect context data.
1274 * @warning Is higher recommended just create a transit with this effect when
1275 * the window that the objects of the transit belongs has already been created.
1276 * This is because this effect needs the geometry information about the objects,
1277 * and if the window was not created yet, it can get a wrong information.
1279 EAPI Elm_Transit_Effect *
1280 elm_transit_effect_translation_add(Elm_Transit *transit, Evas_Coord from_dx, Evas_Coord from_dy, Evas_Coord to_dx, Evas_Coord to_dy)
1282 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1283 Elm_Transit_Effect *effect_context = _transit_effect_translation_context_new(from_dx, from_dy, to_dx, to_dy);
1285 if (!effect_context) return NULL;
1286 elm_transit_effect_add(transit,
1287 _transit_effect_translation_op, effect_context,
1288 _transit_effect_translation_context_free);
1289 return effect_context;
1293 ///////////////////////////////////////////////////////////////////////////////
1295 ///////////////////////////////////////////////////////////////////////////////
1296 typedef struct _Elm_Transit_Effect_Zoom Elm_Transit_Effect_Zoom;
1298 struct _Elm_Transit_Effect_Zoom
1304 _transit_effect_zoom_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
1306 Elm_Transit_Effect_Zoom *zoom = effect;
1311 _transit_effect_zoom_op(Elm_Transit_Effect *effect, Elm_Transit *transit , double progress)
1313 EINA_SAFETY_ON_NULL_RETURN(effect);
1314 EINA_SAFETY_ON_NULL_RETURN(transit);
1317 Elm_Transit_Effect_Zoom *zoom = effect;
1319 Evas_Coord x, y, w, h;
1321 map = evas_map_new(4);
1324 EINA_LIST_FOREACH(transit->objs, elist, obj)
1326 evas_object_geometry_get(obj, &x, &y, &w, &h);
1327 evas_map_util_points_populate_from_object_full(map, obj, zoom->from +
1328 (progress * zoom->to));
1329 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, _TRANSIT_FOCAL);
1330 evas_object_map_set(obj, map);
1331 evas_object_map_enable_set(obj, EINA_TRUE);
1336 static Elm_Transit_Effect *
1337 _transit_effect_zoom_context_new(float from_rate, float to_rate)
1339 Elm_Transit_Effect_Zoom *zoom;
1341 zoom = ELM_NEW(Elm_Transit_Effect_Zoom);
1342 if (!zoom) return NULL;
1344 zoom->from = (_TRANSIT_FOCAL - (from_rate * _TRANSIT_FOCAL)) * (1 / from_rate);
1345 zoom->to = ((_TRANSIT_FOCAL - (to_rate * _TRANSIT_FOCAL)) * (1 / to_rate)) - zoom->from;
1351 * Add the Zoom Effect to Elm_Transit.
1353 * @note This API is one of the facades. It creates zoom effect context
1354 * and add it's required APIs to elm_transit_effect_add.
1356 * @see elm_transit_effect_add()
1358 * @param transit Transit object.
1359 * @param from_rate Scale rate when effect begins (1 is current rate).
1360 * @param to_rate Scale rate when effect ends.
1361 * @return Zoom effect context data.
1364 * @warning Is higher recommended just create a transit with this effect when
1365 * the window that the objects of the transit belongs has already been created.
1366 * This is because this effect needs the geometry information about the objects,
1367 * and if the window was not created yet, it can get a wrong information.
1369 EAPI Elm_Transit_Effect *
1370 elm_transit_effect_zoom_add(Elm_Transit *transit, float from_rate, float to_rate)
1372 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1373 Elm_Transit_Effect *effect_context = _transit_effect_zoom_context_new(from_rate, to_rate);
1375 if (!effect_context) return NULL;
1376 elm_transit_effect_add(transit,
1377 _transit_effect_zoom_op, effect_context,
1378 _transit_effect_zoom_context_free);
1379 return effect_context;
1383 ///////////////////////////////////////////////////////////////////////////////
1385 ///////////////////////////////////////////////////////////////////////////////
1386 typedef struct _Elm_Transit_Effect_Flip Elm_Transit_Effect_Flip;
1388 struct _Elm_Transit_Effect_Flip
1390 Elm_Transit_Effect_Flip_Axis axis;
1395 _transit_effect_flip_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit)
1397 EINA_SAFETY_ON_NULL_RETURN(effect);
1398 EINA_SAFETY_ON_NULL_RETURN(transit);
1399 Elm_Transit_Effect_Flip *flip = effect;
1400 Evas_Object *front, *back;
1402 int count = eina_list_count(transit->objs);
1404 for (i = 0; i < (count - 1); i += 2)
1406 front = eina_list_nth(transit->objs, i);
1407 back = eina_list_nth(transit->objs, i+1);
1408 evas_object_map_enable_set(front, EINA_FALSE);
1409 evas_object_map_enable_set(back, EINA_FALSE);
1415 _transit_effect_flip_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
1417 EINA_SAFETY_ON_NULL_RETURN(effect);
1418 EINA_SAFETY_ON_NULL_RETURN(transit);
1419 Evas_Object *obj, *front, *back;
1421 Elm_Transit_Effect_Flip *flip = effect;
1424 Evas_Coord x, y, w, h;
1426 map = evas_map_new(4);
1429 if (flip->cw) degree = (float)(progress * 180);
1430 else degree = (float)(progress * -180);
1432 count = eina_list_count(transit->objs);
1434 for (i = 0; i < (count - 1); i += 2)
1436 Evas_Coord half_w, half_h;
1438 front = eina_list_nth(transit->objs, i);
1439 back = eina_list_nth(transit->objs, i+1);
1441 if ((degree < 90) && (degree > -90))
1446 evas_object_hide(back);
1447 evas_object_show(front);
1455 evas_object_hide(front);
1456 evas_object_show(back);
1460 evas_map_util_points_populate_from_object_full(map, obj, 0);
1461 evas_object_geometry_get(obj, &x, &y, &w, &h);
1465 if (flip->axis == ELM_TRANSIT_EFFECT_FLIP_AXIS_Y)
1467 if ((degree >= 90) || (degree <= -90))
1469 evas_map_point_image_uv_set(map, 0, w, 0);
1470 evas_map_point_image_uv_set(map, 1, 0, 0);
1471 evas_map_point_image_uv_set(map, 2, 0, h);
1472 evas_map_point_image_uv_set(map, 3, w, h);
1474 evas_map_util_3d_rotate(map, 0, degree,
1475 0, x + half_w, y + half_h, 0);
1479 if ((degree >= 90) || (degree <= -90))
1481 evas_map_point_image_uv_set(map, 0, 0, h);
1482 evas_map_point_image_uv_set(map, 1, w, h);
1483 evas_map_point_image_uv_set(map, 2, w, 0);
1484 evas_map_point_image_uv_set(map, 3, 0, 0);
1486 evas_map_util_3d_rotate(map, degree,
1487 0, 0, x + half_w, y + half_h, 0);
1489 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, _TRANSIT_FOCAL);
1490 evas_object_map_enable_set(front, EINA_TRUE);
1491 evas_object_map_enable_set(back, EINA_TRUE);
1492 evas_object_map_set(obj, map);
1497 static Elm_Transit_Effect *
1498 _transit_effect_flip_context_new(Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1500 Elm_Transit_Effect_Flip *flip;
1502 flip = ELM_NEW(Elm_Transit_Effect_Flip);
1503 if (!flip) return NULL;
1512 * Add the Flip Effect to Elm_Transit.
1514 * @note This API is one of the facades. It creates flip effect context
1515 * and add it's required APIs to elm_transit_effect_add.
1516 * @note This effect is applied to each pair of objects in the order they are listed
1517 * in the transit list of objects. The first object in the pair will be the
1518 * "front" object and the second will be the "back" object.
1520 * @see elm_transit_effect_add()
1522 * @param transit Transit object.
1523 * @param axis Flipping Axis(X or Y).
1524 * @param cw Flipping Direction. EINA_TRUE is clock-wise.
1525 * @return Flip effect context data.
1528 * @warning Is higher recommended just create a transit with this effect when
1529 * the window that the objects of the transit belongs has already been created.
1530 * This is because this effect needs the geometry information about the objects,
1531 * and if the window was not created yet, it can get a wrong information.
1533 EAPI Elm_Transit_Effect *
1534 elm_transit_effect_flip_add(Elm_Transit *transit, Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1536 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1537 Elm_Transit_Effect *effect_context = _transit_effect_flip_context_new(axis, cw);
1539 if (!effect_context) return NULL;
1540 elm_transit_effect_add(transit,
1541 _transit_effect_flip_op, effect_context,
1542 _transit_effect_flip_context_free);
1543 return effect_context;
1546 ///////////////////////////////////////////////////////////////////////////////
1547 //ResizableFlip Effect
1548 ///////////////////////////////////////////////////////////////////////////////
1549 typedef struct _Elm_Transit_Effect_Resizable_Flip Elm_Transit_Effect_ResizableFlip;
1550 typedef struct _Elm_Transit_Effect_Resizable_Flip_Node Elm_Transit_Effect_ResizableFlip_Node;
1552 struct _Elm_Transit_Effect_Resizable_Flip_Node
1558 } from_pos, from_size, to_pos, to_size;
1561 struct _Elm_Transit_Effect_Resizable_Flip
1565 Elm_Transit_Effect_Flip_Axis axis;
1569 _resizable_flip_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1571 Elm_Transit_Effect_ResizableFlip *resizable_flip = data;
1573 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1575 EINA_LIST_FOREACH(resizable_flip->nodes, elist, resizable_flip_node)
1577 if (resizable_flip_node->front == obj)
1578 evas_object_event_callback_del(resizable_flip_node->back,
1579 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1580 else if (resizable_flip_node->back == obj)
1581 evas_object_event_callback_del(resizable_flip_node->front,
1582 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1585 resizable_flip->nodes = eina_list_remove_list(resizable_flip->nodes,
1587 free(resizable_flip_node);
1593 _resizable_flip_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_ResizableFlip *resizable_flip)
1595 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1596 Eina_List *data_list = NULL;
1597 Evas_Coord front_x, front_y, front_w, front_h;
1598 Evas_Coord back_x, back_y, back_w, back_h;
1601 count = eina_list_count(transit->objs);
1602 for (i = 0; i < (count - 1); i += 2)
1604 resizable_flip_node = ELM_NEW(Elm_Transit_Effect_ResizableFlip_Node);
1605 if (!resizable_flip_node)
1607 eina_list_free(data_list);
1611 resizable_flip_node->front = eina_list_nth(transit->objs, i);
1612 resizable_flip_node->back = eina_list_nth(transit->objs, i+1);
1614 evas_object_geometry_get(resizable_flip_node->front,
1615 &front_x, &front_y, &front_w, &front_h);
1616 evas_object_geometry_get(resizable_flip_node->back,
1617 &back_x, &back_y, &back_w, &back_h);
1619 resizable_flip_node->from_pos.x = front_x;
1620 resizable_flip_node->from_pos.y = front_y;
1621 resizable_flip_node->to_pos.x = back_x - front_x;
1622 resizable_flip_node->to_pos.y = back_y - front_y;
1624 resizable_flip_node->from_size.x = front_w;
1625 resizable_flip_node->from_size.y = front_h;
1626 resizable_flip_node->to_size.x = back_w - front_w;
1627 resizable_flip_node->to_size.y = back_h - front_h;
1629 data_list = eina_list_append(data_list, resizable_flip_node);
1631 evas_object_event_callback_add(resizable_flip_node->back,
1632 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb, resizable_flip);
1633 evas_object_event_callback_add(resizable_flip_node->front,
1634 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb, resizable_flip);
1641 _set_image_uv_by_axis_y(Evas_Map *map, Elm_Transit_Effect_ResizableFlip_Node *flip, float degree)
1643 if ((degree >= 90) || (degree <= -90))
1645 evas_map_point_image_uv_set(map, 0,
1646 (flip->from_size.x * 2) + flip->to_size.x,
1648 evas_map_point_image_uv_set(map, 1, 0, 0);
1649 evas_map_point_image_uv_set(map, 2, 0,
1650 (flip->from_size.y * 2) + flip->to_size.y);
1651 evas_map_point_image_uv_set(map, 3,
1652 (flip->from_size.x * 2) + flip->to_size.x,
1653 (flip->from_size.y * 2) + flip->to_size.y);
1657 evas_map_point_image_uv_set(map, 0, 0, 0);
1658 evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
1659 evas_map_point_image_uv_set(map, 2, flip->from_size.x,
1661 evas_map_point_image_uv_set(map, 3, 0, flip->from_size.y);
1666 _set_image_uv_by_axis_x(Evas_Map *map, Elm_Transit_Effect_ResizableFlip_Node *flip, float degree)
1668 if ((degree >= 90) || (degree <= -90))
1670 evas_map_point_image_uv_set(map, 0, 0,
1671 (flip->from_size.y * 2) + flip->to_size.y);
1672 evas_map_point_image_uv_set(map, 1,
1673 (flip->from_size.x * 2) + flip->to_size.x,
1674 (flip->from_size.y * 2) + flip->to_size.y);
1675 evas_map_point_image_uv_set(map, 2,
1676 (flip->from_size.x * 2) + flip->to_size.x,
1678 evas_map_point_image_uv_set(map, 3, 0, 0);
1682 evas_map_point_image_uv_set(map, 0, 0, 0);
1683 evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
1684 evas_map_point_image_uv_set(map, 2, flip->from_size.x,
1686 evas_map_point_image_uv_set(map, 3, 0, flip->from_size.y);
1691 _transit_effect_resizable_flip_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
1693 EINA_SAFETY_ON_NULL_RETURN(effect);
1695 Elm_Transit_Effect_ResizableFlip *resizable_flip = effect;
1696 Eina_List *elist, *elist_next;
1697 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1699 EINA_LIST_FOREACH_SAFE(resizable_flip->nodes,
1700 elist, elist_next, resizable_flip_node)
1702 evas_object_map_enable_set(resizable_flip_node->front, EINA_FALSE);
1703 evas_object_map_enable_set(resizable_flip_node->back, EINA_FALSE);
1705 resizable_flip->nodes = eina_list_remove_list(resizable_flip->nodes,
1708 evas_object_event_callback_del(resizable_flip_node->back,
1709 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1710 evas_object_event_callback_del(resizable_flip_node->front,
1711 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1712 free(resizable_flip_node);
1714 free(resizable_flip);
1718 _transit_effect_resizable_flip_op(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__, double progress)
1720 EINA_SAFETY_ON_NULL_RETURN(effect);
1725 Evas_Coord half_w, half_h;
1726 Elm_Transit_Effect_ResizableFlip *resizable_flip = effect;
1727 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1730 map = evas_map_new(4);
1733 if (resizable_flip->cw) degree = (float)(progress * 180);
1734 else degree = (float)(progress * -180);
1736 if (!resizable_flip->nodes)
1737 resizable_flip->nodes = _resizable_flip_nodes_build(transit,
1740 EINA_LIST_FOREACH(resizable_flip->nodes, elist, resizable_flip_node)
1742 if ((degree < 90) && (degree > -90))
1744 obj = resizable_flip_node->front;
1745 if (resizable_flip_node->front != resizable_flip_node->back)
1747 evas_object_hide(resizable_flip_node->back);
1748 evas_object_show(resizable_flip_node->front);
1753 obj = resizable_flip_node->back;
1754 if (resizable_flip_node->front != resizable_flip_node->back)
1756 evas_object_hide(resizable_flip_node->front);
1757 evas_object_show(resizable_flip_node->back);
1761 x = resizable_flip_node->from_pos.x +
1762 (resizable_flip_node->to_pos.x * progress);
1763 y = resizable_flip_node->from_pos.y +
1764 (resizable_flip_node->to_pos.y * progress);
1765 w = resizable_flip_node->from_size.x +
1766 (resizable_flip_node->to_size.x * progress);
1767 h = resizable_flip_node->from_size.y +
1768 (resizable_flip_node->to_size.y * progress);
1769 evas_map_point_coord_set(map, 0, x, y, 0);
1770 evas_map_point_coord_set(map, 1, x + w, y, 0);
1771 evas_map_point_coord_set(map, 2, x + w, y + h, 0);
1772 evas_map_point_coord_set(map, 3, x, y + h, 0);
1774 half_w = (Evas_Coord)(w / 2);
1775 half_h = (Evas_Coord)(h / 2);
1777 if (resizable_flip->axis == ELM_TRANSIT_EFFECT_FLIP_AXIS_Y)
1779 _set_image_uv_by_axis_y(map, resizable_flip_node, degree);
1780 evas_map_util_3d_rotate(map, 0, degree,
1781 0, x + half_w, y + half_h, 0);
1785 _set_image_uv_by_axis_x(map, resizable_flip_node, degree);
1786 evas_map_util_3d_rotate(map, degree, 0,
1787 0, x + half_w, y + half_h, 0);
1790 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, _TRANSIT_FOCAL);
1791 evas_object_map_enable_set(resizable_flip_node->front, EINA_TRUE);
1792 evas_object_map_enable_set(resizable_flip_node->back, EINA_TRUE);
1793 evas_object_map_set(obj, map);
1798 static Elm_Transit_Effect *
1799 _transit_effect_resizable_flip_context_new(Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1801 Elm_Transit_Effect_ResizableFlip *resizable_flip;
1803 resizable_flip = ELM_NEW(Elm_Transit_Effect_ResizableFlip);
1804 if (!resizable_flip) return NULL;
1806 resizable_flip->cw = cw;
1807 resizable_flip->axis = axis;
1809 return resizable_flip;
1813 * Add the Resizable Flip Effect to Elm_Transit.
1815 * @note This API is one of the facades. It creates resizable flip effect context
1816 * and add it's required APIs to elm_transit_effect_add.
1817 * @note This effect is applied to each pair of objects in the order they are listed
1818 * in the transit list of objects. The first object in the pair will be the
1819 * "front" object and the second will be the "back" object.
1821 * @see elm_transit_effect_add()
1823 * @param transit Transit object.
1824 * @param axis Flipping Axis(X or Y).
1825 * @param cw Flipping Direction. EINA_TRUE is clock-wise.
1826 * @return Resizable flip effect context data.
1829 * @warning Is higher recommended just create a transit with this effect when
1830 * the window that the objects of the transit belongs has already been created.
1831 * This is because this effect needs the geometry information about the objects,
1832 * and if the window was not created yet, it can get a wrong information.
1834 EAPI Elm_Transit_Effect *
1835 elm_transit_effect_resizable_flip_add(Elm_Transit *transit, Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1837 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1838 Elm_Transit_Effect *effect_context = _transit_effect_resizable_flip_context_new(axis, cw);
1840 if (!effect_context) return NULL;
1841 elm_transit_effect_add(transit,
1842 _transit_effect_resizable_flip_op, effect_context,
1843 _transit_effect_resizable_flip_context_free);
1844 return effect_context;
1848 ///////////////////////////////////////////////////////////////////////////////
1850 ///////////////////////////////////////////////////////////////////////////////
1851 typedef struct _Elm_Transit_Effect_Wipe Elm_Transit_Effect_Wipe;
1853 struct _Elm_Transit_Effect_Wipe
1855 Elm_Transit_Effect_Wipe_Type type;
1856 Elm_Transit_Effect_Wipe_Dir dir;
1860 _elm_fx_wipe_hide(Evas_Map * map, Elm_Transit_Effect_Wipe_Dir dir, float x, float y, float w, float h, float progress)
1866 case ELM_TRANSIT_EFFECT_WIPE_DIR_LEFT:
1867 w2 = w - (w * progress);
1869 evas_map_point_image_uv_set(map, 0, 0, 0);
1870 evas_map_point_image_uv_set(map, 1, w2, 0);
1871 evas_map_point_image_uv_set(map, 2, w2, h);
1872 evas_map_point_image_uv_set(map, 3, 0, h);
1873 evas_map_point_coord_set(map, 0, x, y, 0);
1874 evas_map_point_coord_set(map, 1, x + w2, y, 0);
1875 evas_map_point_coord_set(map, 2, x + w2, h2, 0);
1876 evas_map_point_coord_set(map, 3, x, h2, 0);
1878 case ELM_TRANSIT_EFFECT_WIPE_DIR_RIGHT:
1879 w2 = (w * progress);
1881 evas_map_point_image_uv_set(map, 0, w2, 0);
1882 evas_map_point_image_uv_set(map, 1, w, 0);
1883 evas_map_point_image_uv_set(map, 2, w, h);
1884 evas_map_point_image_uv_set(map, 3, w2, h);
1885 evas_map_point_coord_set(map, 0, x + w2, y, 0);
1886 evas_map_point_coord_set(map, 1, x + w, y, 0);
1887 evas_map_point_coord_set(map, 2, x + w, h2, 0);
1888 evas_map_point_coord_set(map, 3, x + w2, h2, 0);
1890 case ELM_TRANSIT_EFFECT_WIPE_DIR_UP:
1892 h2 = h - (h * progress);
1893 evas_map_point_image_uv_set(map, 0, 0, 0);
1894 evas_map_point_image_uv_set(map, 1, w, 0);
1895 evas_map_point_image_uv_set(map, 2, w, h2);
1896 evas_map_point_image_uv_set(map, 3, 0, h2);
1897 evas_map_point_coord_set(map, 0, x, y, 0);
1898 evas_map_point_coord_set(map, 1, w2, y, 0);
1899 evas_map_point_coord_set(map, 2, w2, y+h2, 0);
1900 evas_map_point_coord_set(map, 3, x, y+h2, 0);
1902 case ELM_TRANSIT_EFFECT_WIPE_DIR_DOWN:
1904 h2 = (h * progress);
1905 evas_map_point_image_uv_set(map, 0, 0, h2);
1906 evas_map_point_image_uv_set(map, 1, w, h2);
1907 evas_map_point_image_uv_set(map, 2, w, h);
1908 evas_map_point_image_uv_set(map, 3, 0, h);
1909 evas_map_point_coord_set(map, 0, x, y + h2, 0);
1910 evas_map_point_coord_set(map, 1, w2, y + h2, 0);
1911 evas_map_point_coord_set(map, 2, w2, y + h, 0);
1912 evas_map_point_coord_set(map, 3, x, y + h, 0);
1917 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, _TRANSIT_FOCAL);
1921 _elm_fx_wipe_show(Evas_Map *map, Elm_Transit_Effect_Wipe_Dir dir, float x, float y, float w, float h, float progress)
1927 case ELM_TRANSIT_EFFECT_WIPE_DIR_LEFT:
1928 w2 = (w - (w * progress));
1930 evas_map_point_image_uv_set(map, 0, w2, 0);
1931 evas_map_point_image_uv_set(map, 1, w, 0);
1932 evas_map_point_image_uv_set(map, 2, w, h);
1933 evas_map_point_image_uv_set(map, 3, w2, h);
1934 evas_map_point_coord_set(map, 0, x + w2, y, 0);
1935 evas_map_point_coord_set(map, 1, w, y, 0);
1936 evas_map_point_coord_set(map, 2, w, h2, 0);
1937 evas_map_point_coord_set(map, 3, x + w2, h2, 0);
1939 case ELM_TRANSIT_EFFECT_WIPE_DIR_RIGHT:
1940 w2 = (w * progress);
1942 evas_map_point_image_uv_set(map, 0, 0, 0);
1943 evas_map_point_image_uv_set(map, 1, w2, 0);
1944 evas_map_point_image_uv_set(map, 2, w2, h);
1945 evas_map_point_image_uv_set(map, 3, 0, h);
1946 evas_map_point_coord_set(map, 0, x, y, 0);
1947 evas_map_point_coord_set(map, 1, x + w2, y, 0);
1948 evas_map_point_coord_set(map, 2, x + w2, h2, 0);
1949 evas_map_point_coord_set(map, 3, x, h2, 0);
1951 case ELM_TRANSIT_EFFECT_WIPE_DIR_UP:
1953 h2 = (h - (h * progress));
1954 evas_map_point_image_uv_set(map, 0, 0, h2);
1955 evas_map_point_image_uv_set(map, 1, w, h2);
1956 evas_map_point_image_uv_set(map, 2, w, h);
1957 evas_map_point_image_uv_set(map, 3, 0, h);
1958 evas_map_point_coord_set(map, 0, x, y + h2, 0);
1959 evas_map_point_coord_set(map, 1, w2, y + h2, 0);
1960 evas_map_point_coord_set(map, 2, w2, y + h, 0);
1961 evas_map_point_coord_set(map, 3, x, y + h, 0);
1963 case ELM_TRANSIT_EFFECT_WIPE_DIR_DOWN:
1965 h2 = (h * progress);
1966 evas_map_point_image_uv_set(map, 0, 0, 0);
1967 evas_map_point_image_uv_set(map, 1, w, 0);
1968 evas_map_point_image_uv_set(map, 2, w, h2);
1969 evas_map_point_image_uv_set(map, 3, 0, h2);
1970 evas_map_point_coord_set(map, 0, x, y, 0);
1971 evas_map_point_coord_set(map, 1, w2, y, 0);
1972 evas_map_point_coord_set(map, 2, w2, y + h2, 0);
1973 evas_map_point_coord_set(map, 3, x, y + h2, 0);
1978 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, _TRANSIT_FOCAL);
1982 _transit_effect_wipe_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit)
1984 EINA_SAFETY_ON_NULL_RETURN(effect);
1985 EINA_SAFETY_ON_NULL_RETURN(transit);
1988 Elm_Transit_Effect_Wipe *wipe = effect;
1989 Eina_Bool reverse = elm_transit_auto_reverse_get(transit);
1991 EINA_LIST_FOREACH(transit->objs, elist, obj)
1993 if ((wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_SHOW && !reverse)
1994 || (wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_HIDE && reverse))
1995 evas_object_show(obj);
1996 else evas_object_hide(obj);
1997 evas_object_map_enable_set(obj, EINA_FALSE);
2004 _transit_effect_wipe_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2006 EINA_SAFETY_ON_NULL_RETURN(effect);
2007 EINA_SAFETY_ON_NULL_RETURN(transit);
2008 Elm_Transit_Effect_Wipe *wipe = effect;
2010 Evas_Coord _x, _y, _w, _h;
2014 map = evas_map_new(4);
2017 EINA_LIST_FOREACH(transit->objs, elist, obj)
2019 evas_object_geometry_get(obj, &_x, &_y, &_w, &_h);
2021 if (wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_SHOW)
2022 _elm_fx_wipe_show(map, wipe->dir, _x, _y, _w, _h, (float)progress);
2024 _elm_fx_wipe_hide(map, wipe->dir, _x, _y, _w, _h, (float)progress);
2026 evas_object_map_enable_set(obj, EINA_TRUE);
2027 evas_object_map_set(obj, map);
2032 static Elm_Transit_Effect *
2033 _transit_effect_wipe_context_new(Elm_Transit_Effect_Wipe_Type type, Elm_Transit_Effect_Wipe_Dir dir)
2035 Elm_Transit_Effect_Wipe *wipe;
2037 wipe = ELM_NEW(Elm_Transit_Effect_Wipe);
2038 if (!wipe) return NULL;
2047 * Add the Wipe Effect to Elm_Transit.
2049 * @note This API is one of the facades. It creates wipe effect context
2050 * and add it's required APIs to elm_transit_effect_add.
2052 * @see elm_transit_effect_add()
2054 * @param transit Transit object.
2055 * @param type Wipe type. Hide or show.
2056 * @param dir Wipe Direction.
2057 * @return Wipe effect context data.
2060 * @warning Is higher recommended just create a transit with this effect when
2061 * the window that the objects of the transit belongs has already been created.
2062 * This is because this effect needs the geometry information about the objects,
2063 * and if the window was not created yet, it can get a wrong information.
2066 elm_transit_effect_wipe_add(Elm_Transit *transit, Elm_Transit_Effect_Wipe_Type type, Elm_Transit_Effect_Wipe_Dir dir)
2068 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2069 void *effect_context = _transit_effect_wipe_context_new(type, dir);
2071 if (!effect_context) return NULL;
2072 elm_transit_effect_add(transit,
2073 _transit_effect_wipe_op, effect_context,
2074 _transit_effect_wipe_context_free);
2075 return effect_context;
2079 ///////////////////////////////////////////////////////////////////////////////
2081 ///////////////////////////////////////////////////////////////////////////////
2082 typedef struct _Elm_Transit_Effect_Color Elm_Transit_Effect_Color;
2084 struct _Elm_Transit_Effect_Color
2086 struct _unsigned_color {
2087 unsigned int r, g, b, a;
2089 struct _signed_color {
2095 _transit_effect_color_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
2097 Elm_Transit_Effect_Color *color = effect;
2102 _transit_effect_color_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2104 EINA_SAFETY_ON_NULL_RETURN(effect);
2105 EINA_SAFETY_ON_NULL_RETURN(transit);
2106 Elm_Transit_Effect_Color *color = effect;
2109 unsigned int r, g, b, a;
2111 r = (color->from.r + (int)((float)color->to.r * progress));
2112 g = (color->from.g + (int)((float)color->to.g * progress));
2113 b = (color->from.b + (int)((float)color->to.b * progress));
2114 a = (color->from.a + (int)((float)color->to.a * progress));
2116 EINA_LIST_FOREACH(transit->objs, elist, obj)
2117 evas_object_color_set(obj, r, g, b, a);
2120 static Elm_Transit_Effect *
2121 _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)
2123 Elm_Transit_Effect_Color *color;
2125 color = ELM_NEW(Elm_Transit_Effect_Color);
2126 if (!color) return NULL;
2128 color->from.r = from_r;
2129 color->from.g = from_g;
2130 color->from.b = from_b;
2131 color->from.a = from_a;
2132 color->to.r = to_r - from_r;
2133 color->to.g = to_g - from_g;
2134 color->to.b = to_b - from_b;
2135 color->to.a = to_a - from_a;
2141 * Add the Color Effect to Elm_Transit.
2143 * @note This API is one of the facades. It creates color effect context
2144 * and add it's required APIs to elm_transit_effect_add.
2146 * @see elm_transit_effect_add()
2148 * @param transit Transit object.
2149 * @param from_r RGB R when effect begins.
2150 * @param from_g RGB G when effect begins.
2151 * @param from_b RGB B when effect begins.
2152 * @param from_a RGB A when effect begins.
2153 * @param to_r RGB R when effect ends.
2154 * @param to_g RGB G when effect ends.
2155 * @param to_b RGB B when effect ends.
2156 * @param to_a RGB A when effect ends.
2157 * @return Color effect context data.
2161 EAPI Elm_Transit_Effect *
2162 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)
2164 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2165 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);
2167 if (!effect_context) return NULL;
2168 elm_transit_effect_add(transit,
2169 _transit_effect_color_op, effect_context,
2170 _transit_effect_color_context_free);
2171 return effect_context;
2174 ///////////////////////////////////////////////////////////////////////////////
2176 ///////////////////////////////////////////////////////////////////////////////
2177 typedef struct _Elm_Transit_Effect_Fade Elm_Transit_Effect_Fade;
2178 typedef struct _Elm_Transit_Effect_Fade_Node Elm_Transit_Effect_Fade_Node;
2180 struct _Elm_Transit_Effect_Fade_Node
2182 Evas_Object *before;
2184 struct _signed_color before_color, after_color;
2187 Eina_Bool inversed : 1;
2190 struct _Elm_Transit_Effect_Fade
2196 _fade_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2198 Elm_Transit_Effect_Fade *fade = data;
2200 Elm_Transit_Effect_Fade_Node *fade_node;
2202 EINA_LIST_FOREACH(fade->nodes, elist, fade_node)
2204 if (fade_node->before == obj)
2205 evas_object_event_callback_del(fade_node->after,
2206 EVAS_CALLBACK_DEL, _fade_object_del_cb);
2207 else if (fade_node->after == obj)
2208 evas_object_event_callback_del(fade_node->before,
2209 EVAS_CALLBACK_DEL, _fade_object_del_cb);
2212 fade->nodes = eina_list_remove_list(fade->nodes, elist);
2219 _fade_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Fade *fade_data)
2221 Elm_Transit_Effect_Fade_Node *fade;
2222 Eina_List *data_list = NULL;
2225 count = eina_list_count(transit->objs);
2226 for (i = 0; i < count; i += 2)
2228 fade = ELM_NEW(Elm_Transit_Effect_Fade_Node);
2231 eina_list_free(data_list);
2235 fade->before = eina_list_nth(transit->objs, i);
2236 fade->after = eina_list_nth(transit->objs, i+1);
2238 evas_object_color_get(fade->before,
2239 &fade->before_color.r, &fade->before_color.g,
2240 &fade->before_color.b, &fade->before_color.a);
2241 evas_object_color_get(fade->after,
2242 &fade->after_color.r, &fade->after_color.g,
2243 &fade->after_color.b, &fade->after_color.a);
2245 fade->before_alpha = (255 - fade->before_color.a);
2246 fade->after_alpha = (255 - fade->after_color.a);
2248 data_list = eina_list_append(data_list, fade);
2250 evas_object_event_callback_add(fade->before,
2251 EVAS_CALLBACK_DEL, _fade_object_del_cb, fade_data);
2252 evas_object_event_callback_add(fade->after,
2253 EVAS_CALLBACK_DEL, _fade_object_del_cb, fade_data);
2259 _transit_effect_fade_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
2261 EINA_SAFETY_ON_NULL_RETURN(effect);
2262 Elm_Transit_Effect_Fade *fade = effect;
2263 Elm_Transit_Effect_Fade_Node *fade_node;
2264 Eina_List *elist, *elist_next;
2266 EINA_LIST_FOREACH_SAFE(fade->nodes, elist, elist_next, fade_node)
2268 evas_object_color_set(fade_node->before, fade_node->before_color.r,
2269 fade_node->before_color.g,
2270 fade_node->before_color.b,
2271 fade_node->before_color.a);
2272 evas_object_color_set(fade_node->after, fade_node->after_color.r,
2273 fade_node->after_color.g,
2274 fade_node->after_color.b,
2275 fade_node->after_color.a);
2277 fade->nodes = eina_list_remove_list(fade->nodes, elist);
2278 evas_object_event_callback_del(fade_node->before,
2279 EVAS_CALLBACK_DEL, _fade_object_del_cb);
2280 evas_object_event_callback_del(fade_node->after,
2281 EVAS_CALLBACK_DEL, _fade_object_del_cb);
2289 _transit_effect_fade_op(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__, double progress)
2291 EINA_SAFETY_ON_NULL_RETURN(effect);
2292 Elm_Transit_Effect_Fade *fade = effect;
2294 Elm_Transit_Effect_Fade_Node *fade_node;
2298 fade->nodes = _fade_nodes_build(transit, fade);
2300 EINA_LIST_FOREACH(fade->nodes, elist, fade_node)
2304 if (!fade_node->inversed)
2306 evas_object_hide(fade_node->after);
2307 evas_object_show(fade_node->before);
2308 fade_node->inversed = EINA_TRUE;
2311 _progress = (1 - (progress * 2));
2313 evas_object_color_set(fade_node->before,
2314 fade_node->before_color.r * _progress,
2315 fade_node->before_color.g * _progress,
2316 fade_node->before_color.b * _progress,
2317 fade_node->before_color.a +
2318 fade_node->before_alpha * (1 - _progress));
2322 if (fade_node->inversed)
2324 evas_object_hide(fade_node->before);
2325 evas_object_show(fade_node->after);
2326 fade_node->inversed = EINA_FALSE;
2329 _progress = ((progress - 0.5) * 2);
2331 evas_object_color_set(fade_node->after,
2332 fade_node->after_color.r * _progress,
2333 fade_node->after_color.g * _progress,
2334 fade_node->after_color.b * _progress,
2335 fade_node->after_color.a +
2336 fade_node->after_alpha * (1 - _progress));
2341 static Elm_Transit_Effect *
2342 _transit_effect_fade_context_new(void)
2344 Elm_Transit_Effect_Fade *fade;
2345 fade = ELM_NEW(Elm_Transit_Effect_Fade);
2346 if (!fade) return NULL;
2351 * Add the Fade Effect to Elm_Transit.
2353 * @note This API is one of the facades. It creates fade effect context
2354 * and add it's required APIs to elm_transit_effect_add.
2355 * @note This effect is applied to each pair of objects in the order they are listed
2356 * in the transit list of objects. The first object in the pair will be the
2357 * "before" object and the second will be the "after" object.
2359 * @see elm_transit_effect_add()
2361 * @param transit Transit object.
2362 * @return Fade effect context data.
2365 * @warning Is higher recommended just create a transit with this effect when
2366 * the window that the objects of the transit belongs has already been created.
2367 * This is because this effect needs the color information about the objects,
2368 * and if the window was not created yet, it can get a wrong information.
2370 EAPI Elm_Transit_Effect *
2371 elm_transit_effect_fade_add(Elm_Transit *transit)
2373 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2375 Elm_Transit_Effect *effect_context = _transit_effect_fade_context_new();
2376 if (!effect_context) return NULL;
2377 elm_transit_effect_add(transit,
2378 _transit_effect_fade_op, effect_context,
2379 _transit_effect_fade_context_free);
2380 return effect_context;
2384 ///////////////////////////////////////////////////////////////////////////////
2386 ///////////////////////////////////////////////////////////////////////////////
2387 typedef struct _Elm_Transit_Effect_Blend Elm_Transit_Effect_Blend;
2388 typedef struct _Elm_Transit_Effect_Blend_Node Elm_Transit_Effect_Blend_Node;
2390 struct _Elm_Transit_Effect_Blend_Node
2392 Evas_Object *before;
2394 struct _signed_color from, to;
2397 struct _Elm_Transit_Effect_Blend
2403 _blend_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2405 Elm_Transit_Effect_Blend *blend = data;
2407 Elm_Transit_Effect_Blend_Node *blend_node;
2409 EINA_LIST_FOREACH(blend->nodes, elist, blend_node)
2411 if (blend_node->after == obj)
2412 evas_object_event_callback_del(blend_node->before,
2413 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2414 else if (blend_node->before == obj)
2415 evas_object_event_callback_del(blend_node->after,
2416 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2419 blend->nodes = eina_list_remove_list(blend->nodes, elist);
2426 _blend_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Blend *blend)
2428 Elm_Transit_Effect_Blend_Node *blend_node;
2429 Eina_List *data_list = NULL;
2432 count = eina_list_count(transit->objs);
2433 for (i = 0; i < (count - 1); i += 2)
2435 blend_node = ELM_NEW(Elm_Transit_Effect_Blend_Node);
2438 eina_list_free(data_list);
2442 blend_node->before = eina_list_nth(transit->objs, i);
2443 blend_node->after = eina_list_nth(transit->objs, i + 1);
2444 evas_object_show(blend_node->before);
2445 evas_object_show(blend_node->after);
2447 evas_object_color_get(blend_node->before, &blend_node->from.r,
2448 &blend_node->from.g, &blend_node->from.b,
2449 &blend_node->from.a);
2450 evas_object_color_get(blend_node->after, &blend_node->to.r,
2451 &blend_node->to.g, &blend_node->to.b,
2454 data_list = eina_list_append(data_list, blend_node);
2456 evas_object_event_callback_add(blend_node->before,
2457 EVAS_CALLBACK_DEL, _blend_object_del_cb, blend);
2458 evas_object_event_callback_add(blend_node->after,
2459 EVAS_CALLBACK_DEL, _blend_object_del_cb, blend);
2465 _transit_effect_blend_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
2467 EINA_SAFETY_ON_NULL_RETURN(effect);
2468 Elm_Transit_Effect_Blend *blend = effect;
2469 Elm_Transit_Effect_Blend_Node *blend_node;
2470 Eina_List *elist, *elist_next;
2472 EINA_LIST_FOREACH_SAFE(blend->nodes, elist, elist_next, blend_node)
2474 evas_object_color_set(blend_node->before,
2475 blend_node->from.r, blend_node->from.g,
2476 blend_node->from.b, blend_node->from.a);
2477 evas_object_color_set(blend_node->after, blend_node->to.r,
2478 blend_node->to.g, blend_node->to.b,
2481 if (elm_transit_auto_reverse_get(transit))
2482 evas_object_hide(blend_node->after);
2484 evas_object_hide(blend_node->before);
2486 blend->nodes = eina_list_remove_list(blend->nodes, elist);
2488 evas_object_event_callback_del(blend_node->before,
2489 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2490 evas_object_event_callback_del(blend_node->after,
2491 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2498 _transit_effect_blend_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2500 EINA_SAFETY_ON_NULL_RETURN(effect);
2501 EINA_SAFETY_ON_NULL_RETURN(transit);
2502 Elm_Transit_Effect_Blend *blend = effect;
2503 Elm_Transit_Effect_Blend_Node *blend_node;
2506 if (!blend->nodes) blend->nodes = _blend_nodes_build(transit, blend);
2508 EINA_LIST_FOREACH(blend->nodes, elist, blend_node)
2510 evas_object_color_set(blend_node->before,
2511 (int)(blend_node->from.r * (1 - progress)),
2512 (int)(blend_node->from.g * (1 - progress)),
2513 (int)(blend_node->from.b * (1 - progress)),
2514 (int)(blend_node->from.a * (1 - progress)));
2515 evas_object_color_set(blend_node->after,
2516 (int)(blend_node->to.r * progress),
2517 (int)(blend_node->to.g * progress),
2518 (int)(blend_node->to.b * progress),
2519 (int)(blend_node->to.a * progress));
2523 static Elm_Transit_Effect *
2524 _transit_effect_blend_context_new(void)
2526 Elm_Transit_Effect_Blend *blend;
2528 blend = ELM_NEW(Elm_Transit_Effect_Blend);
2529 if (!blend) return NULL;
2534 * Add the Blend Effect to Elm_Transit.
2536 * @note This API is one of the facades. It creates blend effect context
2537 * and add it's required APIs to elm_transit_effect_add.
2538 * @note This effect is applied to each pair of objects in the order they are listed
2539 * in the transit list of objects. The first object in the pair will be the
2540 * "before" object and the second will be the "after" object.
2542 * @see elm_transit_effect_add()
2544 * @param transit Transit object.
2545 * @return Blend effect context data.
2548 * @warning Is higher recommended just create a transit with this effect when
2549 * the window that the objects of the transit belongs has already been created.
2550 * This is because this effect needs the color information about the objects,
2551 * and if the window was not created yet, it can get a wrong information.
2553 EAPI Elm_Transit_Effect *
2554 elm_transit_effect_blend_add(Elm_Transit *transit)
2556 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2557 Elm_Transit_Effect *effect_context = _transit_effect_blend_context_new();
2559 if (!effect_context) return NULL;
2560 elm_transit_effect_add(transit,
2561 _transit_effect_blend_op, effect_context,
2562 _transit_effect_blend_context_free);
2563 return effect_context;
2567 ///////////////////////////////////////////////////////////////////////////////
2569 ///////////////////////////////////////////////////////////////////////////////
2570 typedef struct _Elm_Transit_Effect_Rotation Elm_Transit_Effect_Rotation;
2572 struct _Elm_Transit_Effect_Rotation
2578 _transit_effect_rotation_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
2580 Elm_Transit_Effect_Rotation *rotation = effect;
2585 _transit_effect_rotation_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2587 EINA_SAFETY_ON_NULL_RETURN(effect);
2588 EINA_SAFETY_ON_NULL_RETURN(transit);
2589 Elm_Transit_Effect_Rotation *rotation = effect;
2591 Evas_Coord x, y, w, h;
2593 float half_w, half_h;
2597 map = evas_map_new(4);
2600 EINA_LIST_FOREACH(transit->objs, elist, obj)
2602 evas_map_util_points_populate_from_object_full(map, obj, 0);
2603 degree = rotation->from + (float)(progress * rotation->to);
2605 evas_object_geometry_get(obj, &x, &y, &w, &h);
2607 half_w = (float)w * 0.5;
2608 half_h = (float)h * 0.5;
2610 evas_map_util_3d_rotate(map, 0, 0, degree, x + half_w, y + half_h, 0);
2611 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, _TRANSIT_FOCAL);
2612 evas_object_map_enable_set(obj, EINA_TRUE);
2613 evas_object_map_set(obj, map);
2618 static Elm_Transit_Effect *
2619 _transit_effect_rotation_context_new(float from_degree, float to_degree)
2621 Elm_Transit_Effect_Rotation *rotation;
2623 rotation = ELM_NEW(Elm_Transit_Effect_Rotation);
2624 if (!rotation) return NULL;
2626 rotation->from = from_degree;
2627 rotation->to = to_degree - from_degree;
2633 * Add the Rotation Effect to Elm_Transit.
2635 * @note This API is one of the facades. It creates rotation effect context
2636 * and add it's required APIs to elm_transit_effect_add.
2638 * @see elm_transit_effect_add()
2640 * @param transit Transit object.
2641 * @param from_degree Degree when effect begins.
2642 * @param to_degree Degree when effect is ends.
2643 * @return Rotation effect context data.
2646 * @warning Is higher recommended just create a transit with this effect when
2647 * the window that the objects of the transit belongs has already been created.
2648 * This is because this effect needs the geometry information about the objects,
2649 * and if the window was not created yet, it can get a wrong information.
2651 EAPI Elm_Transit_Effect *
2652 elm_transit_effect_rotation_add(Elm_Transit *transit, float from_degree, float to_degree)
2654 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2655 Elm_Transit_Effect *effect_context = _transit_effect_rotation_context_new(from_degree, to_degree);
2657 if (!effect_context) return NULL;
2658 elm_transit_effect_add(transit,
2659 _transit_effect_rotation_op, effect_context,
2660 _transit_effect_rotation_context_free);
2661 return effect_context;
2665 ///////////////////////////////////////////////////////////////////////////////
2666 //ImageAnimation Effect
2667 ///////////////////////////////////////////////////////////////////////////////
2668 typedef struct _Elm_Transit_Effect_Image_Animation Elm_Transit_Effect_Image_Animation;
2670 struct _Elm_Transit_Effect_Image_Animation
2676 _transit_effect_image_animation_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
2678 EINA_SAFETY_ON_NULL_RETURN(effect);
2679 Elm_Transit_Effect_Image_Animation *image_animation = effect;
2681 Eina_List *elist, *elist_next;
2683 EINA_LIST_FOREACH_SAFE(image_animation->images, elist, elist_next, image)
2685 image_animation->images =
2686 eina_list_remove_list(image_animation->images, elist);
2687 eina_stringshare_del(image);
2690 free(image_animation);
2694 _transit_effect_image_animation_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2696 EINA_SAFETY_ON_NULL_RETURN(effect);
2697 EINA_SAFETY_ON_NULL_RETURN(transit);
2701 Elm_Transit_Effect_Image_Animation *image_animation = effect;
2702 unsigned int count = 0;
2705 type = eina_stringshare_add("icon");
2706 len = eina_list_count(image_animation->images);
2708 if (!len) count = floor(progress * len);
2709 else count = floor(progress * (len - 1));
2711 EINA_LIST_FOREACH(transit->objs, elist, obj)
2713 if (elm_widget_type_check(obj, type))
2714 elm_icon_file_set(obj,
2715 eina_list_nth(image_animation->images, count), NULL);
2718 eina_stringshare_del(type);
2721 static Elm_Transit_Effect *
2722 _transit_effect_image_animation_context_new(Eina_List *images)
2724 Elm_Transit_Effect_Image_Animation *image_animation;
2725 image_animation = ELM_NEW(Elm_Transit_Effect_Image_Animation);
2727 if (!image_animation) return NULL;
2728 image_animation->images = images;
2729 return image_animation;
2733 * Add the ImageAnimation Effect to Elm_Transit.
2735 * @note This API is one of the facades. It creates image animation effect context
2736 * and add it's required APIs to elm_transit_effect_add.
2737 * The @p images parameter is a list images paths. This list and
2738 * its contents will be deleted at the end of the effect by
2739 * elm_transit_effect_image_animation_context_free() function.
2743 * char buf[PATH_MAX];
2744 * Eina_List *images = NULL;
2745 * Elm_Transit *transi = elm_transit_add();
2747 * snprintf(buf, sizeof(buf), "%s/images/icon_11.png", PACKAGE_DATA_DIR);
2748 * images = eina_list_append(images, eina_stringshare_add(buf));
2750 * snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
2751 * images = eina_list_append(images, eina_stringshare_add(buf));
2752 * elm_transit_effect_image_animation_add(transi, images);
2756 * @see elm_transit_effect_add()
2758 * @param transit Transit object.
2759 * @param images Eina_List of images file paths. This list and
2760 * its contents will be deleted at the end of the effect by
2761 * elm_transit_effect_image_animation_context_free() function.
2762 * @return Image Animation effect context data.
2766 EAPI Elm_Transit_Effect *
2767 elm_transit_effect_image_animation_add(Elm_Transit *transit, Eina_List *images)
2769 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2770 Elm_Transit_Effect *effect = _transit_effect_image_animation_context_new(images);
2772 if (!effect) return NULL;
2773 elm_transit_effect_add(transit,
2774 _transit_effect_image_animation_op, effect,
2775 _transit_effect_image_animation_context_free);