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 static const char _transit_key[] = "_elm_transit";
53 #define _TRANSIT_FOCAL 2000
57 #define ELM_TRANSIT_MAGIC 0xd27f190a
60 Ecore_Animator *animator;
61 Eina_List *effect_list;
63 Elm_Transit *prev_chain_transit;
64 Eina_List *next_chain_transits;
65 Elm_Transit_Tween_Mode tween_mode;
67 Elm_Transit_Effect_End_Cb func;
83 unsigned int effects_pending_del;
85 Eina_Bool auto_reverse : 1;
86 Eina_Bool event_enabled : 1;
87 Eina_Bool deleted : 1;
88 Eina_Bool state_keep : 1;
91 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 Elm_Transit *transit;
111 struct _Elm_Obj_State *state;
112 Eina_Bool pass_events : 1;
115 typedef struct _Elm_Transit_Effect_Module Elm_Transit_Effect_Module;
116 typedef struct _Elm_Obj_Data Elm_Obj_Data;
117 typedef struct _Elm_Obj_State Elm_Obj_State;
120 _elm_transit_obj_states_save(Evas_Object *obj)
122 Elm_Obj_Data *obj_data;
123 Elm_Obj_State *state;
125 obj_data = evas_object_data_get(obj, _transit_key);
126 if ((!obj_data) || (obj_data->state)) return;
127 state = calloc(1, sizeof(Elm_Obj_State));
129 evas_object_geometry_get(obj, &state->x, &state->y, &state->w, &state->h);
130 evas_object_color_get(obj, &state->r, &state->g, &state->b, &state->a);
131 state->visible = evas_object_visible_get(obj);
132 state->map_enabled = evas_object_map_enable_get(obj);
133 if (evas_object_map_get(obj))
134 state->map = evas_map_dup(evas_object_map_get(obj));
135 obj_data->state = state;
139 _elm_transit_object_remove_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
141 Elm_Transit *transit = data;
142 Elm_Obj_Data *obj_data = evas_object_data_del(obj, _transit_key);
143 if (!obj_data) return;
144 evas_object_pass_events_set(obj, obj_data->pass_events);
146 free(obj_data->state);
148 transit->objs = eina_list_remove(transit->objs, obj);
149 if (!transit->objs) elm_transit_del(transit);
153 //Since evas map have a afterimage bug for this time.
154 //This function is added temporary.
156 _obj_damage_area_set(Evas_Object *obj)
159 Evas_Coord_Point coords;
160 Evas_Coord_Point min, max;
163 map = evas_object_map_get(obj);
166 evas_map_point_coord_get(map, 0, &coords.x, &coords.y, NULL);
170 for (i = 1; i < 4; ++i)
172 evas_map_point_coord_get(map, i, &coords.x, &coords.y, NULL);
174 if (coords.x < min.x)
176 else if (coords.x > max.x)
179 if (coords.y < min.y)
181 else if (coords.y > max.y)
185 evas_damage_rectangle_add(evas_object_evas_get(obj),
187 max.x - min.x, max.y - min.y);
193 _elm_transit_object_remove(Elm_Transit *transit, Evas_Object *obj)
195 Elm_Obj_Data *obj_data = evas_object_data_del(obj, _transit_key);
196 Elm_Obj_State *state = obj_data->state;
198 evas_object_pass_events_set(obj, obj_data->pass_events);
202 //recover the states of the object.
203 if (!transit->state_keep)
205 evas_object_move(obj, state->x, state->y);
206 evas_object_resize(obj, state->w, state->h);
207 evas_object_color_set(obj, state->r, state->g, state->b, state->a);
208 if (state->visible) evas_object_show(obj);
209 else evas_object_hide(obj);
210 if (state->map_enabled)
211 evas_object_map_enable_set(obj, EINA_TRUE);
213 evas_object_map_enable_set(obj, EINA_FALSE);
215 evas_object_map_set(obj, state->map);
218 //Since evas map have a afterimage bug for this time.
219 //This line is added temporary.
220 _obj_damage_area_set(obj);
227 //remove duplicated objects
228 //TODO: Need to consider about optimizing here
231 if (!eina_list_data_find_list(transit->objs, obj))
233 transit->objs = eina_list_remove(transit->objs, obj);
236 evas_object_event_callback_del(obj, EVAS_CALLBACK_DEL,
237 _elm_transit_object_remove_cb);
241 _elm_transit_effect_del(Elm_Transit *transit, Elm_Transit_Effect_Module *effect_module, Eina_List *elist)
243 if (effect_module->end_cb)
244 effect_module->end_cb(effect_module->effect, transit);
246 transit->effect_list = eina_list_remove_list(transit->effect_list, elist);
251 _remove_dead_effects(Elm_Transit *transit)
253 Eina_List *elist, *elist_next;
254 Elm_Transit_Effect_Module *effect_module;
256 EINA_LIST_FOREACH_SAFE(transit->effect_list, elist, elist_next, effect_module)
258 if (effect_module->deleted)
260 _elm_transit_effect_del(transit, effect_module, elist);
261 transit->effects_pending_del--;
262 if (!transit->effects_pending_del) return;
268 _elm_transit_del(Elm_Transit *transit)
270 Eina_List *elist, *elist_next;
271 Elm_Transit_Effect_Module *effect_module;
272 Elm_Transit *chain_transit;
274 EINA_LIST_FOREACH_SAFE(transit->next_chain_transits, elist, elist_next, chain_transit)
276 if (transit->prev_chain_transit)
277 transit->prev_chain_transit->next_chain_transits = eina_list_remove(transit->prev_chain_transit->next_chain_transits, transit);
278 chain_transit->prev_chain_transit = NULL;
281 eina_list_free(transit->next_chain_transits);
283 if (transit->animator)
284 ecore_animator_del(transit->animator);
286 EINA_LIST_FOREACH_SAFE(transit->effect_list, elist, elist_next, effect_module)
287 _elm_transit_effect_del(transit, effect_module, elist);
289 while (transit->objs)
290 _elm_transit_object_remove(transit, eina_list_data_get(transit->objs));
292 transit->deleted = EINA_TRUE;
294 if (transit->del_data.func)
295 transit->del_data.func(transit->del_data.arg, transit);
297 EINA_MAGIC_SET(transit, EINA_MAGIC_NONE);
302 _chain_transits_go(Elm_Transit *transit)
304 Eina_List *elist, *elist_next;
305 Elm_Transit *chain_transit;
307 EINA_LIST_FOREACH_SAFE(transit->next_chain_transits, elist, elist_next, chain_transit)
308 elm_transit_go(chain_transit);
312 _transit_animate_op(Elm_Transit *transit, double progress)
315 Elm_Transit_Effect_Module *effect_module;
318 EINA_LIST_FOREACH(transit->effect_list, elist, effect_module)
320 if (transit->deleted) break;
321 if (!effect_module->deleted)
322 effect_module->transition_cb(effect_module->effect, transit, progress);
326 if (transit->walking) return;
328 if (transit->deleted) _elm_transit_del(transit);
329 else if (transit->effects_pending_del) _remove_dead_effects(transit);
333 _animator_animate_cb(void *data)
335 Elm_Transit *transit = data;
336 double elapsed_time, duration;
338 transit->time.current = ecore_loop_time_get();
339 elapsed_time = transit->time.current - transit->time.begin;
340 duration = transit->time.duration + transit->time.delayed;
342 if (elapsed_time > duration)
343 elapsed_time = duration;
345 transit->progress = elapsed_time / duration;
346 switch (transit->tween_mode)
348 case ELM_TRANSIT_TWEEN_MODE_ACCELERATE:
349 transit->progress = 1.0 - sin((ELM_PI / 2.0) + (transit->progress * ELM_PI / 2.0));
351 case ELM_TRANSIT_TWEEN_MODE_DECELERATE:
352 transit->progress = sin(transit->progress * ELM_PI / 2.0);
354 case ELM_TRANSIT_TWEEN_MODE_SINUSOIDAL:
355 transit->progress = (1.0 - cos(transit->progress * ELM_PI)) / 2.0;
362 if (transit->repeat.reverse) transit->progress = 1 - transit->progress;
364 if (transit->time.duration > 0) _transit_animate_op(transit, transit->progress);
366 /* Not end. Keep going. */
367 if (elapsed_time < duration) return ECORE_CALLBACK_RENEW;
369 /* Repeat and reverse and time done! */
370 if ((transit->repeat.count >= 0) &&
371 (transit->repeat.current == transit->repeat.count) &&
372 ((!transit->auto_reverse) || transit->repeat.reverse))
374 /* run chain transit */
375 if (transit->next_chain_transits)
376 _chain_transits_go(transit);
378 elm_transit_del(transit);
379 return ECORE_CALLBACK_CANCEL;
383 if (!transit->auto_reverse || transit->repeat.reverse)
385 transit->repeat.current++;
386 transit->repeat.reverse = EINA_FALSE;
388 else transit->repeat.reverse = EINA_TRUE;
390 transit->time.begin = ecore_loop_time_get();
392 return ECORE_CALLBACK_RENEW;
398 * @note Is not necessary to delete the transit object, it will be deleted at
399 * the end of its operation.
400 * @note The transit will start playing when the program enter in the main loop, is not
401 * necessary to give a start to the transit.
403 * @param duration The duration of the transit in seconds. When transit starts
404 * to run, it will last a @p duration time.
405 * @return The transit object.
410 elm_transit_add(void)
412 Elm_Transit *transit = ELM_NEW(Elm_Transit);
413 if (!transit) return NULL;
415 EINA_MAGIC_SET(transit, ELM_TRANSIT_MAGIC);
417 elm_transit_tween_mode_set(transit, ELM_TRANSIT_TWEEN_MODE_LINEAR);
422 * Stops the animation and delete the @p transit object.
424 * Call this function if you wants to stop the animation before the duration
425 * time. Make sure the @p transit object is still alive with
426 * elm_transit_del_cb_set() function.
427 * All added effects will be deleted, calling its repective data_free_cb
428 * functions. The function setted by elm_transit_del_cb_set() will be called.
430 * @see elm_transit_del_cb_set()
432 * @param transit The transit object to be deleted.
435 * @warning Just call this function if you are sure the transit is alive.
438 elm_transit_del(Elm_Transit *transit)
440 ELM_TRANSIT_CHECK_OR_RETURN(transit);
442 if (transit->walking) transit->deleted = EINA_TRUE;
443 else _elm_transit_del(transit);
447 * Add a new effect to the transit.
449 * @note The cb function and the data are the key to the effect. If you try to
450 * add an already added effect, nothing is done.
451 * @note After the first addition of an effect in @p transit, if its
452 * effect list become empty again, the @p transit will be killed by
453 * elm_transit_del(transit) function.
457 * Elm_Transit *transit = elm_transit_add();
458 * elm_transit_effect_add(transit,
459 * elm_transit_effect_blend_op,
460 * elm_transit_effect_blend_context_new(),
461 * elm_transit_effect_blend_context_free);
464 * @param transit The transit object.
465 * @param cb The operation function. It is called when the animation begins,
466 * it is the function that actually performs the animation. It is called with
467 * the @p data, @p transit and the time progression of the animation (a double
468 * value between 0.0 and 1.0).
469 * @param data The context data of the effect.
470 * @param data_free_cb The function to free the context data, it will be called
471 * at the end of the effect, it must finalize the animation and free the
475 * @warning The transit free the context data at the and of the transition with
476 * the data_free_cb function, do not use the context data in another transit.
479 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)
481 ELM_TRANSIT_CHECK_OR_RETURN(transit);
482 EINA_SAFETY_ON_NULL_RETURN(transition_cb);
483 Elm_Transit_Effect_Module *effect_module;
486 EINA_LIST_FOREACH(transit->effect_list, elist, effect_module)
487 if ((effect_module->transition_cb == transition_cb) && (effect_module->effect == effect)) return;
489 effect_module = ELM_NEW(Elm_Transit_Effect_Module);
490 if (!effect_module) return;
492 effect_module->end_cb = end_cb;
493 effect_module->transition_cb = transition_cb;
494 effect_module->effect = effect;
496 transit->effect_list = eina_list_append(transit->effect_list, effect_module);
500 * Delete an added effect.
502 * This function will remove the effect from the @p transit, calling the
503 * data_free_cb to free the @p data.
505 * @see elm_transit_effect_add()
507 * @note If the effect is not found, nothing is done.
508 * @note If the effect list become empty, this function will call
509 * elm_transit_del(transit), that is, it will kill the @p transit.
511 * @param transit The transit object.
512 * @param cb The operation function.
513 * @param data The context data of the effect.
518 elm_transit_effect_del(Elm_Transit *transit, Elm_Transit_Effect_Transition_Cb transition_cb, Elm_Transit_Effect *effect)
520 ELM_TRANSIT_CHECK_OR_RETURN(transit);
521 EINA_SAFETY_ON_NULL_RETURN(transition_cb);
522 Eina_List *elist, *elist_next;
523 Elm_Transit_Effect_Module *effect_module;
525 EINA_LIST_FOREACH_SAFE(transit->effect_list, elist, elist_next, effect_module)
527 if ((effect_module->transition_cb == transition_cb) && (effect_module->effect == effect))
529 if (transit->walking)
531 effect_module->deleted = EINA_TRUE;
532 transit->effects_pending_del++;
536 _elm_transit_effect_del(transit, effect_module, elist);
537 if (!transit->effect_list) elm_transit_del(transit);
545 * Add new object to apply the effects.
547 * @note After the first addition of an object in @p transit, if its
548 * object list become empty again, the @p transit will be killed by
549 * elm_transit_del(transit) function.
550 * @note If the @p obj belongs to another transit, the @p obj will be
551 * removed from it and it will only belong to the @p transit. If the old
552 * transit stays without objects, it will die.
553 * @note When you add an object into the @p transit, its state from
554 * evas_object_pass_events_get(obj) is saved, and it is applied when the
555 * transit ends, if you change this state whith evas_object_pass_events_set()
556 * after add the object, this state will change again when @p transit stops to
559 * @param transit The transit object.
560 * @param obj Object to be animated.
563 * @warning It is not allowed to add a new object after transit begins to go.
566 elm_transit_object_add(Elm_Transit *transit, Evas_Object *obj)
568 ELM_TRANSIT_CHECK_OR_RETURN(transit);
569 EINA_SAFETY_ON_NULL_RETURN(obj);
570 Elm_Obj_Data *obj_data;
572 obj_data = evas_object_data_get(obj, _transit_key);
574 if ((obj_data) && (obj_data->transit != transit))
575 elm_transit_object_remove(obj_data->transit, obj);
577 if ((!obj_data) || (obj_data->transit != transit))
579 obj_data = ELM_NEW(Elm_Obj_Data);
580 obj_data->pass_events = evas_object_pass_events_get(obj);
581 obj_data->transit = transit;
582 evas_object_data_set(obj, _transit_key, obj_data);
583 if (!transit->event_enabled)
584 evas_object_pass_events_set(obj, EINA_TRUE);
586 evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
587 _elm_transit_object_remove_cb,
591 transit->objs = eina_list_append(transit->objs, obj);
593 if (!transit->state_keep)
594 _elm_transit_obj_states_save(obj);
599 * Removes an added object from the transit.
601 * @note If the @p obj is not in the @p transit, nothing is done.
602 * @note If the list become empty, this function will call
603 * elm_transit_del(transit), that is, it will kill the @p transit.
605 * @param transit The transit object.
606 * @param obj Object to be removed from @p transit.
609 * @warning It is not allowed to remove objects after transit begins to go.
612 elm_transit_object_remove(Elm_Transit *transit, Evas_Object *obj)
614 ELM_TRANSIT_CHECK_OR_RETURN(transit);
615 EINA_SAFETY_ON_NULL_RETURN(obj);
616 Elm_Obj_Data *obj_data;
618 obj_data = evas_object_data_get(obj, _transit_key);
620 if ((!obj_data) || (obj_data->transit != transit)) return;
622 _elm_transit_object_remove(transit, obj);
623 if (!transit->objs) elm_transit_del(transit);
627 * Get the objects of the transit.
629 * @param transit The transit object.
630 * @return a Eina_List with the objects from the transit.
634 EAPI const Eina_List *
635 elm_transit_objects_get(const Elm_Transit *transit)
637 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
638 return transit->objs;
642 * Set the event enabled when transit is operating.
644 * If @p enabled is EINA_TRUE, the objects of the transit will receives
645 * events from mouse and keyboard during the animation.
646 * @note When you add an object with elm_transit_object_add(), its state from
647 * evas_object_pass_events_get(obj) is saved, and it is applied when the
648 * transit ends, if you change this state with evas_object_pass_events_set()
649 * after adding the object, this state will change again when @p transit stops
652 * @param transit The transit object.
653 * @param enabled Disable or enable.
658 elm_transit_event_enabled_set(Elm_Transit *transit, Eina_Bool enabled)
660 ELM_TRANSIT_CHECK_OR_RETURN(transit);
663 Elm_Obj_Data *obj_data;
665 if (transit->event_enabled == enabled) return;
667 transit->event_enabled = !!enabled;
671 EINA_LIST_FOREACH(transit->objs, elist, obj)
673 obj_data = evas_object_data_get(obj, _transit_key);
674 evas_object_pass_events_set(obj, obj_data->pass_events);
679 EINA_LIST_FOREACH(transit->objs, elist, obj)
680 evas_object_pass_events_set(obj, EINA_TRUE);
685 * Get the value of event enabled status.
687 * @see elm_transit_event_enabled_set()
689 * @param transit The Transit object
690 * @return EINA_TRUE, when event is enabled. If @p transit is NULL
691 * EINA_FALSE is returned
696 elm_transit_event_enabled_get(const Elm_Transit *transit)
698 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
699 return transit->event_enabled;
704 * Set the event enabled when transit is operating.
706 * If @p disabled is EINA_TRUE, the objects of the transit will receives
707 * events from mouse and keyboard during the animation.
708 * @note When you add an object with elm_transit_object_add(), its state from
709 * evas_object_pass_events_get(obj) is saved, and it is applied when the
710 * transit ends, if you change this state with evas_object_pass_events_set()
711 * after add the object, this state will change again when @p transit stops to
714 * @see elm_transit_event_enabled_set()
716 * @param transit The transit object.
717 * @param disabled Disable or enable.
721 EINA_DEPRECATED EAPI void
722 elm_transit_event_block_set(Elm_Transit *transit, Eina_Bool disabled)
724 elm_transit_event_enabled_set(transit, disabled);
729 * Get the value of event block enabled status.
731 * @see elm_transit_event_enabled_set(), elm_transit_event_enabled_get()
733 * @param transit The Transit object
734 * @return EINA_TRUE, when event is enabled. If @p transit is NULL
735 * EINA_FALSE is returned
739 EINA_DEPRECATED EAPI Eina_Bool
740 elm_transit_event_block_get(const Elm_Transit *transit)
742 return !elm_transit_event_enabled_get(transit);
746 * Set the user-callback function when the transit is deleted.
748 * @note Using this function twice will overwrite the first function setted.
749 * @note the @p transit object will be deleted after call @p cb function.
751 * @param transit The transit object.
752 * @param cb Callback function pointer. This function will be called before
753 * the deletion of the transit.
754 * @param data Callback funtion user data. It is the @p op parameter.
759 elm_transit_del_cb_set(Elm_Transit *transit, void (*cb) (void *data, Elm_Transit *transit), void *data)
761 ELM_TRANSIT_CHECK_OR_RETURN(transit);
762 transit->del_data.func = cb;
763 transit->del_data.arg = data;
767 * Set reverse effect automatically.
769 * If auto reverse is setted, after running the effects with the progress
770 * parameter from 0 to 1, it will call the effecs again with the progress
771 * from 1 to 0. The transit will last for a time iqual to (2 * duration * repeat),
772 * where the duration was setted with the function elm_transit_add and
773 * the repeat with the function elm_transit_repeat_times_set().
775 * @param transit The transit object.
776 * @param reverse EINA_TRUE means the auto_reverse is on.
781 elm_transit_auto_reverse_set(Elm_Transit *transit, Eina_Bool reverse)
783 ELM_TRANSIT_CHECK_OR_RETURN(transit);
784 transit->auto_reverse = reverse;
788 * Get if the auto reverse is on.
790 * @see elm_transit_auto_reverse_set()
792 * @param transit The transit object.
793 * @return EINA_TRUE means auto reverse is on. If @p transit is NULL
794 * EINA_FALSE is returned
799 elm_transit_auto_reverse_get(const Elm_Transit *transit)
801 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
802 return transit->auto_reverse;
806 * Set the transit repeat count. Effect will be repeated by repeat count.
808 * This function sets the number of repetition the transit will run after
809 * the first one, that is, if @p repeat is 1, the transit will run 2 times.
810 * If the @p repeat is a negative number, it will repeat infinite times.
812 * @note If this function is called during the transit execution, the transit
813 * will run @p repeat times, ignoring the times it already performed.
815 * @param transit The transit object
816 * @param repeat Repeat count
821 elm_transit_repeat_times_set(Elm_Transit *transit, int repeat)
823 ELM_TRANSIT_CHECK_OR_RETURN(transit);
824 transit->repeat.count = repeat;
825 transit->repeat.current = 0;
829 * Get the transit repeat count.
831 * @see elm_transit_repeat_times_set()
833 * @param transit The Transit object.
834 * @return The repeat count. If @p transit is NULL
840 elm_transit_repeat_times_get(const Elm_Transit *transit)
842 ELM_TRANSIT_CHECK_OR_RETURN(transit, 0);
843 return transit->repeat.count;
847 * Set the transit animation acceleration type.
849 * This function sets the tween mode of the transit that can be:
850 * ELM_TRANSIT_TWEEN_MODE_LINEAR - The default mode.
851 * ELM_TRANSIT_TWEEN_MODE_SINUSOIDAL - Starts in accelerate mode and ends decelerating.
852 * ELM_TRANSIT_TWEEN_MODE_DECELERATE - The animation will be slowed over time.
853 * ELM_TRANSIT_TWEEN_MODE_ACCELERATE - The animation will accelerate over time.
855 * @param transit The transit object.
856 * @param tween_mode The tween type.
861 elm_transit_tween_mode_set(Elm_Transit *transit, Elm_Transit_Tween_Mode tween_mode)
863 ELM_TRANSIT_CHECK_OR_RETURN(transit);
864 transit->tween_mode = tween_mode;
868 * Get the transit animation acceleration type.
870 * @note @p transit can not be NULL
872 * @param transit The transit object.
873 * @return The tween type. If @p transit is NULL
874 * ELM_TRANSIT_TWEEN_MODE_LINEAR is returned.
878 EAPI Elm_Transit_Tween_Mode
879 elm_transit_tween_mode_get(const Elm_Transit *transit)
881 ELM_TRANSIT_CHECK_OR_RETURN(transit, ELM_TRANSIT_TWEEN_MODE_LINEAR);
882 return transit->tween_mode;
886 * Set the transit animation time
888 * @note @p transit can not be NULL
890 * @param transit The transit object.
891 * @param duration The animation time.
896 elm_transit_duration_set(Elm_Transit *transit, double duration)
898 ELM_TRANSIT_CHECK_OR_RETURN(transit);
899 if (transit->animator) return;
900 transit->time.duration = duration;
904 * Get the transit animation time
906 * @note @p transit can not be NULL
908 * @param transit The transit object.
910 * @return The transit animation time.
915 elm_transit_duration_get(const Elm_Transit *transit)
917 ELM_TRANSIT_CHECK_OR_RETURN(transit, 0.0);
918 return transit->time.duration;
922 * Starts the transition.
923 * Once this API is called, the transit begins to measure the time.
925 * @note @p transit can not be NULL
927 * @param transit The transit object.
932 elm_transit_go(Elm_Transit *transit)
934 ELM_TRANSIT_CHECK_OR_RETURN(transit);
936 if (transit->animator)
937 ecore_animator_del(transit->animator);
939 transit->time.paused = 0;
940 transit->time.delayed = 0;
941 transit->time.begin = ecore_loop_time_get();
942 transit->animator = ecore_animator_add(_animator_animate_cb, transit);
946 * Pause/Resume the transition.
947 * If you call elm_transit_go again, paused states will affect no anymore.
949 * @note @p transit can not be NULL
951 * @param transit The transit object.
956 elm_transit_paused_set(Elm_Transit *transit, Eina_Bool paused)
958 ELM_TRANSIT_CHECK_OR_RETURN(transit);
960 if (!transit->animator) return;
964 if (transit->time.paused > 0)
966 ecore_animator_freeze(transit->animator);
967 transit->time.paused = ecore_loop_time_get();
971 if (transit->time.paused == 0)
973 ecore_animator_thaw(transit->animator);
974 transit->time.delayed += (ecore_loop_time_get() - transit->time.paused);
975 transit->time.paused = 0;
980 * Get the value of paused status.
982 * @see elm_transit_paused_set()
984 * @note @p transit can not be NULL
986 * @param transit The transit object.
987 * @return EINA_TRUE means transition is paused. If @p transit is NULL
988 * EINA_FALSE is returned
993 elm_transit_paused_get(const Elm_Transit *transit)
995 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
997 if (transit->time.paused == 0)
1004 * Get the time progression of the animation (a double value between 0.0 and 1.0).
1006 * @note @p transit can not be NULL
1008 * @param transit The transit object.
1010 * @return The time progression value. If @p transit is NULL
1016 elm_transit_progress_value_get(const Elm_Transit *transit)
1018 ELM_TRANSIT_CHECK_OR_RETURN(transit, 0);
1019 return transit->progress;
1023 * Enable/disable keeping up the objects states.
1024 * If it is not kept, the objects states will be reset when transition ends.
1026 * @note @p transit can not be NULL.
1027 * @note One state includes geometry, color, map data.
1029 * @param transit The transit object.
1030 * @param state_keep Keeping or Non Keeping.
1035 elm_transit_objects_final_state_keep_set(Elm_Transit *transit, Eina_Bool state_keep)
1040 ELM_TRANSIT_CHECK_OR_RETURN(transit);
1041 if (transit->state_keep == state_keep) return;
1042 if (transit->animator) return;
1043 transit->state_keep = !!state_keep;
1046 EINA_LIST_FOREACH(transit->objs, list, obj)
1047 _elm_transit_obj_states_save(obj);
1052 * Get a value whether the objects states will be reset or not.
1054 * @note @p transit can not be NULL
1056 * @see elm_transit_objects_final_state_keep_set()
1058 * @param transit The transit object.
1059 * @return EINA_TRUE means the states of the objects will be reset.
1060 * If @p transit is NULL, EINA_FALSE is returned
1065 elm_transit_objects_final_state_keep_get(const Elm_Transit *transit)
1067 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
1068 return transit->state_keep;
1072 * Makes the chain relationship between two transits.
1074 * @note @p transit can not be NULL. Transit would have multiple chain transits.
1075 * @note @p chain_transit can not be NULL. Chain transits could be chained to the only one transit.
1077 * @param transit The transit object.
1078 * @param chain_transit The chain transit object. This transit will be operated * after transit is done.
1083 elm_transit_chain_transit_add(Elm_Transit *transit, Elm_Transit *chain_transit)
1085 ELM_TRANSIT_CHECK_OR_RETURN(transit);
1086 ELM_TRANSIT_CHECK_OR_RETURN(chain_transit);
1088 if (transit == chain_transit) return;
1089 if (transit == chain_transit->prev_chain_transit) return;
1091 if (chain_transit->prev_chain_transit)
1092 chain_transit->prev_chain_transit->next_chain_transits = eina_list_remove(chain_transit->prev_chain_transit->next_chain_transits, chain_transit);
1094 chain_transit->prev_chain_transit = transit;
1095 transit->next_chain_transits = eina_list_append(transit->next_chain_transits, chain_transit);
1099 * Get the current chain transit list.
1101 * @note @p transit can not be NULL.
1103 * @param transit The transit object.
1104 * @return chain transit list.
1109 elm_transit_chain_transits_get(const Elm_Transit * transit)
1111 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1112 return transit->next_chain_transits;
1115 ///////////////////////////////////////////////////////////////////////////////
1117 ///////////////////////////////////////////////////////////////////////////////
1118 typedef struct _Elm_Transit_Effect_Resizing Elm_Transit_Effect_Resizing;
1120 struct _Elm_Transit_Effect_Resizing
1128 _transit_effect_resizing_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
1130 Elm_Transit_Effect_Resizing *resizing = effect;
1135 _transit_effect_resizing_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
1137 EINA_SAFETY_ON_NULL_RETURN(effect);
1138 EINA_SAFETY_ON_NULL_RETURN(transit);
1142 Elm_Transit_Effect_Resizing *resizing = effect;
1144 w = resizing->from.w + (resizing->to.w * progress);
1145 h = resizing->from.h + (resizing->to.h * progress);
1147 EINA_LIST_FOREACH(transit->objs, elist, obj)
1148 evas_object_resize(obj, w, h);
1151 static Elm_Transit_Effect *
1152 _transit_effect_resizing_context_new(Evas_Coord from_w, Evas_Coord from_h, Evas_Coord to_w, Evas_Coord to_h)
1154 Elm_Transit_Effect_Resizing *resizing;
1156 resizing = ELM_NEW(Elm_Transit_Effect_Resizing);
1157 if (!resizing) return NULL;
1159 resizing->from.w = from_w;
1160 resizing->from.h = from_h;
1161 resizing->to.w = to_w - from_w;
1162 resizing->to.h = to_h - from_h;
1168 * Add the Resizing Effect to Elm_Transit.
1170 * @note This API is one of the facades. It creates resizing effect context
1171 * and add it's required APIs to elm_transit_effect_add.
1173 * @see elm_transit_effect_add()
1175 * @param transit Transit object.
1176 * @param from_w Object width size when effect begins.
1177 * @param from_h Object height size when effect begins.
1178 * @param to_w Object width size when effect ends.
1179 * @param to_h Object height size when effect ends.
1180 * @return Resizing effect context data.
1184 EAPI Elm_Transit_Effect *
1185 elm_transit_effect_resizing_add(Elm_Transit *transit, Evas_Coord from_w, Evas_Coord from_h, Evas_Coord to_w, Evas_Coord to_h)
1187 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1188 Elm_Transit_Effect *effect = _transit_effect_resizing_context_new(from_w, from_h, to_w, to_h);
1190 if (!effect) return NULL;
1191 elm_transit_effect_add(transit,
1192 _transit_effect_resizing_op, effect,
1193 _transit_effect_resizing_context_free);
1197 ///////////////////////////////////////////////////////////////////////////////
1198 //Translation Effect
1199 ///////////////////////////////////////////////////////////////////////////////
1200 typedef struct _Elm_Transit_Effect_Translation Elm_Transit_Effect_Translation;
1201 typedef struct _Elm_Transit_Effect_Translation_Node Elm_Transit_Effect_Translation_Node;
1203 struct _Elm_Transit_Effect_Translation_Node
1209 struct _Elm_Transit_Effect_Translation
1211 struct _position_variation {
1218 _translation_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1220 Elm_Transit_Effect_Translation *translation = data;
1222 Elm_Transit_Effect_Translation_Node *translation_node;
1224 EINA_LIST_FOREACH(translation->nodes, elist, translation_node)
1226 if (translation_node->obj != obj) continue;
1227 translation->nodes = eina_list_remove_list(translation->nodes, elist);
1228 free(translation_node);
1234 _translation_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Translation *translation)
1236 Elm_Transit_Effect_Translation_Node *translation_node;
1237 const Eina_List *elist;
1239 Eina_List *data_list = NULL;
1240 const Eina_List *objs = elm_transit_objects_get(transit);
1242 EINA_LIST_FOREACH(objs, elist, obj)
1244 translation_node = ELM_NEW(Elm_Transit_Effect_Translation_Node);
1245 if (!translation_node)
1247 eina_list_free(data_list);
1250 translation_node->obj = obj;
1251 evas_object_geometry_get(obj, &(translation_node->x),
1252 &(translation_node->y), NULL, NULL);
1253 data_list = eina_list_append(data_list, translation_node);
1254 evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
1255 _translation_object_del_cb, translation);
1261 _transit_effect_translation_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
1263 EINA_SAFETY_ON_NULL_RETURN(effect);
1264 Elm_Transit_Effect_Translation *translation = effect;
1265 Eina_List *elist, *elist_next;
1266 Elm_Transit_Effect_Translation_Node *translation_node;
1268 EINA_LIST_FOREACH_SAFE(translation->nodes,
1269 elist, elist_next, translation_node)
1271 evas_object_event_callback_del(translation_node->obj,
1272 EVAS_CALLBACK_DEL, _translation_object_del_cb);
1273 translation->nodes = eina_list_remove_list(translation->nodes, elist);
1274 free(translation_node);
1280 _transit_effect_translation_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress __UNUSED__)
1282 EINA_SAFETY_ON_NULL_RETURN(effect);
1283 EINA_SAFETY_ON_NULL_RETURN(transit);
1285 Elm_Transit_Effect_Translation *translation = effect;
1286 Elm_Transit_Effect_Translation_Node *translation_node;
1289 if (!translation->nodes)
1290 translation->nodes = _translation_nodes_build(transit, translation);
1292 EINA_LIST_FOREACH(translation->nodes, elist, translation_node)
1294 x = translation_node->x + translation->from.dx
1295 + (translation->to.dx * progress);
1296 y = translation_node->y + translation->from.dy
1297 + (translation->to.dy * progress);
1298 evas_object_move(translation_node->obj, x, y);
1302 static Elm_Transit_Effect *
1303 _transit_effect_translation_context_new(Evas_Coord from_dx, Evas_Coord from_dy, Evas_Coord to_dx, Evas_Coord to_dy)
1305 Elm_Transit_Effect_Translation *translation;
1307 translation = ELM_NEW(Elm_Transit_Effect_Translation);
1308 if (!translation) return NULL;
1310 translation->from.dx = from_dx;
1311 translation->from.dy = from_dy;
1312 translation->to.dx = to_dx - from_dx;
1313 translation->to.dy = to_dy - from_dy;
1319 * Add the Translation Effect to Elm_Transit.
1321 * @note This API is one of the facades. It creates translation effect context
1322 * and add it's required APIs to elm_transit_effect_add.
1324 * @see elm_transit_effect_add()
1326 * @param transit Transit object.
1327 * @param from_dx X Position variation when effect begins.
1328 * @param from_dy Y Position variation when effect begins.
1329 * @param to_dx X Position variation when effect ends.
1330 * @param to_dy Y Position variation when effect ends.
1331 * @return Translation effect context data.
1334 * @warning Is higher recommended just create a transit with this effect when
1335 * the window that the objects of the transit belongs has already been created.
1336 * This is because this effect needs the geometry information about the objects,
1337 * and if the window was not created yet, it can get a wrong information.
1339 EAPI Elm_Transit_Effect *
1340 elm_transit_effect_translation_add(Elm_Transit *transit, Evas_Coord from_dx, Evas_Coord from_dy, Evas_Coord to_dx, Evas_Coord to_dy)
1342 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1343 Elm_Transit_Effect *effect_context = _transit_effect_translation_context_new(from_dx, from_dy, to_dx, to_dy);
1345 if (!effect_context) return NULL;
1346 elm_transit_effect_add(transit,
1347 _transit_effect_translation_op, effect_context,
1348 _transit_effect_translation_context_free);
1349 return effect_context;
1353 ///////////////////////////////////////////////////////////////////////////////
1355 ///////////////////////////////////////////////////////////////////////////////
1356 typedef struct _Elm_Transit_Effect_Zoom Elm_Transit_Effect_Zoom;
1358 struct _Elm_Transit_Effect_Zoom
1364 _transit_effect_zoom_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
1366 Elm_Transit_Effect_Zoom *zoom = effect;
1371 _transit_effect_zoom_op(Elm_Transit_Effect *effect, Elm_Transit *transit , double progress)
1373 EINA_SAFETY_ON_NULL_RETURN(effect);
1374 EINA_SAFETY_ON_NULL_RETURN(transit);
1377 Elm_Transit_Effect_Zoom *zoom = effect;
1379 Evas_Coord x, y, w, h;
1381 map = evas_map_new(4);
1384 EINA_LIST_FOREACH(transit->objs, elist, obj)
1386 evas_object_geometry_get(obj, &x, &y, &w, &h);
1387 evas_map_util_points_populate_from_object_full(map, obj, zoom->from +
1388 (progress * zoom->to));
1389 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, _TRANSIT_FOCAL);
1390 evas_object_map_set(obj, map);
1391 evas_object_map_enable_set(obj, EINA_TRUE);
1396 static Elm_Transit_Effect *
1397 _transit_effect_zoom_context_new(float from_rate, float to_rate)
1399 Elm_Transit_Effect_Zoom *zoom;
1401 zoom = ELM_NEW(Elm_Transit_Effect_Zoom);
1402 if (!zoom) return NULL;
1404 zoom->from = (_TRANSIT_FOCAL - (from_rate * _TRANSIT_FOCAL)) * (1 / from_rate);
1405 zoom->to = ((_TRANSIT_FOCAL - (to_rate * _TRANSIT_FOCAL)) * (1 / to_rate)) - zoom->from;
1411 * Add the Zoom Effect to Elm_Transit.
1413 * @note This API is one of the facades. It creates zoom effect context
1414 * and add it's required APIs to elm_transit_effect_add.
1416 * @see elm_transit_effect_add()
1418 * @param transit Transit object.
1419 * @param from_rate Scale rate when effect begins (1 is current rate).
1420 * @param to_rate Scale rate when effect ends.
1421 * @return Zoom effect context data.
1424 * @warning Is higher recommended just create a transit with this effect when
1425 * the window that the objects of the transit belongs has already been created.
1426 * This is because this effect needs the geometry information about the objects,
1427 * and if the window was not created yet, it can get a wrong information.
1429 EAPI Elm_Transit_Effect *
1430 elm_transit_effect_zoom_add(Elm_Transit *transit, float from_rate, float to_rate)
1432 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1433 Elm_Transit_Effect *effect_context = _transit_effect_zoom_context_new(from_rate, to_rate);
1435 if (!effect_context) return NULL;
1436 elm_transit_effect_add(transit,
1437 _transit_effect_zoom_op, effect_context,
1438 _transit_effect_zoom_context_free);
1439 return effect_context;
1443 ///////////////////////////////////////////////////////////////////////////////
1445 ///////////////////////////////////////////////////////////////////////////////
1446 typedef struct _Elm_Transit_Effect_Flip Elm_Transit_Effect_Flip;
1448 struct _Elm_Transit_Effect_Flip
1450 Elm_Transit_Effect_Flip_Axis axis;
1455 _transit_effect_flip_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit)
1457 EINA_SAFETY_ON_NULL_RETURN(effect);
1458 EINA_SAFETY_ON_NULL_RETURN(transit);
1459 Elm_Transit_Effect_Flip *flip = effect;
1460 Evas_Object *front, *back;
1462 int count = eina_list_count(transit->objs);
1464 for (i = 0; i < (count - 1); i += 2)
1466 front = eina_list_nth(transit->objs, i);
1467 back = eina_list_nth(transit->objs, i+1);
1468 evas_object_map_enable_set(front, EINA_FALSE);
1469 evas_object_map_enable_set(back, EINA_FALSE);
1475 _transit_effect_flip_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
1477 EINA_SAFETY_ON_NULL_RETURN(effect);
1478 EINA_SAFETY_ON_NULL_RETURN(transit);
1479 Evas_Object *obj, *front, *back;
1481 Elm_Transit_Effect_Flip *flip = effect;
1484 Evas_Coord x, y, w, h;
1486 map = evas_map_new(4);
1489 if (flip->cw) degree = (float)(progress * 180);
1490 else degree = (float)(progress * -180);
1492 count = eina_list_count(transit->objs);
1493 for (i = 0; i < (count - 1); i += 2)
1495 Evas_Coord half_w, half_h;
1497 front = eina_list_nth(transit->objs, i);
1498 back = eina_list_nth(transit->objs, i+1);
1500 if ((degree < 90) && (degree > -90))
1505 evas_object_hide(back);
1506 evas_object_show(front);
1514 evas_object_hide(front);
1515 evas_object_show(back);
1519 evas_map_util_points_populate_from_object_full(map, obj, 0);
1520 evas_object_geometry_get(obj, &x, &y, &w, &h);
1524 if (flip->axis == ELM_TRANSIT_EFFECT_FLIP_AXIS_Y)
1526 if ((degree >= 90) || (degree <= -90))
1528 evas_map_point_image_uv_set(map, 0, w, 0);
1529 evas_map_point_image_uv_set(map, 1, 0, 0);
1530 evas_map_point_image_uv_set(map, 2, 0, h);
1531 evas_map_point_image_uv_set(map, 3, w, h);
1533 evas_map_util_3d_rotate(map, 0, degree,
1534 0, x + half_w, y + half_h, 0);
1538 if ((degree >= 90) || (degree <= -90))
1540 evas_map_point_image_uv_set(map, 0, 0, h);
1541 evas_map_point_image_uv_set(map, 1, w, h);
1542 evas_map_point_image_uv_set(map, 2, w, 0);
1543 evas_map_point_image_uv_set(map, 3, 0, 0);
1545 evas_map_util_3d_rotate(map, degree,
1546 0, 0, x + half_w, y + half_h, 0);
1548 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, _TRANSIT_FOCAL);
1549 evas_object_map_enable_set(front, EINA_TRUE);
1550 evas_object_map_enable_set(back, EINA_TRUE);
1551 evas_object_map_set(obj, map);
1556 static Elm_Transit_Effect *
1557 _transit_effect_flip_context_new(Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1559 Elm_Transit_Effect_Flip *flip;
1561 flip = ELM_NEW(Elm_Transit_Effect_Flip);
1562 if (!flip) return NULL;
1571 * Add the Flip Effect to Elm_Transit.
1573 * @note This API is one of the facades. It creates flip effect context
1574 * and add it's required APIs to elm_transit_effect_add.
1575 * @note This effect is applied to each pair of objects in the order they are listed
1576 * in the transit list of objects. The first object in the pair will be the
1577 * "front" object and the second will be the "back" object.
1579 * @see elm_transit_effect_add()
1581 * @param transit Transit object.
1582 * @param axis Flipping Axis(X or Y).
1583 * @param cw Flipping Direction. EINA_TRUE is clock-wise.
1584 * @return Flip effect context data.
1587 * @warning Is higher recommended just create a transit with this effect when
1588 * the window that the objects of the transit belongs has already been created.
1589 * This is because this effect needs the geometry information about the objects,
1590 * and if the window was not created yet, it can get a wrong information.
1592 EAPI Elm_Transit_Effect *
1593 elm_transit_effect_flip_add(Elm_Transit *transit, Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1595 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1596 Elm_Transit_Effect *effect_context = _transit_effect_flip_context_new(axis, cw);
1598 if (!effect_context) return NULL;
1599 elm_transit_effect_add(transit,
1600 _transit_effect_flip_op, effect_context,
1601 _transit_effect_flip_context_free);
1602 return effect_context;
1605 ///////////////////////////////////////////////////////////////////////////////
1606 //ResizableFlip Effect
1607 ///////////////////////////////////////////////////////////////////////////////
1608 typedef struct _Elm_Transit_Effect_Resizable_Flip Elm_Transit_Effect_ResizableFlip;
1609 typedef struct _Elm_Transit_Effect_Resizable_Flip_Node Elm_Transit_Effect_ResizableFlip_Node;
1611 struct _Elm_Transit_Effect_Resizable_Flip_Node
1617 } from_pos, from_size, to_pos, to_size;
1620 struct _Elm_Transit_Effect_Resizable_Flip
1624 Elm_Transit_Effect_Flip_Axis axis;
1628 _resizable_flip_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1630 Elm_Transit_Effect_ResizableFlip *resizable_flip = data;
1632 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1634 EINA_LIST_FOREACH(resizable_flip->nodes, elist, resizable_flip_node)
1636 if (resizable_flip_node->front == obj)
1637 evas_object_event_callback_del(resizable_flip_node->back,
1638 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1639 else if (resizable_flip_node->back == obj)
1640 evas_object_event_callback_del(resizable_flip_node->front,
1641 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1644 resizable_flip->nodes = eina_list_remove_list(resizable_flip->nodes,
1646 free(resizable_flip_node);
1652 _resizable_flip_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_ResizableFlip *resizable_flip)
1654 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1655 Eina_List *data_list = NULL;
1656 Evas_Coord front_x, front_y, front_w, front_h;
1657 Evas_Coord back_x, back_y, back_w, back_h;
1660 count = eina_list_count(transit->objs);
1661 for (i = 0; i < (count - 1); i += 2)
1663 resizable_flip_node = ELM_NEW(Elm_Transit_Effect_ResizableFlip_Node);
1664 if (!resizable_flip_node)
1666 eina_list_free(data_list);
1670 resizable_flip_node->front = eina_list_nth(transit->objs, i);
1671 resizable_flip_node->back = eina_list_nth(transit->objs, i+1);
1673 evas_object_geometry_get(resizable_flip_node->front,
1674 &front_x, &front_y, &front_w, &front_h);
1675 evas_object_geometry_get(resizable_flip_node->back,
1676 &back_x, &back_y, &back_w, &back_h);
1678 resizable_flip_node->from_pos.x = front_x;
1679 resizable_flip_node->from_pos.y = front_y;
1680 resizable_flip_node->to_pos.x = back_x - front_x;
1681 resizable_flip_node->to_pos.y = back_y - front_y;
1683 resizable_flip_node->from_size.x = front_w;
1684 resizable_flip_node->from_size.y = front_h;
1685 resizable_flip_node->to_size.x = back_w - front_w;
1686 resizable_flip_node->to_size.y = back_h - front_h;
1688 data_list = eina_list_append(data_list, resizable_flip_node);
1690 evas_object_event_callback_add(resizable_flip_node->back,
1691 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb, resizable_flip);
1692 evas_object_event_callback_add(resizable_flip_node->front,
1693 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb, resizable_flip);
1700 _set_image_uv_by_axis_y(Evas_Map *map, Elm_Transit_Effect_ResizableFlip_Node *flip, float degree)
1702 if ((degree >= 90) || (degree <= -90))
1704 evas_map_point_image_uv_set(map, 0,
1705 (flip->from_size.x * 2) + flip->to_size.x,
1707 evas_map_point_image_uv_set(map, 1, 0, 0);
1708 evas_map_point_image_uv_set(map, 2, 0,
1709 (flip->from_size.y * 2) + flip->to_size.y);
1710 evas_map_point_image_uv_set(map, 3,
1711 (flip->from_size.x * 2) + flip->to_size.x,
1712 (flip->from_size.y * 2) + flip->to_size.y);
1716 evas_map_point_image_uv_set(map, 0, 0, 0);
1717 evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
1718 evas_map_point_image_uv_set(map, 2, flip->from_size.x,
1720 evas_map_point_image_uv_set(map, 3, 0, flip->from_size.y);
1725 _set_image_uv_by_axis_x(Evas_Map *map, Elm_Transit_Effect_ResizableFlip_Node *flip, float degree)
1727 if ((degree >= 90) || (degree <= -90))
1729 evas_map_point_image_uv_set(map, 0, 0,
1730 (flip->from_size.y * 2) + flip->to_size.y);
1731 evas_map_point_image_uv_set(map, 1,
1732 (flip->from_size.x * 2) + flip->to_size.x,
1733 (flip->from_size.y * 2) + flip->to_size.y);
1734 evas_map_point_image_uv_set(map, 2,
1735 (flip->from_size.x * 2) + flip->to_size.x,
1737 evas_map_point_image_uv_set(map, 3, 0, 0);
1741 evas_map_point_image_uv_set(map, 0, 0, 0);
1742 evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
1743 evas_map_point_image_uv_set(map, 2, flip->from_size.x,
1745 evas_map_point_image_uv_set(map, 3, 0, flip->from_size.y);
1750 _transit_effect_resizable_flip_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
1752 EINA_SAFETY_ON_NULL_RETURN(effect);
1754 Elm_Transit_Effect_ResizableFlip *resizable_flip = effect;
1755 Eina_List *elist, *elist_next;
1756 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1758 EINA_LIST_FOREACH_SAFE(resizable_flip->nodes,
1759 elist, elist_next, resizable_flip_node)
1761 evas_object_map_enable_set(resizable_flip_node->front, EINA_FALSE);
1762 evas_object_map_enable_set(resizable_flip_node->back, EINA_FALSE);
1764 resizable_flip->nodes = eina_list_remove_list(resizable_flip->nodes,
1767 evas_object_event_callback_del(resizable_flip_node->back,
1768 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1769 evas_object_event_callback_del(resizable_flip_node->front,
1770 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1771 free(resizable_flip_node);
1773 free(resizable_flip);
1777 _transit_effect_resizable_flip_op(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__, double progress)
1779 EINA_SAFETY_ON_NULL_RETURN(effect);
1784 Evas_Coord half_w, half_h;
1785 Elm_Transit_Effect_ResizableFlip *resizable_flip = effect;
1786 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1789 map = evas_map_new(4);
1792 if (resizable_flip->cw) degree = (float)(progress * 180);
1793 else degree = (float)(progress * -180);
1795 if (!resizable_flip->nodes)
1796 resizable_flip->nodes = _resizable_flip_nodes_build(transit,
1799 EINA_LIST_FOREACH(resizable_flip->nodes, elist, resizable_flip_node)
1801 if ((degree < 90) && (degree > -90))
1803 obj = resizable_flip_node->front;
1804 if (resizable_flip_node->front != resizable_flip_node->back)
1806 evas_object_hide(resizable_flip_node->back);
1807 evas_object_show(resizable_flip_node->front);
1812 obj = resizable_flip_node->back;
1813 if (resizable_flip_node->front != resizable_flip_node->back)
1815 evas_object_hide(resizable_flip_node->front);
1816 evas_object_show(resizable_flip_node->back);
1820 x = resizable_flip_node->from_pos.x +
1821 (resizable_flip_node->to_pos.x * progress);
1822 y = resizable_flip_node->from_pos.y +
1823 (resizable_flip_node->to_pos.y * progress);
1824 w = resizable_flip_node->from_size.x +
1825 (resizable_flip_node->to_size.x * progress);
1826 h = resizable_flip_node->from_size.y +
1827 (resizable_flip_node->to_size.y * progress);
1828 evas_map_point_coord_set(map, 0, x, y, 0);
1829 evas_map_point_coord_set(map, 1, x + w, y, 0);
1830 evas_map_point_coord_set(map, 2, x + w, y + h, 0);
1831 evas_map_point_coord_set(map, 3, x, y + h, 0);
1833 half_w = (Evas_Coord)(w / 2);
1834 half_h = (Evas_Coord)(h / 2);
1836 if (resizable_flip->axis == ELM_TRANSIT_EFFECT_FLIP_AXIS_Y)
1838 _set_image_uv_by_axis_y(map, resizable_flip_node, degree);
1839 evas_map_util_3d_rotate(map, 0, degree,
1840 0, x + half_w, y + half_h, 0);
1844 _set_image_uv_by_axis_x(map, resizable_flip_node, degree);
1845 evas_map_util_3d_rotate(map, degree, 0,
1846 0, x + half_w, y + half_h, 0);
1849 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, _TRANSIT_FOCAL);
1850 evas_object_map_enable_set(resizable_flip_node->front, EINA_TRUE);
1851 evas_object_map_enable_set(resizable_flip_node->back, EINA_TRUE);
1852 evas_object_map_set(obj, map);
1857 static Elm_Transit_Effect *
1858 _transit_effect_resizable_flip_context_new(Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1860 Elm_Transit_Effect_ResizableFlip *resizable_flip;
1862 resizable_flip = ELM_NEW(Elm_Transit_Effect_ResizableFlip);
1863 if (!resizable_flip) return NULL;
1865 resizable_flip->cw = cw;
1866 resizable_flip->axis = axis;
1868 return resizable_flip;
1872 * Add the Resizable Flip Effect to Elm_Transit.
1874 * @note This API is one of the facades. It creates resizable flip effect context
1875 * and add it's required APIs to elm_transit_effect_add.
1876 * @note This effect is applied to each pair of objects in the order they are listed
1877 * in the transit list of objects. The first object in the pair will be the
1878 * "front" object and the second will be the "back" object.
1880 * @see elm_transit_effect_add()
1882 * @param transit Transit object.
1883 * @param axis Flipping Axis(X or Y).
1884 * @param cw Flipping Direction. EINA_TRUE is clock-wise.
1885 * @return Resizable flip effect context data.
1888 * @warning Is higher recommended just create a transit with this effect when
1889 * the window that the objects of the transit belongs has already been created.
1890 * This is because this effect needs the geometry information about the objects,
1891 * and if the window was not created yet, it can get a wrong information.
1893 EAPI Elm_Transit_Effect *
1894 elm_transit_effect_resizable_flip_add(Elm_Transit *transit, Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1896 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1897 Elm_Transit_Effect *effect_context = _transit_effect_resizable_flip_context_new(axis, cw);
1899 if (!effect_context) return NULL;
1900 elm_transit_effect_add(transit,
1901 _transit_effect_resizable_flip_op, effect_context,
1902 _transit_effect_resizable_flip_context_free);
1903 return effect_context;
1907 ///////////////////////////////////////////////////////////////////////////////
1909 ///////////////////////////////////////////////////////////////////////////////
1910 typedef struct _Elm_Transit_Effect_Wipe Elm_Transit_Effect_Wipe;
1912 struct _Elm_Transit_Effect_Wipe
1914 Elm_Transit_Effect_Wipe_Type type;
1915 Elm_Transit_Effect_Wipe_Dir dir;
1919 _elm_fx_wipe_hide(Evas_Map * map, Elm_Transit_Effect_Wipe_Dir dir, float x, float y, float w, float h, float progress)
1925 case ELM_TRANSIT_EFFECT_WIPE_DIR_LEFT:
1926 w2 = w - (w * progress);
1928 evas_map_point_image_uv_set(map, 0, 0, 0);
1929 evas_map_point_image_uv_set(map, 1, w2, 0);
1930 evas_map_point_image_uv_set(map, 2, w2, h);
1931 evas_map_point_image_uv_set(map, 3, 0, h);
1932 evas_map_point_coord_set(map, 0, x, y, 0);
1933 evas_map_point_coord_set(map, 1, x + w2, y, 0);
1934 evas_map_point_coord_set(map, 2, x + w2, h2, 0);
1935 evas_map_point_coord_set(map, 3, x, h2, 0);
1937 case ELM_TRANSIT_EFFECT_WIPE_DIR_RIGHT:
1938 w2 = (w * progress);
1940 evas_map_point_image_uv_set(map, 0, w2, 0);
1941 evas_map_point_image_uv_set(map, 1, w, 0);
1942 evas_map_point_image_uv_set(map, 2, w, h);
1943 evas_map_point_image_uv_set(map, 3, w2, h);
1944 evas_map_point_coord_set(map, 0, x + w2, y, 0);
1945 evas_map_point_coord_set(map, 1, x + w, y, 0);
1946 evas_map_point_coord_set(map, 2, x + w, h2, 0);
1947 evas_map_point_coord_set(map, 3, x + w2, h2, 0);
1949 case ELM_TRANSIT_EFFECT_WIPE_DIR_UP:
1951 h2 = h - (h * progress);
1952 evas_map_point_image_uv_set(map, 0, 0, 0);
1953 evas_map_point_image_uv_set(map, 1, w, 0);
1954 evas_map_point_image_uv_set(map, 2, w, h2);
1955 evas_map_point_image_uv_set(map, 3, 0, h2);
1956 evas_map_point_coord_set(map, 0, x, y, 0);
1957 evas_map_point_coord_set(map, 1, w2, y, 0);
1958 evas_map_point_coord_set(map, 2, w2, y+h2, 0);
1959 evas_map_point_coord_set(map, 3, x, y+h2, 0);
1961 case ELM_TRANSIT_EFFECT_WIPE_DIR_DOWN:
1963 h2 = (h * progress);
1964 evas_map_point_image_uv_set(map, 0, 0, h2);
1965 evas_map_point_image_uv_set(map, 1, w, h2);
1966 evas_map_point_image_uv_set(map, 2, w, h);
1967 evas_map_point_image_uv_set(map, 3, 0, h);
1968 evas_map_point_coord_set(map, 0, x, y + h2, 0);
1969 evas_map_point_coord_set(map, 1, w2, y + h2, 0);
1970 evas_map_point_coord_set(map, 2, w2, y + h, 0);
1971 evas_map_point_coord_set(map, 3, x, y + h, 0);
1976 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, _TRANSIT_FOCAL);
1980 _elm_fx_wipe_show(Evas_Map *map, Elm_Transit_Effect_Wipe_Dir dir, float x, float y, float w, float h, float progress)
1986 case ELM_TRANSIT_EFFECT_WIPE_DIR_LEFT:
1987 w2 = (w - (w * progress));
1989 evas_map_point_image_uv_set(map, 0, w2, 0);
1990 evas_map_point_image_uv_set(map, 1, w, 0);
1991 evas_map_point_image_uv_set(map, 2, w, h);
1992 evas_map_point_image_uv_set(map, 3, w2, h);
1993 evas_map_point_coord_set(map, 0, x + w2, y, 0);
1994 evas_map_point_coord_set(map, 1, w, y, 0);
1995 evas_map_point_coord_set(map, 2, w, h2, 0);
1996 evas_map_point_coord_set(map, 3, x + w2, h2, 0);
1998 case ELM_TRANSIT_EFFECT_WIPE_DIR_RIGHT:
1999 w2 = (w * progress);
2001 evas_map_point_image_uv_set(map, 0, 0, 0);
2002 evas_map_point_image_uv_set(map, 1, w2, 0);
2003 evas_map_point_image_uv_set(map, 2, w2, h);
2004 evas_map_point_image_uv_set(map, 3, 0, h);
2005 evas_map_point_coord_set(map, 0, x, y, 0);
2006 evas_map_point_coord_set(map, 1, x + w2, y, 0);
2007 evas_map_point_coord_set(map, 2, x + w2, h2, 0);
2008 evas_map_point_coord_set(map, 3, x, h2, 0);
2010 case ELM_TRANSIT_EFFECT_WIPE_DIR_UP:
2012 h2 = (h - (h * progress));
2013 evas_map_point_image_uv_set(map, 0, 0, h2);
2014 evas_map_point_image_uv_set(map, 1, w, h2);
2015 evas_map_point_image_uv_set(map, 2, w, h);
2016 evas_map_point_image_uv_set(map, 3, 0, h);
2017 evas_map_point_coord_set(map, 0, x, y + h2, 0);
2018 evas_map_point_coord_set(map, 1, w2, y + h2, 0);
2019 evas_map_point_coord_set(map, 2, w2, y + h, 0);
2020 evas_map_point_coord_set(map, 3, x, y + h, 0);
2022 case ELM_TRANSIT_EFFECT_WIPE_DIR_DOWN:
2024 h2 = (h * progress);
2025 evas_map_point_image_uv_set(map, 0, 0, 0);
2026 evas_map_point_image_uv_set(map, 1, w, 0);
2027 evas_map_point_image_uv_set(map, 2, w, h2);
2028 evas_map_point_image_uv_set(map, 3, 0, h2);
2029 evas_map_point_coord_set(map, 0, x, y, 0);
2030 evas_map_point_coord_set(map, 1, w2, y, 0);
2031 evas_map_point_coord_set(map, 2, w2, y + h2, 0);
2032 evas_map_point_coord_set(map, 3, x, y + h2, 0);
2037 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, _TRANSIT_FOCAL);
2041 _transit_effect_wipe_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit)
2043 EINA_SAFETY_ON_NULL_RETURN(effect);
2044 EINA_SAFETY_ON_NULL_RETURN(transit);
2047 Elm_Transit_Effect_Wipe *wipe = effect;
2048 Eina_Bool reverse = elm_transit_auto_reverse_get(transit);
2050 EINA_LIST_FOREACH(transit->objs, elist, obj)
2052 if ((wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_SHOW && !reverse)
2053 || (wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_HIDE && reverse))
2054 evas_object_show(obj);
2055 else evas_object_hide(obj);
2056 evas_object_map_enable_set(obj, EINA_FALSE);
2063 _transit_effect_wipe_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2065 EINA_SAFETY_ON_NULL_RETURN(effect);
2066 EINA_SAFETY_ON_NULL_RETURN(transit);
2067 Elm_Transit_Effect_Wipe *wipe = effect;
2069 Evas_Coord _x, _y, _w, _h;
2073 map = evas_map_new(4);
2076 EINA_LIST_FOREACH(transit->objs, elist, obj)
2078 evas_object_geometry_get(obj, &_x, &_y, &_w, &_h);
2080 if (wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_SHOW)
2081 _elm_fx_wipe_show(map, wipe->dir, _x, _y, _w, _h, (float)progress);
2083 _elm_fx_wipe_hide(map, wipe->dir, _x, _y, _w, _h, (float)progress);
2085 evas_object_map_enable_set(obj, EINA_TRUE);
2086 evas_object_map_set(obj, map);
2091 static Elm_Transit_Effect *
2092 _transit_effect_wipe_context_new(Elm_Transit_Effect_Wipe_Type type, Elm_Transit_Effect_Wipe_Dir dir)
2094 Elm_Transit_Effect_Wipe *wipe;
2096 wipe = ELM_NEW(Elm_Transit_Effect_Wipe);
2097 if (!wipe) return NULL;
2106 * Add the Wipe Effect to Elm_Transit.
2108 * @note This API is one of the facades. It creates wipe effect context
2109 * and add it's required APIs to elm_transit_effect_add.
2111 * @see elm_transit_effect_add()
2113 * @param transit Transit object.
2114 * @param type Wipe type. Hide or show.
2115 * @param dir Wipe Direction.
2116 * @return Wipe effect context data.
2119 * @warning Is higher recommended just create a transit with this effect when
2120 * the window that the objects of the transit belongs has already been created.
2121 * This is because this effect needs the geometry information about the objects,
2122 * and if the window was not created yet, it can get a wrong information.
2125 elm_transit_effect_wipe_add(Elm_Transit *transit, Elm_Transit_Effect_Wipe_Type type, Elm_Transit_Effect_Wipe_Dir dir)
2127 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2128 void *effect_context = _transit_effect_wipe_context_new(type, dir);
2130 if (!effect_context) return NULL;
2131 elm_transit_effect_add(transit,
2132 _transit_effect_wipe_op, effect_context,
2133 _transit_effect_wipe_context_free);
2134 return effect_context;
2138 ///////////////////////////////////////////////////////////////////////////////
2140 ///////////////////////////////////////////////////////////////////////////////
2141 typedef struct _Elm_Transit_Effect_Color Elm_Transit_Effect_Color;
2143 struct _Elm_Transit_Effect_Color
2145 struct _unsigned_color {
2146 unsigned int r, g, b, a;
2148 struct _signed_color {
2154 _transit_effect_color_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
2156 Elm_Transit_Effect_Color *color = effect;
2161 _transit_effect_color_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2163 EINA_SAFETY_ON_NULL_RETURN(effect);
2164 EINA_SAFETY_ON_NULL_RETURN(transit);
2165 Elm_Transit_Effect_Color *color = effect;
2168 unsigned int r, g, b, a;
2170 r = (color->from.r + (int)((float)color->to.r * progress));
2171 g = (color->from.g + (int)((float)color->to.g * progress));
2172 b = (color->from.b + (int)((float)color->to.b * progress));
2173 a = (color->from.a + (int)((float)color->to.a * progress));
2175 EINA_LIST_FOREACH(transit->objs, elist, obj)
2176 evas_object_color_set(obj, r, g, b, a);
2179 static Elm_Transit_Effect *
2180 _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)
2182 Elm_Transit_Effect_Color *color;
2184 color = ELM_NEW(Elm_Transit_Effect_Color);
2185 if (!color) return NULL;
2187 color->from.r = from_r;
2188 color->from.g = from_g;
2189 color->from.b = from_b;
2190 color->from.a = from_a;
2191 color->to.r = to_r - from_r;
2192 color->to.g = to_g - from_g;
2193 color->to.b = to_b - from_b;
2194 color->to.a = to_a - from_a;
2200 * Add the Color Effect to Elm_Transit.
2202 * @note This API is one of the facades. It creates color effect context
2203 * and add it's required APIs to elm_transit_effect_add.
2205 * @see elm_transit_effect_add()
2207 * @param transit Transit object.
2208 * @param from_r RGB R when effect begins.
2209 * @param from_g RGB G when effect begins.
2210 * @param from_b RGB B when effect begins.
2211 * @param from_a RGB A when effect begins.
2212 * @param to_r RGB R when effect ends.
2213 * @param to_g RGB G when effect ends.
2214 * @param to_b RGB B when effect ends.
2215 * @param to_a RGB A when effect ends.
2216 * @return Color effect context data.
2220 EAPI Elm_Transit_Effect *
2221 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)
2223 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2224 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);
2226 if (!effect_context) return NULL;
2227 elm_transit_effect_add(transit,
2228 _transit_effect_color_op, effect_context,
2229 _transit_effect_color_context_free);
2230 return effect_context;
2233 ///////////////////////////////////////////////////////////////////////////////
2235 ///////////////////////////////////////////////////////////////////////////////
2236 typedef struct _Elm_Transit_Effect_Fade Elm_Transit_Effect_Fade;
2237 typedef struct _Elm_Transit_Effect_Fade_Node Elm_Transit_Effect_Fade_Node;
2239 struct _Elm_Transit_Effect_Fade_Node
2241 Evas_Object *before;
2243 struct _signed_color before_color, after_color;
2246 Eina_Bool inversed : 1;
2249 struct _Elm_Transit_Effect_Fade
2255 _fade_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2257 Elm_Transit_Effect_Fade *fade = data;
2259 Elm_Transit_Effect_Fade_Node *fade_node;
2261 EINA_LIST_FOREACH(fade->nodes, elist, fade_node)
2263 if (fade_node->before == obj)
2264 evas_object_event_callback_del(fade_node->after,
2265 EVAS_CALLBACK_DEL, _fade_object_del_cb);
2266 else if (fade_node->after == obj)
2267 evas_object_event_callback_del(fade_node->before,
2268 EVAS_CALLBACK_DEL, _fade_object_del_cb);
2271 fade->nodes = eina_list_remove_list(fade->nodes, elist);
2278 _fade_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Fade *fade_data)
2280 Elm_Transit_Effect_Fade_Node *fade;
2281 Eina_List *data_list = NULL;
2284 count = eina_list_count(transit->objs);
2285 for (i = 0; i < count; i += 2)
2287 fade = ELM_NEW(Elm_Transit_Effect_Fade_Node);
2290 eina_list_free(data_list);
2294 fade->before = eina_list_nth(transit->objs, i);
2295 fade->after = eina_list_nth(transit->objs, i+1);
2297 evas_object_color_get(fade->before,
2298 &fade->before_color.r, &fade->before_color.g,
2299 &fade->before_color.b, &fade->before_color.a);
2300 evas_object_color_get(fade->after,
2301 &fade->after_color.r, &fade->after_color.g,
2302 &fade->after_color.b, &fade->after_color.a);
2304 fade->before_alpha = (255 - fade->before_color.a);
2305 fade->after_alpha = (255 - fade->after_color.a);
2307 data_list = eina_list_append(data_list, fade);
2309 evas_object_event_callback_add(fade->before,
2310 EVAS_CALLBACK_DEL, _fade_object_del_cb, fade_data);
2311 evas_object_event_callback_add(fade->after,
2312 EVAS_CALLBACK_DEL, _fade_object_del_cb, fade_data);
2318 _transit_effect_fade_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
2320 EINA_SAFETY_ON_NULL_RETURN(effect);
2321 Elm_Transit_Effect_Fade *fade = effect;
2322 Elm_Transit_Effect_Fade_Node *fade_node;
2323 Eina_List *elist, *elist_next;
2325 EINA_LIST_FOREACH_SAFE(fade->nodes, elist, elist_next, fade_node)
2327 evas_object_color_set(fade_node->before, fade_node->before_color.r,
2328 fade_node->before_color.g,
2329 fade_node->before_color.b,
2330 fade_node->before_color.a);
2331 evas_object_color_set(fade_node->after, fade_node->after_color.r,
2332 fade_node->after_color.g,
2333 fade_node->after_color.b,
2334 fade_node->after_color.a);
2336 fade->nodes = eina_list_remove_list(fade->nodes, elist);
2337 evas_object_event_callback_del(fade_node->before,
2338 EVAS_CALLBACK_DEL, _fade_object_del_cb);
2339 evas_object_event_callback_del(fade_node->after,
2340 EVAS_CALLBACK_DEL, _fade_object_del_cb);
2348 _transit_effect_fade_op(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__, double progress)
2350 EINA_SAFETY_ON_NULL_RETURN(effect);
2351 Elm_Transit_Effect_Fade *fade = effect;
2353 Elm_Transit_Effect_Fade_Node *fade_node;
2357 fade->nodes = _fade_nodes_build(transit, fade);
2359 EINA_LIST_FOREACH(fade->nodes, elist, fade_node)
2363 if (!fade_node->inversed)
2365 evas_object_hide(fade_node->after);
2366 evas_object_show(fade_node->before);
2367 fade_node->inversed = EINA_TRUE;
2370 _progress = (1 - (progress * 2));
2372 evas_object_color_set(fade_node->before,
2373 fade_node->before_color.r * _progress,
2374 fade_node->before_color.g * _progress,
2375 fade_node->before_color.b * _progress,
2376 fade_node->before_color.a +
2377 fade_node->before_alpha * (1 - _progress));
2381 if (fade_node->inversed)
2383 evas_object_hide(fade_node->before);
2384 evas_object_show(fade_node->after);
2385 fade_node->inversed = EINA_FALSE;
2388 _progress = ((progress - 0.5) * 2);
2390 evas_object_color_set(fade_node->after,
2391 fade_node->after_color.r * _progress,
2392 fade_node->after_color.g * _progress,
2393 fade_node->after_color.b * _progress,
2394 fade_node->after_color.a +
2395 fade_node->after_alpha * (1 - _progress));
2400 static Elm_Transit_Effect *
2401 _transit_effect_fade_context_new(void)
2403 Elm_Transit_Effect_Fade *fade;
2404 fade = ELM_NEW(Elm_Transit_Effect_Fade);
2405 if (!fade) return NULL;
2410 * Add the Fade Effect to Elm_Transit.
2412 * @note This API is one of the facades. It creates fade effect context
2413 * and add it's required APIs to elm_transit_effect_add.
2414 * @note This effect is applied to each pair of objects in the order they are listed
2415 * in the transit list of objects. The first object in the pair will be the
2416 * "before" object and the second will be the "after" object.
2418 * @see elm_transit_effect_add()
2420 * @param transit Transit object.
2421 * @return Fade effect context data.
2424 * @warning Is higher recommended just create a transit with this effect when
2425 * the window that the objects of the transit belongs has already been created.
2426 * This is because this effect needs the color information about the objects,
2427 * and if the window was not created yet, it can get a wrong information.
2429 EAPI Elm_Transit_Effect *
2430 elm_transit_effect_fade_add(Elm_Transit *transit)
2432 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2434 Elm_Transit_Effect *effect_context = _transit_effect_fade_context_new();
2435 if (!effect_context) return NULL;
2436 elm_transit_effect_add(transit,
2437 _transit_effect_fade_op, effect_context,
2438 _transit_effect_fade_context_free);
2439 return effect_context;
2443 ///////////////////////////////////////////////////////////////////////////////
2445 ///////////////////////////////////////////////////////////////////////////////
2446 typedef struct _Elm_Transit_Effect_Blend Elm_Transit_Effect_Blend;
2447 typedef struct _Elm_Transit_Effect_Blend_Node Elm_Transit_Effect_Blend_Node;
2449 struct _Elm_Transit_Effect_Blend_Node
2451 Evas_Object *before;
2453 struct _signed_color from, to;
2456 struct _Elm_Transit_Effect_Blend
2462 _blend_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2464 Elm_Transit_Effect_Blend *blend = data;
2466 Elm_Transit_Effect_Blend_Node *blend_node;
2468 EINA_LIST_FOREACH(blend->nodes, elist, blend_node)
2470 if (blend_node->after == obj)
2471 evas_object_event_callback_del(blend_node->before,
2472 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2473 else if (blend_node->before == obj)
2474 evas_object_event_callback_del(blend_node->after,
2475 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2478 blend->nodes = eina_list_remove_list(blend->nodes, elist);
2485 _blend_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Blend *blend)
2487 Elm_Transit_Effect_Blend_Node *blend_node;
2488 Eina_List *data_list = NULL;
2491 count = eina_list_count(transit->objs);
2492 for (i = 0; i < (count - 1); i += 2)
2494 blend_node = ELM_NEW(Elm_Transit_Effect_Blend_Node);
2497 eina_list_free(data_list);
2501 blend_node->before = eina_list_nth(transit->objs, i);
2502 blend_node->after = eina_list_nth(transit->objs, i + 1);
2503 evas_object_show(blend_node->before);
2504 evas_object_show(blend_node->after);
2506 evas_object_color_get(blend_node->before, &blend_node->from.r,
2507 &blend_node->from.g, &blend_node->from.b,
2508 &blend_node->from.a);
2509 evas_object_color_get(blend_node->after, &blend_node->to.r,
2510 &blend_node->to.g, &blend_node->to.b,
2513 data_list = eina_list_append(data_list, blend_node);
2515 evas_object_event_callback_add(blend_node->before,
2516 EVAS_CALLBACK_DEL, _blend_object_del_cb, blend);
2517 evas_object_event_callback_add(blend_node->after,
2518 EVAS_CALLBACK_DEL, _blend_object_del_cb, blend);
2524 _transit_effect_blend_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
2526 EINA_SAFETY_ON_NULL_RETURN(effect);
2527 Elm_Transit_Effect_Blend *blend = effect;
2528 Elm_Transit_Effect_Blend_Node *blend_node;
2529 Eina_List *elist, *elist_next;
2531 EINA_LIST_FOREACH_SAFE(blend->nodes, elist, elist_next, blend_node)
2533 evas_object_color_set(blend_node->before,
2534 blend_node->from.r, blend_node->from.g,
2535 blend_node->from.b, blend_node->from.a);
2536 evas_object_color_set(blend_node->after, blend_node->to.r,
2537 blend_node->to.g, blend_node->to.b,
2540 if (elm_transit_auto_reverse_get(transit))
2541 evas_object_hide(blend_node->after);
2543 evas_object_hide(blend_node->before);
2545 blend->nodes = eina_list_remove_list(blend->nodes, elist);
2547 evas_object_event_callback_del(blend_node->before,
2548 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2549 evas_object_event_callback_del(blend_node->after,
2550 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2557 _transit_effect_blend_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2559 EINA_SAFETY_ON_NULL_RETURN(effect);
2560 EINA_SAFETY_ON_NULL_RETURN(transit);
2561 Elm_Transit_Effect_Blend *blend = effect;
2562 Elm_Transit_Effect_Blend_Node *blend_node;
2565 if (!blend->nodes) blend->nodes = _blend_nodes_build(transit, blend);
2567 EINA_LIST_FOREACH(blend->nodes, elist, blend_node)
2569 evas_object_color_set(blend_node->before,
2570 (int)(blend_node->from.r * (1 - progress)),
2571 (int)(blend_node->from.g * (1 - progress)),
2572 (int)(blend_node->from.b * (1 - progress)),
2573 (int)(blend_node->from.a * (1 - progress)));
2574 evas_object_color_set(blend_node->after,
2575 (int)(blend_node->to.r * progress),
2576 (int)(blend_node->to.g * progress),
2577 (int)(blend_node->to.b * progress),
2578 (int)(blend_node->to.a * progress));
2582 static Elm_Transit_Effect *
2583 _transit_effect_blend_context_new(void)
2585 Elm_Transit_Effect_Blend *blend;
2587 blend = ELM_NEW(Elm_Transit_Effect_Blend);
2588 if (!blend) return NULL;
2593 * Add the Blend Effect to Elm_Transit.
2595 * @note This API is one of the facades. It creates blend effect context
2596 * and add it's required APIs to elm_transit_effect_add.
2597 * @note This effect is applied to each pair of objects in the order they are listed
2598 * in the transit list of objects. The first object in the pair will be the
2599 * "before" object and the second will be the "after" object.
2601 * @see elm_transit_effect_add()
2603 * @param transit Transit object.
2604 * @return Blend effect context data.
2607 * @warning Is higher recommended just create a transit with this effect when
2608 * the window that the objects of the transit belongs has already been created.
2609 * This is because this effect needs the color information about the objects,
2610 * and if the window was not created yet, it can get a wrong information.
2612 EAPI Elm_Transit_Effect *
2613 elm_transit_effect_blend_add(Elm_Transit *transit)
2615 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2616 Elm_Transit_Effect *effect_context = _transit_effect_blend_context_new();
2618 if (!effect_context) return NULL;
2619 elm_transit_effect_add(transit,
2620 _transit_effect_blend_op, effect_context,
2621 _transit_effect_blend_context_free);
2622 return effect_context;
2626 ///////////////////////////////////////////////////////////////////////////////
2628 ///////////////////////////////////////////////////////////////////////////////
2629 typedef struct _Elm_Transit_Effect_Rotation Elm_Transit_Effect_Rotation;
2631 struct _Elm_Transit_Effect_Rotation
2637 _transit_effect_rotation_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
2639 Elm_Transit_Effect_Rotation *rotation = effect;
2644 _transit_effect_rotation_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2646 EINA_SAFETY_ON_NULL_RETURN(effect);
2647 EINA_SAFETY_ON_NULL_RETURN(transit);
2648 Elm_Transit_Effect_Rotation *rotation = effect;
2650 Evas_Coord x, y, w, h;
2652 float half_w, half_h;
2656 map = evas_map_new(4);
2659 EINA_LIST_FOREACH(transit->objs, elist, obj)
2661 evas_map_util_points_populate_from_object_full(map, obj, 0);
2662 degree = rotation->from + (float)(progress * rotation->to);
2664 evas_object_geometry_get(obj, &x, &y, &w, &h);
2666 half_w = (float)w * 0.5;
2667 half_h = (float)h * 0.5;
2669 evas_map_util_3d_rotate(map, 0, 0, degree, x + half_w, y + half_h, 0);
2670 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, _TRANSIT_FOCAL);
2671 evas_object_map_enable_set(obj, EINA_TRUE);
2672 evas_object_map_set(obj, map);
2677 static Elm_Transit_Effect *
2678 _transit_effect_rotation_context_new(float from_degree, float to_degree)
2680 Elm_Transit_Effect_Rotation *rotation;
2682 rotation = ELM_NEW(Elm_Transit_Effect_Rotation);
2683 if (!rotation) return NULL;
2685 rotation->from = from_degree;
2686 rotation->to = to_degree - from_degree;
2692 * Add the Rotation Effect to Elm_Transit.
2694 * @note This API is one of the facades. It creates rotation effect context
2695 * and add it's required APIs to elm_transit_effect_add.
2697 * @see elm_transit_effect_add()
2699 * @param transit Transit object.
2700 * @param from_degree Degree when effect begins.
2701 * @param to_degree Degree when effect is ends.
2702 * @return Rotation effect context data.
2705 * @warning Is higher recommended just create a transit with this effect when
2706 * the window that the objects of the transit belongs has already been created.
2707 * This is because this effect needs the geometry information about the objects,
2708 * and if the window was not created yet, it can get a wrong information.
2710 EAPI Elm_Transit_Effect *
2711 elm_transit_effect_rotation_add(Elm_Transit *transit, float from_degree, float to_degree)
2713 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2714 Elm_Transit_Effect *effect_context = _transit_effect_rotation_context_new(from_degree, to_degree);
2716 if (!effect_context) return NULL;
2717 elm_transit_effect_add(transit,
2718 _transit_effect_rotation_op, effect_context,
2719 _transit_effect_rotation_context_free);
2720 return effect_context;
2724 ///////////////////////////////////////////////////////////////////////////////
2725 //ImageAnimation Effect
2726 ///////////////////////////////////////////////////////////////////////////////
2727 typedef struct _Elm_Transit_Effect_Image_Animation Elm_Transit_Effect_Image_Animation;
2729 struct _Elm_Transit_Effect_Image_Animation
2735 _transit_effect_image_animation_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
2737 EINA_SAFETY_ON_NULL_RETURN(effect);
2738 Elm_Transit_Effect_Image_Animation *image_animation = effect;
2740 Eina_List *elist, *elist_next;
2742 EINA_LIST_FOREACH_SAFE(image_animation->images, elist, elist_next, image)
2744 image_animation->images =
2745 eina_list_remove_list(image_animation->images, elist);
2746 eina_stringshare_del(image);
2749 free(image_animation);
2753 _transit_effect_image_animation_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2755 EINA_SAFETY_ON_NULL_RETURN(effect);
2756 EINA_SAFETY_ON_NULL_RETURN(transit);
2760 Elm_Transit_Effect_Image_Animation *image_animation = effect;
2761 unsigned int count = 0;
2764 type = eina_stringshare_add("icon");
2765 len = eina_list_count(image_animation->images);
2767 if (!len) count = floor(progress * len);
2768 else count = floor(progress * (len - 1));
2770 EINA_LIST_FOREACH(transit->objs, elist, obj)
2772 if (elm_widget_type_check(obj, type))
2773 elm_icon_file_set(obj,
2774 eina_list_nth(image_animation->images, count), NULL);
2777 eina_stringshare_del(type);
2780 static Elm_Transit_Effect *
2781 _transit_effect_image_animation_context_new(Eina_List *images)
2783 Elm_Transit_Effect_Image_Animation *image_animation;
2784 image_animation = ELM_NEW(Elm_Transit_Effect_Image_Animation);
2786 if (!image_animation) return NULL;
2787 image_animation->images = images;
2788 return image_animation;
2792 * Add the ImageAnimation Effect to Elm_Transit.
2794 * @note This API is one of the facades. It creates image animation effect context
2795 * and add it's required APIs to elm_transit_effect_add.
2796 * The @p images parameter is a list images paths. This list and
2797 * its contents will be deleted at the end of the effect by
2798 * elm_transit_effect_image_animation_context_free() function.
2802 * char buf[PATH_MAX];
2803 * Eina_List *images = NULL;
2804 * Elm_Transit *transi = elm_transit_add();
2806 * snprintf(buf, sizeof(buf), "%s/images/icon_11.png", PACKAGE_DATA_DIR);
2807 * images = eina_list_append(images, eina_stringshare_add(buf));
2809 * snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
2810 * images = eina_list_append(images, eina_stringshare_add(buf));
2811 * elm_transit_effect_image_animation_add(transi, images);
2815 * @see elm_transit_effect_add()
2817 * @param transit Transit object.
2818 * @param images Eina_List of images file paths. This list and
2819 * its contents will be deleted at the end of the effect by
2820 * elm_transit_effect_image_animation_context_free() function.
2821 * @return Image Animation effect context data.
2825 EAPI Elm_Transit_Effect *
2826 elm_transit_effect_image_animation_add(Elm_Transit *transit, Eina_List *images)
2828 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2829 Elm_Transit_Effect *effect = _transit_effect_image_animation_context_new(images);
2831 if (!effect) return NULL;
2832 elm_transit_effect_add(transit,
2833 _transit_effect_image_animation_op, effect,
2834 _transit_effect_image_animation_context_free);