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 void (*del_op) (void* data);
30 unsigned int shared_cnt;
34 static Evas_Object *_create_block_rect(Evas_Object *parent);
35 static void _transit_animate_cb(void *data, Elm_Animator *animator,
37 static void _transit_fx_begin(Elm_Transit *transit);
38 static void _transit_fx_end(Elm_Transit *transit);
39 static void _transit_complete_cb(void *data);
40 static void _transit_fx_del(Elm_Effect *effect);
41 //static void _transit_parent_del(void *data);
45 _animator_parent_del(void *data)
47 Elm_Transit *transit = data;
48 elm_transit_del(data);
53 _create_block_rect(Evas_Object *parent)
59 rect = evas_object_rectangle_add(evas_object_evas_get(parent));
60 evas_output_size_get(evas_object_evas_get(parent), &w, &h);
61 evas_object_resize(rect, w, h);
62 evas_object_color_set(rect, 0, 0, 0, 0);
67 _transit_animate_cb(void *data, Elm_Animator *animator, double frame)
73 Elm_Transit *transit = data;
75 EINA_LIST_FOREACH(transit->effect_list, elist, effect)
77 effect->animation_op(effect->user_data, animator, frame);
82 _transit_fx_begin(Elm_Transit *transit)
88 Eina_Bool auto_reverse;
90 unsigned int repeat_cnt;
92 auto_reverse = elm_animator_auto_reverse_get(transit->animator);
93 repeat_cnt = elm_animator_repeat_get(transit->animator);
95 EINA_LIST_FOREACH(transit->effect_list, elist, effect)
98 effect->begin_op(effect->user_data, auto_reverse, repeat_cnt);
103 _transit_fx_end(Elm_Transit *transit)
109 Eina_Bool auto_reverse;
111 unsigned int repeat_cnt;
113 auto_reverse = elm_animator_auto_reverse_get(transit->animator);
114 repeat_cnt = elm_animator_repeat_get(transit->animator);
116 EINA_LIST_FOREACH(transit->effect_list, elist, effect)
119 effect->end_op(effect->user_data, auto_reverse, repeat_cnt);
124 _transit_complete_cb(void *data)
126 Elm_Transit *transit = (Elm_Transit *) data;
128 evas_render(evas_object_evas_get(transit->parent));
130 _transit_fx_end(transit);
132 if (transit->block_rect)
133 evas_object_hide(transit->block_rect);
135 if (transit->completion_op)
136 transit->completion_op(transit->completion_arg, transit);
138 if (transit->reserved_del)
140 transit->reserved_del = EINA_FALSE;
141 elm_transit_del(transit);
146 _transit_fx_del(Elm_Effect *effect)
151 --effect->shared_cnt;
153 if (effect->shared_cnt > 0)
157 (*effect->del_op)(effect->user_data);
159 if (effect->user_data)
160 free(effect->user_data);
165 * Set the event blocked when transit is operating.
167 * @param transit Transit object
168 * @param disabled Disable or enable
173 elm_transit_event_block_disabled_set(Elm_Transit *transit, Eina_Bool disabled)
180 if (transit->block_rect)
182 evas_object_del(transit->block_rect);
183 transit->block_rect = NULL;
188 if (transit->block_rect == NULL)
189 transit->block_rect = _create_block_rect(transit->parent);
194 * Get the value of event blockd status.
196 * @param transit Transit
197 * @return EINA_TRUE, when event block is disabled
202 elm_transit_event_block_disabled_get(Elm_Transit *transit)
206 return transit->block_rect ? EINA_TRUE : EINA_FALSE;
210 * Remove effect from transit.
212 * @param transit Transit
213 * @param effect Effect to be removed
214 * @return EINA_TRUE, if the effect is removed
215 * @warning If removed effect does not inserted in any transit, it will be deleted.
220 elm_transit_fx_remove(Elm_Transit *transit, Elm_Effect *effect)
229 EINA_LIST_FOREACH(transit->effect_list, elist, _effect)
231 if (_effect == effect)
233 transit->effect_list =
234 eina_list_remove(transit->effect_list, _effect);
235 _transit_fx_del(_effect);
243 * Remove all current inserted effects.
245 * @param transit Transit
250 elm_transit_fx_clear(Elm_Transit *transit)
259 EINA_LIST_FOREACH(transit->effect_list, elist, effect)
261 transit->effect_list = eina_list_remove(transit->effect_list, effect);
262 _transit_fx_del(effect);
267 * Get the list of current inseted effects.
269 * @param transit Transit
270 * @return Effect list
274 EAPI const Eina_List *
275 elm_transit_fx_get(Elm_Transit *transit)
279 return transit->effect_list;
283 * Set the user-callback function when the transit operation is done.
285 * @param transit Transit
286 * @param op Callback function pointer
287 * @param data Callback funtion user data
292 elm_transit_completion_callback_set(Elm_Transit *transit,
293 void (*op) (void *data,
294 Elm_Transit *transit),
299 transit->completion_op = op;
300 transit->completion_arg = data;
306 * @param transit Transit to be deleted
311 elm_transit_del(Elm_Transit *transit)
315 if (elm_animator_operating_get(transit->animator))
317 transit->reserved_del = EINA_TRUE;
321 if (transit->block_rect)
322 evas_object_del(transit->block_rect);
324 elm_animator_del(transit->animator);
325 elm_transit_fx_clear(transit);
327 // if(transit->parent)
329 // evas_object_event_callback_del(transit->parent, EVAS_CALLBACK_DEL, _transit_parent_del);
336 * Set the transit animation acceleration style.
338 * @param transit Transit
339 * @param cs Curve style(Please refer elm_animator_curve_style_set)
344 elm_transit_curve_style_set(Elm_Transit *transit, Elm_Animator_Curve_Style cs)
348 elm_animator_curve_style_set(transit->animator, cs);
355 * @param parent Parent object
361 elm_transit_add(Evas_Object *parent)
363 Elm_Transit *transit = calloc(1, sizeof(Elm_Transit));
368 transit->animator = elm_animator_add(parent);
370 if (!transit->animator)
376 transit->parent = parent;
377 elm_animator_operation_callback_set(transit->animator, _transit_animate_cb,
379 elm_animator_completion_callback_set(transit->animator, _transit_complete_cb,
381 elm_transit_event_block_disabled_set(transit, EINA_FALSE);
385 evas_object_event_callback_add(parent, EVAS_CALLBACK_DEL, _transit_parent_del,
393 * Set reverse effect automatically.
395 * @param transit Transit
396 * @param reverse EINA_TRUE is reverse.
401 elm_transit_auto_reverse_set(Elm_Transit *transit, Eina_Bool reverse)
405 elm_animator_auto_reverse_set(transit->animator, reverse);
409 * Insert an effect into the transit.
411 * @param transit Transit
412 * @param effect Effect to be inserted
413 * @return EINA_TRUE is success
418 elm_transit_fx_insert(Elm_Transit *transit, Elm_Effect *effect)
427 EINA_LIST_FOREACH(transit->effect_list, elist, _effect)
429 if (_effect == effect)
433 ++effect->shared_cnt;
434 transit->effect_list = eina_list_append(transit->effect_list, effect);
440 * Set the transit repeat count. Effect will be repeated by repeat count.
442 * @param transit Transit
443 * @param repeat Repeat count
448 elm_transit_repeat_set(Elm_Transit *transit, unsigned int repeat)
452 elm_animator_repeat_set(transit->animator, repeat);
456 * Stop the current transit, if the transit is operating.
458 * @param transit Transit
463 elm_transit_stop(Elm_Transit *transit)
467 elm_animator_stop(transit->animator);
471 * Run the all the inserted effects.
473 * @param transit Transit
474 * @param duration Transit time in seconds
479 elm_transit_run(Elm_Transit *transit, double duration)
483 _transit_fx_begin(transit);
484 elm_animator_duration_set(transit->animator, duration);
487 if (transit->block_rect)
488 evas_object_show(transit->block_rect);
490 elm_animator_animate(transit->animator);
492 //If failed to animate.
493 if (!elm_animator_operating_get(transit->animator))
495 if (transit->block_rect)
496 evas_object_hide(transit->block_rect);
497 _transit_fx_end(transit);
501 /////////////////////////////////////////////////////////////////////////////////////
503 /////////////////////////////////////////////////////////////////////////////////////
504 typedef struct _resizing Elm_Fx_Resizing;
505 static void _elm_fx_resizing_op(void *data, Elm_Animator *animator,
507 static void _elm_fx_resizing_begin(void *data, Eina_Bool auto_reverse,
508 unsigned int repeat_cnt);
520 _elm_fx_resizing_begin(void *data, Eina_Bool auto_reverse,
521 unsigned int repeat_cnt)
523 Elm_Fx_Resizing *resizing = data;
525 evas_object_show(resizing->obj);
526 evas_object_resize(resizing->obj, resizing->from.w, resizing->from.h);
530 _elm_fx_resizing_op(void *data, Elm_Animator *animator, double frame)
534 Elm_Fx_Resizing *resizing = data;
536 w = resizing->from.w + (Evas_Coord) ((float)resizing->to.h * (float)frame);
537 h = resizing->from.h + (Evas_Coord) ((float)resizing->to.w * (float)frame);
538 evas_object_resize(resizing->obj, w, h);
542 * Add Resizing effect.
544 * @param obj Evas_Object that effect is applying to
545 * @param from_w Object width size when effect begins
546 * @param from_h Object height size when effect begins
547 * @param to_w Object width size when effect ends
548 * @param to_h Object height size when effect ends
549 * @return Resizing effect
554 elm_fx_resizing_add(Evas_Object *obj, Evas_Coord from_w, Evas_Coord from_h,
555 Evas_Coord to_w, Evas_Coord to_h)
559 Elm_Fx_Resizing *resizing;
564 effect = calloc(1, sizeof(Elm_Effect));
568 resizing = calloc(1, sizeof(Elm_Fx_Resizing));
576 resizing->from.w = from_w;
577 resizing->from.h = from_h;
578 resizing->to.w = to_w - from_w;
579 resizing->to.h = to_h - from_h;
581 effect->begin_op = _elm_fx_resizing_begin;
582 effect->animation_op = _elm_fx_resizing_op;
583 effect->user_data = resizing;
588 /////////////////////////////////////////////////////////////////////////////////////
590 /////////////////////////////////////////////////////////////////////////////////////
591 typedef struct _translation Elm_Fx_Translation;
592 static void _elm_fx_translation_op(void *data, Elm_Animator *animator,
594 static void _elm_fx_translation_begin(void *data, Eina_Bool auto_reverse,
595 unsigned int repeat_cnt);
596 static void _elm_fx_translation_end(void *data, Eina_Bool auto_reverse,
597 unsigned int repeat_cnt);
609 _elm_fx_translation_begin(void *data, Eina_Bool auto_reverse,
610 unsigned int repeat_cnt)
612 Elm_Fx_Translation *translation = data;
614 evas_object_show(translation->obj);
615 evas_object_move(translation->obj, translation->from.x, translation->from.y);
619 _elm_fx_translation_end(void *data, Eina_Bool auto_reverse,
620 unsigned int repeat_cnt)
622 Elm_Fx_Translation *translation = data;
624 evas_object_move(translation->obj, translation->from.x + translation->to.x,
625 translation->from.y + translation->to.y);
629 _elm_fx_translation_op(void *data, Elm_Animator *animator, double frame)
633 Elm_Fx_Translation *translation = data;
635 x = translation->from.x +
636 (Evas_Coord) ((float)translation->to.x * (float)frame);
637 y = translation->from.y +
638 (Evas_Coord) ((float)translation->to.y * (float)frame);
639 evas_object_move(translation->obj, x, y);
643 * Add Translation effect.
645 * @param obj Evas_Object that effect is applying to
646 * @param from_x Position X when effect begins
647 * @param from_y Position Y when effect begins
648 * @param to_x Position X when effect ends
649 * @param to_y Position Y when effect ends
650 * @return Translation effect
655 elm_fx_translation_add(Evas_Object *obj, Evas_Coord from_x, Evas_Coord from_y,
656 Evas_Coord to_x, Evas_Coord to_y)
660 Elm_Fx_Translation *translation;
665 effect = calloc(1, sizeof(Elm_Effect));
669 translation = calloc(1, sizeof(Elm_Fx_Translation));
677 translation->obj = obj;
678 translation->from.x = from_x;
679 translation->from.y = from_y;
680 translation->to.x = to_x - from_x;
681 translation->to.y = to_y - from_y;
683 effect->begin_op = _elm_fx_translation_begin;
684 effect->end_op = _elm_fx_translation_end;
685 effect->animation_op = _elm_fx_translation_op;
686 effect->user_data = translation;
691 /////////////////////////////////////////////////////////////////////////////////////
693 /////////////////////////////////////////////////////////////////////////////////////
694 typedef struct _zoom Elm_Fx_Zoom;
695 static void _elm_fx_zoom_op(void *data, Elm_Animator * animator,
697 static void _elm_fx_zoom_begin(void *data, Eina_Bool reverse,
698 unsigned int repeat);
699 static void _elm_fx_zoom_end(void *data, Eina_Bool reverse,
700 unsigned int repeat);
709 _elm_fx_zoom_begin(void *data, Eina_Bool reverse, unsigned int repeat)
711 Elm_Fx_Zoom *zoom = data;
713 evas_object_show(zoom->obj);
714 _elm_fx_zoom_op(data, NULL, 0);
718 _elm_fx_zoom_end(void *data, Eina_Bool reverse, unsigned int repeat)
720 Elm_Fx_Zoom *zoom = data;
722 evas_object_map_enable_set(zoom->obj, EINA_FALSE);
726 _elm_fx_zoom_op(void *data, Elm_Animator *animator, double frame)
732 Evas_Coord x, y, w, h;
734 map = evas_map_new(4);
739 evas_object_geometry_get(zoom->obj, &x, &y, &w, &h);
740 evas_map_smooth_set(map, EINA_TRUE);
741 evas_map_util_points_populate_from_object_full(map, zoom->obj,
744 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, 10000);
745 evas_object_map_set(zoom->obj, map);
746 evas_object_map_enable_set(zoom->obj, EINA_TRUE);
753 * @param obj Evas_Object that effect is applying to
754 * @param from_rate Scale rate when effect begins (1 is current rate)
755 * @param to_rate Scale rate when effect ends
756 * @return Zoom effect
761 elm_fx_zoom_add(Evas_Object *obj, float from_rate, float to_rate)
770 effect = calloc(1, sizeof(Elm_Effect));
774 zoom = calloc(1, sizeof(Elm_Fx_Zoom));
782 zoom->from = (10000 - (from_rate * 10000)) * (1 / from_rate);
783 zoom->to = ((10000 - (to_rate * 10000)) * (1 / to_rate)) - zoom->from;
784 effect->begin_op = _elm_fx_zoom_begin;
785 effect->end_op = _elm_fx_zoom_end;
786 effect->animation_op = _elm_fx_zoom_op;
787 effect->user_data = zoom;
793 /////////////////////////////////////////////////////////////////////////////////////
795 /////////////////////////////////////////////////////////////////////////////////////
796 typedef struct _flip Elm_Fx_Flip;
797 static void _elm_fx_flip_op(void *data, Elm_Animator *animator,
799 static void _elm_fx_flip_end(void *data, Eina_Bool auto_reverse,
800 unsigned int repeat_cnt);
806 Elm_Fx_Flip_Axis axis;
811 _elm_fx_flip_end(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
813 Elm_Fx_Flip *flip = data;
815 evas_object_map_enable_set(flip->front, EINA_FALSE);
816 evas_object_map_enable_set(flip->back, EINA_FALSE);
820 _elm_fx_flip_op(void *data, Elm_Animator *animator, double frame)
830 Evas_Coord x, y, w, h;
832 map = evas_map_new(4);
839 degree = (float)(frame * 180);
841 degree = (float)(frame * -180);
843 if (degree < 90 && degree > -90)
846 evas_object_hide(flip->back);
847 evas_object_show(flip->front);
852 evas_object_hide(flip->front);
853 evas_object_show(flip->back);
856 evas_map_smooth_set(map, EINA_TRUE);
857 evas_map_util_points_populate_from_object_full(map, obj, 0);
858 evas_object_geometry_get(obj, &x, &y, &w, &h);
859 Evas_Coord half_w = (w / 2);
861 Evas_Coord half_h = (h / 2);
863 if (flip->axis == ELM_FX_FLIP_AXIS_Y)
865 if ((degree >= 90) || (degree <= -90))
867 evas_map_point_image_uv_set(map, 0, w, 0);
868 evas_map_point_image_uv_set(map, 1, 0, 0);
869 evas_map_point_image_uv_set(map, 2, 0, h);
870 evas_map_point_image_uv_set(map, 3, w, h);
872 evas_map_util_3d_rotate(map, 0, degree, 0, x + half_w, y + half_h, 0);
876 if ((degree >= 90) || (degree <= -90))
878 evas_map_point_image_uv_set(map, 0, 0, h);
879 evas_map_point_image_uv_set(map, 1, w, h);
880 evas_map_point_image_uv_set(map, 2, w, 0);
881 evas_map_point_image_uv_set(map, 3, 0, 0);
883 evas_map_util_3d_rotate(map, degree, 0, 0, x + half_w, y + half_h, 0);
885 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, 10000);
886 evas_object_map_enable_set(flip->front, EINA_TRUE);
887 evas_object_map_enable_set(flip->back, EINA_TRUE);
888 evas_object_map_set(obj, map);
895 * @param front Front surface object
896 * @param back Back surface object
897 * @param axis Flipping Axis(X or Y)
898 * @param cw Flipping Direction. EINA_TRUE is clock-wise
899 * @return Flip effect
904 elm_fx_flip_add(Evas_Object *front, Evas_Object *back, Elm_Fx_Flip_Axis axis,
911 if ((!front) || (!back))
914 effect = calloc(1, sizeof(Elm_Effect));
918 flip = calloc(1, sizeof(Elm_Fx_Flip));
930 effect->end_op = _elm_fx_flip_end;
931 effect->animation_op = _elm_fx_flip_op;
932 effect->user_data = flip;
937 /////////////////////////////////////////////////////////////////////////////////////
939 /////////////////////////////////////////////////////////////////////////////////////
940 typedef struct _resizable_flip Elm_Fx_ResizableFlip;
941 static void _elm_fx_resizable_flip_begin(void *data, Eina_Bool reverse,
942 unsigned int repeat);
943 static void _elm_fx_resizable_flip_end(void *data, Eina_Bool auto_reverse,
944 unsigned int repeat_cnt);
945 static void _elm_fx_resizable_flip_op(void *data, Elm_Animator *animator,
947 static void _set_image_uv_by_axis_y(Evas_Map *map, Elm_Fx_ResizableFlip *flip,
949 static void _set_image_uv_by_axis_x(Evas_Map *map, Elm_Fx_ResizableFlip *flip,
952 struct _resizable_flip
956 Elm_Fx_Flip_Axis axis;
960 } from_pos, from_size, to_pos, to_size;
965 _elm_fx_resizable_flip_begin(void *data, Eina_Bool reverse, unsigned int repeat)
967 Elm_Fx_ResizableFlip *resizable_flip = data;
969 evas_object_show(resizable_flip->front);
970 _elm_fx_resizable_flip_op(data, NULL, 0);
974 _elm_fx_resizable_flip_end(void *data, Eina_Bool auto_reverse,
975 unsigned int repeat_cnt)
977 Elm_Fx_ResizableFlip *resizable_flip = data;
979 evas_object_map_enable_set(resizable_flip->front, EINA_FALSE);
980 evas_object_map_enable_set(resizable_flip->back, EINA_FALSE);
984 _set_image_uv_by_axis_y(Evas_Map *map, Elm_Fx_ResizableFlip *flip,
987 if ((degree >= 90) || (degree <= -90))
989 evas_map_point_image_uv_set(map, 0,
990 (flip->from_size.x * 2) + flip->to_size.x,
992 evas_map_point_image_uv_set(map, 1, 0, 0);
993 evas_map_point_image_uv_set(map, 2, 0,
994 (flip->from_size.y * 2) + flip->to_size.y);
995 evas_map_point_image_uv_set(map, 3,
996 (flip->from_size.x * 2) + flip->to_size.x,
997 (flip->from_size.y * 2) + flip->to_size.y);
1001 evas_map_point_image_uv_set(map, 0, 0, 0);
1002 evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
1003 evas_map_point_image_uv_set(map, 2, flip->from_size.x,
1005 evas_map_point_image_uv_set(map, 3, 0, flip->to_size.y);
1010 _set_image_uv_by_axis_x(Evas_Map *map, Elm_Fx_ResizableFlip *flip,
1013 if ((degree >= 90) || (degree <= -90))
1015 evas_map_point_image_uv_set(map, 0, 0,
1016 (flip->from_size.y * 2) + flip->to_size.y);
1017 evas_map_point_image_uv_set(map, 1,
1018 (flip->from_size.x * 2) + flip->to_size.x,
1019 (flip->from_size.y * 2) + flip->to_size.y);
1020 evas_map_point_image_uv_set(map, 2,
1021 (flip->from_size.x * 2) + flip->to_size.x,
1023 evas_map_point_image_uv_set(map, 3, 0, 0);
1027 evas_map_point_image_uv_set(map, 0, 0, 0);
1028 evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
1029 evas_map_point_image_uv_set(map, 2, flip->from_size.x,
1031 evas_map_point_image_uv_set(map, 3, 0, flip->to_size.y);
1036 _elm_fx_resizable_flip_op(void *data, Elm_Animator *animator, double frame)
1038 Elm_Fx_ResizableFlip *resizable_flip;
1048 Evas_Coord half_w, half_h;
1050 map = evas_map_new(4);
1054 resizable_flip = data;
1056 if (resizable_flip->cw)
1057 degree = (float)(frame * 180);
1059 degree = (float)(frame * -180);
1061 if ((degree < 90) && (degree > -90))
1063 obj = resizable_flip->front;
1064 evas_object_hide(resizable_flip->back);
1065 evas_object_show(resizable_flip->front);
1069 obj = resizable_flip->back;
1070 evas_object_hide(resizable_flip->front);
1071 evas_object_show(resizable_flip->back);
1074 evas_map_smooth_set(map, EINA_TRUE);
1076 x = resizable_flip->from_pos.x + (resizable_flip->to_pos.x * frame);
1077 y = resizable_flip->from_pos.y + (resizable_flip->to_pos.y * frame);
1078 w = resizable_flip->from_size.x + (resizable_flip->to_size.x * frame);
1079 h = resizable_flip->from_size.y + (resizable_flip->to_size.y * frame);
1080 evas_map_point_coord_set(map, 0, x, y, 0);
1081 evas_map_point_coord_set(map, 1, x + w, y, 0);
1082 evas_map_point_coord_set(map, 2, x + w, y + h, 0);
1083 evas_map_point_coord_set(map, 3, x, y + h, 0);
1085 half_w = (Evas_Coord) (w / 2);
1086 half_h = (Evas_Coord) (h / 2);
1088 if (resizable_flip->axis == ELM_FX_FLIP_AXIS_Y)
1090 _set_image_uv_by_axis_y(map, resizable_flip, degree);
1091 evas_map_util_3d_rotate(map, 0, degree, 0, x + half_w, y + half_h, 0);
1095 _set_image_uv_by_axis_x(map, resizable_flip, degree);
1096 evas_map_util_3d_rotate(map, degree, 0, 0, x + half_w, y + half_h, 0);
1099 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, 10000);
1100 evas_object_map_enable_set(resizable_flip->front, EINA_TRUE);
1101 evas_object_map_enable_set(resizable_flip->back, EINA_TRUE);
1102 evas_object_map_set(obj, map);
1107 * Add ResizbleFlip effect. the size of each surface objects are interpolated automatically.
1109 * @param front Front surface object
1110 * @param back Back surface object
1111 * @param axis Flipping Axis.(X or Y)
1112 * @param cw Flipping Direction. EINA_TRUE is clock-wise
1113 * @return Flip effect
1118 elm_fx_resizable_flip_add(Evas_Object *front, Evas_Object *back,
1119 Elm_Fx_Flip_Axis axis, Eina_Bool cw)
1121 Elm_Fx_ResizableFlip *resizable_flip;
1125 Evas_Coord front_x, front_y, front_w, front_h;
1127 Evas_Coord back_x, back_y, back_w, back_h;
1129 if (!front || !back)
1132 effect = calloc(1, sizeof(Elm_Effect));
1136 resizable_flip = calloc(1, sizeof(Elm_Fx_ResizableFlip));
1138 if (!resizable_flip)
1144 resizable_flip->front = front;
1145 resizable_flip->back = back;
1146 resizable_flip->cw = cw;
1147 resizable_flip->axis = axis;
1149 evas_object_geometry_get(resizable_flip->front, &front_x, &front_y, &front_w,
1151 evas_object_geometry_get(resizable_flip->back, &back_x, &back_y, &back_w,
1154 resizable_flip->from_pos.x = front_x;
1155 resizable_flip->from_pos.y = front_y;
1156 resizable_flip->to_pos.x = back_x - front_x;
1157 resizable_flip->to_pos.y = back_y - front_y;
1159 resizable_flip->from_size.x = front_w;
1160 resizable_flip->from_size.y = front_h;
1161 resizable_flip->to_size.x = back_w - front_w;
1162 resizable_flip->to_size.y = back_h - front_h;
1164 effect->begin_op = _elm_fx_resizable_flip_begin;
1165 effect->end_op = _elm_fx_resizable_flip_end;
1166 effect->animation_op = _elm_fx_resizable_flip_op;
1167 effect->user_data = resizable_flip;
1172 /////////////////////////////////////////////////////////////////////////////////////
1174 /////////////////////////////////////////////////////////////////////////////////////
1175 typedef struct _wipe Elm_Fx_Wipe;
1176 static void _elm_fx_wipe_op(void *data, Elm_Animator *animator,
1178 static void _elm_fx_wipe_begin(void *data, Eina_Bool auto_repeat,
1179 unsigned int repeat_cnt);
1180 static void _elm_fx_wipe_end(void *data, Eina_Bool auto_repeat,
1181 unsigned int repeat_cnt);
1182 static void _elm_fx_wipe_hide(Evas_Map * map, Elm_Fx_Wipe_Dir dir,
1183 float x, float y, float w, float h, float frame);
1184 static void _elm_fx_wipe_show(Evas_Map *map, Elm_Fx_Wipe_Dir dir,
1185 float x, float y, float w, float h, float frame);
1190 Elm_Fx_Wipe_Type type;
1191 Elm_Fx_Wipe_Dir dir;
1195 _elm_fx_wipe_begin(void *data, Eina_Bool auto_repeat, unsigned int repeat_cnt)
1197 Elm_Fx_Wipe *wipe = data;
1199 evas_object_show(wipe->obj);
1200 _elm_fx_wipe_op(data, NULL, 0);
1204 _elm_fx_wipe_end(void *data, Eina_Bool auto_repeat, unsigned int repeat_cnt)
1206 Elm_Fx_Wipe *wipe = data;
1208 evas_object_map_enable_set(wipe->obj, EINA_FALSE);
1212 _elm_fx_wipe_hide(Evas_Map * map, Elm_Fx_Wipe_Dir dir, float x, float y,
1213 float w, float h, float frame)
1219 case ELM_FX_WIPE_DIR_LEFT:
1220 w2 = w - (w * frame);
1222 evas_map_point_image_uv_set(map, 0, 0, 0);
1223 evas_map_point_image_uv_set(map, 1, w2, 0);
1224 evas_map_point_image_uv_set(map, 2, w2, h);
1225 evas_map_point_image_uv_set(map, 3, 0, h);
1226 evas_map_point_coord_set(map, 0, x, y, 0);
1227 evas_map_point_coord_set(map, 1, x + w2, y, 0);
1228 evas_map_point_coord_set(map, 2, x + w2, h2, 0);
1229 evas_map_point_coord_set(map, 3, x, h2, 0);
1231 case ELM_FX_WIPE_DIR_RIGHT:
1234 evas_map_point_image_uv_set(map, 0, w2, 0);
1235 evas_map_point_image_uv_set(map, 1, w, 0);
1236 evas_map_point_image_uv_set(map, 2, w, h);
1237 evas_map_point_image_uv_set(map, 3, w2, h);
1238 evas_map_point_coord_set(map, 0, x + w2, y, 0);
1239 evas_map_point_coord_set(map, 1, x + w, y, 0);
1240 evas_map_point_coord_set(map, 2, x + w, h2, 0);
1241 evas_map_point_coord_set(map, 3, x + w2, h2, 0);
1243 case ELM_FX_WIPE_DIR_UP:
1245 h2 = h - (h * frame);
1246 evas_map_point_image_uv_set(map, 0, 0, 0);
1247 evas_map_point_image_uv_set(map, 1, w, 0);
1248 evas_map_point_image_uv_set(map, 2, w, h2);
1249 evas_map_point_image_uv_set(map, 3, 0, h2);
1250 evas_map_point_coord_set(map, 0, x, y, 0);
1251 evas_map_point_coord_set(map, 1, w2, y, 0);
1252 evas_map_point_coord_set(map, 2, w2, h2, 0);
1253 evas_map_point_coord_set(map, 3, x, h2, 0);
1255 case ELM_FX_WIPE_DIR_DOWN:
1258 evas_map_point_image_uv_set(map, 0, 0, h2);
1259 evas_map_point_image_uv_set(map, 1, w, h2);
1260 evas_map_point_image_uv_set(map, 2, w, h);
1261 evas_map_point_image_uv_set(map, 3, 0, h);
1262 evas_map_point_coord_set(map, 0, x, y + h2, 0);
1263 evas_map_point_coord_set(map, 1, w2, y + h2, 0);
1264 evas_map_point_coord_set(map, 2, w2, y + h, 0);
1265 evas_map_point_coord_set(map, 3, x, y + h, 0);
1271 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, 10000);
1275 _elm_fx_wipe_show(Evas_Map *map, Elm_Fx_Wipe_Dir dir, float x, float y,
1276 float w, float h, float frame)
1282 case ELM_FX_WIPE_DIR_LEFT:
1283 w2 = (w - (w * frame));
1285 evas_map_point_image_uv_set(map, 0, w2, 0);
1286 evas_map_point_image_uv_set(map, 1, w, 0);
1287 evas_map_point_image_uv_set(map, 2, w, h);
1288 evas_map_point_image_uv_set(map, 3, w2, h);
1289 evas_map_point_coord_set(map, 0, x + w2, y, 0);
1290 evas_map_point_coord_set(map, 1, w, y, 0);
1291 evas_map_point_coord_set(map, 2, w, h2, 0);
1292 evas_map_point_coord_set(map, 3, x + w2, h2, 0);
1294 case ELM_FX_WIPE_DIR_RIGHT:
1297 evas_map_point_image_uv_set(map, 0, 0, 0);
1298 evas_map_point_image_uv_set(map, 1, w2, 0);
1299 evas_map_point_image_uv_set(map, 2, w2, h);
1300 evas_map_point_image_uv_set(map, 3, 0, h);
1301 evas_map_point_coord_set(map, 0, x, y, 0);
1302 evas_map_point_coord_set(map, 1, x + w2, y, 0);
1303 evas_map_point_coord_set(map, 2, x + w2, h2, 0);
1304 evas_map_point_coord_set(map, 3, x, h2, 0);
1306 case ELM_FX_WIPE_DIR_UP:
1308 h2 = (h - (h * frame));
1309 evas_map_point_image_uv_set(map, 0, 0, h2);
1310 evas_map_point_image_uv_set(map, 1, w, h2);
1311 evas_map_point_image_uv_set(map, 2, w, h);
1312 evas_map_point_image_uv_set(map, 3, 0, h);
1313 evas_map_point_coord_set(map, 0, x, y + h2, 0);
1314 evas_map_point_coord_set(map, 1, w2, y + h2, 0);
1315 evas_map_point_coord_set(map, 2, w2, y + h, 0);
1316 evas_map_point_coord_set(map, 3, x, y + h, 0);
1318 case ELM_FX_WIPE_DIR_DOWN:
1321 evas_map_point_image_uv_set(map, 0, 0, 0);
1322 evas_map_point_image_uv_set(map, 1, w, 0);
1323 evas_map_point_image_uv_set(map, 2, w, h2);
1324 evas_map_point_image_uv_set(map, 3, 0, h2);
1325 evas_map_point_coord_set(map, 0, x, y, 0);
1326 evas_map_point_coord_set(map, 1, w2, y, 0);
1327 evas_map_point_coord_set(map, 2, w2, y + h2, 0);
1328 evas_map_point_coord_set(map, 3, x, y + h2, 0);
1334 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, 10000);
1338 _elm_fx_wipe_op(void *data, Elm_Animator *animator, double frame)
1344 Evas_Coord _x, _y, _w, _h;
1346 map = evas_map_new(4);
1351 evas_map_smooth_set(map, EINA_TRUE);
1352 evas_object_geometry_get(wipe->obj, &_x, &_y, &_w, &_h);
1354 if (wipe->type == ELM_FX_WIPE_TYPE_SHOW)
1355 _elm_fx_wipe_show(map, wipe->dir, _x, _y, _w, _h, (float)frame);
1357 _elm_fx_wipe_hide(map, wipe->dir, _x, _y, _w, _h, (float)frame);
1359 evas_object_map_enable_set(wipe->obj, EINA_TRUE);
1360 evas_object_map_set(wipe->obj, map);
1367 * @param obj Evas_Object that effect is applying to
1368 * @param type Wipe type. Hide or show
1369 * @param dir Wipe Direction
1370 * @return Wipe effect
1375 elm_fx_wipe_add(Evas_Object *obj, Elm_Fx_Wipe_Type type, Elm_Fx_Wipe_Dir dir)
1384 effect = calloc(1, sizeof(Elm_Effect));
1388 wipe = calloc(1, sizeof(Elm_Fx_Wipe));
1398 effect->begin_op = _elm_fx_wipe_begin;
1399 effect->end_op = _elm_fx_wipe_end;
1400 effect->animation_op = _elm_fx_wipe_op;
1401 effect->user_data = wipe;
1406 /////////////////////////////////////////////////////////////////////////////////////
1408 /////////////////////////////////////////////////////////////////////////////////////
1409 typedef struct _color Elm_Fx_Color;
1410 static void _elm_fx_color_begin(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt);
1411 static void _elm_fx_color_op(void *data, Elm_Animator *animator, double frame);
1416 struct _unsigned_color
1418 unsigned int r, g, b, a;
1420 struct _signed_color
1427 _elm_fx_color_begin(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
1429 Elm_Fx_Color *color = data;
1431 evas_object_show(color->obj);
1435 _elm_fx_color_op(void *data, Elm_Animator *animator, double frame)
1437 Elm_Fx_Color *color;
1439 unsigned int r, g, b, a;
1442 r = (color->from.r + (int)((float)color->to.r * frame));
1443 g = (color->from.g + (int)((float)color->to.g * frame));
1444 b = (color->from.b + (int)((float)color->to.b * frame));
1445 a = (color->from.a + (int)((float)color->to.a * frame));
1447 evas_object_color_set(color->obj, r, g, b, a);
1453 * @param obj Evas_Object that effect is applying to
1454 * @param from_r RGB R when effect begins
1455 * @param from_g RGB G when effect begins
1456 * @param from_b RGB B when effect begins
1457 * @param from_a RGB A when effect begins
1458 * @param to_r RGB R when effect ends
1459 * @param to_g RGB G when effect ends
1460 * @param to_b RGB B when effect ends
1461 * @param to_a RGB A when effect ends
1462 * @return Color Effect
1467 elm_fx_color_add(Evas_Object *obj, unsigned int from_r, unsigned int from_g,
1468 unsigned int from_b, unsigned int from_a, unsigned int to_r,
1469 unsigned int to_g, unsigned int to_b, unsigned int to_a)
1473 Elm_Fx_Color *color;
1478 effect = calloc(1, sizeof(Elm_Effect));
1482 color = calloc(1, sizeof(Elm_Fx_Color));
1490 color->from.r = from_r;
1491 color->from.g = from_g;
1492 color->from.b = from_b;
1493 color->from.a = from_a;
1494 color->to.r = to_r - from_r;
1495 color->to.g = to_g - from_g;
1496 color->to.b = to_b - from_b;
1497 color->to.a = to_a - from_a;
1499 effect->begin_op = _elm_fx_color_begin;
1500 effect->animation_op = _elm_fx_color_op;
1501 effect->user_data = color;
1506 /////////////////////////////////////////////////////////////////////////////////////
1508 /////////////////////////////////////////////////////////////////////////////////////
1509 typedef struct _fade Elm_Fx_Fade;
1510 static void _elm_fx_fade_begin(void *data, Eina_Bool auto_reverse,
1511 unsigned int repeat_cnt);
1512 static void _elm_fx_fade_end(void *data, Eina_Bool auto_reverse,
1513 unsigned int repeat_cnt);
1514 static void _elm_fx_fade_op(void *data, Elm_Animator *animator,
1519 Evas_Object *before;
1521 struct _signed_color before_color, after_color;
1524 Eina_Bool inversed:1;
1528 _elm_fx_fade_begin(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
1530 Elm_Fx_Fade *fade = data;
1532 fade->inversed = EINA_FALSE;
1536 _elm_fx_fade_end(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
1538 Elm_Fx_Fade *fade = data;
1540 evas_object_color_set(fade->before, fade->before_color.r,
1541 fade->before_color.g, fade->before_color.b,
1542 fade->before_color.a);
1543 evas_object_color_set(fade->after, fade->after_color.r, fade->after_color.g,
1544 fade->after_color.b, fade->after_color.a);
1548 _elm_fx_fade_op(void *data, Elm_Animator *animator, double frame)
1558 if (!fade->inversed)
1560 evas_object_hide(fade->after);
1561 evas_object_show(fade->before);
1562 fade->inversed = EINA_TRUE;
1565 _frame = (1 - (frame * 2));
1567 evas_object_color_set(fade->before, fade->before_color.r * _frame,
1568 fade->before_color.g * _frame,
1569 fade->before_color.b * _frame,
1570 fade->before_color.a + fade->before_alpha * (1 -
1577 evas_object_hide(fade->before);
1578 evas_object_show(fade->after);
1579 fade->inversed = EINA_FALSE;
1582 _frame = ((frame - 0.5) * 2);
1584 evas_object_color_set(fade->after, fade->after_color.r * _frame,
1585 fade->after_color.g * _frame,
1586 fade->after_color.b * _frame,
1587 fade->after_color.a + fade->after_alpha * (1 -
1596 * @param before Evas Object before fade in
1597 * @param after Evas Object after fade out
1598 * @return Fade effect
1603 elm_fx_fade_add(Evas_Object *before, Evas_Object *after)
1609 if ((!before) && (!after))
1612 effect = calloc(1, sizeof(Elm_Effect));
1616 fade = calloc(1, sizeof(Elm_Fx_Fade));
1624 evas_object_color_get(before, &fade->before_color.r, &fade->before_color.g,
1625 &fade->before_color.b, &fade->before_color.a);
1626 evas_object_color_get(after, &fade->after_color.r, &fade->after_color.g,
1627 &fade->after_color.b, &fade->after_color.a);
1629 fade->before = before;
1630 fade->after = after;
1631 fade->before_alpha = (255 - fade->before_color.a);
1632 fade->after_alpha = (255 - fade->after_color.a);
1634 effect->begin_op = _elm_fx_fade_begin;
1635 effect->end_op = _elm_fx_fade_end;
1636 effect->animation_op = _elm_fx_fade_op;
1637 effect->user_data = fade;
1642 /////////////////////////////////////////////////////////////////////////////////////
1644 /////////////////////////////////////////////////////////////////////////////////////
1645 typedef struct _blend Elm_Fx_Blend;
1646 static void _elm_fx_blend_begin(void *data, Eina_Bool auto_reverse,
1647 unsigned int repeat_cnt);
1648 static void _elm_fx_blend_end(void *data, Eina_Bool auto_reverse,
1649 unsigned int repeat_cnt);
1650 static void _elm_fx_blend_op(void *data, Elm_Animator *animator,
1655 Evas_Object *before;
1657 struct _signed_color from, to;
1661 _elm_fx_blend_begin(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
1663 Elm_Fx_Blend *blend = data;
1665 evas_object_show(blend->before);
1669 _elm_fx_blend_end(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
1671 Elm_Fx_Blend *blend = data;
1673 evas_object_color_set(blend->before, blend->from.r, blend->from.g,
1674 blend->from.b, blend->from.a);
1675 evas_object_color_set(blend->after, blend->to.r, blend->to.g, blend->to.b,
1678 evas_object_hide(blend->before);
1680 evas_object_hide(blend->after);
1684 _elm_fx_blend_op(void *data, Elm_Animator *animator, double frame)
1686 Elm_Fx_Blend *blend = data;
1688 evas_object_show(blend->after);
1689 evas_object_color_set(blend->before, (int)(blend->from.r * (1 - frame)),
1690 (int)(blend->from.g * (1 - frame)),
1691 (int)(blend->from.b * (1 - frame)),
1692 (int)(blend->from.a * (1 - frame)));
1693 evas_object_color_set(blend->after, (int)(blend->to.r * frame),
1694 (int)(blend->to.g * frame), (int)(blend->to.b * frame),
1695 (int)(blend->to.a * frame));
1701 * @param before Evas Object before blending
1702 * @param after Evas Object after blending
1703 * @return Blend effect
1708 elm_fx_blend_add(Evas_Object *before, Evas_Object *after)
1712 Elm_Fx_Blend *blend;
1714 if ((!before) && (!after))
1717 effect = calloc(1, sizeof(Elm_Effect));
1721 blend = calloc(1, sizeof(Elm_Fx_Blend));
1728 blend->before = before;
1729 blend->after = after;
1730 evas_object_color_get(before, &blend->from.r, &blend->from.g, &blend->from.b,
1732 evas_object_color_get(after, &blend->to.r, &blend->to.g, &blend->to.b,
1735 effect->begin_op = _elm_fx_blend_begin;
1736 effect->end_op = _elm_fx_blend_end;
1737 effect->animation_op = _elm_fx_blend_op;
1738 effect->user_data = blend;
1743 /////////////////////////////////////////////////////////////////////////////////////
1745 /////////////////////////////////////////////////////////////////////////////////////
1746 typedef struct _rotation Elm_Fx_Rotation;
1747 static void _elm_fx_rotation_begin(void *data, Eina_Bool auto_reverse,
1748 unsigned int repeat_cnt);
1749 static void _elm_fx_rotation_end(void *data, Eina_Bool auto_reverse,
1750 unsigned int repeat_cnt);
1751 static void _elm_fx_rotation_op(void *data, Elm_Animator *animator,
1762 _elm_fx_rotation_begin(void *data, Eina_Bool auto_reverse,
1763 unsigned int repeat_cnt)
1765 Elm_Fx_Rotation *rotation = data;
1767 evas_object_show(rotation->obj);
1771 _elm_fx_rotation_end(void *data, Eina_Bool auto_reverse,
1772 unsigned int repeat_cnt)
1774 Elm_Fx_Rotation *rotation = data;
1776 evas_object_map_enable_set(rotation->obj, EINA_FALSE);
1780 _elm_fx_rotation_op(void *data, Elm_Animator *animator, double frame)
1782 Elm_Fx_Rotation *rotation;
1786 Evas_Coord x, y, w, h;
1790 float half_w, half_h;
1792 map = evas_map_new(4);
1798 evas_map_smooth_set(map, EINA_TRUE);
1799 evas_map_util_points_populate_from_object_full(map, rotation->obj, 0);
1800 degree = rotation->from + (float)(frame * rotation->to);
1805 evas_object_geometry_get(rotation->obj, &x, &y, &w, &h);
1807 half_w = (float)w *0.5;
1809 half_h = (float)h *0.5;
1811 evas_map_util_3d_rotate(map, 0, 0, degree, x + half_w, y + half_h, 0);
1812 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, 10000);
1813 evas_object_map_enable_set(rotation->obj, EINA_TRUE);
1814 evas_object_map_set(rotation->obj, map);
1819 * Add Rotation effect
1821 * @param obj Evas_Object that effect is applying to
1822 * @param from degree Degree when effect begins
1823 * @param to_degree Degree when effect is ends
1824 * @param cw Rotation direction. EINA_TRUE is clock wise
1825 * @return Rotation effect
1830 elm_fx_rotation_add(Evas_Object *obj, float from_degree, float to_degree,
1835 Elm_Fx_Rotation *rotation;
1840 effect = calloc(1, sizeof(Elm_Effect));
1844 rotation = calloc(1, sizeof(Elm_Fx_Rotation));
1852 rotation->obj = obj;
1853 rotation->from = from_degree;
1854 rotation->to = to_degree - from_degree;
1857 effect->begin_op = _elm_fx_rotation_begin;
1858 effect->end_op = _elm_fx_rotation_end;
1859 effect->animation_op = _elm_fx_rotation_op;
1860 effect->user_data = rotation;
1865 /////////////////////////////////////////////////////////////////////////////////////
1866 // ImageAnimation FX
1867 /////////////////////////////////////////////////////////////////////////////////////
1868 typedef struct _image_animation Elm_Fx_Image_Animation;
1869 static void _elm_fx_image_animation_begin(void *data, Eina_Bool auto_reverse,
1870 unsigned int repeat_cnt);
1871 static void _elm_fx_image_animation_op(void *data, Elm_Animator *animator,
1873 EAPI Elm_Effect *elm_fx_image_animation_add(Evas_Object *obj, const char **images,
1874 unsigned int item_num);
1876 struct _image_animation
1885 _elm_fx_image_animation_begin(void *data, Eina_Bool auto_reverse,
1886 unsigned int repeat_cnt)
1888 Elm_Fx_Image_Animation *image_animation = data;
1889 evas_object_show(image_animation->obj);
1894 _elm_fx_image_animation_op(void *data, Elm_Animator *animator, double frame)
1896 Elm_Fx_Image_Animation *image_animation = (Elm_Fx_Image_Animation *) data;
1897 elm_icon_file_set(image_animation->obj,
1898 image_animation->images[ (int) floor(frame * image_animation->img_cnt) ], NULL);
1902 _elm_fx_image_animation_del(void *data)
1905 Elm_Fx_Image_Animation *image_animation = data;
1907 for(idx = 0; idx < image_animation->img_cnt; ++idx ) {
1908 eina_stringshare_del(image_animation->images[ idx ]);
1911 free(image_animation->images);
1915 * Add image_animation effect.
1917 * @param obj Icon object
1918 * @param images Array of image file path.
1919 * @param img_cnt Count of image.
1920 * @return ImageAnimation effect.
1925 elm_fx_image_animation_add(Evas_Object *obj, const char **images,
1926 unsigned int img_cnt)
1929 Elm_Fx_Image_Animation *image_animation;
1932 if ((!obj) || !images || !(*images))
1935 effect = calloc(1, sizeof(Elm_Effect));
1939 image_animation = calloc(1, sizeof(Elm_Fx_Image_Animation));
1941 if (!image_animation)
1947 image_animation->obj = obj;
1948 image_animation->images = calloc( img_cnt, sizeof(char*));
1949 for(idx = 0; idx < img_cnt; ++idx )
1950 image_animation->images[ idx ] = eina_stringshare_add( images[ idx ] );
1952 image_animation->img_cnt = img_cnt;
1954 effect->begin_op = _elm_fx_image_animation_begin;
1955 effect->animation_op = _elm_fx_image_animation_op;
1956 effect->del_op = _elm_fx_image_animation_del;
1957 effect->user_data = image_animation;