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 *, Elm_Transit *);
18 Eina_Bool reserved_del:1;
23 void (*animation_op)(void *, Elm_Animator *, double);
24 void (*begin_op)(void *, Eina_Bool, unsigned int);
25 void (*end_op)( void *, Eina_Bool, unsigned int);
26 unsigned int shared_cnt;
30 static Evas_Object *_create_block_rect(Evas_Object *parent)
35 rect = evas_object_rectangle_add(evas_object_evas_get(parent));
36 evas_output_size_get(evas_object_evas_get(parent), &w, &h);
37 evas_object_resize(rect, w, h);
38 evas_object_color_set(rect, 0, 0, 0, 0);
42 static void _transit_animate_cb(void *data, Elm_Animator *animator, double frame)
46 Elm_Transit *transit = data;
48 EINA_LIST_FOREACH(transit->effect_list, elist, effect)
50 effect->animation_op(effect->user_data, animator, frame);
54 static void _transit_fx_begin(Elm_Transit *transit)
58 Eina_Bool auto_reverse;
59 unsigned int repeat_cnt;
61 auto_reverse = elm_animator_auto_reverse_get(transit->animator);
62 repeat_cnt = elm_animator_repeat_get(transit->animator);
64 EINA_LIST_FOREACH(transit->effect_list, elist, effect)
67 effect->begin_op(effect->user_data, auto_reverse, repeat_cnt);
71 static void _transit_fx_end(Elm_Transit *transit)
75 Eina_Bool auto_reverse;
76 unsigned int repeat_cnt;
78 auto_reverse = elm_animator_auto_reverse_get(transit->animator);
79 repeat_cnt = elm_animator_repeat_get(transit->animator);
81 EINA_LIST_FOREACH(transit->effect_list, elist, effect)
84 effect->end_op(effect->user_data, auto_reverse, repeat_cnt);
88 static void _transit_complete_cb(void *data)
90 Elm_Transit *transit = (Elm_Transit *) data;
92 evas_render(evas_object_evas_get(transit->parent));
94 _transit_fx_end(transit);
96 if(transit->block_rect)
97 evas_object_hide(transit->block_rect);
99 if(transit->completion_op)
100 transit->completion_op(transit->completion_arg, transit);
102 if(transit->reserved_del)
104 transit->reserved_del = EINA_FALSE;
105 elm_transit_del(transit);
109 static void _transit_fx_del(Elm_Effect *effect)
113 --effect->shared_cnt;
115 if(effect->shared_cnt > 0) return;
116 if(effect->user_data) free(effect->user_data);
123 * Set the event block when the transit is operating.
125 * @param transit Transit object
126 * @param disable Disable or enable
128 EAPI void elm_transit_event_block_disabled_set(Elm_Transit *transit, Eina_Bool disable)
134 if(transit->block_rect)
136 evas_object_del(transit->block_rect);
137 transit->block_rect = NULL;
141 if(transit->block_rect == NULL)
142 transit->block_rect = _create_block_rect(transit->parent);
149 * Get the event block setting status.
151 * @param transit Transit object
152 * @return EINA_TRUE when the event block is disabled
154 EAPI Eina_Bool elm_transit_event_block_disabled_get(Elm_Transit *transit)
156 if(!transit) return EINA_FALSE;
157 return transit->block_rect ? EINA_TRUE : EINA_FALSE;
163 * Remove effect from transit.
165 * @param transit Transit object
166 * @param effect effect that should be removed
167 * @return EINA_TRUE, if the effect is removed
168 * @warning If the effect is not inserted in any transit, it will be deleted
170 EAPI Eina_Bool elm_transit_fx_remove(Elm_Transit *transit, Elm_Effect *effect)
175 if(!transit) return EINA_FALSE;
177 EINA_LIST_FOREACH(transit->effect_list, elist, _effect)
179 if(_effect == effect)
181 transit->effect_list = eina_list_remove(transit->effect_list, _effect);
182 _transit_fx_del(_effect);
192 * Remove all current inseted effects.
194 * @param transit Transit object
196 EAPI void elm_transit_fx_clear(Elm_Transit *transit)
203 EINA_LIST_FOREACH(transit->effect_list, elist, effect)
205 transit->effect_list = eina_list_remove(transit->effect_list, effect);
206 _transit_fx_del(effect);
213 * Remove all current inseted effects.
215 * @param transit Transit object
216 * @return Effect list
218 EAPI const Eina_List *elm_transit_fx_get(Elm_Transit *transit)
220 if(!transit) return NULL;
221 return transit->effect_list;
227 * Set the user-callback function when the transit is done.
229 * @param transit Transit object
230 * @param op Callback function pointer
231 * @param data Callback funtion user argument
233 EAPI void elm_transit_completion_callback_set(Elm_Transit *transit, void (*op)(void *data, Elm_Transit* transit), void *data)
236 transit->completion_op = op;
237 transit->completion_arg = data;
243 * Delete transit object.
245 * @param transit Transit object
247 EAPI void elm_transit_del(Elm_Transit *transit)
250 if(elm_animator_operating_get(transit->animator))
252 transit->reserved_del = EINA_TRUE;
256 if(transit->block_rect)
257 evas_object_del( transit->block_rect );
259 elm_animator_del(transit->animator);
260 elm_transit_fx_clear(transit);
270 * Set the animation acceleration style.
272 * @param transit Transit object
273 * @param cs Curve style
275 EAPI void elm_transit_curve_style_set(Elm_Transit* transit, Elm_Animator_Curve_Style cs)
278 elm_animator_curve_style_set(transit->animator, cs);
289 * @param parent Given canvas of parent object will be blocked
290 * @return Transit object
292 EAPI Elm_Transit *elm_transit_add(Evas_Object *parent)
294 Elm_Transit *transit = calloc(1, sizeof(Elm_Transit));
296 if(!transit) return NULL;
298 transit->animator = elm_animator_add(parent);
300 if(!transit->animator)
306 transit->parent = parent;
307 elm_animator_operation_callback_set(transit->animator, _transit_animate_cb, transit);
308 elm_animator_completion_callback_set(transit->animator, _transit_complete_cb, transit);
309 elm_transit_event_block_disabled_set(transit, EINA_FALSE);
317 * Set auto reverse function.
319 * @param transit Transit object
320 * @param reverse Reverse or not
322 EAPI void elm_transit_auto_reverse_set(Elm_Transit *transit, Eina_Bool reverse)
325 elm_animator_auto_reverse_set(transit->animator, reverse);
331 * Insert an effect in given transit.
333 * @param transit Transit object.
334 * @param effect Effect
335 * @return EINA_TRUE is success
337 EAPI Eina_Bool elm_transit_fx_insert(Elm_Transit *transit, Elm_Effect *effect)
342 if(!transit) return EINA_FALSE;
344 EINA_LIST_FOREACH(transit->effect_list, elist, _effect)
346 if(_effect == effect) return EINA_FALSE;
349 ++effect->shared_cnt;
350 transit->effect_list = eina_list_append(transit->effect_list, effect);
358 * Set the transit repeat count. Effect will be repeated by repeat count.
360 * @param transit Transit object
361 * @param repeat Repeat count
363 EAPI void elm_transit_repeat_set(Elm_Transit *transit, unsigned int repeat)
366 elm_animator_repeat_set(transit->animator, repeat);
372 * Stop the current transit effect if transit is operating.
374 * @param transit Transit object
376 EAPI void elm_transit_stop(Elm_Transit *transit)
379 elm_animator_stop(transit->animator);
385 * Run the all the inserted effects.
387 * @param transit Transit object
388 * @param duration Transit time in second
390 EAPI void elm_transit_run(Elm_Transit *transit, double duration)
393 _transit_fx_begin(transit);
394 elm_animator_duration_set(transit->animator, duration);
397 if(transit->block_rect)
398 evas_object_show(transit->block_rect);
400 elm_animator_animate(transit->animator);
402 //If failed to animate.
403 if(!elm_animator_operating_get(transit->animator))
405 if(transit->block_rect)
406 evas_object_hide(transit->block_rect);
407 _transit_fx_end(transit);
411 /////////////////////////////////////////////////////////////////////////////////////
413 /////////////////////////////////////////////////////////////////////////////////////
414 typedef struct _resizing Elm_Fx_Resizing;
415 static void _elm_fx_resizing_op(void *data, Elm_Animator *animator, double frame);
426 static void _elm_fx_resizing_begin(void* data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
428 Elm_Fx_Resizing *resizing = data;
429 evas_object_show(resizing->obj);
430 evas_object_resize(resizing->obj, resizing->from.w, resizing->from.h);
433 static void _elm_fx_resizing_end(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
435 Elm_Fx_Resizing *resizing = data;
436 evas_object_move(resizing->obj, resizing->from.w + resizing->to.w, resizing->from.h + resizing->to.h);
439 static void _elm_fx_resizing_op(void *data, Elm_Animator *animator, double frame)
442 Elm_Fx_Resizing *resizing = data;
443 w = resizing->from.w + (Evas_Coord)((float) resizing->to.h * (float) frame);
444 h = resizing->from.h + (Evas_Coord)((float) resizing->to.w * (float) frame);
445 evas_object_resize(resizing->obj, w, h);
451 * Add resizing effect.
453 * @param obj Evas_Object that effect is applying to
454 * @param from_w Width size when effect begin
455 * @param from_h Height size whene effect begin
456 * @param to_w Width size to be
457 * @param to_h Height size to be
458 * @return Resizing effect
460 EAPI Elm_Effect *elm_fx_resizing_add(Evas_Object* obj, Evas_Coord from_w, Evas_Coord from_h, Evas_Coord to_w, Evas_Coord to_h)
463 Elm_Fx_Resizing *resizing;
464 if(!obj) return NULL;
466 effect = calloc(1, sizeof(Elm_Effect));
467 if(!effect) return NULL;
469 resizing = calloc(1, sizeof(Elm_Fx_Resizing));
477 resizing->from.w = from_w;
478 resizing->from.h = from_h;
479 resizing->to.w = to_w - from_w;
480 resizing->to.h = to_h - from_h;
482 effect->begin_op = _elm_fx_resizing_begin;
483 effect->animation_op = _elm_fx_resizing_op;
484 effect->user_data = resizing;
489 /////////////////////////////////////////////////////////////////////////////////////
491 /////////////////////////////////////////////////////////////////////////////////////
492 typedef struct _translation Elm_Fx_Translation;
493 static void _elm_fx_translation_op(void *data, Elm_Animator *animator, double frame);
504 static void _elm_fx_translation_begin(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
506 Elm_Fx_Translation *translation = data;
507 evas_object_show(translation->obj);
508 evas_object_move(translation->obj, translation->from.x, translation->from.y);
511 static void _elm_fx_translation_end(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
513 Elm_Fx_Translation *translation = data;
514 evas_object_move(translation->obj, translation->from.x + translation->to.x, translation->from.y + translation->to.y);
517 static void _elm_fx_translation_op(void *data, Elm_Animator *animator, double frame)
520 Elm_Fx_Translation *translation = data;
521 x = translation->from.x + (Evas_Coord)((float) translation->to.x * (float) frame);
522 y = translation->from.y + (Evas_Coord)((float) translation->to.y * (float) frame);
523 evas_object_move(translation->obj, x, y);
529 * Add translation effect.
531 * @param obj Evas_Object that effect is applying to
532 * @param from_x Position X when effect begin
533 * @param from_y Position Y whene effect begin
534 * @param to_x Position X to be
535 * @param to_y Position Y to be
536 * @return Translation effect
538 EAPI Elm_Effect *elm_fx_translation_add(Evas_Object *obj, Evas_Coord from_x, Evas_Coord from_y, Evas_Coord to_x, Evas_Coord to_y)
541 Elm_Fx_Translation *translation;
543 if(!obj) return NULL;
545 effect = calloc(1, sizeof(Elm_Effect));
546 if(!effect) return NULL;
548 translation = calloc(1, sizeof(Elm_Fx_Translation));
556 translation->obj = obj;
557 translation->from.x = from_x;
558 translation->from.y = from_y;
559 translation->to.x = to_x - from_x;
560 translation->to.y = to_y - from_y;
562 effect->begin_op = _elm_fx_translation_begin;
563 effect->end_op = _elm_fx_translation_end;
564 effect->animation_op = _elm_fx_translation_op;
565 effect->user_data = translation;
570 /////////////////////////////////////////////////////////////////////////////////////
572 /////////////////////////////////////////////////////////////////////////////////////
573 typedef struct _zoom Elm_Fx_Zoom;
574 static void _elm_fx_zoom_op(void *data, Elm_Animator *animator, double frame);
581 static void _elm_fx_zoom_begin(void *data, Eina_Bool reverse, unsigned int repeat)
583 Elm_Fx_Zoom *zoom = data;
584 evas_object_show(zoom->obj);
585 _elm_fx_zoom_op(data, NULL, 0);
588 static void _elm_fx_zoom_end(void *data, Eina_Bool reverse, unsigned int repeat)
590 Elm_Fx_Zoom *zoom = data;
591 evas_object_map_enable_set(zoom->obj, EINA_FALSE);
594 static void _elm_fx_zoom_op(void *data, Elm_Animator *animator, double frame)
598 Evas_Coord x, y, w, h;
600 map = evas_map_new(4);
604 evas_object_geometry_get(zoom->obj, &x, &y, &w, &h);
605 evas_map_smooth_set(map, EINA_TRUE);
606 evas_map_util_points_populate_from_object_full(map, zoom->obj, zoom->from + (frame * zoom->to));
607 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, 10000);
608 evas_object_map_set(zoom->obj, map);
609 evas_object_map_enable_set(zoom->obj, EINA_TRUE);
618 * @param obj Evas_Object that effect is applying to
619 * @param from_rate Scale rate when the effect begin (1 is current rate)
620 * @param to_rate Scale rate to be
621 * @return Zoom effect
623 EAPI Elm_Effect *elm_fx_zoom_add(Evas_Object *obj, float from_rate, float to_rate)
628 if(!obj) return NULL;
630 effect = calloc(1, sizeof(Elm_Effect));
631 if(!effect) return NULL;
633 zoom = calloc(1, sizeof(Elm_Fx_Zoom));
641 zoom->from = (10000 - (from_rate * 10000)) * (1 / from_rate);
642 zoom->to = ((10000 - (to_rate * 10000)) * (1 / to_rate)) - zoom->from;
643 effect->begin_op = _elm_fx_zoom_begin;
644 effect->end_op = _elm_fx_zoom_end;
645 effect->animation_op = _elm_fx_zoom_op;
646 effect->user_data = zoom;
652 /////////////////////////////////////////////////////////////////////////////////////
654 /////////////////////////////////////////////////////////////////////////////////////
655 typedef struct _flip Elm_Fx_Flip;
661 Elm_Fx_Flip_Axis axis;
665 static void _elm_fx_flip_end(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
667 Elm_Fx_Flip *flip = data;
668 evas_object_map_enable_set(flip->front, EINA_FALSE);
669 evas_object_map_enable_set(flip->back, EINA_FALSE);
672 static void _elm_fx_flip_op(void *data, Elm_Animator *animator, double frame)
678 Evas_Coord x, y, w, h;
680 map = evas_map_new(4);
685 if(flip->cw) degree = (float) (frame * 180);
686 else degree = (float) (frame * -180);
688 if(degree < 90 && degree > -90)
691 evas_object_hide(flip->back);
692 evas_object_show(flip->front);
697 evas_object_hide(flip->front);
698 evas_object_show(flip->back);
701 evas_map_smooth_set(map, EINA_TRUE);
702 evas_map_util_points_populate_from_object_full(map, obj, 0);
703 evas_object_geometry_get(obj, &x, &y, &w, &h);
704 Evas_Coord half_w =(w / 2);
705 Evas_Coord half_h =(h / 2);
707 if(flip->axis == ELM_FX_FLIP_AXIS_Y)
709 if((degree >= 90)||(degree <= -90))
711 evas_map_point_image_uv_set(map, 0, w, 0);
712 evas_map_point_image_uv_set(map, 1, 0, 0);
713 evas_map_point_image_uv_set(map, 2, 0, h);
714 evas_map_point_image_uv_set(map, 3, w, h);
716 evas_map_util_3d_rotate(map, 0, degree, 0, x + half_w, y + half_h, 0);
718 if((degree >= 90)||(degree <= -90))
720 evas_map_point_image_uv_set(map, 0, 0, h);
721 evas_map_point_image_uv_set(map, 1, w, h);
722 evas_map_point_image_uv_set(map, 2, w, 0);
723 evas_map_point_image_uv_set(map, 3, 0, 0);
725 evas_map_util_3d_rotate(map, degree, 0, 0, x + half_w, y + half_h, 0);
727 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, 10000);
728 evas_object_map_enable_set(flip->front, EINA_TRUE);
729 evas_object_map_enable_set(flip->back, EINA_TRUE);
730 evas_object_map_set(obj, map);
739 * @param front Front surface object
740 * @param back Back surface object
741 * @param axis Flipping Axis. X or Y
742 * @param cw Flipping Direction. EINA_TRUE is clock-wise
743 * @return Flip effect
745 EAPI Elm_Effect *elm_fx_flip_add(Evas_Object *front, Evas_Object *back, Elm_Fx_Flip_Axis axis, Eina_Bool cw)
750 if((!front)||(!back)) return NULL;
752 effect = calloc(1, sizeof(Elm_Effect));
753 if(!effect) return NULL;
755 flip = calloc(1, sizeof(Elm_Fx_Flip));
767 effect->end_op = _elm_fx_flip_end;
768 effect->animation_op = _elm_fx_flip_op;
769 effect->user_data = flip;
774 /////////////////////////////////////////////////////////////////////////////////////
776 /////////////////////////////////////////////////////////////////////////////////////
777 typedef struct _resizable_flip Elm_Fx_ResizableFlip;
778 static void _elm_fx_resizable_flip_op(void *data, Elm_Animator *animator, double frame);
780 struct _resizable_flip
784 Elm_Fx_Flip_Axis axis;
788 } from_pos, from_size, to_pos, to_size;
792 static void _elm_fx_resizable_flip_begin(void *data, Eina_Bool reverse, unsigned int repeat)
794 Elm_Fx_ResizableFlip *resizable_flip = data;
795 evas_object_show(resizable_flip->front);
796 _elm_fx_resizable_flip_op(data, NULL, 0);
799 static void _elm_fx_resizable_flip_end(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
801 Elm_Fx_ResizableFlip *resizable_flip = data;
802 evas_object_map_enable_set(resizable_flip->front, EINA_FALSE);
803 evas_object_map_enable_set(resizable_flip->back, EINA_FALSE);
806 static void _set_image_uv_by_axis_y(Evas_Map *map, Elm_Fx_ResizableFlip *flip, float degree)
808 if((degree >= 90)||(degree <= -90))
810 evas_map_point_image_uv_set(map, 0, (flip->from_size.x * 2) + flip->to_size.x, 0);
811 evas_map_point_image_uv_set(map, 1, 0, 0);
812 evas_map_point_image_uv_set(map, 2, 0, (flip->from_size.y * 2) + flip->to_size.y);
813 evas_map_point_image_uv_set(map, 3, (flip->from_size.x * 2) + flip->to_size.x, (flip->from_size.y * 2) + flip->to_size.y);
817 evas_map_point_image_uv_set(map, 0, 0, 0);
818 evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
819 evas_map_point_image_uv_set(map, 2, flip->from_size.x, flip->from_size.y);
820 evas_map_point_image_uv_set(map, 3, 0, flip->to_size.y);
824 static void _set_image_uv_by_axis_x(Evas_Map *map, Elm_Fx_ResizableFlip *flip, float degree)
826 if((degree >= 90)||(degree <= -90))
828 evas_map_point_image_uv_set(map, 0, 0, (flip->from_size.y * 2) + flip->to_size.y);
829 evas_map_point_image_uv_set(map, 1, (flip->from_size.x * 2) + flip->to_size.x, (flip->from_size.y * 2) + flip->to_size.y);
830 evas_map_point_image_uv_set(map, 2, (flip->from_size.x * 2) + flip->to_size.x, 0);
831 evas_map_point_image_uv_set(map, 3, 0, 0);
834 evas_map_point_image_uv_set(map, 0, 0, 0);
835 evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
836 evas_map_point_image_uv_set(map, 2, flip->from_size.x, flip->from_size.y);
837 evas_map_point_image_uv_set(map, 3, 0, flip->to_size.y);
841 static void _elm_fx_resizable_flip_op(void *data, Elm_Animator *animator, double frame)
843 Elm_Fx_ResizableFlip *resizable_flip;
848 Evas_Coord half_w, half_h;
850 map = evas_map_new(4);
853 resizable_flip = data;
855 if(resizable_flip->cw) degree = (float) (frame * 180);
856 else degree = (float) (frame * -180);
858 if((degree < 90) && (degree > -90))
860 obj = resizable_flip->front;
861 evas_object_hide(resizable_flip->back);
862 evas_object_show(resizable_flip->front);
866 obj = resizable_flip->back;
867 evas_object_hide(resizable_flip->front);
868 evas_object_show(resizable_flip->back);
871 evas_map_smooth_set(map, EINA_TRUE);
873 x = resizable_flip->from_pos.x + (resizable_flip->to_pos.x * frame);
874 y = resizable_flip->from_pos.y + (resizable_flip->to_pos.y * frame);
875 w = resizable_flip->from_size.x + (resizable_flip->to_size.x * frame);
876 h = resizable_flip->from_size.y + (resizable_flip->to_size.y * frame);
877 evas_map_point_coord_set(map, 0, x, y, 0);
878 evas_map_point_coord_set(map, 1, x + w, y, 0);
879 evas_map_point_coord_set(map, 2, x + w, y + h, 0);
880 evas_map_point_coord_set(map, 3, x, y + h, 0);
882 half_w = (Evas_Coord) (w / 2);
883 half_h = (Evas_Coord) (h / 2);
885 if(resizable_flip->axis == ELM_FX_FLIP_AXIS_Y)
887 _set_image_uv_by_axis_y(map, resizable_flip, degree);
888 evas_map_util_3d_rotate(map, 0, degree, 0, x + half_w, y + half_h, 0);
892 _set_image_uv_by_axis_x(map, resizable_flip, degree);
893 evas_map_util_3d_rotate(map, degree, 0, 0, x + half_w, y + half_h, 0);
896 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, 10000);
897 evas_object_map_enable_set(resizable_flip->front, EINA_TRUE);
898 evas_object_map_enable_set(resizable_flip->back, EINA_TRUE);
899 evas_object_map_set(obj, map);
906 * Add ResizbleFlip effect.
908 * @param front Front surface object
909 * @param back Back surface object
910 * @param axis Flipping Axis. X or Y
911 * @param cw Flipping Direction. EINA_TRUE is clock-wise
912 * @return Flip effect
914 EAPI Elm_Effect *elm_fx_resizable_flip_add(Evas_Object *front, Evas_Object *back, Elm_Fx_Flip_Axis axis, Eina_Bool cw)
916 Elm_Fx_ResizableFlip *resizable_flip;
918 Evas_Coord front_x, front_y, front_w, front_h;
919 Evas_Coord back_x, back_y, back_w, back_h;
921 if(!front||!back) return NULL;
923 effect = calloc(1, sizeof(Elm_Effect));
924 if(!effect) return NULL;
926 resizable_flip = calloc(1, sizeof(Elm_Fx_ResizableFlip));
934 resizable_flip->front = front;
935 resizable_flip->back = back;
936 resizable_flip->cw = cw;
937 resizable_flip->axis = axis;
939 evas_object_geometry_get( resizable_flip->front, &front_x, &front_y, &front_w, &front_h );
940 evas_object_geometry_get( resizable_flip->back, &back_x, &back_y, &back_w, &back_h );
942 resizable_flip->from_pos.x = front_x;
943 resizable_flip->from_pos.y = front_y;
944 resizable_flip->to_pos.x = back_x - front_x;
945 resizable_flip->to_pos.y = back_y - front_y;
947 resizable_flip->from_size.x = front_w;
948 resizable_flip->from_size.y = front_h;
949 resizable_flip->to_size.x = back_w - front_w;
950 resizable_flip->to_size.y = back_h - front_h;
952 effect->begin_op = _elm_fx_resizable_flip_begin;
953 effect->end_op = _elm_fx_resizable_flip_end;
954 effect->animation_op = _elm_fx_resizable_flip_op;
955 effect->user_data = resizable_flip;
960 /////////////////////////////////////////////////////////////////////////////////////
962 /////////////////////////////////////////////////////////////////////////////////////
963 typedef struct _wipe Elm_Fx_Wipe;
964 static void _elm_fx_wipe_op(void *data, Elm_Animator *animator, double frame);
969 Elm_Fx_Wipe_Type type;
973 static void _elm_fx_wipe_begin(void *data, Eina_Bool auto_repeat, unsigned int repeat_cnt)
975 Elm_Fx_Wipe *wipe = data;
976 evas_object_show(wipe->obj);
977 _elm_fx_wipe_op(data, NULL, 0);
980 static void _elm_fx_wipe_end(void *data, Eina_Bool auto_repeat, unsigned int repeat_cnt)
982 Elm_Fx_Wipe *wipe = data;
983 evas_object_map_enable_set(wipe->obj, EINA_FALSE);
986 static void _elm_fx_wipe_hide(Evas_Map *map, Elm_Fx_Wipe_Dir dir, float x, float y, float w, float h, float frame)
992 case ELM_FX_WIPE_DIR_LEFT:
993 w2 = w - (w * frame);
995 evas_map_point_image_uv_set(map, 0, 0, 0);
996 evas_map_point_image_uv_set(map, 1, w2, 0);
997 evas_map_point_image_uv_set(map, 2, w2, h);
998 evas_map_point_image_uv_set(map, 3, 0, h);
999 evas_map_point_coord_set(map, 0, x, y, 0);
1000 evas_map_point_coord_set(map, 1, x + w2, y, 0);
1001 evas_map_point_coord_set(map, 2, x + w2, h2, 0);
1002 evas_map_point_coord_set(map, 3, x, h2, 0);
1004 case ELM_FX_WIPE_DIR_RIGHT:
1007 evas_map_point_image_uv_set(map, 0, w2, 0);
1008 evas_map_point_image_uv_set(map, 1, w, 0);
1009 evas_map_point_image_uv_set(map, 2, w, h);
1010 evas_map_point_image_uv_set(map, 3, w2, h);
1011 evas_map_point_coord_set(map, 0, x + w2, y, 0);
1012 evas_map_point_coord_set(map, 1, x + w, y, 0);
1013 evas_map_point_coord_set(map, 2, x + w, h2, 0);
1014 evas_map_point_coord_set(map, 3, x + w2, h2, 0);
1016 case ELM_FX_WIPE_DIR_UP:
1018 h2 = h - (h * frame);
1019 evas_map_point_image_uv_set(map, 0, 0, 0);
1020 evas_map_point_image_uv_set(map, 1, w, 0);
1021 evas_map_point_image_uv_set(map, 2, w, h2);
1022 evas_map_point_image_uv_set(map, 3, 0, h2);
1023 evas_map_point_coord_set(map, 0, x, y, 0);
1024 evas_map_point_coord_set(map, 1, w2, y, 0);
1025 evas_map_point_coord_set(map, 2, w2, h2, 0);
1026 evas_map_point_coord_set(map, 3, x, h2, 0);
1028 case ELM_FX_WIPE_DIR_DOWN:
1031 evas_map_point_image_uv_set(map, 0, 0, h2);
1032 evas_map_point_image_uv_set(map, 1, w, h2);
1033 evas_map_point_image_uv_set(map, 2, w, h);
1034 evas_map_point_image_uv_set(map, 3, 0, h);
1035 evas_map_point_coord_set(map, 0, x, y + h2, 0);
1036 evas_map_point_coord_set(map, 1, w2, y + h2, 0 );
1037 evas_map_point_coord_set(map, 2, w2, y + h, 0);
1038 evas_map_point_coord_set(map, 3, x, y + h, 0);
1044 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, 10000);
1048 static void _elm_fx_wipe_show(Evas_Map *map, Elm_Fx_Wipe_Dir dir, float x, float y, float w, float h, float frame)
1054 case ELM_FX_WIPE_DIR_LEFT:
1055 w2 = (w - (w * frame));
1057 evas_map_point_image_uv_set(map, 0, w2, 0);
1058 evas_map_point_image_uv_set(map, 1, w, 0);
1059 evas_map_point_image_uv_set(map, 2, w, h);
1060 evas_map_point_image_uv_set(map, 3, w2, h);
1061 evas_map_point_coord_set(map, 0, x + w2, y, 0);
1062 evas_map_point_coord_set(map, 1, w, y, 0);
1063 evas_map_point_coord_set(map, 2, w, h2, 0);
1064 evas_map_point_coord_set(map, 3, x + w2, h2, 0);
1066 case ELM_FX_WIPE_DIR_RIGHT:
1069 evas_map_point_image_uv_set(map, 0, 0, 0);
1070 evas_map_point_image_uv_set(map, 1, w2, 0);
1071 evas_map_point_image_uv_set(map, 2, w2, h);
1072 evas_map_point_image_uv_set(map, 3, 0, h);
1073 evas_map_point_coord_set(map, 0, x, y, 0);
1074 evas_map_point_coord_set(map, 1, x + w2, y, 0);
1075 evas_map_point_coord_set(map, 2, x + w2, h2, 0);
1076 evas_map_point_coord_set(map, 3, x, h2, 0);
1078 case ELM_FX_WIPE_DIR_UP:
1080 h2 = (h - (h * frame));
1081 evas_map_point_image_uv_set(map, 0, 0, h2);
1082 evas_map_point_image_uv_set(map, 1, w, h2);
1083 evas_map_point_image_uv_set(map, 2, w, h);
1084 evas_map_point_image_uv_set(map, 3, 0, h);
1085 evas_map_point_coord_set(map, 0, x, y + h2, 0);
1086 evas_map_point_coord_set(map, 1, w2, y + h2, 0);
1087 evas_map_point_coord_set(map, 2, w2, y + h, 0);
1088 evas_map_point_coord_set(map, 3, x, y + h, 0);
1090 case ELM_FX_WIPE_DIR_DOWN:
1093 evas_map_point_image_uv_set(map, 0, 0, 0);
1094 evas_map_point_image_uv_set(map, 1, w, 0);
1095 evas_map_point_image_uv_set(map, 2, w, h2);
1096 evas_map_point_image_uv_set(map, 3, 0, h2);
1097 evas_map_point_coord_set(map, 0, x, y, 0);
1098 evas_map_point_coord_set(map, 1, w2, y, 0);
1099 evas_map_point_coord_set(map, 2, w2, y + h2, 0);
1100 evas_map_point_coord_set(map, 3, x, y + h2, 0);
1106 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, 10000);
1109 static void _elm_fx_wipe_op(void *data, Elm_Animator *animator, double frame)
1113 Evas_Coord _x, _y, _w, _h;
1115 map = evas_map_new(4);
1119 evas_map_smooth_set(map, EINA_TRUE);
1120 evas_object_geometry_get(wipe->obj, &_x, &_y, &_w, &_h);
1122 if(wipe->type == ELM_FX_WIPE_TYPE_SHOW)
1123 _elm_fx_wipe_show(map, wipe->dir, _x, _y, _w, _h, (float) frame);
1125 _elm_fx_wipe_hide(map, wipe->dir, _x, _y, _w, _h, (float) frame);
1127 evas_object_map_enable_set(wipe->obj, EINA_TRUE);
1128 evas_object_map_set(wipe->obj, map);
1137 * @param obj Evas_Object that effect is applying to
1138 * @param type Wipe type. Hide or show
1139 * @param dir Wipe Direction
1140 * @return Wipe Effect
1142 EAPI Elm_Effect *elm_fx_wipe_add(Evas_Object *obj, Elm_Fx_Wipe_Type type, Elm_Fx_Wipe_Dir dir)
1147 if(!obj) return NULL;
1149 effect = calloc(1, sizeof(Elm_Effect));
1150 if(!effect) return NULL;
1152 wipe = calloc(1, sizeof(Elm_Fx_Wipe));
1161 effect->begin_op = _elm_fx_wipe_begin;
1162 effect->end_op = _elm_fx_wipe_end;
1163 effect->animation_op = _elm_fx_wipe_op;
1164 effect->user_data = wipe;
1169 /////////////////////////////////////////////////////////////////////////////////////
1171 /////////////////////////////////////////////////////////////////////////////////////
1172 typedef struct _color Elm_Fx_Color;
1177 struct _unsigned_color
1179 unsigned int r, g, b, a;
1181 struct _signed_color
1187 static void _elm_fx_color_begin(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
1189 Elm_Fx_Color *color = data;
1190 evas_object_show(color->obj);
1193 static void _elm_fx_color_op(void *data, Elm_Animator *animator, double frame)
1195 Elm_Fx_Color *color;
1196 unsigned int r, g, b, a;
1198 r = (color->from.r + (int) ( (float) color->to.r * frame ));
1199 g = (color->from.g + (int) ( (float) color->to.g * frame ));
1200 b = (color->from.b + (int) ( (float) color->to.b * frame ));
1201 a = (color->from.a + (int) ( (float) color->to.a * frame ));
1203 evas_object_color_set(color->obj, r, g, b, a);
1211 * @param obj Evas_Object that effect is applying to
1212 * @param from_r RGB R when the effect begins
1213 * @param from_g RGB G when the effect begins
1214 * @param from_b RGB B when the effect begins
1215 * @param from_a RGB A when the effect begins
1216 * @param to_r RGB R to be
1217 * @param to_g RGB G to be
1218 * @param to_b RGB B to be
1219 * @param to_a RGB A to be
1220 * @return Color Effect
1222 EAPI Elm_Effect* elm_fx_color_add(Evas_Object *obj, unsigned int from_r, unsigned int from_g, unsigned int from_b, unsigned int from_a, unsigned int to_r, unsigned int to_g, unsigned int to_b, unsigned int to_a)
1225 Elm_Fx_Color *color;
1226 if(!obj) return NULL;
1228 effect = calloc(1, sizeof(Elm_Effect));
1229 if(!effect) return NULL;
1231 color = calloc(1, sizeof(Elm_Fx_Color));
1239 color->from.r = from_r;
1240 color->from.g = from_g;
1241 color->from.b = from_b;
1242 color->from.a = from_a;
1243 color->to.r = to_r - from_r;
1244 color->to.g = to_g - from_g;
1245 color->to.b = to_b - from_b;
1246 color->to.a = to_a - from_a;
1248 effect->begin_op = _elm_fx_color_begin;
1249 effect->animation_op = _elm_fx_color_op;
1250 effect->user_data = color;
1255 /////////////////////////////////////////////////////////////////////////////////////
1257 /////////////////////////////////////////////////////////////////////////////////////
1258 typedef struct _fade Elm_Fx_Fade;
1262 Evas_Object *before;
1264 struct _signed_color before_color, after_color;
1267 Eina_Bool inversed : 1;
1270 static void _elm_fx_fade_begin(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
1272 Elm_Fx_Fade *fade = data;
1273 fade->inversed = EINA_FALSE;
1276 static void _elm_fx_fade_end(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
1278 Elm_Fx_Fade *fade = data;
1279 evas_object_color_set(fade->before, fade->before_color.r, fade->before_color.g, fade->before_color.b, fade->before_color.a);
1280 evas_object_color_set(fade->after, fade->after_color.r, fade->after_color.g, fade->after_color.b, fade->after_color.a);
1283 static void _elm_fx_fade_op(void *data, Elm_Animator *animator, double frame)
1294 evas_object_hide(fade->after);
1295 evas_object_show(fade->before);
1296 fade->inversed = EINA_TRUE;
1299 _frame = (1 - (frame * 2));
1301 evas_object_color_set( fade->before, fade->before_color.r * _frame, fade->before_color.g * _frame, fade->before_color.b * _frame, fade->before_color.a + fade->before_alpha * (1-_frame));
1306 evas_object_hide(fade->before);
1307 evas_object_show(fade->after);
1308 fade->inversed = EINA_FALSE;
1311 _frame = ((frame - 0.5) * 2);
1313 evas_object_color_set(fade->after, fade->after_color.r * _frame, fade->after_color.g * _frame, fade->after_color.b * _frame, fade->after_color.a + fade->after_alpha * (1 -_frame));
1324 * @param before Evas Object before fade in
1325 * @param after Evas Object after fade out
1326 * @return Fade Effect
1328 EAPI Elm_Effect *elm_fx_fade_add(Evas_Object *before, Evas_Object *after)
1333 if((!before) && (!after)) return NULL;
1335 effect = calloc(1, sizeof(Elm_Effect));
1336 if(!effect) return NULL;
1338 fade = calloc(1, sizeof(Elm_Fx_Fade));
1346 evas_object_color_get(before, &fade->before_color.r, &fade->before_color.g, &fade->before_color.b, &fade->before_color.a);
1347 evas_object_color_get(after, &fade->after_color.r, &fade->after_color.g, &fade->after_color.b, &fade->after_color.a);
1349 fade->before = before;
1350 fade->after = after;
1351 fade->before_alpha = (255 - fade->before_color.a);
1352 fade->after_alpha = (255 - fade->after_color.a);
1354 effect->begin_op = _elm_fx_fade_begin;
1355 effect->end_op = _elm_fx_fade_end;
1356 effect->animation_op = _elm_fx_fade_op;
1357 effect->user_data = fade;
1362 /////////////////////////////////////////////////////////////////////////////////////
1364 /////////////////////////////////////////////////////////////////////////////////////
1365 typedef struct _blend Elm_Fx_Blend;
1369 Evas_Object *before;
1371 struct _signed_color from, to;
1374 static void _elm_fx_blend_begin(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
1376 Elm_Fx_Blend *blend = data;
1377 evas_object_show(blend->before);
1380 static void _elm_fx_blend_end(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
1382 Elm_Fx_Blend *blend = data;
1383 evas_object_color_set(blend->before, blend->from.r, blend->from.g, blend->from.b, blend->from.a);
1384 evas_object_color_set(blend->after, blend->to.r, blend->to.g, blend->to.b, blend->to.a);
1386 evas_object_hide(blend->before);
1388 evas_object_hide(blend->after);
1391 static void _elm_fx_blend_op(void *data, Elm_Animator *animator, double frame)
1393 Elm_Fx_Blend *blend = data;
1394 evas_object_show(blend->after);
1395 evas_object_color_set(blend->before, (int) (blend->from.r * (1 - frame)), (int) (blend->from.g * (1 - frame)), (int) (blend->from.b * (1 - frame)), (int) (blend->from.a * (1 - frame)));
1396 evas_object_color_set(blend->after, (int) (blend->to.r * frame), (int) (blend->to.g * frame), (int) (blend->to.b * frame), (int) (blend->to.a * frame));
1404 * @param before Evas Object before blending
1405 * @param after Evas Object after blending
1406 * @return Blend Effect
1408 EAPI Elm_Effect *elm_fx_blend_add(Evas_Object *before, Evas_Object *after)
1411 Elm_Fx_Blend *blend;
1413 if((!before) && (!after)) return NULL;
1415 effect = calloc(1, sizeof(Elm_Effect));
1416 if(!effect) return NULL;
1418 blend = calloc(1, sizeof(Elm_Fx_Blend));
1425 blend->before = before;
1426 blend->after = after;
1427 evas_object_color_get(before, &blend->from.r, &blend->from.g, &blend->from.b, &blend->from.a);
1428 evas_object_color_get(after, &blend->to.r, &blend->to.g, &blend->to.b, &blend->to.a);
1430 effect->begin_op = _elm_fx_blend_begin;
1431 effect->end_op = _elm_fx_blend_end;
1432 effect->animation_op = _elm_fx_blend_op;
1433 effect->user_data = blend;
1438 /////////////////////////////////////////////////////////////////////////////////////
1440 /////////////////////////////////////////////////////////////////////////////////////
1441 typedef struct _rotation Elm_Fx_Rotation;
1450 static void _elm_fx_rotation_begin(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
1452 Elm_Fx_Rotation *rotation = data;
1453 evas_object_show(rotation->obj);
1456 static void _elm_fx_rotation_end(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
1458 Elm_Fx_Rotation *rotation = data;
1459 evas_object_map_enable_set(rotation->obj, EINA_FALSE);
1462 static void _elm_fx_rotation_op(void *data, Elm_Animator *animator, double frame)
1464 Elm_Fx_Rotation *rotation;
1466 Evas_Coord x, y, w, h;
1468 float half_w, half_h;
1470 map = evas_map_new(4);
1475 evas_map_smooth_set(map, EINA_TRUE);
1476 evas_map_util_points_populate_from_object_full(map, rotation->obj, 0);
1477 degree = rotation->from + (float) (frame * rotation->to);
1479 if(!rotation->cw) degree *= -1;
1481 evas_object_geometry_get(rotation->obj, &x, &y, &w, &h);
1483 half_w = (float) w * 0.5;
1484 half_h = (float) h * 0.5;
1486 evas_map_util_3d_rotate(map, 0, 0, degree, x + half_w, y + half_h, 0);
1487 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, 10000);
1488 evas_object_map_enable_set(rotation->obj, EINA_TRUE);
1489 evas_object_map_set(rotation->obj, map);
1496 * Add Rotation Effect
1498 * @param obj Evas_Object that effect is applying to
1499 * @param from degree Degree when effect begins
1500 * @param to_degree Degree when effect is done
1501 * @param cw Rotation Direction. EINA_TRUE is clock wise
1502 * @return Rotation effect
1504 EAPI Elm_Effect *elm_fx_rotation_add(Evas_Object *obj, float from_degree, float to_degree, Eina_Bool cw)
1507 Elm_Fx_Rotation *rotation;
1509 if(!obj) return NULL;
1511 effect = calloc(1, sizeof(Elm_Effect));
1512 if(!effect) return NULL;
1514 rotation = calloc(1, sizeof(Elm_Fx_Rotation));
1522 rotation->obj = obj;
1523 rotation->from = from_degree;
1524 rotation->to = to_degree - from_degree;
1527 effect->begin_op = _elm_fx_rotation_begin;
1528 effect->end_op = _elm_fx_rotation_end;
1529 effect->animation_op = _elm_fx_rotation_op;
1530 effect->user_data = rotation;
1537 /////////////////////////////////////////////////////////////////////////////////////
1538 // ImageAnimation FX
1539 /////////////////////////////////////////////////////////////////////////////////////
1540 typedef struct _image_animation Elm_Fx_Image_Animation;
1542 struct _image_animation
1550 static void _elm_fx_imageanimation_op(void *data, Elm_Animator *animator, double frame)
1552 Elm_Fx_Image_Animation *image_animation = (Elm_Fx_Image_Animation *) data;
1553 if(!image_animation->icon) return;
1554 image_animation->count = floor(frame * image_animation->item_num);
1555 elm_icon_file_set(image_animation->icon, image_animation->images[image_animation->count], NULL);
1561 * Add ImageAnimation effect.
1563 * @param images Images for animation.
1564 * @return ImageAnimation Effect.
1566 EAPI Elm_Effect *elm_fx_imageanimation_add(Evas_Object *icon, const char** images, unsigned int item_num)
1569 Elm_Fx_Image_Animation *image_animation;
1571 if(!images || !(*images)) return NULL;
1573 effect = calloc(1, sizeof(Elm_Effect));
1574 if(!effect) return NULL;
1576 image_animation = calloc(1, sizeof(Elm_Fx_Image_Animation));
1578 if(!image_animation)
1584 image_animation->icon = icon;
1585 image_animation->images = (char**) images;
1586 image_animation->count = 0;
1587 image_animation->item_num = item_num;
1589 effect->animation_op = _elm_fx_imageanimation_op;
1590 effect->user_data = image_animation;