1 #include <Elementary.h>
5 * @defgroup Transit Transit
13 Elm_Animator *animator;
14 Eina_List *effect_list;
15 Evas_Object *block_rect;
16 void (*completion_op) (void *data, Elm_Transit *transit);
18 Eina_Bool reserved_del:1;
23 void (*animation_op) (void *data, Elm_Animator *animator, double frame);
24 void (*begin_op) (void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt);
25 void (*end_op) (void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt);
26 unsigned int shared_cnt;
31 _create_block_rect(Evas_Object *parent)
37 rect = evas_object_rectangle_add(evas_object_evas_get(parent));
38 evas_output_size_get(evas_object_evas_get(parent), &w, &h);
39 evas_object_resize(rect, w, h);
40 evas_object_color_set(rect, 0, 0, 0, 0);
45 _transit_animate_cb(void *data, Elm_Animator *animator, double frame)
51 Elm_Transit *transit = data;
53 EINA_LIST_FOREACH(transit->effect_list, elist, effect)
55 effect->animation_op(effect->user_data, animator, frame);
60 _transit_fx_begin(Elm_Transit *transit)
66 Eina_Bool auto_reverse;
68 unsigned int repeat_cnt;
70 auto_reverse = elm_animator_auto_reverse_get(transit->animator);
71 repeat_cnt = elm_animator_repeat_get(transit->animator);
73 EINA_LIST_FOREACH(transit->effect_list, elist, effect)
76 effect->begin_op(effect->user_data, auto_reverse, repeat_cnt);
81 _transit_fx_end(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->end_op(effect->user_data, auto_reverse, repeat_cnt);
102 _transit_complete_cb(void *data)
104 Elm_Transit *transit = (Elm_Transit *) data;
106 evas_render(evas_object_evas_get(transit->parent));
108 _transit_fx_end(transit);
110 if (transit->block_rect)
111 evas_object_hide(transit->block_rect);
113 if (transit->completion_op)
114 transit->completion_op(transit->completion_arg, transit);
116 if (transit->reserved_del)
118 transit->reserved_del = EINA_FALSE;
119 elm_transit_del(transit);
124 _transit_fx_del(Elm_Effect *effect)
129 --effect->shared_cnt;
131 if (effect->shared_cnt > 0)
133 if (effect->user_data)
134 free(effect->user_data);
141 * Set the event block when the transit is operating.
143 * @param transit Transit object
144 * @param disable Disable or enable
147 elm_transit_event_block_disabled_set(Elm_Transit *transit, Eina_Bool disable)
154 if (transit->block_rect)
156 evas_object_del(transit->block_rect);
157 transit->block_rect = NULL;
162 if (transit->block_rect == NULL)
163 transit->block_rect = _create_block_rect(transit->parent);
170 * Get the event block setting status.
172 * @param transit Transit object
173 * @return EINA_TRUE when the event block is disabled
176 elm_transit_event_block_disabled_get(Elm_Transit *transit)
180 return transit->block_rect ? EINA_TRUE : EINA_FALSE;
186 * Remove effect from transit.
188 * @param transit Transit object
189 * @param effect effect that should be removed
190 * @return EINA_TRUE, if the effect is removed
191 * @warning If the effect is not inserted in any transit, it will be deleted
194 elm_transit_fx_remove(Elm_Transit *transit, Elm_Effect *effect)
203 EINA_LIST_FOREACH(transit->effect_list, elist, _effect)
205 if (_effect == effect)
207 transit->effect_list =
208 eina_list_remove(transit->effect_list, _effect);
209 _transit_fx_del(_effect);
219 * Remove all current inseted effects.
221 * @param transit Transit object
224 elm_transit_fx_clear(Elm_Transit *transit)
233 EINA_LIST_FOREACH(transit->effect_list, elist, effect)
235 transit->effect_list = eina_list_remove(transit->effect_list, effect);
236 _transit_fx_del(effect);
243 * Remove all current inseted effects.
245 * @param transit Transit object
246 * @return Effect list
248 EAPI const Eina_List *
249 elm_transit_fx_get(Elm_Transit *transit)
253 return transit->effect_list;
259 * Set the user-callback function when the transit is done.
261 * @param transit Transit object
262 * @param op Callback function pointer
263 * @param data Callback funtion user argument
266 elm_transit_completion_callback_set(Elm_Transit *transit,
267 void (*op) (void *data,
268 Elm_Transit *transit),
273 transit->completion_op = op;
274 transit->completion_arg = data;
280 * Delete transit object.
282 * @param transit Transit object
285 elm_transit_del(Elm_Transit *transit)
289 if (elm_animator_operating_get(transit->animator))
291 transit->reserved_del = EINA_TRUE;
295 if (transit->block_rect)
296 evas_object_del(transit->block_rect);
298 elm_animator_del(transit->animator);
299 elm_transit_fx_clear(transit);
307 * Set the animation acceleration style.
309 * @param transit Transit object
310 * @param cs Curve style
313 elm_transit_curve_style_set(Elm_Transit *transit, Elm_Animator_Curve_Style cs)
317 elm_animator_curve_style_set(transit->animator, cs);
325 * @param parent Given canvas of parent object will be blocked
326 * @return Transit object
329 elm_transit_add(Evas_Object *parent)
331 Elm_Transit *transit = calloc(1, sizeof(Elm_Transit));
336 transit->animator = elm_animator_add(parent);
338 if (!transit->animator)
344 transit->parent = parent;
345 elm_animator_operation_callback_set(transit->animator, _transit_animate_cb,
347 elm_animator_completion_callback_set(transit->animator, _transit_complete_cb,
349 elm_transit_event_block_disabled_set(transit, EINA_FALSE);
357 * Set auto reverse function.
359 * @param transit Transit object
360 * @param reverse Reverse or not
363 elm_transit_auto_reverse_set(Elm_Transit *transit, Eina_Bool reverse)
367 elm_animator_auto_reverse_set(transit->animator, reverse);
373 * Insert an effect in given transit.
375 * @param transit Transit object.
376 * @param effect Effect
377 * @return EINA_TRUE is success
380 elm_transit_fx_insert(Elm_Transit *transit, Elm_Effect *effect)
389 EINA_LIST_FOREACH(transit->effect_list, elist, _effect)
391 if (_effect == effect)
395 ++effect->shared_cnt;
396 transit->effect_list = eina_list_append(transit->effect_list, effect);
404 * Set the transit repeat count. Effect will be repeated by repeat count.
406 * @param transit Transit object
407 * @param repeat Repeat count
410 elm_transit_repeat_set(Elm_Transit *transit, unsigned int repeat)
414 elm_animator_repeat_set(transit->animator, repeat);
420 * Stop the current transit effect if transit is operating.
422 * @param transit Transit object
425 elm_transit_stop(Elm_Transit *transit)
429 elm_animator_stop(transit->animator);
435 * Run the all the inserted effects.
437 * @param transit Transit object
438 * @param duration Transit time in second
441 elm_transit_run(Elm_Transit *transit, double duration)
445 _transit_fx_begin(transit);
446 elm_animator_duration_set(transit->animator, duration);
449 if (transit->block_rect)
450 evas_object_show(transit->block_rect);
452 elm_animator_animate(transit->animator);
454 //If failed to animate.
455 if (!elm_animator_operating_get(transit->animator))
457 if (transit->block_rect)
458 evas_object_hide(transit->block_rect);
459 _transit_fx_end(transit);
463 /////////////////////////////////////////////////////////////////////////////////////
465 /////////////////////////////////////////////////////////////////////////////////////
466 typedef struct _resizing Elm_Fx_Resizing;
468 static void _elm_fx_resizing_op(void *data, Elm_Animator *animator,
481 _elm_fx_resizing_begin(void *data, Eina_Bool auto_reverse,
482 unsigned int repeat_cnt)
484 Elm_Fx_Resizing *resizing = data;
486 evas_object_show(resizing->obj);
487 evas_object_resize(resizing->obj, resizing->from.w, resizing->from.h);
491 _elm_fx_resizing_end(void *data, Eina_Bool auto_reverse,
492 unsigned int repeat_cnt)
494 Elm_Fx_Resizing *resizing = data;
496 evas_object_move(resizing->obj, resizing->from.w + resizing->to.w,
497 resizing->from.h + resizing->to.h);
501 _elm_fx_resizing_op(void *data, Elm_Animator *animator, double frame)
505 Elm_Fx_Resizing *resizing = data;
507 w = resizing->from.w + (Evas_Coord) ((float)resizing->to.h * (float)frame);
508 h = resizing->from.h + (Evas_Coord) ((float)resizing->to.w * (float)frame);
509 evas_object_resize(resizing->obj, w, h);
515 * Add resizing effect.
517 * @param obj Evas_Object that effect is applying to
518 * @param from_w Width size when effect begin
519 * @param from_h Height size whene effect begin
520 * @param to_w Width size to be
521 * @param to_h Height size to be
522 * @return Resizing effect
525 elm_fx_resizing_add(Evas_Object *obj, Evas_Coord from_w, Evas_Coord from_h,
526 Evas_Coord to_w, Evas_Coord to_h)
530 Elm_Fx_Resizing *resizing;
535 effect = calloc(1, sizeof(Elm_Effect));
539 resizing = calloc(1, sizeof(Elm_Fx_Resizing));
547 resizing->from.w = from_w;
548 resizing->from.h = from_h;
549 resizing->to.w = to_w - from_w;
550 resizing->to.h = to_h - from_h;
552 effect->begin_op = _elm_fx_resizing_begin;
553 effect->animation_op = _elm_fx_resizing_op;
554 effect->user_data = resizing;
559 /////////////////////////////////////////////////////////////////////////////////////
561 /////////////////////////////////////////////////////////////////////////////////////
562 typedef struct _translation Elm_Fx_Translation;
564 static void _elm_fx_translation_op(void *data, Elm_Animator *animator,
577 _elm_fx_translation_begin(void *data, Eina_Bool auto_reverse,
578 unsigned int repeat_cnt)
580 Elm_Fx_Translation *translation = data;
582 evas_object_show(translation->obj);
583 evas_object_move(translation->obj, translation->from.x, translation->from.y);
587 _elm_fx_translation_end(void *data, Eina_Bool auto_reverse,
588 unsigned int repeat_cnt)
590 Elm_Fx_Translation *translation = data;
592 evas_object_move(translation->obj, translation->from.x + translation->to.x,
593 translation->from.y + translation->to.y);
597 _elm_fx_translation_op(void *data, Elm_Animator *animator, double frame)
601 Elm_Fx_Translation *translation = data;
603 x = translation->from.x +
604 (Evas_Coord) ((float)translation->to.x * (float)frame);
605 y = translation->from.y +
606 (Evas_Coord) ((float)translation->to.y * (float)frame);
607 evas_object_move(translation->obj, x, y);
613 * Add translation effect.
615 * @param obj Evas_Object that effect is applying to
616 * @param from_x Position X when effect begin
617 * @param from_y Position Y whene effect begin
618 * @param to_x Position X to be
619 * @param to_y Position Y to be
620 * @return Translation effect
623 elm_fx_translation_add(Evas_Object *obj, Evas_Coord from_x, Evas_Coord from_y,
624 Evas_Coord to_x, Evas_Coord to_y)
628 Elm_Fx_Translation *translation;
633 effect = calloc(1, sizeof(Elm_Effect));
637 translation = calloc(1, sizeof(Elm_Fx_Translation));
645 translation->obj = obj;
646 translation->from.x = from_x;
647 translation->from.y = from_y;
648 translation->to.x = to_x - from_x;
649 translation->to.y = to_y - from_y;
651 effect->begin_op = _elm_fx_translation_begin;
652 effect->end_op = _elm_fx_translation_end;
653 effect->animation_op = _elm_fx_translation_op;
654 effect->user_data = translation;
659 /////////////////////////////////////////////////////////////////////////////////////
661 /////////////////////////////////////////////////////////////////////////////////////
662 typedef struct _zoom Elm_Fx_Zoom;
664 static void _elm_fx_zoom_op(void *data, Elm_Animator * animator, double frame);
673 _elm_fx_zoom_begin(void *data, Eina_Bool reverse, unsigned int repeat)
675 Elm_Fx_Zoom *zoom = data;
677 evas_object_show(zoom->obj);
678 _elm_fx_zoom_op(data, NULL, 0);
682 _elm_fx_zoom_end(void *data, Eina_Bool reverse, unsigned int repeat)
684 Elm_Fx_Zoom *zoom = data;
686 evas_object_map_enable_set(zoom->obj, EINA_FALSE);
690 _elm_fx_zoom_op(void *data, Elm_Animator *animator, double frame)
696 Evas_Coord x, y, w, h;
698 map = evas_map_new(4);
703 evas_object_geometry_get(zoom->obj, &x, &y, &w, &h);
704 evas_map_smooth_set(map, EINA_TRUE);
705 evas_map_util_points_populate_from_object_full(map, zoom->obj,
708 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, 10000);
709 evas_object_map_set(zoom->obj, map);
710 evas_object_map_enable_set(zoom->obj, EINA_TRUE);
719 * @param obj Evas_Object that effect is applying to
720 * @param from_rate Scale rate when the effect begin (1 is current rate)
721 * @param to_rate Scale rate to be
722 * @return Zoom effect
725 elm_fx_zoom_add(Evas_Object *obj, float from_rate, float to_rate)
734 effect = calloc(1, sizeof(Elm_Effect));
738 zoom = calloc(1, sizeof(Elm_Fx_Zoom));
746 zoom->from = (10000 - (from_rate * 10000)) * (1 / from_rate);
747 zoom->to = ((10000 - (to_rate * 10000)) * (1 / to_rate)) - zoom->from;
748 effect->begin_op = _elm_fx_zoom_begin;
749 effect->end_op = _elm_fx_zoom_end;
750 effect->animation_op = _elm_fx_zoom_op;
751 effect->user_data = zoom;
757 /////////////////////////////////////////////////////////////////////////////////////
759 /////////////////////////////////////////////////////////////////////////////////////
760 typedef struct _flip Elm_Fx_Flip;
766 Elm_Fx_Flip_Axis axis;
771 _elm_fx_flip_end(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
773 Elm_Fx_Flip *flip = data;
775 evas_object_map_enable_set(flip->front, EINA_FALSE);
776 evas_object_map_enable_set(flip->back, EINA_FALSE);
780 _elm_fx_flip_op(void *data, Elm_Animator *animator, double frame)
790 Evas_Coord x, y, w, h;
792 map = evas_map_new(4);
799 degree = (float)(frame * 180);
801 degree = (float)(frame * -180);
803 if (degree < 90 && degree > -90)
806 evas_object_hide(flip->back);
807 evas_object_show(flip->front);
812 evas_object_hide(flip->front);
813 evas_object_show(flip->back);
816 evas_map_smooth_set(map, EINA_TRUE);
817 evas_map_util_points_populate_from_object_full(map, obj, 0);
818 evas_object_geometry_get(obj, &x, &y, &w, &h);
819 Evas_Coord half_w = (w / 2);
821 Evas_Coord half_h = (h / 2);
823 if (flip->axis == ELM_FX_FLIP_AXIS_Y)
825 if ((degree >= 90) || (degree <= -90))
827 evas_map_point_image_uv_set(map, 0, w, 0);
828 evas_map_point_image_uv_set(map, 1, 0, 0);
829 evas_map_point_image_uv_set(map, 2, 0, h);
830 evas_map_point_image_uv_set(map, 3, w, h);
832 evas_map_util_3d_rotate(map, 0, degree, 0, x + half_w, y + half_h, 0);
836 if ((degree >= 90) || (degree <= -90))
838 evas_map_point_image_uv_set(map, 0, 0, h);
839 evas_map_point_image_uv_set(map, 1, w, h);
840 evas_map_point_image_uv_set(map, 2, w, 0);
841 evas_map_point_image_uv_set(map, 3, 0, 0);
843 evas_map_util_3d_rotate(map, degree, 0, 0, x + half_w, y + half_h, 0);
845 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, 10000);
846 evas_object_map_enable_set(flip->front, EINA_TRUE);
847 evas_object_map_enable_set(flip->back, EINA_TRUE);
848 evas_object_map_set(obj, map);
857 * @param front Front surface object
858 * @param back Back surface object
859 * @param axis Flipping Axis. X or Y
860 * @param cw Flipping Direction. EINA_TRUE is clock-wise
861 * @return Flip effect
864 elm_fx_flip_add(Evas_Object *front, Evas_Object *back, Elm_Fx_Flip_Axis axis,
871 if ((!front) || (!back))
874 effect = calloc(1, sizeof(Elm_Effect));
878 flip = calloc(1, sizeof(Elm_Fx_Flip));
890 effect->end_op = _elm_fx_flip_end;
891 effect->animation_op = _elm_fx_flip_op;
892 effect->user_data = flip;
897 /////////////////////////////////////////////////////////////////////////////////////
899 /////////////////////////////////////////////////////////////////////////////////////
900 typedef struct _resizable_flip Elm_Fx_ResizableFlip;
902 static void _elm_fx_resizable_flip_op(void *data, Elm_Animator *animator,
905 struct _resizable_flip
909 Elm_Fx_Flip_Axis axis;
913 } from_pos, from_size, to_pos, to_size;
918 _elm_fx_resizable_flip_begin(void *data, Eina_Bool reverse, unsigned int repeat)
920 Elm_Fx_ResizableFlip *resizable_flip = data;
922 evas_object_show(resizable_flip->front);
923 _elm_fx_resizable_flip_op(data, NULL, 0);
927 _elm_fx_resizable_flip_end(void *data, Eina_Bool auto_reverse,
928 unsigned int repeat_cnt)
930 Elm_Fx_ResizableFlip *resizable_flip = data;
932 evas_object_map_enable_set(resizable_flip->front, EINA_FALSE);
933 evas_object_map_enable_set(resizable_flip->back, EINA_FALSE);
937 _set_image_uv_by_axis_y(Evas_Map *map, Elm_Fx_ResizableFlip *flip,
940 if ((degree >= 90) || (degree <= -90))
942 evas_map_point_image_uv_set(map, 0,
943 (flip->from_size.x * 2) + flip->to_size.x,
945 evas_map_point_image_uv_set(map, 1, 0, 0);
946 evas_map_point_image_uv_set(map, 2, 0,
947 (flip->from_size.y * 2) + flip->to_size.y);
948 evas_map_point_image_uv_set(map, 3,
949 (flip->from_size.x * 2) + flip->to_size.x,
950 (flip->from_size.y * 2) + flip->to_size.y);
954 evas_map_point_image_uv_set(map, 0, 0, 0);
955 evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
956 evas_map_point_image_uv_set(map, 2, flip->from_size.x,
958 evas_map_point_image_uv_set(map, 3, 0, flip->to_size.y);
963 _set_image_uv_by_axis_x(Evas_Map *map, Elm_Fx_ResizableFlip *flip,
966 if ((degree >= 90) || (degree <= -90))
968 evas_map_point_image_uv_set(map, 0, 0,
969 (flip->from_size.y * 2) + flip->to_size.y);
970 evas_map_point_image_uv_set(map, 1,
971 (flip->from_size.x * 2) + flip->to_size.x,
972 (flip->from_size.y * 2) + flip->to_size.y);
973 evas_map_point_image_uv_set(map, 2,
974 (flip->from_size.x * 2) + flip->to_size.x,
976 evas_map_point_image_uv_set(map, 3, 0, 0);
980 evas_map_point_image_uv_set(map, 0, 0, 0);
981 evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
982 evas_map_point_image_uv_set(map, 2, flip->from_size.x,
984 evas_map_point_image_uv_set(map, 3, 0, flip->to_size.y);
989 _elm_fx_resizable_flip_op(void *data, Elm_Animator *animator, double frame)
991 Elm_Fx_ResizableFlip *resizable_flip;
1001 Evas_Coord half_w, half_h;
1003 map = evas_map_new(4);
1007 resizable_flip = data;
1009 if (resizable_flip->cw)
1010 degree = (float)(frame * 180);
1012 degree = (float)(frame * -180);
1014 if ((degree < 90) && (degree > -90))
1016 obj = resizable_flip->front;
1017 evas_object_hide(resizable_flip->back);
1018 evas_object_show(resizable_flip->front);
1022 obj = resizable_flip->back;
1023 evas_object_hide(resizable_flip->front);
1024 evas_object_show(resizable_flip->back);
1027 evas_map_smooth_set(map, EINA_TRUE);
1029 x = resizable_flip->from_pos.x + (resizable_flip->to_pos.x * frame);
1030 y = resizable_flip->from_pos.y + (resizable_flip->to_pos.y * frame);
1031 w = resizable_flip->from_size.x + (resizable_flip->to_size.x * frame);
1032 h = resizable_flip->from_size.y + (resizable_flip->to_size.y * frame);
1033 evas_map_point_coord_set(map, 0, x, y, 0);
1034 evas_map_point_coord_set(map, 1, x + w, y, 0);
1035 evas_map_point_coord_set(map, 2, x + w, y + h, 0);
1036 evas_map_point_coord_set(map, 3, x, y + h, 0);
1038 half_w = (Evas_Coord) (w / 2);
1039 half_h = (Evas_Coord) (h / 2);
1041 if (resizable_flip->axis == ELM_FX_FLIP_AXIS_Y)
1043 _set_image_uv_by_axis_y(map, resizable_flip, degree);
1044 evas_map_util_3d_rotate(map, 0, degree, 0, x + half_w, y + half_h, 0);
1048 _set_image_uv_by_axis_x(map, resizable_flip, degree);
1049 evas_map_util_3d_rotate(map, degree, 0, 0, x + half_w, y + half_h, 0);
1052 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, 10000);
1053 evas_object_map_enable_set(resizable_flip->front, EINA_TRUE);
1054 evas_object_map_enable_set(resizable_flip->back, EINA_TRUE);
1055 evas_object_map_set(obj, map);
1062 * Add ResizbleFlip effect.
1064 * @param front Front surface object
1065 * @param back Back surface object
1066 * @param axis Flipping Axis. X or Y
1067 * @param cw Flipping Direction. EINA_TRUE is clock-wise
1068 * @return Flip effect
1071 elm_fx_resizable_flip_add(Evas_Object *front, Evas_Object *back,
1072 Elm_Fx_Flip_Axis axis, Eina_Bool cw)
1074 Elm_Fx_ResizableFlip *resizable_flip;
1078 Evas_Coord front_x, front_y, front_w, front_h;
1080 Evas_Coord back_x, back_y, back_w, back_h;
1082 if (!front || !back)
1085 effect = calloc(1, sizeof(Elm_Effect));
1089 resizable_flip = calloc(1, sizeof(Elm_Fx_ResizableFlip));
1091 if (!resizable_flip)
1097 resizable_flip->front = front;
1098 resizable_flip->back = back;
1099 resizable_flip->cw = cw;
1100 resizable_flip->axis = axis;
1102 evas_object_geometry_get(resizable_flip->front, &front_x, &front_y, &front_w,
1104 evas_object_geometry_get(resizable_flip->back, &back_x, &back_y, &back_w,
1107 resizable_flip->from_pos.x = front_x;
1108 resizable_flip->from_pos.y = front_y;
1109 resizable_flip->to_pos.x = back_x - front_x;
1110 resizable_flip->to_pos.y = back_y - front_y;
1112 resizable_flip->from_size.x = front_w;
1113 resizable_flip->from_size.y = front_h;
1114 resizable_flip->to_size.x = back_w - front_w;
1115 resizable_flip->to_size.y = back_h - front_h;
1117 effect->begin_op = _elm_fx_resizable_flip_begin;
1118 effect->end_op = _elm_fx_resizable_flip_end;
1119 effect->animation_op = _elm_fx_resizable_flip_op;
1120 effect->user_data = resizable_flip;
1125 /////////////////////////////////////////////////////////////////////////////////////
1127 /////////////////////////////////////////////////////////////////////////////////////
1128 typedef struct _wipe Elm_Fx_Wipe;
1130 static void _elm_fx_wipe_op(void *data, Elm_Animator *animator, double frame);
1135 Elm_Fx_Wipe_Type type;
1136 Elm_Fx_Wipe_Dir dir;
1140 _elm_fx_wipe_begin(void *data, Eina_Bool auto_repeat, unsigned int repeat_cnt)
1142 Elm_Fx_Wipe *wipe = data;
1144 evas_object_show(wipe->obj);
1145 _elm_fx_wipe_op(data, NULL, 0);
1149 _elm_fx_wipe_end(void *data, Eina_Bool auto_repeat, unsigned int repeat_cnt)
1151 Elm_Fx_Wipe *wipe = data;
1153 evas_object_map_enable_set(wipe->obj, EINA_FALSE);
1157 _elm_fx_wipe_hide(Evas_Map * map, Elm_Fx_Wipe_Dir dir, float x, float y,
1158 float w, float h, float frame)
1164 case ELM_FX_WIPE_DIR_LEFT:
1165 w2 = w - (w * frame);
1167 evas_map_point_image_uv_set(map, 0, 0, 0);
1168 evas_map_point_image_uv_set(map, 1, w2, 0);
1169 evas_map_point_image_uv_set(map, 2, w2, h);
1170 evas_map_point_image_uv_set(map, 3, 0, h);
1171 evas_map_point_coord_set(map, 0, x, y, 0);
1172 evas_map_point_coord_set(map, 1, x + w2, y, 0);
1173 evas_map_point_coord_set(map, 2, x + w2, h2, 0);
1174 evas_map_point_coord_set(map, 3, x, h2, 0);
1176 case ELM_FX_WIPE_DIR_RIGHT:
1179 evas_map_point_image_uv_set(map, 0, w2, 0);
1180 evas_map_point_image_uv_set(map, 1, w, 0);
1181 evas_map_point_image_uv_set(map, 2, w, h);
1182 evas_map_point_image_uv_set(map, 3, w2, h);
1183 evas_map_point_coord_set(map, 0, x + w2, y, 0);
1184 evas_map_point_coord_set(map, 1, x + w, y, 0);
1185 evas_map_point_coord_set(map, 2, x + w, h2, 0);
1186 evas_map_point_coord_set(map, 3, x + w2, h2, 0);
1188 case ELM_FX_WIPE_DIR_UP:
1190 h2 = h - (h * frame);
1191 evas_map_point_image_uv_set(map, 0, 0, 0);
1192 evas_map_point_image_uv_set(map, 1, w, 0);
1193 evas_map_point_image_uv_set(map, 2, w, h2);
1194 evas_map_point_image_uv_set(map, 3, 0, h2);
1195 evas_map_point_coord_set(map, 0, x, y, 0);
1196 evas_map_point_coord_set(map, 1, w2, y, 0);
1197 evas_map_point_coord_set(map, 2, w2, h2, 0);
1198 evas_map_point_coord_set(map, 3, x, h2, 0);
1200 case ELM_FX_WIPE_DIR_DOWN:
1203 evas_map_point_image_uv_set(map, 0, 0, h2);
1204 evas_map_point_image_uv_set(map, 1, w, h2);
1205 evas_map_point_image_uv_set(map, 2, w, h);
1206 evas_map_point_image_uv_set(map, 3, 0, h);
1207 evas_map_point_coord_set(map, 0, x, y + h2, 0);
1208 evas_map_point_coord_set(map, 1, w2, y + h2, 0);
1209 evas_map_point_coord_set(map, 2, w2, y + h, 0);
1210 evas_map_point_coord_set(map, 3, x, y + h, 0);
1216 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, 10000);
1220 _elm_fx_wipe_show(Evas_Map *map, Elm_Fx_Wipe_Dir dir, float x, float y,
1221 float w, float h, float frame)
1227 case ELM_FX_WIPE_DIR_LEFT:
1228 w2 = (w - (w * frame));
1230 evas_map_point_image_uv_set(map, 0, w2, 0);
1231 evas_map_point_image_uv_set(map, 1, w, 0);
1232 evas_map_point_image_uv_set(map, 2, w, h);
1233 evas_map_point_image_uv_set(map, 3, w2, h);
1234 evas_map_point_coord_set(map, 0, x + w2, y, 0);
1235 evas_map_point_coord_set(map, 1, w, y, 0);
1236 evas_map_point_coord_set(map, 2, w, h2, 0);
1237 evas_map_point_coord_set(map, 3, x + w2, h2, 0);
1239 case ELM_FX_WIPE_DIR_RIGHT:
1242 evas_map_point_image_uv_set(map, 0, 0, 0);
1243 evas_map_point_image_uv_set(map, 1, w2, 0);
1244 evas_map_point_image_uv_set(map, 2, w2, h);
1245 evas_map_point_image_uv_set(map, 3, 0, h);
1246 evas_map_point_coord_set(map, 0, x, y, 0);
1247 evas_map_point_coord_set(map, 1, x + w2, y, 0);
1248 evas_map_point_coord_set(map, 2, x + w2, h2, 0);
1249 evas_map_point_coord_set(map, 3, x, h2, 0);
1251 case ELM_FX_WIPE_DIR_UP:
1253 h2 = (h - (h * frame));
1254 evas_map_point_image_uv_set(map, 0, 0, h2);
1255 evas_map_point_image_uv_set(map, 1, w, h2);
1256 evas_map_point_image_uv_set(map, 2, w, h);
1257 evas_map_point_image_uv_set(map, 3, 0, h);
1258 evas_map_point_coord_set(map, 0, x, y + h2, 0);
1259 evas_map_point_coord_set(map, 1, w2, y + h2, 0);
1260 evas_map_point_coord_set(map, 2, w2, y + h, 0);
1261 evas_map_point_coord_set(map, 3, x, y + h, 0);
1263 case ELM_FX_WIPE_DIR_DOWN:
1266 evas_map_point_image_uv_set(map, 0, 0, 0);
1267 evas_map_point_image_uv_set(map, 1, w, 0);
1268 evas_map_point_image_uv_set(map, 2, w, h2);
1269 evas_map_point_image_uv_set(map, 3, 0, h2);
1270 evas_map_point_coord_set(map, 0, x, y, 0);
1271 evas_map_point_coord_set(map, 1, w2, y, 0);
1272 evas_map_point_coord_set(map, 2, w2, y + h2, 0);
1273 evas_map_point_coord_set(map, 3, x, y + h2, 0);
1279 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, 10000);
1283 _elm_fx_wipe_op(void *data, Elm_Animator *animator, double frame)
1289 Evas_Coord _x, _y, _w, _h;
1291 map = evas_map_new(4);
1296 evas_map_smooth_set(map, EINA_TRUE);
1297 evas_object_geometry_get(wipe->obj, &_x, &_y, &_w, &_h);
1299 if (wipe->type == ELM_FX_WIPE_TYPE_SHOW)
1300 _elm_fx_wipe_show(map, wipe->dir, _x, _y, _w, _h, (float)frame);
1302 _elm_fx_wipe_hide(map, wipe->dir, _x, _y, _w, _h, (float)frame);
1304 evas_object_map_enable_set(wipe->obj, EINA_TRUE);
1305 evas_object_map_set(wipe->obj, map);
1314 * @param obj Evas_Object that effect is applying to
1315 * @param type Wipe type. Hide or show
1316 * @param dir Wipe Direction
1317 * @return Wipe Effect
1320 elm_fx_wipe_add(Evas_Object *obj, Elm_Fx_Wipe_Type type, Elm_Fx_Wipe_Dir dir)
1329 effect = calloc(1, sizeof(Elm_Effect));
1333 wipe = calloc(1, sizeof(Elm_Fx_Wipe));
1343 effect->begin_op = _elm_fx_wipe_begin;
1344 effect->end_op = _elm_fx_wipe_end;
1345 effect->animation_op = _elm_fx_wipe_op;
1346 effect->user_data = wipe;
1351 /////////////////////////////////////////////////////////////////////////////////////
1353 /////////////////////////////////////////////////////////////////////////////////////
1354 typedef struct _color Elm_Fx_Color;
1359 struct _unsigned_color
1361 unsigned int r, g, b, a;
1363 struct _signed_color
1370 _elm_fx_color_begin(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
1372 Elm_Fx_Color *color = data;
1374 evas_object_show(color->obj);
1378 _elm_fx_color_op(void *data, Elm_Animator *animator, double frame)
1380 Elm_Fx_Color *color;
1382 unsigned int r, g, b, a;
1385 r = (color->from.r + (int)((float)color->to.r * frame));
1386 g = (color->from.g + (int)((float)color->to.g * frame));
1387 b = (color->from.b + (int)((float)color->to.b * frame));
1388 a = (color->from.a + (int)((float)color->to.a * frame));
1390 evas_object_color_set(color->obj, r, g, b, a);
1398 * @param obj Evas_Object that effect is applying to
1399 * @param from_r RGB R when the effect begins
1400 * @param from_g RGB G when the effect begins
1401 * @param from_b RGB B when the effect begins
1402 * @param from_a RGB A when the effect begins
1403 * @param to_r RGB R to be
1404 * @param to_g RGB G to be
1405 * @param to_b RGB B to be
1406 * @param to_a RGB A to be
1407 * @return Color Effect
1410 elm_fx_color_add(Evas_Object *obj, unsigned int from_r, unsigned int from_g,
1411 unsigned int from_b, unsigned int from_a, unsigned int to_r,
1412 unsigned int to_g, unsigned int to_b, unsigned int to_a)
1416 Elm_Fx_Color *color;
1421 effect = calloc(1, sizeof(Elm_Effect));
1425 color = calloc(1, sizeof(Elm_Fx_Color));
1433 color->from.r = from_r;
1434 color->from.g = from_g;
1435 color->from.b = from_b;
1436 color->from.a = from_a;
1437 color->to.r = to_r - from_r;
1438 color->to.g = to_g - from_g;
1439 color->to.b = to_b - from_b;
1440 color->to.a = to_a - from_a;
1442 effect->begin_op = _elm_fx_color_begin;
1443 effect->animation_op = _elm_fx_color_op;
1444 effect->user_data = color;
1449 /////////////////////////////////////////////////////////////////////////////////////
1451 /////////////////////////////////////////////////////////////////////////////////////
1452 typedef struct _fade Elm_Fx_Fade;
1456 Evas_Object *before;
1458 struct _signed_color before_color, after_color;
1461 Eina_Bool inversed:1;
1465 _elm_fx_fade_begin(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
1467 Elm_Fx_Fade *fade = data;
1469 fade->inversed = EINA_FALSE;
1473 _elm_fx_fade_end(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
1475 Elm_Fx_Fade *fade = data;
1477 evas_object_color_set(fade->before, fade->before_color.r,
1478 fade->before_color.g, fade->before_color.b,
1479 fade->before_color.a);
1480 evas_object_color_set(fade->after, fade->after_color.r, fade->after_color.g,
1481 fade->after_color.b, fade->after_color.a);
1485 _elm_fx_fade_op(void *data, Elm_Animator *animator, double frame)
1495 if (!fade->inversed)
1497 evas_object_hide(fade->after);
1498 evas_object_show(fade->before);
1499 fade->inversed = EINA_TRUE;
1502 _frame = (1 - (frame * 2));
1504 evas_object_color_set(fade->before, fade->before_color.r * _frame,
1505 fade->before_color.g * _frame,
1506 fade->before_color.b * _frame,
1507 fade->before_color.a + fade->before_alpha * (1 -
1514 evas_object_hide(fade->before);
1515 evas_object_show(fade->after);
1516 fade->inversed = EINA_FALSE;
1519 _frame = ((frame - 0.5) * 2);
1521 evas_object_color_set(fade->after, fade->after_color.r * _frame,
1522 fade->after_color.g * _frame,
1523 fade->after_color.b * _frame,
1524 fade->after_color.a + fade->after_alpha * (1 -
1535 * @param before Evas Object before fade in
1536 * @param after Evas Object after fade out
1537 * @return Fade Effect
1540 elm_fx_fade_add(Evas_Object *before, Evas_Object *after)
1546 if ((!before) && (!after))
1549 effect = calloc(1, sizeof(Elm_Effect));
1553 fade = calloc(1, sizeof(Elm_Fx_Fade));
1561 evas_object_color_get(before, &fade->before_color.r, &fade->before_color.g,
1562 &fade->before_color.b, &fade->before_color.a);
1563 evas_object_color_get(after, &fade->after_color.r, &fade->after_color.g,
1564 &fade->after_color.b, &fade->after_color.a);
1566 fade->before = before;
1567 fade->after = after;
1568 fade->before_alpha = (255 - fade->before_color.a);
1569 fade->after_alpha = (255 - fade->after_color.a);
1571 effect->begin_op = _elm_fx_fade_begin;
1572 effect->end_op = _elm_fx_fade_end;
1573 effect->animation_op = _elm_fx_fade_op;
1574 effect->user_data = fade;
1579 /////////////////////////////////////////////////////////////////////////////////////
1581 /////////////////////////////////////////////////////////////////////////////////////
1582 typedef struct _blend Elm_Fx_Blend;
1586 Evas_Object *before;
1588 struct _signed_color from, to;
1592 _elm_fx_blend_begin(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
1594 Elm_Fx_Blend *blend = data;
1596 evas_object_show(blend->before);
1600 _elm_fx_blend_end(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
1602 Elm_Fx_Blend *blend = data;
1604 evas_object_color_set(blend->before, blend->from.r, blend->from.g,
1605 blend->from.b, blend->from.a);
1606 evas_object_color_set(blend->after, blend->to.r, blend->to.g, blend->to.b,
1609 evas_object_hide(blend->before);
1611 evas_object_hide(blend->after);
1615 _elm_fx_blend_op(void *data, Elm_Animator *animator, double frame)
1617 Elm_Fx_Blend *blend = data;
1619 evas_object_show(blend->after);
1620 evas_object_color_set(blend->before, (int)(blend->from.r * (1 - frame)),
1621 (int)(blend->from.g * (1 - frame)),
1622 (int)(blend->from.b * (1 - frame)),
1623 (int)(blend->from.a * (1 - frame)));
1624 evas_object_color_set(blend->after, (int)(blend->to.r * frame),
1625 (int)(blend->to.g * frame), (int)(blend->to.b * frame),
1626 (int)(blend->to.a * frame));
1634 * @param before Evas Object before blending
1635 * @param after Evas Object after blending
1636 * @return Blend Effect
1639 elm_fx_blend_add(Evas_Object *before, Evas_Object *after)
1643 Elm_Fx_Blend *blend;
1645 if ((!before) && (!after))
1648 effect = calloc(1, sizeof(Elm_Effect));
1652 blend = calloc(1, sizeof(Elm_Fx_Blend));
1659 blend->before = before;
1660 blend->after = after;
1661 evas_object_color_get(before, &blend->from.r, &blend->from.g, &blend->from.b,
1663 evas_object_color_get(after, &blend->to.r, &blend->to.g, &blend->to.b,
1666 effect->begin_op = _elm_fx_blend_begin;
1667 effect->end_op = _elm_fx_blend_end;
1668 effect->animation_op = _elm_fx_blend_op;
1669 effect->user_data = blend;
1674 /////////////////////////////////////////////////////////////////////////////////////
1676 /////////////////////////////////////////////////////////////////////////////////////
1677 typedef struct _rotation Elm_Fx_Rotation;
1687 _elm_fx_rotation_begin(void *data, Eina_Bool auto_reverse,
1688 unsigned int repeat_cnt)
1690 Elm_Fx_Rotation *rotation = data;
1692 evas_object_show(rotation->obj);
1696 _elm_fx_rotation_end(void *data, Eina_Bool auto_reverse,
1697 unsigned int repeat_cnt)
1699 Elm_Fx_Rotation *rotation = data;
1701 evas_object_map_enable_set(rotation->obj, EINA_FALSE);
1705 _elm_fx_rotation_op(void *data, Elm_Animator *animator, double frame)
1707 Elm_Fx_Rotation *rotation;
1711 Evas_Coord x, y, w, h;
1715 float half_w, half_h;
1717 map = evas_map_new(4);
1723 evas_map_smooth_set(map, EINA_TRUE);
1724 evas_map_util_points_populate_from_object_full(map, rotation->obj, 0);
1725 degree = rotation->from + (float)(frame * rotation->to);
1730 evas_object_geometry_get(rotation->obj, &x, &y, &w, &h);
1732 half_w = (float)w *0.5;
1734 half_h = (float)h *0.5;
1736 evas_map_util_3d_rotate(map, 0, 0, degree, x + half_w, y + half_h, 0);
1737 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, 10000);
1738 evas_object_map_enable_set(rotation->obj, EINA_TRUE);
1739 evas_object_map_set(rotation->obj, map);
1746 * Add Rotation Effect
1748 * @param obj Evas_Object that effect is applying to
1749 * @param from degree Degree when effect begins
1750 * @param to_degree Degree when effect is done
1751 * @param cw Rotation Direction. EINA_TRUE is clock wise
1752 * @return Rotation effect
1755 elm_fx_rotation_add(Evas_Object *obj, float from_degree, float to_degree,
1760 Elm_Fx_Rotation *rotation;
1765 effect = calloc(1, sizeof(Elm_Effect));
1769 rotation = calloc(1, sizeof(Elm_Fx_Rotation));
1777 rotation->obj = obj;
1778 rotation->from = from_degree;
1779 rotation->to = to_degree - from_degree;
1782 effect->begin_op = _elm_fx_rotation_begin;
1783 effect->end_op = _elm_fx_rotation_end;
1784 effect->animation_op = _elm_fx_rotation_op;
1785 effect->user_data = rotation;
1790 /////////////////////////////////////////////////////////////////////////////////////
1791 // ImageAnimation FX
1792 /////////////////////////////////////////////////////////////////////////////////////
1793 typedef struct _image_animation Elm_Fx_Image_Animation;
1795 struct _image_animation
1804 _elm_fx_imageanimation_op(void *data, Elm_Animator *animator, double frame)
1806 Elm_Fx_Image_Animation *image_animation = (Elm_Fx_Image_Animation *) data;
1808 if (!image_animation->obj)
1810 image_animation->count = floor(frame * image_animation->item_num);
1811 elm_icon_file_set(image_animation->obj,
1812 image_animation->images[image_animation->count], NULL);
1818 * Add ImageAnimation effect.
1820 * @param images Images for animation.
1821 * @return ImageAnimation Effect.
1824 elm_fx_imageanimation_add(Evas_Object *obj, const char **images,
1825 unsigned int item_num)
1829 Elm_Fx_Image_Animation *image_animation;
1831 if (!images || !(*images))
1834 effect = calloc(1, sizeof(Elm_Effect));
1838 image_animation = calloc(1, sizeof(Elm_Fx_Image_Animation));
1840 if (!image_animation)
1846 image_animation->obj = obj;
1847 image_animation->images = (char **)images;
1848 image_animation->count = 0;
1849 image_animation->item_num = item_num;
1851 effect->animation_op = _elm_fx_imageanimation_op;
1852 effect->user_data = image_animation;