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, 5);
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, -1);
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";
57 #define ELM_TRANSIT_MAGIC 0xd27f190a
60 Ecore_Animator *animator;
61 Eina_List *effect_list;
63 Elm_Transit_Tween_Mode tween_mode;
65 void (*func) (void *data, Elm_Transit *transit);
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
91 void (*animation_op) (void *data, Elm_Transit *transit, double progress);
92 void (*user_data_free) (void *data, Elm_Transit *transit);
94 Eina_Bool deleted : 1;
99 Evas_Coord x, y, w, h;
102 Eina_Bool map_enabled : 1;
103 Eina_Bool visible : 1;
108 Elm_Transit *transit;
109 struct _Elm_Obj_State *state;
110 Eina_Bool pass_events : 1;
113 typedef struct _Elm_Transit_Effect Elm_Transit_Effect;
114 typedef struct _Elm_Obj_Data Elm_Obj_Data;
115 typedef struct _Elm_Obj_State Elm_Obj_State;
118 _elm_transit_obj_states_save(Evas_Object *obj)
120 Elm_Obj_Data *obj_data;
121 Elm_Obj_State *state;
123 obj_data = evas_object_data_get(obj, _transit_key);
124 if ((!obj_data) || (obj_data->state)) return;
125 state = calloc(1, sizeof(Elm_Obj_State));
127 evas_object_geometry_get(obj, &state->x, &state->y, &state->w, &state->h);
128 evas_object_color_get(obj, &state->r, &state->g, &state->b, &state->a);
129 state->visible = evas_object_visible_get(obj);
130 state->map_enabled = evas_object_map_enable_get(obj);
131 if (evas_object_map_get(obj))
132 state->map = evas_map_dup(evas_object_map_get(obj));
133 obj_data->state = state;
137 _elm_transit_object_remove_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
139 Elm_Transit *transit = data;
140 Elm_Obj_Data *obj_data = evas_object_data_del(obj, _transit_key);
141 evas_object_pass_events_set(obj, obj_data->pass_events);
143 free(obj_data->state);
145 transit->objs = eina_list_remove(transit->objs, obj);
146 if (!transit->objs) elm_transit_del(transit);
150 _elm_transit_object_remove(Elm_Transit *transit, Evas_Object *obj)
153 Elm_Obj_Data *obj_data = evas_object_data_del(obj, _transit_key);
154 Elm_Obj_State *state = obj_data->state;
156 evas_object_pass_events_set(obj, obj_data->pass_events);
160 //recover the states of the object.
161 if (!transit->state_keep)
163 evas_object_move(obj, state->x, state->y);
164 evas_object_resize(obj, state->w, state->h);
165 evas_object_color_set(obj, state->r, state->g, state->b, state->a);
166 if (state->visible) evas_object_show(obj);
167 else evas_object_hide(obj);
168 if (state->map_enabled)
169 evas_object_map_enable_set(obj, EINA_TRUE);
171 evas_object_map_enable_set(obj, EINA_FALSE);
173 evas_object_map_set(obj, state->map);
180 //remove duplicated objects
181 //TODO: Need to consider about optimizing here
184 if (!eina_list_data_find_list(transit->objs, obj))
186 transit->objs = eina_list_remove(transit->objs, obj);
189 evas_object_event_callback_del(obj, EVAS_CALLBACK_DEL,
190 _elm_transit_object_remove_cb);
194 _elm_transit_effect_del(Elm_Transit *transit, Elm_Transit_Effect *effect, Eina_List *elist)
196 if (effect->user_data_free)
197 effect->user_data_free(effect->user_data, transit);
199 transit->effect_list = eina_list_remove_list(transit->effect_list, elist);
204 _remove_dead_effects(Elm_Transit *transit)
206 Eina_List *elist, *elist_next;
207 Elm_Transit_Effect *effect;
209 EINA_LIST_FOREACH_SAFE(transit->effect_list, elist, elist_next, effect)
213 _elm_transit_effect_del(transit, effect, elist);
214 transit->effects_pending_del--;
215 if (!transit->effects_pending_del) return;
221 _elm_transit_del(Elm_Transit *transit)
223 Eina_List *elist, *elist_next;
224 Elm_Transit_Effect *effect;
226 if (transit->animator)
227 ecore_animator_del(transit->animator);
229 EINA_LIST_FOREACH_SAFE(transit->effect_list, elist, elist_next, effect)
230 _elm_transit_effect_del(transit, effect, elist);
232 while (transit->objs)
233 _elm_transit_object_remove(transit, eina_list_data_get(transit->objs));
235 if (transit->del_data.func)
236 transit->del_data.func(transit->del_data.arg, transit);
238 EINA_MAGIC_SET(transit, EINA_MAGIC_NONE);
243 _transit_animate_op(Elm_Transit *transit, double progress)
246 Elm_Transit_Effect *effect;
249 EINA_LIST_FOREACH(transit->effect_list, elist, effect)
251 if (transit->deleted) break;
252 if (!effect->deleted)
253 effect->animation_op(effect->user_data, transit, progress);
257 if (transit->walking) return;
259 if (transit->deleted) _elm_transit_del(transit);
260 else if (transit->effects_pending_del) _remove_dead_effects(transit);
264 _animator_animate_cb(void *data)
266 Elm_Transit *transit = data;
267 double elapsed_time, duration;
269 transit->time.current = ecore_loop_time_get();
270 elapsed_time = transit->time.current - transit->time.begin;
271 duration = transit->time.duration + transit->time.delayed;
273 if (elapsed_time > duration)
274 elapsed_time = duration;
276 transit->progress = elapsed_time / duration;
277 switch (transit->tween_mode)
279 case ELM_TRANSIT_TWEEN_MODE_ACCELERATE:
280 transit->progress = 1.0 - sin((ELM_PI / 2.0) + (transit->progress * ELM_PI / 2.0));
282 case ELM_TRANSIT_TWEEN_MODE_DECELERATE:
283 transit->progress = sin(transit->progress * ELM_PI / 2.0);
285 case ELM_TRANSIT_TWEEN_MODE_SINUSOIDAL:
286 transit->progress = (1.0 - cos(transit->progress * ELM_PI)) / 2.0;
293 if (transit->repeat.reverse) transit->progress = 1 - transit->progress;
295 if (transit->time.duration > 0) _transit_animate_op(transit, transit->progress);
297 /* Not end. Keep going. */
298 if (elapsed_time < duration) return ECORE_CALLBACK_RENEW;
300 /* Repeat and reverse and time done! */
301 if ((transit->repeat.count >= 0) &&
302 (transit->repeat.current == transit->repeat.count) &&
303 ((!transit->auto_reverse) || transit->repeat.reverse))
305 elm_transit_del(transit);
306 return ECORE_CALLBACK_CANCEL;
310 if (!transit->auto_reverse || transit->repeat.reverse)
312 transit->repeat.current++;
313 transit->repeat.reverse = EINA_FALSE;
315 else transit->repeat.reverse = EINA_TRUE;
317 transit->time.begin = ecore_loop_time_get();
319 return ECORE_CALLBACK_RENEW;
325 * @note Is not necessary to delete the transit object, it will be deleted at
326 * the end of its operation.
327 * @note The transit will start playing when the program enter in the main loop, is not
328 * necessary to give a start to the transit.
330 * @param duration The duration of the transit in seconds. When transit starts
331 * to run, it will last a @p duration time.
332 * @return The transit object.
337 elm_transit_add(void)
339 Elm_Transit *transit = ELM_NEW(Elm_Transit);
340 if (!transit) return NULL;
342 EINA_MAGIC_SET(transit, ELM_TRANSIT_MAGIC);
344 elm_transit_tween_mode_set(transit, ELM_TRANSIT_TWEEN_MODE_LINEAR);
349 * Stops the animation and delete the @p transit object.
351 * Call this function if you wants to stop the animation before the duration
352 * time. Make sure the @p transit object is still alive with
353 * elm_transit_del_cb_set() function.
354 * All added effects will be deleted, calling its repective data_free_cb
355 * functions. The function setted by elm_tansit_del_cb_set() will be called.
357 * @see elm_transit_del_cb_set()
359 * @param transit The transit object to be deleted.
362 * @warning Just call this function if you are sure the transit is alive.
365 elm_transit_del(Elm_Transit *transit)
367 ELM_TRANSIT_CHECK_OR_RETURN(transit);
369 if (transit->walking) transit->deleted = EINA_TRUE;
370 else _elm_transit_del(transit);
374 * Add a new effect to the transit.
376 * @note The cb function and the data are the key to the effect. If you try to
377 * add an already added effect, nothing is done.
378 * @note After the first addition of an effect in @p transit, if its
379 * effect list become empty again, the @p transit will be killed by
380 * elm_transit_del(transit) function.
384 * Elm_Transit *transit = elm_transit_add();
385 * elm_transit_effect_add(transit,
386 * elm_transit_effect_blend_op,
387 * elm_transit_effect_blend_context_new(),
388 * elm_transit_effect_blend_context_free);
391 * @param transit The transit object.
392 * @param cb The operation function. It is called when the animation begins,
393 * it is the function that actually performs the animation. It is called with
394 * the @p data, @p transit and the time progression of the animation (a double
395 * value between 0.0 and 1.0).
396 * @param data The context data of the effect.
397 * @param data_free_cb The function to free the context data, it will be called
398 * at the end of the effect, it must finalize the animation and free the
402 * @warning The transit free the context data at the and of the transition with
403 * the data_free_cb function, do not use the context data in another transit.
406 elm_transit_effect_add(Elm_Transit *transit, void (*cb)(void *data, Elm_Transit *transit, double progress), void *data, void (*data_free_cb)(void *data, Elm_Transit *transit))
408 ELM_TRANSIT_CHECK_OR_RETURN(transit);
409 EINA_SAFETY_ON_NULL_RETURN(cb);
410 Elm_Transit_Effect *effect;
413 EINA_LIST_FOREACH(transit->effect_list, elist, effect)
414 if ((effect->animation_op == cb) && (effect->user_data == data)) return;
416 effect = ELM_NEW(Elm_Transit_Effect);
419 effect->user_data_free = data_free_cb;
420 effect->animation_op = cb;
421 effect->user_data = data;
423 transit->effect_list = eina_list_append(transit->effect_list, effect);
427 * Delete an added effect.
429 * This function will remove the effect from the @p transit, calling the
430 * data_free_cb to free the @p data.
432 * @see elm_transit_effect_add()
434 * @note If the effect is not found, nothing is done.
435 * @note If the effect list become empty, this function will call
436 * elm_transit_del(transit), that is, it will kill the @p transit.
438 * @param transit The transit object.
439 * @param cb The operation function.
440 * @param data The context data of the effect.
445 elm_transit_effect_del(Elm_Transit *transit, void (*cb)(void *data, Elm_Transit *transit, double progress), void *data)
447 ELM_TRANSIT_CHECK_OR_RETURN(transit);
448 EINA_SAFETY_ON_NULL_RETURN(cb);
449 Eina_List *elist, *elist_next;
450 Elm_Transit_Effect *effect;
452 EINA_LIST_FOREACH_SAFE(transit->effect_list, elist, elist_next, effect)
454 if ((effect->animation_op == cb) && (effect->user_data == data))
456 if (transit->walking)
458 effect->deleted = EINA_TRUE;
459 transit->effects_pending_del++;
463 _elm_transit_effect_del(transit, effect, elist);
464 if (!transit->effect_list) elm_transit_del(transit);
472 * Add new object to apply the effects.
474 * @note After the first addition of an object in @p transit, if its
475 * object list become empty again, the @p transit will be killed by
476 * elm_transit_del(transit) function.
477 * @note If the @p obj belongs to another transit, the @p obj will be
478 * removed from it and it will only belong to the @p transit. If the old
479 * transit stays without objects, it will die.
480 * @note When you add an object into the @p transit, its state from
481 * evas_object_pass_events_get(obj) is saved, and it is applied when the
482 * transit ends, if you change this state whith evas_object_pass_events_set()
483 * after add the object, this state will change again when @p transit stops to
486 * @param transit The transit object.
487 * @param obj Object to be animated.
490 * @warning It is not allowed to add a new object after transit begins to go.
493 elm_transit_object_add(Elm_Transit *transit, Evas_Object *obj)
495 ELM_TRANSIT_CHECK_OR_RETURN(transit);
496 EINA_SAFETY_ON_NULL_RETURN(obj);
497 Elm_Obj_Data *obj_data;
499 obj_data = evas_object_data_get(obj, _transit_key);
501 if ((obj_data) && (obj_data->transit != transit))
502 elm_transit_object_remove(obj_data->transit, obj);
504 if ((!obj_data) || (obj_data->transit != transit))
506 obj_data = ELM_NEW(Elm_Obj_Data);
507 obj_data->pass_events = evas_object_pass_events_get(obj);
508 obj_data->transit = transit;
509 evas_object_data_set(obj, _transit_key, obj_data);
510 if (!transit->event_enabled)
511 evas_object_pass_events_set(obj, EINA_TRUE);
513 evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
514 _elm_transit_object_remove_cb,
518 transit->objs = eina_list_append(transit->objs, obj);
520 if (!transit->state_keep)
521 _elm_transit_obj_states_save(obj);
526 * Removes an added object from the transit.
528 * @note If the @p obj is not in the @p transit, nothing is done.
529 * @note If the list become empty, this function will call
530 * elm_transit_del(transit), that is, it will kill the @p transit.
532 * @param transit The transit object.
533 * @param obj Object to be removed from @p transit.
536 * @warning It is not allowed to remove objects after transit begins to go.
539 elm_transit_object_remove(Elm_Transit *transit, Evas_Object *obj)
541 ELM_TRANSIT_CHECK_OR_RETURN(transit);
542 EINA_SAFETY_ON_NULL_RETURN(obj);
543 Elm_Obj_Data *obj_data;
545 obj_data = evas_object_data_get(obj, _transit_key);
547 if ((!obj_data) || (obj_data->transit != transit)) return;
549 _elm_transit_object_remove(transit, obj);
550 if (!transit->objs) elm_transit_del(transit);
554 * Get the objects of the transit.
556 * @param transit The transit object.
557 * @return a Eina_List with the objects from the transit.
561 EAPI const Eina_List *
562 elm_transit_objects_get(const Elm_Transit *transit)
564 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
565 return transit->objs;
569 * Set the event enabled when transit is operating.
571 * If @p enabled is EINA_TRUE, the objects of the transit will receives
572 * events from mouse and keyboard during the animation.
573 * @note When you add an object with elm_transit_object_add(), its state from
574 * evas_object_pass_events_get(obj) is saved, and it is applied when the
575 * transit ends, if you change this state with evas_object_pass_events_set()
576 * after adding the object, this state will change again when @p transit stops
579 * @param transit The transit object.
580 * @param enabled Disable or enable.
585 elm_transit_event_enabled_set(Elm_Transit *transit, Eina_Bool enabled)
587 ELM_TRANSIT_CHECK_OR_RETURN(transit);
590 Elm_Obj_Data *obj_data;
592 if (transit->event_enabled == enabled) return;
594 transit->event_enabled = !!enabled;
598 EINA_LIST_FOREACH(transit->objs, elist, obj)
600 obj_data = evas_object_data_get(obj, _transit_key);
601 evas_object_pass_events_set(obj, obj_data->pass_events);
606 EINA_LIST_FOREACH(transit->objs, elist, obj)
607 evas_object_pass_events_set(obj, EINA_TRUE);
612 * Get the value of event enabled status.
614 * @see elm_transit_event_enabled_set()
616 * @param transit The Transit object
617 * @return EINA_TRUE, when event is enabled. If @p transit is NULL
618 * EINA_FALSE is returned
623 elm_transit_event_enabled_get(const Elm_Transit *transit)
625 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
626 return transit->event_enabled;
631 * Set the event enabled when transit is operating.
633 * If @p disabled is EINA_TRUE, the objects of the transit will receives
634 * events from mouse and keyboard during the animation.
635 * @note When you add an object with elm_transit_object_add(), its state from
636 * evas_object_pass_events_get(obj) is saved, and it is applied when the
637 * transit ends, if you change this state with evas_object_pass_events_set()
638 * after add the object, this state will change again when @p transit stops to
641 * @see elm_transit_event_enabled_set()
643 * @param transit The transit object.
644 * @param disabled Disable or enable.
648 EINA_DEPRECATED EAPI void
649 elm_transit_event_block_set(Elm_Transit *transit, Eina_Bool disabled)
651 elm_transit_event_enabled_set(transit, disabled);
656 * Get the value of event block enabled status.
658 * @see elm_transit_event_enabled_set(), elm_transit_event_enabled_get()
660 * @param transit The Transit object
661 * @return EINA_TRUE, when event is enabled. If @p transit is NULL
662 * EINA_FALSE is returned
666 EINA_DEPRECATED EAPI Eina_Bool
667 elm_transit_event_block_get(const Elm_Transit *transit)
669 return !elm_transit_event_enabled_get(transit);
673 * Set the user-callback function when the transit is deleted.
675 * @note Using this function twice will overwrite the first function setted.
676 * @note the @p transit object will be deleted after call @p cb function.
678 * @param transit The transit object.
679 * @param cb Callback function pointer. This function will be called before
680 * the deletion of the transit.
681 * @param data Callback funtion user data. It is the @p op parameter.
686 elm_transit_del_cb_set(Elm_Transit *transit, void (*cb) (void *data, Elm_Transit *transit), void *data)
688 ELM_TRANSIT_CHECK_OR_RETURN(transit);
689 transit->del_data.func = cb;
690 transit->del_data.arg = data;
694 * Set reverse effect automatically.
696 * If auto reverse is setted, after running the effects with the progress
697 * parameter from 0 to 1, it will call the effecs again with the progress
698 * from 1 to 0. The transit will last for a time iqual to (2 * duration * repeat),
699 * where the duration was setted with the function elm_transit_add and
700 * the repeat with the function elm_transit_repeat_times_set().
702 * @param transit The transit object.
703 * @param reverse EINA_TRUE means the auto_reverse is on.
708 elm_transit_auto_reverse_set(Elm_Transit *transit, Eina_Bool reverse)
710 ELM_TRANSIT_CHECK_OR_RETURN(transit);
711 transit->auto_reverse = reverse;
715 * Get if the auto reverse is on.
717 * @see elm_transit_auto_reverse_set()
719 * @param transit The transit object.
720 * @return EINA_TRUE means auto reverse is on. If @p transit is NULL
721 * EINA_FALSE is returned
726 elm_transit_auto_reverse_get(const Elm_Transit *transit)
728 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
729 return transit->auto_reverse;
733 * Set the transit repeat count. Effect will be repeated by repeat count.
735 * This function sets the number of repetition the transit will run after
736 * the first one, that is, if @p repeat is 1, the transit will run 2 times.
737 * If the @p repeat is a negative number, it will repeat infinite times.
739 * @note If this function is called during the transit execution, the transit
740 * will run @p repeat times, ignoring the times it already performed.
742 * @param transit The transit object
743 * @param repeat Repeat count
748 elm_transit_repeat_times_set(Elm_Transit *transit, int repeat)
750 ELM_TRANSIT_CHECK_OR_RETURN(transit);
751 transit->repeat.count = repeat;
752 transit->repeat.current = 0;
756 * Get the transit repeat count.
758 * @see elm_transit_repeat_times_set()
760 * @param transit The Transit object.
761 * @return The repeat count. If @p transit is NULL
767 elm_transit_repeat_times_get(const Elm_Transit *transit)
769 ELM_TRANSIT_CHECK_OR_RETURN(transit, 0);
770 return transit->repeat.count;
774 * Set the transit animation acceleration type.
776 * This function sets the tween mode of the transit that can be:
777 * ELM_TRANSIT_TWEEN_MODE_LINEAR - The default mode.
778 * ELM_TRANSIT_TWEEN_MODE_SINUSOIDAL - Starts in accelerate mode and ends decelerating.
779 * ELM_TRANSIT_TWEEN_MODE_DECELERATE - The animation will be slowed over time.
780 * ELM_TRANSIT_TWEEN_MODE_ACCELERATE - The animation will accelerate over time.
782 * @param transit The transit object.
783 * @param tween_mode The tween type.
788 elm_transit_tween_mode_set(Elm_Transit *transit, Elm_Transit_Tween_Mode tween_mode)
790 ELM_TRANSIT_CHECK_OR_RETURN(transit);
791 transit->tween_mode = tween_mode;
795 * Get the transit animation acceleration type.
797 * @note @p transit can not be NULL
799 * @param transit The transit object.
800 * @return The tween type. If @p transit is NULL
801 * ELM_TRANSIT_TWEEN_MODE_LINEAR is returned.
805 EAPI Elm_Transit_Tween_Mode
806 elm_transit_tween_mode_get(const Elm_Transit *transit)
808 ELM_TRANSIT_CHECK_OR_RETURN(transit, ELM_TRANSIT_TWEEN_MODE_LINEAR);
809 return transit->tween_mode;
813 * Set the transit animation time
815 * @note @p transit can not be NULL
817 * @param transit The transit object.
818 * @param duration The animation time.
823 elm_transit_duration_set(Elm_Transit *transit, double duration)
825 ELM_TRANSIT_CHECK_OR_RETURN(transit);
826 if (transit->animator) return;
827 transit->time.duration = duration;
831 * Get the transit animation time
833 * @note @p transit can not be NULL
835 * @param transit The transit object.
837 * @return The transit animation time.
842 elm_transit_duration_get(const Elm_Transit *transit)
844 ELM_TRANSIT_CHECK_OR_RETURN(transit, 0.0);
845 return transit->time.duration;
849 * Starts the transition.
850 * Once this API is called, the transit begins to measure the time.
852 * @note @p transit can not be NULL
854 * @param transit The transit object.
859 elm_transit_go(Elm_Transit *transit)
861 ELM_TRANSIT_CHECK_OR_RETURN(transit);
863 if (transit->animator)
864 ecore_animator_del(transit->animator);
866 transit->time.paused = 0;
867 transit->time.delayed = 0;
868 transit->time.begin = ecore_loop_time_get();
869 transit->animator = ecore_animator_add(_animator_animate_cb, transit);
873 * Pause/Resume the transition.
874 * If you call elm_transit_go again, paused states will affect no anymore.
876 * @note @p transit can not be NULL
878 * @param transit The transit object.
883 elm_transit_paused_set(Elm_Transit *transit, Eina_Bool paused)
885 ELM_TRANSIT_CHECK_OR_RETURN(transit);
887 if (!transit->animator) return;
891 if (transit->time.paused > 0)
893 ecore_animator_freeze(transit->animator);
894 transit->time.paused = ecore_loop_time_get();
898 if (transit->time.paused == 0)
900 ecore_animator_thaw(transit->animator);
901 transit->time.delayed += (ecore_loop_time_get() - transit->time.paused);
902 transit->time.paused = 0;
907 * Get the value of paused status.
909 * @see elm_transit_paused_set()
911 * @note @p transit can not be NULL
913 * @param transit The transit object.
914 * @return EINA_TRUE means transition is paused. If @p transit is NULL
915 * EINA_FALSE is returned
920 elm_transit_paused_get(const Elm_Transit *transit)
922 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
924 if (transit->time.paused == 0)
931 * Get the time progression of the animation (a double value between 0.0 and 1.0).
933 * @note @p transit can not be NULL
935 * @param transit The transit object.
937 * @return The time progression value. If @p transit is NULL
943 elm_transit_progress_value_get(const Elm_Transit *transit)
945 ELM_TRANSIT_CHECK_OR_RETURN(transit, 0);
946 return transit->progress;
950 * Enable/disable keeping up the objects states.
951 * If it is not kept, the objects states will be reset when transition ends.
953 * @note @p transit can not be NULL.
954 * @note One state includes geometry, color, map data.
956 * @param transit The transit object.
957 * @param state_keep Keeping or Non Keeping.
962 elm_transit_objects_final_state_keep_set(Elm_Transit *transit, Eina_Bool state_keep)
967 ELM_TRANSIT_CHECK_OR_RETURN(transit);
968 if (transit->state_keep == state_keep) return;
969 if (transit->animator) return;
970 transit->state_keep = !!state_keep;
973 EINA_LIST_FOREACH(transit->objs, list, obj)
974 _elm_transit_obj_states_save(obj);
979 * Get a value whether the objects states will be reset or not.
981 * @note @p transit can not be NULL
983 * @see elm_transit_objects_final_state_keep_set()
985 * @param transit The transit object.
986 * @return EINA_TRUE means the states of the objects will be reset.
987 * If @p transit is NULL, EINA_FALSE is returned
992 elm_transit_objects_final_state_keep_get(const Elm_Transit *transit)
994 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
995 return transit->state_keep;
998 ///////////////////////////////////////////////////////////////////////////////
1000 ///////////////////////////////////////////////////////////////////////////////
1001 typedef struct _Elm_Transit_Effect_Resizing Elm_Transit_Effect_Resizing;
1003 struct _Elm_Transit_Effect_Resizing
1011 _transit_effect_resizing_context_free(void *data, Elm_Transit *transit __UNUSED__)
1017 _transit_effect_resizing_op(void *data, Elm_Transit *transit, double progress)
1019 EINA_SAFETY_ON_NULL_RETURN(data);
1020 EINA_SAFETY_ON_NULL_RETURN(transit);
1024 Elm_Transit_Effect_Resizing *resizing = data;
1026 w = resizing->from.w + (resizing->to.w * progress);
1027 h = resizing->from.h + (resizing->to.h * progress);
1029 EINA_LIST_FOREACH(transit->objs, elist, obj)
1030 evas_object_resize(obj, w, h);
1034 _transit_effect_resizing_context_new(Evas_Coord from_w, Evas_Coord from_h, Evas_Coord to_w, Evas_Coord to_h)
1036 Elm_Transit_Effect_Resizing *resizing;
1038 resizing = ELM_NEW(Elm_Transit_Effect_Resizing);
1039 if (!resizing) return NULL;
1041 resizing->from.w = from_w;
1042 resizing->from.h = from_h;
1043 resizing->to.w = to_w - from_w;
1044 resizing->to.h = to_h - from_h;
1050 * Add the Resizing Effect to Elm_Transit.
1052 * @note This API is one of the facades. It creates resizing effect context
1053 * and add it's required APIs to elm_transit_effect_add.
1055 * @see elm_transit_effect_add()
1057 * @param transit Transit object.
1058 * @param from_w Object width size when effect begins.
1059 * @param from_h Object height size when effect begins.
1060 * @param to_w Object width size when effect ends.
1061 * @param to_h Object height size when effect ends.
1062 * @return Resizing effect context data.
1067 elm_transit_effect_resizing_add(Elm_Transit *transit, Evas_Coord from_w, Evas_Coord from_h, Evas_Coord to_w, Evas_Coord to_h)
1069 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1070 void *effect_context = _transit_effect_resizing_context_new(from_w, from_h, to_w, to_h);
1072 if (!effect_context) return NULL;
1073 elm_transit_effect_add(transit,
1074 _transit_effect_resizing_op, effect_context,
1075 _transit_effect_resizing_context_free);
1076 return effect_context;
1079 ///////////////////////////////////////////////////////////////////////////////
1080 //Translation Effect
1081 ///////////////////////////////////////////////////////////////////////////////
1082 typedef struct _Elm_Transit_Effect_Translation Elm_Transit_Effect_Translation;
1083 typedef struct _Elm_Transit_Effect_Translation_Node Elm_Transit_Effect_Translation_Node;
1085 struct _Elm_Transit_Effect_Translation_Node
1091 struct _Elm_Transit_Effect_Translation
1093 struct _position_variation {
1100 _translation_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1102 Elm_Transit_Effect_Translation *translation = data;
1104 Elm_Transit_Effect_Translation_Node *translation_node;
1106 EINA_LIST_FOREACH(translation->nodes, elist, translation_node)
1108 if (translation_node->obj != obj) continue;
1109 translation->nodes = eina_list_remove_list(translation->nodes, elist);
1110 free(translation_node);
1116 _translation_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Translation *translation)
1118 Elm_Transit_Effect_Translation_Node *translation_node;
1119 const Eina_List *elist;
1121 Eina_List *data_list = NULL;
1122 const Eina_List *objs = elm_transit_objects_get(transit);
1124 EINA_LIST_FOREACH(objs, elist, obj)
1126 translation_node = ELM_NEW(Elm_Transit_Effect_Translation_Node);
1127 if (!translation_node)
1129 eina_list_free(data_list);
1132 translation_node->obj = obj;
1133 evas_object_geometry_get(obj, &(translation_node->x),
1134 &(translation_node->y), NULL, NULL);
1135 data_list = eina_list_append(data_list, translation_node);
1136 evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
1137 _translation_object_del_cb, translation);
1143 _transit_effect_translation_context_free(void *data, Elm_Transit *transit __UNUSED__)
1145 EINA_SAFETY_ON_NULL_RETURN(data);
1146 Elm_Transit_Effect_Translation *translation = data;
1147 Eina_List *elist, *elist_next;
1148 Elm_Transit_Effect_Translation_Node *translation_node;
1150 EINA_LIST_FOREACH_SAFE(translation->nodes,
1151 elist, elist_next, translation_node)
1153 evas_object_event_callback_del(translation_node->obj,
1154 EVAS_CALLBACK_DEL, _translation_object_del_cb);
1155 translation->nodes = eina_list_remove_list(translation->nodes, elist);
1156 free(translation_node);
1162 _transit_effect_translation_op(void *data, Elm_Transit *transit, double progress __UNUSED__)
1164 EINA_SAFETY_ON_NULL_RETURN(data);
1165 EINA_SAFETY_ON_NULL_RETURN(transit);
1167 Elm_Transit_Effect_Translation *translation = data;
1168 Elm_Transit_Effect_Translation_Node *translation_node;
1171 if (!translation->nodes)
1172 translation->nodes = _translation_nodes_build(transit, translation);
1174 EINA_LIST_FOREACH(translation->nodes, elist, translation_node)
1176 x = translation_node->x + translation->from.dx
1177 + (translation->to.dx * progress);
1178 y = translation_node->y + translation->from.dy
1179 + (translation->to.dy * progress);
1180 evas_object_move(translation_node->obj, x, y);
1185 _transit_effect_translation_context_new(Evas_Coord from_dx, Evas_Coord from_dy, Evas_Coord to_dx, Evas_Coord to_dy)
1187 Elm_Transit_Effect_Translation *translation;
1189 translation = ELM_NEW(Elm_Transit_Effect_Translation);
1190 if (!translation) return NULL;
1192 translation->from.dx = from_dx;
1193 translation->from.dy = from_dy;
1194 translation->to.dx = to_dx - from_dx;
1195 translation->to.dy = to_dy - from_dy;
1201 * Add the Translation Effect to Elm_Transit.
1203 * @note This API is one of the facades. It creates translation 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_dx X Position variation when effect begins.
1210 * @param from_dy Y Position variation when effect begins.
1211 * @param to_dx X Position variation when effect ends.
1212 * @param to_dy Y Position variation when effect ends.
1213 * @return Translation effect context data.
1216 * @warning Is higher recommended just create a transit with this effect when
1217 * the window that the objects of the transit belongs has already been created.
1218 * This is because this effect needs the geometry information about the objects,
1219 * and if the window was not created yet, it can get a wrong information.
1222 elm_transit_effect_translation_add(Elm_Transit *transit, Evas_Coord from_dx, Evas_Coord from_dy, Evas_Coord to_dx, Evas_Coord to_dy)
1224 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1225 void *effect_context = _transit_effect_translation_context_new(from_dx, from_dy, to_dx, to_dy);
1227 if (!effect_context) return NULL;
1228 elm_transit_effect_add(transit,
1229 _transit_effect_translation_op, effect_context,
1230 _transit_effect_translation_context_free);
1231 return effect_context;
1235 ///////////////////////////////////////////////////////////////////////////////
1237 ///////////////////////////////////////////////////////////////////////////////
1238 typedef struct _Elm_Transit_Effect_Zoom Elm_Transit_Effect_Zoom;
1240 struct _Elm_Transit_Effect_Zoom
1246 _transit_effect_zoom_context_free(void *data, Elm_Transit *transit __UNUSED__)
1252 _transit_effect_zoom_op(void *data, Elm_Transit *transit , double progress)
1254 EINA_SAFETY_ON_NULL_RETURN(data);
1255 EINA_SAFETY_ON_NULL_RETURN(transit);
1258 Elm_Transit_Effect_Zoom *zoom = data;
1260 Evas_Coord x, y, w, h;
1262 map = evas_map_new(4);
1265 EINA_LIST_FOREACH(transit->objs, elist, obj)
1267 evas_object_geometry_get(obj, &x, &y, &w, &h);
1268 evas_map_util_points_populate_from_object_full(map, obj, zoom->from +
1269 (progress * zoom->to));
1270 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, FOCAL);
1271 evas_object_map_set(obj, map);
1272 evas_object_map_enable_set(obj, EINA_TRUE);
1278 _transit_effect_zoom_context_new(float from_rate, float to_rate)
1280 Elm_Transit_Effect_Zoom *zoom;
1282 zoom = ELM_NEW(Elm_Transit_Effect_Zoom);
1283 if (!zoom) return NULL;
1285 zoom->from = (FOCAL - (from_rate * FOCAL)) * (1 / from_rate);
1286 zoom->to = ((FOCAL - (to_rate * FOCAL)) * (1 / to_rate)) - zoom->from;
1292 * Add the Zoom Effect to Elm_Transit.
1294 * @note This API is one of the facades. It creates zoom effect context
1295 * and add it's required APIs to elm_transit_effect_add.
1297 * @see elm_transit_effect_add()
1299 * @param transit Transit object.
1300 * @param from_rate Scale rate when effect begins (1 is current rate).
1301 * @param to_rate Scale rate when effect ends.
1302 * @return Zoom effect context data.
1305 * @warning Is higher recommended just create a transit with this effect when
1306 * the window that the objects of the transit belongs has already been created.
1307 * This is because this effect needs the geometry information about the objects,
1308 * and if the window was not created yet, it can get a wrong information.
1311 elm_transit_effect_zoom_add(Elm_Transit *transit, float from_rate, float to_rate)
1313 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1314 void *effect_context = _transit_effect_zoom_context_new(from_rate, to_rate);
1316 if (!effect_context) return NULL;
1317 elm_transit_effect_add(transit,
1318 _transit_effect_zoom_op, effect_context,
1319 _transit_effect_zoom_context_free);
1320 return effect_context;
1324 ///////////////////////////////////////////////////////////////////////////////
1326 ///////////////////////////////////////////////////////////////////////////////
1327 typedef struct _Elm_Transit_Effect_Flip Elm_Transit_Effect_Flip;
1329 struct _Elm_Transit_Effect_Flip
1331 Elm_Transit_Effect_Flip_Axis axis;
1336 _transit_effect_flip_context_free(void *data, Elm_Transit *transit)
1338 EINA_SAFETY_ON_NULL_RETURN(data);
1339 EINA_SAFETY_ON_NULL_RETURN(transit);
1340 Evas_Object *front, *back;
1342 int count = eina_list_count(transit->objs);
1344 for (i = 0; i < (count - 1); i += 2)
1346 front = eina_list_nth(transit->objs, i);
1347 back = eina_list_nth(transit->objs, i+1);
1348 evas_object_map_enable_set(front, EINA_FALSE);
1349 evas_object_map_enable_set(back, EINA_FALSE);
1355 _transit_effect_flip_op(void *data, Elm_Transit *transit, double progress)
1357 EINA_SAFETY_ON_NULL_RETURN(data);
1358 EINA_SAFETY_ON_NULL_RETURN(transit);
1359 Evas_Object *obj, *front, *back;
1361 Elm_Transit_Effect_Flip *flip = data;
1364 Evas_Coord x, y, w, h;
1366 map = evas_map_new(4);
1369 if (flip->cw) degree = (float)(progress * 180);
1370 else degree = (float)(progress * -180);
1372 count = eina_list_count(transit->objs);
1373 for (i = 0; i < (count - 1); i += 2)
1375 Evas_Coord half_w, half_h;
1377 front = eina_list_nth(transit->objs, i);
1378 back = eina_list_nth(transit->objs, i+1);
1380 if ((degree < 90) && (degree > -90))
1385 evas_object_hide(back);
1386 evas_object_show(front);
1394 evas_object_hide(front);
1395 evas_object_show(back);
1399 evas_map_util_points_populate_from_object_full(map, obj, 0);
1400 evas_object_geometry_get(obj, &x, &y, &w, &h);
1404 if (flip->axis == ELM_TRANSIT_EFFECT_FLIP_AXIS_Y)
1406 if ((degree >= 90) || (degree <= -90))
1408 evas_map_point_image_uv_set(map, 0, w, 0);
1409 evas_map_point_image_uv_set(map, 1, 0, 0);
1410 evas_map_point_image_uv_set(map, 2, 0, h);
1411 evas_map_point_image_uv_set(map, 3, w, h);
1413 evas_map_util_3d_rotate(map, 0, degree,
1414 0, x + half_w, y + half_h, 0);
1418 if ((degree >= 90) || (degree <= -90))
1420 evas_map_point_image_uv_set(map, 0, 0, h);
1421 evas_map_point_image_uv_set(map, 1, w, h);
1422 evas_map_point_image_uv_set(map, 2, w, 0);
1423 evas_map_point_image_uv_set(map, 3, 0, 0);
1425 evas_map_util_3d_rotate(map, degree,
1426 0, 0, x + half_w, y + half_h, 0);
1428 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, FOCAL);
1429 evas_object_map_enable_set(front, EINA_TRUE);
1430 evas_object_map_enable_set(back, EINA_TRUE);
1431 evas_object_map_set(obj, map);
1437 _transit_effect_flip_context_new(Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1439 Elm_Transit_Effect_Flip *flip;
1441 flip = ELM_NEW(Elm_Transit_Effect_Flip);
1442 if (!flip) return NULL;
1451 * Add the Flip Effect to Elm_Transit.
1453 * @note This API is one of the facades. It creates flip effect context
1454 * and add it's required APIs to elm_transit_effect_add.
1455 * @note This effect is applied to each pair of objects in the order they are listed
1456 * in the transit list of objects. The first object in the pair will be the
1457 * "front" object and the second will be the "back" object.
1459 * @see elm_transit_effect_add()
1461 * @param transit Transit object.
1462 * @param axis Flipping Axis(X or Y).
1463 * @param cw Flipping Direction. EINA_TRUE is clock-wise.
1464 * @return Flip effect context data.
1467 * @warning Is higher recommended just create a transit with this effect when
1468 * the window that the objects of the transit belongs has already been created.
1469 * This is because this effect needs the geometry information about the objects,
1470 * and if the window was not created yet, it can get a wrong information.
1473 elm_transit_effect_flip_add(Elm_Transit *transit, Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1475 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1476 void *effect_context = _transit_effect_flip_context_new(axis, cw);
1478 if (!effect_context) return NULL;
1479 elm_transit_effect_add(transit,
1480 _transit_effect_flip_op, effect_context,
1481 _transit_effect_flip_context_free);
1482 return effect_context;
1485 ///////////////////////////////////////////////////////////////////////////////
1486 //ResizableFlip Effect
1487 ///////////////////////////////////////////////////////////////////////////////
1488 typedef struct _Elm_Transit_Effect_Resizable_Flip Elm_Transit_Effect_ResizableFlip;
1489 typedef struct _Elm_Transit_Effect_Resizable_Flip_Node Elm_Transit_Effect_ResizableFlip_Node;
1491 struct _Elm_Transit_Effect_Resizable_Flip_Node
1497 } from_pos, from_size, to_pos, to_size;
1500 struct _Elm_Transit_Effect_Resizable_Flip
1504 Elm_Transit_Effect_Flip_Axis axis;
1508 _resizable_flip_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1510 Elm_Transit_Effect_ResizableFlip *resizable_flip = data;
1512 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1514 EINA_LIST_FOREACH(resizable_flip->nodes, elist, resizable_flip_node)
1516 if (resizable_flip_node->front == obj)
1517 evas_object_event_callback_del(resizable_flip_node->back,
1518 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1519 else if (resizable_flip_node->back == obj)
1520 evas_object_event_callback_del(resizable_flip_node->front,
1521 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1524 resizable_flip->nodes = eina_list_remove_list(resizable_flip->nodes,
1526 free(resizable_flip_node);
1532 _resizable_flip_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_ResizableFlip *resizable_flip)
1534 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1535 Eina_List *data_list = NULL;
1536 Evas_Coord front_x, front_y, front_w, front_h;
1537 Evas_Coord back_x, back_y, back_w, back_h;
1540 count = eina_list_count(transit->objs);
1541 for (i = 0; i < (count - 1); i += 2)
1543 resizable_flip_node = ELM_NEW(Elm_Transit_Effect_ResizableFlip_Node);
1544 if (!resizable_flip_node)
1546 eina_list_free(data_list);
1550 resizable_flip_node->front = eina_list_nth(transit->objs, i);
1551 resizable_flip_node->back = eina_list_nth(transit->objs, i+1);
1553 evas_object_geometry_get(resizable_flip_node->front,
1554 &front_x, &front_y, &front_w, &front_h);
1555 evas_object_geometry_get(resizable_flip_node->back,
1556 &back_x, &back_y, &back_w, &back_h);
1558 resizable_flip_node->from_pos.x = front_x;
1559 resizable_flip_node->from_pos.y = front_y;
1560 resizable_flip_node->to_pos.x = back_x - front_x;
1561 resizable_flip_node->to_pos.y = back_y - front_y;
1563 resizable_flip_node->from_size.x = front_w;
1564 resizable_flip_node->from_size.y = front_h;
1565 resizable_flip_node->to_size.x = back_w - front_w;
1566 resizable_flip_node->to_size.y = back_h - front_h;
1568 data_list = eina_list_append(data_list, resizable_flip_node);
1570 evas_object_event_callback_add(resizable_flip_node->back,
1571 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb, resizable_flip);
1572 evas_object_event_callback_add(resizable_flip_node->front,
1573 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb, resizable_flip);
1580 _set_image_uv_by_axis_y(Evas_Map *map, Elm_Transit_Effect_ResizableFlip_Node *flip, float degree)
1582 if ((degree >= 90) || (degree <= -90))
1584 evas_map_point_image_uv_set(map, 0,
1585 (flip->from_size.x * 2) + flip->to_size.x,
1587 evas_map_point_image_uv_set(map, 1, 0, 0);
1588 evas_map_point_image_uv_set(map, 2, 0,
1589 (flip->from_size.y * 2) + flip->to_size.y);
1590 evas_map_point_image_uv_set(map, 3,
1591 (flip->from_size.x * 2) + flip->to_size.x,
1592 (flip->from_size.y * 2) + flip->to_size.y);
1596 evas_map_point_image_uv_set(map, 0, 0, 0);
1597 evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
1598 evas_map_point_image_uv_set(map, 2, flip->from_size.x,
1600 evas_map_point_image_uv_set(map, 3, 0, flip->from_size.y);
1605 _set_image_uv_by_axis_x(Evas_Map *map, Elm_Transit_Effect_ResizableFlip_Node *flip, float degree)
1607 if ((degree >= 90) || (degree <= -90))
1609 evas_map_point_image_uv_set(map, 0, 0,
1610 (flip->from_size.y * 2) + flip->to_size.y);
1611 evas_map_point_image_uv_set(map, 1,
1612 (flip->from_size.x * 2) + flip->to_size.x,
1613 (flip->from_size.y * 2) + flip->to_size.y);
1614 evas_map_point_image_uv_set(map, 2,
1615 (flip->from_size.x * 2) + flip->to_size.x,
1617 evas_map_point_image_uv_set(map, 3, 0, 0);
1621 evas_map_point_image_uv_set(map, 0, 0, 0);
1622 evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
1623 evas_map_point_image_uv_set(map, 2, flip->from_size.x,
1625 evas_map_point_image_uv_set(map, 3, 0, flip->from_size.y);
1630 _transit_effect_resizable_flip_context_free(void *data, Elm_Transit *transit __UNUSED__)
1632 EINA_SAFETY_ON_NULL_RETURN(data);
1634 Elm_Transit_Effect_ResizableFlip *resizable_flip = data;
1635 Eina_List *elist, *elist_next;
1636 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1638 EINA_LIST_FOREACH_SAFE(resizable_flip->nodes,
1639 elist, elist_next, resizable_flip_node)
1641 evas_object_map_enable_set(resizable_flip_node->front, EINA_FALSE);
1642 evas_object_map_enable_set(resizable_flip_node->back, EINA_FALSE);
1644 resizable_flip->nodes = eina_list_remove_list(resizable_flip->nodes,
1647 evas_object_event_callback_del(resizable_flip_node->back,
1648 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1649 evas_object_event_callback_del(resizable_flip_node->front,
1650 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1651 free(resizable_flip_node);
1653 free(resizable_flip);
1657 _transit_effect_resizable_flip_op(void *data, Elm_Transit *transit __UNUSED__, double progress)
1659 EINA_SAFETY_ON_NULL_RETURN(data);
1664 Evas_Coord half_w, half_h;
1665 Elm_Transit_Effect_ResizableFlip *resizable_flip = data;
1666 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1669 map = evas_map_new(4);
1672 if (resizable_flip->cw) degree = (float)(progress * 180);
1673 else degree = (float)(progress * -180);
1675 if (!resizable_flip->nodes)
1676 resizable_flip->nodes = _resizable_flip_nodes_build(transit,
1679 EINA_LIST_FOREACH(resizable_flip->nodes, elist, resizable_flip_node)
1681 if ((degree < 90) && (degree > -90))
1683 obj = resizable_flip_node->front;
1684 if (resizable_flip_node->front != resizable_flip_node->back)
1686 evas_object_hide(resizable_flip_node->back);
1687 evas_object_show(resizable_flip_node->front);
1692 obj = resizable_flip_node->back;
1693 if (resizable_flip_node->front != resizable_flip_node->back)
1695 evas_object_hide(resizable_flip_node->front);
1696 evas_object_show(resizable_flip_node->back);
1700 x = resizable_flip_node->from_pos.x +
1701 (resizable_flip_node->to_pos.x * progress);
1702 y = resizable_flip_node->from_pos.y +
1703 (resizable_flip_node->to_pos.y * progress);
1704 w = resizable_flip_node->from_size.x +
1705 (resizable_flip_node->to_size.x * progress);
1706 h = resizable_flip_node->from_size.y +
1707 (resizable_flip_node->to_size.y * progress);
1708 evas_map_point_coord_set(map, 0, x, y, 0);
1709 evas_map_point_coord_set(map, 1, x + w, y, 0);
1710 evas_map_point_coord_set(map, 2, x + w, y + h, 0);
1711 evas_map_point_coord_set(map, 3, x, y + h, 0);
1713 half_w = (Evas_Coord)(w / 2);
1714 half_h = (Evas_Coord)(h / 2);
1716 if (resizable_flip->axis == ELM_TRANSIT_EFFECT_FLIP_AXIS_Y)
1718 _set_image_uv_by_axis_y(map, resizable_flip_node, degree);
1719 evas_map_util_3d_rotate(map, 0, degree,
1720 0, x + half_w, y + half_h, 0);
1724 _set_image_uv_by_axis_x(map, resizable_flip_node, degree);
1725 evas_map_util_3d_rotate(map, degree, 0,
1726 0, x + half_w, y + half_h, 0);
1729 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, FOCAL);
1730 evas_object_map_enable_set(resizable_flip_node->front, EINA_TRUE);
1731 evas_object_map_enable_set(resizable_flip_node->back, EINA_TRUE);
1732 evas_object_map_set(obj, map);
1738 _transit_effect_resizable_flip_context_new(Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1740 Elm_Transit_Effect_ResizableFlip *resizable_flip;
1742 resizable_flip = ELM_NEW(Elm_Transit_Effect_ResizableFlip);
1743 if (!resizable_flip) return NULL;
1745 resizable_flip->cw = cw;
1746 resizable_flip->axis = axis;
1748 return resizable_flip;
1752 * Add the Resizable Flip Effect to Elm_Transit.
1754 * @note This API is one of the facades. It creates resizable flip effect context
1755 * and add it's required APIs to elm_transit_effect_add.
1756 * @note This effect is applied to each pair of objects in the order they are listed
1757 * in the transit list of objects. The first object in the pair will be the
1758 * "front" object and the second will be the "back" object.
1760 * @see elm_transit_effect_add()
1762 * @param transit Transit object.
1763 * @param axis Flipping Axis(X or Y).
1764 * @param cw Flipping Direction. EINA_TRUE is clock-wise.
1765 * @return Resizable flip effect context data.
1768 * @warning Is higher recommended just create a transit with this effect when
1769 * the window that the objects of the transit belongs has already been created.
1770 * This is because this effect needs the geometry information about the objects,
1771 * and if the window was not created yet, it can get a wrong information.
1774 elm_transit_effect_resizable_flip_add(Elm_Transit *transit, Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1776 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1777 void *effect_context = _transit_effect_resizable_flip_context_new(axis, cw);
1779 if (!effect_context) return NULL;
1780 elm_transit_effect_add(transit,
1781 _transit_effect_resizable_flip_op, effect_context,
1782 _transit_effect_resizable_flip_context_free);
1783 return effect_context;
1787 ///////////////////////////////////////////////////////////////////////////////
1789 ///////////////////////////////////////////////////////////////////////////////
1790 typedef struct _Elm_Transit_Effect_Wipe Elm_Transit_Effect_Wipe;
1792 struct _Elm_Transit_Effect_Wipe
1794 Elm_Transit_Effect_Wipe_Type type;
1795 Elm_Transit_Effect_Wipe_Dir dir;
1799 _elm_fx_wipe_hide(Evas_Map * map, Elm_Transit_Effect_Wipe_Dir dir, float x, float y, float w, float h, float progress)
1805 case ELM_TRANSIT_EFFECT_WIPE_DIR_LEFT:
1806 w2 = w - (w * progress);
1808 evas_map_point_image_uv_set(map, 0, 0, 0);
1809 evas_map_point_image_uv_set(map, 1, w2, 0);
1810 evas_map_point_image_uv_set(map, 2, w2, h);
1811 evas_map_point_image_uv_set(map, 3, 0, h);
1812 evas_map_point_coord_set(map, 0, x, y, 0);
1813 evas_map_point_coord_set(map, 1, x + w2, y, 0);
1814 evas_map_point_coord_set(map, 2, x + w2, h2, 0);
1815 evas_map_point_coord_set(map, 3, x, h2, 0);
1817 case ELM_TRANSIT_EFFECT_WIPE_DIR_RIGHT:
1818 w2 = (w * progress);
1820 evas_map_point_image_uv_set(map, 0, w2, 0);
1821 evas_map_point_image_uv_set(map, 1, w, 0);
1822 evas_map_point_image_uv_set(map, 2, w, h);
1823 evas_map_point_image_uv_set(map, 3, w2, h);
1824 evas_map_point_coord_set(map, 0, x + w2, y, 0);
1825 evas_map_point_coord_set(map, 1, x + w, y, 0);
1826 evas_map_point_coord_set(map, 2, x + w, h2, 0);
1827 evas_map_point_coord_set(map, 3, x + w2, h2, 0);
1829 case ELM_TRANSIT_EFFECT_WIPE_DIR_UP:
1831 h2 = h - (h * progress);
1832 evas_map_point_image_uv_set(map, 0, 0, 0);
1833 evas_map_point_image_uv_set(map, 1, w, 0);
1834 evas_map_point_image_uv_set(map, 2, w, h2);
1835 evas_map_point_image_uv_set(map, 3, 0, h2);
1836 evas_map_point_coord_set(map, 0, x, y, 0);
1837 evas_map_point_coord_set(map, 1, w2, y, 0);
1838 evas_map_point_coord_set(map, 2, w2, y+h2, 0);
1839 evas_map_point_coord_set(map, 3, x, y+h2, 0);
1841 case ELM_TRANSIT_EFFECT_WIPE_DIR_DOWN:
1843 h2 = (h * progress);
1844 evas_map_point_image_uv_set(map, 0, 0, h2);
1845 evas_map_point_image_uv_set(map, 1, w, h2);
1846 evas_map_point_image_uv_set(map, 2, w, h);
1847 evas_map_point_image_uv_set(map, 3, 0, h);
1848 evas_map_point_coord_set(map, 0, x, y + h2, 0);
1849 evas_map_point_coord_set(map, 1, w2, y + h2, 0);
1850 evas_map_point_coord_set(map, 2, w2, y + h, 0);
1851 evas_map_point_coord_set(map, 3, x, y + h, 0);
1856 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, FOCAL);
1860 _elm_fx_wipe_show(Evas_Map *map, Elm_Transit_Effect_Wipe_Dir dir, float x, float y, float w, float h, float progress)
1866 case ELM_TRANSIT_EFFECT_WIPE_DIR_LEFT:
1867 w2 = (w - (w * progress));
1869 evas_map_point_image_uv_set(map, 0, w2, 0);
1870 evas_map_point_image_uv_set(map, 1, w, 0);
1871 evas_map_point_image_uv_set(map, 2, w, h);
1872 evas_map_point_image_uv_set(map, 3, w2, h);
1873 evas_map_point_coord_set(map, 0, x + w2, y, 0);
1874 evas_map_point_coord_set(map, 1, w, y, 0);
1875 evas_map_point_coord_set(map, 2, w, h2, 0);
1876 evas_map_point_coord_set(map, 3, x + w2, h2, 0);
1878 case ELM_TRANSIT_EFFECT_WIPE_DIR_RIGHT:
1879 w2 = (w * progress);
1881 evas_map_point_image_uv_set(map, 0, 0, 0);
1882 evas_map_point_image_uv_set(map, 1, w2, 0);
1883 evas_map_point_image_uv_set(map, 2, w2, h);
1884 evas_map_point_image_uv_set(map, 3, 0, h);
1885 evas_map_point_coord_set(map, 0, x, y, 0);
1886 evas_map_point_coord_set(map, 1, x + w2, y, 0);
1887 evas_map_point_coord_set(map, 2, x + w2, h2, 0);
1888 evas_map_point_coord_set(map, 3, x, h2, 0);
1890 case ELM_TRANSIT_EFFECT_WIPE_DIR_UP:
1892 h2 = (h - (h * progress));
1893 evas_map_point_image_uv_set(map, 0, 0, h2);
1894 evas_map_point_image_uv_set(map, 1, w, h2);
1895 evas_map_point_image_uv_set(map, 2, w, h);
1896 evas_map_point_image_uv_set(map, 3, 0, h);
1897 evas_map_point_coord_set(map, 0, x, y + h2, 0);
1898 evas_map_point_coord_set(map, 1, w2, y + h2, 0);
1899 evas_map_point_coord_set(map, 2, w2, y + h, 0);
1900 evas_map_point_coord_set(map, 3, x, y + h, 0);
1902 case ELM_TRANSIT_EFFECT_WIPE_DIR_DOWN:
1904 h2 = (h * progress);
1905 evas_map_point_image_uv_set(map, 0, 0, 0);
1906 evas_map_point_image_uv_set(map, 1, w, 0);
1907 evas_map_point_image_uv_set(map, 2, w, h2);
1908 evas_map_point_image_uv_set(map, 3, 0, h2);
1909 evas_map_point_coord_set(map, 0, x, y, 0);
1910 evas_map_point_coord_set(map, 1, w2, y, 0);
1911 evas_map_point_coord_set(map, 2, w2, y + h2, 0);
1912 evas_map_point_coord_set(map, 3, x, y + h2, 0);
1917 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, FOCAL);
1921 _transit_effect_wipe_context_free(void *data, Elm_Transit *transit)
1923 EINA_SAFETY_ON_NULL_RETURN(data);
1924 EINA_SAFETY_ON_NULL_RETURN(transit);
1927 Elm_Transit_Effect_Wipe *wipe = data;
1928 Eina_Bool reverse = elm_transit_auto_reverse_get(transit);
1930 EINA_LIST_FOREACH(transit->objs, elist, obj)
1932 if ((wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_SHOW && !reverse)
1933 || (wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_HIDE && reverse))
1934 evas_object_show(obj);
1935 else evas_object_hide(obj);
1936 evas_object_map_enable_set(obj, EINA_FALSE);
1943 _transit_effect_wipe_op(void *data, Elm_Transit *transit, double progress)
1945 EINA_SAFETY_ON_NULL_RETURN(data);
1946 EINA_SAFETY_ON_NULL_RETURN(transit);
1947 Elm_Transit_Effect_Wipe *wipe = data;
1949 Evas_Coord _x, _y, _w, _h;
1953 map = evas_map_new(4);
1956 EINA_LIST_FOREACH(transit->objs, elist, obj)
1958 evas_object_geometry_get(obj, &_x, &_y, &_w, &_h);
1960 if (wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_SHOW)
1961 _elm_fx_wipe_show(map, wipe->dir, _x, _y, _w, _h, (float)progress);
1963 _elm_fx_wipe_hide(map, wipe->dir, _x, _y, _w, _h, (float)progress);
1965 evas_object_map_enable_set(obj, EINA_TRUE);
1966 evas_object_map_set(obj, map);
1972 _transit_effect_wipe_context_new(Elm_Transit_Effect_Wipe_Type type, Elm_Transit_Effect_Wipe_Dir dir)
1974 Elm_Transit_Effect_Wipe *wipe;
1976 wipe = ELM_NEW(Elm_Transit_Effect_Wipe);
1977 if (!wipe) return NULL;
1986 * Add the Wipe Effect to Elm_Transit.
1988 * @note This API is one of the facades. It creates wipe effect context
1989 * and add it's required APIs to elm_transit_effect_add.
1991 * @see elm_transit_effect_add()
1993 * @param transit Transit object.
1994 * @param type Wipe type. Hide or show.
1995 * @param dir Wipe Direction.
1996 * @return Wipe effect context data.
1999 * @warning Is higher recommended just create a transit with this effect when
2000 * the window that the objects of the transit belongs has already been created.
2001 * This is because this effect needs the geometry information about the objects,
2002 * and if the window was not created yet, it can get a wrong information.
2005 elm_transit_effect_wipe_add(Elm_Transit *transit, Elm_Transit_Effect_Wipe_Type type, Elm_Transit_Effect_Wipe_Dir dir)
2007 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2008 void *effect_context = _transit_effect_wipe_context_new(type, dir);
2010 if (!effect_context) return NULL;
2011 elm_transit_effect_add(transit,
2012 _transit_effect_wipe_op, effect_context,
2013 _transit_effect_wipe_context_free);
2014 return effect_context;
2018 ///////////////////////////////////////////////////////////////////////////////
2020 ///////////////////////////////////////////////////////////////////////////////
2021 typedef struct _Elm_Transit_Effect_Color Elm_Transit_Effect_Color;
2023 struct _Elm_Transit_Effect_Color
2025 struct _unsigned_color {
2026 unsigned int r, g, b, a;
2028 struct _signed_color {
2034 _transit_effect_color_context_free(void *data, Elm_Transit *transit __UNUSED__)
2040 _transit_effect_color_op(void *data, Elm_Transit *transit, double progress)
2042 EINA_SAFETY_ON_NULL_RETURN(data);
2043 EINA_SAFETY_ON_NULL_RETURN(transit);
2044 Elm_Transit_Effect_Color *color = data;
2047 unsigned int r, g, b, a;
2049 r = (color->from.r + (int)((float)color->to.r * progress));
2050 g = (color->from.g + (int)((float)color->to.g * progress));
2051 b = (color->from.b + (int)((float)color->to.b * progress));
2052 a = (color->from.a + (int)((float)color->to.a * progress));
2054 EINA_LIST_FOREACH(transit->objs, elist, obj)
2055 evas_object_color_set(obj, r, g, b, a);
2059 _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)
2061 Elm_Transit_Effect_Color *color;
2063 color = ELM_NEW(Elm_Transit_Effect_Color);
2064 if (!color) return NULL;
2066 color->from.r = from_r;
2067 color->from.g = from_g;
2068 color->from.b = from_b;
2069 color->from.a = from_a;
2070 color->to.r = to_r - from_r;
2071 color->to.g = to_g - from_g;
2072 color->to.b = to_b - from_b;
2073 color->to.a = to_a - from_a;
2079 * Add the Color Effect to Elm_Transit.
2081 * @note This API is one of the facades. It creates color effect context
2082 * and add it's required APIs to elm_transit_effect_add.
2084 * @see elm_transit_effect_add()
2086 * @param transit Transit object.
2087 * @param from_r RGB R when effect begins.
2088 * @param from_g RGB G when effect begins.
2089 * @param from_b RGB B when effect begins.
2090 * @param from_a RGB A when effect begins.
2091 * @param to_r RGB R when effect ends.
2092 * @param to_g RGB G when effect ends.
2093 * @param to_b RGB B when effect ends.
2094 * @param to_a RGB A when effect ends.
2095 * @return Color effect context data.
2100 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)
2102 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2103 void *effect_context = _transit_effect_color_context_new(from_r, from_g, from_b, from_a, to_r, to_g, to_b, to_a);
2105 if (!effect_context) return NULL;
2106 elm_transit_effect_add(transit,
2107 _transit_effect_color_op, effect_context,
2108 _transit_effect_color_context_free);
2109 return effect_context;
2112 ///////////////////////////////////////////////////////////////////////////////
2114 ///////////////////////////////////////////////////////////////////////////////
2115 typedef struct _Elm_Transit_Effect_Fade Elm_Transit_Effect_Fade;
2116 typedef struct _Elm_Transit_Effect_Fade_Node Elm_Transit_Effect_Fade_Node;
2118 struct _Elm_Transit_Effect_Fade_Node
2120 Evas_Object *before;
2122 struct _signed_color before_color, after_color;
2125 Eina_Bool inversed : 1;
2128 struct _Elm_Transit_Effect_Fade
2134 _fade_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2136 Elm_Transit_Effect_Fade *fade = data;
2138 Elm_Transit_Effect_Fade_Node *fade_node;
2140 EINA_LIST_FOREACH(fade->nodes, elist, fade_node)
2142 if (fade_node->before == obj)
2143 evas_object_event_callback_del(fade_node->after,
2144 EVAS_CALLBACK_DEL, _fade_object_del_cb);
2145 else if (fade_node->after == obj)
2146 evas_object_event_callback_del(fade_node->before,
2147 EVAS_CALLBACK_DEL, _fade_object_del_cb);
2150 fade->nodes = eina_list_remove_list(fade->nodes, elist);
2157 _fade_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Fade *fade_data)
2159 Elm_Transit_Effect_Fade_Node *fade;
2160 Eina_List *data_list = NULL;
2163 count = eina_list_count(transit->objs);
2164 for (i = 0; i < count; i += 2)
2166 fade = ELM_NEW(Elm_Transit_Effect_Fade_Node);
2169 eina_list_free(data_list);
2173 fade->before = eina_list_nth(transit->objs, i);
2174 fade->after = eina_list_nth(transit->objs, i+1);
2176 evas_object_color_get(fade->before,
2177 &fade->before_color.r, &fade->before_color.g,
2178 &fade->before_color.b, &fade->before_color.a);
2179 evas_object_color_get(fade->after,
2180 &fade->after_color.r, &fade->after_color.g,
2181 &fade->after_color.b, &fade->after_color.a);
2183 fade->before_alpha = (255 - fade->before_color.a);
2184 fade->after_alpha = (255 - fade->after_color.a);
2186 data_list = eina_list_append(data_list, fade);
2188 evas_object_event_callback_add(fade->before,
2189 EVAS_CALLBACK_DEL, _fade_object_del_cb, fade_data);
2190 evas_object_event_callback_add(fade->after,
2191 EVAS_CALLBACK_DEL, _fade_object_del_cb, fade_data);
2197 _transit_effect_fade_context_free(void *data, Elm_Transit *transit __UNUSED__)
2199 EINA_SAFETY_ON_NULL_RETURN(data);
2200 Elm_Transit_Effect_Fade *fade = data;
2201 Elm_Transit_Effect_Fade_Node *fade_node;
2202 Eina_List *elist, *elist_next;
2204 EINA_LIST_FOREACH_SAFE(fade->nodes, elist, elist_next, fade_node)
2206 evas_object_color_set(fade_node->before, fade_node->before_color.r,
2207 fade_node->before_color.g,
2208 fade_node->before_color.b,
2209 fade_node->before_color.a);
2210 evas_object_color_set(fade_node->after, fade_node->after_color.r,
2211 fade_node->after_color.g,
2212 fade_node->after_color.b,
2213 fade_node->after_color.a);
2215 fade->nodes = eina_list_remove_list(fade->nodes, elist);
2216 evas_object_event_callback_del(fade_node->before,
2217 EVAS_CALLBACK_DEL, _fade_object_del_cb);
2218 evas_object_event_callback_del(fade_node->after,
2219 EVAS_CALLBACK_DEL, _fade_object_del_cb);
2227 _transit_effect_fade_op(void *data, Elm_Transit *transit __UNUSED__, double progress)
2229 EINA_SAFETY_ON_NULL_RETURN(data);
2230 Elm_Transit_Effect_Fade *fade = data;
2232 Elm_Transit_Effect_Fade_Node *fade_node;
2236 fade->nodes = _fade_nodes_build(transit, fade);
2238 EINA_LIST_FOREACH(fade->nodes, elist, fade_node)
2242 if (!fade_node->inversed)
2244 evas_object_hide(fade_node->after);
2245 evas_object_show(fade_node->before);
2246 fade_node->inversed = EINA_TRUE;
2249 _progress = (1 - (progress * 2));
2251 evas_object_color_set(fade_node->before,
2252 fade_node->before_color.r * _progress,
2253 fade_node->before_color.g * _progress,
2254 fade_node->before_color.b * _progress,
2255 fade_node->before_color.a +
2256 fade_node->before_alpha * (1 - _progress));
2260 if (fade_node->inversed)
2262 evas_object_hide(fade_node->before);
2263 evas_object_show(fade_node->after);
2264 fade_node->inversed = EINA_FALSE;
2267 _progress = ((progress - 0.5) * 2);
2269 evas_object_color_set(fade_node->after,
2270 fade_node->after_color.r * _progress,
2271 fade_node->after_color.g * _progress,
2272 fade_node->after_color.b * _progress,
2273 fade_node->after_color.a +
2274 fade_node->after_alpha * (1 - _progress));
2280 _transit_effect_fade_context_new(void)
2282 Elm_Transit_Effect_Fade *fade;
2283 fade = ELM_NEW(Elm_Transit_Effect_Fade);
2284 if (!fade) return NULL;
2289 * Add the Fade Effect to Elm_Transit.
2291 * @note This API is one of the facades. It creates fade effect context
2292 * and add it's required APIs to elm_transit_effect_add.
2293 * @note This effect is applied to each pair of objects in the order they are listed
2294 * in the transit list of objects. The first object in the pair will be the
2295 * "before" object and the second will be the "after" object.
2297 * @see elm_transit_effect_add()
2299 * @param transit Transit object.
2300 * @return Fade effect context data.
2303 * @warning Is higher recommended just create a transit with this effect when
2304 * the window that the objects of the transit belongs has already been created.
2305 * This is because this effect needs the color information about the objects,
2306 * and if the window was not created yet, it can get a wrong information.
2309 elm_transit_effect_fade_add(Elm_Transit *transit)
2311 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2313 void *effect_context = _transit_effect_fade_context_new();
2314 if (!effect_context) return NULL;
2315 elm_transit_effect_add(transit,
2316 _transit_effect_fade_op, effect_context,
2317 _transit_effect_fade_context_free);
2318 return effect_context;
2322 ///////////////////////////////////////////////////////////////////////////////
2324 ///////////////////////////////////////////////////////////////////////////////
2325 typedef struct _Elm_Transit_Effect_Blend Elm_Transit_Effect_Blend;
2326 typedef struct _Elm_Transit_Effect_Blend_Node Elm_Transit_Effect_Blend_Node;
2328 struct _Elm_Transit_Effect_Blend_Node
2330 Evas_Object *before;
2332 struct _signed_color from, to;
2335 struct _Elm_Transit_Effect_Blend
2341 _blend_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2343 Elm_Transit_Effect_Blend *blend = data;
2345 Elm_Transit_Effect_Blend_Node *blend_node;
2347 EINA_LIST_FOREACH(blend->nodes, elist, blend_node)
2349 if (blend_node->after == obj)
2350 evas_object_event_callback_del(blend_node->before,
2351 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2352 else if (blend_node->before == obj)
2353 evas_object_event_callback_del(blend_node->after,
2354 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2357 blend->nodes = eina_list_remove_list(blend->nodes, elist);
2364 _blend_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Blend *blend)
2366 Elm_Transit_Effect_Blend_Node *blend_node;
2367 Eina_List *data_list = NULL;
2370 count = eina_list_count(transit->objs);
2371 for (i = 0; i < (count - 1); i += 2)
2373 blend_node = ELM_NEW(Elm_Transit_Effect_Blend_Node);
2376 eina_list_free(data_list);
2380 blend_node->before = eina_list_nth(transit->objs, i);
2381 blend_node->after = eina_list_nth(transit->objs, i + 1);
2382 evas_object_show(blend_node->before);
2383 evas_object_show(blend_node->after);
2385 evas_object_color_get(blend_node->before, &blend_node->from.r,
2386 &blend_node->from.g, &blend_node->from.b,
2387 &blend_node->from.a);
2388 evas_object_color_get(blend_node->after, &blend_node->to.r,
2389 &blend_node->to.g, &blend_node->to.b,
2392 data_list = eina_list_append(data_list, blend_node);
2394 evas_object_event_callback_add(blend_node->before,
2395 EVAS_CALLBACK_DEL, _blend_object_del_cb, blend);
2396 evas_object_event_callback_add(blend_node->after,
2397 EVAS_CALLBACK_DEL, _blend_object_del_cb, blend);
2403 _transit_effect_blend_context_free(void *data, Elm_Transit *transit __UNUSED__)
2405 EINA_SAFETY_ON_NULL_RETURN(data);
2406 Elm_Transit_Effect_Blend *blend = data;
2407 Elm_Transit_Effect_Blend_Node *blend_node;
2408 Eina_List *elist, *elist_next;
2410 EINA_LIST_FOREACH_SAFE(blend->nodes, elist, elist_next, blend_node)
2412 evas_object_color_set(blend_node->before,
2413 blend_node->from.r, blend_node->from.g,
2414 blend_node->from.b, blend_node->from.a);
2415 evas_object_color_set(blend_node->after, blend_node->to.r,
2416 blend_node->to.g, blend_node->to.b,
2419 if (elm_transit_auto_reverse_get(transit))
2420 evas_object_hide(blend_node->after);
2422 evas_object_hide(blend_node->before);
2424 blend->nodes = eina_list_remove_list(blend->nodes, elist);
2426 evas_object_event_callback_del(blend_node->before,
2427 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2428 evas_object_event_callback_del(blend_node->after,
2429 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2436 _transit_effect_blend_op(void *data, Elm_Transit *transit, double progress)
2438 EINA_SAFETY_ON_NULL_RETURN(data);
2439 EINA_SAFETY_ON_NULL_RETURN(transit);
2440 Elm_Transit_Effect_Blend *blend = data;
2441 Elm_Transit_Effect_Blend_Node *blend_node;
2444 if (!blend->nodes) blend->nodes = _blend_nodes_build(transit, blend);
2446 EINA_LIST_FOREACH(blend->nodes, elist, blend_node)
2448 evas_object_color_set(blend_node->before,
2449 (int)(blend_node->from.r * (1 - progress)),
2450 (int)(blend_node->from.g * (1 - progress)),
2451 (int)(blend_node->from.b * (1 - progress)),
2452 (int)(blend_node->from.a * (1 - progress)));
2453 evas_object_color_set(blend_node->after,
2454 (int)(blend_node->to.r * progress),
2455 (int)(blend_node->to.g * progress),
2456 (int)(blend_node->to.b * progress),
2457 (int)(blend_node->to.a * progress));
2462 _transit_effect_blend_context_new(void)
2464 Elm_Transit_Effect_Blend *blend;
2466 blend = ELM_NEW(Elm_Transit_Effect_Blend);
2467 if (!blend) return NULL;
2472 * Add the Blend Effect to Elm_Transit.
2474 * @note This API is one of the facades. It creates blend effect context
2475 * and add it's required APIs to elm_transit_effect_add.
2476 * @note This effect is applied to each pair of objects in the order they are listed
2477 * in the transit list of objects. The first object in the pair will be the
2478 * "before" object and the second will be the "after" object.
2480 * @see elm_transit_effect_add()
2482 * @param transit Transit object.
2483 * @return Blend effect context data.
2486 * @warning Is higher recommended just create a transit with this effect when
2487 * the window that the objects of the transit belongs has already been created.
2488 * This is because this effect needs the color information about the objects,
2489 * and if the window was not created yet, it can get a wrong information.
2492 elm_transit_effect_blend_add(Elm_Transit *transit)
2494 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2495 void *effect_context = _transit_effect_blend_context_new();
2497 if (!effect_context) return NULL;
2498 elm_transit_effect_add(transit,
2499 _transit_effect_blend_op, effect_context,
2500 _transit_effect_blend_context_free);
2501 return effect_context;
2505 ///////////////////////////////////////////////////////////////////////////////
2507 ///////////////////////////////////////////////////////////////////////////////
2508 typedef struct _Elm_Transit_Effect_Rotation Elm_Transit_Effect_Rotation;
2510 struct _Elm_Transit_Effect_Rotation
2516 _transit_effect_rotation_context_free(void *data, Elm_Transit *transit __UNUSED__)
2522 _transit_effect_rotation_op(void *data, Elm_Transit *transit, double progress)
2524 EINA_SAFETY_ON_NULL_RETURN(data);
2525 EINA_SAFETY_ON_NULL_RETURN(transit);
2526 Elm_Transit_Effect_Rotation *rotation = data;
2528 Evas_Coord x, y, w, h;
2530 float half_w, half_h;
2534 map = evas_map_new(4);
2537 EINA_LIST_FOREACH(transit->objs, elist, obj)
2539 evas_map_util_points_populate_from_object_full(map, obj, 0);
2540 degree = rotation->from + (float)(progress * rotation->to);
2542 evas_object_geometry_get(obj, &x, &y, &w, &h);
2544 half_w = (float)w * 0.5;
2545 half_h = (float)h * 0.5;
2547 evas_map_util_3d_rotate(map, 0, 0, degree, x + half_w, y + half_h, 0);
2548 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, FOCAL);
2549 evas_object_map_enable_set(obj, EINA_TRUE);
2550 evas_object_map_set(obj, map);
2556 _transit_effect_rotation_context_new(float from_degree, float to_degree)
2558 Elm_Transit_Effect_Rotation *rotation;
2560 rotation = ELM_NEW(Elm_Transit_Effect_Rotation);
2561 if (!rotation) return NULL;
2563 rotation->from = from_degree;
2564 rotation->to = to_degree - from_degree;
2570 * Add the Rotation Effect to Elm_Transit.
2572 * @note This API is one of the facades. It creates rotation effect context
2573 * and add it's required APIs to elm_transit_effect_add.
2575 * @see elm_transit_effect_add()
2577 * @param transit Transit object.
2578 * @param from_degree Degree when effect begins.
2579 * @param to_degree Degree when effect is ends.
2580 * @return Rotation effect context data.
2583 * @warning Is higher recommended just create a transit with this effect when
2584 * the window that the objects of the transit belongs has already been created.
2585 * This is because this effect needs the geometry information about the objects,
2586 * and if the window was not created yet, it can get a wrong information.
2589 elm_transit_effect_rotation_add(Elm_Transit *transit, float from_degree, float to_degree)
2591 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2592 void *effect_context = _transit_effect_rotation_context_new(from_degree, to_degree);
2594 if (!effect_context) return NULL;
2595 elm_transit_effect_add(transit,
2596 _transit_effect_rotation_op, effect_context,
2597 _transit_effect_rotation_context_free);
2598 return effect_context;
2602 ///////////////////////////////////////////////////////////////////////////////
2603 //ImageAnimation Effect
2604 ///////////////////////////////////////////////////////////////////////////////
2605 typedef struct _Elm_Transit_Effect_Image_Animation Elm_Transit_Effect_Image_Animation;
2607 struct _Elm_Transit_Effect_Image_Animation
2613 _transit_effect_image_animation_context_free(void *data, Elm_Transit *transit __UNUSED__)
2615 EINA_SAFETY_ON_NULL_RETURN(data);
2616 Elm_Transit_Effect_Image_Animation *image_animation = data;
2618 Eina_List *elist, *elist_next;
2620 EINA_LIST_FOREACH_SAFE(image_animation->images, elist, elist_next, image)
2622 image_animation->images =
2623 eina_list_remove_list(image_animation->images, elist);
2624 eina_stringshare_del(image);
2631 _transit_effect_image_animation_op(void *data, Elm_Transit *transit, double progress)
2633 EINA_SAFETY_ON_NULL_RETURN(data);
2634 EINA_SAFETY_ON_NULL_RETURN(transit);
2638 Elm_Transit_Effect_Image_Animation *image_animation = data;
2639 unsigned int count = 0;
2642 type = eina_stringshare_add("icon");
2643 len = eina_list_count(image_animation->images);
2645 if (!len) count = floor(progress * len);
2646 else count = floor(progress * (len - 1));
2648 EINA_LIST_FOREACH(transit->objs, elist, obj)
2650 if (elm_widget_type_check(obj, type))
2651 elm_icon_file_set(obj,
2652 eina_list_nth(image_animation->images, count), NULL);
2655 eina_stringshare_del(type);
2659 _transit_effect_image_animation_context_new(Eina_List *images)
2661 Elm_Transit_Effect_Image_Animation *image_animation;
2662 image_animation = ELM_NEW(Elm_Transit_Effect_Image_Animation);
2664 if (!image_animation) return NULL;
2665 image_animation->images = images;
2666 return image_animation;
2670 * Add the ImageAnimation Effect to Elm_Transit.
2672 * @note This API is one of the facades. It creates image animation effect context
2673 * and add it's required APIs to elm_transit_effect_add.
2674 * The @p images parameter is a list images paths. This list and
2675 * its contents will be deleted at the end of the effect by
2676 * elm_transit_effect_image_animation_context_free() function.
2680 * char buf[PATH_MAX];
2681 * Eina_List *images = NULL;
2682 * Elm_Transit *transi = elm_transit_add();
2684 * snprintf(buf, sizeof(buf), "%s/images/icon_11.png", PACKAGE_DATA_DIR);
2685 * images = eina_list_append(images, eina_stringshare_add(buf));
2687 * snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
2688 * images = eina_list_append(images, eina_stringshare_add(buf));
2689 * elm_transit_effect_image_animation_add(transi, images);
2693 * @see elm_transit_effect_add()
2695 * @param transit Transit object.
2696 * @param images Eina_List of images file paths. This list and
2697 * its contents will be deleted at the end of the effect by
2698 * elm_transit_effect_image_animation_context_free() function.
2699 * @return Image Animation effect context data.
2704 elm_transit_effect_image_animation_add(Elm_Transit *transit, Eina_List *images)
2706 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2707 void *effect_context = _transit_effect_image_animation_context_new(images);
2709 if (!effect_context) return NULL;
2710 elm_transit_effect_add(transit,
2711 _transit_effect_image_animation_op, effect_context,
2712 _transit_effect_image_animation_context_free);
2713 return effect_context;