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);
42 _create_block_rect(Evas_Object *parent)
48 rect = evas_object_rectangle_add(evas_object_evas_get(parent));
49 evas_output_size_get(evas_object_evas_get(parent), &w, &h);
50 evas_object_resize(rect, w, h);
51 evas_object_color_set(rect, 0, 0, 0, 0);
56 _transit_animate_cb(void *data, Elm_Animator *animator, double frame)
62 Elm_Transit *transit = data;
64 EINA_LIST_FOREACH(transit->effect_list, elist, effect)
66 effect->animation_op(effect->user_data, animator, frame);
71 _transit_fx_begin(Elm_Transit *transit)
77 Eina_Bool auto_reverse;
79 unsigned int repeat_cnt;
81 auto_reverse = elm_animator_auto_reverse_get(transit->animator);
82 repeat_cnt = elm_animator_repeat_get(transit->animator);
84 EINA_LIST_FOREACH(transit->effect_list, elist, effect)
87 effect->begin_op(effect->user_data, auto_reverse, repeat_cnt);
92 _transit_fx_end(Elm_Transit *transit)
98 Eina_Bool auto_reverse;
100 unsigned int repeat_cnt;
102 auto_reverse = elm_animator_auto_reverse_get(transit->animator);
103 repeat_cnt = elm_animator_repeat_get(transit->animator);
105 EINA_LIST_FOREACH(transit->effect_list, elist, effect)
108 effect->end_op(effect->user_data, auto_reverse, repeat_cnt);
113 _transit_complete_cb(void *data)
115 Elm_Transit *transit = (Elm_Transit *) data;
117 evas_render(evas_object_evas_get(transit->parent));
119 _transit_fx_end(transit);
121 if (transit->block_rect)
122 evas_object_hide(transit->block_rect);
124 if (transit->completion_op)
125 transit->completion_op(transit->completion_arg, transit);
127 if (transit->reserved_del)
129 transit->reserved_del = EINA_FALSE;
130 elm_transit_del(transit);
135 _transit_fx_del(Elm_Effect *effect)
140 --effect->shared_cnt;
142 if (effect->shared_cnt > 0)
144 if (effect->user_data)
145 free(effect->user_data);
150 * Set the event blocked when transit is operating.
152 * @param transit Transit object
153 * @param disabled Disable or enable
158 elm_transit_event_block_disabled_set(Elm_Transit *transit, Eina_Bool disabled)
165 if (transit->block_rect)
167 evas_object_del(transit->block_rect);
168 transit->block_rect = NULL;
173 if (transit->block_rect == NULL)
174 transit->block_rect = _create_block_rect(transit->parent);
179 * Get the value of event blockd status.
181 * @param transit Transit
182 * @return EINA_TRUE, when event block is disabled
187 elm_transit_event_block_disabled_get(Elm_Transit *transit)
191 return transit->block_rect ? EINA_TRUE : EINA_FALSE;
195 * Remove effect from transit.
197 * @param transit Transit
198 * @param effect Effect to be removed
199 * @return EINA_TRUE, if the effect is removed
200 * @warning If removed effect does not inserted in any transit, it will be deleted.
205 elm_transit_fx_remove(Elm_Transit *transit, Elm_Effect *effect)
214 EINA_LIST_FOREACH(transit->effect_list, elist, _effect)
216 if (_effect == effect)
218 transit->effect_list =
219 eina_list_remove(transit->effect_list, _effect);
220 _transit_fx_del(_effect);
228 * Remove all current inserted effects.
230 * @param transit Transit
235 elm_transit_fx_clear(Elm_Transit *transit)
244 EINA_LIST_FOREACH(transit->effect_list, elist, effect)
246 transit->effect_list = eina_list_remove(transit->effect_list, effect);
247 _transit_fx_del(effect);
252 * Get the list of current inseted effects.
254 * @param transit Transit
255 * @return Effect list
259 EAPI const Eina_List *
260 elm_transit_fx_get(Elm_Transit *transit)
264 return transit->effect_list;
268 * Set the user-callback function when the transit operation is done.
270 * @param transit Transit
271 * @param op Callback function pointer
272 * @param data Callback funtion user data
277 elm_transit_completion_callback_set(Elm_Transit *transit,
278 void (*op) (void *data,
279 Elm_Transit *transit),
284 transit->completion_op = op;
285 transit->completion_arg = data;
291 * @param transit Transit to be deleted
296 elm_transit_del(Elm_Transit *transit)
300 if (elm_animator_operating_get(transit->animator))
302 transit->reserved_del = EINA_TRUE;
306 if (transit->block_rect)
307 evas_object_del(transit->block_rect);
309 elm_animator_del(transit->animator);
310 elm_transit_fx_clear(transit);
316 * Set the transit animation acceleration style.
318 * @param transit Transit
319 * @param cs Curve style(Please refer elm_animator_curve_style_set)
324 elm_transit_curve_style_set(Elm_Transit *transit, Elm_Animator_Curve_Style cs)
328 elm_animator_curve_style_set(transit->animator, cs);
334 * @param parent Parent object
340 elm_transit_add(Evas_Object *parent)
342 Elm_Transit *transit = calloc(1, sizeof(Elm_Transit));
347 transit->animator = elm_animator_add(parent);
349 if (!transit->animator)
355 transit->parent = parent;
356 elm_animator_operation_callback_set(transit->animator, _transit_animate_cb,
358 elm_animator_completion_callback_set(transit->animator, _transit_complete_cb,
360 elm_transit_event_block_disabled_set(transit, EINA_FALSE);
366 * Set reverse effect automatically.
368 * @param transit Transit
369 * @param reverse EINA_TRUE is reverse.
374 elm_transit_auto_reverse_set(Elm_Transit *transit, Eina_Bool reverse)
378 elm_animator_auto_reverse_set(transit->animator, reverse);
382 * Insert an effect into the transit.
384 * @param transit Transit
385 * @param effect Effect to be inserted
386 * @return EINA_TRUE is success
391 elm_transit_fx_insert(Elm_Transit *transit, Elm_Effect *effect)
400 EINA_LIST_FOREACH(transit->effect_list, elist, _effect)
402 if (_effect == effect)
406 ++effect->shared_cnt;
407 transit->effect_list = eina_list_append(transit->effect_list, effect);
413 * Set the transit repeat count. Effect will be repeated by repeat count.
415 * @param transit Transit
416 * @param repeat Repeat count
421 elm_transit_repeat_set(Elm_Transit *transit, unsigned int repeat)
425 elm_animator_repeat_set(transit->animator, repeat);
429 * Stop the current transit, if the transit is operating.
431 * @param transit Transit
436 elm_transit_stop(Elm_Transit *transit)
440 elm_animator_stop(transit->animator);
444 * Run the all the inserted effects.
446 * @param transit Transit
447 * @param duration Transit time in seconds
452 elm_transit_run(Elm_Transit *transit, double duration)
456 _transit_fx_begin(transit);
457 elm_animator_duration_set(transit->animator, duration);
460 if (transit->block_rect)
461 evas_object_show(transit->block_rect);
463 elm_animator_animate(transit->animator);
465 //If failed to animate.
466 if (!elm_animator_operating_get(transit->animator))
468 if (transit->block_rect)
469 evas_object_hide(transit->block_rect);
470 _transit_fx_end(transit);
474 /////////////////////////////////////////////////////////////////////////////////////
476 /////////////////////////////////////////////////////////////////////////////////////
477 typedef struct _resizing Elm_Fx_Resizing;
478 static void _elm_fx_resizing_op(void *data, Elm_Animator *animator,
480 static void _elm_fx_resizing_begin(void *data, Eina_Bool auto_reverse,
481 unsigned int repeat_cnt);
482 static void _elm_fx_resizing_end(void *data, Eina_Bool auto_reverse,
483 unsigned int repeat_cnt);
495 _elm_fx_resizing_begin(void *data, Eina_Bool auto_reverse,
496 unsigned int repeat_cnt)
498 Elm_Fx_Resizing *resizing = data;
500 evas_object_show(resizing->obj);
501 evas_object_resize(resizing->obj, resizing->from.w, resizing->from.h);
505 _elm_fx_resizing_end(void *data, Eina_Bool auto_reverse,
506 unsigned int repeat_cnt)
508 Elm_Fx_Resizing *resizing = data;
510 evas_object_move(resizing->obj, resizing->from.w + resizing->to.w,
511 resizing->from.h + resizing->to.h);
515 _elm_fx_resizing_op(void *data, Elm_Animator *animator, double frame)
519 Elm_Fx_Resizing *resizing = data;
521 w = resizing->from.w + (Evas_Coord) ((float)resizing->to.h * (float)frame);
522 h = resizing->from.h + (Evas_Coord) ((float)resizing->to.w * (float)frame);
523 evas_object_resize(resizing->obj, w, h);
527 * Add Resizing effect.
529 * @param obj Evas_Object that effect is applying to
530 * @param from_w Object width size when effect begins
531 * @param from_h Object height size when effect begins
532 * @param to_w Object width size when effect ends
533 * @param to_h Object height size when effect ends
534 * @return Resizing effect
539 elm_fx_resizing_add(Evas_Object *obj, Evas_Coord from_w, Evas_Coord from_h,
540 Evas_Coord to_w, Evas_Coord to_h)
544 Elm_Fx_Resizing *resizing;
549 effect = calloc(1, sizeof(Elm_Effect));
553 resizing = calloc(1, sizeof(Elm_Fx_Resizing));
561 resizing->from.w = from_w;
562 resizing->from.h = from_h;
563 resizing->to.w = to_w - from_w;
564 resizing->to.h = to_h - from_h;
566 effect->begin_op = _elm_fx_resizing_begin;
567 effect->animation_op = _elm_fx_resizing_op;
568 effect->user_data = resizing;
573 /////////////////////////////////////////////////////////////////////////////////////
575 /////////////////////////////////////////////////////////////////////////////////////
576 typedef struct _translation Elm_Fx_Translation;
577 static void _elm_fx_translation_op(void *data, Elm_Animator *animator,
579 static void _elm_fx_translation_begin(void *data, Eina_Bool auto_reverse,
580 unsigned int repeat_cnt);
581 static void _elm_fx_translation_end(void *data, Eina_Bool auto_reverse,
582 unsigned int repeat_cnt);
594 _elm_fx_translation_begin(void *data, Eina_Bool auto_reverse,
595 unsigned int repeat_cnt)
597 Elm_Fx_Translation *translation = data;
599 evas_object_show(translation->obj);
600 evas_object_move(translation->obj, translation->from.x, translation->from.y);
604 _elm_fx_translation_end(void *data, Eina_Bool auto_reverse,
605 unsigned int repeat_cnt)
607 Elm_Fx_Translation *translation = data;
609 evas_object_move(translation->obj, translation->from.x + translation->to.x,
610 translation->from.y + translation->to.y);
614 _elm_fx_translation_op(void *data, Elm_Animator *animator, double frame)
618 Elm_Fx_Translation *translation = data;
620 x = translation->from.x +
621 (Evas_Coord) ((float)translation->to.x * (float)frame);
622 y = translation->from.y +
623 (Evas_Coord) ((float)translation->to.y * (float)frame);
624 evas_object_move(translation->obj, x, y);
628 * Add Translation effect.
630 * @param obj Evas_Object that effect is applying to
631 * @param from_x Position X when effect begins
632 * @param from_y Position Y when effect begins
633 * @param to_x Position X when effect ends
634 * @param to_y Position Y when effect ends
635 * @return Translation effect
640 elm_fx_translation_add(Evas_Object *obj, Evas_Coord from_x, Evas_Coord from_y,
641 Evas_Coord to_x, Evas_Coord to_y)
645 Elm_Fx_Translation *translation;
650 effect = calloc(1, sizeof(Elm_Effect));
654 translation = calloc(1, sizeof(Elm_Fx_Translation));
662 translation->obj = obj;
663 translation->from.x = from_x;
664 translation->from.y = from_y;
665 translation->to.x = to_x - from_x;
666 translation->to.y = to_y - from_y;
668 effect->begin_op = _elm_fx_translation_begin;
669 effect->end_op = _elm_fx_translation_end;
670 effect->animation_op = _elm_fx_translation_op;
671 effect->user_data = translation;
676 /////////////////////////////////////////////////////////////////////////////////////
678 /////////////////////////////////////////////////////////////////////////////////////
679 typedef struct _zoom Elm_Fx_Zoom;
680 static void _elm_fx_zoom_op(void *data, Elm_Animator * animator,
682 static void _elm_fx_zoom_begin(void *data, Eina_Bool reverse,
683 unsigned int repeat);
684 static void _elm_fx_zoom_end(void *data, Eina_Bool reverse,
685 unsigned int repeat);
694 _elm_fx_zoom_begin(void *data, Eina_Bool reverse, unsigned int repeat)
696 Elm_Fx_Zoom *zoom = data;
698 evas_object_show(zoom->obj);
699 _elm_fx_zoom_op(data, NULL, 0);
703 _elm_fx_zoom_end(void *data, Eina_Bool reverse, unsigned int repeat)
705 Elm_Fx_Zoom *zoom = data;
707 evas_object_map_enable_set(zoom->obj, EINA_FALSE);
711 _elm_fx_zoom_op(void *data, Elm_Animator *animator, double frame)
717 Evas_Coord x, y, w, h;
719 map = evas_map_new(4);
724 evas_object_geometry_get(zoom->obj, &x, &y, &w, &h);
725 evas_map_smooth_set(map, EINA_TRUE);
726 evas_map_util_points_populate_from_object_full(map, zoom->obj,
729 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, 10000);
730 evas_object_map_set(zoom->obj, map);
731 evas_object_map_enable_set(zoom->obj, EINA_TRUE);
738 * @param obj Evas_Object that effect is applying to
739 * @param from_rate Scale rate when effect begins (1 is current rate)
740 * @param to_rate Scale rate when effect ends
741 * @return Zoom effect
746 elm_fx_zoom_add(Evas_Object *obj, float from_rate, float to_rate)
755 effect = calloc(1, sizeof(Elm_Effect));
759 zoom = calloc(1, sizeof(Elm_Fx_Zoom));
767 zoom->from = (10000 - (from_rate * 10000)) * (1 / from_rate);
768 zoom->to = ((10000 - (to_rate * 10000)) * (1 / to_rate)) - zoom->from;
769 effect->begin_op = _elm_fx_zoom_begin;
770 effect->end_op = _elm_fx_zoom_end;
771 effect->animation_op = _elm_fx_zoom_op;
772 effect->user_data = zoom;
778 /////////////////////////////////////////////////////////////////////////////////////
780 /////////////////////////////////////////////////////////////////////////////////////
781 typedef struct _flip Elm_Fx_Flip;
782 static void _elm_fx_flip_op(void *data, Elm_Animator *animator,
784 static void _elm_fx_flip_end(void *data, Eina_Bool auto_reverse,
785 unsigned int repeat_cnt);
791 Elm_Fx_Flip_Axis axis;
796 _elm_fx_flip_end(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
798 Elm_Fx_Flip *flip = data;
800 evas_object_map_enable_set(flip->front, EINA_FALSE);
801 evas_object_map_enable_set(flip->back, EINA_FALSE);
805 _elm_fx_flip_op(void *data, Elm_Animator *animator, double frame)
815 Evas_Coord x, y, w, h;
817 map = evas_map_new(4);
824 degree = (float)(frame * 180);
826 degree = (float)(frame * -180);
828 if (degree < 90 && degree > -90)
831 evas_object_hide(flip->back);
832 evas_object_show(flip->front);
837 evas_object_hide(flip->front);
838 evas_object_show(flip->back);
841 evas_map_smooth_set(map, EINA_TRUE);
842 evas_map_util_points_populate_from_object_full(map, obj, 0);
843 evas_object_geometry_get(obj, &x, &y, &w, &h);
844 Evas_Coord half_w = (w / 2);
846 Evas_Coord half_h = (h / 2);
848 if (flip->axis == ELM_FX_FLIP_AXIS_Y)
850 if ((degree >= 90) || (degree <= -90))
852 evas_map_point_image_uv_set(map, 0, w, 0);
853 evas_map_point_image_uv_set(map, 1, 0, 0);
854 evas_map_point_image_uv_set(map, 2, 0, h);
855 evas_map_point_image_uv_set(map, 3, w, h);
857 evas_map_util_3d_rotate(map, 0, degree, 0, x + half_w, y + half_h, 0);
861 if ((degree >= 90) || (degree <= -90))
863 evas_map_point_image_uv_set(map, 0, 0, h);
864 evas_map_point_image_uv_set(map, 1, w, h);
865 evas_map_point_image_uv_set(map, 2, w, 0);
866 evas_map_point_image_uv_set(map, 3, 0, 0);
868 evas_map_util_3d_rotate(map, degree, 0, 0, x + half_w, y + half_h, 0);
870 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, 10000);
871 evas_object_map_enable_set(flip->front, EINA_TRUE);
872 evas_object_map_enable_set(flip->back, EINA_TRUE);
873 evas_object_map_set(obj, map);
880 * @param front Front surface object
881 * @param back Back surface object
882 * @param axis Flipping Axis(X or Y)
883 * @param cw Flipping Direction. EINA_TRUE is clock-wise
884 * @return Flip effect
889 elm_fx_flip_add(Evas_Object *front, Evas_Object *back, Elm_Fx_Flip_Axis axis,
896 if ((!front) || (!back))
899 effect = calloc(1, sizeof(Elm_Effect));
903 flip = calloc(1, sizeof(Elm_Fx_Flip));
915 effect->end_op = _elm_fx_flip_end;
916 effect->animation_op = _elm_fx_flip_op;
917 effect->user_data = flip;
922 /////////////////////////////////////////////////////////////////////////////////////
924 /////////////////////////////////////////////////////////////////////////////////////
925 typedef struct _resizable_flip Elm_Fx_ResizableFlip;
926 static void _elm_fx_resizable_flip_begin(void *data, Eina_Bool reverse,
927 unsigned int repeat);
928 static void _elm_fx_resizable_flip_end(void *data, Eina_Bool auto_reverse,
929 unsigned int repeat_cnt);
930 static void _elm_fx_resizable_flip_op(void *data, Elm_Animator *animator,
932 static void _set_image_uv_by_axis_y(Evas_Map *map, Elm_Fx_ResizableFlip *flip,
934 static void _set_image_uv_by_axis_x(Evas_Map *map, Elm_Fx_ResizableFlip *flip,
937 struct _resizable_flip
941 Elm_Fx_Flip_Axis axis;
945 } from_pos, from_size, to_pos, to_size;
950 _elm_fx_resizable_flip_begin(void *data, Eina_Bool reverse, unsigned int repeat)
952 Elm_Fx_ResizableFlip *resizable_flip = data;
954 evas_object_show(resizable_flip->front);
955 _elm_fx_resizable_flip_op(data, NULL, 0);
959 _elm_fx_resizable_flip_end(void *data, Eina_Bool auto_reverse,
960 unsigned int repeat_cnt)
962 Elm_Fx_ResizableFlip *resizable_flip = data;
964 evas_object_map_enable_set(resizable_flip->front, EINA_FALSE);
965 evas_object_map_enable_set(resizable_flip->back, EINA_FALSE);
969 _set_image_uv_by_axis_y(Evas_Map *map, Elm_Fx_ResizableFlip *flip,
972 if ((degree >= 90) || (degree <= -90))
974 evas_map_point_image_uv_set(map, 0,
975 (flip->from_size.x * 2) + flip->to_size.x,
977 evas_map_point_image_uv_set(map, 1, 0, 0);
978 evas_map_point_image_uv_set(map, 2, 0,
979 (flip->from_size.y * 2) + flip->to_size.y);
980 evas_map_point_image_uv_set(map, 3,
981 (flip->from_size.x * 2) + flip->to_size.x,
982 (flip->from_size.y * 2) + flip->to_size.y);
986 evas_map_point_image_uv_set(map, 0, 0, 0);
987 evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
988 evas_map_point_image_uv_set(map, 2, flip->from_size.x,
990 evas_map_point_image_uv_set(map, 3, 0, flip->to_size.y);
995 _set_image_uv_by_axis_x(Evas_Map *map, Elm_Fx_ResizableFlip *flip,
998 if ((degree >= 90) || (degree <= -90))
1000 evas_map_point_image_uv_set(map, 0, 0,
1001 (flip->from_size.y * 2) + flip->to_size.y);
1002 evas_map_point_image_uv_set(map, 1,
1003 (flip->from_size.x * 2) + flip->to_size.x,
1004 (flip->from_size.y * 2) + flip->to_size.y);
1005 evas_map_point_image_uv_set(map, 2,
1006 (flip->from_size.x * 2) + flip->to_size.x,
1008 evas_map_point_image_uv_set(map, 3, 0, 0);
1012 evas_map_point_image_uv_set(map, 0, 0, 0);
1013 evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
1014 evas_map_point_image_uv_set(map, 2, flip->from_size.x,
1016 evas_map_point_image_uv_set(map, 3, 0, flip->to_size.y);
1021 _elm_fx_resizable_flip_op(void *data, Elm_Animator *animator, double frame)
1023 Elm_Fx_ResizableFlip *resizable_flip;
1033 Evas_Coord half_w, half_h;
1035 map = evas_map_new(4);
1039 resizable_flip = data;
1041 if (resizable_flip->cw)
1042 degree = (float)(frame * 180);
1044 degree = (float)(frame * -180);
1046 if ((degree < 90) && (degree > -90))
1048 obj = resizable_flip->front;
1049 evas_object_hide(resizable_flip->back);
1050 evas_object_show(resizable_flip->front);
1054 obj = resizable_flip->back;
1055 evas_object_hide(resizable_flip->front);
1056 evas_object_show(resizable_flip->back);
1059 evas_map_smooth_set(map, EINA_TRUE);
1061 x = resizable_flip->from_pos.x + (resizable_flip->to_pos.x * frame);
1062 y = resizable_flip->from_pos.y + (resizable_flip->to_pos.y * frame);
1063 w = resizable_flip->from_size.x + (resizable_flip->to_size.x * frame);
1064 h = resizable_flip->from_size.y + (resizable_flip->to_size.y * frame);
1065 evas_map_point_coord_set(map, 0, x, y, 0);
1066 evas_map_point_coord_set(map, 1, x + w, y, 0);
1067 evas_map_point_coord_set(map, 2, x + w, y + h, 0);
1068 evas_map_point_coord_set(map, 3, x, y + h, 0);
1070 half_w = (Evas_Coord) (w / 2);
1071 half_h = (Evas_Coord) (h / 2);
1073 if (resizable_flip->axis == ELM_FX_FLIP_AXIS_Y)
1075 _set_image_uv_by_axis_y(map, resizable_flip, degree);
1076 evas_map_util_3d_rotate(map, 0, degree, 0, x + half_w, y + half_h, 0);
1080 _set_image_uv_by_axis_x(map, resizable_flip, degree);
1081 evas_map_util_3d_rotate(map, degree, 0, 0, x + half_w, y + half_h, 0);
1084 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, 10000);
1085 evas_object_map_enable_set(resizable_flip->front, EINA_TRUE);
1086 evas_object_map_enable_set(resizable_flip->back, EINA_TRUE);
1087 evas_object_map_set(obj, map);
1092 * Add ResizbleFlip effect. the size of each surface objects are interpolated automatically.
1094 * @param front Front surface object
1095 * @param back Back surface object
1096 * @param axis Flipping Axis.(X or Y)
1097 * @param cw Flipping Direction. EINA_TRUE is clock-wise
1098 * @return Flip effect
1103 elm_fx_resizable_flip_add(Evas_Object *front, Evas_Object *back,
1104 Elm_Fx_Flip_Axis axis, Eina_Bool cw)
1106 Elm_Fx_ResizableFlip *resizable_flip;
1110 Evas_Coord front_x, front_y, front_w, front_h;
1112 Evas_Coord back_x, back_y, back_w, back_h;
1114 if (!front || !back)
1117 effect = calloc(1, sizeof(Elm_Effect));
1121 resizable_flip = calloc(1, sizeof(Elm_Fx_ResizableFlip));
1123 if (!resizable_flip)
1129 resizable_flip->front = front;
1130 resizable_flip->back = back;
1131 resizable_flip->cw = cw;
1132 resizable_flip->axis = axis;
1134 evas_object_geometry_get(resizable_flip->front, &front_x, &front_y, &front_w,
1136 evas_object_geometry_get(resizable_flip->back, &back_x, &back_y, &back_w,
1139 resizable_flip->from_pos.x = front_x;
1140 resizable_flip->from_pos.y = front_y;
1141 resizable_flip->to_pos.x = back_x - front_x;
1142 resizable_flip->to_pos.y = back_y - front_y;
1144 resizable_flip->from_size.x = front_w;
1145 resizable_flip->from_size.y = front_h;
1146 resizable_flip->to_size.x = back_w - front_w;
1147 resizable_flip->to_size.y = back_h - front_h;
1149 effect->begin_op = _elm_fx_resizable_flip_begin;
1150 effect->end_op = _elm_fx_resizable_flip_end;
1151 effect->animation_op = _elm_fx_resizable_flip_op;
1152 effect->user_data = resizable_flip;
1157 /////////////////////////////////////////////////////////////////////////////////////
1159 /////////////////////////////////////////////////////////////////////////////////////
1160 typedef struct _wipe Elm_Fx_Wipe;
1161 static void _elm_fx_wipe_op(void *data, Elm_Animator *animator,
1163 static void _elm_fx_wipe_begin(void *data, Eina_Bool auto_repeat,
1164 unsigned int repeat_cnt);
1165 static void _elm_fx_wipe_end(void *data, Eina_Bool auto_repeat,
1166 unsigned int repeat_cnt);
1167 static void _elm_fx_wipe_hide(Evas_Map * map, Elm_Fx_Wipe_Dir dir,
1168 float x, float y, float w, float h, float frame);
1169 static void _elm_fx_wipe_show(Evas_Map *map, Elm_Fx_Wipe_Dir dir,
1170 float x, float y, float w, float h, float frame);
1175 Elm_Fx_Wipe_Type type;
1176 Elm_Fx_Wipe_Dir dir;
1180 _elm_fx_wipe_begin(void *data, Eina_Bool auto_repeat, unsigned int repeat_cnt)
1182 Elm_Fx_Wipe *wipe = data;
1184 evas_object_show(wipe->obj);
1185 _elm_fx_wipe_op(data, NULL, 0);
1189 _elm_fx_wipe_end(void *data, Eina_Bool auto_repeat, unsigned int repeat_cnt)
1191 Elm_Fx_Wipe *wipe = data;
1193 evas_object_map_enable_set(wipe->obj, EINA_FALSE);
1197 _elm_fx_wipe_hide(Evas_Map * map, Elm_Fx_Wipe_Dir dir, float x, float y,
1198 float w, float h, float frame)
1204 case ELM_FX_WIPE_DIR_LEFT:
1205 w2 = w - (w * frame);
1207 evas_map_point_image_uv_set(map, 0, 0, 0);
1208 evas_map_point_image_uv_set(map, 1, w2, 0);
1209 evas_map_point_image_uv_set(map, 2, w2, h);
1210 evas_map_point_image_uv_set(map, 3, 0, h);
1211 evas_map_point_coord_set(map, 0, x, y, 0);
1212 evas_map_point_coord_set(map, 1, x + w2, y, 0);
1213 evas_map_point_coord_set(map, 2, x + w2, h2, 0);
1214 evas_map_point_coord_set(map, 3, x, h2, 0);
1216 case ELM_FX_WIPE_DIR_RIGHT:
1219 evas_map_point_image_uv_set(map, 0, w2, 0);
1220 evas_map_point_image_uv_set(map, 1, w, 0);
1221 evas_map_point_image_uv_set(map, 2, w, h);
1222 evas_map_point_image_uv_set(map, 3, w2, h);
1223 evas_map_point_coord_set(map, 0, x + w2, y, 0);
1224 evas_map_point_coord_set(map, 1, x + w, y, 0);
1225 evas_map_point_coord_set(map, 2, x + w, h2, 0);
1226 evas_map_point_coord_set(map, 3, x + w2, h2, 0);
1228 case ELM_FX_WIPE_DIR_UP:
1230 h2 = h - (h * frame);
1231 evas_map_point_image_uv_set(map, 0, 0, 0);
1232 evas_map_point_image_uv_set(map, 1, w, 0);
1233 evas_map_point_image_uv_set(map, 2, w, h2);
1234 evas_map_point_image_uv_set(map, 3, 0, h2);
1235 evas_map_point_coord_set(map, 0, x, y, 0);
1236 evas_map_point_coord_set(map, 1, w2, y, 0);
1237 evas_map_point_coord_set(map, 2, w2, h2, 0);
1238 evas_map_point_coord_set(map, 3, x, h2, 0);
1240 case ELM_FX_WIPE_DIR_DOWN:
1243 evas_map_point_image_uv_set(map, 0, 0, h2);
1244 evas_map_point_image_uv_set(map, 1, w, h2);
1245 evas_map_point_image_uv_set(map, 2, w, h);
1246 evas_map_point_image_uv_set(map, 3, 0, h);
1247 evas_map_point_coord_set(map, 0, x, y + h2, 0);
1248 evas_map_point_coord_set(map, 1, w2, y + h2, 0);
1249 evas_map_point_coord_set(map, 2, w2, y + h, 0);
1250 evas_map_point_coord_set(map, 3, x, y + h, 0);
1256 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, 10000);
1260 _elm_fx_wipe_show(Evas_Map *map, Elm_Fx_Wipe_Dir dir, float x, float y,
1261 float w, float h, float frame)
1267 case ELM_FX_WIPE_DIR_LEFT:
1268 w2 = (w - (w * frame));
1270 evas_map_point_image_uv_set(map, 0, w2, 0);
1271 evas_map_point_image_uv_set(map, 1, w, 0);
1272 evas_map_point_image_uv_set(map, 2, w, h);
1273 evas_map_point_image_uv_set(map, 3, w2, h);
1274 evas_map_point_coord_set(map, 0, x + w2, y, 0);
1275 evas_map_point_coord_set(map, 1, w, y, 0);
1276 evas_map_point_coord_set(map, 2, w, h2, 0);
1277 evas_map_point_coord_set(map, 3, x + w2, h2, 0);
1279 case ELM_FX_WIPE_DIR_RIGHT:
1282 evas_map_point_image_uv_set(map, 0, 0, 0);
1283 evas_map_point_image_uv_set(map, 1, w2, 0);
1284 evas_map_point_image_uv_set(map, 2, w2, h);
1285 evas_map_point_image_uv_set(map, 3, 0, h);
1286 evas_map_point_coord_set(map, 0, x, y, 0);
1287 evas_map_point_coord_set(map, 1, x + w2, y, 0);
1288 evas_map_point_coord_set(map, 2, x + w2, h2, 0);
1289 evas_map_point_coord_set(map, 3, x, h2, 0);
1291 case ELM_FX_WIPE_DIR_UP:
1293 h2 = (h - (h * frame));
1294 evas_map_point_image_uv_set(map, 0, 0, h2);
1295 evas_map_point_image_uv_set(map, 1, w, h2);
1296 evas_map_point_image_uv_set(map, 2, w, h);
1297 evas_map_point_image_uv_set(map, 3, 0, h);
1298 evas_map_point_coord_set(map, 0, x, y + h2, 0);
1299 evas_map_point_coord_set(map, 1, w2, y + h2, 0);
1300 evas_map_point_coord_set(map, 2, w2, y + h, 0);
1301 evas_map_point_coord_set(map, 3, x, y + h, 0);
1303 case ELM_FX_WIPE_DIR_DOWN:
1306 evas_map_point_image_uv_set(map, 0, 0, 0);
1307 evas_map_point_image_uv_set(map, 1, w, 0);
1308 evas_map_point_image_uv_set(map, 2, w, h2);
1309 evas_map_point_image_uv_set(map, 3, 0, h2);
1310 evas_map_point_coord_set(map, 0, x, y, 0);
1311 evas_map_point_coord_set(map, 1, w2, y, 0);
1312 evas_map_point_coord_set(map, 2, w2, y + h2, 0);
1313 evas_map_point_coord_set(map, 3, x, y + h2, 0);
1319 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, 10000);
1323 _elm_fx_wipe_op(void *data, Elm_Animator *animator, double frame)
1329 Evas_Coord _x, _y, _w, _h;
1331 map = evas_map_new(4);
1336 evas_map_smooth_set(map, EINA_TRUE);
1337 evas_object_geometry_get(wipe->obj, &_x, &_y, &_w, &_h);
1339 if (wipe->type == ELM_FX_WIPE_TYPE_SHOW)
1340 _elm_fx_wipe_show(map, wipe->dir, _x, _y, _w, _h, (float)frame);
1342 _elm_fx_wipe_hide(map, wipe->dir, _x, _y, _w, _h, (float)frame);
1344 evas_object_map_enable_set(wipe->obj, EINA_TRUE);
1345 evas_object_map_set(wipe->obj, map);
1352 * @param obj Evas_Object that effect is applying to
1353 * @param type Wipe type. Hide or show
1354 * @param dir Wipe Direction
1355 * @return Wipe effect
1360 elm_fx_wipe_add(Evas_Object *obj, Elm_Fx_Wipe_Type type, Elm_Fx_Wipe_Dir dir)
1369 effect = calloc(1, sizeof(Elm_Effect));
1373 wipe = calloc(1, sizeof(Elm_Fx_Wipe));
1383 effect->begin_op = _elm_fx_wipe_begin;
1384 effect->end_op = _elm_fx_wipe_end;
1385 effect->animation_op = _elm_fx_wipe_op;
1386 effect->user_data = wipe;
1391 /////////////////////////////////////////////////////////////////////////////////////
1393 /////////////////////////////////////////////////////////////////////////////////////
1394 typedef struct _color Elm_Fx_Color;
1395 static void _elm_fx_color_begin(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt);
1396 static void _elm_fx_color_op(void *data, Elm_Animator *animator, double frame);
1401 struct _unsigned_color
1403 unsigned int r, g, b, a;
1405 struct _signed_color
1412 _elm_fx_color_begin(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
1414 Elm_Fx_Color *color = data;
1416 evas_object_show(color->obj);
1420 _elm_fx_color_op(void *data, Elm_Animator *animator, double frame)
1422 Elm_Fx_Color *color;
1424 unsigned int r, g, b, a;
1427 r = (color->from.r + (int)((float)color->to.r * frame));
1428 g = (color->from.g + (int)((float)color->to.g * frame));
1429 b = (color->from.b + (int)((float)color->to.b * frame));
1430 a = (color->from.a + (int)((float)color->to.a * frame));
1432 evas_object_color_set(color->obj, r, g, b, a);
1438 * @param obj Evas_Object that effect is applying to
1439 * @param from_r RGB R when effect begins
1440 * @param from_g RGB G when effect begins
1441 * @param from_b RGB B when effect begins
1442 * @param from_a RGB A when effect begins
1443 * @param to_r RGB R when effect ends
1444 * @param to_g RGB G when effect ends
1445 * @param to_b RGB B when effect ends
1446 * @param to_a RGB A when effect ends
1447 * @return Color Effect
1452 elm_fx_color_add(Evas_Object *obj, unsigned int from_r, unsigned int from_g,
1453 unsigned int from_b, unsigned int from_a, unsigned int to_r,
1454 unsigned int to_g, unsigned int to_b, unsigned int to_a)
1458 Elm_Fx_Color *color;
1463 effect = calloc(1, sizeof(Elm_Effect));
1467 color = calloc(1, sizeof(Elm_Fx_Color));
1475 color->from.r = from_r;
1476 color->from.g = from_g;
1477 color->from.b = from_b;
1478 color->from.a = from_a;
1479 color->to.r = to_r - from_r;
1480 color->to.g = to_g - from_g;
1481 color->to.b = to_b - from_b;
1482 color->to.a = to_a - from_a;
1484 effect->begin_op = _elm_fx_color_begin;
1485 effect->animation_op = _elm_fx_color_op;
1486 effect->user_data = color;
1491 /////////////////////////////////////////////////////////////////////////////////////
1493 /////////////////////////////////////////////////////////////////////////////////////
1494 typedef struct _fade Elm_Fx_Fade;
1495 static void _elm_fx_fade_begin(void *data, Eina_Bool auto_reverse,
1496 unsigned int repeat_cnt);
1497 static void _elm_fx_fade_end(void *data, Eina_Bool auto_reverse,
1498 unsigned int repeat_cnt);
1499 static void _elm_fx_fade_op(void *data, Elm_Animator *animator,
1504 Evas_Object *before;
1506 struct _signed_color before_color, after_color;
1509 Eina_Bool inversed:1;
1513 _elm_fx_fade_begin(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
1515 Elm_Fx_Fade *fade = data;
1517 fade->inversed = EINA_FALSE;
1521 _elm_fx_fade_end(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
1523 Elm_Fx_Fade *fade = data;
1525 evas_object_color_set(fade->before, fade->before_color.r,
1526 fade->before_color.g, fade->before_color.b,
1527 fade->before_color.a);
1528 evas_object_color_set(fade->after, fade->after_color.r, fade->after_color.g,
1529 fade->after_color.b, fade->after_color.a);
1533 _elm_fx_fade_op(void *data, Elm_Animator *animator, double frame)
1543 if (!fade->inversed)
1545 evas_object_hide(fade->after);
1546 evas_object_show(fade->before);
1547 fade->inversed = EINA_TRUE;
1550 _frame = (1 - (frame * 2));
1552 evas_object_color_set(fade->before, fade->before_color.r * _frame,
1553 fade->before_color.g * _frame,
1554 fade->before_color.b * _frame,
1555 fade->before_color.a + fade->before_alpha * (1 -
1562 evas_object_hide(fade->before);
1563 evas_object_show(fade->after);
1564 fade->inversed = EINA_FALSE;
1567 _frame = ((frame - 0.5) * 2);
1569 evas_object_color_set(fade->after, fade->after_color.r * _frame,
1570 fade->after_color.g * _frame,
1571 fade->after_color.b * _frame,
1572 fade->after_color.a + fade->after_alpha * (1 -
1581 * @param before Evas Object before fade in
1582 * @param after Evas Object after fade out
1583 * @return Fade effect
1588 elm_fx_fade_add(Evas_Object *before, Evas_Object *after)
1594 if ((!before) && (!after))
1597 effect = calloc(1, sizeof(Elm_Effect));
1601 fade = calloc(1, sizeof(Elm_Fx_Fade));
1609 evas_object_color_get(before, &fade->before_color.r, &fade->before_color.g,
1610 &fade->before_color.b, &fade->before_color.a);
1611 evas_object_color_get(after, &fade->after_color.r, &fade->after_color.g,
1612 &fade->after_color.b, &fade->after_color.a);
1614 fade->before = before;
1615 fade->after = after;
1616 fade->before_alpha = (255 - fade->before_color.a);
1617 fade->after_alpha = (255 - fade->after_color.a);
1619 effect->begin_op = _elm_fx_fade_begin;
1620 effect->end_op = _elm_fx_fade_end;
1621 effect->animation_op = _elm_fx_fade_op;
1622 effect->user_data = fade;
1627 /////////////////////////////////////////////////////////////////////////////////////
1629 /////////////////////////////////////////////////////////////////////////////////////
1630 typedef struct _blend Elm_Fx_Blend;
1631 static void _elm_fx_blend_begin(void *data, Eina_Bool auto_reverse,
1632 unsigned int repeat_cnt);
1633 static void _elm_fx_blend_end(void *data, Eina_Bool auto_reverse,
1634 unsigned int repeat_cnt);
1635 static void _elm_fx_blend_op(void *data, Elm_Animator *animator,
1640 Evas_Object *before;
1642 struct _signed_color from, to;
1646 _elm_fx_blend_begin(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
1648 Elm_Fx_Blend *blend = data;
1650 evas_object_show(blend->before);
1654 _elm_fx_blend_end(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
1656 Elm_Fx_Blend *blend = data;
1658 evas_object_color_set(blend->before, blend->from.r, blend->from.g,
1659 blend->from.b, blend->from.a);
1660 evas_object_color_set(blend->after, blend->to.r, blend->to.g, blend->to.b,
1663 evas_object_hide(blend->before);
1665 evas_object_hide(blend->after);
1669 _elm_fx_blend_op(void *data, Elm_Animator *animator, double frame)
1671 Elm_Fx_Blend *blend = data;
1673 evas_object_show(blend->after);
1674 evas_object_color_set(blend->before, (int)(blend->from.r * (1 - frame)),
1675 (int)(blend->from.g * (1 - frame)),
1676 (int)(blend->from.b * (1 - frame)),
1677 (int)(blend->from.a * (1 - frame)));
1678 evas_object_color_set(blend->after, (int)(blend->to.r * frame),
1679 (int)(blend->to.g * frame), (int)(blend->to.b * frame),
1680 (int)(blend->to.a * frame));
1686 * @param before Evas Object before blending
1687 * @param after Evas Object after blending
1688 * @return Blend effect
1693 elm_fx_blend_add(Evas_Object *before, Evas_Object *after)
1697 Elm_Fx_Blend *blend;
1699 if ((!before) && (!after))
1702 effect = calloc(1, sizeof(Elm_Effect));
1706 blend = calloc(1, sizeof(Elm_Fx_Blend));
1713 blend->before = before;
1714 blend->after = after;
1715 evas_object_color_get(before, &blend->from.r, &blend->from.g, &blend->from.b,
1717 evas_object_color_get(after, &blend->to.r, &blend->to.g, &blend->to.b,
1720 effect->begin_op = _elm_fx_blend_begin;
1721 effect->end_op = _elm_fx_blend_end;
1722 effect->animation_op = _elm_fx_blend_op;
1723 effect->user_data = blend;
1728 /////////////////////////////////////////////////////////////////////////////////////
1730 /////////////////////////////////////////////////////////////////////////////////////
1731 typedef struct _rotation Elm_Fx_Rotation;
1732 static void _elm_fx_rotation_begin(void *data, Eina_Bool auto_reverse,
1733 unsigned int repeat_cnt);
1734 static void _elm_fx_rotation_end(void *data, Eina_Bool auto_reverse,
1735 unsigned int repeat_cnt);
1736 static void _elm_fx_rotation_op(void *data, Elm_Animator *animator,
1747 _elm_fx_rotation_begin(void *data, Eina_Bool auto_reverse,
1748 unsigned int repeat_cnt)
1750 Elm_Fx_Rotation *rotation = data;
1752 evas_object_show(rotation->obj);
1756 _elm_fx_rotation_end(void *data, Eina_Bool auto_reverse,
1757 unsigned int repeat_cnt)
1759 Elm_Fx_Rotation *rotation = data;
1761 evas_object_map_enable_set(rotation->obj, EINA_FALSE);
1765 _elm_fx_rotation_op(void *data, Elm_Animator *animator, double frame)
1767 Elm_Fx_Rotation *rotation;
1771 Evas_Coord x, y, w, h;
1775 float half_w, half_h;
1777 map = evas_map_new(4);
1783 evas_map_smooth_set(map, EINA_TRUE);
1784 evas_map_util_points_populate_from_object_full(map, rotation->obj, 0);
1785 degree = rotation->from + (float)(frame * rotation->to);
1790 evas_object_geometry_get(rotation->obj, &x, &y, &w, &h);
1792 half_w = (float)w *0.5;
1794 half_h = (float)h *0.5;
1796 evas_map_util_3d_rotate(map, 0, 0, degree, x + half_w, y + half_h, 0);
1797 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, 10000);
1798 evas_object_map_enable_set(rotation->obj, EINA_TRUE);
1799 evas_object_map_set(rotation->obj, map);
1804 * Add Rotation effect
1806 * @param obj Evas_Object that effect is applying to
1807 * @param from degree Degree when effect begins
1808 * @param to_degree Degree when effect is ends
1809 * @param cw Rotation direction. EINA_TRUE is clock wise
1810 * @return Rotation effect
1815 elm_fx_rotation_add(Evas_Object *obj, float from_degree, float to_degree,
1820 Elm_Fx_Rotation *rotation;
1825 effect = calloc(1, sizeof(Elm_Effect));
1829 rotation = calloc(1, sizeof(Elm_Fx_Rotation));
1837 rotation->obj = obj;
1838 rotation->from = from_degree;
1839 rotation->to = to_degree - from_degree;
1842 effect->begin_op = _elm_fx_rotation_begin;
1843 effect->end_op = _elm_fx_rotation_end;
1844 effect->animation_op = _elm_fx_rotation_op;
1845 effect->user_data = rotation;
1850 /////////////////////////////////////////////////////////////////////////////////////
1851 // ImageAnimation FX
1852 /////////////////////////////////////////////////////////////////////////////////////
1853 typedef struct _image_animation Elm_Fx_Image_Animation;
1854 static void _elm_fx_imageanimation_op(void *data, Elm_Animator *animator,
1856 EAPI Elm_Effect *elm_fx_imageanimation_add(Evas_Object *obj, const char **images,
1857 unsigned int item_num);
1859 struct _image_animation
1868 _elm_fx_imageanimation_op(void *data, Elm_Animator *animator, double frame)
1870 Elm_Fx_Image_Animation *image_animation = (Elm_Fx_Image_Animation *) data;
1872 if (!image_animation->obj)
1874 image_animation->count = floor(frame * image_animation->img_cnt);
1875 elm_icon_file_set(image_animation->obj,
1876 image_animation->images[image_animation->count], NULL);
1880 * Add ImageAnimation effect.
1882 * @param obj Icon object
1883 * @param images Array of image file path.
1884 * @param img_cnt Count of image.
1885 * @return ImageAnimation effect.
1890 elm_fx_imageanimation_add(Evas_Object *obj, const char **images,
1891 unsigned int img_cnt)
1895 Elm_Fx_Image_Animation *image_animation;
1897 if (!images || !(*images))
1900 effect = calloc(1, sizeof(Elm_Effect));
1904 image_animation = calloc(1, sizeof(Elm_Fx_Image_Animation));
1906 if (!image_animation)
1912 image_animation->obj = obj;
1913 image_animation->images = (char **) images;
1914 image_animation->count = 0;
1915 image_animation->img_cnt = img_cnt;
1917 effect->animation_op = _elm_fx_imageanimation_op;
1918 effect->user_data = image_animation;