1 #include <Elementary.h>
5 * @defgroup Transit Transit
14 Elm_Animator *animator;
15 Eina_List *effect_list;
16 Evas_Object *block_rect;
17 void (*completion_op)(void *, Elm_Transit *);
19 Eina_Bool reserved_del:1;
24 void (*animation_op)(void *, Elm_Animator *, double);
25 void (*begin_op)(void *, Eina_Bool, unsigned int);
26 void (*end_op)( void *, Eina_Bool, unsigned int);
27 unsigned int shared_cnt;
31 static Evas_Object *_create_block_rect(Evas_Object *parent)
33 Evas_Object* rect = evas_object_rectangle_add(evas_object_evas_get(parent));
35 evas_output_size_get(evas_object_evas_get(parent), &w, &h);
36 evas_object_resize(rect, w, h);
37 evas_object_color_set(rect, 0, 0, 0, 0);
41 static void _transit_animate_cb(void *data, Elm_Animator *animator, double frame)
43 Elm_Transit *transit = data;
47 EINA_LIST_FOREACH(transit->effect_list, elist, effect)
49 effect->animation_op(effect->user_data, animator, frame);
53 static void _transit_fx_begin(Elm_Transit *transit)
57 Eina_Bool auto_reverse = elm_animator_auto_reverse_get(transit->animator);
58 unsigned int repeat_cnt = elm_animator_repeat_get(transit->animator);
60 EINA_LIST_FOREACH(transit->effect_list, elist, effect)
63 effect->begin_op(effect->user_data, auto_reverse, repeat_cnt);
67 static void _transit_fx_end(Elm_Transit *transit)
71 Eina_Bool auto_reverse = elm_animator_auto_reverse_get(transit->animator);
72 unsigned int repeat_cnt = elm_animator_repeat_get(transit->animator);
74 EINA_LIST_FOREACH(transit->effect_list, elist, effect)
77 effect->end_op(effect->user_data, auto_reverse, repeat_cnt);
81 static void _transit_complete_cb(void *data)
83 Elm_Transit *transit = (Elm_Transit *) data;
85 evas_render(evas_object_evas_get(transit->parent));
87 _transit_fx_end(transit);
89 if(transit->block_rect)
90 evas_object_hide(transit->block_rect);
92 if(transit->completion_op)
93 transit->completion_op(transit->completion_arg, transit);
95 if(transit->reserved_del == EINA_TRUE)
97 transit->reserved_del = EINA_FALSE;
98 elm_transit_del(transit);
102 static void _transit_fx_del(Elm_Effect *effect)
106 --effect->shared_cnt;
108 if(effect->shared_cnt > 0) return ;
109 if(effect->user_data) free(effect->user_data);
116 * Set the event block when the transit is operating.
118 * @param transit Transit object
119 * @param disable Disable or enable
121 EAPI void elm_transit_event_block_disabled_set(Elm_Transit *transit, Eina_Bool disable)
125 if(disable == EINA_TRUE)
127 if(transit->block_rect)
129 evas_object_del(transit->block_rect);
130 transit->block_rect = NULL;
134 if(transit->block_rect == NULL)
135 transit->block_rect = _create_block_rect(transit->parent);
142 * Get the event block setting status.
144 * @param transit Transit object
145 * @return EINA_TRUE when the event block is disabled
147 EAPI Eina_Bool elm_transit_event_block_disabled_get(Elm_Transit *transit)
149 if(!transit) return EINA_FALSE;
150 return transit->block_rect ? EINA_TRUE : EINA_FALSE;
156 * Remove effect from transit.
158 * @param transit Transit object
159 * @param effect effect that should be removed
160 * @return EINA_TRUE, if the effect is removed
161 * @warning If the effect is not inserted in any transit, it will be deleted
163 EAPI Eina_Bool elm_transit_fx_remove(Elm_Transit *transit, Elm_Effect *effect)
165 if(!transit) return EINA_FALSE;
170 EINA_LIST_FOREACH(transit->effect_list, elist, _effect)
172 if(_effect == effect)
174 transit->effect_list = eina_list_remove(transit->effect_list, _effect);
175 _transit_fx_del(_effect);
185 * Remove all current inseted effects.
187 * @param transit Transit object
189 EAPI void elm_transit_fx_clear(Elm_Transit *transit)
196 EINA_LIST_FOREACH(transit->effect_list, elist, effect)
198 transit->effect_list = eina_list_remove(transit->effect_list, effect);
199 _transit_fx_del(effect);
206 * Remove all current inseted effects.
208 * @param transit Transit object
209 * @return Effect list
211 EAPI const Eina_List* elm_transit_fx_get(Elm_Transit *transit)
213 if(!transit) return NULL;
214 return transit->effect_list;
220 * Set the user-callback function when the transit is done.
222 * @param transit Transit object
223 * @param op Callback function pointer
224 * @param data Callback funtion user argument
226 EAPI void elm_transit_completion_callback_set(Elm_Transit *transit, void (*op)(void *data, Elm_Transit* transit), void *data)
229 transit->completion_op = op;
230 transit->completion_arg = data;
236 * Delete transit object.
238 * @param transit Transit object
240 EAPI void elm_transit_del(Elm_Transit *transit)
243 if(elm_animator_operating_get(transit->animator) == EINA_TRUE)
245 transit->reserved_del = EINA_TRUE;
249 if(transit->block_rect)
250 evas_object_del( transit->block_rect );
252 //TODO: if usr call stop and del directly?
253 elm_animator_del(transit->animator);
254 elm_transit_fx_clear(transit);
264 * Set the animation acceleration style.
266 * @param transit Transit object
267 * @param cs Curve style
269 EAPI void elm_transit_curve_style_set(Elm_Transit* transit, Elm_Animator_Curve_Style cs)
272 elm_animator_curve_style_set(transit->animator, cs);
283 * @param parent Given canvas of parent object will be blocked
284 * @return Transit object
286 EAPI Elm_Transit *elm_transit_add(Evas_Object *parent)
288 Elm_Transit *transit = calloc(1, sizeof(Elm_Transit));
290 if(!transit) return NULL;
292 transit->animator = elm_animator_add(parent);
294 if(!transit->animator)
300 transit->parent = parent;
301 elm_animator_operation_callback_set(transit->animator, _transit_animate_cb, transit);
302 elm_animator_completion_callback_set(transit->animator, _transit_complete_cb, transit);
303 elm_transit_event_block_disabled_set(transit, EINA_FALSE);
311 * Set auto reverse function.
313 * @param transit Transit object
314 * @param reverse Reverse or not
316 EAPI void elm_transit_auto_reverse_set(Elm_Transit *transit, Eina_Bool reverse)
319 elm_animator_auto_reverse_set(transit->animator, reverse);
325 * Insert an effect in given transit.
327 * @param transit Transit object.
328 * @param effect Effect
329 * @return EINA_TRUE is success
331 EAPI Eina_Bool elm_transit_fx_insert(Elm_Transit *transit, Elm_Effect *effect)
333 if(!transit) return EINA_FALSE;
337 EINA_LIST_FOREACH(transit->effect_list, elist, _effect)
339 if(_effect == effect) return EINA_FALSE;
342 ++effect->shared_cnt;
343 transit->effect_list = eina_list_append(transit->effect_list, effect);
351 * Set the transit repeat count. Effect will be repeated by repeat count.
353 * @param transit Transit object
354 * @param repeat Repeat count
356 EAPI void elm_transit_repeat_set(Elm_Transit *transit, unsigned int repeat)
359 elm_animator_repeat_set(transit->animator, repeat);
365 * Stop the current transit effect if transit is operating.
367 * @param transit Transit object
369 EAPI void elm_transit_stop(Elm_Transit *transit)
372 elm_animator_stop(transit->animator);
378 * Run the all the inserted effects.
380 * @param transit Transit object
381 * @param duration Transit time in second
383 EAPI void elm_transit_run(Elm_Transit *transit, double duration)
386 _transit_fx_begin(transit);
387 elm_animator_duration_set(transit->animator, duration);
390 if(transit->block_rect)
391 evas_object_show( transit->block_rect );
393 elm_animator_animate(transit->animator);
395 //If failed to animate.
396 if(elm_animator_operating_get(transit->animator) == EINA_FALSE)
398 if(transit->block_rect)
399 evas_object_hide( transit->block_rect );
400 _transit_fx_end(transit);
404 /////////////////////////////////////////////////////////////////////////////////////
406 /////////////////////////////////////////////////////////////////////////////////////
407 typedef struct _resizing Elm_Fx_Resizing;
408 static void _elm_fx_resizing_op(void *data, Elm_Animator *animator, double frame);
420 static void _elm_fx_resizing_begin(void* data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
422 Elm_Fx_Resizing *resizing = data;
423 evas_object_show(resizing->obj);
424 evas_object_resize(resizing->obj, resizing->from.w, resizing->from.h);
427 static void _elm_fx_resizing_end(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
429 Elm_Fx_Resizing *resizing = data;
430 evas_object_move(resizing->obj, resizing->from.w + resizing->to.w, resizing->from.h + resizing->to.h);
433 static void _elm_fx_resizing_op(void *data, Elm_Animator *animator, double frame)
435 Elm_Fx_Resizing *resizing = data;
438 w = resizing->from.w + (Evas_Coord)((float) resizing->to.h * (float) frame);
439 h = resizing->from.h + (Evas_Coord)((float) resizing->to.w * (float) frame);
440 evas_object_resize(resizing->obj, w, h);
446 * Add resizing effect.
448 * @param obj Evas_Object that effect is applying to
449 * @param from_w Width size when effect begin
450 * @param from_h Height size whene effect begin
451 * @param to_w Width size to be
452 * @param to_h Height size to be
453 * @return Resizing effect
455 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)
457 if(!obj) return NULL;
459 Elm_Effect* effect = calloc(1, sizeof(Elm_Effect));
461 if(!effect) return NULL;
463 Elm_Fx_Resizing *resizing = calloc(1, sizeof(Elm_Fx_Resizing));
472 resizing->from.w = from_w;
473 resizing->from.h = from_h;
474 resizing->to.w = to_w - from_w;
475 resizing->to.h = to_h - from_h;
477 effect->begin_op = _elm_fx_resizing_begin;
478 effect->animation_op = _elm_fx_resizing_op;
479 effect->user_data = resizing;
484 /////////////////////////////////////////////////////////////////////////////////////
486 /////////////////////////////////////////////////////////////////////////////////////
487 typedef struct _translation Elm_Fx_Translation;
488 static void _elm_fx_translation_op(void *data, Elm_Animator* animator, double frame);
499 static void _elm_fx_translation_begin(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
501 Elm_Fx_Translation *translation = data;
502 evas_object_show(translation->obj);
503 evas_object_move(translation->obj, translation->from.x, translation->from.y);
506 static void _elm_fx_translation_end(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
508 Elm_Fx_Translation *translation = data;
509 evas_object_move(translation->obj, translation->from.x + translation->to.x, translation->from.y + translation->to.y);
512 static void _elm_fx_translation_op(void *data, Elm_Animator *animator, double frame)
514 Elm_Fx_Translation *translation = data;
516 x = translation->from.x + (Evas_Coord)((float) translation->to.x * (float) frame);
517 y = translation->from.y + (Evas_Coord)((float) translation->to.y * (float) frame);
518 evas_object_move(translation->obj, x, y);
524 * Add translation effect.
526 * @param obj Evas_Object that effect is applying to
527 * @param from_x Position X when effect begin
528 * @param from_y Position Y whene effect begin
529 * @param to_x Position X to be
530 * @param to_y Position Y to be
531 * @return Translation effect
533 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)
535 if(!obj) return NULL;
536 Elm_Effect *effect = calloc(1, sizeof(Elm_Effect));
537 if(!effect) return NULL;
538 Elm_Fx_Translation *translation = calloc(1, sizeof(Elm_Fx_Translation));
546 translation->obj = obj;
547 translation->from.x = from_x;
548 translation->from.y = from_y;
549 translation->to.x = to_x - from_x;
550 translation->to.y = to_y - from_y;
552 effect->begin_op = _elm_fx_translation_begin;
553 effect->end_op = _elm_fx_translation_end;
554 effect->animation_op = _elm_fx_translation_op;
555 effect->user_data = translation;
560 /////////////////////////////////////////////////////////////////////////////////////
562 /////////////////////////////////////////////////////////////////////////////////////
563 typedef struct _zoom Elm_Fx_Zoom;
564 static void _elm_fx_zoom_op(void *data, Elm_Animator *animator, double frame);
573 static void _elm_fx_zoom_begin(void *data, Eina_Bool reverse, unsigned int repeat)
575 Elm_Fx_Zoom *zoom = data;
576 evas_object_show(zoom->obj);
577 _elm_fx_zoom_op(data, NULL, 0);
580 static void _elm_fx_zoom_end(void *data, Eina_Bool reverse, unsigned int repeat)
582 Elm_Fx_Zoom *zoom = data;
583 evas_object_map_enable_set(zoom->obj, EINA_FALSE);
586 static void _elm_fx_zoom_op(void *data, Elm_Animator *animator, double frame)
590 Evas_Coord x, y, w, h;
592 map = evas_map_new(4);
596 evas_object_geometry_get(zoom->obj, &x, &y, &w, &h);
597 evas_map_smooth_set(map, EINA_TRUE);
598 evas_map_util_points_populate_from_object_full(map, zoom->obj, zoom->from + frame * zoom->to);
599 evas_map_util_3d_perspective(map, x + w / 2, y + h / 2, 0, 10000);
600 evas_object_map_set(zoom->obj, map);
601 evas_object_map_enable_set(zoom->obj, EINA_TRUE);
610 * @param obj Evas_Object that effect is applying to
611 * @param from_rate Scale rate when the effect begin (1 is current rate)
612 * @param to_rate Scale rate to be
613 * @return Zoom effect
615 EAPI Elm_Effect *elm_fx_zoom_add(Evas_Object *obj, float from_rate, float to_rate)
620 if(!obj) return NULL;
622 effect = calloc(1, sizeof(Elm_Effect));
623 if(!effect) return NULL;
625 zoom = calloc(1, sizeof(Elm_Fx_Zoom));
633 zoom->from = (10000 - (from_rate * 10000)) * (1 / from_rate);
634 zoom->to = ((10000 - (to_rate * 10000)) * (1 / to_rate)) - zoom->from;
635 effect->begin_op = _elm_fx_zoom_begin;
636 effect->end_op = _elm_fx_zoom_end;
637 effect->animation_op = _elm_fx_zoom_op;
638 effect->user_data = zoom;
644 /////////////////////////////////////////////////////////////////////////////////////
646 /////////////////////////////////////////////////////////////////////////////////////
647 typedef struct _flip Elm_Fx_Flip;
653 Elm_Fx_Flip_Axis axis;
657 static void _elm_fx_flip_end(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
659 Elm_Fx_Flip *flip = data;
660 evas_object_map_enable_set(flip->front, EINA_FALSE);
661 evas_object_map_enable_set(flip->back, EINA_FALSE);
664 static void _elm_fx_flip_op(void *data, Elm_Animator *animator, double frame)
670 Evas_Coord x, y, w, h;
672 map = evas_map_new(4);
677 if(flip->cw) degree = (float) (frame * 180);
678 else degree = (float) (frame * -180);
680 if(degree < 90 && degree > -90)
683 evas_object_hide(flip->back);
684 evas_object_show(flip->front);
689 evas_object_hide(flip->front);
690 evas_object_show(flip->back);
693 evas_map_smooth_set(map, EINA_TRUE);
694 evas_map_util_points_populate_from_object_full(map, obj, 0);
695 evas_object_geometry_get(obj, &x, &y, &w, &h);
696 Evas_Coord half_w =(w / 2);
697 Evas_Coord half_h =(h / 2);
699 if(flip->axis == ELM_FX_FLIP_AXIS_Y)
701 if((degree >= 90)||(degree <= -90))
703 evas_map_point_image_uv_set(map, 0, w, 0);
704 evas_map_point_image_uv_set(map, 1, 0, 0);
705 evas_map_point_image_uv_set(map, 2, 0, h);
706 evas_map_point_image_uv_set(map, 3, w, h);
708 evas_map_util_3d_rotate(map, 0, degree, 0, x + half_w, y + half_h, 0);
710 if((degree >= 90)||(degree <= -90))
712 evas_map_point_image_uv_set(map, 0, 0, h);
713 evas_map_point_image_uv_set(map, 1, w, h);
714 evas_map_point_image_uv_set(map, 2, w, 0);
715 evas_map_point_image_uv_set(map, 3, 0, 0);
717 evas_map_util_3d_rotate(map, degree, 0, 0, x + half_w, y + half_h, 0);
719 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, 10000);
720 evas_object_map_enable_set(flip->front, EINA_TRUE);
721 evas_object_map_enable_set(flip->back, EINA_TRUE);
722 evas_object_map_set(obj, map);
731 * @param front Front surface object
732 * @param back Back surface object
733 * @param axis Flipping Axis. X or Y
734 * @param cw Flipping Direction. EINA_TRUE is clock-wise
735 * @return Flip effect
737 EAPI Elm_Effect *elm_fx_flip_add(Evas_Object *front, Evas_Object *back, Elm_Fx_Flip_Axis axis, Eina_Bool cw)
739 if(!front||!back) return NULL;
744 effect = calloc(1, sizeof(Elm_Effect));
745 if(!effect) return NULL;
747 flip = calloc(1, sizeof(Elm_Fx_Flip));
759 effect->end_op = _elm_fx_flip_end;
760 effect->animation_op = _elm_fx_flip_op;
761 effect->user_data = flip;
766 /////////////////////////////////////////////////////////////////////////////////////
768 /////////////////////////////////////////////////////////////////////////////////////
769 typedef struct _resizable_flip Elm_Fx_ResizableFlip;
770 static void _elm_fx_resizable_flip_op(void *data, Elm_Animator *animator, double frame);
772 struct _resizable_flip
776 Elm_Fx_Flip_Axis axis;
780 } from_pos, from_size, to_pos, to_size;
784 static void _elm_fx_resizable_flip_begin(void *data, Eina_Bool reverse, unsigned int repeat)
786 Elm_Fx_ResizableFlip *resizable_flip = data;
787 evas_object_show(resizable_flip->front);
788 _elm_fx_resizable_flip_op(data, NULL, 0);
791 static void _elm_fx_resizable_flip_end(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
793 Elm_Fx_ResizableFlip *resizable_flip = data;
794 evas_object_map_enable_set(resizable_flip->front, EINA_FALSE);
795 evas_object_map_enable_set(resizable_flip->back, EINA_FALSE);
798 static void _set_image_uv_by_axis_y(Evas_Map *map, Elm_Fx_ResizableFlip *flip, float degree)
800 if((degree >= 90)||(degree <= -90))
802 evas_map_point_image_uv_set(map, 0, (flip->from_size.x * 2) + flip->to_size.x, 0);
803 evas_map_point_image_uv_set(map, 1, 0, 0);
804 evas_map_point_image_uv_set(map, 2, 0, (flip->from_size.y * 2) + flip->to_size.y);
805 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);
809 evas_map_point_image_uv_set(map, 0, 0, 0);
810 evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
811 evas_map_point_image_uv_set(map, 2, flip->from_size.x, flip->from_size.y);
812 evas_map_point_image_uv_set(map, 3, 0, flip->to_size.y);
816 static void _set_image_uv_by_axis_x(Evas_Map *map, Elm_Fx_ResizableFlip *flip, float degree)
818 if((degree >= 90)||(degree <= -90))
820 evas_map_point_image_uv_set(map, 0, 0, (flip->from_size.y * 2) + flip->to_size.y);
821 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);
822 evas_map_point_image_uv_set(map, 2, (flip->from_size.x * 2) + flip->to_size.x, 0);
823 evas_map_point_image_uv_set(map, 3, 0, 0);
826 evas_map_point_image_uv_set(map, 0, 0, 0);
827 evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
828 evas_map_point_image_uv_set(map, 2, flip->from_size.x, flip->from_size.y);
829 evas_map_point_image_uv_set(map, 3, 0, flip->to_size.y);
833 static void _elm_fx_resizable_flip_op(void *data, Elm_Animator *animator, double frame)
835 Elm_Fx_ResizableFlip *resizable_flip;
840 Evas_Coord half_w, half_h;
842 resizable_flip = data;
843 map = evas_map_new(4);
846 if(resizable_flip->cw) degree = (float) (frame * 180);
847 else degree = (float) (frame * -180);
849 if((degree < 90) && (degree > -90))
851 obj = resizable_flip->front;
852 evas_object_hide(resizable_flip->back);
853 evas_object_show(resizable_flip->front);
856 obj = resizable_flip->back;
857 evas_object_hide(resizable_flip->front);
858 evas_object_show(resizable_flip->back);
861 evas_map_smooth_set(map, EINA_TRUE);
863 x = resizable_flip->from_pos.x + (resizable_flip->to_pos.x * frame);
864 y = resizable_flip->from_pos.y + (resizable_flip->to_pos.y * frame);
865 w = resizable_flip->from_size.x + (resizable_flip->to_size.x * frame);
866 h = resizable_flip->from_size.y + (resizable_flip->to_size.y * frame);
867 evas_map_point_coord_set(map, 0, x, y, 0);
868 evas_map_point_coord_set(map, 1, x + w, y, 0);
869 evas_map_point_coord_set(map, 2, x + w, y + h, 0);
870 evas_map_point_coord_set(map, 3, x, y + h, 0);
872 half_w = (Evas_Coord) (w / 2);
873 half_h = (Evas_Coord) (h / 2);
875 if(resizable_flip->axis == ELM_FX_FLIP_AXIS_Y)
877 _set_image_uv_by_axis_y(map, resizable_flip, degree);
878 evas_map_util_3d_rotate(map, 0, degree, 0, x + half_w, y + half_h, 0);
881 _set_image_uv_by_axis_x(map, resizable_flip, degree);
882 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(resizable_flip->front, EINA_TRUE);
887 evas_object_map_enable_set(resizable_flip->back, EINA_TRUE);
888 evas_object_map_set(obj, map);
895 * Add ResizbleFlip effect.
897 * @param front Front surface object
898 * @param back Back surface object
899 * @param axis Flipping Axis. X or Y
900 * @param cw Flipping Direction. EINA_TRUE is clock-wise
901 * @return Flip effect
903 EAPI Elm_Effect *elm_fx_resizable_flip_add(Evas_Object *front, Evas_Object *back, Elm_Fx_Flip_Axis axis, Eina_Bool cw)
905 Elm_Fx_ResizableFlip* resizable_flip;
907 Evas_Coord front_x, front_y, front_w, front_h;
908 Evas_Coord back_x, back_y, back_w, back_h;
910 if(!front||!back) return NULL;
912 effect = calloc(1, sizeof(Elm_Effect));
913 if(!effect) return NULL;
915 resizable_flip = calloc(1, sizeof(Elm_Fx_ResizableFlip));
922 resizable_flip->front = front;
923 resizable_flip->back = back;
924 resizable_flip->cw = cw;
925 resizable_flip->axis = axis;
927 evas_object_geometry_get( resizable_flip->front, &front_x, &front_y, &front_w, &front_h );
928 evas_object_geometry_get( resizable_flip->back, &back_x, &back_y, &back_w, &back_h );
930 resizable_flip->from_pos.x = front_x;
931 resizable_flip->from_pos.y = front_y;
932 resizable_flip->to_pos.x = back_x - front_x;
933 resizable_flip->to_pos.y = back_y - front_y;
935 resizable_flip->from_size.x = front_w;
936 resizable_flip->from_size.y = front_h;
937 resizable_flip->to_size.x = back_w - front_w;
938 resizable_flip->to_size.y = back_h - front_h;
940 effect->begin_op = _elm_fx_resizable_flip_begin;
941 effect->end_op = _elm_fx_resizable_flip_end;
942 effect->animation_op = _elm_fx_resizable_flip_op;
943 effect->user_data = resizable_flip;
948 /////////////////////////////////////////////////////////////////////////////////////
950 /////////////////////////////////////////////////////////////////////////////////////
951 typedef struct _wipe Elm_Fx_Wipe;
952 static void _elm_fx_wipe_op(void *data, Elm_Animator *animator, double frame);
957 Elm_Fx_Wipe_Type type;
961 static void _elm_fx_wipe_begin(void *data, Eina_Bool auto_repeat, unsigned int repeat_cnt)
963 Elm_Fx_Wipe *wipe = data;
964 evas_object_show(wipe->obj);
965 _elm_fx_wipe_op(data, NULL, 0);
968 static void _elm_fx_wipe_end(void *data, Eina_Bool auto_repeat, unsigned int repeat_cnt)
970 Elm_Fx_Wipe *wipe = data;
971 evas_object_map_enable_set(wipe->obj, EINA_FALSE);
974 static void _elm_fx_wipe_hide(Evas_Map *map, Elm_Fx_Wipe_Dir dir, float x, float y, float w, float h, float frame)
980 case ELM_FX_WIPE_DIR_LEFT:
981 w2 = w - (w * frame);
983 evas_map_point_image_uv_set(map, 0, 0, 0);
984 evas_map_point_image_uv_set(map, 1, w2, 0);
985 evas_map_point_image_uv_set(map, 2, w2, h);
986 evas_map_point_image_uv_set(map, 3, 0, h);
987 evas_map_point_coord_set(map, 0, x, y, 0);
988 evas_map_point_coord_set(map, 1, x + w2, y, 0);
989 evas_map_point_coord_set(map, 2, x + w2, h2, 0);
990 evas_map_point_coord_set(map, 3, x, h2, 0);
992 case ELM_FX_WIPE_DIR_RIGHT:
995 evas_map_point_image_uv_set(map, 0, w2, 0);
996 evas_map_point_image_uv_set(map, 1, w, 0);
997 evas_map_point_image_uv_set(map, 2, w, h);
998 evas_map_point_image_uv_set(map, 3, w2, h);
999 evas_map_point_coord_set(map, 0, x + w2, y, 0);
1000 evas_map_point_coord_set(map, 1, x + w, y, 0);
1001 evas_map_point_coord_set(map, 2, x + w, h2, 0);
1002 evas_map_point_coord_set(map, 3, x + w2, h2, 0);
1004 case ELM_FX_WIPE_DIR_UP:
1006 h2 = h - (h * frame);
1007 evas_map_point_image_uv_set(map, 0, 0, 0);
1008 evas_map_point_image_uv_set(map, 1, w, 0);
1009 evas_map_point_image_uv_set(map, 2, w, h2);
1010 evas_map_point_image_uv_set(map, 3, 0, h2);
1011 evas_map_point_coord_set(map, 0, x, y, 0);
1012 evas_map_point_coord_set(map, 1, w2, y, 0);
1013 evas_map_point_coord_set(map, 2, w2, h2, 0);
1014 evas_map_point_coord_set(map, 3, x, h2, 0);
1016 case ELM_FX_WIPE_DIR_DOWN:
1019 evas_map_point_image_uv_set(map, 0, 0, h2);
1020 evas_map_point_image_uv_set(map, 1, w, h2);
1021 evas_map_point_image_uv_set(map, 2, w, h);
1022 evas_map_point_image_uv_set(map, 3, 0, h);
1023 evas_map_point_coord_set(map, 0, x, y + h2, 0);
1024 evas_map_point_coord_set(map, 1, w2, y + h2, 0 );
1025 evas_map_point_coord_set(map, 2, w2, y + h, 0);
1026 evas_map_point_coord_set(map, 3, x, y + h, 0);
1032 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, 10000);
1036 static void _elm_fx_wipe_show(Evas_Map *map, Elm_Fx_Wipe_Dir dir, float x, float y, float w, float h, float frame)
1042 case ELM_FX_WIPE_DIR_LEFT:
1043 w2 = (w - (w * frame));
1045 evas_map_point_image_uv_set(map, 0, w2, 0);
1046 evas_map_point_image_uv_set(map, 1, w, 0);
1047 evas_map_point_image_uv_set(map, 2, w, h);
1048 evas_map_point_image_uv_set(map, 3, w2, h);
1049 evas_map_point_coord_set(map, 0, x + w2, y, 0);
1050 evas_map_point_coord_set(map, 1, w, y, 0);
1051 evas_map_point_coord_set(map, 2, w, h2, 0);
1052 evas_map_point_coord_set(map, 3, x + w2, h2, 0);
1054 case ELM_FX_WIPE_DIR_RIGHT:
1057 evas_map_point_image_uv_set(map, 0, 0, 0);
1058 evas_map_point_image_uv_set(map, 1, w2, 0);
1059 evas_map_point_image_uv_set(map, 2, w2, h);
1060 evas_map_point_image_uv_set(map, 3, 0, h);
1061 evas_map_point_coord_set(map, 0, x, y, 0);
1062 evas_map_point_coord_set(map, 1, x + w2, y, 0);
1063 evas_map_point_coord_set(map, 2, x + w2, h2, 0);
1064 evas_map_point_coord_set(map, 3, x, h2, 0);
1066 case ELM_FX_WIPE_DIR_UP:
1068 h2 = (h - (h * frame));
1069 evas_map_point_image_uv_set(map, 0, 0, h2);
1070 evas_map_point_image_uv_set(map, 1, w, h2);
1071 evas_map_point_image_uv_set(map, 2, w, h);
1072 evas_map_point_image_uv_set(map, 3, 0, h);
1073 evas_map_point_coord_set(map, 0, x, y + h2, 0);
1074 evas_map_point_coord_set(map, 1, w2, y + h2, 0);
1075 evas_map_point_coord_set(map, 2, w2, y + h, 0);
1076 evas_map_point_coord_set(map, 3, x, y + h, 0);
1078 case ELM_FX_WIPE_DIR_DOWN:
1081 evas_map_point_image_uv_set(map, 0, 0, 0);
1082 evas_map_point_image_uv_set(map, 1, w, 0);
1083 evas_map_point_image_uv_set(map, 2, w, h2);
1084 evas_map_point_image_uv_set(map, 3, 0, h2);
1085 evas_map_point_coord_set(map, 0, x, y, 0);
1086 evas_map_point_coord_set(map, 1, w2, y, 0);
1087 evas_map_point_coord_set(map, 2, w2, y + h2, 0);
1088 evas_map_point_coord_set(map, 3, x, y + h2, 0);
1094 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, 10000);
1097 static void _elm_fx_wipe_op(void *data, Elm_Animator *animator, double frame)
1101 Evas_Coord _x, _y, _w, _h;
1103 map = evas_map_new(4);
1107 evas_map_smooth_set(map, EINA_TRUE);
1108 evas_object_geometry_get(wipe->obj, &_x, &_y, &_w, &_h);
1110 if(wipe->type == ELM_FX_WIPE_TYPE_SHOW)
1111 _elm_fx_wipe_show(map, wipe->dir, _x, _y, _w, _h, (float) frame);
1113 _elm_fx_wipe_hide(map, wipe->dir, _x, _y, _w, _h, (float) frame);
1115 evas_object_map_enable_set(wipe->obj, EINA_TRUE);
1116 evas_object_map_set(wipe->obj, map);
1125 * @param obj Evas_Object that effect is applying to
1126 * @param type Wipe type. Hide or show
1127 * @param dir Wipe Direction
1128 * @return Wipe Effect
1130 EAPI Elm_Effect *elm_fx_wipe_add(Evas_Object *obj, Elm_Fx_Wipe_Type type, Elm_Fx_Wipe_Dir dir)
1135 if(!obj) return NULL;
1137 effect = calloc(1, sizeof(Elm_Effect));
1138 if(!effect) return NULL;
1140 wipe = calloc(1, sizeof(Elm_Fx_Wipe));
1149 effect->begin_op = _elm_fx_wipe_begin;
1150 effect->end_op = _elm_fx_wipe_end;
1151 effect->animation_op = _elm_fx_wipe_op;
1152 effect->user_data = wipe;
1157 /////////////////////////////////////////////////////////////////////////////////////
1159 /////////////////////////////////////////////////////////////////////////////////////
1160 typedef struct _color Elm_Fx_Color;
1165 struct _unsigned_color
1167 unsigned int r, g, b, a;
1169 struct _signed_color
1175 static void _elm_fx_color_begin(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
1177 Elm_Fx_Color *color = data;
1178 evas_object_show(color->obj);
1181 static void _elm_fx_color_op(void *data, Elm_Animator *animator, double frame)
1183 Elm_Fx_Color *color;
1184 unsigned int r, g, b, a;
1186 r = (color->from.r + (int) ( (float) color->to.r * frame ));
1187 g = (color->from.g + (int) ( (float) color->to.g * frame ));
1188 b = (color->from.b + (int) ( (float) color->to.b * frame ));
1189 a = (color->from.a + (int) ( (float) color->to.a * frame ));
1191 evas_object_color_set(color->obj, r, g, b, a);
1199 * @param obj Evas_Object that effect is applying to
1200 * @param from_r RGB R when the effect begins
1201 * @param from_g RGB G when the effect begins
1202 * @param from_b RGB B when the effect begins
1203 * @param from_a RGB A when the effect begins
1204 * @param to_r RGB R to be
1205 * @param to_g RGB G to be
1206 * @param to_b RGB B to be
1207 * @param to_a RGB A to be
1208 * @return Color Effect
1210 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)
1213 Elm_Fx_Color* color;
1214 if(!obj) return NULL;
1216 effect = calloc(1, sizeof(Elm_Effect));
1217 if(!effect) return NULL;
1219 color = calloc(1, sizeof( Elm_Fx_Color ));
1227 color->from.r = from_r;
1228 color->from.g = from_g;
1229 color->from.b = from_b;
1230 color->from.a = from_a;
1231 color->to.r = to_r - from_r;
1232 color->to.g = to_g - from_g;
1233 color->to.b = to_b - from_b;
1234 color->to.a = to_a - from_a;
1236 effect->begin_op = _elm_fx_color_begin;
1237 effect->animation_op = _elm_fx_color_op;
1238 effect->user_data = color;
1243 /////////////////////////////////////////////////////////////////////////////////////
1245 /////////////////////////////////////////////////////////////////////////////////////
1246 typedef struct _fade Elm_Fx_Fade;
1250 Evas_Object *before;
1252 struct _signed_color before_color, after_color;
1255 Eina_Bool inversed : 1;
1258 static void _elm_fx_fade_begin(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
1260 Elm_Fx_Fade *fade = data;
1261 fade->inversed = EINA_FALSE;
1264 static void _elm_fx_fade_end(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
1266 Elm_Fx_Fade *fade = data;
1267 evas_object_color_set(fade->before, fade->before_color.r, fade->before_color.g, fade->before_color.b, fade->before_color.a);
1268 evas_object_color_set(fade->after, fade->after_color.r, fade->after_color.g, fade->after_color.b, fade->after_color.a);
1271 static void _elm_fx_fade_op(void *data, Elm_Animator *animator, double frame)
1282 evas_object_hide(fade->after);
1283 evas_object_show(fade->before);
1284 fade->inversed = EINA_TRUE;
1287 _frame = 1 - (frame * 2);
1289 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));
1294 evas_object_hide(fade->before);
1295 evas_object_show(fade->after);
1296 fade->inversed = EINA_FALSE;
1299 _frame = (frame - 0.5) * 2;
1301 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));
1312 * @param before Evas Object before fade in
1313 * @param after Evas Object after fade out
1314 * @return Fade Effect
1316 EAPI Elm_Effect *elm_fx_fade_add(Evas_Object *before, Evas_Object *after)
1321 if((!before) && (!after)) return NULL;
1323 effect = calloc(1, sizeof(Elm_Effect));
1324 if(!effect) return NULL;
1326 fade = calloc(1, sizeof(Elm_Fx_Fade));
1334 evas_object_color_get(before, &fade->before_color.r, &fade->before_color.g, &fade->before_color.b, &fade->before_color.a);
1335 evas_object_color_get(after, &fade->after_color.r, &fade->after_color.g, &fade->after_color.b, &fade->after_color.a);
1337 fade->before = before;
1338 fade->after = after;
1339 fade->before_alpha = (255 - fade->before_color.a);
1340 fade->after_alpha = (255 - fade->after_color.a);
1342 effect->begin_op = _elm_fx_fade_begin;
1343 effect->end_op = _elm_fx_fade_end;
1344 effect->animation_op = _elm_fx_fade_op;
1345 effect->user_data = fade;
1350 /////////////////////////////////////////////////////////////////////////////////////
1352 /////////////////////////////////////////////////////////////////////////////////////
1353 typedef struct _blend Elm_Fx_Blend;
1357 Evas_Object *before;
1359 struct _signed_color from, to;
1362 static void _elm_fx_blend_begin(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
1364 Elm_Fx_Blend *blend = data;
1365 evas_object_show(blend->before);
1368 static void _elm_fx_blend_end(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
1370 Elm_Fx_Blend *blend = data;
1371 evas_object_color_set(blend->before, blend->from.r, blend->from.g, blend->from.b, blend->from.a);
1372 evas_object_color_set(blend->after, blend->to.r, blend->to.g, blend->to.b, blend->to.a);
1374 evas_object_hide(blend->before);
1376 evas_object_hide(blend->after);
1379 static void _elm_fx_blend_op(void *data, Elm_Animator *animator, double frame)
1381 Elm_Fx_Blend *blend = data;
1382 evas_object_show(blend->after);
1383 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)));
1384 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));
1392 * @param before Evas Object before blending
1393 * @param after Evas Object after blending
1394 * @return Blend Effect
1396 EAPI Elm_Effect *elm_fx_blend_add(Evas_Object *before, Evas_Object *after)
1399 Elm_Fx_Blend* blend;
1401 if((!before) && (!after)) return NULL;
1403 effect = calloc(1, sizeof(Elm_Effect));
1404 if(!effect) return NULL;
1406 blend = calloc(1, sizeof(Elm_Fx_Blend));
1413 blend->before = before;
1414 blend->after = after;
1415 evas_object_color_get(before, &blend->from.r, &blend->from.g, &blend->from.b, &blend->from.a);
1416 evas_object_color_get(after, &blend->to.r, &blend->to.g, &blend->to.b, &blend->to.a);
1418 effect->begin_op = _elm_fx_blend_begin;
1419 effect->end_op = _elm_fx_blend_end;
1420 effect->animation_op = _elm_fx_blend_op;
1421 effect->user_data = blend;
1426 /////////////////////////////////////////////////////////////////////////////////////
1428 /////////////////////////////////////////////////////////////////////////////////////
1429 typedef struct _rotation Elm_Fx_Rotation;
1438 static void _elm_fx_rotation_begin(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
1440 Elm_Fx_Rotation *rotation = data;
1441 evas_object_show(rotation->obj);
1444 static void _elm_fx_rotation_end(void *data, Eina_Bool auto_reverse, unsigned int repeat_cnt)
1446 Elm_Fx_Rotation *rotation = data;
1447 evas_object_map_enable_set(rotation->obj, EINA_FALSE);
1450 static void _elm_fx_rotation_op(void *data, Elm_Animator *animator, double frame)
1452 Elm_Fx_Rotation *rotation;
1454 Evas_Coord x, y, w, h;
1456 float half_w, half_h;
1458 map = evas_map_new(4);
1463 evas_map_smooth_set(map, EINA_TRUE);
1464 evas_map_util_points_populate_from_object_full(map, rotation->obj, 0);
1465 degree = rotation->from + (float) (frame * rotation->to);
1467 if(!rotation->cw) degree *= -1;
1469 evas_object_geometry_get(rotation->obj, &x, &y, &w, &h);
1471 half_w = (float) w * 0.5;
1472 half_h = (float) h * 0.5;
1474 evas_map_util_3d_rotate(map, 0, 0, degree, x + half_w, y + half_h, 0);
1475 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, 10000);
1476 evas_object_map_enable_set(rotation->obj, EINA_TRUE);
1477 evas_object_map_set(rotation->obj, map);
1484 * Add Rotation Effect
1486 * @param obj Evas_Object that effect is applying to
1487 * @param from degree Degree when effect begins
1488 * @param to_degree Degree when effect is done
1489 * @param cw Rotation Direction. EINA_TRUE is clock wise
1490 * @return Rotation effect
1492 EAPI Elm_Effect *elm_fx_rotation_add(Evas_Object *obj, float from_degree, float to_degree, Eina_Bool cw)
1495 Elm_Fx_Rotation *rotation;
1497 if(!obj) return NULL;
1499 effect = calloc(1, sizeof(Elm_Effect));
1500 if(!effect) return NULL;
1502 rotation = calloc(1, sizeof(Elm_Fx_Rotation));
1510 rotation->obj = obj;
1511 rotation->from = from_degree;
1512 rotation->to = to_degree - from_degree;
1515 effect->begin_op = _elm_fx_rotation_begin;
1516 effect->end_op = _elm_fx_rotation_end;
1517 effect->animation_op = _elm_fx_rotation_op;
1518 effect->user_data = rotation;
1525 /////////////////////////////////////////////////////////////////////////////////////
1526 // ImageAnimation FX
1527 /////////////////////////////////////////////////////////////////////////////////////
1528 typedef struct _image_animation Elm_Fx_Image_Animation;
1530 struct _image_animation
1538 static void _elm_fx_imageanimation_op(void *data, Elm_Animator *animator, double frame)
1540 Elm_Fx_Image_Animation* image_animation = (Elm_Fx_Image_Animation *) data;
1541 if(!image_animation->icon) return;
1542 image_animation->count = floor(frame * image_animation->item_num);
1543 elm_icon_file_set(image_animation->icon, image_animation->images[image_animation->count], NULL);
1549 * Add ImageAnimation effect.
1551 * @param images Images for animation.
1552 * @return ImageAnimation Effect.
1554 EAPI Elm_Effect *elm_fx_imageanimation_add(Evas_Object *icon, const char** images, unsigned int item_num)
1557 Elm_Fx_Image_Animation *image_animation;
1559 if(!images || !(*images)) return NULL;
1561 effect = calloc(1, sizeof(Elm_Effect));
1562 if(!effect) return NULL;
1564 image_animation = calloc(1, sizeof(Elm_Fx_Image_Animation));
1566 if(!image_animation)
1572 image_animation->icon = icon;
1573 image_animation->images = (char**) images;
1574 image_animation->count = 0;
1575 image_animation->item_num = item_num;
1577 effect->animation_op = _elm_fx_imageanimation_op;
1578 effect->user_data = image_animation;