1 #include <Elementary.h>
5 * @defgroup Transit Transit
8 * Transit is designed to set the various effects for the Evas_Object such like translation,
9 * rotation, etc. For using Effects, Create transit and add the some of effects which are
10 * interested. Each effects has the type of Elm_Effect and those can be added into transit.
11 * Once effects are added into transit, it will manage the effects (ex deleting).
16 Elm_Animator *animator;
17 Eina_List *effect_list;
18 Evas_Object *block_rect;
19 void (*completion_op) (void *data, Elm_Transit *transit);
21 Eina_Bool reserved_del:1;
26 void (*animation_op) (void *data, Elm_Animator *animator, double frame);
27 void (*begin_op) (void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt);
28 void (*end_op) (void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt);
29 unsigned int shared_cnt;
33 static Evas_Object *_create_block_rect(Evas_Object *parent);
34 static void _transit_animate_cb(void *data, Elm_Animator *animator, double frame);
35 static void _transit_fx_begin(Elm_Transit *transit);
36 static void _transit_fx_end(Elm_Transit *transit);
37 static void _transit_complete_cb(void *data);
38 static void _transit_fx_del(Elm_Effect *effect);
41 _create_block_rect(Evas_Object *parent)
47 rect = evas_object_rectangle_add(evas_object_evas_get(parent));
48 evas_output_size_get(evas_object_evas_get(parent), &w, &h);
49 evas_object_resize(rect, w, h);
50 evas_object_color_set(rect, 0, 0, 0, 0);
55 _transit_animate_cb(void *data, Elm_Animator *animator, double frame)
61 Elm_Transit *transit = data;
63 EINA_LIST_FOREACH(transit->effect_list, elist, effect)
65 effect->animation_op(effect->user_data, animator, frame);
70 _transit_fx_begin(Elm_Transit *transit)
76 Eina_Bool auto_reverse;
78 unsigned int repeat_cnt;
80 auto_reverse = elm_animator_auto_reverse_get(transit->animator);
81 repeat_cnt = elm_animator_repeat_get(transit->animator);
83 EINA_LIST_FOREACH(transit->effect_list, elist, effect)
86 effect->begin_op(effect->user_data, auto_reverse, repeat_cnt);
91 _transit_fx_end(Elm_Transit *transit)
97 Eina_Bool auto_reverse;
99 unsigned int repeat_cnt;
101 auto_reverse = elm_animator_auto_reverse_get(transit->animator);
102 repeat_cnt = elm_animator_repeat_get(transit->animator);
104 EINA_LIST_FOREACH(transit->effect_list, elist, effect)
107 effect->end_op(effect->user_data, auto_reverse, repeat_cnt);
112 _transit_complete_cb(void *data)
114 Elm_Transit *transit = (Elm_Transit *) data;
116 evas_render(evas_object_evas_get(transit->parent));
118 _transit_fx_end(transit);
120 if (transit->block_rect)
121 evas_object_hide(transit->block_rect);
123 if (transit->completion_op)
124 transit->completion_op(transit->completion_arg, transit);
126 if (transit->reserved_del)
128 transit->reserved_del = EINA_FALSE;
129 elm_transit_del(transit);
134 _transit_fx_del(Elm_Effect *effect)
139 --effect->shared_cnt;
141 if (effect->shared_cnt > 0)
143 if (effect->user_data)
144 free(effect->user_data);
151 * Set the event block when the transit is operating.
153 * @param transit Transit object
154 * @param disable Disable or enable
157 elm_transit_event_block_disabled_set(Elm_Transit *transit, Eina_Bool disable)
164 if (transit->block_rect)
166 evas_object_del(transit->block_rect);
167 transit->block_rect = NULL;
172 if (transit->block_rect == NULL)
173 transit->block_rect = _create_block_rect(transit->parent);
180 * Get the event block setting status.
182 * @param transit Transit object
183 * @return EINA_TRUE when the event block is disabled
186 elm_transit_event_block_disabled_get(Elm_Transit *transit)
190 return transit->block_rect ? EINA_TRUE : EINA_FALSE;
196 * Remove effect from transit.
198 * @param transit Transit object
199 * @param effect effect that should be removed
200 * @return EINA_TRUE, if the effect is removed
201 * @warning If the effect is not inserted in any transit, it will be deleted
204 elm_transit_fx_remove(Elm_Transit *transit, Elm_Effect *effect)
213 EINA_LIST_FOREACH(transit->effect_list, elist, _effect)
215 if (_effect == effect)
217 transit->effect_list =
218 eina_list_remove(transit->effect_list, _effect);
219 _transit_fx_del(_effect);
229 * Remove all current inseted effects.
231 * @param transit Transit object
234 elm_transit_fx_clear(Elm_Transit *transit)
243 EINA_LIST_FOREACH(transit->effect_list, elist, effect)
245 transit->effect_list = eina_list_remove(transit->effect_list, effect);
246 _transit_fx_del(effect);
253 * Remove all current inseted effects.
255 * @param transit Transit object
256 * @return Effect list
258 EAPI const Eina_List *
259 elm_transit_fx_get(Elm_Transit *transit)
263 return transit->effect_list;
269 * Set the user-callback function when the transit is done.
271 * @param transit Transit object
272 * @param op Callback function pointer
273 * @param data Callback funtion user argument
276 elm_transit_completion_callback_set(Elm_Transit *transit,
277 void (*op) (void *data,
278 Elm_Transit *transit),
283 transit->completion_op = op;
284 transit->completion_arg = data;
290 * Delete transit object.
292 * @param transit Transit object
295 elm_transit_del(Elm_Transit *transit)
299 if (elm_animator_operating_get(transit->animator))
301 transit->reserved_del = EINA_TRUE;
305 if (transit->block_rect)
306 evas_object_del(transit->block_rect);
308 elm_animator_del(transit->animator);
309 elm_transit_fx_clear(transit);
317 * Set the animation acceleration style.
319 * @param transit Transit object
320 * @param cs Curve style
323 elm_transit_curve_style_set(Elm_Transit *transit, Elm_Animator_Curve_Style cs)
327 elm_animator_curve_style_set(transit->animator, cs);
335 * @param parent Given canvas of parent object will be blocked
336 * @return Transit object
339 elm_transit_add(Evas_Object *parent)
341 Elm_Transit *transit = calloc(1, sizeof(Elm_Transit));
346 transit->animator = elm_animator_add(parent);
348 if (!transit->animator)
354 transit->parent = parent;
355 elm_animator_operation_callback_set(transit->animator, _transit_animate_cb,
357 elm_animator_completion_callback_set(transit->animator, _transit_complete_cb,
359 elm_transit_event_block_disabled_set(transit, EINA_FALSE);
367 * Set auto reverse function.
369 * @param transit Transit object
370 * @param reverse Reverse or not
373 elm_transit_auto_reverse_set(Elm_Transit *transit, Eina_Bool reverse)
377 elm_animator_auto_reverse_set(transit->animator, reverse);
383 * Insert an effect in given transit.
385 * @param transit Transit object.
386 * @param effect Effect
387 * @return EINA_TRUE is success
390 elm_transit_fx_insert(Elm_Transit *transit, Elm_Effect *effect)
399 EINA_LIST_FOREACH(transit->effect_list, elist, _effect)
401 if (_effect == effect)
405 ++effect->shared_cnt;
406 transit->effect_list = eina_list_append(transit->effect_list, effect);
414 * Set the transit repeat count. Effect will be repeated by repeat count.
416 * @param transit Transit object
417 * @param repeat Repeat count
420 elm_transit_repeat_set(Elm_Transit *transit, unsigned int repeat)
424 elm_animator_repeat_set(transit->animator, repeat);
430 * Stop the current transit effect if transit is operating.
432 * @param transit Transit object
435 elm_transit_stop(Elm_Transit *transit)
439 elm_animator_stop(transit->animator);
445 * Run the all the inserted effects.
447 * @param transit Transit object
448 * @param duration Transit time in second
451 elm_transit_run(Elm_Transit *transit, double duration)
455 _transit_fx_begin(transit);
456 elm_animator_duration_set(transit->animator, duration);
459 if (transit->block_rect)
460 evas_object_show(transit->block_rect);
462 elm_animator_animate(transit->animator);
464 //If failed to animate.
465 if (!elm_animator_operating_get(transit->animator))
467 if (transit->block_rect)
468 evas_object_hide(transit->block_rect);
469 _transit_fx_end(transit);
473 /////////////////////////////////////////////////////////////////////////////////////
475 /////////////////////////////////////////////////////////////////////////////////////
476 typedef struct _resizing Elm_Fx_Resizing;
477 static void _elm_fx_resizing_op(void *data, Elm_Animator *animator, double frame);
478 static void _elm_fx_resizing_begin(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt);
479 static void _elm_fx_resizing_end(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt);
491 _elm_fx_resizing_begin(void *data, Eina_Bool auto_reverse,
492 unsigned int repeat_cnt)
494 Elm_Fx_Resizing *resizing = data;
496 evas_object_show(resizing->obj);
497 evas_object_resize(resizing->obj, resizing->from.w, resizing->from.h);
501 _elm_fx_resizing_end(void *data, Eina_Bool auto_reverse,
502 unsigned int repeat_cnt)
504 Elm_Fx_Resizing *resizing = data;
506 evas_object_move(resizing->obj, resizing->from.w + resizing->to.w,
507 resizing->from.h + resizing->to.h);
511 _elm_fx_resizing_op(void *data, Elm_Animator *animator, double frame)
515 Elm_Fx_Resizing *resizing = data;
517 w = resizing->from.w + (Evas_Coord) ((float)resizing->to.h * (float)frame);
518 h = resizing->from.h + (Evas_Coord) ((float)resizing->to.w * (float)frame);
519 evas_object_resize(resizing->obj, w, h);
525 * Add resizing effect.
527 * @param obj Evas_Object that effect is applying to
528 * @param from_w Width size when effect begin
529 * @param from_h Height size whene effect begin
530 * @param to_w Width size to be
531 * @param to_h Height size to be
532 * @return Resizing effect
535 elm_fx_resizing_add(Evas_Object *obj, Evas_Coord from_w, Evas_Coord from_h,
536 Evas_Coord to_w, Evas_Coord to_h)
540 Elm_Fx_Resizing *resizing;
545 effect = calloc(1, sizeof(Elm_Effect));
549 resizing = calloc(1, sizeof(Elm_Fx_Resizing));
557 resizing->from.w = from_w;
558 resizing->from.h = from_h;
559 resizing->to.w = to_w - from_w;
560 resizing->to.h = to_h - from_h;
562 effect->begin_op = _elm_fx_resizing_begin;
563 effect->animation_op = _elm_fx_resizing_op;
564 effect->user_data = resizing;
569 /////////////////////////////////////////////////////////////////////////////////////
571 /////////////////////////////////////////////////////////////////////////////////////
572 typedef struct _translation Elm_Fx_Translation;
573 static void _elm_fx_translation_op(void *data, Elm_Animator *animator, double frame);
574 static void _elm_fx_translation_begin(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt);
575 static void _elm_fx_translation_end(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt);
588 _elm_fx_translation_begin(void *data, Eina_Bool auto_reverse,
589 unsigned int repeat_cnt)
591 Elm_Fx_Translation *translation = data;
593 evas_object_show(translation->obj);
594 evas_object_move(translation->obj, translation->from.x, translation->from.y);
598 _elm_fx_translation_end(void *data, Eina_Bool auto_reverse,
599 unsigned int repeat_cnt)
601 Elm_Fx_Translation *translation = data;
603 evas_object_move(translation->obj, translation->from.x + translation->to.x,
604 translation->from.y + translation->to.y);
608 _elm_fx_translation_op(void *data, Elm_Animator *animator, double frame)
612 Elm_Fx_Translation *translation = data;
614 x = translation->from.x +
615 (Evas_Coord) ((float)translation->to.x * (float)frame);
616 y = translation->from.y +
617 (Evas_Coord) ((float)translation->to.y * (float)frame);
618 evas_object_move(translation->obj, x, y);
624 * Add translation effect.
626 * @param obj Evas_Object that effect is applying to
627 * @param from_x Position X when effect begin
628 * @param from_y Position Y whene effect begin
629 * @param to_x Position X to be
630 * @param to_y Position Y to be
631 * @return Translation effect
634 elm_fx_translation_add(Evas_Object *obj, Evas_Coord from_x, Evas_Coord from_y,
635 Evas_Coord to_x, Evas_Coord to_y)
639 Elm_Fx_Translation *translation;
644 effect = calloc(1, sizeof(Elm_Effect));
648 translation = calloc(1, sizeof(Elm_Fx_Translation));
656 translation->obj = obj;
657 translation->from.x = from_x;
658 translation->from.y = from_y;
659 translation->to.x = to_x - from_x;
660 translation->to.y = to_y - from_y;
662 effect->begin_op = _elm_fx_translation_begin;
663 effect->end_op = _elm_fx_translation_end;
664 effect->animation_op = _elm_fx_translation_op;
665 effect->user_data = translation;
670 /////////////////////////////////////////////////////////////////////////////////////
672 /////////////////////////////////////////////////////////////////////////////////////
673 typedef struct _zoom Elm_Fx_Zoom;
674 static void _elm_fx_zoom_op(void *data, Elm_Animator * animator, double frame);
675 static void _elm_fx_zoom_begin(void *data, Eina_Bool reverse, unsigned int repeat);
676 static void _elm_fx_zoom_end(void *data, Eina_Bool reverse, unsigned int repeat);
685 _elm_fx_zoom_begin(void *data, Eina_Bool reverse, unsigned int repeat)
687 Elm_Fx_Zoom *zoom = data;
689 evas_object_show(zoom->obj);
690 _elm_fx_zoom_op(data, NULL, 0);
694 _elm_fx_zoom_end(void *data, Eina_Bool reverse, unsigned int repeat)
696 Elm_Fx_Zoom *zoom = data;
698 evas_object_map_enable_set(zoom->obj, EINA_FALSE);
702 _elm_fx_zoom_op(void *data, Elm_Animator *animator, double frame)
708 Evas_Coord x, y, w, h;
710 map = evas_map_new(4);
715 evas_object_geometry_get(zoom->obj, &x, &y, &w, &h);
716 evas_map_smooth_set(map, EINA_TRUE);
717 evas_map_util_points_populate_from_object_full(map, zoom->obj,
720 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, 10000);
721 evas_object_map_set(zoom->obj, map);
722 evas_object_map_enable_set(zoom->obj, EINA_TRUE);
731 * @param obj Evas_Object that effect is applying to
732 * @param from_rate Scale rate when the effect begin (1 is current rate)
733 * @param to_rate Scale rate to be
734 * @return Zoom effect
737 elm_fx_zoom_add(Evas_Object *obj, float from_rate, float to_rate)
746 effect = calloc(1, sizeof(Elm_Effect));
750 zoom = calloc(1, sizeof(Elm_Fx_Zoom));
758 zoom->from = (10000 - (from_rate * 10000)) * (1 / from_rate);
759 zoom->to = ((10000 - (to_rate * 10000)) * (1 / to_rate)) - zoom->from;
760 effect->begin_op = _elm_fx_zoom_begin;
761 effect->end_op = _elm_fx_zoom_end;
762 effect->animation_op = _elm_fx_zoom_op;
763 effect->user_data = zoom;
769 /////////////////////////////////////////////////////////////////////////////////////
771 /////////////////////////////////////////////////////////////////////////////////////
772 typedef struct _flip Elm_Fx_Flip;
773 static void _elm_fx_flip_op(void *data, Elm_Animator *animator, double frame);
774 static void _elm_fx_flip_end(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt);
780 Elm_Fx_Flip_Axis axis;
785 _elm_fx_flip_end(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
787 Elm_Fx_Flip *flip = data;
789 evas_object_map_enable_set(flip->front, EINA_FALSE);
790 evas_object_map_enable_set(flip->back, EINA_FALSE);
794 _elm_fx_flip_op(void *data, Elm_Animator *animator, double frame)
804 Evas_Coord x, y, w, h;
806 map = evas_map_new(4);
813 degree = (float)(frame * 180);
815 degree = (float)(frame * -180);
817 if (degree < 90 && degree > -90)
820 evas_object_hide(flip->back);
821 evas_object_show(flip->front);
826 evas_object_hide(flip->front);
827 evas_object_show(flip->back);
830 evas_map_smooth_set(map, EINA_TRUE);
831 evas_map_util_points_populate_from_object_full(map, obj, 0);
832 evas_object_geometry_get(obj, &x, &y, &w, &h);
833 Evas_Coord half_w = (w / 2);
835 Evas_Coord half_h = (h / 2);
837 if (flip->axis == ELM_FX_FLIP_AXIS_Y)
839 if ((degree >= 90) || (degree <= -90))
841 evas_map_point_image_uv_set(map, 0, w, 0);
842 evas_map_point_image_uv_set(map, 1, 0, 0);
843 evas_map_point_image_uv_set(map, 2, 0, h);
844 evas_map_point_image_uv_set(map, 3, w, h);
846 evas_map_util_3d_rotate(map, 0, degree, 0, x + half_w, y + half_h, 0);
850 if ((degree >= 90) || (degree <= -90))
852 evas_map_point_image_uv_set(map, 0, 0, h);
853 evas_map_point_image_uv_set(map, 1, w, h);
854 evas_map_point_image_uv_set(map, 2, w, 0);
855 evas_map_point_image_uv_set(map, 3, 0, 0);
857 evas_map_util_3d_rotate(map, degree, 0, 0, x + half_w, y + half_h, 0);
859 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, 10000);
860 evas_object_map_enable_set(flip->front, EINA_TRUE);
861 evas_object_map_enable_set(flip->back, EINA_TRUE);
862 evas_object_map_set(obj, map);
871 * @param front Front surface object
872 * @param back Back surface object
873 * @param axis Flipping Axis. X or Y
874 * @param cw Flipping Direction. EINA_TRUE is clock-wise
875 * @return Flip effect
878 elm_fx_flip_add(Evas_Object *front, Evas_Object *back, Elm_Fx_Flip_Axis axis,
885 if ((!front) || (!back))
888 effect = calloc(1, sizeof(Elm_Effect));
892 flip = calloc(1, sizeof(Elm_Fx_Flip));
904 effect->end_op = _elm_fx_flip_end;
905 effect->animation_op = _elm_fx_flip_op;
906 effect->user_data = flip;
911 /////////////////////////////////////////////////////////////////////////////////////
913 /////////////////////////////////////////////////////////////////////////////////////
914 typedef struct _resizable_flip Elm_Fx_ResizableFlip;
915 static void _elm_fx_resizable_flip_begin(void *data, Eina_Bool reverse, unsigned int repeat);
916 static void _elm_fx_resizable_flip_end(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt);
917 static void _elm_fx_resizable_flip_op(void *data, Elm_Animator *animator,
919 static void _set_image_uv_by_axis_y(Evas_Map *map, Elm_Fx_ResizableFlip *flip, float degree);
920 static void _set_image_uv_by_axis_x(Evas_Map *map, Elm_Fx_ResizableFlip *flip, float degree);
922 struct _resizable_flip
926 Elm_Fx_Flip_Axis axis;
930 } from_pos, from_size, to_pos, to_size;
935 _elm_fx_resizable_flip_begin(void *data, Eina_Bool reverse, unsigned int repeat)
937 Elm_Fx_ResizableFlip *resizable_flip = data;
939 evas_object_show(resizable_flip->front);
940 _elm_fx_resizable_flip_op(data, NULL, 0);
944 _elm_fx_resizable_flip_end(void *data, Eina_Bool auto_reverse,
945 unsigned int repeat_cnt)
947 Elm_Fx_ResizableFlip *resizable_flip = data;
949 evas_object_map_enable_set(resizable_flip->front, EINA_FALSE);
950 evas_object_map_enable_set(resizable_flip->back, EINA_FALSE);
954 _set_image_uv_by_axis_y(Evas_Map *map, Elm_Fx_ResizableFlip *flip,
957 if ((degree >= 90) || (degree <= -90))
959 evas_map_point_image_uv_set(map, 0,
960 (flip->from_size.x * 2) + flip->to_size.x,
962 evas_map_point_image_uv_set(map, 1, 0, 0);
963 evas_map_point_image_uv_set(map, 2, 0,
964 (flip->from_size.y * 2) + flip->to_size.y);
965 evas_map_point_image_uv_set(map, 3,
966 (flip->from_size.x * 2) + flip->to_size.x,
967 (flip->from_size.y * 2) + flip->to_size.y);
971 evas_map_point_image_uv_set(map, 0, 0, 0);
972 evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
973 evas_map_point_image_uv_set(map, 2, flip->from_size.x,
975 evas_map_point_image_uv_set(map, 3, 0, flip->to_size.y);
980 _set_image_uv_by_axis_x(Evas_Map *map, Elm_Fx_ResizableFlip *flip,
983 if ((degree >= 90) || (degree <= -90))
985 evas_map_point_image_uv_set(map, 0, 0,
986 (flip->from_size.y * 2) + flip->to_size.y);
987 evas_map_point_image_uv_set(map, 1,
988 (flip->from_size.x * 2) + flip->to_size.x,
989 (flip->from_size.y * 2) + flip->to_size.y);
990 evas_map_point_image_uv_set(map, 2,
991 (flip->from_size.x * 2) + flip->to_size.x,
993 evas_map_point_image_uv_set(map, 3, 0, 0);
997 evas_map_point_image_uv_set(map, 0, 0, 0);
998 evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
999 evas_map_point_image_uv_set(map, 2, flip->from_size.x,
1001 evas_map_point_image_uv_set(map, 3, 0, flip->to_size.y);
1006 _elm_fx_resizable_flip_op(void *data, Elm_Animator *animator, double frame)
1008 Elm_Fx_ResizableFlip *resizable_flip;
1018 Evas_Coord half_w, half_h;
1020 map = evas_map_new(4);
1024 resizable_flip = data;
1026 if (resizable_flip->cw)
1027 degree = (float)(frame * 180);
1029 degree = (float)(frame * -180);
1031 if ((degree < 90) && (degree > -90))
1033 obj = resizable_flip->front;
1034 evas_object_hide(resizable_flip->back);
1035 evas_object_show(resizable_flip->front);
1039 obj = resizable_flip->back;
1040 evas_object_hide(resizable_flip->front);
1041 evas_object_show(resizable_flip->back);
1044 evas_map_smooth_set(map, EINA_TRUE);
1046 x = resizable_flip->from_pos.x + (resizable_flip->to_pos.x * frame);
1047 y = resizable_flip->from_pos.y + (resizable_flip->to_pos.y * frame);
1048 w = resizable_flip->from_size.x + (resizable_flip->to_size.x * frame);
1049 h = resizable_flip->from_size.y + (resizable_flip->to_size.y * frame);
1050 evas_map_point_coord_set(map, 0, x, y, 0);
1051 evas_map_point_coord_set(map, 1, x + w, y, 0);
1052 evas_map_point_coord_set(map, 2, x + w, y + h, 0);
1053 evas_map_point_coord_set(map, 3, x, y + h, 0);
1055 half_w = (Evas_Coord) (w / 2);
1056 half_h = (Evas_Coord) (h / 2);
1058 if (resizable_flip->axis == ELM_FX_FLIP_AXIS_Y)
1060 _set_image_uv_by_axis_y(map, resizable_flip, degree);
1061 evas_map_util_3d_rotate(map, 0, degree, 0, x + half_w, y + half_h, 0);
1065 _set_image_uv_by_axis_x(map, resizable_flip, degree);
1066 evas_map_util_3d_rotate(map, degree, 0, 0, x + half_w, y + half_h, 0);
1069 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, 10000);
1070 evas_object_map_enable_set(resizable_flip->front, EINA_TRUE);
1071 evas_object_map_enable_set(resizable_flip->back, EINA_TRUE);
1072 evas_object_map_set(obj, map);
1079 * Add ResizbleFlip effect.
1081 * @param front Front surface object
1082 * @param back Back surface object
1083 * @param axis Flipping Axis. X or Y
1084 * @param cw Flipping Direction. EINA_TRUE is clock-wise
1085 * @return Flip effect
1088 elm_fx_resizable_flip_add(Evas_Object *front, Evas_Object *back,
1089 Elm_Fx_Flip_Axis axis, Eina_Bool cw)
1091 Elm_Fx_ResizableFlip *resizable_flip;
1095 Evas_Coord front_x, front_y, front_w, front_h;
1097 Evas_Coord back_x, back_y, back_w, back_h;
1099 if (!front || !back)
1102 effect = calloc(1, sizeof(Elm_Effect));
1106 resizable_flip = calloc(1, sizeof(Elm_Fx_ResizableFlip));
1108 if (!resizable_flip)
1114 resizable_flip->front = front;
1115 resizable_flip->back = back;
1116 resizable_flip->cw = cw;
1117 resizable_flip->axis = axis;
1119 evas_object_geometry_get(resizable_flip->front, &front_x, &front_y, &front_w,
1121 evas_object_geometry_get(resizable_flip->back, &back_x, &back_y, &back_w,
1124 resizable_flip->from_pos.x = front_x;
1125 resizable_flip->from_pos.y = front_y;
1126 resizable_flip->to_pos.x = back_x - front_x;
1127 resizable_flip->to_pos.y = back_y - front_y;
1129 resizable_flip->from_size.x = front_w;
1130 resizable_flip->from_size.y = front_h;
1131 resizable_flip->to_size.x = back_w - front_w;
1132 resizable_flip->to_size.y = back_h - front_h;
1134 effect->begin_op = _elm_fx_resizable_flip_begin;
1135 effect->end_op = _elm_fx_resizable_flip_end;
1136 effect->animation_op = _elm_fx_resizable_flip_op;
1137 effect->user_data = resizable_flip;
1142 /////////////////////////////////////////////////////////////////////////////////////
1144 /////////////////////////////////////////////////////////////////////////////////////
1145 typedef struct _wipe Elm_Fx_Wipe;
1146 static void _elm_fx_wipe_op(void *data, Elm_Animator *animator, double frame);
1147 static void _elm_fx_wipe_begin(void *data, Eina_Bool auto_repeat, unsigned int repeat_cnt);
1148 static void _elm_fx_wipe_end(void *data, Eina_Bool auto_repeat, unsigned int repeat_cnt);
1149 static void _elm_fx_wipe_hide(Evas_Map * map, Elm_Fx_Wipe_Dir dir, float x, float y, float w, float h, float frame);
1150 static void _elm_fx_wipe_show(Evas_Map *map, Elm_Fx_Wipe_Dir dir, float x, float y, float w, float h, float frame);
1155 Elm_Fx_Wipe_Type type;
1156 Elm_Fx_Wipe_Dir dir;
1160 _elm_fx_wipe_begin(void *data, Eina_Bool auto_repeat, unsigned int repeat_cnt)
1162 Elm_Fx_Wipe *wipe = data;
1164 evas_object_show(wipe->obj);
1165 _elm_fx_wipe_op(data, NULL, 0);
1169 _elm_fx_wipe_end(void *data, Eina_Bool auto_repeat, unsigned int repeat_cnt)
1171 Elm_Fx_Wipe *wipe = data;
1173 evas_object_map_enable_set(wipe->obj, EINA_FALSE);
1177 _elm_fx_wipe_hide(Evas_Map * map, Elm_Fx_Wipe_Dir dir, float x, float y,
1178 float w, float h, float frame)
1184 case ELM_FX_WIPE_DIR_LEFT:
1185 w2 = w - (w * frame);
1187 evas_map_point_image_uv_set(map, 0, 0, 0);
1188 evas_map_point_image_uv_set(map, 1, w2, 0);
1189 evas_map_point_image_uv_set(map, 2, w2, h);
1190 evas_map_point_image_uv_set(map, 3, 0, h);
1191 evas_map_point_coord_set(map, 0, x, y, 0);
1192 evas_map_point_coord_set(map, 1, x + w2, y, 0);
1193 evas_map_point_coord_set(map, 2, x + w2, h2, 0);
1194 evas_map_point_coord_set(map, 3, x, h2, 0);
1196 case ELM_FX_WIPE_DIR_RIGHT:
1199 evas_map_point_image_uv_set(map, 0, w2, 0);
1200 evas_map_point_image_uv_set(map, 1, w, 0);
1201 evas_map_point_image_uv_set(map, 2, w, h);
1202 evas_map_point_image_uv_set(map, 3, w2, h);
1203 evas_map_point_coord_set(map, 0, x + w2, y, 0);
1204 evas_map_point_coord_set(map, 1, x + w, y, 0);
1205 evas_map_point_coord_set(map, 2, x + w, h2, 0);
1206 evas_map_point_coord_set(map, 3, x + w2, h2, 0);
1208 case ELM_FX_WIPE_DIR_UP:
1210 h2 = h - (h * frame);
1211 evas_map_point_image_uv_set(map, 0, 0, 0);
1212 evas_map_point_image_uv_set(map, 1, w, 0);
1213 evas_map_point_image_uv_set(map, 2, w, h2);
1214 evas_map_point_image_uv_set(map, 3, 0, h2);
1215 evas_map_point_coord_set(map, 0, x, y, 0);
1216 evas_map_point_coord_set(map, 1, w2, y, 0);
1217 evas_map_point_coord_set(map, 2, w2, h2, 0);
1218 evas_map_point_coord_set(map, 3, x, h2, 0);
1220 case ELM_FX_WIPE_DIR_DOWN:
1223 evas_map_point_image_uv_set(map, 0, 0, h2);
1224 evas_map_point_image_uv_set(map, 1, w, h2);
1225 evas_map_point_image_uv_set(map, 2, w, h);
1226 evas_map_point_image_uv_set(map, 3, 0, h);
1227 evas_map_point_coord_set(map, 0, x, y + h2, 0);
1228 evas_map_point_coord_set(map, 1, w2, y + h2, 0);
1229 evas_map_point_coord_set(map, 2, w2, y + h, 0);
1230 evas_map_point_coord_set(map, 3, x, y + h, 0);
1236 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, 10000);
1240 _elm_fx_wipe_show(Evas_Map *map, Elm_Fx_Wipe_Dir dir, float x, float y,
1241 float w, float h, float frame)
1247 case ELM_FX_WIPE_DIR_LEFT:
1248 w2 = (w - (w * frame));
1250 evas_map_point_image_uv_set(map, 0, w2, 0);
1251 evas_map_point_image_uv_set(map, 1, w, 0);
1252 evas_map_point_image_uv_set(map, 2, w, h);
1253 evas_map_point_image_uv_set(map, 3, w2, h);
1254 evas_map_point_coord_set(map, 0, x + w2, y, 0);
1255 evas_map_point_coord_set(map, 1, w, y, 0);
1256 evas_map_point_coord_set(map, 2, w, h2, 0);
1257 evas_map_point_coord_set(map, 3, x + w2, h2, 0);
1259 case ELM_FX_WIPE_DIR_RIGHT:
1262 evas_map_point_image_uv_set(map, 0, 0, 0);
1263 evas_map_point_image_uv_set(map, 1, w2, 0);
1264 evas_map_point_image_uv_set(map, 2, w2, h);
1265 evas_map_point_image_uv_set(map, 3, 0, h);
1266 evas_map_point_coord_set(map, 0, x, y, 0);
1267 evas_map_point_coord_set(map, 1, x + w2, y, 0);
1268 evas_map_point_coord_set(map, 2, x + w2, h2, 0);
1269 evas_map_point_coord_set(map, 3, x, h2, 0);
1271 case ELM_FX_WIPE_DIR_UP:
1273 h2 = (h - (h * frame));
1274 evas_map_point_image_uv_set(map, 0, 0, h2);
1275 evas_map_point_image_uv_set(map, 1, w, h2);
1276 evas_map_point_image_uv_set(map, 2, w, h);
1277 evas_map_point_image_uv_set(map, 3, 0, h);
1278 evas_map_point_coord_set(map, 0, x, y + h2, 0);
1279 evas_map_point_coord_set(map, 1, w2, y + h2, 0);
1280 evas_map_point_coord_set(map, 2, w2, y + h, 0);
1281 evas_map_point_coord_set(map, 3, x, y + h, 0);
1283 case ELM_FX_WIPE_DIR_DOWN:
1286 evas_map_point_image_uv_set(map, 0, 0, 0);
1287 evas_map_point_image_uv_set(map, 1, w, 0);
1288 evas_map_point_image_uv_set(map, 2, w, h2);
1289 evas_map_point_image_uv_set(map, 3, 0, h2);
1290 evas_map_point_coord_set(map, 0, x, y, 0);
1291 evas_map_point_coord_set(map, 1, w2, y, 0);
1292 evas_map_point_coord_set(map, 2, w2, y + h2, 0);
1293 evas_map_point_coord_set(map, 3, x, y + h2, 0);
1299 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, 10000);
1303 _elm_fx_wipe_op(void *data, Elm_Animator *animator, double frame)
1309 Evas_Coord _x, _y, _w, _h;
1311 map = evas_map_new(4);
1316 evas_map_smooth_set(map, EINA_TRUE);
1317 evas_object_geometry_get(wipe->obj, &_x, &_y, &_w, &_h);
1319 if (wipe->type == ELM_FX_WIPE_TYPE_SHOW)
1320 _elm_fx_wipe_show(map, wipe->dir, _x, _y, _w, _h, (float)frame);
1322 _elm_fx_wipe_hide(map, wipe->dir, _x, _y, _w, _h, (float)frame);
1324 evas_object_map_enable_set(wipe->obj, EINA_TRUE);
1325 evas_object_map_set(wipe->obj, map);
1334 * @param obj Evas_Object that effect is applying to
1335 * @param type Wipe type. Hide or show
1336 * @param dir Wipe Direction
1337 * @return Wipe Effect
1340 elm_fx_wipe_add(Evas_Object *obj, Elm_Fx_Wipe_Type type, Elm_Fx_Wipe_Dir dir)
1349 effect = calloc(1, sizeof(Elm_Effect));
1353 wipe = calloc(1, sizeof(Elm_Fx_Wipe));
1363 effect->begin_op = _elm_fx_wipe_begin;
1364 effect->end_op = _elm_fx_wipe_end;
1365 effect->animation_op = _elm_fx_wipe_op;
1366 effect->user_data = wipe;
1371 /////////////////////////////////////////////////////////////////////////////////////
1373 /////////////////////////////////////////////////////////////////////////////////////
1374 typedef struct _color Elm_Fx_Color;
1375 static void _elm_fx_color_begin(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt);
1376 static void _elm_fx_color_op(void *data, Elm_Animator *animator, double frame);
1381 struct _unsigned_color
1383 unsigned int r, g, b, a;
1385 struct _signed_color
1392 _elm_fx_color_begin(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
1394 Elm_Fx_Color *color = data;
1396 evas_object_show(color->obj);
1400 _elm_fx_color_op(void *data, Elm_Animator *animator, double frame)
1402 Elm_Fx_Color *color;
1404 unsigned int r, g, b, a;
1407 r = (color->from.r + (int)((float)color->to.r * frame));
1408 g = (color->from.g + (int)((float)color->to.g * frame));
1409 b = (color->from.b + (int)((float)color->to.b * frame));
1410 a = (color->from.a + (int)((float)color->to.a * frame));
1412 evas_object_color_set(color->obj, r, g, b, a);
1420 * @param obj Evas_Object that effect is applying to
1421 * @param from_r RGB R when the effect begins
1422 * @param from_g RGB G when the effect begins
1423 * @param from_b RGB B when the effect begins
1424 * @param from_a RGB A when the effect begins
1425 * @param to_r RGB R to be
1426 * @param to_g RGB G to be
1427 * @param to_b RGB B to be
1428 * @param to_a RGB A to be
1429 * @return Color Effect
1432 elm_fx_color_add(Evas_Object *obj, unsigned int from_r, unsigned int from_g,
1433 unsigned int from_b, unsigned int from_a, unsigned int to_r,
1434 unsigned int to_g, unsigned int to_b, unsigned int to_a)
1438 Elm_Fx_Color *color;
1443 effect = calloc(1, sizeof(Elm_Effect));
1447 color = calloc(1, sizeof(Elm_Fx_Color));
1455 color->from.r = from_r;
1456 color->from.g = from_g;
1457 color->from.b = from_b;
1458 color->from.a = from_a;
1459 color->to.r = to_r - from_r;
1460 color->to.g = to_g - from_g;
1461 color->to.b = to_b - from_b;
1462 color->to.a = to_a - from_a;
1464 effect->begin_op = _elm_fx_color_begin;
1465 effect->animation_op = _elm_fx_color_op;
1466 effect->user_data = color;
1471 /////////////////////////////////////////////////////////////////////////////////////
1473 /////////////////////////////////////////////////////////////////////////////////////
1474 typedef struct _fade Elm_Fx_Fade;
1475 static void _elm_fx_fade_begin(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt);
1476 static void _elm_fx_fade_end(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt);
1477 static void _elm_fx_fade_op(void *data, Elm_Animator *animator, double frame);
1481 Evas_Object *before;
1483 struct _signed_color before_color, after_color;
1486 Eina_Bool inversed:1;
1490 _elm_fx_fade_begin(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
1492 Elm_Fx_Fade *fade = data;
1494 fade->inversed = EINA_FALSE;
1498 _elm_fx_fade_end(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
1500 Elm_Fx_Fade *fade = data;
1502 evas_object_color_set(fade->before, fade->before_color.r,
1503 fade->before_color.g, fade->before_color.b,
1504 fade->before_color.a);
1505 evas_object_color_set(fade->after, fade->after_color.r, fade->after_color.g,
1506 fade->after_color.b, fade->after_color.a);
1510 _elm_fx_fade_op(void *data, Elm_Animator *animator, double frame)
1520 if (!fade->inversed)
1522 evas_object_hide(fade->after);
1523 evas_object_show(fade->before);
1524 fade->inversed = EINA_TRUE;
1527 _frame = (1 - (frame * 2));
1529 evas_object_color_set(fade->before, fade->before_color.r * _frame,
1530 fade->before_color.g * _frame,
1531 fade->before_color.b * _frame,
1532 fade->before_color.a + fade->before_alpha * (1 -
1539 evas_object_hide(fade->before);
1540 evas_object_show(fade->after);
1541 fade->inversed = EINA_FALSE;
1544 _frame = ((frame - 0.5) * 2);
1546 evas_object_color_set(fade->after, fade->after_color.r * _frame,
1547 fade->after_color.g * _frame,
1548 fade->after_color.b * _frame,
1549 fade->after_color.a + fade->after_alpha * (1 -
1560 * @param before Evas Object before fade in
1561 * @param after Evas Object after fade out
1562 * @return Fade Effect
1565 elm_fx_fade_add(Evas_Object *before, Evas_Object *after)
1571 if ((!before) && (!after))
1574 effect = calloc(1, sizeof(Elm_Effect));
1578 fade = calloc(1, sizeof(Elm_Fx_Fade));
1586 evas_object_color_get(before, &fade->before_color.r, &fade->before_color.g,
1587 &fade->before_color.b, &fade->before_color.a);
1588 evas_object_color_get(after, &fade->after_color.r, &fade->after_color.g,
1589 &fade->after_color.b, &fade->after_color.a);
1591 fade->before = before;
1592 fade->after = after;
1593 fade->before_alpha = (255 - fade->before_color.a);
1594 fade->after_alpha = (255 - fade->after_color.a);
1596 effect->begin_op = _elm_fx_fade_begin;
1597 effect->end_op = _elm_fx_fade_end;
1598 effect->animation_op = _elm_fx_fade_op;
1599 effect->user_data = fade;
1604 /////////////////////////////////////////////////////////////////////////////////////
1606 /////////////////////////////////////////////////////////////////////////////////////
1607 typedef struct _blend Elm_Fx_Blend;
1608 static void _elm_fx_blend_begin(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt);
1609 static void _elm_fx_blend_end(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt);
1610 static void _elm_fx_blend_op(void *data, Elm_Animator *animator, double frame);
1614 Evas_Object *before;
1616 struct _signed_color from, to;
1620 _elm_fx_blend_begin(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
1622 Elm_Fx_Blend *blend = data;
1624 evas_object_show(blend->before);
1628 _elm_fx_blend_end(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
1630 Elm_Fx_Blend *blend = data;
1632 evas_object_color_set(blend->before, blend->from.r, blend->from.g,
1633 blend->from.b, blend->from.a);
1634 evas_object_color_set(blend->after, blend->to.r, blend->to.g, blend->to.b,
1637 evas_object_hide(blend->before);
1639 evas_object_hide(blend->after);
1643 _elm_fx_blend_op(void *data, Elm_Animator *animator, double frame)
1645 Elm_Fx_Blend *blend = data;
1647 evas_object_show(blend->after);
1648 evas_object_color_set(blend->before, (int)(blend->from.r * (1 - frame)),
1649 (int)(blend->from.g * (1 - frame)),
1650 (int)(blend->from.b * (1 - frame)),
1651 (int)(blend->from.a * (1 - frame)));
1652 evas_object_color_set(blend->after, (int)(blend->to.r * frame),
1653 (int)(blend->to.g * frame), (int)(blend->to.b * frame),
1654 (int)(blend->to.a * frame));
1662 * @param before Evas Object before blending
1663 * @param after Evas Object after blending
1664 * @return Blend Effect
1667 elm_fx_blend_add(Evas_Object *before, Evas_Object *after)
1671 Elm_Fx_Blend *blend;
1673 if ((!before) && (!after))
1676 effect = calloc(1, sizeof(Elm_Effect));
1680 blend = calloc(1, sizeof(Elm_Fx_Blend));
1687 blend->before = before;
1688 blend->after = after;
1689 evas_object_color_get(before, &blend->from.r, &blend->from.g, &blend->from.b,
1691 evas_object_color_get(after, &blend->to.r, &blend->to.g, &blend->to.b,
1694 effect->begin_op = _elm_fx_blend_begin;
1695 effect->end_op = _elm_fx_blend_end;
1696 effect->animation_op = _elm_fx_blend_op;
1697 effect->user_data = blend;
1702 /////////////////////////////////////////////////////////////////////////////////////
1704 /////////////////////////////////////////////////////////////////////////////////////
1705 typedef struct _rotation Elm_Fx_Rotation;
1706 static void _elm_fx_rotation_begin(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt);
1707 static void _elm_fx_rotation_end(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt);
1708 static void _elm_fx_rotation_op(void *data, Elm_Animator *animator, double frame);
1718 _elm_fx_rotation_begin(void *data, Eina_Bool auto_reverse,
1719 unsigned int repeat_cnt)
1721 Elm_Fx_Rotation *rotation = data;
1723 evas_object_show(rotation->obj);
1727 _elm_fx_rotation_end(void *data, Eina_Bool auto_reverse,
1728 unsigned int repeat_cnt)
1730 Elm_Fx_Rotation *rotation = data;
1732 evas_object_map_enable_set(rotation->obj, EINA_FALSE);
1736 _elm_fx_rotation_op(void *data, Elm_Animator *animator, double frame)
1738 Elm_Fx_Rotation *rotation;
1742 Evas_Coord x, y, w, h;
1746 float half_w, half_h;
1748 map = evas_map_new(4);
1754 evas_map_smooth_set(map, EINA_TRUE);
1755 evas_map_util_points_populate_from_object_full(map, rotation->obj, 0);
1756 degree = rotation->from + (float)(frame * rotation->to);
1761 evas_object_geometry_get(rotation->obj, &x, &y, &w, &h);
1763 half_w = (float)w *0.5;
1765 half_h = (float)h *0.5;
1767 evas_map_util_3d_rotate(map, 0, 0, degree, x + half_w, y + half_h, 0);
1768 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, 10000);
1769 evas_object_map_enable_set(rotation->obj, EINA_TRUE);
1770 evas_object_map_set(rotation->obj, map);
1777 * Add Rotation Effect
1779 * @param obj Evas_Object that effect is applying to
1780 * @param from degree Degree when effect begins
1781 * @param to_degree Degree when effect is done
1782 * @param cw Rotation Direction. EINA_TRUE is clock wise
1783 * @return Rotation effect
1786 elm_fx_rotation_add(Evas_Object *obj, float from_degree, float to_degree,
1791 Elm_Fx_Rotation *rotation;
1796 effect = calloc(1, sizeof(Elm_Effect));
1800 rotation = calloc(1, sizeof(Elm_Fx_Rotation));
1808 rotation->obj = obj;
1809 rotation->from = from_degree;
1810 rotation->to = to_degree - from_degree;
1813 effect->begin_op = _elm_fx_rotation_begin;
1814 effect->end_op = _elm_fx_rotation_end;
1815 effect->animation_op = _elm_fx_rotation_op;
1816 effect->user_data = rotation;
1821 /////////////////////////////////////////////////////////////////////////////////////
1822 // ImageAnimation FX
1823 /////////////////////////////////////////////////////////////////////////////////////
1824 typedef struct _image_animation Elm_Fx_Image_Animation;
1825 static void _elm_fx_imageanimation_op(void *data, Elm_Animator *animator, double frame);
1826 EAPI Elm_Effect *elm_fx_imageanimation_add(Evas_Object *obj, const char **images, unsigned int item_num);
1828 struct _image_animation
1837 _elm_fx_imageanimation_op(void *data, Elm_Animator *animator, double frame)
1839 Elm_Fx_Image_Animation *image_animation = (Elm_Fx_Image_Animation *) data;
1841 if (!image_animation->obj)
1843 image_animation->count = floor(frame * image_animation->item_num);
1844 elm_icon_file_set(image_animation->obj,
1845 image_animation->images[image_animation->count], NULL);
1851 * Add ImageAnimation effect.
1853 * @param images Images for animation.
1854 * @return ImageAnimation Effect.
1857 elm_fx_imageanimation_add(Evas_Object *obj, const char **images,
1858 unsigned int item_num)
1862 Elm_Fx_Image_Animation *image_animation;
1864 if (!images || !(*images))
1867 effect = calloc(1, sizeof(Elm_Effect));
1871 image_animation = calloc(1, sizeof(Elm_Fx_Image_Animation));
1873 if (!image_animation)
1879 image_animation->obj = obj;
1880 image_animation->images = (char **)images;
1881 image_animation->count = 0;
1882 image_animation->item_num = item_num;
1884 effect->animation_op = _elm_fx_imageanimation_op;
1885 effect->user_data = image_animation;