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 Elm_Transit *prev_chain_transit;
62 Eina_List *next_chain_transits;
63 Elm_Transit_Tween_Mode tween_mode;
65 Elm_Transit_Effect_End_Cb func;
81 unsigned int effects_pending_del;
83 Eina_Bool auto_reverse : 1;
84 Eina_Bool event_enabled : 1;
85 Eina_Bool deleted : 1;
86 Eina_Bool state_keep : 1;
89 struct _Elm_Transit_Effect_Module
92 Elm_Transit_Effect_Transition_Cb transition_cb;
93 Elm_Transit_Effect_End_Cb end_cb;
94 Elm_Transit_Effect *effect;
95 Eina_Bool deleted : 1;
98 struct _Elm_Transit_Obj_State
100 Evas_Coord x, y, w, h;
103 Eina_Bool map_enabled : 1;
104 Eina_Bool visible : 1;
107 struct _Elm_Transit_Obj_Data
109 struct _Elm_Transit_Obj_State *state;
110 Eina_Bool pass_events : 1;
113 typedef struct _Elm_Transit_Effect_Module Elm_Transit_Effect_Module;
114 typedef struct _Elm_Transit_Obj_Data Elm_Transit_Obj_Data;
115 typedef struct _Elm_Transit_Obj_State Elm_Transit_Obj_State;
117 static void _elm_transit_obj_data_update(Elm_Transit *transit, Evas_Object *obj);
118 static void _elm_transit_obj_data_recover(Elm_Transit *transit, Evas_Object *obj);
119 static void _elm_transit_obj_states_save(Evas_Object *obj, Elm_Transit_Obj_Data *obj_data);
120 static void _elm_transit_obj_remove_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__);
121 static void _obj_damage_area_set(Evas_Object *obj);
122 static void _elm_transit_obj_remove(Elm_Transit *transit, Evas_Object *obj);
123 static void _elm_transit_effect_del(Elm_Transit *transit, Elm_Transit_Effect_Module *effect_module);
124 static void _remove_dead_effects(Elm_Transit *transit);
125 static void _elm_transit_del(Elm_Transit *transit);
126 static void _chain_transits_go(Elm_Transit *transit);
127 static void _transit_animate_op(Elm_Transit *transit, double progress);
128 static Eina_Bool _animator_animate_cb(void *data);
130 static char *_transit_key= "_elm_transit_key";
133 _elm_transit_obj_data_update(Elm_Transit *transit, Evas_Object *obj)
135 Elm_Transit_Obj_Data *obj_data = evas_object_data_get(obj, _transit_key);
138 obj_data = ELM_NEW(Elm_Transit_Obj_Data);
140 obj_data->pass_events = evas_object_pass_events_get(obj);
142 if ((!transit->state_keep) && (obj_data->state))
144 free(obj_data->state);
145 obj_data->state = NULL;
149 _elm_transit_obj_states_save(obj, obj_data);
152 evas_object_data_set(obj, _transit_key, obj_data);
156 _elm_transit_obj_states_save(Evas_Object *obj, Elm_Transit_Obj_Data *obj_data)
158 Elm_Transit_Obj_State *state = obj_data->state;
161 state = calloc(1, sizeof(Elm_Transit_Obj_State));
164 evas_object_geometry_get(obj, &state->x, &state->y, &state->w, &state->h);
165 evas_object_color_get(obj, &state->r, &state->g, &state->b, &state->a);
166 state->visible = evas_object_visible_get(obj);
167 state->map_enabled = evas_object_map_enable_get(obj);
168 if (evas_object_map_get(obj))
169 state->map = evas_map_dup(evas_object_map_get(obj));
170 obj_data->state = state;
174 _remove_obj_from_list(Elm_Transit *transit, Evas_Object *obj)
176 //Remove duplicated objects
177 //TODO: Need to consider about optimizing here
180 if (!eina_list_data_find_list(transit->objs, obj))
182 transit->objs = eina_list_remove(transit->objs, obj);
183 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_DEL,
184 _elm_transit_obj_remove_cb,
190 _elm_transit_obj_remove_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
192 Elm_Transit *transit = data;
193 Elm_Transit_Obj_Data *obj_data = evas_object_data_get(obj, _transit_key);
197 free(obj_data->state);
200 _remove_obj_from_list(transit, obj);
201 if (!transit->objs) elm_transit_del(transit);
205 //Since evas map have a afterimage bug for this time.
206 //This function is added temporary.
208 _obj_damage_area_set(Evas_Object *obj)
211 Evas_Coord_Point coords;
212 Evas_Coord_Point min, max;
215 map = evas_object_map_get(obj);
218 evas_map_point_coord_get(map, 0, &coords.x, &coords.y, NULL);
222 for (i = 1; i < 4; ++i)
224 evas_map_point_coord_get(map, i, &coords.x, &coords.y, NULL);
226 if (coords.x < min.x)
228 else if (coords.x > max.x)
231 if (coords.y < min.y)
233 else if (coords.y > max.y)
237 evas_damage_rectangle_add(evas_object_evas_get(obj),
239 max.x - min.x, max.y - min.y);
243 _elm_transit_obj_data_recover(Elm_Transit *transit, Evas_Object *obj)
245 Elm_Transit_Obj_Data *obj_data;
246 Elm_Transit_Obj_State *state;
248 obj_data = evas_object_data_get(obj, _transit_key);
249 if (!obj_data) return;
250 evas_object_data_del(obj, _transit_key);
251 evas_object_pass_events_set(obj, obj_data->pass_events);
252 state = obj_data->state;
255 //recover the states of the object.
256 if (!transit->state_keep)
258 evas_object_move(obj, state->x, state->y);
259 evas_object_resize(obj, state->w, state->h);
260 evas_object_color_set(obj, state->r, state->g, state->b, state->a);
261 if (state->visible) evas_object_show(obj);
262 else evas_object_hide(obj);
263 if (state->map_enabled)
264 evas_object_map_enable_set(obj, EINA_TRUE);
266 evas_object_map_enable_set(obj, EINA_FALSE);
268 evas_object_map_set(obj, state->map);
271 //Since evas map have a afterimage bug for this time.
272 //This line is added temporary.
273 _obj_damage_area_set(obj);
282 _elm_transit_obj_remove(Elm_Transit *transit, Evas_Object *obj)
284 _remove_obj_from_list(transit, obj);
285 _elm_transit_obj_data_recover(transit, obj);
289 _elm_transit_effect_del(Elm_Transit *transit, Elm_Transit_Effect_Module *effect_module)
291 if (effect_module->end_cb)
292 effect_module->end_cb(effect_module->effect, transit);
297 _remove_dead_effects(Elm_Transit *transit)
299 Elm_Transit_Effect_Module *effect_module;
301 EINA_INLIST_FOREACH(transit->effect_list, effect_module)
303 if (effect_module->deleted)
305 _elm_transit_effect_del(transit, effect_module);
306 transit->effects_pending_del--;
307 if (!transit->effects_pending_del) return;
313 _elm_transit_del(Elm_Transit *transit)
315 Elm_Transit_Effect_Module *effect_module;
316 Elm_Transit *chain_transit;
317 Eina_List *elist, *elist_next;
319 EINA_LIST_FOREACH_SAFE(transit->next_chain_transits, elist, elist_next, chain_transit)
321 if (transit->prev_chain_transit)
322 transit->prev_chain_transit->next_chain_transits = eina_list_remove(transit->prev_chain_transit->next_chain_transits, transit);
323 chain_transit->prev_chain_transit = NULL;
326 eina_list_free(transit->next_chain_transits);
328 if (transit->animator)
329 ecore_animator_del(transit->animator);
331 while (transit->effect_list)
333 effect_module = EINA_INLIST_CONTAINER_GET(transit->effect_list, Elm_Transit_Effect_Module);
334 transit->effect_list = eina_inlist_remove(transit->effect_list, transit->effect_list);
335 _elm_transit_effect_del(transit, effect_module);
338 while (transit->objs)
339 _elm_transit_obj_remove(transit, eina_list_data_get(transit->objs));
341 transit->deleted = EINA_TRUE;
343 if (transit->del_data.func)
344 transit->del_data.func(transit->del_data.arg, transit);
346 EINA_MAGIC_SET(transit, EINA_MAGIC_NONE);
351 _chain_transits_go(Elm_Transit *transit)
353 Eina_List *elist, *elist_next;
354 Elm_Transit *chain_transit;
357 EINA_LIST_FOREACH(transit->objs, elist, obj)
358 _elm_transit_obj_data_recover(transit, obj);
360 EINA_LIST_FOREACH_SAFE(transit->next_chain_transits, elist, elist_next, chain_transit)
361 elm_transit_go(chain_transit);
365 _transit_animate_op(Elm_Transit *transit, double progress)
367 Elm_Transit_Effect_Module *effect_module;
370 EINA_INLIST_FOREACH(transit->effect_list, effect_module)
372 if (transit->deleted) break;
373 if (!effect_module->deleted)
374 effect_module->transition_cb(effect_module->effect, transit, progress);
378 if (transit->walking) return;
380 if (transit->deleted) _elm_transit_del(transit);
381 else if (transit->effects_pending_del) _remove_dead_effects(transit);
385 _animator_animate_cb(void *data)
387 Elm_Transit *transit = data;
388 double elapsed_time, duration;
390 transit->time.current = ecore_loop_time_get();
391 elapsed_time = transit->time.current - transit->time.begin;
392 duration = transit->time.duration + transit->time.delayed;
394 if (elapsed_time > duration)
395 elapsed_time = duration;
397 transit->progress = elapsed_time / duration;
398 switch (transit->tween_mode)
400 case ELM_TRANSIT_TWEEN_MODE_ACCELERATE:
401 transit->progress = 1.0 - sin((ELM_PI / 2.0) + (transit->progress * ELM_PI / 2.0));
403 case ELM_TRANSIT_TWEEN_MODE_DECELERATE:
404 transit->progress = sin(transit->progress * ELM_PI / 2.0);
406 case ELM_TRANSIT_TWEEN_MODE_SINUSOIDAL:
407 transit->progress = (1.0 - cos(transit->progress * ELM_PI)) / 2.0;
414 if (transit->repeat.reverse) transit->progress = 1 - transit->progress;
416 if (transit->time.duration > 0) _transit_animate_op(transit, transit->progress);
418 /* Not end. Keep going. */
419 if (elapsed_time < duration) return ECORE_CALLBACK_RENEW;
421 /* Repeat and reverse and time done! */
422 if ((transit->repeat.count >= 0) &&
423 (transit->repeat.current == transit->repeat.count) &&
424 ((!transit->auto_reverse) || transit->repeat.reverse))
426 /* run chain transit */
427 if (transit->next_chain_transits)
428 _chain_transits_go(transit);
430 elm_transit_del(transit);
431 return ECORE_CALLBACK_CANCEL;
435 if (!transit->auto_reverse || transit->repeat.reverse)
437 transit->repeat.current++;
438 transit->repeat.reverse = EINA_FALSE;
440 else transit->repeat.reverse = EINA_TRUE;
442 transit->time.begin = ecore_loop_time_get();
444 return ECORE_CALLBACK_RENEW;
450 * @note Is not necessary to delete the transit object, it will be deleted at
451 * the end of its operation.
452 * @note The transit will start playing when the program enter in the main loop, is not
453 * necessary to give a start to the transit.
455 * @param duration The duration of the transit in seconds. When transit starts
456 * to run, it will last a @p duration time.
457 * @return The transit object.
462 elm_transit_add(void)
464 Elm_Transit *transit = ELM_NEW(Elm_Transit);
465 if (!transit) return NULL;
467 EINA_MAGIC_SET(transit, ELM_TRANSIT_MAGIC);
469 elm_transit_tween_mode_set(transit, ELM_TRANSIT_TWEEN_MODE_LINEAR);
475 * Stops the animation and delete the @p transit object.
477 * Call this function if you wants to stop the animation before the duration
478 * time. Make sure the @p transit object is still alive with
479 * elm_transit_del_cb_set() function.
480 * All added effects will be deleted, calling its repective data_free_cb
481 * functions. The function setted by elm_transit_del_cb_set() will be called.
483 * @see elm_transit_del_cb_set()
485 * @param transit The transit object to be deleted.
488 * @warning Just call this function if you are sure the transit is alive.
491 elm_transit_del(Elm_Transit *transit)
493 ELM_TRANSIT_CHECK_OR_RETURN(transit);
495 if (transit->walking) transit->deleted = EINA_TRUE;
496 else _elm_transit_del(transit);
500 * Add a new effect to the transit.
502 * @note The cb function and the data are the key to the effect. If you try to
503 * add an already added effect, nothing is done.
504 * @note After the first addition of an effect in @p transit, if its
505 * effect list become empty again, the @p transit will be killed by
506 * elm_transit_del(transit) function.
510 * Elm_Transit *transit = elm_transit_add();
511 * elm_transit_effect_add(transit,
512 * elm_transit_effect_blend_op,
513 * elm_transit_effect_blend_context_new(),
514 * elm_transit_effect_blend_context_free);
517 * @param transit The transit object.
518 * @param cb The operation function. It is called when the animation begins,
519 * it is the function that actually performs the animation. It is called with
520 * the @p data, @p transit and the time progression of the animation (a double
521 * value between 0.0 and 1.0).
522 * @param data The context data of the effect.
523 * @param data_free_cb The function to free the context data, it will be called
524 * at the end of the effect, it must finalize the animation and free the
528 * @warning The transit free the context data at the and of the transition with
529 * the data_free_cb function, do not use the context data in another transit.
532 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)
534 ELM_TRANSIT_CHECK_OR_RETURN(transit);
535 EINA_SAFETY_ON_NULL_RETURN(transition_cb);
536 Elm_Transit_Effect_Module *effect_module;
538 EINA_INLIST_FOREACH(transit->effect_list, effect_module)
539 if ((effect_module->transition_cb == transition_cb) && (effect_module->effect == effect)) return;
541 effect_module = ELM_NEW(Elm_Transit_Effect_Module);
542 if (!effect_module) return;
544 effect_module->end_cb = end_cb;
545 effect_module->transition_cb = transition_cb;
546 effect_module->effect = effect;
548 transit->effect_list = eina_inlist_append(transit->effect_list, (Eina_Inlist*) effect_module);
552 * Delete an added effect.
554 * This function will remove the effect from the @p transit, calling the
555 * data_free_cb to free the @p data.
557 * @see elm_transit_effect_add()
559 * @note If the effect is not found, nothing is done.
560 * @note If the effect list become empty, this function will call
561 * elm_transit_del(transit), that is, it will kill the @p transit.
563 * @param transit The transit object.
564 * @param cb The operation function.
565 * @param data The context data of the effect.
570 elm_transit_effect_del(Elm_Transit *transit, Elm_Transit_Effect_Transition_Cb transition_cb, Elm_Transit_Effect *effect)
572 ELM_TRANSIT_CHECK_OR_RETURN(transit);
573 EINA_SAFETY_ON_NULL_RETURN(transition_cb);
574 Elm_Transit_Effect_Module *effect_module;
576 EINA_INLIST_FOREACH(transit->effect_list, effect_module)
578 if ((effect_module->transition_cb == transition_cb) && (effect_module->effect == effect))
580 if (transit->walking)
582 effect_module->deleted = EINA_TRUE;
583 transit->effects_pending_del++;
587 _elm_transit_effect_del(transit, effect_module);
588 if (!transit->effect_list) elm_transit_del(transit);
596 * Add new object to apply the effects.
598 * @note After the first addition of an object in @p transit, if its
599 * object list become empty again, the @p transit will be killed by
600 * elm_transit_del(transit) function.
601 * @note If the @p obj belongs to another transit, the @p obj will be
602 * removed from it and it will only belong to the @p transit. If the old
603 * transit stays without objects, it will die.
604 * @note When you add an object into the @p transit, its state from
605 * evas_object_pass_events_get(obj) is saved, and it is applied when the
606 * transit ends, if you change this state whith evas_object_pass_events_set()
607 * after add the object, this state will change again when @p transit stops to
610 * @param transit The transit object.
611 * @param obj Object to be animated.
614 * @warning It is not allowed to add a new object after transit begins to go.
617 elm_transit_object_add(Elm_Transit *transit, Evas_Object *obj)
619 ELM_TRANSIT_CHECK_OR_RETURN(transit);
620 EINA_SAFETY_ON_NULL_RETURN(obj);
622 if (transit->animator)
624 if (!evas_object_data_get(obj, _transit_key))
626 _elm_transit_obj_data_update(transit, obj);
627 evas_object_pass_events_set(obj, EINA_TRUE);
631 evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
632 _elm_transit_obj_remove_cb,
635 transit->objs = eina_list_append(transit->objs, obj);
639 * Removes an added object from the transit.
641 * @note If the @p obj is not in the @p transit, nothing is done.
642 * @note If the list become empty, this function will call
643 * elm_transit_del(transit), that is, it will kill the @p transit.
645 * @param transit The transit object.
646 * @param obj Object to be removed from @p transit.
649 * @warning It is not allowed to remove objects after transit begins to go.
652 elm_transit_object_remove(Elm_Transit *transit, Evas_Object *obj)
654 ELM_TRANSIT_CHECK_OR_RETURN(transit);
655 EINA_SAFETY_ON_NULL_RETURN(obj);
657 _elm_transit_obj_remove(transit, obj);
658 if (!transit->objs) elm_transit_del(transit);
662 * Get the objects of the transit.
664 * @param transit The transit object.
665 * @return a Eina_List with the objects from the transit.
669 EAPI const Eina_List *
670 elm_transit_objects_get(const Elm_Transit *transit)
672 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
673 return transit->objs;
677 * Set the event enabled when transit is operating.
679 * If @p enabled is EINA_TRUE, the objects of the transit will receives
680 * events from mouse and keyboard during the animation.
681 * @note When you add an object with elm_transit_object_add(), its state from
682 * evas_object_pass_events_get(obj) is saved, and it is applied when the
683 * transit ends, if you change this state with evas_object_pass_events_set()
684 * after adding the object, this state will change again when @p transit stops
687 * @param transit The transit object.
688 * @param enabled Disable or enable.
693 elm_transit_event_enabled_set(Elm_Transit *transit, Eina_Bool enabled)
695 ELM_TRANSIT_CHECK_OR_RETURN(transit);
700 if (transit->event_enabled == enabled) return;
701 transit->event_enabled = !!enabled;
702 if (!transit->animator) return;
704 EINA_LIST_FOREACH(transit->objs, list, obj)
705 evas_object_pass_events_set(obj, enabled);
709 * Get the value of event enabled status.
711 * @see elm_transit_event_enabled_set()
713 * @param transit The Transit object
714 * @return EINA_TRUE, when event is enabled. If @p transit is NULL
715 * EINA_FALSE is returned
720 elm_transit_event_enabled_get(const Elm_Transit *transit)
722 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
723 return transit->event_enabled;
728 * Set the event enabled when transit is operating.
730 * If @p disabled is EINA_TRUE, the objects of the transit will receives
731 * events from mouse and keyboard during the animation.
732 * @note When you add an object with elm_transit_object_add(), its state from
733 * evas_object_pass_events_get(obj) is saved, and it is applied when the
734 * transit ends, if you change this state with evas_object_pass_events_set()
735 * after add the object, this state will change again when @p transit stops to
738 * @see elm_transit_event_enabled_set()
740 * @param transit The transit object.
741 * @param disabled Disable or enable.
745 EINA_DEPRECATED EAPI void
746 elm_transit_event_block_set(Elm_Transit *transit, Eina_Bool disabled)
748 elm_transit_event_enabled_set(transit, disabled);
753 * Get the value of event block enabled status.
755 * @see elm_transit_event_enabled_set(), elm_transit_event_enabled_get()
757 * @param transit The Transit object
758 * @return EINA_TRUE, when event is enabled. If @p transit is NULL
759 * EINA_FALSE is returned
763 EINA_DEPRECATED EAPI Eina_Bool
764 elm_transit_event_block_get(const Elm_Transit *transit)
766 return !elm_transit_event_enabled_get(transit);
770 * Set the user-callback function when the transit is deleted.
772 * @note Using this function twice will overwrite the first function setted.
773 * @note the @p transit object will be deleted after call @p cb function.
775 * @param transit The transit object.
776 * @param cb Callback function pointer. This function will be called before
777 * the deletion of the transit.
778 * @param data Callback funtion user data. It is the @p op parameter.
783 elm_transit_del_cb_set(Elm_Transit *transit, void (*cb) (void *data, Elm_Transit *transit), void *data)
785 ELM_TRANSIT_CHECK_OR_RETURN(transit);
786 transit->del_data.func = cb;
787 transit->del_data.arg = data;
791 * Set reverse effect automatically.
793 * If auto reverse is setted, after running the effects with the progress
794 * parameter from 0 to 1, it will call the effecs again with the progress
795 * from 1 to 0. The transit will last for a time iqual to (2 * duration * repeat),
796 * where the duration was setted with the function elm_transit_add and
797 * the repeat with the function elm_transit_repeat_times_set().
799 * @param transit The transit object.
800 * @param reverse EINA_TRUE means the auto_reverse is on.
805 elm_transit_auto_reverse_set(Elm_Transit *transit, Eina_Bool reverse)
807 ELM_TRANSIT_CHECK_OR_RETURN(transit);
808 transit->auto_reverse = reverse;
812 * Get if the auto reverse is on.
814 * @see elm_transit_auto_reverse_set()
816 * @param transit The transit object.
817 * @return EINA_TRUE means auto reverse is on. If @p transit is NULL
818 * EINA_FALSE is returned
823 elm_transit_auto_reverse_get(const Elm_Transit *transit)
825 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
826 return transit->auto_reverse;
830 * Set the transit repeat count. Effect will be repeated by repeat count.
832 * This function sets the number of repetition the transit will run after
833 * the first one, that is, if @p repeat is 1, the transit will run 2 times.
834 * If the @p repeat is a negative number, it will repeat infinite times.
836 * @note If this function is called during the transit execution, the transit
837 * will run @p repeat times, ignoring the times it already performed.
839 * @param transit The transit object
840 * @param repeat Repeat count
845 elm_transit_repeat_times_set(Elm_Transit *transit, int repeat)
847 ELM_TRANSIT_CHECK_OR_RETURN(transit);
848 transit->repeat.count = repeat;
849 transit->repeat.current = 0;
853 * Get the transit repeat count.
855 * @see elm_transit_repeat_times_set()
857 * @param transit The Transit object.
858 * @return The repeat count. If @p transit is NULL
864 elm_transit_repeat_times_get(const Elm_Transit *transit)
866 ELM_TRANSIT_CHECK_OR_RETURN(transit, 0);
867 return transit->repeat.count;
871 * Set the transit animation acceleration type.
873 * This function sets the tween mode of the transit that can be:
874 * ELM_TRANSIT_TWEEN_MODE_LINEAR - The default mode.
875 * ELM_TRANSIT_TWEEN_MODE_SINUSOIDAL - Starts in accelerate mode and ends decelerating.
876 * ELM_TRANSIT_TWEEN_MODE_DECELERATE - The animation will be slowed over time.
877 * ELM_TRANSIT_TWEEN_MODE_ACCELERATE - The animation will accelerate over time.
879 * @param transit The transit object.
880 * @param tween_mode The tween type.
885 elm_transit_tween_mode_set(Elm_Transit *transit, Elm_Transit_Tween_Mode tween_mode)
887 ELM_TRANSIT_CHECK_OR_RETURN(transit);
888 transit->tween_mode = tween_mode;
892 * Get the transit animation acceleration type.
894 * @note @p transit can not be NULL
896 * @param transit The transit object.
897 * @return The tween type. If @p transit is NULL
898 * ELM_TRANSIT_TWEEN_MODE_LINEAR is returned.
902 EAPI Elm_Transit_Tween_Mode
903 elm_transit_tween_mode_get(const Elm_Transit *transit)
905 ELM_TRANSIT_CHECK_OR_RETURN(transit, ELM_TRANSIT_TWEEN_MODE_LINEAR);
906 return transit->tween_mode;
910 * Set the transit animation time
912 * @note @p transit can not be NULL
914 * @param transit The transit object.
915 * @param duration The animation time.
920 elm_transit_duration_set(Elm_Transit *transit, double duration)
922 ELM_TRANSIT_CHECK_OR_RETURN(transit);
923 if (transit->animator) return;
924 transit->time.duration = duration;
928 * Get the transit animation time
930 * @note @p transit can not be NULL
932 * @param transit The transit object.
934 * @return The transit animation time.
939 elm_transit_duration_get(const Elm_Transit *transit)
941 ELM_TRANSIT_CHECK_OR_RETURN(transit, 0.0);
942 return transit->time.duration;
946 * Starts the transition.
947 * Once this API is called, the transit begins to measure the time.
949 * @note @p transit can not be NULL
951 * @param transit The transit object.
956 elm_transit_go(Elm_Transit *transit)
958 ELM_TRANSIT_CHECK_OR_RETURN(transit);
963 if (transit->animator)
964 ecore_animator_del(transit->animator);
966 EINA_LIST_FOREACH(transit->objs, elist, obj)
967 _elm_transit_obj_data_update(transit, obj);
969 if (!transit->event_enabled)
971 EINA_LIST_FOREACH(transit->objs, elist, obj)
972 evas_object_pass_events_set(obj, EINA_TRUE);
975 transit->time.paused = 0;
976 transit->time.delayed = 0;
977 transit->time.begin = ecore_loop_time_get();
978 transit->animator = ecore_animator_add(_animator_animate_cb, transit);
982 * Pause/Resume the transition.
983 * If you call elm_transit_go again, paused states will affect no anymore.
985 * @note @p transit can not be NULL
987 * @param transit The transit object.
992 elm_transit_paused_set(Elm_Transit *transit, Eina_Bool paused)
994 ELM_TRANSIT_CHECK_OR_RETURN(transit);
996 if (!transit->animator) return;
1000 if (transit->time.paused > 0)
1002 ecore_animator_freeze(transit->animator);
1003 transit->time.paused = ecore_loop_time_get();
1007 if (transit->time.paused == 0)
1009 ecore_animator_thaw(transit->animator);
1010 transit->time.delayed += (ecore_loop_time_get() - transit->time.paused);
1011 transit->time.paused = 0;
1016 * Get the value of paused status.
1018 * @see elm_transit_paused_set()
1020 * @note @p transit can not be NULL
1022 * @param transit The transit object.
1023 * @return EINA_TRUE means transition is paused. If @p transit is NULL
1024 * EINA_FALSE is returned
1029 elm_transit_paused_get(const Elm_Transit *transit)
1031 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
1033 if (transit->time.paused == 0)
1040 * Get the time progression of the animation (a double value between 0.0 and 1.0).
1042 * @note @p transit can not be NULL
1044 * @param transit The transit object.
1046 * @return The time progression value. If @p transit is NULL
1052 elm_transit_progress_value_get(const Elm_Transit *transit)
1054 ELM_TRANSIT_CHECK_OR_RETURN(transit, 0);
1056 return transit->progress;
1062 * Enable/disable keeping up the objects states.
1063 * If it is not kept, the objects states will be reset when transition ends.
1065 * @note @p transit can not be NULL.
1066 * @note One state includes geometry, color, map data.
1068 * @param transit The transit object.
1069 * @param state_keep Keeping or Non Keeping.
1074 elm_transit_objects_final_state_keep_set(Elm_Transit *transit, Eina_Bool state_keep)
1076 ELM_TRANSIT_CHECK_OR_RETURN(transit);
1078 if (transit->state_keep == state_keep) return;
1079 if (transit->animator) return;
1080 transit->state_keep = !!state_keep;
1084 * Get a value whether the objects states will be reset or not.
1086 * @note @p transit can not be NULL
1088 * @see elm_transit_objects_final_state_keep_set()
1090 * @param transit The transit object.
1091 * @return EINA_TRUE means the states of the objects will be reset.
1092 * If @p transit is NULL, EINA_FALSE is returned
1097 elm_transit_objects_final_state_keep_get(const Elm_Transit *transit)
1099 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
1100 return transit->state_keep;
1104 * Makes the chain relationship between two transits.
1106 * @note @p transit can not be NULL. Transit would have multiple chain transits.
1107 * @note @p chain_transit can not be NULL. Chain transits could be chained to the only one transit.
1109 * @param transit The transit object.
1110 * @param chain_transit The chain transit object. This transit will be operated
1111 * after transit is done.
1116 elm_transit_chain_transit_add(Elm_Transit *transit, Elm_Transit *chain_transit)
1118 ELM_TRANSIT_CHECK_OR_RETURN(transit);
1119 ELM_TRANSIT_CHECK_OR_RETURN(chain_transit);
1121 if (transit == chain_transit) return;
1122 if (transit == chain_transit->prev_chain_transit) return;
1124 if (chain_transit->prev_chain_transit)
1125 chain_transit->prev_chain_transit->next_chain_transits = eina_list_remove(chain_transit->prev_chain_transit->next_chain_transits, chain_transit);
1127 chain_transit->prev_chain_transit = transit;
1128 transit->next_chain_transits = eina_list_append(transit->next_chain_transits, chain_transit);
1132 * Get the current chain transit list.
1134 * @note @p transit can not be NULL.
1136 * @param transit The transit object.
1137 * @return chain transit list.
1142 elm_transit_chain_transits_get(const Elm_Transit * transit)
1144 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1145 return transit->next_chain_transits;
1148 ///////////////////////////////////////////////////////////////////////////////
1150 ///////////////////////////////////////////////////////////////////////////////
1151 typedef struct _Elm_Transit_Effect_Resizing Elm_Transit_Effect_Resizing;
1153 struct _Elm_Transit_Effect_Resizing
1161 _transit_effect_resizing_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
1163 Elm_Transit_Effect_Resizing *resizing = effect;
1168 _transit_effect_resizing_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
1170 EINA_SAFETY_ON_NULL_RETURN(effect);
1171 EINA_SAFETY_ON_NULL_RETURN(transit);
1175 Elm_Transit_Effect_Resizing *resizing = effect;
1177 w = resizing->from.w + (resizing->to.w * progress);
1178 h = resizing->from.h + (resizing->to.h * progress);
1180 EINA_LIST_FOREACH(transit->objs, elist, obj)
1181 evas_object_resize(obj, w, h);
1184 static Elm_Transit_Effect *
1185 _transit_effect_resizing_context_new(Evas_Coord from_w, Evas_Coord from_h, Evas_Coord to_w, Evas_Coord to_h)
1187 Elm_Transit_Effect_Resizing *resizing;
1189 resizing = ELM_NEW(Elm_Transit_Effect_Resizing);
1190 if (!resizing) return NULL;
1192 resizing->from.w = from_w;
1193 resizing->from.h = from_h;
1194 resizing->to.w = to_w - from_w;
1195 resizing->to.h = to_h - from_h;
1201 * Add the Resizing Effect to Elm_Transit.
1203 * @note This API is one of the facades. It creates resizing effect context
1204 * and add it's required APIs to elm_transit_effect_add.
1206 * @see elm_transit_effect_add()
1208 * @param transit Transit object.
1209 * @param from_w Object width size when effect begins.
1210 * @param from_h Object height size when effect begins.
1211 * @param to_w Object width size when effect ends.
1212 * @param to_h Object height size when effect ends.
1213 * @return Resizing effect context data.
1217 EAPI Elm_Transit_Effect *
1218 elm_transit_effect_resizing_add(Elm_Transit *transit, Evas_Coord from_w, Evas_Coord from_h, Evas_Coord to_w, Evas_Coord to_h)
1220 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1221 Elm_Transit_Effect *effect = _transit_effect_resizing_context_new(from_w, from_h, to_w, to_h);
1223 if (!effect) return NULL;
1224 elm_transit_effect_add(transit,
1225 _transit_effect_resizing_op, effect,
1226 _transit_effect_resizing_context_free);
1230 ///////////////////////////////////////////////////////////////////////////////
1231 //Translation Effect
1232 ///////////////////////////////////////////////////////////////////////////////
1233 typedef struct _Elm_Transit_Effect_Translation Elm_Transit_Effect_Translation;
1234 typedef struct _Elm_Transit_Effect_Translation_Node Elm_Transit_Effect_Translation_Node;
1236 struct _Elm_Transit_Effect_Translation_Node
1242 struct _Elm_Transit_Effect_Translation
1244 struct _position_variation {
1251 _translation_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1253 Elm_Transit_Effect_Translation *translation = data;
1255 Elm_Transit_Effect_Translation_Node *translation_node;
1257 EINA_LIST_FOREACH(translation->nodes, elist, translation_node)
1259 if (translation_node->obj != obj) continue;
1260 translation->nodes = eina_list_remove_list(translation->nodes, elist);
1261 free(translation_node);
1267 _translation_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Translation *translation)
1269 Elm_Transit_Effect_Translation_Node *translation_node;
1270 const Eina_List *elist;
1272 Eina_List *data_list = NULL;
1273 const Eina_List *objs = elm_transit_objects_get(transit);
1275 EINA_LIST_FOREACH(objs, elist, obj)
1277 translation_node = ELM_NEW(Elm_Transit_Effect_Translation_Node);
1278 if (!translation_node)
1280 eina_list_free(data_list);
1283 translation_node->obj = obj;
1284 evas_object_geometry_get(obj, &(translation_node->x),
1285 &(translation_node->y), NULL, NULL);
1286 data_list = eina_list_append(data_list, translation_node);
1287 evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
1288 _translation_object_del_cb, translation);
1294 _transit_effect_translation_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
1296 EINA_SAFETY_ON_NULL_RETURN(effect);
1297 Elm_Transit_Effect_Translation *translation = effect;
1298 Eina_List *elist, *elist_next;
1299 Elm_Transit_Effect_Translation_Node *translation_node;
1301 EINA_LIST_FOREACH_SAFE(translation->nodes,
1302 elist, elist_next, translation_node)
1304 evas_object_event_callback_del(translation_node->obj,
1305 EVAS_CALLBACK_DEL, _translation_object_del_cb);
1306 translation->nodes = eina_list_remove_list(translation->nodes, elist);
1307 free(translation_node);
1313 _transit_effect_translation_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress __UNUSED__)
1315 EINA_SAFETY_ON_NULL_RETURN(effect);
1316 EINA_SAFETY_ON_NULL_RETURN(transit);
1318 Elm_Transit_Effect_Translation *translation = effect;
1319 Elm_Transit_Effect_Translation_Node *translation_node;
1322 if (!translation->nodes)
1323 translation->nodes = _translation_nodes_build(transit, translation);
1325 EINA_LIST_FOREACH(translation->nodes, elist, translation_node)
1327 x = translation_node->x + translation->from.dx
1328 + (translation->to.dx * progress);
1329 y = translation_node->y + translation->from.dy
1330 + (translation->to.dy * progress);
1331 evas_object_move(translation_node->obj, x, y);
1335 static Elm_Transit_Effect *
1336 _transit_effect_translation_context_new(Evas_Coord from_dx, Evas_Coord from_dy, Evas_Coord to_dx, Evas_Coord to_dy)
1338 Elm_Transit_Effect_Translation *translation;
1340 translation = ELM_NEW(Elm_Transit_Effect_Translation);
1341 if (!translation) return NULL;
1343 translation->from.dx = from_dx;
1344 translation->from.dy = from_dy;
1345 translation->to.dx = to_dx - from_dx;
1346 translation->to.dy = to_dy - from_dy;
1352 * Add the Translation Effect to Elm_Transit.
1354 * @note This API is one of the facades. It creates translation effect context
1355 * and add it's required APIs to elm_transit_effect_add.
1357 * @see elm_transit_effect_add()
1359 * @param transit Transit object.
1360 * @param from_dx X Position variation when effect begins.
1361 * @param from_dy Y Position variation when effect begins.
1362 * @param to_dx X Position variation when effect ends.
1363 * @param to_dy Y Position variation when effect ends.
1364 * @return Translation effect context data.
1367 * @warning Is higher recommended just create a transit with this effect when
1368 * the window that the objects of the transit belongs has already been created.
1369 * This is because this effect needs the geometry information about the objects,
1370 * and if the window was not created yet, it can get a wrong information.
1372 EAPI Elm_Transit_Effect *
1373 elm_transit_effect_translation_add(Elm_Transit *transit, Evas_Coord from_dx, Evas_Coord from_dy, Evas_Coord to_dx, Evas_Coord to_dy)
1375 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1376 Elm_Transit_Effect *effect_context = _transit_effect_translation_context_new(from_dx, from_dy, to_dx, to_dy);
1378 if (!effect_context) return NULL;
1379 elm_transit_effect_add(transit,
1380 _transit_effect_translation_op, effect_context,
1381 _transit_effect_translation_context_free);
1382 return effect_context;
1386 ///////////////////////////////////////////////////////////////////////////////
1388 ///////////////////////////////////////////////////////////////////////////////
1389 typedef struct _Elm_Transit_Effect_Zoom Elm_Transit_Effect_Zoom;
1391 struct _Elm_Transit_Effect_Zoom
1397 _transit_effect_zoom_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
1399 Elm_Transit_Effect_Zoom *zoom = effect;
1404 _transit_effect_zoom_op(Elm_Transit_Effect *effect, Elm_Transit *transit , double progress)
1406 EINA_SAFETY_ON_NULL_RETURN(effect);
1407 EINA_SAFETY_ON_NULL_RETURN(transit);
1410 Elm_Transit_Effect_Zoom *zoom = effect;
1412 Evas_Coord x, y, w, h;
1414 map = evas_map_new(4);
1417 EINA_LIST_FOREACH(transit->objs, elist, obj)
1419 evas_object_geometry_get(obj, &x, &y, &w, &h);
1420 evas_map_util_points_populate_from_object_full(map, obj, zoom->from +
1421 (progress * zoom->to));
1422 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, _TRANSIT_FOCAL);
1423 evas_object_map_set(obj, map);
1424 evas_object_map_enable_set(obj, EINA_TRUE);
1429 static Elm_Transit_Effect *
1430 _transit_effect_zoom_context_new(float from_rate, float to_rate)
1432 Elm_Transit_Effect_Zoom *zoom;
1434 zoom = ELM_NEW(Elm_Transit_Effect_Zoom);
1435 if (!zoom) return NULL;
1437 zoom->from = (_TRANSIT_FOCAL - (from_rate * _TRANSIT_FOCAL)) * (1 / from_rate);
1438 zoom->to = ((_TRANSIT_FOCAL - (to_rate * _TRANSIT_FOCAL)) * (1 / to_rate)) - zoom->from;
1444 * Add the Zoom Effect to Elm_Transit.
1446 * @note This API is one of the facades. It creates zoom effect context
1447 * and add it's required APIs to elm_transit_effect_add.
1449 * @see elm_transit_effect_add()
1451 * @param transit Transit object.
1452 * @param from_rate Scale rate when effect begins (1 is current rate).
1453 * @param to_rate Scale rate when effect ends.
1454 * @return Zoom effect context data.
1457 * @warning Is higher recommended just create a transit with this effect when
1458 * the window that the objects of the transit belongs has already been created.
1459 * This is because this effect needs the geometry information about the objects,
1460 * and if the window was not created yet, it can get a wrong information.
1462 EAPI Elm_Transit_Effect *
1463 elm_transit_effect_zoom_add(Elm_Transit *transit, float from_rate, float to_rate)
1465 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1466 Elm_Transit_Effect *effect_context = _transit_effect_zoom_context_new(from_rate, to_rate);
1468 if (!effect_context) return NULL;
1469 elm_transit_effect_add(transit,
1470 _transit_effect_zoom_op, effect_context,
1471 _transit_effect_zoom_context_free);
1472 return effect_context;
1476 ///////////////////////////////////////////////////////////////////////////////
1478 ///////////////////////////////////////////////////////////////////////////////
1479 typedef struct _Elm_Transit_Effect_Flip Elm_Transit_Effect_Flip;
1481 struct _Elm_Transit_Effect_Flip
1483 Elm_Transit_Effect_Flip_Axis axis;
1488 _transit_effect_flip_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit)
1490 EINA_SAFETY_ON_NULL_RETURN(effect);
1491 EINA_SAFETY_ON_NULL_RETURN(transit);
1492 Elm_Transit_Effect_Flip *flip = effect;
1493 Evas_Object *front, *back;
1495 int count = eina_list_count(transit->objs);
1497 for (i = 0; i < (count - 1); i += 2)
1499 front = eina_list_nth(transit->objs, i);
1500 back = eina_list_nth(transit->objs, i+1);
1501 evas_object_map_enable_set(front, EINA_FALSE);
1502 evas_object_map_enable_set(back, EINA_FALSE);
1508 _transit_effect_flip_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
1510 EINA_SAFETY_ON_NULL_RETURN(effect);
1511 EINA_SAFETY_ON_NULL_RETURN(transit);
1512 Evas_Object *obj, *front, *back;
1514 Elm_Transit_Effect_Flip *flip = effect;
1517 Evas_Coord x, y, w, h;
1519 map = evas_map_new(4);
1522 if (flip->cw) degree = (float)(progress * 180);
1523 else degree = (float)(progress * -180);
1525 count = eina_list_count(transit->objs);
1527 for (i = 0; i < (count - 1); i += 2)
1529 Evas_Coord half_w, half_h;
1531 front = eina_list_nth(transit->objs, i);
1532 back = eina_list_nth(transit->objs, i+1);
1534 if ((degree < 90) && (degree > -90))
1539 evas_object_hide(back);
1540 evas_object_show(front);
1548 evas_object_hide(front);
1549 evas_object_show(back);
1553 evas_map_util_points_populate_from_object_full(map, obj, 0);
1554 evas_object_geometry_get(obj, &x, &y, &w, &h);
1558 if (flip->axis == ELM_TRANSIT_EFFECT_FLIP_AXIS_Y)
1560 if ((degree >= 90) || (degree <= -90))
1562 evas_map_point_image_uv_set(map, 0, w, 0);
1563 evas_map_point_image_uv_set(map, 1, 0, 0);
1564 evas_map_point_image_uv_set(map, 2, 0, h);
1565 evas_map_point_image_uv_set(map, 3, w, h);
1567 evas_map_util_3d_rotate(map, 0, degree,
1568 0, x + half_w, y + half_h, 0);
1572 if ((degree >= 90) || (degree <= -90))
1574 evas_map_point_image_uv_set(map, 0, 0, h);
1575 evas_map_point_image_uv_set(map, 1, w, h);
1576 evas_map_point_image_uv_set(map, 2, w, 0);
1577 evas_map_point_image_uv_set(map, 3, 0, 0);
1579 evas_map_util_3d_rotate(map, degree,
1580 0, 0, x + half_w, y + half_h, 0);
1582 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, _TRANSIT_FOCAL);
1583 evas_object_map_enable_set(front, EINA_TRUE);
1584 evas_object_map_enable_set(back, EINA_TRUE);
1585 evas_object_map_set(obj, map);
1590 static Elm_Transit_Effect *
1591 _transit_effect_flip_context_new(Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1593 Elm_Transit_Effect_Flip *flip;
1595 flip = ELM_NEW(Elm_Transit_Effect_Flip);
1596 if (!flip) return NULL;
1605 * Add the Flip Effect to Elm_Transit.
1607 * @note This API is one of the facades. It creates flip effect context
1608 * and add it's required APIs to elm_transit_effect_add.
1609 * @note This effect is applied to each pair of objects in the order they are listed
1610 * in the transit list of objects. The first object in the pair will be the
1611 * "front" object and the second will be the "back" object.
1613 * @see elm_transit_effect_add()
1615 * @param transit Transit object.
1616 * @param axis Flipping Axis(X or Y).
1617 * @param cw Flipping Direction. EINA_TRUE is clock-wise.
1618 * @return Flip effect context data.
1621 * @warning Is higher recommended just create a transit with this effect when
1622 * the window that the objects of the transit belongs has already been created.
1623 * This is because this effect needs the geometry information about the objects,
1624 * and if the window was not created yet, it can get a wrong information.
1626 EAPI Elm_Transit_Effect *
1627 elm_transit_effect_flip_add(Elm_Transit *transit, Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1629 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1630 Elm_Transit_Effect *effect_context = _transit_effect_flip_context_new(axis, cw);
1632 if (!effect_context) return NULL;
1633 elm_transit_effect_add(transit,
1634 _transit_effect_flip_op, effect_context,
1635 _transit_effect_flip_context_free);
1636 return effect_context;
1639 ///////////////////////////////////////////////////////////////////////////////
1640 //ResizableFlip Effect
1641 ///////////////////////////////////////////////////////////////////////////////
1642 typedef struct _Elm_Transit_Effect_Resizable_Flip Elm_Transit_Effect_ResizableFlip;
1643 typedef struct _Elm_Transit_Effect_Resizable_Flip_Node Elm_Transit_Effect_ResizableFlip_Node;
1645 struct _Elm_Transit_Effect_Resizable_Flip_Node
1651 } from_pos, from_size, to_pos, to_size;
1654 struct _Elm_Transit_Effect_Resizable_Flip
1658 Elm_Transit_Effect_Flip_Axis axis;
1662 _resizable_flip_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1664 Elm_Transit_Effect_ResizableFlip *resizable_flip = data;
1666 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1668 EINA_LIST_FOREACH(resizable_flip->nodes, elist, resizable_flip_node)
1670 if (resizable_flip_node->front == obj)
1671 evas_object_event_callback_del(resizable_flip_node->back,
1672 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1673 else if (resizable_flip_node->back == obj)
1674 evas_object_event_callback_del(resizable_flip_node->front,
1675 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1678 resizable_flip->nodes = eina_list_remove_list(resizable_flip->nodes,
1680 free(resizable_flip_node);
1686 _resizable_flip_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_ResizableFlip *resizable_flip)
1688 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1689 Eina_List *data_list = NULL;
1690 Evas_Coord front_x, front_y, front_w, front_h;
1691 Evas_Coord back_x, back_y, back_w, back_h;
1694 count = eina_list_count(transit->objs);
1695 for (i = 0; i < (count - 1); i += 2)
1697 resizable_flip_node = ELM_NEW(Elm_Transit_Effect_ResizableFlip_Node);
1698 if (!resizable_flip_node)
1700 eina_list_free(data_list);
1704 resizable_flip_node->front = eina_list_nth(transit->objs, i);
1705 resizable_flip_node->back = eina_list_nth(transit->objs, i+1);
1707 evas_object_geometry_get(resizable_flip_node->front,
1708 &front_x, &front_y, &front_w, &front_h);
1709 evas_object_geometry_get(resizable_flip_node->back,
1710 &back_x, &back_y, &back_w, &back_h);
1712 resizable_flip_node->from_pos.x = front_x;
1713 resizable_flip_node->from_pos.y = front_y;
1714 resizable_flip_node->to_pos.x = back_x - front_x;
1715 resizable_flip_node->to_pos.y = back_y - front_y;
1717 resizable_flip_node->from_size.x = front_w;
1718 resizable_flip_node->from_size.y = front_h;
1719 resizable_flip_node->to_size.x = back_w - front_w;
1720 resizable_flip_node->to_size.y = back_h - front_h;
1722 data_list = eina_list_append(data_list, resizable_flip_node);
1724 evas_object_event_callback_add(resizable_flip_node->back,
1725 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb, resizable_flip);
1726 evas_object_event_callback_add(resizable_flip_node->front,
1727 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb, resizable_flip);
1734 _set_image_uv_by_axis_y(Evas_Map *map, Elm_Transit_Effect_ResizableFlip_Node *flip, float degree)
1736 if ((degree >= 90) || (degree <= -90))
1738 evas_map_point_image_uv_set(map, 0,
1739 (flip->from_size.x * 2) + flip->to_size.x,
1741 evas_map_point_image_uv_set(map, 1, 0, 0);
1742 evas_map_point_image_uv_set(map, 2, 0,
1743 (flip->from_size.y * 2) + flip->to_size.y);
1744 evas_map_point_image_uv_set(map, 3,
1745 (flip->from_size.x * 2) + flip->to_size.x,
1746 (flip->from_size.y * 2) + flip->to_size.y);
1750 evas_map_point_image_uv_set(map, 0, 0, 0);
1751 evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
1752 evas_map_point_image_uv_set(map, 2, flip->from_size.x,
1754 evas_map_point_image_uv_set(map, 3, 0, flip->from_size.y);
1759 _set_image_uv_by_axis_x(Evas_Map *map, Elm_Transit_Effect_ResizableFlip_Node *flip, float degree)
1761 if ((degree >= 90) || (degree <= -90))
1763 evas_map_point_image_uv_set(map, 0, 0,
1764 (flip->from_size.y * 2) + flip->to_size.y);
1765 evas_map_point_image_uv_set(map, 1,
1766 (flip->from_size.x * 2) + flip->to_size.x,
1767 (flip->from_size.y * 2) + flip->to_size.y);
1768 evas_map_point_image_uv_set(map, 2,
1769 (flip->from_size.x * 2) + flip->to_size.x,
1771 evas_map_point_image_uv_set(map, 3, 0, 0);
1775 evas_map_point_image_uv_set(map, 0, 0, 0);
1776 evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
1777 evas_map_point_image_uv_set(map, 2, flip->from_size.x,
1779 evas_map_point_image_uv_set(map, 3, 0, flip->from_size.y);
1784 _transit_effect_resizable_flip_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
1786 EINA_SAFETY_ON_NULL_RETURN(effect);
1788 Elm_Transit_Effect_ResizableFlip *resizable_flip = effect;
1789 Eina_List *elist, *elist_next;
1790 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1792 EINA_LIST_FOREACH_SAFE(resizable_flip->nodes,
1793 elist, elist_next, resizable_flip_node)
1795 evas_object_map_enable_set(resizable_flip_node->front, EINA_FALSE);
1796 evas_object_map_enable_set(resizable_flip_node->back, EINA_FALSE);
1798 resizable_flip->nodes = eina_list_remove_list(resizable_flip->nodes,
1801 evas_object_event_callback_del(resizable_flip_node->back,
1802 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1803 evas_object_event_callback_del(resizable_flip_node->front,
1804 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1805 free(resizable_flip_node);
1807 free(resizable_flip);
1811 _transit_effect_resizable_flip_op(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__, double progress)
1813 EINA_SAFETY_ON_NULL_RETURN(effect);
1818 Evas_Coord half_w, half_h;
1819 Elm_Transit_Effect_ResizableFlip *resizable_flip = effect;
1820 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1823 map = evas_map_new(4);
1826 if (resizable_flip->cw) degree = (float)(progress * 180);
1827 else degree = (float)(progress * -180);
1829 if (!resizable_flip->nodes)
1830 resizable_flip->nodes = _resizable_flip_nodes_build(transit,
1833 EINA_LIST_FOREACH(resizable_flip->nodes, elist, resizable_flip_node)
1835 if ((degree < 90) && (degree > -90))
1837 obj = resizable_flip_node->front;
1838 if (resizable_flip_node->front != resizable_flip_node->back)
1840 evas_object_hide(resizable_flip_node->back);
1841 evas_object_show(resizable_flip_node->front);
1846 obj = resizable_flip_node->back;
1847 if (resizable_flip_node->front != resizable_flip_node->back)
1849 evas_object_hide(resizable_flip_node->front);
1850 evas_object_show(resizable_flip_node->back);
1854 x = resizable_flip_node->from_pos.x +
1855 (resizable_flip_node->to_pos.x * progress);
1856 y = resizable_flip_node->from_pos.y +
1857 (resizable_flip_node->to_pos.y * progress);
1858 w = resizable_flip_node->from_size.x +
1859 (resizable_flip_node->to_size.x * progress);
1860 h = resizable_flip_node->from_size.y +
1861 (resizable_flip_node->to_size.y * progress);
1862 evas_map_point_coord_set(map, 0, x, y, 0);
1863 evas_map_point_coord_set(map, 1, x + w, y, 0);
1864 evas_map_point_coord_set(map, 2, x + w, y + h, 0);
1865 evas_map_point_coord_set(map, 3, x, y + h, 0);
1867 half_w = (Evas_Coord)(w / 2);
1868 half_h = (Evas_Coord)(h / 2);
1870 if (resizable_flip->axis == ELM_TRANSIT_EFFECT_FLIP_AXIS_Y)
1872 _set_image_uv_by_axis_y(map, resizable_flip_node, degree);
1873 evas_map_util_3d_rotate(map, 0, degree,
1874 0, x + half_w, y + half_h, 0);
1878 _set_image_uv_by_axis_x(map, resizable_flip_node, degree);
1879 evas_map_util_3d_rotate(map, degree, 0,
1880 0, x + half_w, y + half_h, 0);
1883 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, _TRANSIT_FOCAL);
1884 evas_object_map_enable_set(resizable_flip_node->front, EINA_TRUE);
1885 evas_object_map_enable_set(resizable_flip_node->back, EINA_TRUE);
1886 evas_object_map_set(obj, map);
1891 static Elm_Transit_Effect *
1892 _transit_effect_resizable_flip_context_new(Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1894 Elm_Transit_Effect_ResizableFlip *resizable_flip;
1896 resizable_flip = ELM_NEW(Elm_Transit_Effect_ResizableFlip);
1897 if (!resizable_flip) return NULL;
1899 resizable_flip->cw = cw;
1900 resizable_flip->axis = axis;
1902 return resizable_flip;
1906 * Add the Resizable Flip Effect to Elm_Transit.
1908 * @note This API is one of the facades. It creates resizable flip effect context
1909 * and add it's required APIs to elm_transit_effect_add.
1910 * @note This effect is applied to each pair of objects in the order they are listed
1911 * in the transit list of objects. The first object in the pair will be the
1912 * "front" object and the second will be the "back" object.
1914 * @see elm_transit_effect_add()
1916 * @param transit Transit object.
1917 * @param axis Flipping Axis(X or Y).
1918 * @param cw Flipping Direction. EINA_TRUE is clock-wise.
1919 * @return Resizable flip effect context data.
1922 * @warning Is higher recommended just create a transit with this effect when
1923 * the window that the objects of the transit belongs has already been created.
1924 * This is because this effect needs the geometry information about the objects,
1925 * and if the window was not created yet, it can get a wrong information.
1927 EAPI Elm_Transit_Effect *
1928 elm_transit_effect_resizable_flip_add(Elm_Transit *transit, Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1930 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1931 Elm_Transit_Effect *effect_context = _transit_effect_resizable_flip_context_new(axis, cw);
1933 if (!effect_context) return NULL;
1934 elm_transit_effect_add(transit,
1935 _transit_effect_resizable_flip_op, effect_context,
1936 _transit_effect_resizable_flip_context_free);
1937 return effect_context;
1941 ///////////////////////////////////////////////////////////////////////////////
1943 ///////////////////////////////////////////////////////////////////////////////
1944 typedef struct _Elm_Transit_Effect_Wipe Elm_Transit_Effect_Wipe;
1946 struct _Elm_Transit_Effect_Wipe
1948 Elm_Transit_Effect_Wipe_Type type;
1949 Elm_Transit_Effect_Wipe_Dir dir;
1953 _elm_fx_wipe_hide(Evas_Map * map, Elm_Transit_Effect_Wipe_Dir dir, float x, float y, float w, float h, float progress)
1959 case ELM_TRANSIT_EFFECT_WIPE_DIR_LEFT:
1960 w2 = w - (w * progress);
1962 evas_map_point_image_uv_set(map, 0, 0, 0);
1963 evas_map_point_image_uv_set(map, 1, w2, 0);
1964 evas_map_point_image_uv_set(map, 2, w2, h);
1965 evas_map_point_image_uv_set(map, 3, 0, h);
1966 evas_map_point_coord_set(map, 0, x, y, 0);
1967 evas_map_point_coord_set(map, 1, x + w2, y, 0);
1968 evas_map_point_coord_set(map, 2, x + w2, h2, 0);
1969 evas_map_point_coord_set(map, 3, x, h2, 0);
1971 case ELM_TRANSIT_EFFECT_WIPE_DIR_RIGHT:
1972 w2 = (w * progress);
1974 evas_map_point_image_uv_set(map, 0, w2, 0);
1975 evas_map_point_image_uv_set(map, 1, w, 0);
1976 evas_map_point_image_uv_set(map, 2, w, h);
1977 evas_map_point_image_uv_set(map, 3, w2, h);
1978 evas_map_point_coord_set(map, 0, x + w2, y, 0);
1979 evas_map_point_coord_set(map, 1, x + w, y, 0);
1980 evas_map_point_coord_set(map, 2, x + w, h2, 0);
1981 evas_map_point_coord_set(map, 3, x + w2, h2, 0);
1983 case ELM_TRANSIT_EFFECT_WIPE_DIR_UP:
1985 h2 = h - (h * progress);
1986 evas_map_point_image_uv_set(map, 0, 0, 0);
1987 evas_map_point_image_uv_set(map, 1, w, 0);
1988 evas_map_point_image_uv_set(map, 2, w, h2);
1989 evas_map_point_image_uv_set(map, 3, 0, h2);
1990 evas_map_point_coord_set(map, 0, x, y, 0);
1991 evas_map_point_coord_set(map, 1, w2, y, 0);
1992 evas_map_point_coord_set(map, 2, w2, y+h2, 0);
1993 evas_map_point_coord_set(map, 3, x, y+h2, 0);
1995 case ELM_TRANSIT_EFFECT_WIPE_DIR_DOWN:
1997 h2 = (h * progress);
1998 evas_map_point_image_uv_set(map, 0, 0, h2);
1999 evas_map_point_image_uv_set(map, 1, w, h2);
2000 evas_map_point_image_uv_set(map, 2, w, h);
2001 evas_map_point_image_uv_set(map, 3, 0, h);
2002 evas_map_point_coord_set(map, 0, x, y + h2, 0);
2003 evas_map_point_coord_set(map, 1, w2, y + h2, 0);
2004 evas_map_point_coord_set(map, 2, w2, y + h, 0);
2005 evas_map_point_coord_set(map, 3, x, y + h, 0);
2010 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, _TRANSIT_FOCAL);
2014 _elm_fx_wipe_show(Evas_Map *map, Elm_Transit_Effect_Wipe_Dir dir, float x, float y, float w, float h, float progress)
2020 case ELM_TRANSIT_EFFECT_WIPE_DIR_LEFT:
2021 w2 = (w - (w * progress));
2023 evas_map_point_image_uv_set(map, 0, w2, 0);
2024 evas_map_point_image_uv_set(map, 1, w, 0);
2025 evas_map_point_image_uv_set(map, 2, w, h);
2026 evas_map_point_image_uv_set(map, 3, w2, h);
2027 evas_map_point_coord_set(map, 0, x + w2, y, 0);
2028 evas_map_point_coord_set(map, 1, w, y, 0);
2029 evas_map_point_coord_set(map, 2, w, h2, 0);
2030 evas_map_point_coord_set(map, 3, x + w2, h2, 0);
2032 case ELM_TRANSIT_EFFECT_WIPE_DIR_RIGHT:
2033 w2 = (w * progress);
2035 evas_map_point_image_uv_set(map, 0, 0, 0);
2036 evas_map_point_image_uv_set(map, 1, w2, 0);
2037 evas_map_point_image_uv_set(map, 2, w2, h);
2038 evas_map_point_image_uv_set(map, 3, 0, h);
2039 evas_map_point_coord_set(map, 0, x, y, 0);
2040 evas_map_point_coord_set(map, 1, x + w2, y, 0);
2041 evas_map_point_coord_set(map, 2, x + w2, h2, 0);
2042 evas_map_point_coord_set(map, 3, x, h2, 0);
2044 case ELM_TRANSIT_EFFECT_WIPE_DIR_UP:
2046 h2 = (h - (h * progress));
2047 evas_map_point_image_uv_set(map, 0, 0, h2);
2048 evas_map_point_image_uv_set(map, 1, w, h2);
2049 evas_map_point_image_uv_set(map, 2, w, h);
2050 evas_map_point_image_uv_set(map, 3, 0, h);
2051 evas_map_point_coord_set(map, 0, x, y + h2, 0);
2052 evas_map_point_coord_set(map, 1, w2, y + h2, 0);
2053 evas_map_point_coord_set(map, 2, w2, y + h, 0);
2054 evas_map_point_coord_set(map, 3, x, y + h, 0);
2056 case ELM_TRANSIT_EFFECT_WIPE_DIR_DOWN:
2058 h2 = (h * progress);
2059 evas_map_point_image_uv_set(map, 0, 0, 0);
2060 evas_map_point_image_uv_set(map, 1, w, 0);
2061 evas_map_point_image_uv_set(map, 2, w, h2);
2062 evas_map_point_image_uv_set(map, 3, 0, h2);
2063 evas_map_point_coord_set(map, 0, x, y, 0);
2064 evas_map_point_coord_set(map, 1, w2, y, 0);
2065 evas_map_point_coord_set(map, 2, w2, y + h2, 0);
2066 evas_map_point_coord_set(map, 3, x, y + h2, 0);
2071 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, _TRANSIT_FOCAL);
2075 _transit_effect_wipe_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit)
2077 EINA_SAFETY_ON_NULL_RETURN(effect);
2078 EINA_SAFETY_ON_NULL_RETURN(transit);
2081 Elm_Transit_Effect_Wipe *wipe = effect;
2082 Eina_Bool reverse = elm_transit_auto_reverse_get(transit);
2084 EINA_LIST_FOREACH(transit->objs, elist, obj)
2086 if ((wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_SHOW && !reverse)
2087 || (wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_HIDE && reverse))
2088 evas_object_show(obj);
2089 else evas_object_hide(obj);
2090 evas_object_map_enable_set(obj, EINA_FALSE);
2097 _transit_effect_wipe_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2099 EINA_SAFETY_ON_NULL_RETURN(effect);
2100 EINA_SAFETY_ON_NULL_RETURN(transit);
2101 Elm_Transit_Effect_Wipe *wipe = effect;
2103 Evas_Coord _x, _y, _w, _h;
2107 map = evas_map_new(4);
2110 EINA_LIST_FOREACH(transit->objs, elist, obj)
2112 evas_object_geometry_get(obj, &_x, &_y, &_w, &_h);
2114 if (wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_SHOW)
2115 _elm_fx_wipe_show(map, wipe->dir, _x, _y, _w, _h, (float)progress);
2117 _elm_fx_wipe_hide(map, wipe->dir, _x, _y, _w, _h, (float)progress);
2119 evas_object_map_enable_set(obj, EINA_TRUE);
2120 evas_object_map_set(obj, map);
2125 static Elm_Transit_Effect *
2126 _transit_effect_wipe_context_new(Elm_Transit_Effect_Wipe_Type type, Elm_Transit_Effect_Wipe_Dir dir)
2128 Elm_Transit_Effect_Wipe *wipe;
2130 wipe = ELM_NEW(Elm_Transit_Effect_Wipe);
2131 if (!wipe) return NULL;
2140 * Add the Wipe Effect to Elm_Transit.
2142 * @note This API is one of the facades. It creates wipe effect context
2143 * and add it's required APIs to elm_transit_effect_add.
2145 * @see elm_transit_effect_add()
2147 * @param transit Transit object.
2148 * @param type Wipe type. Hide or show.
2149 * @param dir Wipe Direction.
2150 * @return Wipe effect context data.
2153 * @warning Is higher recommended just create a transit with this effect when
2154 * the window that the objects of the transit belongs has already been created.
2155 * This is because this effect needs the geometry information about the objects,
2156 * and if the window was not created yet, it can get a wrong information.
2159 elm_transit_effect_wipe_add(Elm_Transit *transit, Elm_Transit_Effect_Wipe_Type type, Elm_Transit_Effect_Wipe_Dir dir)
2161 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2162 void *effect_context = _transit_effect_wipe_context_new(type, dir);
2164 if (!effect_context) return NULL;
2165 elm_transit_effect_add(transit,
2166 _transit_effect_wipe_op, effect_context,
2167 _transit_effect_wipe_context_free);
2168 return effect_context;
2172 ///////////////////////////////////////////////////////////////////////////////
2174 ///////////////////////////////////////////////////////////////////////////////
2175 typedef struct _Elm_Transit_Effect_Color Elm_Transit_Effect_Color;
2177 struct _Elm_Transit_Effect_Color
2179 struct _unsigned_color {
2180 unsigned int r, g, b, a;
2182 struct _signed_color {
2188 _transit_effect_color_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
2190 Elm_Transit_Effect_Color *color = effect;
2195 _transit_effect_color_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2197 EINA_SAFETY_ON_NULL_RETURN(effect);
2198 EINA_SAFETY_ON_NULL_RETURN(transit);
2199 Elm_Transit_Effect_Color *color = effect;
2202 unsigned int r, g, b, a;
2204 r = (color->from.r + (int)((float)color->to.r * progress));
2205 g = (color->from.g + (int)((float)color->to.g * progress));
2206 b = (color->from.b + (int)((float)color->to.b * progress));
2207 a = (color->from.a + (int)((float)color->to.a * progress));
2209 EINA_LIST_FOREACH(transit->objs, elist, obj)
2210 evas_object_color_set(obj, r, g, b, a);
2213 static Elm_Transit_Effect *
2214 _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)
2216 Elm_Transit_Effect_Color *color;
2218 color = ELM_NEW(Elm_Transit_Effect_Color);
2219 if (!color) return NULL;
2221 color->from.r = from_r;
2222 color->from.g = from_g;
2223 color->from.b = from_b;
2224 color->from.a = from_a;
2225 color->to.r = to_r - from_r;
2226 color->to.g = to_g - from_g;
2227 color->to.b = to_b - from_b;
2228 color->to.a = to_a - from_a;
2234 * Add the Color Effect to Elm_Transit.
2236 * @note This API is one of the facades. It creates color effect context
2237 * and add it's required APIs to elm_transit_effect_add.
2239 * @see elm_transit_effect_add()
2241 * @param transit Transit object.
2242 * @param from_r RGB R when effect begins.
2243 * @param from_g RGB G when effect begins.
2244 * @param from_b RGB B when effect begins.
2245 * @param from_a RGB A when effect begins.
2246 * @param to_r RGB R when effect ends.
2247 * @param to_g RGB G when effect ends.
2248 * @param to_b RGB B when effect ends.
2249 * @param to_a RGB A when effect ends.
2250 * @return Color effect context data.
2254 EAPI Elm_Transit_Effect *
2255 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)
2257 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2258 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);
2260 if (!effect_context) return NULL;
2261 elm_transit_effect_add(transit,
2262 _transit_effect_color_op, effect_context,
2263 _transit_effect_color_context_free);
2264 return effect_context;
2267 ///////////////////////////////////////////////////////////////////////////////
2269 ///////////////////////////////////////////////////////////////////////////////
2270 typedef struct _Elm_Transit_Effect_Fade Elm_Transit_Effect_Fade;
2271 typedef struct _Elm_Transit_Effect_Fade_Node Elm_Transit_Effect_Fade_Node;
2273 struct _Elm_Transit_Effect_Fade_Node
2275 Evas_Object *before;
2277 struct _signed_color before_color, after_color;
2280 Eina_Bool inversed : 1;
2283 struct _Elm_Transit_Effect_Fade
2289 _fade_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2291 Elm_Transit_Effect_Fade *fade = data;
2293 Elm_Transit_Effect_Fade_Node *fade_node;
2295 EINA_LIST_FOREACH(fade->nodes, elist, fade_node)
2297 if (fade_node->before == obj)
2298 evas_object_event_callback_del(fade_node->after,
2299 EVAS_CALLBACK_DEL, _fade_object_del_cb);
2300 else if (fade_node->after == obj)
2301 evas_object_event_callback_del(fade_node->before,
2302 EVAS_CALLBACK_DEL, _fade_object_del_cb);
2305 fade->nodes = eina_list_remove_list(fade->nodes, elist);
2312 _fade_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Fade *fade_data)
2314 Elm_Transit_Effect_Fade_Node *fade;
2315 Eina_List *data_list = NULL;
2318 count = eina_list_count(transit->objs);
2319 for (i = 0; i < count; i += 2)
2321 fade = ELM_NEW(Elm_Transit_Effect_Fade_Node);
2324 eina_list_free(data_list);
2328 fade->before = eina_list_nth(transit->objs, i);
2329 fade->after = eina_list_nth(transit->objs, i+1);
2331 evas_object_color_get(fade->before,
2332 &fade->before_color.r, &fade->before_color.g,
2333 &fade->before_color.b, &fade->before_color.a);
2334 evas_object_color_get(fade->after,
2335 &fade->after_color.r, &fade->after_color.g,
2336 &fade->after_color.b, &fade->after_color.a);
2338 fade->before_alpha = (255 - fade->before_color.a);
2339 fade->after_alpha = (255 - fade->after_color.a);
2341 data_list = eina_list_append(data_list, fade);
2343 evas_object_event_callback_add(fade->before,
2344 EVAS_CALLBACK_DEL, _fade_object_del_cb, fade_data);
2345 evas_object_event_callback_add(fade->after,
2346 EVAS_CALLBACK_DEL, _fade_object_del_cb, fade_data);
2352 _transit_effect_fade_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
2354 EINA_SAFETY_ON_NULL_RETURN(effect);
2355 Elm_Transit_Effect_Fade *fade = effect;
2356 Elm_Transit_Effect_Fade_Node *fade_node;
2357 Eina_List *elist, *elist_next;
2359 EINA_LIST_FOREACH_SAFE(fade->nodes, elist, elist_next, fade_node)
2361 evas_object_color_set(fade_node->before, fade_node->before_color.r,
2362 fade_node->before_color.g,
2363 fade_node->before_color.b,
2364 fade_node->before_color.a);
2365 evas_object_color_set(fade_node->after, fade_node->after_color.r,
2366 fade_node->after_color.g,
2367 fade_node->after_color.b,
2368 fade_node->after_color.a);
2370 fade->nodes = eina_list_remove_list(fade->nodes, elist);
2371 evas_object_event_callback_del(fade_node->before,
2372 EVAS_CALLBACK_DEL, _fade_object_del_cb);
2373 evas_object_event_callback_del(fade_node->after,
2374 EVAS_CALLBACK_DEL, _fade_object_del_cb);
2382 _transit_effect_fade_op(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__, double progress)
2384 EINA_SAFETY_ON_NULL_RETURN(effect);
2385 Elm_Transit_Effect_Fade *fade = effect;
2387 Elm_Transit_Effect_Fade_Node *fade_node;
2391 fade->nodes = _fade_nodes_build(transit, fade);
2393 EINA_LIST_FOREACH(fade->nodes, elist, fade_node)
2397 if (!fade_node->inversed)
2399 evas_object_hide(fade_node->after);
2400 evas_object_show(fade_node->before);
2401 fade_node->inversed = EINA_TRUE;
2404 _progress = (1 - (progress * 2));
2406 evas_object_color_set(fade_node->before,
2407 fade_node->before_color.r * _progress,
2408 fade_node->before_color.g * _progress,
2409 fade_node->before_color.b * _progress,
2410 fade_node->before_color.a +
2411 fade_node->before_alpha * (1 - _progress));
2415 if (fade_node->inversed)
2417 evas_object_hide(fade_node->before);
2418 evas_object_show(fade_node->after);
2419 fade_node->inversed = EINA_FALSE;
2422 _progress = ((progress - 0.5) * 2);
2424 evas_object_color_set(fade_node->after,
2425 fade_node->after_color.r * _progress,
2426 fade_node->after_color.g * _progress,
2427 fade_node->after_color.b * _progress,
2428 fade_node->after_color.a +
2429 fade_node->after_alpha * (1 - _progress));
2434 static Elm_Transit_Effect *
2435 _transit_effect_fade_context_new(void)
2437 Elm_Transit_Effect_Fade *fade;
2438 fade = ELM_NEW(Elm_Transit_Effect_Fade);
2439 if (!fade) return NULL;
2444 * Add the Fade Effect to Elm_Transit.
2446 * @note This API is one of the facades. It creates fade effect context
2447 * and add it's required APIs to elm_transit_effect_add.
2448 * @note This effect is applied to each pair of objects in the order they are listed
2449 * in the transit list of objects. The first object in the pair will be the
2450 * "before" object and the second will be the "after" object.
2452 * @see elm_transit_effect_add()
2454 * @param transit Transit object.
2455 * @return Fade effect context data.
2458 * @warning Is higher recommended just create a transit with this effect when
2459 * the window that the objects of the transit belongs has already been created.
2460 * This is because this effect needs the color information about the objects,
2461 * and if the window was not created yet, it can get a wrong information.
2463 EAPI Elm_Transit_Effect *
2464 elm_transit_effect_fade_add(Elm_Transit *transit)
2466 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2468 Elm_Transit_Effect *effect_context = _transit_effect_fade_context_new();
2469 if (!effect_context) return NULL;
2470 elm_transit_effect_add(transit,
2471 _transit_effect_fade_op, effect_context,
2472 _transit_effect_fade_context_free);
2473 return effect_context;
2477 ///////////////////////////////////////////////////////////////////////////////
2479 ///////////////////////////////////////////////////////////////////////////////
2480 typedef struct _Elm_Transit_Effect_Blend Elm_Transit_Effect_Blend;
2481 typedef struct _Elm_Transit_Effect_Blend_Node Elm_Transit_Effect_Blend_Node;
2483 struct _Elm_Transit_Effect_Blend_Node
2485 Evas_Object *before;
2487 struct _signed_color from, to;
2490 struct _Elm_Transit_Effect_Blend
2496 _blend_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2498 Elm_Transit_Effect_Blend *blend = data;
2500 Elm_Transit_Effect_Blend_Node *blend_node;
2502 EINA_LIST_FOREACH(blend->nodes, elist, blend_node)
2504 if (blend_node->after == obj)
2505 evas_object_event_callback_del(blend_node->before,
2506 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2507 else if (blend_node->before == obj)
2508 evas_object_event_callback_del(blend_node->after,
2509 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2512 blend->nodes = eina_list_remove_list(blend->nodes, elist);
2519 _blend_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Blend *blend)
2521 Elm_Transit_Effect_Blend_Node *blend_node;
2522 Eina_List *data_list = NULL;
2525 count = eina_list_count(transit->objs);
2526 for (i = 0; i < (count - 1); i += 2)
2528 blend_node = ELM_NEW(Elm_Transit_Effect_Blend_Node);
2531 eina_list_free(data_list);
2535 blend_node->before = eina_list_nth(transit->objs, i);
2536 blend_node->after = eina_list_nth(transit->objs, i + 1);
2537 evas_object_show(blend_node->before);
2538 evas_object_show(blend_node->after);
2540 evas_object_color_get(blend_node->before, &blend_node->from.r,
2541 &blend_node->from.g, &blend_node->from.b,
2542 &blend_node->from.a);
2543 evas_object_color_get(blend_node->after, &blend_node->to.r,
2544 &blend_node->to.g, &blend_node->to.b,
2547 data_list = eina_list_append(data_list, blend_node);
2549 evas_object_event_callback_add(blend_node->before,
2550 EVAS_CALLBACK_DEL, _blend_object_del_cb, blend);
2551 evas_object_event_callback_add(blend_node->after,
2552 EVAS_CALLBACK_DEL, _blend_object_del_cb, blend);
2558 _transit_effect_blend_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
2560 EINA_SAFETY_ON_NULL_RETURN(effect);
2561 Elm_Transit_Effect_Blend *blend = effect;
2562 Elm_Transit_Effect_Blend_Node *blend_node;
2563 Eina_List *elist, *elist_next;
2565 EINA_LIST_FOREACH_SAFE(blend->nodes, elist, elist_next, blend_node)
2567 evas_object_color_set(blend_node->before,
2568 blend_node->from.r, blend_node->from.g,
2569 blend_node->from.b, blend_node->from.a);
2570 evas_object_color_set(blend_node->after, blend_node->to.r,
2571 blend_node->to.g, blend_node->to.b,
2574 if (elm_transit_auto_reverse_get(transit))
2575 evas_object_hide(blend_node->after);
2577 evas_object_hide(blend_node->before);
2579 blend->nodes = eina_list_remove_list(blend->nodes, elist);
2581 evas_object_event_callback_del(blend_node->before,
2582 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2583 evas_object_event_callback_del(blend_node->after,
2584 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2591 _transit_effect_blend_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2593 EINA_SAFETY_ON_NULL_RETURN(effect);
2594 EINA_SAFETY_ON_NULL_RETURN(transit);
2595 Elm_Transit_Effect_Blend *blend = effect;
2596 Elm_Transit_Effect_Blend_Node *blend_node;
2599 if (!blend->nodes) blend->nodes = _blend_nodes_build(transit, blend);
2601 EINA_LIST_FOREACH(blend->nodes, elist, blend_node)
2603 evas_object_color_set(blend_node->before,
2604 (int)(blend_node->from.r * (1 - progress)),
2605 (int)(blend_node->from.g * (1 - progress)),
2606 (int)(blend_node->from.b * (1 - progress)),
2607 (int)(blend_node->from.a * (1 - progress)));
2608 evas_object_color_set(blend_node->after,
2609 (int)(blend_node->to.r * progress),
2610 (int)(blend_node->to.g * progress),
2611 (int)(blend_node->to.b * progress),
2612 (int)(blend_node->to.a * progress));
2616 static Elm_Transit_Effect *
2617 _transit_effect_blend_context_new(void)
2619 Elm_Transit_Effect_Blend *blend;
2621 blend = ELM_NEW(Elm_Transit_Effect_Blend);
2622 if (!blend) return NULL;
2627 * Add the Blend Effect to Elm_Transit.
2629 * @note This API is one of the facades. It creates blend effect context
2630 * and add it's required APIs to elm_transit_effect_add.
2631 * @note This effect is applied to each pair of objects in the order they are listed
2632 * in the transit list of objects. The first object in the pair will be the
2633 * "before" object and the second will be the "after" object.
2635 * @see elm_transit_effect_add()
2637 * @param transit Transit object.
2638 * @return Blend effect context data.
2641 * @warning Is higher recommended just create a transit with this effect when
2642 * the window that the objects of the transit belongs has already been created.
2643 * This is because this effect needs the color information about the objects,
2644 * and if the window was not created yet, it can get a wrong information.
2646 EAPI Elm_Transit_Effect *
2647 elm_transit_effect_blend_add(Elm_Transit *transit)
2649 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2650 Elm_Transit_Effect *effect_context = _transit_effect_blend_context_new();
2652 if (!effect_context) return NULL;
2653 elm_transit_effect_add(transit,
2654 _transit_effect_blend_op, effect_context,
2655 _transit_effect_blend_context_free);
2656 return effect_context;
2660 ///////////////////////////////////////////////////////////////////////////////
2662 ///////////////////////////////////////////////////////////////////////////////
2663 typedef struct _Elm_Transit_Effect_Rotation Elm_Transit_Effect_Rotation;
2665 struct _Elm_Transit_Effect_Rotation
2671 _transit_effect_rotation_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
2673 Elm_Transit_Effect_Rotation *rotation = effect;
2678 _transit_effect_rotation_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2680 EINA_SAFETY_ON_NULL_RETURN(effect);
2681 EINA_SAFETY_ON_NULL_RETURN(transit);
2682 Elm_Transit_Effect_Rotation *rotation = effect;
2684 Evas_Coord x, y, w, h;
2686 float half_w, half_h;
2690 map = evas_map_new(4);
2693 EINA_LIST_FOREACH(transit->objs, elist, obj)
2695 evas_map_util_points_populate_from_object_full(map, obj, 0);
2696 degree = rotation->from + (float)(progress * rotation->to);
2698 evas_object_geometry_get(obj, &x, &y, &w, &h);
2700 half_w = (float)w * 0.5;
2701 half_h = (float)h * 0.5;
2703 evas_map_util_3d_rotate(map, 0, 0, degree, x + half_w, y + half_h, 0);
2704 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, _TRANSIT_FOCAL);
2705 evas_object_map_enable_set(obj, EINA_TRUE);
2706 evas_object_map_set(obj, map);
2711 static Elm_Transit_Effect *
2712 _transit_effect_rotation_context_new(float from_degree, float to_degree)
2714 Elm_Transit_Effect_Rotation *rotation;
2716 rotation = ELM_NEW(Elm_Transit_Effect_Rotation);
2717 if (!rotation) return NULL;
2719 rotation->from = from_degree;
2720 rotation->to = to_degree - from_degree;
2726 * Add the Rotation Effect to Elm_Transit.
2728 * @note This API is one of the facades. It creates rotation effect context
2729 * and add it's required APIs to elm_transit_effect_add.
2731 * @see elm_transit_effect_add()
2733 * @param transit Transit object.
2734 * @param from_degree Degree when effect begins.
2735 * @param to_degree Degree when effect is ends.
2736 * @return Rotation effect context data.
2739 * @warning Is higher recommended just create a transit with this effect when
2740 * the window that the objects of the transit belongs has already been created.
2741 * This is because this effect needs the geometry information about the objects,
2742 * and if the window was not created yet, it can get a wrong information.
2744 EAPI Elm_Transit_Effect *
2745 elm_transit_effect_rotation_add(Elm_Transit *transit, float from_degree, float to_degree)
2747 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2748 Elm_Transit_Effect *effect_context = _transit_effect_rotation_context_new(from_degree, to_degree);
2750 if (!effect_context) return NULL;
2751 elm_transit_effect_add(transit,
2752 _transit_effect_rotation_op, effect_context,
2753 _transit_effect_rotation_context_free);
2754 return effect_context;
2758 ///////////////////////////////////////////////////////////////////////////////
2759 //ImageAnimation Effect
2760 ///////////////////////////////////////////////////////////////////////////////
2761 typedef struct _Elm_Transit_Effect_Image_Animation Elm_Transit_Effect_Image_Animation;
2763 struct _Elm_Transit_Effect_Image_Animation
2769 _transit_effect_image_animation_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
2771 EINA_SAFETY_ON_NULL_RETURN(effect);
2772 Elm_Transit_Effect_Image_Animation *image_animation = effect;
2774 Eina_List *elist, *elist_next;
2776 EINA_LIST_FOREACH_SAFE(image_animation->images, elist, elist_next, image)
2778 image_animation->images =
2779 eina_list_remove_list(image_animation->images, elist);
2780 eina_stringshare_del(image);
2783 free(image_animation);
2787 _transit_effect_image_animation_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2789 EINA_SAFETY_ON_NULL_RETURN(effect);
2790 EINA_SAFETY_ON_NULL_RETURN(transit);
2794 Elm_Transit_Effect_Image_Animation *image_animation = effect;
2795 unsigned int count = 0;
2798 type = eina_stringshare_add("icon");
2799 len = eina_list_count(image_animation->images);
2801 if (!len) count = floor(progress * len);
2802 else count = floor(progress * (len - 1));
2804 EINA_LIST_FOREACH(transit->objs, elist, obj)
2806 if (elm_widget_type_check(obj, type))
2807 elm_icon_file_set(obj,
2808 eina_list_nth(image_animation->images, count), NULL);
2811 eina_stringshare_del(type);
2814 static Elm_Transit_Effect *
2815 _transit_effect_image_animation_context_new(Eina_List *images)
2817 Elm_Transit_Effect_Image_Animation *image_animation;
2818 image_animation = ELM_NEW(Elm_Transit_Effect_Image_Animation);
2820 if (!image_animation) return NULL;
2821 image_animation->images = images;
2822 return image_animation;
2826 * Add the ImageAnimation Effect to Elm_Transit.
2828 * @note This API is one of the facades. It creates image animation effect context
2829 * and add it's required APIs to elm_transit_effect_add.
2830 * The @p images parameter is a list images paths. This list and
2831 * its contents will be deleted at the end of the effect by
2832 * elm_transit_effect_image_animation_context_free() function.
2836 * char buf[PATH_MAX];
2837 * Eina_List *images = NULL;
2838 * Elm_Transit *transi = elm_transit_add();
2840 * snprintf(buf, sizeof(buf), "%s/images/icon_11.png", PACKAGE_DATA_DIR);
2841 * images = eina_list_append(images, eina_stringshare_add(buf));
2843 * snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
2844 * images = eina_list_append(images, eina_stringshare_add(buf));
2845 * elm_transit_effect_image_animation_add(transi, images);
2849 * @see elm_transit_effect_add()
2851 * @param transit Transit object.
2852 * @param images Eina_List of images file paths. This list and
2853 * its contents will be deleted at the end of the effect by
2854 * elm_transit_effect_image_animation_context_free() function.
2855 * @return Image Animation effect context data.
2859 EAPI Elm_Transit_Effect *
2860 elm_transit_effect_image_animation_add(Elm_Transit *transit, Eina_List *images)
2862 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2863 Elm_Transit_Effect *effect = _transit_effect_image_animation_context_new(images);
2865 if (!effect) return NULL;
2866 elm_transit_effect_add(transit,
2867 _transit_effect_image_animation_op, effect,
2868 _transit_effect_image_animation_context_free);