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 insert the some of effects which are
10 * interested. Each effects has the type of Elm_Effect and those can be inserted into transit.
11 * Once effects are inserted into transit, transit will manage those 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,
36 static void _transit_fx_begin(Elm_Transit *transit);
37 static void _transit_fx_end(Elm_Transit *transit);
38 static void _transit_complete_cb(void *data);
39 static void _transit_fx_del(Elm_Effect *effect);
40 //static void _transit_parent_del(void *data);
44 _animator_parent_del(void *data)
46 Elm_Transit *transit = data;
47 elm_transit_del(data);
52 _create_block_rect(Evas_Object *parent)
58 rect = evas_object_rectangle_add(evas_object_evas_get(parent));
59 evas_output_size_get(evas_object_evas_get(parent), &w, &h);
60 evas_object_resize(rect, w, h);
61 evas_object_color_set(rect, 0, 0, 0, 0);
66 _transit_animate_cb(void *data, Elm_Animator *animator, double frame)
72 Elm_Transit *transit = data;
74 EINA_LIST_FOREACH(transit->effect_list, elist, effect)
76 effect->animation_op(effect->user_data, animator, frame);
81 _transit_fx_begin(Elm_Transit *transit)
87 Eina_Bool auto_reverse;
89 unsigned int repeat_cnt;
91 auto_reverse = elm_animator_auto_reverse_get(transit->animator);
92 repeat_cnt = elm_animator_repeat_get(transit->animator);
94 EINA_LIST_FOREACH(transit->effect_list, elist, effect)
97 effect->begin_op(effect->user_data, auto_reverse, repeat_cnt);
102 _transit_fx_end(Elm_Transit *transit)
108 Eina_Bool auto_reverse;
110 unsigned int repeat_cnt;
112 auto_reverse = elm_animator_auto_reverse_get(transit->animator);
113 repeat_cnt = elm_animator_repeat_get(transit->animator);
115 EINA_LIST_FOREACH(transit->effect_list, elist, effect)
118 effect->end_op(effect->user_data, auto_reverse, repeat_cnt);
123 _transit_complete_cb(void *data)
125 Elm_Transit *transit = (Elm_Transit *) data;
127 evas_render(evas_object_evas_get(transit->parent));
129 _transit_fx_end(transit);
131 if (transit->block_rect)
132 evas_object_hide(transit->block_rect);
134 if (transit->completion_op)
135 transit->completion_op(transit->completion_arg, transit);
137 if (transit->reserved_del)
139 transit->reserved_del = EINA_FALSE;
140 elm_transit_del(transit);
145 _transit_fx_del(Elm_Effect *effect)
150 --effect->shared_cnt;
152 if (effect->shared_cnt > 0)
154 if (effect->user_data)
155 free(effect->user_data);
160 * Set the event blocked when transit is operating.
162 * @param transit Transit object
163 * @param disabled Disable or enable
168 elm_transit_event_block_disabled_set(Elm_Transit *transit, Eina_Bool disabled)
175 if (transit->block_rect)
177 evas_object_del(transit->block_rect);
178 transit->block_rect = NULL;
183 if (transit->block_rect == NULL)
184 transit->block_rect = _create_block_rect(transit->parent);
189 * Get the value of event blockd status.
191 * @param transit Transit
192 * @return EINA_TRUE, when event block is disabled
197 elm_transit_event_block_disabled_get(Elm_Transit *transit)
201 return transit->block_rect ? EINA_TRUE : EINA_FALSE;
205 * Remove effect from transit.
207 * @param transit Transit
208 * @param effect Effect to be removed
209 * @return EINA_TRUE, if the effect is removed
210 * @warning If removed effect does not inserted in any transit, it will be deleted.
215 elm_transit_fx_remove(Elm_Transit *transit, Elm_Effect *effect)
224 EINA_LIST_FOREACH(transit->effect_list, elist, _effect)
226 if (_effect == effect)
228 transit->effect_list =
229 eina_list_remove(transit->effect_list, _effect);
230 _transit_fx_del(_effect);
238 * Remove all current inserted effects.
240 * @param transit Transit
245 elm_transit_fx_clear(Elm_Transit *transit)
254 EINA_LIST_FOREACH(transit->effect_list, elist, effect)
256 transit->effect_list = eina_list_remove(transit->effect_list, effect);
257 _transit_fx_del(effect);
262 * Get the list of current inseted effects.
264 * @param transit Transit
265 * @return Effect list
269 EAPI const Eina_List *
270 elm_transit_fx_get(Elm_Transit *transit)
274 return transit->effect_list;
278 * Set the user-callback function when the transit operation is done.
280 * @param transit Transit
281 * @param op Callback function pointer
282 * @param data Callback funtion user data
287 elm_transit_completion_callback_set(Elm_Transit *transit,
288 void (*op) (void *data,
289 Elm_Transit *transit),
294 transit->completion_op = op;
295 transit->completion_arg = data;
301 * @param transit Transit to be deleted
306 elm_transit_del(Elm_Transit *transit)
310 if (elm_animator_operating_get(transit->animator))
312 transit->reserved_del = EINA_TRUE;
316 if (transit->block_rect)
317 evas_object_del(transit->block_rect);
319 elm_animator_del(transit->animator);
320 elm_transit_fx_clear(transit);
322 // if(transit->parent)
324 // evas_object_event_callback_del(transit->parent, EVAS_CALLBACK_DEL, _transit_parent_del);
331 * Set the transit animation acceleration style.
333 * @param transit Transit
334 * @param cs Curve style(Please refer elm_animator_curve_style_set)
339 elm_transit_curve_style_set(Elm_Transit *transit, Elm_Animator_Curve_Style cs)
343 elm_animator_curve_style_set(transit->animator, cs);
350 * @param parent Parent object
356 elm_transit_add(Evas_Object *parent)
358 Elm_Transit *transit = calloc(1, sizeof(Elm_Transit));
363 transit->animator = elm_animator_add(parent);
365 if (!transit->animator)
371 transit->parent = parent;
372 elm_animator_operation_callback_set(transit->animator, _transit_animate_cb,
374 elm_animator_completion_callback_set(transit->animator, _transit_complete_cb,
376 elm_transit_event_block_disabled_set(transit, EINA_FALSE);
380 evas_object_event_callback_add(parent, EVAS_CALLBACK_DEL, _transit_parent_del,
388 * Set reverse effect automatically.
390 * @param transit Transit
391 * @param reverse EINA_TRUE is reverse.
396 elm_transit_auto_reverse_set(Elm_Transit *transit, Eina_Bool reverse)
400 elm_animator_auto_reverse_set(transit->animator, reverse);
404 * Insert an effect into the transit.
406 * @param transit Transit
407 * @param effect Effect to be inserted
408 * @return EINA_TRUE is success
413 elm_transit_fx_insert(Elm_Transit *transit, Elm_Effect *effect)
422 EINA_LIST_FOREACH(transit->effect_list, elist, _effect)
424 if (_effect == effect)
428 ++effect->shared_cnt;
429 transit->effect_list = eina_list_append(transit->effect_list, effect);
435 * Set the transit repeat count. Effect will be repeated by repeat count.
437 * @param transit Transit
438 * @param repeat Repeat count
443 elm_transit_repeat_set(Elm_Transit *transit, unsigned int repeat)
447 elm_animator_repeat_set(transit->animator, repeat);
451 * Stop the current transit, if the transit is operating.
453 * @param transit Transit
458 elm_transit_stop(Elm_Transit *transit)
462 elm_animator_stop(transit->animator);
466 * Run the all the inserted effects.
468 * @param transit Transit
469 * @param duration Transit time in seconds
474 elm_transit_run(Elm_Transit *transit, double duration)
478 _transit_fx_begin(transit);
479 elm_animator_duration_set(transit->animator, duration);
482 if (transit->block_rect)
483 evas_object_show(transit->block_rect);
485 elm_animator_animate(transit->animator);
487 //If failed to animate.
488 if (!elm_animator_operating_get(transit->animator))
490 if (transit->block_rect)
491 evas_object_hide(transit->block_rect);
492 _transit_fx_end(transit);
496 /////////////////////////////////////////////////////////////////////////////////////
498 /////////////////////////////////////////////////////////////////////////////////////
499 typedef struct _resizing Elm_Fx_Resizing;
500 static void _elm_fx_resizing_op(void *data, Elm_Animator *animator,
502 static void _elm_fx_resizing_begin(void *data, Eina_Bool auto_reverse,
503 unsigned int repeat_cnt);
515 _elm_fx_resizing_begin(void *data, Eina_Bool auto_reverse,
516 unsigned int repeat_cnt)
518 Elm_Fx_Resizing *resizing = data;
520 evas_object_show(resizing->obj);
521 evas_object_resize(resizing->obj, resizing->from.w, resizing->from.h);
525 _elm_fx_resizing_op(void *data, Elm_Animator *animator, double frame)
529 Elm_Fx_Resizing *resizing = data;
531 w = resizing->from.w + (Evas_Coord) ((float)resizing->to.h * (float)frame);
532 h = resizing->from.h + (Evas_Coord) ((float)resizing->to.w * (float)frame);
533 evas_object_resize(resizing->obj, w, h);
537 * Add Resizing effect.
539 * @param obj Evas_Object that effect is applying to
540 * @param from_w Object width size when effect begins
541 * @param from_h Object height size when effect begins
542 * @param to_w Object width size when effect ends
543 * @param to_h Object height size when effect ends
544 * @return Resizing effect
549 elm_fx_resizing_add(Evas_Object *obj, Evas_Coord from_w, Evas_Coord from_h,
550 Evas_Coord to_w, Evas_Coord to_h)
554 Elm_Fx_Resizing *resizing;
559 effect = calloc(1, sizeof(Elm_Effect));
563 resizing = calloc(1, sizeof(Elm_Fx_Resizing));
571 resizing->from.w = from_w;
572 resizing->from.h = from_h;
573 resizing->to.w = to_w - from_w;
574 resizing->to.h = to_h - from_h;
576 effect->begin_op = _elm_fx_resizing_begin;
577 effect->animation_op = _elm_fx_resizing_op;
578 effect->user_data = resizing;
583 /////////////////////////////////////////////////////////////////////////////////////
585 /////////////////////////////////////////////////////////////////////////////////////
586 typedef struct _translation Elm_Fx_Translation;
587 static void _elm_fx_translation_op(void *data, Elm_Animator *animator,
589 static void _elm_fx_translation_begin(void *data, Eina_Bool auto_reverse,
590 unsigned int repeat_cnt);
591 static void _elm_fx_translation_end(void *data, Eina_Bool auto_reverse,
592 unsigned int repeat_cnt);
604 _elm_fx_translation_begin(void *data, Eina_Bool auto_reverse,
605 unsigned int repeat_cnt)
607 Elm_Fx_Translation *translation = data;
609 evas_object_show(translation->obj);
610 evas_object_move(translation->obj, translation->from.x, translation->from.y);
614 _elm_fx_translation_end(void *data, Eina_Bool auto_reverse,
615 unsigned int repeat_cnt)
617 Elm_Fx_Translation *translation = data;
619 evas_object_move(translation->obj, translation->from.x + translation->to.x,
620 translation->from.y + translation->to.y);
624 _elm_fx_translation_op(void *data, Elm_Animator *animator, double frame)
628 Elm_Fx_Translation *translation = data;
630 x = translation->from.x +
631 (Evas_Coord) ((float)translation->to.x * (float)frame);
632 y = translation->from.y +
633 (Evas_Coord) ((float)translation->to.y * (float)frame);
634 evas_object_move(translation->obj, x, y);
638 * Add Translation effect.
640 * @param obj Evas_Object that effect is applying to
641 * @param from_x Position X when effect begins
642 * @param from_y Position Y when effect begins
643 * @param to_x Position X when effect ends
644 * @param to_y Position Y when effect ends
645 * @return Translation effect
650 elm_fx_translation_add(Evas_Object *obj, Evas_Coord from_x, Evas_Coord from_y,
651 Evas_Coord to_x, Evas_Coord to_y)
655 Elm_Fx_Translation *translation;
660 effect = calloc(1, sizeof(Elm_Effect));
664 translation = calloc(1, sizeof(Elm_Fx_Translation));
672 translation->obj = obj;
673 translation->from.x = from_x;
674 translation->from.y = from_y;
675 translation->to.x = to_x - from_x;
676 translation->to.y = to_y - from_y;
678 effect->begin_op = _elm_fx_translation_begin;
679 effect->end_op = _elm_fx_translation_end;
680 effect->animation_op = _elm_fx_translation_op;
681 effect->user_data = translation;
686 /////////////////////////////////////////////////////////////////////////////////////
688 /////////////////////////////////////////////////////////////////////////////////////
689 typedef struct _zoom Elm_Fx_Zoom;
690 static void _elm_fx_zoom_op(void *data, Elm_Animator * animator,
692 static void _elm_fx_zoom_begin(void *data, Eina_Bool reverse,
693 unsigned int repeat);
694 static void _elm_fx_zoom_end(void *data, Eina_Bool reverse,
695 unsigned int repeat);
704 _elm_fx_zoom_begin(void *data, Eina_Bool reverse, unsigned int repeat)
706 Elm_Fx_Zoom *zoom = data;
708 evas_object_show(zoom->obj);
709 _elm_fx_zoom_op(data, NULL, 0);
713 _elm_fx_zoom_end(void *data, Eina_Bool reverse, unsigned int repeat)
715 Elm_Fx_Zoom *zoom = data;
717 evas_object_map_enable_set(zoom->obj, EINA_FALSE);
721 _elm_fx_zoom_op(void *data, Elm_Animator *animator, double frame)
727 Evas_Coord x, y, w, h;
729 map = evas_map_new(4);
734 evas_object_geometry_get(zoom->obj, &x, &y, &w, &h);
735 evas_map_smooth_set(map, EINA_TRUE);
736 evas_map_util_points_populate_from_object_full(map, zoom->obj,
739 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, 10000);
740 evas_object_map_set(zoom->obj, map);
741 evas_object_map_enable_set(zoom->obj, EINA_TRUE);
748 * @param obj Evas_Object that effect is applying to
749 * @param from_rate Scale rate when effect begins (1 is current rate)
750 * @param to_rate Scale rate when effect ends
751 * @return Zoom effect
756 elm_fx_zoom_add(Evas_Object *obj, float from_rate, float to_rate)
765 effect = calloc(1, sizeof(Elm_Effect));
769 zoom = calloc(1, sizeof(Elm_Fx_Zoom));
777 zoom->from = (10000 - (from_rate * 10000)) * (1 / from_rate);
778 zoom->to = ((10000 - (to_rate * 10000)) * (1 / to_rate)) - zoom->from;
779 effect->begin_op = _elm_fx_zoom_begin;
780 effect->end_op = _elm_fx_zoom_end;
781 effect->animation_op = _elm_fx_zoom_op;
782 effect->user_data = zoom;
788 /////////////////////////////////////////////////////////////////////////////////////
790 /////////////////////////////////////////////////////////////////////////////////////
791 typedef struct _flip Elm_Fx_Flip;
792 static void _elm_fx_flip_op(void *data, Elm_Animator *animator,
794 static void _elm_fx_flip_end(void *data, Eina_Bool auto_reverse,
795 unsigned int repeat_cnt);
801 Elm_Fx_Flip_Axis axis;
806 _elm_fx_flip_end(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
808 Elm_Fx_Flip *flip = data;
810 evas_object_map_enable_set(flip->front, EINA_FALSE);
811 evas_object_map_enable_set(flip->back, EINA_FALSE);
815 _elm_fx_flip_op(void *data, Elm_Animator *animator, double frame)
825 Evas_Coord x, y, w, h;
827 map = evas_map_new(4);
834 degree = (float)(frame * 180);
836 degree = (float)(frame * -180);
838 if (degree < 90 && degree > -90)
841 evas_object_hide(flip->back);
842 evas_object_show(flip->front);
847 evas_object_hide(flip->front);
848 evas_object_show(flip->back);
851 evas_map_smooth_set(map, EINA_TRUE);
852 evas_map_util_points_populate_from_object_full(map, obj, 0);
853 evas_object_geometry_get(obj, &x, &y, &w, &h);
854 Evas_Coord half_w = (w / 2);
856 Evas_Coord half_h = (h / 2);
858 if (flip->axis == ELM_FX_FLIP_AXIS_Y)
860 if ((degree >= 90) || (degree <= -90))
862 evas_map_point_image_uv_set(map, 0, w, 0);
863 evas_map_point_image_uv_set(map, 1, 0, 0);
864 evas_map_point_image_uv_set(map, 2, 0, h);
865 evas_map_point_image_uv_set(map, 3, w, h);
867 evas_map_util_3d_rotate(map, 0, degree, 0, x + half_w, y + half_h, 0);
871 if ((degree >= 90) || (degree <= -90))
873 evas_map_point_image_uv_set(map, 0, 0, h);
874 evas_map_point_image_uv_set(map, 1, w, h);
875 evas_map_point_image_uv_set(map, 2, w, 0);
876 evas_map_point_image_uv_set(map, 3, 0, 0);
878 evas_map_util_3d_rotate(map, degree, 0, 0, x + half_w, y + half_h, 0);
880 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, 10000);
881 evas_object_map_enable_set(flip->front, EINA_TRUE);
882 evas_object_map_enable_set(flip->back, EINA_TRUE);
883 evas_object_map_set(obj, map);
890 * @param front Front surface object
891 * @param back Back surface object
892 * @param axis Flipping Axis(X or Y)
893 * @param cw Flipping Direction. EINA_TRUE is clock-wise
894 * @return Flip effect
899 elm_fx_flip_add(Evas_Object *front, Evas_Object *back, Elm_Fx_Flip_Axis axis,
906 if ((!front) || (!back))
909 effect = calloc(1, sizeof(Elm_Effect));
913 flip = calloc(1, sizeof(Elm_Fx_Flip));
925 effect->end_op = _elm_fx_flip_end;
926 effect->animation_op = _elm_fx_flip_op;
927 effect->user_data = flip;
932 /////////////////////////////////////////////////////////////////////////////////////
934 /////////////////////////////////////////////////////////////////////////////////////
935 typedef struct _resizable_flip Elm_Fx_ResizableFlip;
936 static void _elm_fx_resizable_flip_begin(void *data, Eina_Bool reverse,
937 unsigned int repeat);
938 static void _elm_fx_resizable_flip_end(void *data, Eina_Bool auto_reverse,
939 unsigned int repeat_cnt);
940 static void _elm_fx_resizable_flip_op(void *data, Elm_Animator *animator,
942 static void _set_image_uv_by_axis_y(Evas_Map *map, Elm_Fx_ResizableFlip *flip,
944 static void _set_image_uv_by_axis_x(Evas_Map *map, Elm_Fx_ResizableFlip *flip,
947 struct _resizable_flip
951 Elm_Fx_Flip_Axis axis;
955 } from_pos, from_size, to_pos, to_size;
960 _elm_fx_resizable_flip_begin(void *data, Eina_Bool reverse, unsigned int repeat)
962 Elm_Fx_ResizableFlip *resizable_flip = data;
964 evas_object_show(resizable_flip->front);
965 _elm_fx_resizable_flip_op(data, NULL, 0);
969 _elm_fx_resizable_flip_end(void *data, Eina_Bool auto_reverse,
970 unsigned int repeat_cnt)
972 Elm_Fx_ResizableFlip *resizable_flip = data;
974 evas_object_map_enable_set(resizable_flip->front, EINA_FALSE);
975 evas_object_map_enable_set(resizable_flip->back, EINA_FALSE);
979 _set_image_uv_by_axis_y(Evas_Map *map, Elm_Fx_ResizableFlip *flip,
982 if ((degree >= 90) || (degree <= -90))
984 evas_map_point_image_uv_set(map, 0,
985 (flip->from_size.x * 2) + flip->to_size.x,
987 evas_map_point_image_uv_set(map, 1, 0, 0);
988 evas_map_point_image_uv_set(map, 2, 0,
989 (flip->from_size.y * 2) + flip->to_size.y);
990 evas_map_point_image_uv_set(map, 3,
991 (flip->from_size.x * 2) + flip->to_size.x,
992 (flip->from_size.y * 2) + flip->to_size.y);
996 evas_map_point_image_uv_set(map, 0, 0, 0);
997 evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
998 evas_map_point_image_uv_set(map, 2, flip->from_size.x,
1000 evas_map_point_image_uv_set(map, 3, 0, flip->to_size.y);
1005 _set_image_uv_by_axis_x(Evas_Map *map, Elm_Fx_ResizableFlip *flip,
1008 if ((degree >= 90) || (degree <= -90))
1010 evas_map_point_image_uv_set(map, 0, 0,
1011 (flip->from_size.y * 2) + flip->to_size.y);
1012 evas_map_point_image_uv_set(map, 1,
1013 (flip->from_size.x * 2) + flip->to_size.x,
1014 (flip->from_size.y * 2) + flip->to_size.y);
1015 evas_map_point_image_uv_set(map, 2,
1016 (flip->from_size.x * 2) + flip->to_size.x,
1018 evas_map_point_image_uv_set(map, 3, 0, 0);
1022 evas_map_point_image_uv_set(map, 0, 0, 0);
1023 evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
1024 evas_map_point_image_uv_set(map, 2, flip->from_size.x,
1026 evas_map_point_image_uv_set(map, 3, 0, flip->to_size.y);
1031 _elm_fx_resizable_flip_op(void *data, Elm_Animator *animator, double frame)
1033 Elm_Fx_ResizableFlip *resizable_flip;
1043 Evas_Coord half_w, half_h;
1045 map = evas_map_new(4);
1049 resizable_flip = data;
1051 if (resizable_flip->cw)
1052 degree = (float)(frame * 180);
1054 degree = (float)(frame * -180);
1056 if ((degree < 90) && (degree > -90))
1058 obj = resizable_flip->front;
1059 evas_object_hide(resizable_flip->back);
1060 evas_object_show(resizable_flip->front);
1064 obj = resizable_flip->back;
1065 evas_object_hide(resizable_flip->front);
1066 evas_object_show(resizable_flip->back);
1069 evas_map_smooth_set(map, EINA_TRUE);
1071 x = resizable_flip->from_pos.x + (resizable_flip->to_pos.x * frame);
1072 y = resizable_flip->from_pos.y + (resizable_flip->to_pos.y * frame);
1073 w = resizable_flip->from_size.x + (resizable_flip->to_size.x * frame);
1074 h = resizable_flip->from_size.y + (resizable_flip->to_size.y * frame);
1075 evas_map_point_coord_set(map, 0, x, y, 0);
1076 evas_map_point_coord_set(map, 1, x + w, y, 0);
1077 evas_map_point_coord_set(map, 2, x + w, y + h, 0);
1078 evas_map_point_coord_set(map, 3, x, y + h, 0);
1080 half_w = (Evas_Coord) (w / 2);
1081 half_h = (Evas_Coord) (h / 2);
1083 if (resizable_flip->axis == ELM_FX_FLIP_AXIS_Y)
1085 _set_image_uv_by_axis_y(map, resizable_flip, degree);
1086 evas_map_util_3d_rotate(map, 0, degree, 0, x + half_w, y + half_h, 0);
1090 _set_image_uv_by_axis_x(map, resizable_flip, degree);
1091 evas_map_util_3d_rotate(map, degree, 0, 0, x + half_w, y + half_h, 0);
1094 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, 10000);
1095 evas_object_map_enable_set(resizable_flip->front, EINA_TRUE);
1096 evas_object_map_enable_set(resizable_flip->back, EINA_TRUE);
1097 evas_object_map_set(obj, map);
1102 * Add ResizbleFlip effect. the size of each surface objects are interpolated automatically.
1104 * @param front Front surface object
1105 * @param back Back surface object
1106 * @param axis Flipping Axis.(X or Y)
1107 * @param cw Flipping Direction. EINA_TRUE is clock-wise
1108 * @return Flip effect
1113 elm_fx_resizable_flip_add(Evas_Object *front, Evas_Object *back,
1114 Elm_Fx_Flip_Axis axis, Eina_Bool cw)
1116 Elm_Fx_ResizableFlip *resizable_flip;
1120 Evas_Coord front_x, front_y, front_w, front_h;
1122 Evas_Coord back_x, back_y, back_w, back_h;
1124 if (!front || !back)
1127 effect = calloc(1, sizeof(Elm_Effect));
1131 resizable_flip = calloc(1, sizeof(Elm_Fx_ResizableFlip));
1133 if (!resizable_flip)
1139 resizable_flip->front = front;
1140 resizable_flip->back = back;
1141 resizable_flip->cw = cw;
1142 resizable_flip->axis = axis;
1144 evas_object_geometry_get(resizable_flip->front, &front_x, &front_y, &front_w,
1146 evas_object_geometry_get(resizable_flip->back, &back_x, &back_y, &back_w,
1149 resizable_flip->from_pos.x = front_x;
1150 resizable_flip->from_pos.y = front_y;
1151 resizable_flip->to_pos.x = back_x - front_x;
1152 resizable_flip->to_pos.y = back_y - front_y;
1154 resizable_flip->from_size.x = front_w;
1155 resizable_flip->from_size.y = front_h;
1156 resizable_flip->to_size.x = back_w - front_w;
1157 resizable_flip->to_size.y = back_h - front_h;
1159 effect->begin_op = _elm_fx_resizable_flip_begin;
1160 effect->end_op = _elm_fx_resizable_flip_end;
1161 effect->animation_op = _elm_fx_resizable_flip_op;
1162 effect->user_data = resizable_flip;
1167 /////////////////////////////////////////////////////////////////////////////////////
1169 /////////////////////////////////////////////////////////////////////////////////////
1170 typedef struct _wipe Elm_Fx_Wipe;
1171 static void _elm_fx_wipe_op(void *data, Elm_Animator *animator,
1173 static void _elm_fx_wipe_begin(void *data, Eina_Bool auto_repeat,
1174 unsigned int repeat_cnt);
1175 static void _elm_fx_wipe_end(void *data, Eina_Bool auto_repeat,
1176 unsigned int repeat_cnt);
1177 static void _elm_fx_wipe_hide(Evas_Map * map, Elm_Fx_Wipe_Dir dir,
1178 float x, float y, float w, float h, float frame);
1179 static void _elm_fx_wipe_show(Evas_Map *map, Elm_Fx_Wipe_Dir dir,
1180 float x, float y, float w, float h, float frame);
1185 Elm_Fx_Wipe_Type type;
1186 Elm_Fx_Wipe_Dir dir;
1190 _elm_fx_wipe_begin(void *data, Eina_Bool auto_repeat, unsigned int repeat_cnt)
1192 Elm_Fx_Wipe *wipe = data;
1194 evas_object_show(wipe->obj);
1195 _elm_fx_wipe_op(data, NULL, 0);
1199 _elm_fx_wipe_end(void *data, Eina_Bool auto_repeat, unsigned int repeat_cnt)
1201 Elm_Fx_Wipe *wipe = data;
1203 evas_object_map_enable_set(wipe->obj, EINA_FALSE);
1207 _elm_fx_wipe_hide(Evas_Map * map, Elm_Fx_Wipe_Dir dir, float x, float y,
1208 float w, float h, float frame)
1214 case ELM_FX_WIPE_DIR_LEFT:
1215 w2 = w - (w * frame);
1217 evas_map_point_image_uv_set(map, 0, 0, 0);
1218 evas_map_point_image_uv_set(map, 1, w2, 0);
1219 evas_map_point_image_uv_set(map, 2, w2, h);
1220 evas_map_point_image_uv_set(map, 3, 0, h);
1221 evas_map_point_coord_set(map, 0, x, y, 0);
1222 evas_map_point_coord_set(map, 1, x + w2, y, 0);
1223 evas_map_point_coord_set(map, 2, x + w2, h2, 0);
1224 evas_map_point_coord_set(map, 3, x, h2, 0);
1226 case ELM_FX_WIPE_DIR_RIGHT:
1229 evas_map_point_image_uv_set(map, 0, w2, 0);
1230 evas_map_point_image_uv_set(map, 1, w, 0);
1231 evas_map_point_image_uv_set(map, 2, w, h);
1232 evas_map_point_image_uv_set(map, 3, w2, h);
1233 evas_map_point_coord_set(map, 0, x + w2, y, 0);
1234 evas_map_point_coord_set(map, 1, x + w, y, 0);
1235 evas_map_point_coord_set(map, 2, x + w, h2, 0);
1236 evas_map_point_coord_set(map, 3, x + w2, h2, 0);
1238 case ELM_FX_WIPE_DIR_UP:
1240 h2 = h - (h * frame);
1241 evas_map_point_image_uv_set(map, 0, 0, 0);
1242 evas_map_point_image_uv_set(map, 1, w, 0);
1243 evas_map_point_image_uv_set(map, 2, w, h2);
1244 evas_map_point_image_uv_set(map, 3, 0, h2);
1245 evas_map_point_coord_set(map, 0, x, y, 0);
1246 evas_map_point_coord_set(map, 1, w2, y, 0);
1247 evas_map_point_coord_set(map, 2, w2, h2, 0);
1248 evas_map_point_coord_set(map, 3, x, h2, 0);
1250 case ELM_FX_WIPE_DIR_DOWN:
1253 evas_map_point_image_uv_set(map, 0, 0, h2);
1254 evas_map_point_image_uv_set(map, 1, w, h2);
1255 evas_map_point_image_uv_set(map, 2, w, h);
1256 evas_map_point_image_uv_set(map, 3, 0, h);
1257 evas_map_point_coord_set(map, 0, x, y + h2, 0);
1258 evas_map_point_coord_set(map, 1, w2, y + h2, 0);
1259 evas_map_point_coord_set(map, 2, w2, y + h, 0);
1260 evas_map_point_coord_set(map, 3, x, y + h, 0);
1266 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, 10000);
1270 _elm_fx_wipe_show(Evas_Map *map, Elm_Fx_Wipe_Dir dir, float x, float y,
1271 float w, float h, float frame)
1277 case ELM_FX_WIPE_DIR_LEFT:
1278 w2 = (w - (w * frame));
1280 evas_map_point_image_uv_set(map, 0, w2, 0);
1281 evas_map_point_image_uv_set(map, 1, w, 0);
1282 evas_map_point_image_uv_set(map, 2, w, h);
1283 evas_map_point_image_uv_set(map, 3, w2, h);
1284 evas_map_point_coord_set(map, 0, x + w2, y, 0);
1285 evas_map_point_coord_set(map, 1, w, y, 0);
1286 evas_map_point_coord_set(map, 2, w, h2, 0);
1287 evas_map_point_coord_set(map, 3, x + w2, h2, 0);
1289 case ELM_FX_WIPE_DIR_RIGHT:
1292 evas_map_point_image_uv_set(map, 0, 0, 0);
1293 evas_map_point_image_uv_set(map, 1, w2, 0);
1294 evas_map_point_image_uv_set(map, 2, w2, h);
1295 evas_map_point_image_uv_set(map, 3, 0, h);
1296 evas_map_point_coord_set(map, 0, x, y, 0);
1297 evas_map_point_coord_set(map, 1, x + w2, y, 0);
1298 evas_map_point_coord_set(map, 2, x + w2, h2, 0);
1299 evas_map_point_coord_set(map, 3, x, h2, 0);
1301 case ELM_FX_WIPE_DIR_UP:
1303 h2 = (h - (h * frame));
1304 evas_map_point_image_uv_set(map, 0, 0, h2);
1305 evas_map_point_image_uv_set(map, 1, w, h2);
1306 evas_map_point_image_uv_set(map, 2, w, h);
1307 evas_map_point_image_uv_set(map, 3, 0, h);
1308 evas_map_point_coord_set(map, 0, x, y + h2, 0);
1309 evas_map_point_coord_set(map, 1, w2, y + h2, 0);
1310 evas_map_point_coord_set(map, 2, w2, y + h, 0);
1311 evas_map_point_coord_set(map, 3, x, y + h, 0);
1313 case ELM_FX_WIPE_DIR_DOWN:
1316 evas_map_point_image_uv_set(map, 0, 0, 0);
1317 evas_map_point_image_uv_set(map, 1, w, 0);
1318 evas_map_point_image_uv_set(map, 2, w, h2);
1319 evas_map_point_image_uv_set(map, 3, 0, h2);
1320 evas_map_point_coord_set(map, 0, x, y, 0);
1321 evas_map_point_coord_set(map, 1, w2, y, 0);
1322 evas_map_point_coord_set(map, 2, w2, y + h2, 0);
1323 evas_map_point_coord_set(map, 3, x, y + h2, 0);
1329 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, 10000);
1333 _elm_fx_wipe_op(void *data, Elm_Animator *animator, double frame)
1339 Evas_Coord _x, _y, _w, _h;
1341 map = evas_map_new(4);
1346 evas_map_smooth_set(map, EINA_TRUE);
1347 evas_object_geometry_get(wipe->obj, &_x, &_y, &_w, &_h);
1349 if (wipe->type == ELM_FX_WIPE_TYPE_SHOW)
1350 _elm_fx_wipe_show(map, wipe->dir, _x, _y, _w, _h, (float)frame);
1352 _elm_fx_wipe_hide(map, wipe->dir, _x, _y, _w, _h, (float)frame);
1354 evas_object_map_enable_set(wipe->obj, EINA_TRUE);
1355 evas_object_map_set(wipe->obj, map);
1362 * @param obj Evas_Object that effect is applying to
1363 * @param type Wipe type. Hide or show
1364 * @param dir Wipe Direction
1365 * @return Wipe effect
1370 elm_fx_wipe_add(Evas_Object *obj, Elm_Fx_Wipe_Type type, Elm_Fx_Wipe_Dir dir)
1379 effect = calloc(1, sizeof(Elm_Effect));
1383 wipe = calloc(1, sizeof(Elm_Fx_Wipe));
1393 effect->begin_op = _elm_fx_wipe_begin;
1394 effect->end_op = _elm_fx_wipe_end;
1395 effect->animation_op = _elm_fx_wipe_op;
1396 effect->user_data = wipe;
1401 /////////////////////////////////////////////////////////////////////////////////////
1403 /////////////////////////////////////////////////////////////////////////////////////
1404 typedef struct _color Elm_Fx_Color;
1405 static void _elm_fx_color_begin(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt);
1406 static void _elm_fx_color_op(void *data, Elm_Animator *animator, double frame);
1411 struct _unsigned_color
1413 unsigned int r, g, b, a;
1415 struct _signed_color
1422 _elm_fx_color_begin(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
1424 Elm_Fx_Color *color = data;
1426 evas_object_show(color->obj);
1430 _elm_fx_color_op(void *data, Elm_Animator *animator, double frame)
1432 Elm_Fx_Color *color;
1434 unsigned int r, g, b, a;
1437 r = (color->from.r + (int)((float)color->to.r * frame));
1438 g = (color->from.g + (int)((float)color->to.g * frame));
1439 b = (color->from.b + (int)((float)color->to.b * frame));
1440 a = (color->from.a + (int)((float)color->to.a * frame));
1442 evas_object_color_set(color->obj, r, g, b, a);
1448 * @param obj Evas_Object that effect is applying to
1449 * @param from_r RGB R when effect begins
1450 * @param from_g RGB G when effect begins
1451 * @param from_b RGB B when effect begins
1452 * @param from_a RGB A when effect begins
1453 * @param to_r RGB R when effect ends
1454 * @param to_g RGB G when effect ends
1455 * @param to_b RGB B when effect ends
1456 * @param to_a RGB A when effect ends
1457 * @return Color Effect
1462 elm_fx_color_add(Evas_Object *obj, unsigned int from_r, unsigned int from_g,
1463 unsigned int from_b, unsigned int from_a, unsigned int to_r,
1464 unsigned int to_g, unsigned int to_b, unsigned int to_a)
1468 Elm_Fx_Color *color;
1473 effect = calloc(1, sizeof(Elm_Effect));
1477 color = calloc(1, sizeof(Elm_Fx_Color));
1485 color->from.r = from_r;
1486 color->from.g = from_g;
1487 color->from.b = from_b;
1488 color->from.a = from_a;
1489 color->to.r = to_r - from_r;
1490 color->to.g = to_g - from_g;
1491 color->to.b = to_b - from_b;
1492 color->to.a = to_a - from_a;
1494 effect->begin_op = _elm_fx_color_begin;
1495 effect->animation_op = _elm_fx_color_op;
1496 effect->user_data = color;
1501 /////////////////////////////////////////////////////////////////////////////////////
1503 /////////////////////////////////////////////////////////////////////////////////////
1504 typedef struct _fade Elm_Fx_Fade;
1505 static void _elm_fx_fade_begin(void *data, Eina_Bool auto_reverse,
1506 unsigned int repeat_cnt);
1507 static void _elm_fx_fade_end(void *data, Eina_Bool auto_reverse,
1508 unsigned int repeat_cnt);
1509 static void _elm_fx_fade_op(void *data, Elm_Animator *animator,
1514 Evas_Object *before;
1516 struct _signed_color before_color, after_color;
1519 Eina_Bool inversed:1;
1523 _elm_fx_fade_begin(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
1525 Elm_Fx_Fade *fade = data;
1527 fade->inversed = EINA_FALSE;
1531 _elm_fx_fade_end(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
1533 Elm_Fx_Fade *fade = data;
1535 evas_object_color_set(fade->before, fade->before_color.r,
1536 fade->before_color.g, fade->before_color.b,
1537 fade->before_color.a);
1538 evas_object_color_set(fade->after, fade->after_color.r, fade->after_color.g,
1539 fade->after_color.b, fade->after_color.a);
1543 _elm_fx_fade_op(void *data, Elm_Animator *animator, double frame)
1553 if (!fade->inversed)
1555 evas_object_hide(fade->after);
1556 evas_object_show(fade->before);
1557 fade->inversed = EINA_TRUE;
1560 _frame = (1 - (frame * 2));
1562 evas_object_color_set(fade->before, fade->before_color.r * _frame,
1563 fade->before_color.g * _frame,
1564 fade->before_color.b * _frame,
1565 fade->before_color.a + fade->before_alpha * (1 -
1572 evas_object_hide(fade->before);
1573 evas_object_show(fade->after);
1574 fade->inversed = EINA_FALSE;
1577 _frame = ((frame - 0.5) * 2);
1579 evas_object_color_set(fade->after, fade->after_color.r * _frame,
1580 fade->after_color.g * _frame,
1581 fade->after_color.b * _frame,
1582 fade->after_color.a + fade->after_alpha * (1 -
1591 * @param before Evas Object before fade in
1592 * @param after Evas Object after fade out
1593 * @return Fade effect
1598 elm_fx_fade_add(Evas_Object *before, Evas_Object *after)
1604 if ((!before) && (!after))
1607 effect = calloc(1, sizeof(Elm_Effect));
1611 fade = calloc(1, sizeof(Elm_Fx_Fade));
1619 evas_object_color_get(before, &fade->before_color.r, &fade->before_color.g,
1620 &fade->before_color.b, &fade->before_color.a);
1621 evas_object_color_get(after, &fade->after_color.r, &fade->after_color.g,
1622 &fade->after_color.b, &fade->after_color.a);
1624 fade->before = before;
1625 fade->after = after;
1626 fade->before_alpha = (255 - fade->before_color.a);
1627 fade->after_alpha = (255 - fade->after_color.a);
1629 effect->begin_op = _elm_fx_fade_begin;
1630 effect->end_op = _elm_fx_fade_end;
1631 effect->animation_op = _elm_fx_fade_op;
1632 effect->user_data = fade;
1637 /////////////////////////////////////////////////////////////////////////////////////
1639 /////////////////////////////////////////////////////////////////////////////////////
1640 typedef struct _blend Elm_Fx_Blend;
1641 static void _elm_fx_blend_begin(void *data, Eina_Bool auto_reverse,
1642 unsigned int repeat_cnt);
1643 static void _elm_fx_blend_end(void *data, Eina_Bool auto_reverse,
1644 unsigned int repeat_cnt);
1645 static void _elm_fx_blend_op(void *data, Elm_Animator *animator,
1650 Evas_Object *before;
1652 struct _signed_color from, to;
1656 _elm_fx_blend_begin(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
1658 Elm_Fx_Blend *blend = data;
1660 evas_object_show(blend->before);
1664 _elm_fx_blend_end(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
1666 Elm_Fx_Blend *blend = data;
1668 evas_object_color_set(blend->before, blend->from.r, blend->from.g,
1669 blend->from.b, blend->from.a);
1670 evas_object_color_set(blend->after, blend->to.r, blend->to.g, blend->to.b,
1673 evas_object_hide(blend->before);
1675 evas_object_hide(blend->after);
1679 _elm_fx_blend_op(void *data, Elm_Animator *animator, double frame)
1681 Elm_Fx_Blend *blend = data;
1683 evas_object_show(blend->after);
1684 evas_object_color_set(blend->before, (int)(blend->from.r * (1 - frame)),
1685 (int)(blend->from.g * (1 - frame)),
1686 (int)(blend->from.b * (1 - frame)),
1687 (int)(blend->from.a * (1 - frame)));
1688 evas_object_color_set(blend->after, (int)(blend->to.r * frame),
1689 (int)(blend->to.g * frame), (int)(blend->to.b * frame),
1690 (int)(blend->to.a * frame));
1696 * @param before Evas Object before blending
1697 * @param after Evas Object after blending
1698 * @return Blend effect
1703 elm_fx_blend_add(Evas_Object *before, Evas_Object *after)
1707 Elm_Fx_Blend *blend;
1709 if ((!before) && (!after))
1712 effect = calloc(1, sizeof(Elm_Effect));
1716 blend = calloc(1, sizeof(Elm_Fx_Blend));
1723 blend->before = before;
1724 blend->after = after;
1725 evas_object_color_get(before, &blend->from.r, &blend->from.g, &blend->from.b,
1727 evas_object_color_get(after, &blend->to.r, &blend->to.g, &blend->to.b,
1730 effect->begin_op = _elm_fx_blend_begin;
1731 effect->end_op = _elm_fx_blend_end;
1732 effect->animation_op = _elm_fx_blend_op;
1733 effect->user_data = blend;
1738 /////////////////////////////////////////////////////////////////////////////////////
1740 /////////////////////////////////////////////////////////////////////////////////////
1741 typedef struct _rotation Elm_Fx_Rotation;
1742 static void _elm_fx_rotation_begin(void *data, Eina_Bool auto_reverse,
1743 unsigned int repeat_cnt);
1744 static void _elm_fx_rotation_end(void *data, Eina_Bool auto_reverse,
1745 unsigned int repeat_cnt);
1746 static void _elm_fx_rotation_op(void *data, Elm_Animator *animator,
1757 _elm_fx_rotation_begin(void *data, Eina_Bool auto_reverse,
1758 unsigned int repeat_cnt)
1760 Elm_Fx_Rotation *rotation = data;
1762 evas_object_show(rotation->obj);
1766 _elm_fx_rotation_end(void *data, Eina_Bool auto_reverse,
1767 unsigned int repeat_cnt)
1769 Elm_Fx_Rotation *rotation = data;
1771 evas_object_map_enable_set(rotation->obj, EINA_FALSE);
1775 _elm_fx_rotation_op(void *data, Elm_Animator *animator, double frame)
1777 Elm_Fx_Rotation *rotation;
1781 Evas_Coord x, y, w, h;
1785 float half_w, half_h;
1787 map = evas_map_new(4);
1793 evas_map_smooth_set(map, EINA_TRUE);
1794 evas_map_util_points_populate_from_object_full(map, rotation->obj, 0);
1795 degree = rotation->from + (float)(frame * rotation->to);
1800 evas_object_geometry_get(rotation->obj, &x, &y, &w, &h);
1802 half_w = (float)w *0.5;
1804 half_h = (float)h *0.5;
1806 evas_map_util_3d_rotate(map, 0, 0, degree, x + half_w, y + half_h, 0);
1807 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, 10000);
1808 evas_object_map_enable_set(rotation->obj, EINA_TRUE);
1809 evas_object_map_set(rotation->obj, map);
1814 * Add Rotation effect
1816 * @param obj Evas_Object that effect is applying to
1817 * @param from degree Degree when effect begins
1818 * @param to_degree Degree when effect is ends
1819 * @param cw Rotation direction. EINA_TRUE is clock wise
1820 * @return Rotation effect
1825 elm_fx_rotation_add(Evas_Object *obj, float from_degree, float to_degree,
1830 Elm_Fx_Rotation *rotation;
1835 effect = calloc(1, sizeof(Elm_Effect));
1839 rotation = calloc(1, sizeof(Elm_Fx_Rotation));
1847 rotation->obj = obj;
1848 rotation->from = from_degree;
1849 rotation->to = to_degree - from_degree;
1852 effect->begin_op = _elm_fx_rotation_begin;
1853 effect->end_op = _elm_fx_rotation_end;
1854 effect->animation_op = _elm_fx_rotation_op;
1855 effect->user_data = rotation;
1860 /////////////////////////////////////////////////////////////////////////////////////
1861 // ImageAnimation FX
1862 /////////////////////////////////////////////////////////////////////////////////////
1863 typedef struct _image_animation Elm_Fx_Image_Animation;
1864 static void _elm_fx_imageanimation_op(void *data, Elm_Animator *animator,
1866 EAPI Elm_Effect *elm_fx_imageanimation_add(Evas_Object *obj, const char **images,
1867 unsigned int item_num);
1869 struct _image_animation
1878 _elm_fx_imageanimation_op(void *data, Elm_Animator *animator, double frame)
1880 Elm_Fx_Image_Animation *image_animation = (Elm_Fx_Image_Animation *) data;
1882 if (!image_animation->obj)
1884 image_animation->count = floor(frame * image_animation->img_cnt);
1885 elm_icon_file_set(image_animation->obj,
1886 image_animation->images[image_animation->count], NULL);
1890 * Add ImageAnimation effect.
1892 * @param obj Icon object
1893 * @param images Array of image file path.
1894 * @param img_cnt Count of image.
1895 * @return ImageAnimation effect.
1900 elm_fx_imageanimation_add(Evas_Object *obj, const char **images,
1901 unsigned int img_cnt)
1904 Elm_Fx_Image_Animation *image_animation;
1906 if (!images || !(*images))
1909 effect = calloc(1, sizeof(Elm_Effect));
1913 image_animation = calloc(1, sizeof(Elm_Fx_Image_Animation));
1915 if (!image_animation)
1921 image_animation->obj = obj;
1922 image_animation->images = (char **) images;
1923 image_animation->count = 0;
1924 image_animation->img_cnt = img_cnt;
1926 effect->animation_op = _elm_fx_imageanimation_op;
1927 effect->user_data = image_animation;