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;
88 struct _Elm_Transit_Effect
90 void (*animation_op) (void *data, Elm_Transit *transit, double progress);
91 void (*user_data_free) (void *data, Elm_Transit *transit);
93 Eina_Bool deleted : 1;
102 typedef struct _Elm_Transit_Effect Elm_Transit_Effect;
103 typedef struct _Elm_Obj_Data Elm_Obj_Data;
106 _elm_transit_object_remove_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
108 Elm_Transit *transit = data;
110 Elm_Obj_Data *obj_data = evas_object_data_del(obj, _transit_key);
111 evas_object_pass_events_set(obj, obj_data->state);
113 transit->objs = eina_list_remove(transit->objs, obj);
114 if (!transit->objs) elm_transit_del(transit);
118 _elm_transit_object_remove(Elm_Transit *transit, Evas_Object *obj)
120 Elm_Obj_Data *obj_data = evas_object_data_del(obj, _transit_key);
122 evas_object_pass_events_set(obj, obj_data->state);
124 transit->objs = eina_list_remove(transit->objs, obj);
125 evas_object_event_callback_del(obj, EVAS_CALLBACK_DEL,
126 _elm_transit_object_remove_cb);
130 _elm_transit_effect_del(Elm_Transit *transit, Elm_Transit_Effect *effect, Eina_List *elist)
132 if (effect->user_data_free)
133 effect->user_data_free(effect->user_data, transit);
135 transit->effect_list = eina_list_remove_list(transit->effect_list, elist);
140 _remove_dead_effects(Elm_Transit *transit)
142 Eina_List *elist, *elist_next;
143 Elm_Transit_Effect *effect;
145 EINA_LIST_FOREACH_SAFE(transit->effect_list, elist, elist_next, effect)
149 _elm_transit_effect_del(transit, effect, elist);
150 transit->effects_pending_del--;
151 if (!transit->effects_pending_del) return;
157 _elm_transit_del(Elm_Transit *transit)
159 Eina_List *elist, *elist_next;
160 Elm_Transit_Effect *effect;
162 if (transit->animator)
163 ecore_animator_del(transit->animator);
165 EINA_LIST_FOREACH_SAFE(transit->effect_list, elist, elist_next, effect)
166 _elm_transit_effect_del(transit, effect, elist);
168 while (transit->objs)
169 _elm_transit_object_remove(transit, eina_list_data_get(transit->objs));
171 if (transit->del_data.func)
172 transit->del_data.func(transit->del_data.arg, transit);
174 EINA_MAGIC_SET(transit, EINA_MAGIC_NONE);
179 _transit_animate_op(Elm_Transit *transit, double progress)
182 Elm_Transit_Effect *effect;
185 EINA_LIST_FOREACH(transit->effect_list, elist, effect)
187 if (transit->deleted) break;
188 if (!effect->deleted)
189 effect->animation_op(effect->user_data, transit, progress);
193 if (transit->walking) return;
195 if (transit->deleted) _elm_transit_del(transit);
196 else if (transit->effects_pending_del) _remove_dead_effects(transit);
200 _animator_animate_cb(void *data)
202 Elm_Transit *transit = data;
203 double elapsed_time, duration;
205 transit->time.current = ecore_loop_time_get();
206 elapsed_time = transit->time.current - transit->time.begin;
207 duration = transit->time.duration + transit->time.delayed;
209 if (elapsed_time > duration)
210 elapsed_time = duration;
212 transit->progress = elapsed_time / duration;
213 switch (transit->tween_mode)
215 case ELM_TRANSIT_TWEEN_MODE_ACCELERATE:
216 transit->progress = 1.0 - sin((ELM_PI / 2.0) + (transit->progress * ELM_PI / 2.0));
218 case ELM_TRANSIT_TWEEN_MODE_DECELERATE:
219 transit->progress = sin(transit->progress * ELM_PI / 2.0);
221 case ELM_TRANSIT_TWEEN_MODE_SINUSOIDAL:
222 transit->progress = (1.0 - cos(transit->progress * ELM_PI)) / 2.0;
229 if (transit->repeat.reverse) transit->progress = 1 - transit->progress;
231 if (transit->time.duration > 0) _transit_animate_op(transit, transit->progress);
233 /* Not end. Keep going. */
234 if (elapsed_time < duration) return ECORE_CALLBACK_RENEW;
236 /* Repeat and reverse and time done! */
237 if ((transit->repeat.current == transit->repeat.count)
238 && (!transit->auto_reverse || transit->repeat.reverse))
240 elm_transit_del(transit);
241 return ECORE_CALLBACK_CANCEL;
245 if (!transit->auto_reverse || transit->repeat.reverse)
247 transit->repeat.current++;
248 transit->repeat.reverse = EINA_FALSE;
250 else transit->repeat.reverse = EINA_TRUE;
252 transit->time.begin = ecore_loop_time_get();
254 return ECORE_CALLBACK_RENEW;
260 * @note Is not necessary to delete the transit object, it will be deleted at
261 * the end of its operation.
262 * @note The transit will start playing when the program enter in the main loop, is not
263 * necessary to give a start to the transit.
265 * @param duration The duration of the transit in seconds. When transit starts
266 * to run, it will last a @p duration time.
267 * @return The transit object.
272 elm_transit_add(void)
274 Elm_Transit *transit = ELM_NEW(Elm_Transit);
275 if (!transit) return NULL;
277 EINA_MAGIC_SET(transit, ELM_TRANSIT_MAGIC);
279 elm_transit_tween_mode_set(transit, ELM_TRANSIT_TWEEN_MODE_LINEAR);
284 * Stops the animation and delete the @p transit object.
286 * Call this function if you wants to stop the animation before the duration
287 * time. Make sure the @p transit object is still alive with
288 * elm_transit_del_cb_set() function.
289 * All added effects will be deleted, calling its repective data_free_cb
290 * functions. The function setted by elm_tansit_del_cb_set() will be called.
292 * @see elm_transit_del_cb_set()
294 * @param transit The transit object to be deleted.
297 * @warning Just call this function if you are sure the transit is alive.
300 elm_transit_del(Elm_Transit *transit)
302 ELM_TRANSIT_CHECK_OR_RETURN(transit);
304 if (transit->walking) transit->deleted = EINA_TRUE;
305 else _elm_transit_del(transit);
309 * Add a new effect to the transit.
311 * @note The cb function and the data are the key to the effect. If you try to
312 * add an already added effect, nothing is done.
313 * @note After the first addition of an effect in @p transit, if its
314 * effect list become empty again, the @p transit will be killed by
315 * elm_transit_del(transit) function.
319 * Elm_Transit *transit = elm_transit_add();
320 * elm_transit_effect_add(transit,
321 * elm_transit_effect_blend_op,
322 * elm_transit_effect_blend_context_new(),
323 * elm_transit_effect_blend_context_free);
326 * @param transit The transit object.
327 * @param cb The operation function. It is called when the animation begins,
328 * it is the function that actually performs the animation. It is called with
329 * the @p data, @p transit and the time progression of the animation (a double
330 * value between 0.0 and 1.0).
331 * @param data The context data of the effect.
332 * @param data_free_cb The function to free the context data, it will be called
333 * at the end of the effect, it must finalize the animation and free the
337 * @warning The transit free the context data at the and of the transition with
338 * the data_free_cb function, do not use the context data in another transit.
341 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))
343 ELM_TRANSIT_CHECK_OR_RETURN(transit);
344 EINA_SAFETY_ON_NULL_RETURN(cb);
345 Elm_Transit_Effect *effect;
348 EINA_LIST_FOREACH(transit->effect_list, elist, effect)
350 if ((effect->animation_op == cb) && (effect->user_data == data)) return;
353 effect = ELM_NEW(Elm_Transit_Effect);
356 effect->user_data_free = data_free_cb;
357 effect->animation_op = cb;
358 effect->user_data = data;
360 transit->effect_list = eina_list_append(transit->effect_list, effect);
364 * Delete an added effect.
366 * This function will remove the effect from the @p transit, calling the
367 * data_free_cb to free the @p data.
369 * @see elm_transit_effect_add()
371 * @note If the effect is not found, nothing is done.
372 * @note If the effect list become empty, this function will call
373 * elm_transit_del(transit), that is, it will kill the @p transit.
375 * @param transit The transit object.
376 * @param cb The operation function.
377 * @param data The context data of the effect.
382 elm_transit_effect_del(Elm_Transit *transit, void (*cb)(void *data, Elm_Transit *transit, double progress), void *data)
384 ELM_TRANSIT_CHECK_OR_RETURN(transit);
385 EINA_SAFETY_ON_NULL_RETURN(cb);
386 Eina_List *elist, *elist_next;
387 Elm_Transit_Effect *effect;
389 EINA_LIST_FOREACH_SAFE(transit->effect_list, elist, elist_next, effect)
391 if ((effect->animation_op == cb) && (effect->user_data == data))
393 if (transit->walking)
395 effect->deleted = EINA_TRUE;
396 transit->effects_pending_del++;
400 _elm_transit_effect_del(transit, effect, elist);
401 if (!transit->effect_list) elm_transit_del(transit);
409 * Add new object to apply the effects.
411 * @note After the first addition of an object in @p transit, if its
412 * object list become empty again, the @p transit will be killed by
413 * elm_transit_del(transit) function.
414 * @note If the @p obj belongs to another transit, the @p obj will be
415 * removed from it and it will only belong to the @p transit. If the old
416 * transit stays without objects, it will die.
417 * @note When you add an object into the @p transit, its state from
418 * evas_object_pass_events_get(obj) is saved, and it is applied when the
419 * transit ends, if you change this state whith evas_object_pass_events_set()
420 * after add the object, this state will change again when @p transit stops to
423 * @param transit The transit object.
424 * @param obj Object to be animated.
427 * @warning It is not allowed to add a new object after transit begins to go.
430 elm_transit_object_add(Elm_Transit *transit, Evas_Object *obj)
432 ELM_TRANSIT_CHECK_OR_RETURN(transit);
433 EINA_SAFETY_ON_NULL_RETURN(obj);
434 Elm_Obj_Data *obj_data;
436 if (transit->animator) return;
438 obj_data = evas_object_data_get(obj, _transit_key);
442 if (obj_data->transit == transit) return;
443 elm_transit_object_remove(obj_data->transit, obj);
446 obj_data = ELM_NEW(Elm_Obj_Data);
447 obj_data->state = evas_object_pass_events_get(obj);
448 obj_data->transit = transit;
449 evas_object_data_set(obj, _transit_key, obj_data);
451 transit->objs = eina_list_append(transit->objs, obj);
453 if (!transit->event_enabled)
454 evas_object_pass_events_set(obj, EINA_TRUE);
456 evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
457 _elm_transit_object_remove_cb, transit);
461 * Removes an added object from the transit.
463 * @note If the @p obj is not in the @p transit, nothing is done.
464 * @note If the list become empty, this function will call
465 * elm_transit_del(transit), that is, it will kill the @p transit.
467 * @param transit The transit object.
468 * @param obj Object to be removed from @p transit.
471 * @warning It is not allowed to remove objects after transit begins to go.
474 elm_transit_object_remove(Elm_Transit *transit, Evas_Object *obj)
476 ELM_TRANSIT_CHECK_OR_RETURN(transit);
477 EINA_SAFETY_ON_NULL_RETURN(obj);
478 Elm_Obj_Data *obj_data;
480 if (transit->animator) return;
482 obj_data = evas_object_data_get(obj, _transit_key);
484 if ((!obj_data) || (obj_data->transit != transit)) return;
486 _elm_transit_object_remove(transit, obj);
487 if (!transit->objs) elm_transit_del(transit);
491 * Get the objects of the transit.
493 * @param transit The transit object.
494 * @return a Eina_List with the objects from the transit.
498 EAPI const Eina_List *
499 elm_transit_objects_get(const Elm_Transit *transit)
501 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
502 return transit->objs;
506 * Set the event enabled when transit is operating.
508 * If @p enabled is EINA_TRUE, the objects of the transit will receives
509 * events from mouse and keyboard during the animation.
510 * @note When you add an object with elm_transit_object_add(), its state from
511 * evas_object_pass_events_get(obj) is saved, and it is applied when the
512 * transit ends, if you change this state with evas_object_pass_events_set()
513 * after add the object, this state will change again when @p transit stops to
516 * @param transit The transit object.
517 * @param enabled Disable or enable.
522 elm_transit_event_enabled_set(Elm_Transit *transit, Eina_Bool enabled)
524 ELM_TRANSIT_CHECK_OR_RETURN(transit);
527 Elm_Obj_Data *obj_data;
529 if (transit->event_enabled == enabled) return;
531 transit->event_enabled = enabled;
535 EINA_LIST_FOREACH(transit->objs, elist, obj)
537 obj_data = evas_object_data_get(obj, _transit_key);
538 evas_object_pass_events_set(obj, obj_data->state);
543 EINA_LIST_FOREACH(transit->objs, elist, obj)
544 evas_object_pass_events_set(obj, EINA_TRUE);
549 * Get the value of event enabled status.
551 * @see elm_transit_event_enabled_set()
553 * @param transit The Transit object
554 * @return EINA_TRUE, when event is enabled. If @p transit is NULL
555 * EINA_FALSE is returned
560 elm_transit_event_enabled_get(const Elm_Transit *transit)
562 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
564 return transit->event_enabled;
569 * Set the event enabled when transit is operating.
571 * If @p disabled 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 add the object, this state will change again when @p transit stops to
579 * @see elm_transit_event_enabled_set()
581 * @param transit The transit object.
582 * @param disabled Disable or enable.
586 EINA_DEPRECATED EAPI void
587 elm_transit_event_block_set(Elm_Transit *transit, Eina_Bool disabled)
589 elm_transit_event_enabled_set(transit, disabled);
594 * Get the value of event block enabled status.
596 * @see elm_transit_event_enabled_set(), elm_transit_event_enabled_get()
598 * @param transit The Transit object
599 * @return EINA_TRUE, when event is enabled. If @p transit is NULL
600 * EINA_FALSE is returned
604 EINA_DEPRECATED EAPI Eina_Bool
605 elm_transit_event_block_get(const Elm_Transit *transit)
607 return !elm_transit_event_enabled_get(transit);
611 * Set the user-callback function when the transit is deleted.
613 * @note Using this function twice will overwrite the first function setted.
614 * @note the @p transit object will be deleted after call @p cb function.
616 * @param transit The transit object.
617 * @param cb Callback function pointer. This function will be called before
618 * the deletion of the transit.
619 * @param data Callback funtion user data. It is the @p op parameter.
624 elm_transit_del_cb_set(Elm_Transit *transit, void (*cb) (void *data, Elm_Transit *transit), void *data)
626 ELM_TRANSIT_CHECK_OR_RETURN(transit);
627 transit->del_data.func = cb;
628 transit->del_data.arg = data;
632 * Set reverse effect automatically.
634 * If auto reverse is setted, after running the effects with the progress
635 * parameter from 0 to 1, it will call the effecs again with the progress
636 * from 1 to 0. The transit will last for a time iqual to (2 * duration * repeat),
637 * where the duration was setted with the function elm_transit_add and
638 * the repeat with the function elm_transit_repeat_times_set().
640 * @param transit The transit object.
641 * @param reverse EINA_TRUE means the auto_reverse is on.
646 elm_transit_auto_reverse_set(Elm_Transit *transit, Eina_Bool reverse)
648 ELM_TRANSIT_CHECK_OR_RETURN(transit);
649 transit->auto_reverse = reverse;
653 * Get if the auto reverse is on.
655 * @see elm_transit_auto_reverse_set()
657 * @param transit The transit object.
658 * @return EINA_TRUE means auto reverse is on. If @p transit is NULL
659 * EINA_FALSE is returned
664 elm_transit_auto_reverse_get(Elm_Transit *transit)
666 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
667 return transit->auto_reverse;
671 * Set the transit repeat count. Effect will be repeated by repeat count.
673 * This function sets the number of repetition the transit will run after
674 * the first one, that is, if @p repeat is 1, the transit will run 2 times.
675 * If the @p repeat is a negative number, it will repeat infinite times.
677 * @note If this function is called during the transit execution, the transit
678 * will run @p repeat times, ignoring the times it already performed.
680 * @param transit The transit object
681 * @param repeat Repeat count
686 elm_transit_repeat_times_set(Elm_Transit *transit, int repeat)
688 ELM_TRANSIT_CHECK_OR_RETURN(transit);
689 transit->repeat.count = repeat;
690 transit->repeat.current = 0;
694 * Get the transit repeat count.
696 * @see elm_transit_repeat_times_set()
698 * @param transit The Transit object.
699 * @return The repeat count. If @p transit is NULL
705 elm_transit_repeat_times_get(Elm_Transit *transit)
707 ELM_TRANSIT_CHECK_OR_RETURN(transit, 0);
708 return transit->repeat.count;
712 * Set the transit animation acceleration type.
714 * This function sets the tween mode of the transit that can be:
715 * ELM_TRANSIT_TWEEN_MODE_LINEAR - The default mode.
716 * ELM_TRANSIT_TWEEN_MODE_SINUSOIDAL - Starts in accelerate mode and ends decelerating.
717 * ELM_TRANSIT_TWEEN_MODE_DECELERATE - The animation will be slowed over time.
718 * ELM_TRANSIT_TWEEN_MODE_ACCELERATE - The animation will accelerate over time.
720 * @param transit The transit object.
721 * @param tween_mode The tween type.
726 elm_transit_tween_mode_set(Elm_Transit *transit, Elm_Transit_Tween_Mode tween_mode)
728 ELM_TRANSIT_CHECK_OR_RETURN(transit);
730 transit->tween_mode = tween_mode;
734 * Get the transit animation acceleration type.
736 * @note @p transit can not be NULL
738 * @param transit The transit object.
739 * @return The tween type. If @p transit is NULL
740 * ELM_TRANSIT_TWEEN_MODE_LINEAR is returned.
744 EAPI Elm_Transit_Tween_Mode
745 elm_transit_tween_mode_get(const Elm_Transit *transit)
747 ELM_TRANSIT_CHECK_OR_RETURN(transit, ELM_TRANSIT_TWEEN_MODE_LINEAR);
748 return transit->tween_mode;
752 * Set the transit animation time
754 * @note @p transit can not be NULL
756 * @param transit The transit object.
757 * @param duration The animation time.
762 elm_transit_duration_set(Elm_Transit *transit, double duration)
764 ELM_TRANSIT_CHECK_OR_RETURN(transit);
765 if (transit->animator) return;
766 transit->time.duration = duration;
770 * Get the transit animation time
772 * @note @p transit can not be NULL
774 * @param transit The transit object.
776 * @return The transit animation time.
781 elm_transit_duration_get(const Elm_Transit *transit)
783 ELM_TRANSIT_CHECK_OR_RETURN(transit, 0.0);
784 return transit->time.duration;
788 * Starts the transition.
789 * Once this API is called, the transit begins to measure the time.
791 * @note @p transit can not be NULL
793 * @param transit The transit object.
798 elm_transit_go(Elm_Transit *transit)
800 ELM_TRANSIT_CHECK_OR_RETURN(transit);
802 if (transit->animator)
803 ecore_animator_del(transit->animator);
805 transit->time.paused = 0;
806 transit->time.delayed = 0;
807 transit->time.begin = ecore_loop_time_get();
808 transit->animator = ecore_animator_add(_animator_animate_cb, transit);
812 * Pause/Resume the transition.
813 * If you call elm_transit_go again, paused states will affect no anymore.
815 * @note @p transit can not be NULL
817 * @param transit The transit object.
822 elm_transit_paused_set(Elm_Transit *transit, Eina_Bool paused)
824 ELM_TRANSIT_CHECK_OR_RETURN(transit);
826 if (!transit->animator) return;
830 if (transit->time.paused > 0)
832 ecore_animator_freeze(transit->animator);
833 transit->time.paused = ecore_loop_time_get();
837 if (transit->time.paused == 0)
839 ecore_animator_thaw(transit->animator);
840 transit->time.delayed += (ecore_loop_time_get() - transit->time.paused);
841 transit->time.paused = 0;
846 * Get the value of paused status.
848 * @see elm_transit_paused_set()
850 * @note @p transit can not be NULL
852 * @param transit The transit object.
853 * @return EINA_TRUE means transition is paused. If @p transit is NULL
854 * EINA_FALSE is returned
859 elm_transit_paused_get(const Elm_Transit *transit)
861 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
863 if (transit->time.paused == 0)
870 * Get the time progression of the animation (a double value between 0.0 and 1.0).
872 * @note @p transit can not be NULL
874 * @param transit The transit object.
876 * @return The time progression value. If @p transit is NULL
882 elm_transit_progress_value_get(const Elm_Transit *transit)
884 ELM_TRANSIT_CHECK_OR_RETURN(transit, 0);
886 return transit->progress;
889 ///////////////////////////////////////////////////////////////////////////////
891 ///////////////////////////////////////////////////////////////////////////////
892 typedef struct _Elm_Transit_Effect_Resizing Elm_Transit_Effect_Resizing;
894 struct _Elm_Transit_Effect_Resizing
902 _transit_effect_resizing_context_free(void *data, Elm_Transit *transit __UNUSED__)
908 _transit_effect_resizing_op(void *data, Elm_Transit *transit, double progress)
910 EINA_SAFETY_ON_NULL_RETURN(data);
911 EINA_SAFETY_ON_NULL_RETURN(transit);
915 Elm_Transit_Effect_Resizing *resizing = data;
917 w = resizing->from.w + (resizing->to.w * progress);
918 h = resizing->from.h + (resizing->to.h * progress);
920 EINA_LIST_FOREACH(transit->objs, elist, obj)
921 evas_object_resize(obj, w, h);
925 _transit_effect_resizing_context_new(Evas_Coord from_w, Evas_Coord from_h, Evas_Coord to_w, Evas_Coord to_h)
927 Elm_Transit_Effect_Resizing *resizing;
929 resizing = ELM_NEW(Elm_Transit_Effect_Resizing);
930 if (!resizing) return NULL;
932 resizing->from.w = from_w;
933 resizing->from.h = from_h;
934 resizing->to.w = to_w - from_w;
935 resizing->to.h = to_h - from_h;
941 * Add the Resizing Effect to Elm_Transit.
943 * @note This API is one of the facades. It creates resizing effect context
944 * and add it's required APIs to elm_transit_effect_add.
946 * @see elm_transit_effect_add()
948 * @param transit Transit object.
949 * @param from_w Object width size when effect begins.
950 * @param from_h Object height size when effect begins.
951 * @param to_w Object width size when effect ends.
952 * @param to_h Object height size when effect ends.
953 * @return Resizing effect context data.
958 elm_transit_effect_resizing_add(Elm_Transit *transit, Evas_Coord from_w, Evas_Coord from_h, Evas_Coord to_w, Evas_Coord to_h)
960 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
961 void *effect_context = _transit_effect_resizing_context_new(from_w, from_h, to_w, to_h);
963 if (!effect_context) return NULL;
964 elm_transit_effect_add(transit,
965 _transit_effect_resizing_op, effect_context,
966 _transit_effect_resizing_context_free);
967 return effect_context;
970 ///////////////////////////////////////////////////////////////////////////////
972 ///////////////////////////////////////////////////////////////////////////////
973 typedef struct _Elm_Transit_Effect_Translation Elm_Transit_Effect_Translation;
974 typedef struct _Elm_Transit_Effect_Translation_Node Elm_Transit_Effect_Translation_Node;
976 struct _Elm_Transit_Effect_Translation_Node
982 struct _Elm_Transit_Effect_Translation
984 struct _position_variation {
991 _translation_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
993 Elm_Transit_Effect_Translation *translation = data;
995 Elm_Transit_Effect_Translation_Node *translation_node;
997 EINA_LIST_FOREACH(translation->nodes, elist, translation_node)
999 if (translation_node->obj != obj) continue;
1000 translation->nodes = eina_list_remove_list(translation->nodes, elist);
1001 free(translation_node);
1007 _translation_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Translation *translation)
1009 Elm_Transit_Effect_Translation_Node *translation_node;
1010 const Eina_List *elist;
1012 Eina_List *data_list = NULL;
1013 const Eina_List *objs = elm_transit_objects_get(transit);
1015 EINA_LIST_FOREACH(objs, elist, obj)
1017 translation_node = ELM_NEW(Elm_Transit_Effect_Translation_Node);
1018 if (!translation_node)
1020 eina_list_free(data_list);
1023 translation_node->obj = obj;
1024 evas_object_geometry_get(obj, &(translation_node->x),
1025 &(translation_node->y), NULL, NULL);
1026 data_list = eina_list_append(data_list, translation_node);
1027 evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
1028 _translation_object_del_cb, translation);
1034 _transit_effect_translation_context_free(void *data, Elm_Transit *transit __UNUSED__)
1036 EINA_SAFETY_ON_NULL_RETURN(data);
1037 Elm_Transit_Effect_Translation *translation = data;
1038 Eina_List *elist, *elist_next;
1039 Elm_Transit_Effect_Translation_Node *translation_node;
1041 EINA_LIST_FOREACH_SAFE(translation->nodes,
1042 elist, elist_next, translation_node)
1044 evas_object_event_callback_del(translation_node->obj,
1045 EVAS_CALLBACK_DEL, _translation_object_del_cb);
1046 translation->nodes = eina_list_remove_list(translation->nodes, elist);
1047 free(translation_node);
1053 _transit_effect_translation_op(void *data, Elm_Transit *transit, double progress __UNUSED__)
1055 EINA_SAFETY_ON_NULL_RETURN(data);
1056 EINA_SAFETY_ON_NULL_RETURN(transit);
1058 Elm_Transit_Effect_Translation *translation = data;
1059 Elm_Transit_Effect_Translation_Node *translation_node;
1062 if (!translation->nodes)
1063 translation->nodes = _translation_nodes_build(transit, translation);
1065 EINA_LIST_FOREACH(translation->nodes, elist, translation_node)
1067 x = translation_node->x + translation->from.dx
1068 + (translation->to.dx * progress);
1069 y = translation_node->y + translation->from.dy
1070 + (translation->to.dy * progress);
1071 evas_object_move(translation_node->obj, x, y);
1076 _transit_effect_translation_context_new(Evas_Coord from_dx, Evas_Coord from_dy, Evas_Coord to_dx, Evas_Coord to_dy)
1078 Elm_Transit_Effect_Translation *translation;
1080 translation = ELM_NEW(Elm_Transit_Effect_Translation);
1081 if (!translation) return NULL;
1083 translation->from.dx = from_dx;
1084 translation->from.dy = from_dy;
1085 translation->to.dx = to_dx - from_dx;
1086 translation->to.dy = to_dy - from_dy;
1092 * Add the Translation Effect to Elm_Transit.
1094 * @note This API is one of the facades. It creates translation effect context
1095 * and add it's required APIs to elm_transit_effect_add.
1097 * @see elm_transit_effect_add()
1099 * @param transit Transit object.
1100 * @param from_dx X Position variation when effect begins.
1101 * @param from_dy Y Position variation when effect begins.
1102 * @param to_dx X Position variation when effect ends.
1103 * @param to_dy Y Position variation when effect ends.
1104 * @return Translation effect context data.
1107 * @warning Is higher recommended just create a transit with this effect when
1108 * the window that the objects of the transit belongs has already been created.
1109 * This is because this effect needs the geometry information about the objects,
1110 * and if the window was not created yet, it can get a wrong information.
1113 elm_transit_effect_translation_add(Elm_Transit *transit, Evas_Coord from_dx, Evas_Coord from_dy, Evas_Coord to_dx, Evas_Coord to_dy)
1115 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1116 void *effect_context = _transit_effect_translation_context_new(from_dx, from_dy, to_dx, to_dy);
1118 if (!effect_context) return NULL;
1119 elm_transit_effect_add(transit,
1120 _transit_effect_translation_op, effect_context,
1121 _transit_effect_translation_context_free);
1122 return effect_context;
1126 ///////////////////////////////////////////////////////////////////////////////
1128 ///////////////////////////////////////////////////////////////////////////////
1129 typedef struct _Elm_Transit_Effect_Zoom Elm_Transit_Effect_Zoom;
1131 struct _Elm_Transit_Effect_Zoom
1137 _transit_effect_zoom_context_free(void *data, Elm_Transit *transit __UNUSED__)
1143 _transit_effect_zoom_op(void *data, Elm_Transit *transit , double progress)
1145 EINA_SAFETY_ON_NULL_RETURN(data);
1146 EINA_SAFETY_ON_NULL_RETURN(transit);
1149 Elm_Transit_Effect_Zoom *zoom = data;
1151 Evas_Coord x, y, w, h;
1153 map = evas_map_new(4);
1156 EINA_LIST_FOREACH(transit->objs, elist, obj)
1158 evas_object_geometry_get(obj, &x, &y, &w, &h);
1159 evas_map_util_points_populate_from_object_full(map, obj, zoom->from +
1160 (progress * zoom->to));
1161 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, FOCAL);
1162 evas_object_map_set(obj, map);
1163 evas_object_map_enable_set(obj, EINA_TRUE);
1169 _transit_effect_zoom_context_new(float from_rate, float to_rate)
1171 Elm_Transit_Effect_Zoom *zoom;
1173 zoom = ELM_NEW(Elm_Transit_Effect_Zoom);
1174 if (!zoom) return NULL;
1176 zoom->from = (FOCAL - (from_rate * FOCAL)) * (1 / from_rate);
1177 zoom->to = ((FOCAL - (to_rate * FOCAL)) * (1 / to_rate)) - zoom->from;
1183 * Add the Zoom Effect to Elm_Transit.
1185 * @note This API is one of the facades. It creates zoom effect context
1186 * and add it's required APIs to elm_transit_effect_add.
1188 * @see elm_transit_effect_add()
1190 * @param transit Transit object.
1191 * @param from_rate Scale rate when effect begins (1 is current rate).
1192 * @param to_rate Scale rate when effect ends.
1193 * @return Zoom effect context data.
1196 * @warning Is higher recommended just create a transit with this effect when
1197 * the window that the objects of the transit belongs has already been created.
1198 * This is because this effect needs the geometry information about the objects,
1199 * and if the window was not created yet, it can get a wrong information.
1202 elm_transit_effect_zoom_add(Elm_Transit *transit, float from_rate, float to_rate)
1204 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1205 void *effect_context = _transit_effect_zoom_context_new(from_rate, to_rate);
1207 if (!effect_context) return NULL;
1208 elm_transit_effect_add(transit,
1209 _transit_effect_zoom_op, effect_context,
1210 _transit_effect_zoom_context_free);
1211 return effect_context;
1215 ///////////////////////////////////////////////////////////////////////////////
1217 ///////////////////////////////////////////////////////////////////////////////
1218 typedef struct _Elm_Transit_Effect_Flip Elm_Transit_Effect_Flip;
1220 struct _Elm_Transit_Effect_Flip
1222 Elm_Transit_Effect_Flip_Axis axis;
1227 _transit_effect_flip_context_free(void *data, Elm_Transit *transit)
1229 EINA_SAFETY_ON_NULL_RETURN(data);
1230 EINA_SAFETY_ON_NULL_RETURN(transit);
1231 Evas_Object *front, *back;
1233 int count = eina_list_count(transit->objs);
1235 for (i = 0; i < (count - 1); i += 2)
1237 front = eina_list_nth(transit->objs, i);
1238 back = eina_list_nth(transit->objs, i+1);
1239 evas_object_map_enable_set(front, EINA_FALSE);
1240 evas_object_map_enable_set(back, EINA_FALSE);
1246 _transit_effect_flip_op(void *data, Elm_Transit *transit, double progress)
1248 EINA_SAFETY_ON_NULL_RETURN(data);
1249 EINA_SAFETY_ON_NULL_RETURN(transit);
1250 Evas_Object *obj, *front, *back;
1252 Elm_Transit_Effect_Flip *flip = data;
1255 Evas_Coord x, y, w, h;
1257 map = evas_map_new(4);
1260 if (flip->cw) degree = (float)(progress * 180);
1261 else degree = (float)(progress * -180);
1263 count = eina_list_count(transit->objs);
1264 for (i = 0; i < (count - 1); i += 2)
1266 Evas_Coord half_w, half_h;
1268 front = eina_list_nth(transit->objs, i);
1269 back = eina_list_nth(transit->objs, i+1);
1271 if ((degree < 90) && (degree > -90))
1276 evas_object_hide(back);
1277 evas_object_show(front);
1285 evas_object_hide(front);
1286 evas_object_show(back);
1290 evas_map_util_points_populate_from_object_full(map, obj, 0);
1291 evas_object_geometry_get(obj, &x, &y, &w, &h);
1295 if (flip->axis == ELM_TRANSIT_EFFECT_FLIP_AXIS_Y)
1297 if ((degree >= 90) || (degree <= -90))
1299 evas_map_point_image_uv_set(map, 0, w, 0);
1300 evas_map_point_image_uv_set(map, 1, 0, 0);
1301 evas_map_point_image_uv_set(map, 2, 0, h);
1302 evas_map_point_image_uv_set(map, 3, w, h);
1304 evas_map_util_3d_rotate(map, 0, degree,
1305 0, x + half_w, y + half_h, 0);
1309 if ((degree >= 90) || (degree <= -90))
1311 evas_map_point_image_uv_set(map, 0, 0, h);
1312 evas_map_point_image_uv_set(map, 1, w, h);
1313 evas_map_point_image_uv_set(map, 2, w, 0);
1314 evas_map_point_image_uv_set(map, 3, 0, 0);
1316 evas_map_util_3d_rotate(map, degree,
1317 0, 0, x + half_w, y + half_h, 0);
1319 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, FOCAL);
1320 evas_object_map_enable_set(front, EINA_TRUE);
1321 evas_object_map_enable_set(back, EINA_TRUE);
1322 evas_object_map_set(obj, map);
1328 _transit_effect_flip_context_new(Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1330 Elm_Transit_Effect_Flip *flip;
1332 flip = ELM_NEW(Elm_Transit_Effect_Flip);
1333 if (!flip) return NULL;
1342 * Add the Flip Effect to Elm_Transit.
1344 * @note This API is one of the facades. It creates flip effect context
1345 * and add it's required APIs to elm_transit_effect_add.
1346 * @note This effect is applied to each pair of objects in the order they are listed
1347 * in the transit list of objects. The first object in the pair will be the
1348 * "front" object and the second will be the "back" object.
1350 * @see elm_transit_effect_add()
1352 * @param transit Transit object.
1353 * @param axis Flipping Axis(X or Y).
1354 * @param cw Flipping Direction. EINA_TRUE is clock-wise.
1355 * @return Flip effect context data.
1358 * @warning Is higher recommended just create a transit with this effect when
1359 * the window that the objects of the transit belongs has already been created.
1360 * This is because this effect needs the geometry information about the objects,
1361 * and if the window was not created yet, it can get a wrong information.
1364 elm_transit_effect_flip_add(Elm_Transit *transit, Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1366 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1367 void *effect_context = _transit_effect_flip_context_new(axis, cw);
1369 if (!effect_context) return NULL;
1370 elm_transit_effect_add(transit,
1371 _transit_effect_flip_op, effect_context,
1372 _transit_effect_flip_context_free);
1373 return effect_context;
1376 ///////////////////////////////////////////////////////////////////////////////
1378 ///////////////////////////////////////////////////////////////////////////////
1379 typedef struct _Elm_Transit_Effect_Resizable_Flip Elm_Transit_Effect_ResizableFlip;
1380 typedef struct _Elm_Transit_Effect_Resizable_Flip_Node Elm_Transit_Effect_ResizableFlip_Node;
1382 struct _Elm_Transit_Effect_Resizable_Flip_Node
1388 } from_pos, from_size, to_pos, to_size;
1391 struct _Elm_Transit_Effect_Resizable_Flip
1395 Elm_Transit_Effect_Flip_Axis axis;
1399 _resizable_flip_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1401 Elm_Transit_Effect_ResizableFlip *resizable_flip = data;
1403 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1405 EINA_LIST_FOREACH(resizable_flip->nodes, elist, resizable_flip_node)
1407 if (resizable_flip_node->front == obj)
1408 evas_object_event_callback_del(resizable_flip_node->back,
1409 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1410 else if (resizable_flip_node->back == obj)
1411 evas_object_event_callback_del(resizable_flip_node->front,
1412 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1415 resizable_flip->nodes = eina_list_remove_list(resizable_flip->nodes,
1417 free(resizable_flip_node);
1423 _resizable_flip_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_ResizableFlip *resizable_flip)
1425 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1426 Eina_List *data_list = NULL;
1427 Evas_Coord front_x, front_y, front_w, front_h;
1428 Evas_Coord back_x, back_y, back_w, back_h;
1431 count = eina_list_count(transit->objs);
1432 for (i = 0; i < (count - 1); i += 2)
1434 resizable_flip_node = ELM_NEW(Elm_Transit_Effect_ResizableFlip_Node);
1435 if (!resizable_flip_node)
1437 eina_list_free(data_list);
1441 resizable_flip_node->front = eina_list_nth(transit->objs, i);
1442 resizable_flip_node->back = eina_list_nth(transit->objs, i+1);
1444 evas_object_geometry_get(resizable_flip_node->front,
1445 &front_x, &front_y, &front_w, &front_h);
1446 evas_object_geometry_get(resizable_flip_node->back,
1447 &back_x, &back_y, &back_w, &back_h);
1449 resizable_flip_node->from_pos.x = front_x;
1450 resizable_flip_node->from_pos.y = front_y;
1451 resizable_flip_node->to_pos.x = back_x - front_x;
1452 resizable_flip_node->to_pos.y = back_y - front_y;
1454 resizable_flip_node->from_size.x = front_w;
1455 resizable_flip_node->from_size.y = front_h;
1456 resizable_flip_node->to_size.x = back_w - front_w;
1457 resizable_flip_node->to_size.y = back_h - front_h;
1459 data_list = eina_list_append(data_list, resizable_flip_node);
1461 evas_object_event_callback_add(resizable_flip_node->back,
1462 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb, resizable_flip);
1463 evas_object_event_callback_add(resizable_flip_node->front,
1464 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb, resizable_flip);
1471 _set_image_uv_by_axis_y(Evas_Map *map, Elm_Transit_Effect_ResizableFlip_Node *flip, float degree)
1473 if ((degree >= 90) || (degree <= -90))
1475 evas_map_point_image_uv_set(map, 0,
1476 (flip->from_size.x * 2) + flip->to_size.x,
1478 evas_map_point_image_uv_set(map, 1, 0, 0);
1479 evas_map_point_image_uv_set(map, 2, 0,
1480 (flip->from_size.y * 2) + flip->to_size.y);
1481 evas_map_point_image_uv_set(map, 3,
1482 (flip->from_size.x * 2) + flip->to_size.x,
1483 (flip->from_size.y * 2) + flip->to_size.y);
1487 evas_map_point_image_uv_set(map, 0, 0, 0);
1488 evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
1489 evas_map_point_image_uv_set(map, 2, flip->from_size.x,
1491 evas_map_point_image_uv_set(map, 3, 0, flip->from_size.y);
1496 _set_image_uv_by_axis_x(Evas_Map *map, Elm_Transit_Effect_ResizableFlip_Node *flip, float degree)
1498 if ((degree >= 90) || (degree <= -90))
1500 evas_map_point_image_uv_set(map, 0, 0,
1501 (flip->from_size.y * 2) + flip->to_size.y);
1502 evas_map_point_image_uv_set(map, 1,
1503 (flip->from_size.x * 2) + flip->to_size.x,
1504 (flip->from_size.y * 2) + flip->to_size.y);
1505 evas_map_point_image_uv_set(map, 2,
1506 (flip->from_size.x * 2) + flip->to_size.x,
1508 evas_map_point_image_uv_set(map, 3, 0, 0);
1512 evas_map_point_image_uv_set(map, 0, 0, 0);
1513 evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
1514 evas_map_point_image_uv_set(map, 2, flip->from_size.x,
1516 evas_map_point_image_uv_set(map, 3, 0, flip->from_size.y);
1521 _transit_effect_resizable_flip_context_free(void *data, Elm_Transit *transit __UNUSED__)
1523 EINA_SAFETY_ON_NULL_RETURN(data);
1525 Elm_Transit_Effect_ResizableFlip *resizable_flip = data;
1526 Eina_List *elist, *elist_next;
1527 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1529 EINA_LIST_FOREACH_SAFE(resizable_flip->nodes,
1530 elist, elist_next, resizable_flip_node)
1532 evas_object_map_enable_set(resizable_flip_node->front, EINA_FALSE);
1533 evas_object_map_enable_set(resizable_flip_node->back, EINA_FALSE);
1535 resizable_flip->nodes = eina_list_remove_list(resizable_flip->nodes,
1538 evas_object_event_callback_del(resizable_flip_node->back,
1539 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1540 evas_object_event_callback_del(resizable_flip_node->front,
1541 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1542 free(resizable_flip_node);
1544 free(resizable_flip);
1548 _transit_effect_resizable_flip_op(void *data, Elm_Transit *transit __UNUSED__, double progress)
1550 EINA_SAFETY_ON_NULL_RETURN(data);
1555 Evas_Coord half_w, half_h;
1556 Elm_Transit_Effect_ResizableFlip *resizable_flip = data;
1557 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1560 map = evas_map_new(4);
1563 if (resizable_flip->cw) degree = (float)(progress * 180);
1564 else degree = (float)(progress * -180);
1566 if (!resizable_flip->nodes)
1567 resizable_flip->nodes = _resizable_flip_nodes_build(transit,
1570 EINA_LIST_FOREACH(resizable_flip->nodes, elist, resizable_flip_node)
1572 if ((degree < 90) && (degree > -90))
1574 obj = resizable_flip_node->front;
1575 if (resizable_flip_node->front != resizable_flip_node->back)
1577 evas_object_hide(resizable_flip_node->back);
1578 evas_object_show(resizable_flip_node->front);
1583 obj = resizable_flip_node->back;
1584 if (resizable_flip_node->front != resizable_flip_node->back)
1586 evas_object_hide(resizable_flip_node->front);
1587 evas_object_show(resizable_flip_node->back);
1591 x = resizable_flip_node->from_pos.x +
1592 (resizable_flip_node->to_pos.x * progress);
1593 y = resizable_flip_node->from_pos.y +
1594 (resizable_flip_node->to_pos.y * progress);
1595 w = resizable_flip_node->from_size.x +
1596 (resizable_flip_node->to_size.x * progress);
1597 h = resizable_flip_node->from_size.y +
1598 (resizable_flip_node->to_size.y * progress);
1599 evas_map_point_coord_set(map, 0, x, y, 0);
1600 evas_map_point_coord_set(map, 1, x + w, y, 0);
1601 evas_map_point_coord_set(map, 2, x + w, y + h, 0);
1602 evas_map_point_coord_set(map, 3, x, y + h, 0);
1604 half_w = (Evas_Coord)(w / 2);
1605 half_h = (Evas_Coord)(h / 2);
1607 if (resizable_flip->axis == ELM_TRANSIT_EFFECT_FLIP_AXIS_Y)
1609 _set_image_uv_by_axis_y(map, resizable_flip_node, degree);
1610 evas_map_util_3d_rotate(map, 0, degree,
1611 0, x + half_w, y + half_h, 0);
1615 _set_image_uv_by_axis_x(map, resizable_flip_node, degree);
1616 evas_map_util_3d_rotate(map, degree, 0,
1617 0, x + half_w, y + half_h, 0);
1620 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, FOCAL);
1621 evas_object_map_enable_set(resizable_flip_node->front, EINA_TRUE);
1622 evas_object_map_enable_set(resizable_flip_node->back, EINA_TRUE);
1623 evas_object_map_set(obj, map);
1629 _transit_effect_resizable_flip_context_new(Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1631 Elm_Transit_Effect_ResizableFlip *resizable_flip;
1633 resizable_flip = ELM_NEW(Elm_Transit_Effect_ResizableFlip);
1634 if (!resizable_flip) return NULL;
1636 resizable_flip->cw = cw;
1637 resizable_flip->axis = axis;
1639 return resizable_flip;
1643 * Add the Resizable Flip Effect to Elm_Transit.
1645 * @note This API is one of the facades. It creates resizable flip effect context
1646 * and add it's required APIs to elm_transit_effect_add.
1647 * @note This effect is applied to each pair of objects in the order they are listed
1648 * in the transit list of objects. The first object in the pair will be the
1649 * "front" object and the second will be the "back" object.
1651 * @see elm_transit_effect_add()
1653 * @param transit Transit object.
1654 * @param axis Flipping Axis(X or Y).
1655 * @param cw Flipping Direction. EINA_TRUE is clock-wise.
1656 * @return Resizable flip effect context data.
1659 * @warning Is higher recommended just create a transit with this effect when
1660 * the window that the objects of the transit belongs has already been created.
1661 * This is because this effect needs the geometry information about the objects,
1662 * and if the window was not created yet, it can get a wrong information.
1665 elm_transit_effect_resizable_flip_add(Elm_Transit *transit, Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1667 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1668 void *effect_context = _transit_effect_resizable_flip_context_new(axis, cw);
1670 if (!effect_context) return NULL;
1671 elm_transit_effect_add(transit,
1672 _transit_effect_resizable_flip_op, effect_context,
1673 _transit_effect_resizable_flip_context_free);
1674 return effect_context;
1678 ///////////////////////////////////////////////////////////////////////////////
1680 ///////////////////////////////////////////////////////////////////////////////
1681 typedef struct _Elm_Transit_Effect_Wipe Elm_Transit_Effect_Wipe;
1683 struct _Elm_Transit_Effect_Wipe
1685 Elm_Transit_Effect_Wipe_Type type;
1686 Elm_Transit_Effect_Wipe_Dir dir;
1690 _elm_fx_wipe_hide(Evas_Map * map, Elm_Transit_Effect_Wipe_Dir dir, float x, float y, float w, float h, float progress)
1696 case ELM_TRANSIT_EFFECT_WIPE_DIR_LEFT:
1697 w2 = w - (w * progress);
1699 evas_map_point_image_uv_set(map, 0, 0, 0);
1700 evas_map_point_image_uv_set(map, 1, w2, 0);
1701 evas_map_point_image_uv_set(map, 2, w2, h);
1702 evas_map_point_image_uv_set(map, 3, 0, h);
1703 evas_map_point_coord_set(map, 0, x, y, 0);
1704 evas_map_point_coord_set(map, 1, x + w2, y, 0);
1705 evas_map_point_coord_set(map, 2, x + w2, h2, 0);
1706 evas_map_point_coord_set(map, 3, x, h2, 0);
1708 case ELM_TRANSIT_EFFECT_WIPE_DIR_RIGHT:
1709 w2 = (w * progress);
1711 evas_map_point_image_uv_set(map, 0, w2, 0);
1712 evas_map_point_image_uv_set(map, 1, w, 0);
1713 evas_map_point_image_uv_set(map, 2, w, h);
1714 evas_map_point_image_uv_set(map, 3, w2, h);
1715 evas_map_point_coord_set(map, 0, x + w2, y, 0);
1716 evas_map_point_coord_set(map, 1, x + w, y, 0);
1717 evas_map_point_coord_set(map, 2, x + w, h2, 0);
1718 evas_map_point_coord_set(map, 3, x + w2, h2, 0);
1720 case ELM_TRANSIT_EFFECT_WIPE_DIR_UP:
1722 h2 = h - (h * progress);
1723 evas_map_point_image_uv_set(map, 0, 0, 0);
1724 evas_map_point_image_uv_set(map, 1, w, 0);
1725 evas_map_point_image_uv_set(map, 2, w, h2);
1726 evas_map_point_image_uv_set(map, 3, 0, h2);
1727 evas_map_point_coord_set(map, 0, x, y, 0);
1728 evas_map_point_coord_set(map, 1, w2, y, 0);
1729 evas_map_point_coord_set(map, 2, w2, y+h2, 0);
1730 evas_map_point_coord_set(map, 3, x, y+h2, 0);
1732 case ELM_TRANSIT_EFFECT_WIPE_DIR_DOWN:
1734 h2 = (h * progress);
1735 evas_map_point_image_uv_set(map, 0, 0, h2);
1736 evas_map_point_image_uv_set(map, 1, w, h2);
1737 evas_map_point_image_uv_set(map, 2, w, h);
1738 evas_map_point_image_uv_set(map, 3, 0, h);
1739 evas_map_point_coord_set(map, 0, x, y + h2, 0);
1740 evas_map_point_coord_set(map, 1, w2, y + h2, 0);
1741 evas_map_point_coord_set(map, 2, w2, y + h, 0);
1742 evas_map_point_coord_set(map, 3, x, y + h, 0);
1747 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, FOCAL);
1751 _elm_fx_wipe_show(Evas_Map *map, Elm_Transit_Effect_Wipe_Dir dir, float x, float y, float w, float h, float progress)
1757 case ELM_TRANSIT_EFFECT_WIPE_DIR_LEFT:
1758 w2 = (w - (w * progress));
1760 evas_map_point_image_uv_set(map, 0, w2, 0);
1761 evas_map_point_image_uv_set(map, 1, w, 0);
1762 evas_map_point_image_uv_set(map, 2, w, h);
1763 evas_map_point_image_uv_set(map, 3, w2, h);
1764 evas_map_point_coord_set(map, 0, x + w2, y, 0);
1765 evas_map_point_coord_set(map, 1, w, y, 0);
1766 evas_map_point_coord_set(map, 2, w, h2, 0);
1767 evas_map_point_coord_set(map, 3, x + w2, h2, 0);
1769 case ELM_TRANSIT_EFFECT_WIPE_DIR_RIGHT:
1770 w2 = (w * progress);
1772 evas_map_point_image_uv_set(map, 0, 0, 0);
1773 evas_map_point_image_uv_set(map, 1, w2, 0);
1774 evas_map_point_image_uv_set(map, 2, w2, h);
1775 evas_map_point_image_uv_set(map, 3, 0, h);
1776 evas_map_point_coord_set(map, 0, x, y, 0);
1777 evas_map_point_coord_set(map, 1, x + w2, y, 0);
1778 evas_map_point_coord_set(map, 2, x + w2, h2, 0);
1779 evas_map_point_coord_set(map, 3, x, h2, 0);
1781 case ELM_TRANSIT_EFFECT_WIPE_DIR_UP:
1783 h2 = (h - (h * progress));
1784 evas_map_point_image_uv_set(map, 0, 0, h2);
1785 evas_map_point_image_uv_set(map, 1, w, h2);
1786 evas_map_point_image_uv_set(map, 2, w, h);
1787 evas_map_point_image_uv_set(map, 3, 0, h);
1788 evas_map_point_coord_set(map, 0, x, y + h2, 0);
1789 evas_map_point_coord_set(map, 1, w2, y + h2, 0);
1790 evas_map_point_coord_set(map, 2, w2, y + h, 0);
1791 evas_map_point_coord_set(map, 3, x, y + h, 0);
1793 case ELM_TRANSIT_EFFECT_WIPE_DIR_DOWN:
1795 h2 = (h * progress);
1796 evas_map_point_image_uv_set(map, 0, 0, 0);
1797 evas_map_point_image_uv_set(map, 1, w, 0);
1798 evas_map_point_image_uv_set(map, 2, w, h2);
1799 evas_map_point_image_uv_set(map, 3, 0, h2);
1800 evas_map_point_coord_set(map, 0, x, y, 0);
1801 evas_map_point_coord_set(map, 1, w2, y, 0);
1802 evas_map_point_coord_set(map, 2, w2, y + h2, 0);
1803 evas_map_point_coord_set(map, 3, x, y + h2, 0);
1808 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, FOCAL);
1812 _transit_effect_wipe_context_free(void *data, Elm_Transit *transit)
1814 EINA_SAFETY_ON_NULL_RETURN(data);
1815 EINA_SAFETY_ON_NULL_RETURN(transit);
1818 Elm_Transit_Effect_Wipe *wipe = data;
1819 Eina_Bool reverse = elm_transit_auto_reverse_get(transit);
1821 EINA_LIST_FOREACH(transit->objs, elist, obj)
1823 if ((wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_SHOW && !reverse)
1824 || (wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_HIDE && reverse))
1825 evas_object_show(obj);
1826 else evas_object_hide(obj);
1827 evas_object_map_enable_set(obj, EINA_FALSE);
1834 _transit_effect_wipe_op(void *data, Elm_Transit *transit, double progress)
1836 EINA_SAFETY_ON_NULL_RETURN(data);
1837 EINA_SAFETY_ON_NULL_RETURN(transit);
1838 Elm_Transit_Effect_Wipe *wipe = data;
1840 Evas_Coord _x, _y, _w, _h;
1844 map = evas_map_new(4);
1847 EINA_LIST_FOREACH(transit->objs, elist, obj)
1849 evas_object_geometry_get(obj, &_x, &_y, &_w, &_h);
1851 if (wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_SHOW)
1852 _elm_fx_wipe_show(map, wipe->dir, _x, _y, _w, _h, (float)progress);
1854 _elm_fx_wipe_hide(map, wipe->dir, _x, _y, _w, _h, (float)progress);
1856 evas_object_map_enable_set(obj, EINA_TRUE);
1857 evas_object_map_set(obj, map);
1863 _transit_effect_wipe_context_new(Elm_Transit_Effect_Wipe_Type type, Elm_Transit_Effect_Wipe_Dir dir)
1865 Elm_Transit_Effect_Wipe *wipe;
1867 wipe = ELM_NEW(Elm_Transit_Effect_Wipe);
1868 if (!wipe) return NULL;
1877 * Add the Wipe Effect to Elm_Transit.
1879 * @note This API is one of the facades. It creates wipe effect context
1880 * and add it's required APIs to elm_transit_effect_add.
1882 * @see elm_transit_effect_add()
1884 * @param transit Transit object.
1885 * @param type Wipe type. Hide or show.
1886 * @param dir Wipe Direction.
1887 * @return Wipe effect context data.
1890 * @warning Is higher recommended just create a transit with this effect when
1891 * the window that the objects of the transit belongs has already been created.
1892 * This is because this effect needs the geometry information about the objects,
1893 * and if the window was not created yet, it can get a wrong information.
1896 elm_transit_effect_wipe_add(Elm_Transit *transit, Elm_Transit_Effect_Wipe_Type type, Elm_Transit_Effect_Wipe_Dir dir)
1898 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1899 void *effect_context = _transit_effect_wipe_context_new(type, dir);
1901 if (!effect_context) return NULL;
1902 elm_transit_effect_add(transit,
1903 _transit_effect_wipe_op, effect_context,
1904 _transit_effect_wipe_context_free);
1905 return effect_context;
1909 ///////////////////////////////////////////////////////////////////////////////
1911 ///////////////////////////////////////////////////////////////////////////////
1912 typedef struct _Elm_Transit_Effect_Color Elm_Transit_Effect_Color;
1914 struct _Elm_Transit_Effect_Color
1916 struct _unsigned_color {
1917 unsigned int r, g, b, a;
1919 struct _signed_color {
1925 _transit_effect_color_context_free(void *data, Elm_Transit *transit __UNUSED__)
1931 _transit_effect_color_op(void *data, Elm_Transit *transit, double progress)
1933 EINA_SAFETY_ON_NULL_RETURN(data);
1934 EINA_SAFETY_ON_NULL_RETURN(transit);
1935 Elm_Transit_Effect_Color *color = data;
1938 unsigned int r, g, b, a;
1940 r = (color->from.r + (int)((float)color->to.r * progress));
1941 g = (color->from.g + (int)((float)color->to.g * progress));
1942 b = (color->from.b + (int)((float)color->to.b * progress));
1943 a = (color->from.a + (int)((float)color->to.a * progress));
1945 EINA_LIST_FOREACH(transit->objs, elist, obj)
1946 evas_object_color_set(obj, r, g, b, a);
1950 _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)
1952 Elm_Transit_Effect_Color *color;
1954 color = ELM_NEW(Elm_Transit_Effect_Color);
1955 if (!color) return NULL;
1957 color->from.r = from_r;
1958 color->from.g = from_g;
1959 color->from.b = from_b;
1960 color->from.a = from_a;
1961 color->to.r = to_r - from_r;
1962 color->to.g = to_g - from_g;
1963 color->to.b = to_b - from_b;
1964 color->to.a = to_a - from_a;
1970 * Add the Color Effect to Elm_Transit.
1972 * @note This API is one of the facades. It creates color effect context
1973 * and add it's required APIs to elm_transit_effect_add.
1975 * @see elm_transit_effect_add()
1977 * @param transit Transit object.
1978 * @param from_r RGB R when effect begins.
1979 * @param from_g RGB G when effect begins.
1980 * @param from_b RGB B when effect begins.
1981 * @param from_a RGB A when effect begins.
1982 * @param to_r RGB R when effect ends.
1983 * @param to_g RGB G when effect ends.
1984 * @param to_b RGB B when effect ends.
1985 * @param to_a RGB A when effect ends.
1986 * @return Color effect context data.
1991 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)
1993 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1994 void *effect_context = _transit_effect_color_context_new(from_r, from_g, from_b, from_a, to_r, to_g, to_b, to_a);
1996 if (!effect_context) return NULL;
1997 elm_transit_effect_add(transit,
1998 _transit_effect_color_op, effect_context,
1999 _transit_effect_color_context_free);
2000 return effect_context;
2003 ///////////////////////////////////////////////////////////////////////////////
2005 ///////////////////////////////////////////////////////////////////////////////
2006 typedef struct _Elm_Transit_Effect_Fade Elm_Transit_Effect_Fade;
2007 typedef struct _Elm_Transit_Effect_Fade_Node Elm_Transit_Effect_Fade_Node;
2009 struct _Elm_Transit_Effect_Fade_Node
2011 Evas_Object *before;
2013 struct _signed_color before_color, after_color;
2016 Eina_Bool inversed : 1;
2019 struct _Elm_Transit_Effect_Fade
2025 _fade_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2027 Elm_Transit_Effect_Fade *fade = data;
2029 Elm_Transit_Effect_Fade_Node *fade_node;
2031 EINA_LIST_FOREACH(fade->nodes, elist, fade_node)
2033 if (fade_node->before == obj)
2034 evas_object_event_callback_del(fade_node->after,
2035 EVAS_CALLBACK_DEL, _fade_object_del_cb);
2036 else if (fade_node->after == obj)
2037 evas_object_event_callback_del(fade_node->before,
2038 EVAS_CALLBACK_DEL, _fade_object_del_cb);
2041 fade->nodes = eina_list_remove_list(fade->nodes, elist);
2048 _fade_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Fade *fade_data)
2050 Elm_Transit_Effect_Fade_Node *fade;
2051 Eina_List *data_list = NULL;
2054 count = eina_list_count(transit->objs);
2055 for (i = 0; i < (count - 1); i += 2)
2057 fade = ELM_NEW(Elm_Transit_Effect_Fade_Node);
2060 eina_list_free(data_list);
2064 fade->before = eina_list_nth(transit->objs, i);
2065 fade->after = eina_list_nth(transit->objs, i+1);
2067 evas_object_color_get(fade->before,
2068 &fade->before_color.r, &fade->before_color.g,
2069 &fade->before_color.b, &fade->before_color.a);
2070 evas_object_color_get(fade->after,
2071 &fade->after_color.r, &fade->after_color.g,
2072 &fade->after_color.b, &fade->after_color.a);
2074 fade->before_alpha = (255 - fade->before_color.a);
2075 fade->after_alpha = (255 - fade->after_color.a);
2077 data_list = eina_list_append(data_list, fade);
2079 evas_object_event_callback_add(fade->before,
2080 EVAS_CALLBACK_DEL, _fade_object_del_cb, fade_data);
2081 evas_object_event_callback_add(fade->after,
2082 EVAS_CALLBACK_DEL, _fade_object_del_cb, fade_data);
2088 _transit_effect_fade_context_free(void *data, Elm_Transit *transit __UNUSED__)
2090 EINA_SAFETY_ON_NULL_RETURN(data);
2091 Elm_Transit_Effect_Fade *fade = data;
2092 Elm_Transit_Effect_Fade_Node *fade_node;
2093 Eina_List *elist, *elist_next;
2095 EINA_LIST_FOREACH_SAFE(fade->nodes, elist, elist_next, fade_node)
2097 evas_object_color_set(fade_node->before, fade_node->before_color.r,
2098 fade_node->before_color.g,
2099 fade_node->before_color.b,
2100 fade_node->before_color.a);
2101 evas_object_color_set(fade_node->after, fade_node->after_color.r,
2102 fade_node->after_color.g,
2103 fade_node->after_color.b,
2104 fade_node->after_color.a);
2106 fade->nodes = eina_list_remove_list(fade->nodes, elist);
2107 evas_object_event_callback_del(fade_node->before,
2108 EVAS_CALLBACK_DEL, _fade_object_del_cb);
2109 evas_object_event_callback_del(fade_node->after,
2110 EVAS_CALLBACK_DEL, _fade_object_del_cb);
2118 _transit_effect_fade_op(void *data, Elm_Transit *transit __UNUSED__, double progress)
2120 EINA_SAFETY_ON_NULL_RETURN(data);
2121 Elm_Transit_Effect_Fade *fade = data;
2123 Elm_Transit_Effect_Fade_Node *fade_node;
2127 fade->nodes = _fade_nodes_build(transit, fade);
2129 EINA_LIST_FOREACH(fade->nodes, elist, fade_node)
2133 if (!fade_node->inversed)
2135 evas_object_hide(fade_node->after);
2136 evas_object_show(fade_node->before);
2137 fade_node->inversed = EINA_TRUE;
2140 _progress = (1 - (progress * 2));
2142 evas_object_color_set(fade_node->before,
2143 fade_node->before_color.r * _progress,
2144 fade_node->before_color.g * _progress,
2145 fade_node->before_color.b * _progress,
2146 fade_node->before_color.a +
2147 fade_node->before_alpha * (1 - _progress));
2151 if (fade_node->inversed)
2153 evas_object_hide(fade_node->before);
2154 evas_object_show(fade_node->after);
2155 fade_node->inversed = EINA_FALSE;
2158 _progress = ((progress - 0.5) * 2);
2160 evas_object_color_set(fade_node->after,
2161 fade_node->after_color.r * _progress,
2162 fade_node->after_color.g * _progress,
2163 fade_node->after_color.b * _progress,
2164 fade_node->after_color.a +
2165 fade_node->after_alpha * (1 - _progress));
2171 _transit_effect_fade_context_new(void)
2173 Elm_Transit_Effect_Fade *fade;
2174 fade = ELM_NEW(Elm_Transit_Effect_Fade);
2175 if (!fade) return NULL;
2180 * Add the Fade Effect to Elm_Transit.
2182 * @note This API is one of the facades. It creates fade effect context
2183 * and add it's required APIs to elm_transit_effect_add.
2184 * @note This effect is applied to each pair of objects in the order they are listed
2185 * in the transit list of objects. The first object in the pair will be the
2186 * "before" object and the second will be the "after" object.
2188 * @see elm_transit_effect_add()
2190 * @param transit Transit object.
2191 * @return Fade effect context data.
2194 * @warning Is higher recommended just create a transit with this effect when
2195 * the window that the objects of the transit belongs has already been created.
2196 * This is because this effect needs the color information about the objects,
2197 * and if the window was not created yet, it can get a wrong information.
2200 elm_transit_effect_fade_add(Elm_Transit *transit)
2202 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2204 void *effect_context = _transit_effect_fade_context_new();
2205 if (!effect_context) return NULL;
2206 elm_transit_effect_add(transit,
2207 _transit_effect_fade_op, effect_context,
2208 _transit_effect_fade_context_free);
2209 return effect_context;
2213 ///////////////////////////////////////////////////////////////////////////////
2215 ///////////////////////////////////////////////////////////////////////////////
2216 typedef struct _Elm_Transit_Effect_Blend Elm_Transit_Effect_Blend;
2217 typedef struct _Elm_Transit_Effect_Blend_Node Elm_Transit_Effect_Blend_Node;
2219 struct _Elm_Transit_Effect_Blend_Node
2221 Evas_Object *before;
2223 struct _signed_color from, to;
2226 struct _Elm_Transit_Effect_Blend
2232 _blend_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2234 Elm_Transit_Effect_Blend *blend = data;
2236 Elm_Transit_Effect_Blend_Node *blend_node;
2238 EINA_LIST_FOREACH(blend->nodes, elist, blend_node)
2240 if (blend_node->after == obj)
2241 evas_object_event_callback_del(blend_node->before,
2242 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2243 else if (blend_node->before == obj)
2244 evas_object_event_callback_del(blend_node->after,
2245 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2248 blend->nodes = eina_list_remove_list(blend->nodes, elist);
2255 _blend_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Blend *blend)
2257 Elm_Transit_Effect_Blend_Node *blend_node;
2258 Eina_List *data_list = NULL;
2261 count = eina_list_count(transit->objs);
2262 for (i = 0; i < (count - 1); i += 2)
2264 blend_node = ELM_NEW(Elm_Transit_Effect_Blend_Node);
2267 eina_list_free(data_list);
2271 blend_node->before = eina_list_nth(transit->objs, i);
2272 blend_node->after = eina_list_nth(transit->objs, i + 1);
2273 evas_object_show(blend_node->before);
2274 evas_object_show(blend_node->after);
2276 evas_object_color_get(blend_node->before, &blend_node->from.r,
2277 &blend_node->from.g, &blend_node->from.b,
2278 &blend_node->from.a);
2279 evas_object_color_get(blend_node->after, &blend_node->to.r,
2280 &blend_node->to.g, &blend_node->to.b,
2283 data_list = eina_list_append(data_list, blend_node);
2285 evas_object_event_callback_add(blend_node->before,
2286 EVAS_CALLBACK_DEL, _blend_object_del_cb, blend);
2287 evas_object_event_callback_add(blend_node->after,
2288 EVAS_CALLBACK_DEL, _blend_object_del_cb, blend);
2294 _transit_effect_blend_context_free(void *data, Elm_Transit *transit __UNUSED__)
2296 EINA_SAFETY_ON_NULL_RETURN(data);
2297 Elm_Transit_Effect_Blend *blend = data;
2298 Elm_Transit_Effect_Blend_Node *blend_node;
2299 Eina_List *elist, *elist_next;
2301 EINA_LIST_FOREACH_SAFE(blend->nodes, elist, elist_next, blend_node)
2303 evas_object_color_set(blend_node->before,
2304 blend_node->from.r, blend_node->from.g,
2305 blend_node->from.b, blend_node->from.a);
2306 evas_object_color_set(blend_node->after, blend_node->to.r,
2307 blend_node->to.g, blend_node->to.b,
2310 if (elm_transit_auto_reverse_get(transit))
2311 evas_object_hide(blend_node->after);
2313 evas_object_hide(blend_node->before);
2315 blend->nodes = eina_list_remove_list(blend->nodes, elist);
2317 evas_object_event_callback_del(blend_node->before,
2318 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2319 evas_object_event_callback_del(blend_node->after,
2320 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2327 _transit_effect_blend_op(void *data, Elm_Transit *transit, double progress)
2329 EINA_SAFETY_ON_NULL_RETURN(data);
2330 EINA_SAFETY_ON_NULL_RETURN(transit);
2331 Elm_Transit_Effect_Blend *blend = data;
2332 Elm_Transit_Effect_Blend_Node *blend_node;
2335 if (!blend->nodes) blend->nodes = _blend_nodes_build(transit, blend);
2337 EINA_LIST_FOREACH(blend->nodes, elist, blend_node)
2339 evas_object_color_set(blend_node->before,
2340 (int)(blend_node->from.r * (1 - progress)),
2341 (int)(blend_node->from.g * (1 - progress)),
2342 (int)(blend_node->from.b * (1 - progress)),
2343 (int)(blend_node->from.a * (1 - progress)));
2344 evas_object_color_set(blend_node->after,
2345 (int)(blend_node->to.r * progress),
2346 (int)(blend_node->to.g * progress),
2347 (int)(blend_node->to.b * progress),
2348 (int)(blend_node->to.a * progress));
2353 _transit_effect_blend_context_new(void)
2355 Elm_Transit_Effect_Blend *blend;
2357 blend = ELM_NEW(Elm_Transit_Effect_Blend);
2358 if (!blend) return NULL;
2363 * Add the Blend Effect to Elm_Transit.
2365 * @note This API is one of the facades. It creates blend effect context
2366 * and add it's required APIs to elm_transit_effect_add.
2367 * @note This effect is applied to each pair of objects in the order they are listed
2368 * in the transit list of objects. The first object in the pair will be the
2369 * "before" object and the second will be the "after" object.
2371 * @see elm_transit_effect_add()
2373 * @param transit Transit object.
2374 * @return Blend effect context data.
2377 * @warning Is higher recommended just create a transit with this effect when
2378 * the window that the objects of the transit belongs has already been created.
2379 * This is because this effect needs the color information about the objects,
2380 * and if the window was not created yet, it can get a wrong information.
2383 elm_transit_effect_blend_add(Elm_Transit *transit)
2385 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2386 void *effect_context = _transit_effect_blend_context_new();
2388 if (!effect_context) return NULL;
2389 elm_transit_effect_add(transit,
2390 _transit_effect_blend_op, effect_context,
2391 _transit_effect_blend_context_free);
2392 return effect_context;
2396 ///////////////////////////////////////////////////////////////////////////////
2398 ///////////////////////////////////////////////////////////////////////////////
2399 typedef struct _Elm_Transit_Effect_Rotation Elm_Transit_Effect_Rotation;
2401 struct _Elm_Transit_Effect_Rotation
2407 _transit_effect_rotation_context_free(void *data, Elm_Transit *transit __UNUSED__)
2413 _transit_effect_rotation_op(void *data, Elm_Transit *transit, double progress)
2415 EINA_SAFETY_ON_NULL_RETURN(data);
2416 EINA_SAFETY_ON_NULL_RETURN(transit);
2417 Elm_Transit_Effect_Rotation *rotation = data;
2419 Evas_Coord x, y, w, h;
2421 float half_w, half_h;
2425 map = evas_map_new(4);
2428 EINA_LIST_FOREACH(transit->objs, elist, obj)
2430 evas_map_util_points_populate_from_object_full(map, obj, 0);
2431 degree = rotation->from + (float)(progress * rotation->to);
2433 evas_object_geometry_get(obj, &x, &y, &w, &h);
2435 half_w = (float)w * 0.5;
2436 half_h = (float)h * 0.5;
2438 evas_map_util_3d_rotate(map, 0, 0, degree, x + half_w, y + half_h, 0);
2439 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, FOCAL);
2440 evas_object_map_enable_set(obj, EINA_TRUE);
2441 evas_object_map_set(obj, map);
2447 _transit_effect_rotation_context_new(float from_degree, float to_degree)
2449 Elm_Transit_Effect_Rotation *rotation;
2451 rotation = ELM_NEW(Elm_Transit_Effect_Rotation);
2452 if (!rotation) return NULL;
2454 rotation->from = from_degree;
2455 rotation->to = to_degree - from_degree;
2461 * Add the Rotation Effect to Elm_Transit.
2463 * @note This API is one of the facades. It creates rotation effect context
2464 * and add it's required APIs to elm_transit_effect_add.
2466 * @see elm_transit_effect_add()
2468 * @param transit Transit object.
2469 * @param from_degree Degree when effect begins.
2470 * @param to_degree Degree when effect is ends.
2471 * @return Rotation effect context data.
2474 * @warning Is higher recommended just create a transit with this effect when
2475 * the window that the objects of the transit belongs has already been created.
2476 * This is because this effect needs the geometry information about the objects,
2477 * and if the window was not created yet, it can get a wrong information.
2480 elm_transit_effect_rotation_add(Elm_Transit *transit, float from_degree, float to_degree)
2482 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2483 void *effect_context = _transit_effect_rotation_context_new(from_degree, to_degree);
2485 if (!effect_context) return NULL;
2486 elm_transit_effect_add(transit,
2487 _transit_effect_rotation_op, effect_context,
2488 _transit_effect_rotation_context_free);
2489 return effect_context;
2493 ///////////////////////////////////////////////////////////////////////////////
2494 // ImageAnimation FX
2495 ///////////////////////////////////////////////////////////////////////////////
2496 typedef struct _Elm_Transit_Effect_Image_Animation Elm_Transit_Effect_Image_Animation;
2498 struct _Elm_Transit_Effect_Image_Animation
2504 _transit_effect_image_animation_context_free(void *data, Elm_Transit *transit __UNUSED__)
2506 EINA_SAFETY_ON_NULL_RETURN(data);
2507 Elm_Transit_Effect_Image_Animation *image_animation = data;
2509 Eina_List *elist, *elist_next;
2511 EINA_LIST_FOREACH_SAFE(image_animation->images, elist, elist_next, image)
2513 image_animation->images =
2514 eina_list_remove_list(image_animation->images, elist);
2515 eina_stringshare_del(image);
2522 _transit_effect_image_animation_op(void *data, Elm_Transit *transit, double progress)
2524 EINA_SAFETY_ON_NULL_RETURN(data);
2525 EINA_SAFETY_ON_NULL_RETURN(transit);
2529 Elm_Transit_Effect_Image_Animation *image_animation = data;
2530 unsigned int count = 0;
2533 type = eina_stringshare_add("icon");
2534 len = eina_list_count(image_animation->images);
2536 if (!len) count = floor(progress * len);
2537 else count = floor(progress * (len - 1));
2539 EINA_LIST_FOREACH(transit->objs, elist, obj)
2541 if (elm_widget_type_check(obj, type))
2542 elm_icon_file_set(obj,
2543 eina_list_nth(image_animation->images, count), NULL);
2546 eina_stringshare_del(type);
2550 _transit_effect_image_animation_context_new(Eina_List *images)
2552 Elm_Transit_Effect_Image_Animation *image_animation;
2553 image_animation = ELM_NEW(Elm_Transit_Effect_Image_Animation);
2555 if (!image_animation) return NULL;
2556 image_animation->images = images;
2557 return image_animation;
2561 * Add the ImageAnimation Effect to Elm_Transit.
2563 * @note This API is one of the facades. It creates image animation effect context
2564 * and add it's required APIs to elm_transit_effect_add.
2565 * The @p images parameter is a list images paths. This list and
2566 * its contents will be deleted at the end of the effect by
2567 * elm_transit_effect_image_animation_context_free() function.
2571 * char buf[PATH_MAX];
2572 * Eina_List *images = NULL;
2573 * Elm_Transit *transi = elm_transit_add();
2575 * snprintf(buf, sizeof(buf), "%s/images/icon_11.png", PACKAGE_DATA_DIR);
2576 * images = eina_list_append(images, eina_stringshare_add(buf));
2578 * snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
2579 * images = eina_list_append(images, eina_stringshare_add(buf));
2580 * elm_transit_effect_image_animation_add(transi, images);
2584 * @see elm_transit_effect_add()
2586 * @param transit Transit object.
2587 * @param images Eina_List of images file paths. This list and
2588 * its contents will be deleted at the end of the effect by
2589 * elm_transit_effect_image_animation_context_free() function.
2590 * @return Image Animation effect context data.
2595 elm_transit_effect_image_animation_add(Elm_Transit *transit, Eina_List *images)
2597 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2598 void *effect_context = _transit_effect_image_animation_context_new(images);
2600 if (!effect_context) return NULL;
2601 elm_transit_effect_add(transit,
2602 _transit_effect_image_animation_op, effect_context,
2603 _transit_effect_image_animation_context_free);
2604 return effect_context;