1 #include <Elementary.h>
4 #define ELM_TRANSIT_CHECK_OR_RETURN(transit, ...) \
7 CRITICAL("Elm_Transit " # transit " is NULL!"); \
10 if (!EINA_MAGIC_CHECK(transit, ELM_TRANSIT_MAGIC)) { \
11 EINA_MAGIC_FAIL(transit, ELM_TRANSIT_MAGIC); \
14 if (transit->deleted){ \
15 ERR("Elm_Transit " # transit " has already been deleted!"); \
23 * @defgroup Transit Transit
26 * Transit (see Warning below) is designed to set the various effects for the
27 * Evas_Object such like translation, rotation, etc. For using Effects, Create
28 * transit and insert effects which are interesting.
29 * Once effects are inserted into transit, transit will manage those effects.
32 * @warning We strongly recomend to use elm_transit just when edje can not do
33 * the trick. Edje has more advantage than Elm_Transit, it has more flexibility and
34 * animations can be manipulated inside the theme.
39 #define ELM_TRANSIT_MAGIC 0xd27f190a
43 Elm_Animator *animator;
44 Eina_List *effect_list;
45 Elm_Transit_Tween_Mode tween_mode;
46 Evas_Object *block_rect;
47 void (*completion_op) (void *data, Elm_Transit *transit);
54 void (*animation_op) (void *data, Elm_Animator *animator, double frame);
55 void (*begin_op) (void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt);
56 void (*end_op) (void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt);
57 void (*del_op) (void* data);
58 unsigned int shared_cnt;
62 static Evas_Object *_create_block_rect(Evas_Object *parent);
63 static void _transit_animate_cb(void *data, Elm_Animator *animator,
65 static void _transit_fx_begin(Elm_Transit *transit);
66 static void _transit_fx_end(Elm_Transit *transit);
67 static void _transit_complete_cb(void *data);
68 static void _transit_fx_del(Elm_Effect *effect);
72 static void _elm_transit_del(Elm_Transit *transit);
76 _elm_transit_del(Elm_Transit *transit)
78 if (elm_animator_operating_get(transit->animator))
80 transit->deleted = EINA_TRUE;
84 if (transit->block_rect)
85 evas_object_del(transit->block_rect);
87 elm_animator_del(transit->animator);
88 elm_transit_fx_clear(transit);
90 EINA_MAGIC_SET(transit, EINA_MAGIC_NONE);
95 _create_block_rect(Evas_Object *parent)
101 rect = evas_object_rectangle_add(evas_object_evas_get(parent));
102 evas_output_size_get(evas_object_evas_get(parent), &w, &h);
103 evas_object_resize(rect, w, h);
104 evas_object_color_set(rect, 0, 0, 0, 0);
109 _transit_animate_cb(void *data, Elm_Animator *animator, double frame)
115 Elm_Transit *transit = data;
117 EINA_LIST_FOREACH(transit->effect_list, elist, effect)
119 effect->animation_op(effect->user_data, animator, frame);
124 _transit_fx_begin(Elm_Transit *transit)
130 Eina_Bool auto_reverse;
132 unsigned int repeat_cnt;
134 auto_reverse = elm_animator_auto_reverse_get(transit->animator);
135 repeat_cnt = elm_animator_repeat_get(transit->animator);
137 EINA_LIST_FOREACH(transit->effect_list, elist, effect)
139 if (effect->begin_op)
140 effect->begin_op(effect->user_data, auto_reverse, repeat_cnt);
145 _transit_fx_end(Elm_Transit *transit)
151 Eina_Bool auto_reverse;
153 unsigned int repeat_cnt;
155 auto_reverse = elm_animator_auto_reverse_get(transit->animator);
156 repeat_cnt = elm_animator_repeat_get(transit->animator);
158 EINA_LIST_FOREACH(transit->effect_list, elist, effect)
161 effect->end_op(effect->user_data, auto_reverse, repeat_cnt);
166 _transit_complete_cb(void *data)
168 Elm_Transit *transit = (Elm_Transit *) data;
170 evas_render(evas_object_evas_get(transit->parent));
172 _transit_fx_end(transit);
174 if (transit->block_rect)
175 evas_object_hide(transit->block_rect);
177 if (transit->completion_op)
178 transit->completion_op(transit->completion_arg, transit);
180 if (transit->deleted)
182 transit->deleted = EINA_FALSE;
183 elm_transit_del(transit);
188 _transit_fx_del(Elm_Effect *effect)
193 --effect->shared_cnt;
195 if (effect->shared_cnt > 0)
199 (*effect->del_op)(effect->user_data);
201 if (effect->user_data)
202 free(effect->user_data);
207 * Set the event blocked when transit is operating.
209 * @param[in] transit Transit object
210 * @param[in] disabled Disable or enable
215 elm_transit_event_block_disabled_set(Elm_Transit *transit, Eina_Bool disabled)
217 ELM_TRANSIT_CHECK_OR_RETURN(transit);
221 if (transit->block_rect)
223 evas_object_del(transit->block_rect);
224 transit->block_rect = NULL;
229 if (!transit->block_rect)
230 transit->block_rect = _create_block_rect(transit->parent);
235 * Get the value of event blocked status.
237 * @see elm_transit_event_block_set()
239 * @param[in] transit The Transit object
240 * @return EINA_TRUE, when event block is enabled. If @p transit is NULL
241 * EINA_FALSE is returned
246 elm_transit_event_block_disabled_get(const Elm_Transit *transit)
248 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
250 return transit->block_rect ? EINA_TRUE : EINA_FALSE;
254 * Remove effect from transit.
256 * @param[in] transit Transit
257 * @param[in] effect Effect to be removed
258 * @return EINA_TRUE, if the effect is removed
259 * @warning If removed effect does not inserted in any transit, it will be deleted.
264 elm_transit_fx_remove(Elm_Transit *transit, Elm_Effect *effect)
266 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
272 EINA_LIST_FOREACH(transit->effect_list, elist, _effect)
274 if (_effect == effect)
276 transit->effect_list =
277 eina_list_remove(transit->effect_list, _effect);
278 _transit_fx_del(_effect);
286 * Remove all current inserted effects.
288 * @param[in] transit Transit
293 elm_transit_fx_clear(Elm_Transit *transit)
295 ELM_TRANSIT_CHECK_OR_RETURN(transit);
301 EINA_LIST_FOREACH(transit->effect_list, elist, effect)
303 transit->effect_list = eina_list_remove(transit->effect_list, effect);
304 _transit_fx_del(effect);
309 * Get the list of current inseted effects.
311 * @param[in] transit Transit
312 * @return Effect list
316 EAPI const Eina_List *
317 elm_transit_fx_get(Elm_Transit *transit)
319 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
321 return transit->effect_list;
325 * Set the user-callback function when the transit operation is done.
327 * @param[in] transit Transit
328 * @param[in] op Callback function pointer
329 * @param[in] data Callback funtion user data
334 elm_transit_completion_callback_set(Elm_Transit *transit,
335 void (*op) (void *data,
336 Elm_Transit *transit),
339 ELM_TRANSIT_CHECK_OR_RETURN(transit);
341 transit->completion_op = op;
342 transit->completion_arg = data;
352 * @param[in] transit Transit to be deleted
357 elm_transit_del(Elm_Transit *transit)
359 ELM_TRANSIT_CHECK_OR_RETURN(transit);
361 _elm_transit_del(transit);
362 // if (transit->walking) transit->deleted = EINA_TRUE;
363 // else _elm_transit_del(transit);
367 * Set the transit animation acceleration style.
369 * @param transit Transit
370 * @param cs Curve style(Please refer elm_animator_curve_style_set)
375 elm_transit_curve_style_set(Elm_Transit *transit, Elm_Animator_Curve_Style cs)
377 ELM_TRANSIT_CHECK_OR_RETURN(transit);
378 elm_animator_curve_style_set(transit->animator, cs);
382 * Set the transit animation acceleration type.
384 * This function sets the tween mode of the transit that can be:
385 * ELM_TRANSIT_TWEEN_MODE_LINEAR - The default mode.
386 * ELM_TRANSIT_TWEEN_MODE_SINUSOIDAL - Starts in accelerate mode and ends decelerating.
387 * ELM_TRANSIT_TWEEN_MODE_DECELERATE - The animation will be slowed over time.
388 * ELM_TRANSIT_TWEEN_MODE_ACCELERATE - The animation will accelerate over time.
390 * @param[in] transit The transit object.
391 * @param[in] tween_mode The tween type.
396 elm_transit_tween_mode_set(Elm_Transit *transit, Elm_Transit_Tween_Mode tween_mode)
398 ELM_TRANSIT_CHECK_OR_RETURN(transit);
400 transit->tween_mode = tween_mode;
404 case ELM_TRANSIT_TWEEN_MODE_LINEAR:
405 elm_animator_curve_style_set(transit->animator, ELM_ANIMATOR_CURVE_LINEAR);
407 case ELM_TRANSIT_TWEEN_MODE_SINUSODIAL:
408 elm_animator_curve_style_set(transit->animator, ELM_ANIMATOR_CURVE_IN_OUT);
410 case ELM_TRANSIT_TWEEN_MODE_DECELERATE:
411 elm_animator_curve_style_set(transit->animator, ELM_ANIMATOR_CURVE_OUT);
413 case ELM_TRANSIT_TWEEN_MODE_ACCELERATE:
414 elm_animator_curve_style_set(transit->animator, ELM_ANIMATOR_CURVE_IN);
423 * Get the transit animation acceleration type.
425 * @note @p transit can not be NULL
427 * @param[in] transit The transit object.
428 * @return The tween type. If @p transit is NULL
429 * ELM_TRANSIT_TWEEN_MODE_LINEAR is returned.
433 EAPI Elm_Transit_Tween_Mode
434 elm_transit_tween_mode_get(const Elm_Transit *transit)
436 ELM_TRANSIT_CHECK_OR_RETURN(transit, ELM_TRANSIT_TWEEN_MODE_LINEAR);
438 return transit->tween_mode;
444 * @param[in] parent Parent object
450 elm_transit_add(Evas_Object *parent)
452 Elm_Transit *transit = ELM_NEW(Elm_Transit);
454 if (!transit) return NULL;
456 EINA_MAGIC_SET(transit, ELM_TRANSIT_MAGIC);
458 //elm_transit_tween_mode_set(transit, ELM_TRANSIT_TWEEN_MODE_LINEAR);
460 //transit->time.duration = duration;
462 //transit->time.begin = ecore_loop_time_get();
464 //transit->animator = ecore_animator_add(_animator_animate_cb, transit);
466 transit->animator = elm_animator_add(parent);
468 if (!transit->animator)
474 transit->parent = parent;
475 elm_animator_operation_callback_set(transit->animator, _transit_animate_cb,
477 elm_animator_completion_callback_set(transit->animator, _transit_complete_cb,
479 elm_transit_event_block_disabled_set(transit, EINA_FALSE);
483 evas_object_event_callback_add(parent, EVAS_CALLBACK_DEL, _transit_parent_del,
491 * Set reverse effect automatically.
493 * @param[in] transit Transit
494 * @param[in] reverse EINA_TRUE is reverse.
499 elm_transit_auto_reverse_set(Elm_Transit *transit, Eina_Bool reverse)
501 ELM_TRANSIT_CHECK_OR_RETURN(transit);
502 elm_animator_auto_reverse_set(transit->animator, reverse);
506 * Insert an effect into the transit.
508 * @param[in] transit Transit
509 * @param[in] effect Effect to be inserted
510 * @return EINA_TRUE is success
515 //elm_transit_effect_add(Elm_Transit *transit, void (*cb)(void *data, Elm_Transit *transit, double progress), void *data, void (*data_free_cb)(void *data, Elm_Transit *transit))
517 elm_transit_fx_insert(Elm_Transit *transit, Elm_Effect *effect)
519 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
525 EINA_LIST_FOREACH(transit->effect_list, elist, _effect)
527 if (_effect == effect)
531 ++effect->shared_cnt;
532 transit->effect_list = eina_list_append(transit->effect_list, effect);
538 * Set the transit repeat count. Effect will be repeated by repeat count.
540 * @param[in] transit Transit
541 * @param[in] repeat Repeat count
546 elm_transit_repeat_set(Elm_Transit *transit, unsigned int repeat)
548 ELM_TRANSIT_CHECK_OR_RETURN(transit);
549 elm_animator_repeat_set(transit->animator, repeat);
553 * Stop the current transit, if the transit is operating.
555 * @param[in] transit Transit
560 elm_transit_stop(Elm_Transit *transit)
562 ELM_TRANSIT_CHECK_OR_RETURN(transit);
563 elm_animator_stop(transit->animator);
567 * Run the all the inserted effects.
569 * @param[in] transit Transit
570 * @param[in] duration Transit time in seconds
575 elm_transit_run(Elm_Transit *transit, double duration)
577 ELM_TRANSIT_CHECK_OR_RETURN(transit);
578 _transit_fx_begin(transit);
579 elm_animator_duration_set(transit->animator, duration);
582 if (transit->block_rect)
583 evas_object_show(transit->block_rect);
585 elm_animator_animate(transit->animator);
587 //If failed to animate.
588 if (!elm_animator_operating_get(transit->animator))
590 if (transit->block_rect)
591 evas_object_hide(transit->block_rect);
592 _transit_fx_end(transit);
599 * @param[in] transit Transit
604 elm_transit_pause(Elm_Transit *transit)
606 ELM_TRANSIT_CHECK_OR_RETURN(transit);
608 elm_animator_pause(transit->animator);
614 * @param[in] transit Transit
619 elm_transit_resume(Elm_Transit *transit)
621 ELM_TRANSIT_CHECK_OR_RETURN(transit);
623 elm_animator_resume(transit->animator);
628 /////////////////////////////////////////////////////////////////////////////////////
630 /////////////////////////////////////////////////////////////////////////////////////
631 typedef struct _resizing Elm_Fx_Resizing;
632 static void _elm_fx_resizing_op(void *data, Elm_Animator *animator,
634 static void _elm_fx_resizing_begin(void *data, Eina_Bool auto_reverse,
635 unsigned int repeat_cnt);
647 _elm_fx_resizing_begin(void *data, Eina_Bool auto_reverse,
648 unsigned int repeat_cnt)
650 Elm_Fx_Resizing *resizing = data;
652 evas_object_show(resizing->obj);
653 evas_object_resize(resizing->obj, resizing->from.w, resizing->from.h);
657 _elm_fx_resizing_op(void *data, Elm_Animator *animator, double frame)
661 Elm_Fx_Resizing *resizing = data;
663 w = resizing->from.w + (Evas_Coord) ((float)resizing->to.w * (float)frame);
664 h = resizing->from.h + (Evas_Coord) ((float)resizing->to.h * (float)frame);
665 evas_object_resize(resizing->obj, w, h);
669 * Add Resizing effect.
671 * @param[in] obj Evas_Object that effect is applying to
672 * @param[in] from_w Object width size when effect begins
673 * @param[in] from_h Object height size when effect begins
674 * @param[in] to_w Object width size when effect ends
675 * @param[in] to_h Object height size when effect ends
676 * @return Resizing effect
681 elm_fx_resizing_add(Evas_Object *obj, Evas_Coord from_w, Evas_Coord from_h,
682 Evas_Coord to_w, Evas_Coord to_h)
686 Elm_Fx_Resizing *resizing;
691 effect = calloc(1, sizeof(Elm_Effect));
695 resizing = calloc(1, sizeof(Elm_Fx_Resizing));
703 resizing->from.w = from_w;
704 resizing->from.h = from_h;
705 resizing->to.w = to_w - from_w;
706 resizing->to.h = to_h - from_h;
708 effect->begin_op = _elm_fx_resizing_begin;
709 effect->animation_op = _elm_fx_resizing_op;
710 effect->user_data = resizing;
715 /////////////////////////////////////////////////////////////////////////////////////
717 /////////////////////////////////////////////////////////////////////////////////////
718 typedef struct _translation Elm_Fx_Translation;
719 static void _elm_fx_translation_op(void *data, Elm_Animator *animator,
721 static void _elm_fx_translation_begin(void *data, Eina_Bool auto_reverse,
722 unsigned int repeat_cnt);
723 static void _elm_fx_translation_end(void *data, Eina_Bool auto_reverse,
724 unsigned int repeat_cnt);
736 _elm_fx_translation_begin(void *data, Eina_Bool auto_reverse,
737 unsigned int repeat_cnt)
739 Elm_Fx_Translation *translation = data;
741 evas_object_show(translation->obj);
742 evas_object_move(translation->obj, translation->from.x, translation->from.y);
746 _elm_fx_translation_end(void *data, Eina_Bool auto_reverse,
747 unsigned int repeat_cnt)
749 Elm_Fx_Translation *translation = data;
751 evas_object_move(translation->obj, translation->from.x + translation->to.x,
752 translation->from.y + translation->to.y);
756 _elm_fx_translation_op(void *data, Elm_Animator *animator, double frame)
760 Elm_Fx_Translation *translation = data;
762 x = translation->from.x +
763 (Evas_Coord) ((float)translation->to.x * (float)frame);
764 y = translation->from.y +
765 (Evas_Coord) ((float)translation->to.y * (float)frame);
766 evas_object_move(translation->obj, x, y);
770 * Add Translation effect.
772 * @param[in] obj Evas_Object that effect is applying to
773 * @param[in] from_x Position X when effect begins
774 * @param[in] from_y Position Y when effect begins
775 * @param[in] to_x Position X when effect ends
776 * @param[in] to_y Position Y when effect ends
777 * @return Translation effect
782 elm_fx_translation_add(Evas_Object *obj, Evas_Coord from_x, Evas_Coord from_y,
783 Evas_Coord to_x, Evas_Coord to_y)
787 Elm_Fx_Translation *translation;
792 effect = calloc(1, sizeof(Elm_Effect));
796 translation = calloc(1, sizeof(Elm_Fx_Translation));
804 translation->obj = obj;
805 translation->from.x = from_x;
806 translation->from.y = from_y;
807 translation->to.x = to_x - from_x;
808 translation->to.y = to_y - from_y;
810 effect->begin_op = _elm_fx_translation_begin;
811 effect->end_op = _elm_fx_translation_end;
812 effect->animation_op = _elm_fx_translation_op;
813 effect->user_data = translation;
818 /////////////////////////////////////////////////////////////////////////////////////
820 /////////////////////////////////////////////////////////////////////////////////////
821 typedef struct _zoom Elm_Fx_Zoom;
822 static void _elm_fx_zoom_op(void *data, Elm_Animator * animator,
824 static void _elm_fx_zoom_begin(void *data, Eina_Bool reverse,
825 unsigned int repeat);
826 static void _elm_fx_zoom_end(void *data, Eina_Bool reverse,
827 unsigned int repeat);
836 _elm_fx_zoom_begin(void *data, Eina_Bool reverse, unsigned int repeat)
838 Elm_Fx_Zoom *zoom = data;
840 evas_object_show(zoom->obj);
841 _elm_fx_zoom_op(data, NULL, 0);
845 _elm_fx_zoom_end(void *data, Eina_Bool reverse, unsigned int repeat)
847 Elm_Fx_Zoom *zoom = data;
849 evas_object_map_enable_set(zoom->obj, EINA_FALSE);
853 _elm_fx_zoom_op(void *data, Elm_Animator *animator, double frame)
859 Evas_Coord x, y, w, h;
861 map = evas_map_new(4);
866 evas_object_geometry_get(zoom->obj, &x, &y, &w, &h);
867 evas_map_smooth_set(map, EINA_TRUE);
868 evas_map_util_points_populate_from_object_full(map, zoom->obj,
871 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, 10000);
872 evas_object_map_set(zoom->obj, map);
873 evas_object_map_enable_set(zoom->obj, EINA_TRUE);
880 * @param[in] obj Evas_Object that effect is applying to
881 * @param[in] from_rate Scale rate when effect begins (1 is current rate)
882 * @param[in] to_rate Scale rate when effect ends
883 * @return Zoom effect
888 elm_fx_zoom_add(Evas_Object *obj, float from_rate, float to_rate)
897 effect = calloc(1, sizeof(Elm_Effect));
901 zoom = calloc(1, sizeof(Elm_Fx_Zoom));
909 zoom->from = (10000 - (from_rate * 10000)) * (1 / from_rate);
910 zoom->to = ((10000 - (to_rate * 10000)) * (1 / to_rate)) - zoom->from;
911 effect->begin_op = _elm_fx_zoom_begin;
912 effect->end_op = _elm_fx_zoom_end;
913 effect->animation_op = _elm_fx_zoom_op;
914 effect->user_data = zoom;
920 /////////////////////////////////////////////////////////////////////////////////////
922 /////////////////////////////////////////////////////////////////////////////////////
923 typedef struct _flip Elm_Fx_Flip;
924 static void _elm_fx_flip_op(void *data, Elm_Animator *animator,
926 static void _elm_fx_flip_end(void *data, Eina_Bool auto_reverse,
927 unsigned int repeat_cnt);
933 Elm_Fx_Flip_Axis axis;
938 _elm_fx_flip_end(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
940 Elm_Fx_Flip *flip = data;
942 evas_object_map_enable_set(flip->front, EINA_FALSE);
943 evas_object_map_enable_set(flip->back, EINA_FALSE);
947 _elm_fx_flip_op(void *data, Elm_Animator *animator, double frame)
957 Evas_Coord x, y, w, h;
959 map = evas_map_new(4);
966 degree = (float)(frame * 180);
968 degree = (float)(frame * -180);
970 if (degree < 90 && degree > -90)
973 if(flip->back != flip->front) {
974 evas_object_hide(flip->back);
975 evas_object_show(flip->front);
981 if(flip->back != flip->front) {
982 evas_object_hide(flip->front);
983 evas_object_show(flip->back);
987 evas_map_smooth_set(map, EINA_TRUE);
988 evas_map_util_points_populate_from_object_full(map, obj, 0);
989 evas_object_geometry_get(obj, &x, &y, &w, &h);
990 Evas_Coord half_w = (w / 2);
992 Evas_Coord half_h = (h / 2);
994 if (flip->axis == ELM_FX_FLIP_AXIS_Y)
996 if ((degree >= 90) || (degree <= -90))
998 evas_map_point_image_uv_set(map, 0, w, 0);
999 evas_map_point_image_uv_set(map, 1, 0, 0);
1000 evas_map_point_image_uv_set(map, 2, 0, h);
1001 evas_map_point_image_uv_set(map, 3, w, h);
1003 evas_map_util_3d_rotate(map, 0, degree, 0, x + half_w, y + half_h, 0);
1007 if ((degree >= 90) || (degree <= -90))
1009 evas_map_point_image_uv_set(map, 0, 0, h);
1010 evas_map_point_image_uv_set(map, 1, w, h);
1011 evas_map_point_image_uv_set(map, 2, w, 0);
1012 evas_map_point_image_uv_set(map, 3, 0, 0);
1014 evas_map_util_3d_rotate(map, degree, 0, 0, x + half_w, y + half_h, 0);
1016 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, 10000);
1017 evas_object_map_enable_set(flip->front, EINA_TRUE);
1018 evas_object_map_enable_set(flip->back, EINA_TRUE);
1019 evas_object_map_set(obj, map);
1026 * @param[in] front Front surface object
1027 * @param[in] back Back surface object
1028 * @param[in] axis Flipping Axis(X or Y)
1029 * @param[in] cw Flipping Direction. EINA_TRUE is clock-wise
1030 * @return Flip effect
1035 elm_fx_flip_add(Evas_Object *front, Evas_Object *back, Elm_Fx_Flip_Axis axis,
1042 if ((!front) || (!back))
1045 effect = calloc(1, sizeof(Elm_Effect));
1049 flip = calloc(1, sizeof(Elm_Fx_Flip));
1057 flip->front = front;
1061 effect->end_op = _elm_fx_flip_end;
1062 effect->animation_op = _elm_fx_flip_op;
1063 effect->user_data = flip;
1068 /////////////////////////////////////////////////////////////////////////////////////
1070 /////////////////////////////////////////////////////////////////////////////////////
1071 typedef struct _resizable_flip Elm_Fx_ResizableFlip;
1072 static void _elm_fx_resizable_flip_begin(void *data, Eina_Bool reverse,
1073 unsigned int repeat);
1074 static void _elm_fx_resizable_flip_end(void *data, Eina_Bool auto_reverse,
1075 unsigned int repeat_cnt);
1076 static void _elm_fx_resizable_flip_op(void *data, Elm_Animator *animator,
1078 static void _set_image_uv_by_axis_y(Evas_Map *map, Elm_Fx_ResizableFlip *flip,
1080 static void _set_image_uv_by_axis_x(Evas_Map *map, Elm_Fx_ResizableFlip *flip,
1083 struct _resizable_flip
1087 Elm_Fx_Flip_Axis axis;
1091 } from_pos, from_size, to_pos, to_size;
1096 _elm_fx_resizable_flip_begin(void *data, Eina_Bool reverse, unsigned int repeat)
1098 Elm_Fx_ResizableFlip *resizable_flip = data;
1100 evas_object_show(resizable_flip->front);
1101 _elm_fx_resizable_flip_op(data, NULL, 0);
1105 _elm_fx_resizable_flip_end(void *data, Eina_Bool auto_reverse,
1106 unsigned int repeat_cnt)
1108 Elm_Fx_ResizableFlip *resizable_flip = data;
1110 evas_object_map_enable_set(resizable_flip->front, EINA_FALSE);
1111 evas_object_map_enable_set(resizable_flip->back, EINA_FALSE);
1115 _set_image_uv_by_axis_y(Evas_Map *map, Elm_Fx_ResizableFlip *flip,
1118 if ((degree >= 90) || (degree <= -90))
1120 evas_map_point_image_uv_set(map, 0,
1121 (flip->from_size.x * 2) + flip->to_size.x,
1123 evas_map_point_image_uv_set(map, 1, 0, 0);
1124 evas_map_point_image_uv_set(map, 2, 0,
1125 (flip->from_size.y * 2) + flip->to_size.y);
1126 evas_map_point_image_uv_set(map, 3,
1127 (flip->from_size.x * 2) + flip->to_size.x,
1128 (flip->from_size.y * 2) + flip->to_size.y);
1132 evas_map_point_image_uv_set(map, 0, 0, 0);
1133 evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
1134 evas_map_point_image_uv_set(map, 2, flip->from_size.x,
1136 evas_map_point_image_uv_set(map, 3, 0, flip->from_size.y);
1141 _set_image_uv_by_axis_x(Evas_Map *map, Elm_Fx_ResizableFlip *flip,
1144 if ((degree >= 90) || (degree <= -90))
1146 evas_map_point_image_uv_set(map, 0, 0,
1147 (flip->from_size.y * 2) + flip->to_size.y);
1148 evas_map_point_image_uv_set(map, 1,
1149 (flip->from_size.x * 2) + flip->to_size.x,
1150 (flip->from_size.y * 2) + flip->to_size.y);
1151 evas_map_point_image_uv_set(map, 2,
1152 (flip->from_size.x * 2) + flip->to_size.x,
1154 evas_map_point_image_uv_set(map, 3, 0, 0);
1158 evas_map_point_image_uv_set(map, 0, 0, 0);
1159 evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
1160 evas_map_point_image_uv_set(map, 2, flip->from_size.x,
1162 evas_map_point_image_uv_set(map, 3, 0, flip->to_size.y);
1167 _elm_fx_resizable_flip_op(void *data, Elm_Animator *animator, double frame)
1169 Elm_Fx_ResizableFlip *resizable_flip;
1179 Evas_Coord half_w, half_h;
1181 map = evas_map_new(4);
1185 resizable_flip = data;
1187 if (resizable_flip->cw)
1188 degree = (float)(frame * 180);
1190 degree = (float)(frame * -180);
1192 if ((degree < 90) && (degree > -90))
1194 obj = resizable_flip->front;
1195 if(resizable_flip->back != resizable_flip->front) {
1196 evas_object_hide(resizable_flip->back);
1197 evas_object_show(resizable_flip->front);
1202 obj = resizable_flip->back;
1203 if(resizable_flip->back != resizable_flip->front) {
1204 evas_object_hide(resizable_flip->front);
1205 evas_object_show(resizable_flip->back);
1208 evas_map_smooth_set(map, EINA_TRUE);
1210 x = resizable_flip->from_pos.x + (resizable_flip->to_pos.x * frame);
1211 y = resizable_flip->from_pos.y + (resizable_flip->to_pos.y * frame);
1212 w = resizable_flip->from_size.x + (resizable_flip->to_size.x * frame);
1213 h = resizable_flip->from_size.y + (resizable_flip->to_size.y * frame);
1214 evas_map_point_coord_set(map, 0, x, y, 0);
1215 evas_map_point_coord_set(map, 1, x + w, y, 0);
1216 evas_map_point_coord_set(map, 2, x + w, y + h, 0);
1217 evas_map_point_coord_set(map, 3, x, y + h, 0);
1219 half_w = (Evas_Coord) (w / 2);
1220 half_h = (Evas_Coord) (h / 2);
1222 if (resizable_flip->axis == ELM_FX_FLIP_AXIS_Y)
1224 _set_image_uv_by_axis_y(map, resizable_flip, degree);
1225 evas_map_util_3d_rotate(map, 0, degree, 0, x + half_w, y + half_h, 0);
1229 _set_image_uv_by_axis_x(map, resizable_flip, degree);
1230 evas_map_util_3d_rotate(map, degree, 0, 0, x + half_w, y + half_h, 0);
1233 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, 10000);
1234 evas_object_map_enable_set(resizable_flip->front, EINA_TRUE);
1235 evas_object_map_enable_set(resizable_flip->back, EINA_TRUE);
1236 evas_object_map_set(obj, map);
1241 * Add ResizbleFlip effect. the size of each surface objects are interpolated automatically.
1243 * @param[in] front Front surface object
1244 * @param[in] back Back surface object
1245 * @param[in] axis Flipping Axis.(X or Y)
1246 * @param[in] cw Flipping Direction. EINA_TRUE is clock-wise
1247 * @return Flip effect
1252 elm_fx_resizable_flip_add(Evas_Object *front, Evas_Object *back,
1253 Elm_Fx_Flip_Axis axis, Eina_Bool cw)
1255 Elm_Fx_ResizableFlip *resizable_flip;
1259 Evas_Coord front_x, front_y, front_w, front_h;
1261 Evas_Coord back_x, back_y, back_w, back_h;
1263 if (!front || !back)
1266 effect = calloc(1, sizeof(Elm_Effect));
1270 resizable_flip = calloc(1, sizeof(Elm_Fx_ResizableFlip));
1272 if (!resizable_flip)
1278 resizable_flip->front = front;
1279 resizable_flip->back = back;
1280 resizable_flip->cw = cw;
1281 resizable_flip->axis = axis;
1283 evas_object_geometry_get(resizable_flip->front, &front_x, &front_y, &front_w,
1285 evas_object_geometry_get(resizable_flip->back, &back_x, &back_y, &back_w,
1288 resizable_flip->from_pos.x = front_x;
1289 resizable_flip->from_pos.y = front_y;
1290 resizable_flip->to_pos.x = back_x - front_x;
1291 resizable_flip->to_pos.y = back_y - front_y;
1293 resizable_flip->from_size.x = front_w;
1294 resizable_flip->from_size.y = front_h;
1295 resizable_flip->to_size.x = back_w - front_w;
1296 resizable_flip->to_size.y = back_h - front_h;
1298 effect->begin_op = _elm_fx_resizable_flip_begin;
1299 effect->end_op = _elm_fx_resizable_flip_end;
1300 effect->animation_op = _elm_fx_resizable_flip_op;
1301 effect->user_data = resizable_flip;
1306 /////////////////////////////////////////////////////////////////////////////////////
1308 /////////////////////////////////////////////////////////////////////////////////////
1309 typedef struct _wipe Elm_Fx_Wipe;
1310 static void _elm_fx_wipe_op(void *data, Elm_Animator *animator,
1312 static void _elm_fx_wipe_begin(void *data, Eina_Bool auto_repeat,
1313 unsigned int repeat_cnt);
1314 static void _elm_fx_wipe_end(void *data, Eina_Bool auto_repeat,
1315 unsigned int repeat_cnt);
1316 static void _elm_fx_wipe_hide(Evas_Map * map, Elm_Fx_Wipe_Dir dir,
1317 float x, float y, float w, float h, float frame);
1318 static void _elm_fx_wipe_show(Evas_Map *map, Elm_Fx_Wipe_Dir dir,
1319 float x, float y, float w, float h, float frame);
1324 Elm_Fx_Wipe_Type type;
1325 Elm_Fx_Wipe_Dir dir;
1329 _elm_fx_wipe_begin(void *data, Eina_Bool auto_repeat, unsigned int repeat_cnt)
1331 Elm_Fx_Wipe *wipe = data;
1333 evas_object_show(wipe->obj);
1334 _elm_fx_wipe_op(data, NULL, 0);
1338 _elm_fx_wipe_end(void *data, Eina_Bool auto_repeat, unsigned int repeat_cnt)
1340 Elm_Fx_Wipe *wipe = data;
1342 evas_object_map_enable_set(wipe->obj, EINA_FALSE);
1346 _elm_fx_wipe_hide(Evas_Map * map, Elm_Fx_Wipe_Dir dir, float x, float y,
1347 float w, float h, float frame)
1353 case ELM_FX_WIPE_DIR_UP:
1356 evas_map_point_image_uv_set(map, 0, 0, 0);
1357 evas_map_point_image_uv_set(map, 1, w, 0);
1358 evas_map_point_image_uv_set(map, 2, w, h2);
1359 evas_map_point_image_uv_set(map, 3, 0, h2);
1360 evas_map_point_coord_set(map, 0, x, y, 0);
1361 evas_map_point_coord_set(map, 1, w2, y, 0);
1362 evas_map_point_coord_set(map, 2, w2, y+h2, 0);
1363 evas_map_point_coord_set(map, 3, x, y+h2, 0);
1365 case ELM_FX_WIPE_DIR_LEFT:
1366 w2 = w - (w * frame);
1368 evas_map_point_image_uv_set(map, 0, 0, 0);
1369 evas_map_point_image_uv_set(map, 1, w2, 0);
1370 evas_map_point_image_uv_set(map, 2, w2, h);
1371 evas_map_point_image_uv_set(map, 3, 0, h);
1372 evas_map_point_coord_set(map, 0, x, y, 0);
1373 evas_map_point_coord_set(map, 1, x + w2, y, 0);
1374 evas_map_point_coord_set(map, 2, x + w2, h2, 0);
1375 evas_map_point_coord_set(map, 3, x, h2, 0);
1377 case ELM_FX_WIPE_DIR_RIGHT:
1380 evas_map_point_image_uv_set(map, 0, w2, 0);
1381 evas_map_point_image_uv_set(map, 1, w, 0);
1382 evas_map_point_image_uv_set(map, 2, w, h);
1383 evas_map_point_image_uv_set(map, 3, w2, h);
1384 evas_map_point_coord_set(map, 0, x + w2, y, 0);
1385 evas_map_point_coord_set(map, 1, x + w, y, 0);
1386 evas_map_point_coord_set(map, 2, x + w, h2, 0);
1387 evas_map_point_coord_set(map, 3, x + w2, h2, 0);
1389 case ELM_FX_WIPE_DIR_DOWN:
1392 evas_map_point_image_uv_set(map, 0, 0, h2);
1393 evas_map_point_image_uv_set(map, 1, w, h2);
1394 evas_map_point_image_uv_set(map, 2, w, h);
1395 evas_map_point_image_uv_set(map, 3, 0, h);
1396 evas_map_point_coord_set(map, 0, x, y + h2, 0);
1397 evas_map_point_coord_set(map, 1, w2, y + h2, 0);
1398 evas_map_point_coord_set(map, 2, w2, y + h, 0);
1399 evas_map_point_coord_set(map, 3, x, y + h, 0);
1405 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, 10000);
1409 _elm_fx_wipe_show(Evas_Map *map, Elm_Fx_Wipe_Dir dir, float x, float y,
1410 float w, float h, float frame)
1416 case ELM_FX_WIPE_DIR_UP:
1418 h2 = (h - (h * frame));
1419 evas_map_point_image_uv_set(map, 0, 0, h2);
1420 evas_map_point_image_uv_set(map, 1, w, h2);
1421 evas_map_point_image_uv_set(map, 2, w, h);
1422 evas_map_point_image_uv_set(map, 3, 0, h);
1423 evas_map_point_coord_set(map, 0, x, y + h2, 0);
1424 evas_map_point_coord_set(map, 1, w2, y + h2, 0);
1425 evas_map_point_coord_set(map, 2, w2, y + h, 0);
1426 evas_map_point_coord_set(map, 3, x, y + h, 0);
1428 case ELM_FX_WIPE_DIR_LEFT:
1429 w2 = (w - (w * frame));
1431 evas_map_point_image_uv_set(map, 0, w2, 0);
1432 evas_map_point_image_uv_set(map, 1, w, 0);
1433 evas_map_point_image_uv_set(map, 2, w, h);
1434 evas_map_point_image_uv_set(map, 3, w2, h);
1435 evas_map_point_coord_set(map, 0, x + w2, y, 0);
1436 evas_map_point_coord_set(map, 1, x + w, y, 0);
1437 evas_map_point_coord_set(map, 2, x +w, h2, 0);
1438 evas_map_point_coord_set(map, 3, x + w2, h2, 0);
1440 case ELM_FX_WIPE_DIR_RIGHT:
1443 evas_map_point_image_uv_set(map, 0, 0, 0);
1444 evas_map_point_image_uv_set(map, 1, w2, 0);
1445 evas_map_point_image_uv_set(map, 2, w2, h);
1446 evas_map_point_image_uv_set(map, 3, 0, h);
1447 evas_map_point_coord_set(map, 0, x, y, 0);
1448 evas_map_point_coord_set(map, 1, x + w2, y, 0);
1449 evas_map_point_coord_set(map, 2, x + w2, h2, 0);
1450 evas_map_point_coord_set(map, 3, x, h2, 0);
1452 case ELM_FX_WIPE_DIR_DOWN:
1455 evas_map_point_image_uv_set(map, 0, 0, 0);
1456 evas_map_point_image_uv_set(map, 1, w, 0);
1457 evas_map_point_image_uv_set(map, 2, w, h2);
1458 evas_map_point_image_uv_set(map, 3, 0, h2);
1459 evas_map_point_coord_set(map, 0, x, y, 0);
1460 evas_map_point_coord_set(map, 1, w2, y, 0);
1461 evas_map_point_coord_set(map, 2, w2, y + h2, 0);
1462 evas_map_point_coord_set(map, 3, x, y + h2, 0);
1468 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, 10000);
1472 _elm_fx_wipe_op(void *data, Elm_Animator *animator, double frame)
1478 Evas_Coord _x, _y, _w, _h;
1480 map = evas_map_new(4);
1485 evas_map_smooth_set(map, EINA_TRUE);
1486 evas_object_geometry_get(wipe->obj, &_x, &_y, &_w, &_h);
1488 if (wipe->type == ELM_FX_WIPE_TYPE_SHOW)
1489 _elm_fx_wipe_show(map, wipe->dir, _x, _y, _w, _h, (float)frame);
1491 _elm_fx_wipe_hide(map, wipe->dir, _x, _y, _w, _h, (float)frame);
1493 evas_object_map_enable_set(wipe->obj, EINA_TRUE);
1494 evas_object_map_set(wipe->obj, map);
1501 * @param[in] obj Evas_Object that effect is applying to
1502 * @param[in] type Wipe type. Hide or show
1503 * @param[in] dir Wipe Direction
1504 * @return Wipe effect
1509 elm_fx_wipe_add(Evas_Object *obj, Elm_Fx_Wipe_Type type, Elm_Fx_Wipe_Dir dir)
1518 effect = calloc(1, sizeof(Elm_Effect));
1522 wipe = calloc(1, sizeof(Elm_Fx_Wipe));
1532 effect->begin_op = _elm_fx_wipe_begin;
1533 effect->end_op = _elm_fx_wipe_end;
1534 effect->animation_op = _elm_fx_wipe_op;
1535 effect->user_data = wipe;
1540 /////////////////////////////////////////////////////////////////////////////////////
1542 /////////////////////////////////////////////////////////////////////////////////////
1543 typedef struct _color Elm_Fx_Color;
1544 static void _elm_fx_color_begin(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt);
1545 static void _elm_fx_color_op(void *data, Elm_Animator *animator, double frame);
1550 struct _unsigned_color
1552 unsigned int r, g, b, a;
1554 struct _signed_color
1561 _elm_fx_color_begin(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
1563 Elm_Fx_Color *color = data;
1565 evas_object_show(color->obj);
1569 _elm_fx_color_op(void *data, Elm_Animator *animator, double frame)
1571 Elm_Fx_Color *color;
1573 unsigned int r, g, b, a;
1576 r = (color->from.r + (int)((float)color->to.r * frame));
1577 g = (color->from.g + (int)((float)color->to.g * frame));
1578 b = (color->from.b + (int)((float)color->to.b * frame));
1579 a = (color->from.a + (int)((float)color->to.a * frame));
1581 evas_object_color_set(color->obj, r, g, b, a);
1587 * @param[in] obj Evas_Object that effect is applying to
1588 * @param[in] from_r RGB R when effect begins
1589 * @param[in] from_g RGB G when effect begins
1590 * @param[in] from_b RGB B when effect begins
1591 * @param[in] from_a RGB A when effect begins
1592 * @param[in] to_r RGB R when effect ends
1593 * @param[in] to_g RGB G when effect ends
1594 * @param[in] to_b RGB B when effect ends
1595 * @param[in] to_a RGB A when effect ends
1596 * @return Color Effect
1601 elm_fx_color_add(Evas_Object *obj, unsigned int from_r, unsigned int from_g,
1602 unsigned int from_b, unsigned int from_a, unsigned int to_r,
1603 unsigned int to_g, unsigned int to_b, unsigned int to_a)
1607 Elm_Fx_Color *color;
1612 effect = calloc(1, sizeof(Elm_Effect));
1616 color = calloc(1, sizeof(Elm_Fx_Color));
1624 color->from.r = from_r;
1625 color->from.g = from_g;
1626 color->from.b = from_b;
1627 color->from.a = from_a;
1628 color->to.r = to_r - from_r;
1629 color->to.g = to_g - from_g;
1630 color->to.b = to_b - from_b;
1631 color->to.a = to_a - from_a;
1633 effect->begin_op = _elm_fx_color_begin;
1634 effect->animation_op = _elm_fx_color_op;
1635 effect->user_data = color;
1640 /////////////////////////////////////////////////////////////////////////////////////
1642 /////////////////////////////////////////////////////////////////////////////////////
1643 typedef struct _fade Elm_Fx_Fade;
1644 static void _elm_fx_fade_begin(void *data, Eina_Bool auto_reverse,
1645 unsigned int repeat_cnt);
1646 static void _elm_fx_fade_end(void *data, Eina_Bool auto_reverse,
1647 unsigned int repeat_cnt);
1648 static void _elm_fx_fade_op(void *data, Elm_Animator *animator,
1653 Evas_Object *before;
1655 struct _signed_color before_color, after_color;
1658 Eina_Bool inversed:1;
1662 _elm_fx_fade_begin(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
1664 Elm_Fx_Fade *fade = data;
1666 fade->inversed = EINA_FALSE;
1670 _elm_fx_fade_end(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
1672 Elm_Fx_Fade *fade = data;
1674 evas_object_color_set(fade->before, fade->before_color.r,
1675 fade->before_color.g, fade->before_color.b,
1676 fade->before_color.a);
1677 evas_object_color_set(fade->after, fade->after_color.r, fade->after_color.g,
1678 fade->after_color.b, fade->after_color.a);
1682 _elm_fx_fade_op(void *data, Elm_Animator *animator, double frame)
1692 if (!fade->inversed)
1694 evas_object_hide(fade->after);
1695 evas_object_show(fade->before);
1696 fade->inversed = EINA_TRUE;
1699 _frame = (1 - (frame * 2));
1701 evas_object_color_set(fade->before, fade->before_color.r * _frame,
1702 fade->before_color.g * _frame,
1703 fade->before_color.b * _frame,
1704 fade->before_color.a + fade->before_alpha * (1 -
1711 evas_object_hide(fade->before);
1712 evas_object_show(fade->after);
1713 fade->inversed = EINA_FALSE;
1716 _frame = ((frame - 0.5) * 2);
1718 evas_object_color_set(fade->after, fade->after_color.r * _frame,
1719 fade->after_color.g * _frame,
1720 fade->after_color.b * _frame,
1721 fade->after_color.a + fade->after_alpha * (1 -
1730 * @param[in] before Evas Object before fade in
1731 * @param[in] after Evas Object after fade out
1732 * @return Fade effect
1737 elm_fx_fade_add(Evas_Object *before, Evas_Object *after)
1743 if ((!before) && (!after))
1746 effect = calloc(1, sizeof(Elm_Effect));
1750 fade = calloc(1, sizeof(Elm_Fx_Fade));
1758 evas_object_color_get(before, &fade->before_color.r, &fade->before_color.g,
1759 &fade->before_color.b, &fade->before_color.a);
1760 evas_object_color_get(after, &fade->after_color.r, &fade->after_color.g,
1761 &fade->after_color.b, &fade->after_color.a);
1763 fade->before = before;
1764 fade->after = after;
1765 fade->before_alpha = (255 - fade->before_color.a);
1766 fade->after_alpha = (255 - fade->after_color.a);
1768 effect->begin_op = _elm_fx_fade_begin;
1769 effect->end_op = _elm_fx_fade_end;
1770 effect->animation_op = _elm_fx_fade_op;
1771 effect->user_data = fade;
1776 /////////////////////////////////////////////////////////////////////////////////////
1778 /////////////////////////////////////////////////////////////////////////////////////
1779 typedef struct _blend Elm_Fx_Blend;
1780 static void _elm_fx_blend_begin(void *data, Eina_Bool auto_reverse,
1781 unsigned int repeat_cnt);
1782 static void _elm_fx_blend_end(void *data, Eina_Bool auto_reverse,
1783 unsigned int repeat_cnt);
1784 static void _elm_fx_blend_op(void *data, Elm_Animator *animator,
1789 Evas_Object *before;
1791 struct _signed_color from, to;
1795 _elm_fx_blend_begin(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
1797 Elm_Fx_Blend *blend = data;
1799 evas_object_show(blend->before);
1803 _elm_fx_blend_end(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
1805 Elm_Fx_Blend *blend = data;
1807 evas_object_color_set(blend->before, blend->from.r, blend->from.g,
1808 blend->from.b, blend->from.a);
1809 evas_object_color_set(blend->after, blend->to.r, blend->to.g, blend->to.b,
1812 evas_object_hide(blend->before);
1814 evas_object_hide(blend->after);
1818 _elm_fx_blend_op(void *data, Elm_Animator *animator, double frame)
1820 Elm_Fx_Blend *blend = data;
1822 evas_object_show(blend->after);
1823 evas_object_color_set(blend->before, (int)(blend->from.r * (1 - frame)),
1824 (int)(blend->from.g * (1 - frame)),
1825 (int)(blend->from.b * (1 - frame)),
1826 (int)(blend->from.a * (1 - frame)));
1827 evas_object_color_set(blend->after, (int)(blend->to.r * frame),
1828 (int)(blend->to.g * frame), (int)(blend->to.b * frame),
1829 (int)(blend->to.a * frame));
1835 * @param[in] before Evas Object before blending
1836 * @param[in] after Evas Object after blending
1837 * @return Blend effect
1842 elm_fx_blend_add(Evas_Object *before, Evas_Object *after)
1846 Elm_Fx_Blend *blend;
1848 if ((!before) && (!after))
1851 effect = calloc(1, sizeof(Elm_Effect));
1855 blend = calloc(1, sizeof(Elm_Fx_Blend));
1862 blend->before = before;
1863 blend->after = after;
1864 evas_object_color_get(before, &blend->from.r, &blend->from.g, &blend->from.b,
1866 evas_object_color_get(after, &blend->to.r, &blend->to.g, &blend->to.b,
1869 effect->begin_op = _elm_fx_blend_begin;
1870 effect->end_op = _elm_fx_blend_end;
1871 effect->animation_op = _elm_fx_blend_op;
1872 effect->user_data = blend;
1877 /////////////////////////////////////////////////////////////////////////////////////
1879 /////////////////////////////////////////////////////////////////////////////////////
1880 typedef struct _rotation Elm_Fx_Rotation;
1881 static void _elm_fx_rotation_begin(void *data, Eina_Bool auto_reverse,
1882 unsigned int repeat_cnt);
1883 static void _elm_fx_rotation_end(void *data, Eina_Bool auto_reverse,
1884 unsigned int repeat_cnt);
1885 static void _elm_fx_rotation_op(void *data, Elm_Animator *animator,
1896 _elm_fx_rotation_begin(void *data, Eina_Bool auto_reverse,
1897 unsigned int repeat_cnt)
1899 Elm_Fx_Rotation *rotation = data;
1901 evas_object_show(rotation->obj);
1905 _elm_fx_rotation_end(void *data, Eina_Bool auto_reverse,
1906 unsigned int repeat_cnt)
1908 Elm_Fx_Rotation *rotation = data;
1910 evas_object_map_enable_set(rotation->obj, EINA_FALSE);
1914 _elm_fx_rotation_op(void *data, Elm_Animator *animator, double frame)
1916 Elm_Fx_Rotation *rotation;
1920 Evas_Coord x, y, w, h;
1924 float half_w, half_h;
1926 map = evas_map_new(4);
1932 evas_map_smooth_set(map, EINA_TRUE);
1933 evas_map_util_points_populate_from_object_full(map, rotation->obj, 0);
1934 degree = rotation->from + (float)(frame * rotation->to);
1939 evas_object_geometry_get(rotation->obj, &x, &y, &w, &h);
1941 half_w = (float)w *0.5;
1943 half_h = (float)h *0.5;
1945 evas_map_util_3d_rotate(map, 0, 0, degree, x + half_w, y + half_h, 0);
1946 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, 10000);
1947 evas_object_map_enable_set(rotation->obj, EINA_TRUE);
1948 evas_object_map_set(rotation->obj, map);
1953 * Add Rotation effect
1955 * @param[in] obj Evas_Object that effect is applying to
1956 * @param[in] from degree Degree when effect begins
1957 * @param[in] to_degree Degree when effect is ends
1958 * @param[in] cw Rotation direction. EINA_TRUE is clock wise
1959 * @return Rotation effect
1964 elm_fx_rotation_add(Evas_Object *obj, float from_degree, float to_degree,
1969 Elm_Fx_Rotation *rotation;
1974 effect = calloc(1, sizeof(Elm_Effect));
1978 rotation = calloc(1, sizeof(Elm_Fx_Rotation));
1986 rotation->obj = obj;
1987 rotation->from = from_degree;
1988 rotation->to = to_degree - from_degree;
1991 effect->begin_op = _elm_fx_rotation_begin;
1992 effect->end_op = _elm_fx_rotation_end;
1993 effect->animation_op = _elm_fx_rotation_op;
1994 effect->user_data = rotation;
2002 /////////////////////////////////////////////////////////////////////////////////////
2004 /////////////////////////////////////////////////////////////////////////////////////
2005 typedef struct _rotation3d Elm_Fx_Rotation3d;
2006 static void _elm_fx_rotation3d_begin(void *data, Eina_Bool auto_reverse,
2007 unsigned int repeat_cnt);
2008 static void _elm_fx_rotation3d_end(void *data, Eina_Bool auto_reverse,
2009 unsigned int repeat_cnt);
2010 static void _elm_fx_rotation3d_op(void *data, Elm_Animator *animator,
2022 _elm_fx_rotation3d_begin(void *data, Eina_Bool auto_reverse,
2023 unsigned int repeat_cnt)
2025 Elm_Fx_Rotation3d *rotation = data;
2026 evas_object_show(rotation->obj);
2030 _elm_fx_rotation3d_end(void *data, Eina_Bool auto_reverse,
2031 unsigned int repeat_cnt)
2033 Elm_Fx_Rotation3d *rotation = data;
2034 evas_object_map_enable_set(rotation->obj, EINA_FALSE);
2038 _elm_fx_rotation3d_op(void *data, Elm_Animator *animator, double frame)
2040 Elm_Fx_Rotation3d *rotation;
2044 Evas_Coord x, y, w, h;
2048 float half_w, half_h;
2050 map = evas_map_new(4);
2056 evas_map_smooth_set(map, EINA_TRUE);
2057 evas_map_util_points_populate_from_object_full(map, rotation->obj, 0);
2058 degree[0] = rotation->from[0] + (float)(frame * rotation->to[0]);
2059 degree[1] = rotation->from[1] + (float)(frame * rotation->to[1]);
2060 degree[2] = rotation->from[2] + (float)(frame * rotation->to[2]);
2062 evas_object_geometry_get(rotation->obj, &x, &y, &w, &h);
2064 half_w = (float)w *0.5;
2066 half_h = (float)h *0.5;
2068 evas_map_util_3d_rotate(map, degree[0], degree[1], degree[2], rotation->axis_pos[0], rotation->axis_pos[1], rotation->axis_pos[2]);
2069 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, 1000);
2070 evas_object_map_enable_set(rotation->obj, EINA_TRUE);
2071 evas_object_map_set(rotation->obj, map);
2076 * Add Rotation3d effect
2078 * @param[in] obj Evas_Object that effect is applying to
2079 * @param[in] from degree Degree when effect begins
2080 * @param[in] to_degree Degree when effect is ends
2081 * @param[in] axis_dir[3] rotation axis vector. it should be normalized.
2082 * @param[in] axis_pos[3] rotation axis origin position.
2083 * @param[in] cw Rotation direction. EINA_TRUE is clock wise
2084 * @return Rotation effect
2089 elm_fx_rotation3d_add(Evas_Object *obj, float from_degree, float to_degree,
2090 float* axis_dir, float* axis_pos)
2094 Elm_Fx_Rotation3d *rotation;
2099 effect = calloc(1, sizeof(Elm_Effect));
2103 rotation = calloc(1, sizeof(Elm_Fx_Rotation3d));
2111 rotation->obj = obj;
2112 rotation->from[0] = from_degree * axis_dir[0];
2113 rotation->from[1] = from_degree * axis_dir[1];
2114 rotation->from[2] = from_degree * axis_dir[2];
2115 rotation->to[0] = (to_degree * axis_dir[0]) - rotation->from[0];
2116 rotation->to[1] = (to_degree * axis_dir[1]) - rotation->from[1];
2117 rotation->to[2] = (to_degree * axis_dir[2]) - rotation->from[2];
2118 rotation->axis_pos[0] = axis_pos[0];
2119 rotation->axis_pos[1] = axis_pos[1];
2120 rotation->axis_pos[2] = axis_pos[2];
2122 effect->begin_op = _elm_fx_rotation3d_begin;
2123 effect->end_op = _elm_fx_rotation3d_end;
2124 effect->animation_op = _elm_fx_rotation3d_op;
2125 effect->user_data = rotation;
2132 /////////////////////////////////////////////////////////////////////////////////////
2133 // ImageAnimation FX
2134 /////////////////////////////////////////////////////////////////////////////////////
2135 typedef struct _image_animation Elm_Fx_Image_Animation;
2136 static void _elm_fx_image_animation_begin(void *data, Eina_Bool auto_reverse,
2137 unsigned int repeat_cnt);
2138 static void _elm_fx_image_animation_op(void *data, Elm_Animator *animator,
2140 EAPI Elm_Effect *elm_fx_image_animation_add(Evas_Object *obj, const char **images,
2141 unsigned int item_num);
2143 struct _image_animation
2152 _elm_fx_image_animation_begin(void *data, Eina_Bool auto_reverse,
2153 unsigned int repeat_cnt)
2155 Elm_Fx_Image_Animation *image_animation = data;
2156 evas_object_show(image_animation->obj);
2161 _elm_fx_image_animation_op(void *data, Elm_Animator *animator, double frame)
2163 Elm_Fx_Image_Animation *image_animation = (Elm_Fx_Image_Animation *) data;
2165 elm_icon_file_set(image_animation->obj,
2166 image_animation->images[ (int) floor(frame * (image_animation->img_cnt-1)) ], NULL);
2170 _elm_fx_image_animation_del(void *data)
2173 Elm_Fx_Image_Animation *image_animation = data;
2175 for(idx = 0; idx < image_animation->img_cnt; ++idx ) {
2176 eina_stringshare_del(image_animation->images[ idx ]);
2179 free(image_animation->images);
2183 * Add image_animation effect.
2185 * @param[in] obj Icon object
2186 * @param[in] images Array of image file path.
2187 * @param[in] img_cnt Count of image.
2188 * @return ImageAnimation effect.
2193 elm_fx_image_animation_add(Evas_Object *obj, const char **images,
2194 unsigned int img_cnt)
2197 Elm_Fx_Image_Animation *image_animation;
2200 if ((!obj) || !images || !(*images))
2203 effect = calloc(1, sizeof(Elm_Effect));
2207 image_animation = calloc(1, sizeof(Elm_Fx_Image_Animation));
2209 if (!image_animation)
2215 image_animation->obj = obj;
2216 image_animation->images = calloc( img_cnt, sizeof(char*));
2217 for(idx = 0; idx < img_cnt; ++idx )
2218 image_animation->images[ idx ] = eina_stringshare_add( images[ idx ] );
2220 image_animation->img_cnt = img_cnt;
2222 effect->begin_op = _elm_fx_image_animation_begin;
2223 effect->animation_op = _elm_fx_image_animation_op;
2224 effect->del_op = _elm_fx_image_animation_del;
2225 effect->user_data = image_animation;