3 * Copyright (c) 2010 Samsung Electronics, Inc.
6 * This software is a confidential and proprietary information
7 * of Samsung Electronics, Inc. ("Confidential Information"). You
8 * shall not disclose such Confidential Information and shall use
9 * it only in accordance with the terms of the license agreement
10 * you entered into with Samsung Electronics.
16 * @defgroup Transit Transit
25 #include <Elementary.h>
30 #define ELM_FX_EXCEPTION_ENABLE
32 #define ELM_FX_NULL_CHECK( obj ) \
36 #define ELM_FX_NULL_CHECK_WITH_RET( obj, ret ) \
44 Elm_Animator* animator;
45 Eina_List* effect_list;
46 Evas_Object* block_rect;
47 void (*completion_op)(void*, Elm_Transit*);
49 Eina_Bool reserved_del : 1;
55 void (*animation_op)( void*, Elm_Animator*, const double );
56 void (*begin_op)( void*, const Eina_Bool, const unsigned int );
57 void (*end_op)( void*, const Eina_Bool, const unsigned int );
58 unsigned int shared_cnt;
63 inline static Evas_Object* _create_block_rect( Evas_Object* parent )
65 Evas_Object* rect = evas_object_rectangle_add( evas_object_evas_get( parent ) );
68 evas_output_size_get( evas_object_evas_get( parent ), &w, &h );
70 evas_object_resize( rect, w, h );
71 evas_object_color_set( rect, 0, 0, 0, 0 );
79 static void _transit_animate_cb( void* data, Elm_Animator* animator, const double frame )
81 Elm_Transit* transit = data;
85 EINA_LIST_FOREACH( transit->effect_list, elist, effect ) {
86 effect->animation_op( effect->user_data, animator, frame );
93 static void _transit_fx_begin( Elm_Transit* transit )
98 Eina_Bool auto_reverse = elm_animator_auto_reverse_get( transit->animator );
99 unsigned int repeat_cnt = elm_animator_repeat_get( transit->animator );
101 EINA_LIST_FOREACH( transit->effect_list, elist, effect ) {
103 if( effect->begin_op ) {
104 effect->begin_op( effect->user_data,
112 static void _transit_fx_end( Elm_Transit* transit )
117 Eina_Bool auto_reverse = elm_animator_auto_reverse_get( transit->animator );
118 unsigned int repeat_cnt = elm_animator_repeat_get( transit->animator );
120 EINA_LIST_FOREACH( transit->effect_list, elist, effect ) {
122 if( effect->end_op ) {
123 effect->end_op( effect->user_data,
132 static void _transit_complete_cb( void* data )
134 Elm_Transit* transit = (Elm_Transit*) data;
136 evas_render( evas_object_evas_get( transit->parent ) );
138 _transit_fx_end( transit );
140 if( transit->block_rect ) {
141 evas_object_hide( transit->block_rect );
144 if( transit->completion_op ) {
145 transit->completion_op( transit->completion_arg, transit );
148 if( transit->reserved_del == EINA_TRUE ) {
149 transit->reserved_del = EINA_FALSE;
150 elm_transit_del( transit );
159 static void _transit_fx_del( Elm_Effect* effect )
161 #ifdef ELM_FX_EXCEPTION_ENABLE
162 ELM_FX_NULL_CHECK( effect );
165 --effect->shared_cnt;
167 if( effect->shared_cnt > 0 ) {
171 if( effect->user_data ) {
172 free( effect->user_data );
185 * Set the event block when the transit is operating.
187 * @param transit Transit object
188 * @param disable Disable or enable
190 EAPI void elm_transit_event_block_disabled_set( Elm_Transit* transit, Eina_Bool disable )
192 #ifdef ELM_FX_EXCEPTION_ENABLE
193 ELM_FX_NULL_CHECK( transit );
195 if( disable == EINA_TRUE ) {
196 if( transit->block_rect ) {
197 evas_object_del( transit->block_rect );
198 transit->block_rect = NULL;
201 if( transit->block_rect == NULL ) {
202 transit->block_rect = _create_block_rect( transit->parent );
214 * Get the event block setting status.
216 * @param transit Transit object
217 * @return EINA_TRUE when the event block is disabled
219 EAPI Eina_Bool elm_transit_event_block_disabled_get( Elm_Transit* transit )
221 #ifdef ELM_FX_EXCEPTION_ENABLE
222 ELM_FX_NULL_CHECK_WITH_RET( transit, EINA_FALSE );
224 return transit->block_rect ? EINA_TRUE : EINA_FALSE;
235 * Remove effect from transit.
237 * @param transit Transit object
238 * @param effect effect that should be removed
239 * @return EINA_TRUE, if the effect is removed
240 * @warning If the effect is not inserted in any transit, it will be deleted
242 EAPI Eina_Bool elm_transit_fx_remove( Elm_Transit* transit, Elm_Effect* effect )
244 #ifdef ELM_FX_EXCEPTION_ENABLE
245 ELM_FX_NULL_CHECK_WITH_RET( transit, EINA_FALSE );
251 EINA_LIST_FOREACH( transit->effect_list, elist, _effect ) {
253 if( _effect == effect ) {
255 transit->effect_list = eina_list_remove( transit->effect_list, _effect );
256 _transit_fx_del( _effect );
273 * Remove all current inseted effects.
275 * @param transit Transit object
277 EAPI void elm_transit_fx_clear( Elm_Transit* transit )
279 #ifdef ELM_FX_EXCEPTION_ENABLE
280 ELM_FX_NULL_CHECK( transit );
286 EINA_LIST_FOREACH( transit->effect_list, elist, effect ) {
288 transit->effect_list = eina_list_remove( transit->effect_list, effect );
289 _transit_fx_del( effect );
302 * Remove all current inseted effects.
304 * @param transit Transit object
305 * @return Effect list
307 EAPI const Eina_List* elm_transit_fx_get( Elm_Transit* transit )
309 #ifdef ELM_FX_EXCEPTION_ENABLE_WITH_RET
310 ELM_FX_NULL_CHECK( transit );
312 return transit->effect_list;
321 * Set the user-callback function when the transit is done.
323 * @param transit Transit object
324 * @param op Callback function pointer
325 * @param data Callback funtion user argument
327 EAPI void elm_transit_completion_callback_set( Elm_Transit* transit, void (*op)(void*, Elm_Transit*), void* data )
329 #ifdef ELM_FX_EXCEPTION_ENABLE
330 ELM_FX_NULL_CHECK( transit );
332 transit->completion_op = op;
333 transit->completion_arg = data;
343 * Delete transit object.
345 * @param transit Transit object
347 EAPI void elm_transit_del( Elm_Transit* transit )
349 #ifdef ELM_FX_EXCEPTION_ENABLE
350 ELM_FX_NULL_CHECK( transit );
352 if( elm_animator_operating_get( transit->animator ) == EINA_TRUE ) {
353 transit->reserved_del = EINA_TRUE;
357 if( transit->block_rect ) {
358 evas_object_del( transit->block_rect );
361 //TODO: if usr call stop and del directly?
362 elm_animator_del( transit->animator );
363 elm_transit_fx_clear( transit );
373 * Set the animation acceleration style.
375 * @param transit Transit object
376 * @param cs Curve style
378 EAPI void elm_transit_curve_style_set( Elm_Transit* transit, Elm_Animator_Curve_Style cs )
380 #ifdef ELM_FX_EXCEPTION_ENABLE
381 ELM_FX_NULL_CHECK( transit );
383 elm_animator_curve_style_set( transit->animator, cs );
395 * @param parent Given canvas of parent object will be blocked
396 * @return Transit object
398 EAPI Elm_Transit* elm_transit_add( Evas_Object* parent )
400 #ifdef ELM_FX_EXCEPTION_ENABLE
401 ELM_FX_NULL_CHECK_WITH_RET( parent, NULL );
403 Elm_Transit* transit = calloc( 1, sizeof( Elm_Transit ) );
405 if( transit == NULL ) {
406 fprintf( stderr, "Failed to allocate elm_transit!\n" );
410 transit->animator = elm_animator_add( parent );
412 if( transit->animator == NULL ) {
413 fprintf( stderr, "Failed to allocate elm_transit!\n" );
418 transit->parent = parent;
420 elm_animator_operation_callback_set( transit->animator, _transit_animate_cb, transit );
421 elm_animator_completion_callback_set( transit->animator, _transit_complete_cb, transit );
422 elm_transit_event_block_disabled_set( transit, EINA_FALSE );
432 * Set auto reverse function.
434 * @param transit Transit object
435 * @param reverse Reverse or not
437 EAPI void elm_transit_auto_reverse_set( Elm_Transit* transit, Eina_Bool reverse )
439 #ifdef ELM_FX_EXCEPTION_ENABLE
440 ELM_FX_NULL_CHECK( transit );
443 elm_animator_auto_reverse_set( transit->animator, reverse );
456 * Insert an effect in given transit.
458 * @param transit Transit object.
459 * @param effect Effect
460 * @return EINA_TRUE is success
462 EAPI Eina_Bool elm_transit_fx_insert( Elm_Transit* transit, Elm_Effect* effect )
464 ELM_FX_NULL_CHECK_WITH_RET( transit && effect, EINA_FALSE );
469 EINA_LIST_FOREACH( transit->effect_list, elist, _effect ) {
471 if( _effect == effect ) {
476 ++effect->shared_cnt;
477 transit->effect_list = eina_list_append( transit->effect_list, effect );
489 * Set the transit repeat count. Effect will be repeated by repeat count.
491 * @param transit Transit object
492 * @param repeat Repeat count
494 EAPI void elm_transit_repeat_set( Elm_Transit* transit, const unsigned int repeat )
496 #ifdef ELM_FX_EXCEPTION_ENABLE
497 ELM_FX_NULL_CHECK( transit );
499 elm_animator_repeat_set( transit->animator, repeat );
510 * Stop the current transit effect if transit is operating.
512 * @param transit Transit object
514 EAPI void elm_transit_stop( Elm_Transit* transit )
516 #ifdef ELM_FX_EXCEPTION_ENABLE
517 ELM_FX_NULL_CHECK( transit );
519 elm_animator_stop( transit->animator );
529 * Run the all the inserted effects.
531 * @param transit Transit object
532 * @param duration Transit time in second
534 EAPI void elm_transit_run( Elm_Transit* transit, const double duration )
536 #ifdef ELM_FX_EXCEPTION_ENABLE
537 ELM_FX_NULL_CHECK( transit );
539 _transit_fx_begin( transit );
541 elm_animator_duration_set( transit->animator, duration );
544 if( transit->block_rect ) {
545 evas_object_show( transit->block_rect );
548 elm_animator_animate( transit->animator );
550 //If failed to animate.
551 if( elm_animator_operating_get( transit->animator ) == EINA_FALSE ) {
553 if( transit->block_rect ) {
554 evas_object_hide( transit->block_rect );
557 _transit_fx_end( transit );
563 /////////////////////////////////////////////////////////////////////////////////////
565 /////////////////////////////////////////////////////////////////////////////////////
566 typedef struct _resizing Elm_Fx_Resizing;
567 static void _elm_fx_resizing_op( void* data, Elm_Animator* animator, const double frame );
580 static void _elm_fx_resizing_begin( void* data,
581 const Eina_Bool auto_reverse,
582 const unsigned int repeat_cnt )
584 Elm_Fx_Resizing* resizing = data;
586 evas_object_show( resizing->obj );
587 evas_object_resize( resizing->obj, resizing->from.w, resizing->from.h );
593 static void _elm_fx_resizing_end( void* data,
594 const Eina_Bool auto_reverse,
595 const unsigned int repeat_cnt )
597 Elm_Fx_Resizing* resizing = data;
598 evas_object_move( resizing->obj, resizing->from.w + resizing->to.w,
599 resizing->from.h + resizing->to.h );
605 static void _elm_fx_resizing_op( void* data, Elm_Animator* animator, const double frame )
607 Elm_Fx_Resizing* resizing = data;
611 w = resizing->from.w + (Evas_Coord)( (float) resizing->to.h * (float) frame);
612 h = resizing->from.h + (Evas_Coord)( (float) resizing->to.w * (float) frame);
614 evas_object_resize( resizing->obj, w, h );
622 * Add resizing effect.
624 * @param obj Evas_Object that effect is applying to
625 * @param from_w Width size when effect begin
626 * @param from_h Height size whene effect begin
627 * @param to_w Width size to be
628 * @param to_h Height size to be
629 * @return Resizing effect
631 EAPI Elm_Effect* elm_fx_resizing_add( Evas_Object* obj,
632 const Evas_Coord from_w,
633 const Evas_Coord from_h,
634 const Evas_Coord to_w,
635 const Evas_Coord to_h )
637 #ifdef ELM_FX_EXCEPTION_ENABLE
638 ELM_FX_NULL_CHECK_WITH_RET( obj, NULL );
641 Elm_Effect* effect = calloc( 1, sizeof( Elm_Effect ) );
643 if( effect == NULL ) {
644 fprintf( stderr, "Failed to allocate Elm_Effect!\n" );
648 Elm_Fx_Resizing* resizing = calloc( 1, sizeof( Elm_Fx_Resizing ) );
650 if( resizing == NULL ) {
651 fprintf( stderr, "Failed to allocate Elm_Effect!\n" );
657 resizing->from.w = from_w;
658 resizing->from.h = from_h;
659 resizing->to.w = to_w - from_w;
660 resizing->to.h = to_h - from_h;
662 effect->begin_op = _elm_fx_resizing_begin;
663 effect->animation_op = _elm_fx_resizing_op;
664 effect->user_data = resizing;
672 /////////////////////////////////////////////////////////////////////////////////////
674 /////////////////////////////////////////////////////////////////////////////////////
675 typedef struct _translation Elm_Fx_Translation;
676 static void _elm_fx_translation_op( void* data, Elm_Animator* animator, const double frame );
678 struct _translation {
689 static void _elm_fx_translation_begin( void* data,
690 const Eina_Bool auto_reverse,
691 const unsigned int repeat_cnt )
693 Elm_Fx_Translation* translation = data;
695 evas_object_show( translation->obj );
696 evas_object_move( translation->obj, translation->from.x, translation->from.y );
702 static void _elm_fx_translation_end( void* data,
703 const Eina_Bool auto_reverse,
704 const unsigned int repeat_cnt )
706 Elm_Fx_Translation* translation = data;
708 evas_object_move( translation->obj, translation->from.x + translation->to.x,
709 translation->from.y + translation->to.y );
714 static void _elm_fx_translation_op( void* data, Elm_Animator* animator, const double frame )
716 Elm_Fx_Translation* translation = data;
720 x = translation->from.x + (Evas_Coord)( (float) translation->to.x * (float) frame);
721 y = translation->from.y + (Evas_Coord)( (float) translation->to.y * (float) frame);
723 evas_object_move( translation->obj, x, y );
730 * Add translation effect.
732 * @param obj Evas_Object that effect is applying to
733 * @param from_x Position X when effect begin
734 * @param from_y Position Y whene effect begin
735 * @param to_x Position X to be
736 * @param to_y Position Y to be
737 * @return Translation effect
739 EAPI Elm_Effect* elm_fx_translation_add( Evas_Object* obj,
740 const Evas_Coord from_x,
741 const Evas_Coord from_y,
742 const Evas_Coord to_x,
743 const Evas_Coord to_y )
745 #ifdef ELM_FX_EXCEPTION_ENABLE
746 ELM_FX_NULL_CHECK_WITH_RET( obj, NULL );
749 Elm_Effect* effect = calloc( 1, sizeof( Elm_Effect ) );
751 if( effect == NULL ) {
752 fprintf( stderr, "Failed to allocate Elm_Effect!\n" );
756 Elm_Fx_Translation* translation = calloc( 1, sizeof( Elm_Fx_Translation ) );
758 if( translation == NULL ) {
759 fprintf( stderr, "Failed to allocate Elm_Effect!\n" );
764 translation->obj = obj;
765 translation->from.x = from_x;
766 translation->from.y = from_y;
767 translation->to.x = to_x - from_x;
768 translation->to.y = to_y - from_y;
770 effect->begin_op = _elm_fx_translation_begin;
771 effect->end_op = _elm_fx_translation_end;
772 effect->animation_op = _elm_fx_translation_op;
773 effect->user_data = translation;
784 /////////////////////////////////////////////////////////////////////////////////////
786 /////////////////////////////////////////////////////////////////////////////////////
787 typedef struct _zoom Elm_Fx_Zoom;
789 static void _elm_fx_zoom_op( void* data, Elm_Animator* animator, const double frame );
799 static void _elm_fx_zoom_begin( void* data, const Eina_Bool reverse, const unsigned int repeat )
801 Elm_Fx_Zoom* zoom = data;
802 evas_object_show( zoom->obj );
804 _elm_fx_zoom_op( data, NULL, 0 );
809 static void _elm_fx_zoom_end( void* data, const Eina_Bool reverse, const unsigned int repeat )
811 Elm_Fx_Zoom* zoom = data;
812 evas_object_map_enable_set( zoom->obj, EINA_FALSE );
817 static void _elm_fx_zoom_op( void* data, Elm_Animator* animator, const double frame )
819 Elm_Fx_Zoom* zoom = data;
821 Evas_Map* map = evas_map_new( 4 );
827 Evas_Coord x, y, w, h;
828 evas_object_geometry_get( zoom->obj, &x, &y, &w, &h );
830 evas_map_smooth_set( map, EINA_TRUE );
832 evas_map_util_points_populate_from_object_full( map,
833 zoom->obj, zoom->from + frame * zoom->to );
835 evas_map_util_3d_perspective( map, x + w / 2, y + h / 2, 0, 10000 );
837 evas_object_map_set( zoom->obj, map );
838 evas_object_map_enable_set( zoom->obj, EINA_TRUE );
839 evas_map_free( map );
850 * @param obj Evas_Object that effect is applying to
851 * @param from_rate Scale rate when the effect begin (1 is current rate)
852 * @param to_rate Scale rate to be
853 * @return Zoom effect
855 EAPI Elm_Effect* elm_fx_zoom_add( Evas_Object* obj, float from_rate, float to_rate )
857 #ifdef ELM_FX_EXCEPTION_ENABLE
858 ELM_FX_NULL_CHECK_WITH_RET( obj, NULL );
860 if( from_rate <= 0 ) from_rate = 0.001;
861 if( to_rate <= 0 ) to_rate = 0.001;
864 Elm_Effect* effect = calloc( 1, sizeof( Elm_Effect ) );
866 if( effect == NULL ) {
867 fprintf( stderr, "Failed to allocate Elm_Effect!\n" );
871 Elm_Fx_Zoom* zoom = calloc( 1, sizeof( Elm_Fx_Zoom ) );
874 fprintf( stderr, "Failed to allocate Elm_Effect!\n" );
880 zoom->from = ( 10000 - from_rate * 10000 ) * ( 1 / from_rate );
881 zoom->to = (10000 - to_rate * 10000 ) * (1 / to_rate ) - zoom->from;
883 effect->begin_op = _elm_fx_zoom_begin;
884 effect->end_op = _elm_fx_zoom_end;
885 effect->animation_op = _elm_fx_zoom_op;
886 effect->user_data = zoom;
894 /////////////////////////////////////////////////////////////////////////////////////
896 /////////////////////////////////////////////////////////////////////////////////////
897 typedef struct _flip Elm_Fx_Flip;
902 Elm_Fx_Flip_Axis axis;
907 static void _elm_fx_flip_end( void* data,
908 const Eina_Bool auto_reverse,
909 const unsigned int repeat_cnt )
911 Elm_Fx_Flip* flip = data;
912 evas_object_map_enable_set( flip->front, EINA_FALSE );
913 evas_object_map_enable_set( flip->back, EINA_FALSE );
917 static void _elm_fx_flip_op( void* data, Elm_Animator* animator, const double frame )
919 Elm_Fx_Flip* flip = data;
921 Evas_Map* map = evas_map_new( 4 );
929 if( flip->cw == EINA_TRUE ) {
930 degree = (float) ( frame * 180 );
932 degree = (float) ( frame * -180 );
937 if( degree < 90 && degree > -90 ) {
939 evas_object_hide( flip->back );
940 evas_object_show( flip->front );
943 evas_object_hide( flip->front );
944 evas_object_show( flip->back );
947 evas_map_smooth_set( map, EINA_TRUE );
948 evas_map_util_points_populate_from_object_full( map, obj, 0 );
950 Evas_Coord x, y, w, h;
951 evas_object_geometry_get( obj, &x, &y, &w, &h );
953 Evas_Coord half_w = w / 2;
954 Evas_Coord half_h = h / 2;
956 if( flip->axis == ELM_FX_FLIP_AXIS_Y ) {
957 if( degree >= 90 || degree <= -90 ) {
958 evas_map_point_image_uv_set( map, 0, w, 0 );
959 evas_map_point_image_uv_set( map, 1, 0, 0 );
960 evas_map_point_image_uv_set( map, 2, 0, h );
961 evas_map_point_image_uv_set( map, 3, w, h );
963 evas_map_util_3d_rotate( map, 0, degree, 0, x + half_w, y + half_h, 0 );
965 if( degree >= 90 || degree <= -90 ) {
966 evas_map_point_image_uv_set( map, 0, 0, h );
967 evas_map_point_image_uv_set( map, 1, w, h );
968 evas_map_point_image_uv_set( map, 2, w, 0 );
969 evas_map_point_image_uv_set( map, 3, 0, 0 );
972 evas_map_util_3d_rotate( map, degree, 0, 0, x + half_w, y + half_h, 0 );
975 evas_map_util_3d_perspective( map, x + half_w, y + half_h, 0, 10000 );
977 evas_object_map_enable_set( flip->front, EINA_TRUE );
978 evas_object_map_enable_set( flip->back, EINA_TRUE );
979 evas_object_map_set( obj, map );
980 evas_map_free( map );
991 * @param front Front surface object
992 * @param back Back surface object
993 * @param axis Flipping Axis. X or Y
994 * @param cw Flipping Direction. EINA_TRUE is clock-wise
995 * @return Flip effect
997 EAPI Elm_Effect* elm_fx_flip_add( Evas_Object* front,
999 const Elm_Fx_Flip_Axis axis,
1000 const Eina_Bool cw )
1002 #ifdef ELM_FX_EXCEPTION_ENABLE
1003 ELM_FX_NULL_CHECK_WITH_RET( front || back, NULL );
1006 Elm_Effect* effect = calloc( 1, sizeof( Elm_Effect ) );
1008 if( effect == NULL ) {
1009 fprintf( stderr, "Failed to allocate Elm_Effect!\n" );
1013 Elm_Fx_Flip* flip = calloc( 1, sizeof( Elm_Fx_Flip ) );
1015 if( flip == NULL ) {
1016 fprintf( stderr, "Failed to allocate Elm_Effect!\n" );
1021 flip->front = front;
1026 effect->end_op = _elm_fx_flip_end;
1027 effect->animation_op = _elm_fx_flip_op;
1028 effect->user_data = flip;
1036 /////////////////////////////////////////////////////////////////////////////////////
1038 /////////////////////////////////////////////////////////////////////////////////////
1039 typedef struct _resizable_flip Elm_Fx_ResizableFlip;
1040 static void _elm_fx_resizable_flip_op( void* data, Elm_Animator* animator, const double frame );
1042 struct _resizable_flip {
1045 Elm_Fx_Flip_Axis axis;
1049 } from_pos, from_size, to_pos, to_size;
1054 static void _elm_fx_resizable_flip_begin( void* data, const Eina_Bool reverse, const unsigned int repeat )
1056 Elm_Fx_ResizableFlip* resizable_flip = data;
1057 evas_object_show( resizable_flip->front );
1059 _elm_fx_resizable_flip_op( data, NULL, 0 );
1065 static void _elm_fx_resizable_flip_end( void* data,
1066 const Eina_Bool auto_reverse,
1067 const unsigned int repeat_cnt )
1069 Elm_Fx_ResizableFlip* resizable_flip = data;
1070 evas_object_map_enable_set( resizable_flip->front, EINA_FALSE );
1071 evas_object_map_enable_set( resizable_flip->back, EINA_FALSE );
1075 inline static void _set_image_uv_by_axis_y( Evas_Map* map,
1076 Elm_Fx_ResizableFlip* flip,
1079 if( degree >= 90 || degree <= -90 ) {
1080 evas_map_point_image_uv_set( map, 0, flip->from_size.x * 2+ flip->to_size.x,
1082 evas_map_point_image_uv_set( map, 1, 0,
1084 evas_map_point_image_uv_set( map, 2, 0,
1085 flip->from_size.y * 2 + flip->to_size.y );
1086 evas_map_point_image_uv_set( map, 3, flip->from_size.x * 2 + flip->to_size.x,
1087 flip->from_size.y * 2 + flip->to_size.y );
1089 evas_map_point_image_uv_set( map, 0, 0, 0 );
1090 evas_map_point_image_uv_set( map, 1, flip->from_size.x, 0 );
1091 evas_map_point_image_uv_set( map, 2, flip->from_size.x, flip->from_size.y );
1092 evas_map_point_image_uv_set( map, 3, 0, flip->to_size.y );
1096 inline static void _set_image_uv_by_axis_x( Evas_Map* map,
1097 Elm_Fx_ResizableFlip* flip,
1100 if( degree >= 90 || degree <= -90 ) {
1102 evas_map_point_image_uv_set( map, 0, 0,
1103 flip->from_size.y * 2 + flip->to_size.y );
1104 evas_map_point_image_uv_set( map, 1, flip->from_size.x * 2 + flip->to_size.x,
1105 flip->from_size.y * 2 + flip->to_size.y );
1106 evas_map_point_image_uv_set( map, 2, flip->from_size.x * 2 + flip->to_size.x,
1108 evas_map_point_image_uv_set( map, 3, 0,
1111 evas_map_point_image_uv_set( map, 0, 0, 0 );
1112 evas_map_point_image_uv_set( map, 1, flip->from_size.x, 0 );
1113 evas_map_point_image_uv_set( map, 2, flip->from_size.x, flip->from_size.y );
1114 evas_map_point_image_uv_set( map, 3, 0, flip->to_size.y );
1121 static void _elm_fx_resizable_flip_op( void* data, Elm_Animator* animator, const double frame )
1123 Elm_Fx_ResizableFlip* resizable_flip = data;
1125 Evas_Map* map = evas_map_new( 4 );
1133 if( resizable_flip->cw == EINA_TRUE ) {
1134 degree = (float) ( frame * 180 );
1136 degree = (float) ( frame * -180 );
1141 if( degree < 90 && degree > -90 ) {
1142 obj = resizable_flip->front;
1143 evas_object_hide( resizable_flip->back );
1144 evas_object_show( resizable_flip->front );
1146 obj = resizable_flip->back;
1147 evas_object_hide( resizable_flip->front );
1148 evas_object_show( resizable_flip->back );
1151 evas_map_smooth_set( map, EINA_TRUE );
1153 float x = resizable_flip->from_pos.x + resizable_flip->to_pos.x * frame;
1154 float y = resizable_flip->from_pos.y + resizable_flip->to_pos.y * frame;
1155 float w = resizable_flip->from_size.x + resizable_flip->to_size.x * frame;
1156 float h = resizable_flip->from_size.y + resizable_flip->to_size.y * frame;
1158 evas_map_point_coord_set( map, 0, x, y, 0 );
1159 evas_map_point_coord_set( map, 1, x + w, y, 0 );
1160 evas_map_point_coord_set( map, 2, x + w, y + h, 0 );
1161 evas_map_point_coord_set( map, 3, x, y + h, 0 );
1163 Evas_Coord half_w = (Evas_Coord) ( w / 2 );
1164 Evas_Coord half_h = (Evas_Coord) ( h / 2 );
1166 if( resizable_flip->axis == ELM_FX_FLIP_AXIS_Y ) {
1167 _set_image_uv_by_axis_y( map, resizable_flip, degree );
1168 evas_map_util_3d_rotate( map, 0, degree, 0, x + half_w, y + half_h, 0 );
1170 _set_image_uv_by_axis_x( map, resizable_flip, degree );
1171 evas_map_util_3d_rotate( map, degree, 0, 0, x + half_w, y + half_h, 0 );
1174 evas_map_util_3d_perspective( map, x + half_w, y + half_h, 0, 10000 );
1176 evas_object_map_enable_set( resizable_flip->front, EINA_TRUE );
1177 evas_object_map_enable_set( resizable_flip->back, EINA_TRUE );
1178 evas_object_map_set( obj, map );
1179 evas_map_free( map );
1190 * Add ResizbleFlip effect.
1192 * @param front Front surface object
1193 * @param back Back surface object
1194 * @param axis Flipping Axis. X or Y
1195 * @param cw Flipping Direction. EINA_TRUE is clock-wise
1196 * @return Flip effect
1198 EAPI Elm_Effect* elm_fx_resizable_flip_add( Evas_Object* front,
1200 const Elm_Fx_Flip_Axis axis,
1201 const Eina_Bool cw )
1203 #ifdef ELM_FX_EXCEPTION_ENABLE
1204 ELM_FX_NULL_CHECK_WITH_RET( front || back, NULL );
1207 Elm_Effect* effect = calloc( 1, sizeof( Elm_Effect ) );
1209 if( effect == NULL ) {
1210 fprintf( stderr, "Failed to allocate Elm_Effect!\n" );
1214 Elm_Fx_ResizableFlip* resizable_flip = calloc( 1, sizeof( Elm_Fx_ResizableFlip ) );
1216 if( resizable_flip == NULL ) {
1217 fprintf( stderr, "Failed to allocate Elm_Effect!\n" );
1222 resizable_flip->front = front;
1223 resizable_flip->back = back;
1224 resizable_flip->cw = cw;
1225 resizable_flip->axis = axis;
1227 Evas_Coord front_x, front_y, front_w, front_h;
1228 evas_object_geometry_get( resizable_flip->front, &front_x, &front_y, &front_w, &front_h );
1230 Evas_Coord back_x, back_y, back_w, back_h;
1231 evas_object_geometry_get( resizable_flip->back, &back_x, &back_y, &back_w, &back_h );
1233 resizable_flip->from_pos.x = front_x;
1234 resizable_flip->from_pos.y = front_y;
1235 resizable_flip->to_pos.x = back_x - front_x;
1236 resizable_flip->to_pos.y = back_y - front_y;
1238 resizable_flip->from_size.x = front_w;
1239 resizable_flip->from_size.y = front_h;
1240 resizable_flip->to_size.x = back_w - front_w;
1241 resizable_flip->to_size.y = back_h - front_h;
1243 effect->begin_op = _elm_fx_resizable_flip_begin;
1244 effect->end_op = _elm_fx_resizable_flip_end;
1245 effect->animation_op = _elm_fx_resizable_flip_op;
1246 effect->user_data = resizable_flip;
1254 /////////////////////////////////////////////////////////////////////////////////////
1256 /////////////////////////////////////////////////////////////////////////////////////
1257 typedef struct _wipe Elm_Fx_Wipe;
1258 static void _elm_fx_wipe_op( void* data, Elm_Animator* animator, const double frame );
1262 Elm_Fx_Wipe_Type type;
1263 Elm_Fx_Wipe_Dir dir;
1267 static void _elm_fx_wipe_begin( void* data,
1268 const Eina_Bool auto_repeat,
1269 const unsigned int repeat_cnt )
1271 Elm_Fx_Wipe* wipe = data;
1272 evas_object_show( wipe->obj );
1273 _elm_fx_wipe_op( data, NULL, 0 );
1278 static void _elm_fx_wipe_end( void* data,
1279 const Eina_Bool auto_repeat,
1280 const unsigned int repeat_cnt )
1282 Elm_Fx_Wipe* wipe = data;
1283 evas_object_map_enable_set( wipe->obj, EINA_FALSE );
1287 static void _elm_fx_wipe_hide( Evas_Map* map,
1288 Elm_Fx_Wipe_Dir dir,
1289 float x, float y, float w, float h,
1295 case ELM_FX_WIPE_DIR_LEFT:
1298 evas_map_point_image_uv_set( map, 0, 0, 0 );
1299 evas_map_point_image_uv_set( map, 1, w2, 0 );
1300 evas_map_point_image_uv_set( map, 2, w2, h );
1301 evas_map_point_image_uv_set( map, 3, 0, h );
1302 evas_map_point_coord_set( map, 0, x, y, 0 );
1303 evas_map_point_coord_set( map, 1, x + w2, y, 0 );
1304 evas_map_point_coord_set( map, 2, x + w2, h2, 0 );
1305 evas_map_point_coord_set( map, 3, x, h2, 0 );
1307 case ELM_FX_WIPE_DIR_RIGHT:
1310 evas_map_point_image_uv_set( map, 0, w2, 0 );
1311 evas_map_point_image_uv_set( map, 1, w, 0 );
1312 evas_map_point_image_uv_set( map, 2, w, h );
1313 evas_map_point_image_uv_set( map, 3, w2, h );
1314 evas_map_point_coord_set( map, 0, x + w2, y, 0 );
1315 evas_map_point_coord_set( map, 1, x + w, y, 0 );
1316 evas_map_point_coord_set( map, 2, x + w, h2, 0 );
1317 evas_map_point_coord_set( map, 3, x + w2, h2, 0 );
1319 case ELM_FX_WIPE_DIR_UP:
1322 evas_map_point_image_uv_set( map, 0, 0, 0 );
1323 evas_map_point_image_uv_set( map, 1, w, 0 );
1324 evas_map_point_image_uv_set( map, 2, w, h2 );
1325 evas_map_point_image_uv_set( map, 3, 0, h2 );
1326 evas_map_point_coord_set( map, 0, x, y, 0 );
1327 evas_map_point_coord_set( map, 1, w2, y, 0 );
1328 evas_map_point_coord_set( map, 2, w2, h2, 0 );
1329 evas_map_point_coord_set( map, 3, x, h2, 0 );
1331 case ELM_FX_WIPE_DIR_DOWN:
1334 evas_map_point_image_uv_set( map, 0, 0, h2 );
1335 evas_map_point_image_uv_set( map, 1, w, h2 );
1336 evas_map_point_image_uv_set( map, 2, w, h );
1337 evas_map_point_image_uv_set( map, 3, 0, h );
1338 evas_map_point_coord_set( map, 0, x, y + h2, 0 );
1339 evas_map_point_coord_set( map, 1, w2, y + h2, 0 );
1340 evas_map_point_coord_set( map, 2, w2, y + h, 0 );
1341 evas_map_point_coord_set( map, 3, x, y + h, 0 );
1344 fprintf( stderr, "What the wipe direction?\n" );
1347 evas_map_util_3d_perspective( map, x + w / 2, y + h / 2, 0, 10000 );
1352 static void _elm_fx_wipe_show( Evas_Map* map,
1353 Elm_Fx_Wipe_Dir dir,
1354 float x, float y, float w, float h,
1360 case ELM_FX_WIPE_DIR_LEFT:
1363 evas_map_point_image_uv_set( map, 0, w2, 0 );
1364 evas_map_point_image_uv_set( map, 1, w, 0 );
1365 evas_map_point_image_uv_set( map, 2, w, h );
1366 evas_map_point_image_uv_set( map, 3, w2, h );
1367 evas_map_point_coord_set( map, 0, x + w2, y, 0 );
1368 evas_map_point_coord_set( map, 1, w, y, 0 );
1369 evas_map_point_coord_set( map, 2, w, h2, 0 );
1370 evas_map_point_coord_set( map, 3, x + w2, h2, 0 );
1372 case ELM_FX_WIPE_DIR_RIGHT:
1375 evas_map_point_image_uv_set( map, 0, 0, 0 );
1376 evas_map_point_image_uv_set( map, 1, w2, 0 );
1377 evas_map_point_image_uv_set( map, 2, w2, h );
1378 evas_map_point_image_uv_set( map, 3, 0, h );
1379 evas_map_point_coord_set( map, 0, x, y, 0 );
1380 evas_map_point_coord_set( map, 1, x + w2, y, 0 );
1381 evas_map_point_coord_set( map, 2, x + w2, h2, 0 );
1382 evas_map_point_coord_set( map, 3, x, h2, 0 );
1384 case ELM_FX_WIPE_DIR_UP:
1387 evas_map_point_image_uv_set( map, 0, 0, h2 );
1388 evas_map_point_image_uv_set( map, 1, w, h2 );
1389 evas_map_point_image_uv_set( map, 2, w, h );
1390 evas_map_point_image_uv_set( map, 3, 0, h );
1391 evas_map_point_coord_set( map, 0, x, y + h2, 0 );
1392 evas_map_point_coord_set( map, 1, w2, y + h2, 0 );
1393 evas_map_point_coord_set( map, 2, w2, y + h, 0 );
1394 evas_map_point_coord_set( map, 3, x, y + h, 0 );
1396 case ELM_FX_WIPE_DIR_DOWN:
1399 evas_map_point_image_uv_set( map, 0, 0, 0 );
1400 evas_map_point_image_uv_set( map, 1, w, 0 );
1401 evas_map_point_image_uv_set( map, 2, w, h2);
1402 evas_map_point_image_uv_set( map, 3, 0, h2 );
1403 evas_map_point_coord_set( map, 0, x, y, 0 );
1404 evas_map_point_coord_set( map, 1, w2, y, 0 );
1405 evas_map_point_coord_set( map, 2, w2, y + h2, 0 );
1406 evas_map_point_coord_set( map, 3, x, y + h2, 0 );
1409 fprintf( stderr, "What the wipe direction?\n" );
1412 evas_map_util_3d_perspective( map, x + w / 2, y + h / 2, 0, 10000 );
1416 static void _elm_fx_wipe_op( void* data, Elm_Animator* animator, const double frame )
1418 Elm_Fx_Wipe* wipe = data;
1420 Evas_Map* map = evas_map_new( 4 );
1426 evas_map_smooth_set( map, EINA_TRUE );
1428 Evas_Coord _x, _y, _w, _h;
1429 evas_object_geometry_get( wipe->obj, &_x, &_y, &_w, &_h );
1431 if( wipe->type == ELM_FX_WIPE_TYPE_SHOW ) {
1432 _elm_fx_wipe_show( map, wipe->dir, _x, _y, _w, _h, (float) frame );
1434 _elm_fx_wipe_hide( map, wipe->dir, _x, _y, _w, _h, (float) frame );
1437 evas_object_map_enable_set( wipe->obj, EINA_TRUE );
1438 evas_object_map_set( wipe->obj, map );
1439 evas_map_free( map );
1451 * @param obj Evas_Object that effect is applying to
1452 * @param type Wipe type. Hide or show
1453 * @param dir Wipe Direction
1454 * @return Wipe Effect
1456 EAPI Elm_Effect* elm_fx_wipe_add( Evas_Object* obj, Elm_Fx_Wipe_Type type, Elm_Fx_Wipe_Dir dir )
1458 #ifdef ELM_FX_EXCEPTION_ENABLE
1459 ELM_FX_NULL_CHECK_WITH_RET( obj, NULL );
1461 Elm_Effect* effect = calloc( 1, sizeof( Elm_Effect ) );
1463 if( effect == NULL ) {
1464 fprintf( stderr, "Failed to allocate Elm_Effect!\n" );
1468 Elm_Fx_Wipe* wipe = calloc( 1, sizeof( Elm_Fx_Wipe ) );
1470 if( wipe == NULL ) {
1471 fprintf( stderr, "Failed to allocate Elm_Effect!\n" );
1479 effect->begin_op = _elm_fx_wipe_begin;
1480 effect->end_op = _elm_fx_wipe_end;
1481 effect->animation_op = _elm_fx_wipe_op;
1482 effect->user_data = wipe;
1489 /////////////////////////////////////////////////////////////////////////////////////
1491 /////////////////////////////////////////////////////////////////////////////////////
1492 typedef struct _color Elm_Fx_Color;
1498 struct _unsigned_color {
1499 unsigned int r, g, b, a;
1502 struct _signed_color {
1509 static void _elm_fx_color_begin( void* data,
1510 const Eina_Bool auto_reverse,
1511 const unsigned int repeat_cnt )
1513 Elm_Fx_Color* color = data;
1514 evas_object_show( color->obj );
1518 static void _elm_fx_color_op( void* data, Elm_Animator* animator, const double frame )
1520 Elm_Fx_Color* color = data;
1522 unsigned int r = color->from.r + (int) ( (float) color->to.r * frame );
1523 unsigned int g = color->from.g + (int) ( (float) color->to.g * frame );
1524 unsigned int b = color->from.b + (int) ( (float) color->to.b * frame );
1525 unsigned int a = color->from.a + (int) ( (float) color->to.a * frame );
1527 #ifdef ELM_FX_EXCEPTION_ENABLE
1528 if( r > 255 ) r = 255;
1529 if( g > 255 ) g = 255;
1530 if( b > 255 ) b = 255;
1531 if( a > 255 ) a = 255;
1533 evas_object_color_set( color->obj, r, g, b, a );
1549 * @param obj Evas_Object that effect is applying to
1550 * @param from_r RGB R when the effect begins
1551 * @param from_g RGB G when the effect begins
1552 * @param from_b RGB B when the effect begins
1553 * @param from_a RGB A when the effect begins
1554 * @param to_r RGB R to be
1555 * @param to_g RGB G to be
1556 * @param to_b RGB B to be
1557 * @param to_a RGB A to be
1558 * @return Color Effect
1560 EAPI Elm_Effect* elm_fx_color_add( Evas_Object* obj,
1561 const unsigned int from_r,
1562 const unsigned int from_g,
1563 const unsigned int from_b,
1564 const unsigned int from_a,
1565 const unsigned int to_r,
1566 const unsigned int to_g,
1567 const unsigned int to_b,
1568 const unsigned int to_a )
1570 #ifdef ELM_FX_EXCEPTION_ENABLE
1571 ELM_FX_NULL_CHECK_WITH_RET( obj, NULL );
1574 Elm_Effect* effect = calloc( 1, sizeof( Elm_Effect ) );
1576 if( effect == NULL ) {
1577 fprintf( stderr, "Failed to allocate Elm_Effect!\n" );
1581 Elm_Fx_Color* color = calloc( 1, sizeof( Elm_Fx_Color ) );
1583 if( color == NULL ) {
1584 fprintf( stderr, "Failed to allocate Elm_Effect!\n" );
1590 color->from.r = from_r;
1591 color->from.g = from_g;
1592 color->from.b = from_b;
1593 color->from.a = from_a;
1594 color->to.r = to_r - from_r;
1595 color->to.g = to_g - from_g;
1596 color->to.b = to_b - from_b;
1597 color->to.a = to_a - from_a;
1599 effect->begin_op = _elm_fx_color_begin;
1600 effect->animation_op = _elm_fx_color_op;
1601 effect->user_data = color;
1610 /////////////////////////////////////////////////////////////////////////////////////
1612 /////////////////////////////////////////////////////////////////////////////////////
1613 typedef struct _fade Elm_Fx_Fade;
1617 Evas_Object* before;
1620 struct _signed_color before_color, after_color;
1624 Eina_Bool inversed : 1;
1629 static void _elm_fx_fade_begin( void* data,
1630 const Eina_Bool auto_reverse,
1631 const unsigned int repeat_cnt )
1633 Elm_Fx_Fade* fade = data;
1634 fade->inversed = EINA_FALSE;
1638 static void _elm_fx_fade_end( void* data,
1639 const Eina_Bool auto_reverse,
1640 const unsigned int repeat_cnt )
1642 Elm_Fx_Fade* fade = data;
1644 evas_object_color_set( fade->before,
1645 fade->before_color.r,
1646 fade->before_color.g,
1647 fade->before_color.b,
1648 fade->before_color.a );
1650 evas_object_color_set( fade->after,
1651 fade->after_color.r,
1652 fade->after_color.g,
1653 fade->after_color.b,
1654 fade->after_color.a );
1657 static void _elm_fx_fade_op( void* data, Elm_Animator* animator, const double frame )
1659 Elm_Fx_Fade* fade = data;
1665 if( fade->inversed == EINA_FALSE ) {
1666 evas_object_hide( fade->after );
1667 evas_object_show( fade->before );
1668 fade->inversed = EINA_TRUE;
1671 _frame = 1 - frame * 2;
1673 evas_object_color_set( fade->before,
1674 fade->before_color.r * _frame,
1675 fade->before_color.g * _frame,
1676 fade->before_color.b * _frame,
1677 fade->before_color.a + fade->before_alpha * (1-_frame) );
1680 if( fade->inversed == EINA_TRUE ) {
1681 evas_object_hide( fade->before );
1682 evas_object_show( fade->after );
1683 fade->inversed = EINA_FALSE;
1686 _frame = ( frame - 0.5 ) * 2;
1688 evas_object_color_set( fade->after,
1689 fade->after_color.r * _frame,
1690 fade->after_color.g * _frame,
1691 fade->after_color.b * _frame,
1692 fade->after_color.a + fade->after_alpha * (1 -_frame) );
1703 * @param before Evas Object before fade in
1704 * @param after Evas Object after fade out
1705 * @return Fade Effect
1707 EAPI Elm_Effect* elm_fx_fade_add( Evas_Object* before, Evas_Object* after )
1709 #ifdef ELM_FX_EXCEPTION_ENABLE
1710 ELM_FX_NULL_CHECK_WITH_RET( before && after, NULL );
1713 Elm_Effect* effect = calloc( 1, sizeof( Elm_Effect ) );
1715 if( effect == NULL ) {
1716 fprintf( stderr, "Failed to allocate Elm_Effect!\n" );
1720 Elm_Fx_Fade* fade = calloc( 1, sizeof( Elm_Fx_Fade ) );
1722 if( fade == NULL ) {
1723 fprintf( stderr, "Failed to allocate Elm_Effect!\n" );
1728 evas_object_color_get( before,
1729 &fade->before_color.r,
1730 &fade->before_color.g,
1731 &fade->before_color.b,
1732 &fade->before_color.a );
1734 evas_object_color_get( after,
1735 &fade->after_color.r,
1736 &fade->after_color.g,
1737 &fade->after_color.b,
1738 &fade->after_color.a );
1740 fade->before = before;
1741 fade->after = after;
1742 fade->before_alpha = 255 - fade->before_color.a;
1743 fade->after_alpha = 255 - fade->after_color.a;
1745 effect->begin_op = _elm_fx_fade_begin;
1746 effect->end_op = _elm_fx_fade_end;
1747 effect->animation_op = _elm_fx_fade_op;
1748 effect->user_data = fade;
1761 /////////////////////////////////////////////////////////////////////////////////////
1763 /////////////////////////////////////////////////////////////////////////////////////
1764 typedef struct _blend Elm_Fx_Blend;
1768 Evas_Object* before;
1771 struct _signed_color from, to;
1774 static void _elm_fx_blend_begin( void* data,
1775 const Eina_Bool auto_reverse,
1776 const unsigned int repeat_cnt )
1778 Elm_Fx_Blend* blend = data;
1779 evas_object_show( blend->before );
1783 static void _elm_fx_blend_end( void* data,
1784 const Eina_Bool auto_reverse,
1785 const unsigned int repeat_cnt )
1787 Elm_Fx_Blend* blend = data;
1789 evas_object_color_set( blend->before,
1795 evas_object_color_set( blend->after,
1801 if( auto_reverse == EINA_FALSE ) {
1802 evas_object_hide( blend->before );
1804 evas_object_hide( blend->after );
1810 static void _elm_fx_blend_op( void* data, Elm_Animator* animator, const double frame )
1812 Elm_Fx_Blend* blend = data;
1814 evas_object_show( blend->after );
1816 evas_object_color_set( blend->before,
1817 (int) ( blend->from.r * ( 1 - frame ) ),
1818 (int) ( blend->from.g * ( 1 - frame ) ),
1819 (int) ( blend->from.b * ( 1 - frame ) ),
1820 (int) ( blend->from.a * ( 1 - frame ) ) );
1822 evas_object_color_set( blend->after,
1823 (int) ( blend->to.r * frame ),
1824 (int) ( blend->to.g * frame ),
1825 (int) ( blend->to.b * frame ),
1826 (int) ( blend->to.a * frame ) );
1835 * @param before Evas Object before blending
1836 * @param after Evas Object after blending
1837 * @return Blend Effect
1839 EAPI Elm_Effect* elm_fx_blend_add( Evas_Object* before, Evas_Object* after )
1841 #ifdef ELM_FX_EXCEPTION_ENABLE
1842 ELM_FX_NULL_CHECK_WITH_RET( before && after, NULL );
1845 Elm_Effect* effect = calloc( 1, sizeof( Elm_Effect ) );
1847 if( effect == NULL ) {
1848 fprintf( stderr, "Failed to allocate Elm_Effect!\n" );
1852 Elm_Fx_Blend* blend = calloc( 1, sizeof( Elm_Fx_Blend ) );
1854 if( blend == NULL ) {
1855 fprintf( stderr, "Failed to allocate Elm_Effect!\n" );
1860 blend->before = before;
1861 blend->after = after;
1863 evas_object_color_get( before, &blend->from.r, &blend->from.g, &blend->from.b, &blend->from.a );
1864 evas_object_color_get( after, &blend->to.r, &blend->to.g, &blend->to.b, &blend->to.a );
1866 effect->begin_op = _elm_fx_blend_begin;
1867 effect->end_op = _elm_fx_blend_end;
1868 effect->animation_op = _elm_fx_blend_op;
1869 effect->user_data = blend;
1878 /////////////////////////////////////////////////////////////////////////////////////
1880 /////////////////////////////////////////////////////////////////////////////////////
1881 typedef struct _rotation Elm_Fx_Rotation;
1889 static void _elm_fx_rotation_begin( void* data,
1890 const Eina_Bool auto_reverse,
1891 const unsigned int repeat_cnt )
1893 Elm_Fx_Rotation* rotation = data;
1894 evas_object_show( rotation->obj );
1899 static void _elm_fx_rotation_end( void* data,
1900 const Eina_Bool auto_reverse,
1901 const unsigned int repeat_cnt )
1903 Elm_Fx_Rotation* rotation = data;
1904 evas_object_map_enable_set( rotation->obj, EINA_FALSE );
1910 static void _elm_fx_rotation_op( void* data, Elm_Animator* animator, const double frame )
1912 Elm_Fx_Rotation* rotation = data;
1914 Evas_Map* map = evas_map_new( 4 );
1920 evas_map_smooth_set( map, EINA_TRUE );
1921 evas_map_util_points_populate_from_object_full( map, rotation->obj, 0 );
1923 float degree = rotation->from + (float) ( frame * rotation->to );
1925 if( rotation->cw == EINA_FALSE ) {
1929 Evas_Coord x, y, w, h;
1930 evas_object_geometry_get( rotation->obj, &x, &y, &w, &h );
1932 float half_w = (float) w * 0.5;
1933 float half_h = (float) h * 0.5;
1935 evas_map_util_3d_rotate( map, 0, 0, degree, x + half_w, y + half_h, 0 );
1936 evas_map_util_3d_perspective( map, x + half_w, y + half_h, 0, 10000 );
1938 evas_object_map_enable_set( rotation->obj, EINA_TRUE );
1939 evas_object_map_set( rotation->obj, map );
1941 evas_map_free( map );
1950 * Add Rotation Effect
1952 * @param obj Evas_Object that effect is applying to
1953 * @param from degree Degree when effect begins
1954 * @param to_degree Degree when effect is done
1955 * @param cw Rotation Direction. EINA_TRUE is clock wise
1956 * @return Rotation effect
1958 EAPI Elm_Effect* elm_fx_rotation_add( Evas_Object* obj,
1959 const float from_degree,
1960 const float to_degree,
1961 const Eina_Bool cw )
1963 #ifdef ELM_FX_EXCEPTION_ENABLE
1964 ELM_FX_NULL_CHECK_WITH_RET( obj, NULL );
1967 Elm_Effect* effect = calloc( 1, sizeof( Elm_Effect ) );
1969 if( effect == NULL ) {
1970 fprintf( stderr, "Failed to allocate Elm_Effect!\n" );
1974 Elm_Fx_Rotation* rotation = calloc( 1, sizeof( Elm_Fx_Rotation ) );
1976 if( rotation == NULL ) {
1977 fprintf( stderr, "Failed to allocate Elm_Effect!\n" );
1982 rotation->obj = obj;
1983 rotation->from = from_degree;
1984 rotation->to = to_degree - from_degree;
1987 effect->begin_op = _elm_fx_rotation_begin;
1988 effect->end_op = _elm_fx_rotation_end;
1989 effect->animation_op = _elm_fx_rotation_op;
1990 effect->user_data = rotation;
1999 /////////////////////////////////////////////////////////////////////////////////////
2001 /////////////////////////////////////////////////////////////////////////////////////
2002 typedef struct _transform Elm_Fx_Transform;
2006 Elm_Fx_Matrix from, to;
2011 static void _elm_fx_transform_begin( void* data,
2012 const Eina_Bool auto_reverse,
2013 const unsigned int repeat_cnt )
2015 Elm_Fx_Transform* transform = data;
2017 evas_object_geometry_get( transform->obj, NULL, NULL, &transform->w, &transform->h );
2019 float from_rate = ( transform->w - transform->from._43 ) / transform->w;
2020 float to_rate = ( transform->w - transform->to._43 ) / transform->w;
2022 if( from_rate <= 0 ) from_rate = 0.001;
2023 if( to_rate <= 0 ) to_rate = 0.001;
2025 transform->from._43 = ( 10000 - from_rate * 10000 ) * ( 1 / from_rate );
2026 transform->to._43 = ( 10000 - to_rate * 10000 ) * ( 1 / to_rate ) - transform->from._43;
2028 evas_object_show( transform->obj );
2032 static void _elm_fx_transform_end( void* data,
2033 const Eina_Bool auto_reverse,
2034 const unsigned int repeat_cnt )
2036 Elm_Fx_Transform* transform = data;
2037 evas_object_map_enable_set( transform->obj, EINA_FALSE );
2042 void _elm_fx_transform_op( void* data, Elm_Animator* animator, const double frame )
2044 Elm_Fx_Transform* transform = data;
2046 Evas_Map* map = evas_map_new( 4 );
2052 evas_map_smooth_set( map, EINA_TRUE );
2054 float x = frame * transform->to._41 + transform->from._41;
2055 float y = frame * transform->to._42 + transform->from._42;
2057 float z = transform->from._43 + frame * transform->to._43;
2058 float w = transform->to._11 * frame * (float) transform->w + (float) transform->w;
2059 float h = transform->to._22 * frame * (float) transform->h + (float) transform->h;
2061 evas_map_point_coord_set( map, 0, x, y, z );
2062 evas_map_point_coord_set( map, 1, x + w, y, z );
2063 evas_map_point_coord_set( map, 2, x + w, y + h, z );
2064 evas_map_point_coord_set( map, 3, x, y + h, z );
2066 evas_map_point_image_uv_set( map, 0, 0, 0 );
2067 evas_map_point_image_uv_set( map, 1, transform->w, 0 );
2068 evas_map_point_image_uv_set( map, 2, transform->w, transform->h );
2069 evas_map_point_image_uv_set( map, 3, 0, transform->h );
2071 evas_map_util_3d_perspective( map, transform->w / 2, transform->h / 2, 0, 10000 );
2072 evas_object_map_enable_set( transform->obj, EINA_TRUE );
2073 evas_object_map_set( transform->obj, map );
2074 evas_map_free( map );
2081 EAPI Elm_Effect* elm_fx_transform_add( Evas_Object* obj,
2082 Elm_Fx_Matrix* from,
2085 #ifdef ELM_fX_EXCEPTION_ENABLE
2086 ELM_FX_NULL_CHECK_WITH_RET( obj && from && to );
2088 Elm_Effect* effect = calloc( 1, sizeof( Elm_Effect ) );
2090 if( effect == NULL ) {
2091 fprintf( stderr, "Failed to allocate Elm_Effect!\n" );
2095 Elm_Fx_Transform* transform = calloc( 1, sizeof( Elm_Fx_Transform ) );
2097 if( transform == NULL ) {
2098 fprintf( stderr, "Failed to allocate Elm_Effect!\n" );
2103 transform->obj = obj;
2104 memcpy( &transform->from, from, sizeof( Elm_Fx_Matrix ) );
2106 transform->to._11 = to->_11 - from->_11;
2107 transform->to._12 = to->_12 - from->_12;
2108 transform->to._13 = to->_13 - from->_13;
2109 transform->to._14 = to->_14 - from->_14;
2111 transform->to._21 = to->_21 - from->_21;
2112 transform->to._22 = to->_22 - from->_22;
2113 transform->to._23 = to->_23 - from->_23;
2114 transform->to._24 = to->_24 - from->_24;
2116 transform->to._31 = to->_31 - from->_31;
2117 transform->to._32 = to->_32 - from->_32;
2118 transform->to._33 = to->_33 - from->_33;
2119 transform->to._34 = to->_34 - from->_34;
2121 transform->to._41 = to->_41 - from->_41;
2122 transform->to._42 = to->_42 - from->_42;
2123 transform->to._43 = to->_43 - from->_43;
2124 transform->to._44 = to->_44 - from->_44;
2126 effect->begin_op = _elm_fx_transform_begin;
2127 effect->end_op = _elm_fx_transform_end;
2128 effect->animation_op = _elm_fx_transform_op;
2129 effect->user_data = transform;
2136 EAPI void elm_fx_transform_identity_set( Elm_Fx_Matrix* m )
2138 #ifdef ELM_FX_EXCEPTION_ENABLE
2139 ELM_FX_NULL_CHECK( m );
2141 m->_11 = 1; m->_12 = 0; m->_13 = 0; m->_14 = 0;
2142 m->_21 = 0; m->_22 = 1; m->_23 = 0; m->_24 = 0;
2143 m->_31 = 0; m->_32 = 0; m->_33 = 1; m->_34 = 0;
2144 m->_41 = 0; m->_42 = 0; m->_43 = 0; m->_44 = 1;
2149 EAPI void elm_fx_transform_translate( Elm_Fx_Matrix* m,
2154 #ifdef ELM_FX_EXCEPTION_ENABLE
2155 ELM_FX_NULL_CHECK( m );
2157 m->_41 = m->_11 * pos_x + m->_12 * pos_y + m->_13 * pos_z + m->_14;
2158 m->_42 = m->_21 * pos_x + m->_22 * pos_y + m->_23 * pos_z + m->_24;
2159 m->_43 = m->_31 * pos_x + m->_32 * pos_y + m->_33 * pos_z + m->_34;
2164 EAPI void elm_fx_transform_scale( Elm_Fx_Matrix* m,
2165 const float scale_x,
2166 const float scale_y,
2167 const float scale_z )
2169 #ifdef ELM_FX_EXCEPTION_ENABLE
2170 ELM_FX_NULL_CHECK( m );
2172 m->_11 *= scale_x; m->_12 *= scale_y; m->_13 *= scale_z;
2173 m->_21 *= scale_x; m->_22 *= scale_y; m->_23 *= scale_z;
2174 m->_31 *= scale_z; m->_32 *= scale_z; m->_33 *= scale_z;
2179 EAPI void elm_fx_transform_rotate( Elm_Fx_Matrix* m,
2184 #ifdef ELM_FX_EXCEPTION_ENABLE
2185 ELM_FX_NULL_CHECK( m );
2188 fprintf( stderr, "Sorry, It does not support yet!\n" );
2190 //Current rotation is Euler way.
2191 //But how about change to Quarterion way?
2194 if( rad_x != 0.0f ) {
2195 memcpy( &temp, m, sizeof( temp ) );
2196 m->_12 = temp._12 * cos(rad_x) + temp._13 * sin(rad_x);
2197 m->_13 = temp._12 * -sin(rad_x) + temp._13 * cos(rad_x);
2198 m->_22 = temp._22 * cos(rad_x) + temp._23 * sin(rad_x);
2199 m->_23 = temp._22 * -sin(rad_x) + temp._23 * cos(rad_x);
2200 m->_32 = temp._32 * cos(rad_x) + temp._33 * sin(rad_x);
2201 m->_33 = temp._32 * -sin(rad_x) + temp._33 * cos(rad_x);
2202 m->_42 = temp._42 * cos(rad_x) + temp._43 * sin(rad_x);
2203 m->_43 = temp._42 * -sin(rad_x) + temp._43 * cos(rad_x);
2206 if( rad_y != 0.0f ) {
2207 memcpy( &temp, m, sizeof( temp ) );
2208 m->_11 = temp._11 * cos(rad_y) - temp._13 * sin(rad_y);
2209 m->_13 = temp._11 * sin(rad_y) + temp._13 * cos(rad_y);
2210 m->_21 = temp._21 * cos(rad_y) - temp._23 * sin(rad_y);
2211 m->_23 = temp._21 * sin(rad_y) + temp._23 * cos(rad_y);
2212 m->_31 = temp._31 * cos(rad_y) - temp._33 * sin(rad_y);
2213 m->_33 = temp._31 * sin(rad_y) + temp._33 * cos(rad_y);
2214 m->_41 = temp._41 * cos(rad_y) - temp._43 * sin(rad_y);
2215 m->_43 = temp._41 * sin(rad_y) + temp._43 * cos(rad_y);
2218 if( rad_z != 0.0f ) {
2219 memcpy( &temp, m, sizeof( temp ) );
2220 m->_11 = temp._11 * cos(rad_z) + temp._12 * sin(rad_z);
2221 m->_12 = -temp._11 * sin(rad_z) + temp._12 * cos(rad_z);
2222 m->_21 = temp._21 * cos(rad_z) + temp._22 * sin(rad_z);
2223 m->_22 = -temp._21 * sin(rad_z) + temp._22 * cos(rad_z);
2224 m->_31 = temp._31 * cos(rad_z) + temp._32 * sin(rad_z);
2225 m->_32 = -temp._31 * sin(rad_z) + temp._32 * cos(rad_z);
2226 m->_41 = temp._41 * cos(rad_z) + temp._42 * sin(rad_z);
2227 m->_42 = -temp._41 * sin(rad_z) + temp._42 * cos(rad_z);
2235 EAPI void elm_fx_transform_multiply( Elm_Fx_Matrix* m, Elm_Fx_Matrix* m1, Elm_Fx_Matrix* m2 )
2237 #ifdef ELM_FX_EXCEPTION_ENABLE
2238 ELM_FX_NULL_CHECK( m && m1 && m2 );
2241 m->_11 = m1->_11 * m2->_11 + m1->_12 * m2->_21 + m1->_13 * m2->_31 + m1->_14 * m2->_41;
2242 m->_12 = m1->_11 * m2->_12 + m1->_12 * m2->_22 + m1->_13 * m2->_32 + m1->_14 * m2->_42;
2243 m->_13 = m1->_11 * m2->_13 + m1->_12 * m2->_23 + m1->_13 * m2->_33 + m1->_14 * m2->_43;
2244 m->_14 = m1->_11 * m2->_14 + m1->_12 * m2->_24 + m1->_13 * m2->_34 + m1->_14 * m2->_44;
2246 m->_21 = m1->_21 * m2->_11 + m1->_22 * m2->_21 + m1->_23 * m2->_31 + m1->_24 * m2->_41;
2247 m->_22 = m1->_21 * m2->_12 + m1->_22 * m2->_22 + m1->_23 * m2->_32 + m1->_24 * m2->_42;
2248 m->_23 = m1->_21 * m2->_13 + m1->_22 * m2->_23 + m1->_23 * m2->_33 + m1->_24 * m2->_43;
2249 m->_24 = m1->_21 * m2->_14 + m1->_22 * m2->_24 + m1->_23 * m2->_34 + m1->_24 * m2->_44;
2251 m->_31 = m1->_31 * m2->_11 + m1->_32 * m2->_21 + m1->_33 * m2->_31 + m1->_34 * m2->_41;
2252 m->_32 = m1->_31 * m2->_12 + m1->_32 * m2->_22 + m1->_33 * m2->_32 + m1->_34 * m2->_42;
2253 m->_33 = m1->_31 * m2->_13 + m1->_32 * m2->_23 + m1->_33 * m2->_33 + m1->_34 * m2->_43;
2254 m->_34 = m1->_31 * m2->_14 + m1->_32 * m2->_24 + m1->_33 * m2->_34 + m1->_34 * m2->_44;
2256 m->_41 = m1->_41 * m2->_11 + m1->_42 * m2->_21 + m1->_43 * m2->_31 + m1->_44 * m2->_41;
2257 m->_42 = m1->_41 * m2->_12 + m1->_42 * m2->_22 + m1->_43 * m2->_32 + m1->_44 * m2->_42;
2258 m->_43 = m1->_41 * m2->_13 + m1->_42 * m2->_23 + m1->_43 * m2->_33 + m1->_44 * m2->_43;
2259 m->_44 = m1->_41 * m2->_14 + m1->_42 * m2->_24 + m1->_43 * m2->_34 + m1->_44 * m2->_44;
2264 /////////////////////////////////////////////////////////////////////////////////////
2265 // ImageAnimation FX
2266 /////////////////////////////////////////////////////////////////////////////////////
2267 typedef struct _image_animation Elm_Fx_Image_Animation;
2269 struct _image_animation {
2276 static void _elm_fx_imageanimation_begin( void* data,
2277 const Eina_Bool auto_reverse,
2278 const unsigned int repeat_cnt )
2282 static void _elm_fx_imageanimation_end( void* data,
2283 const Eina_Bool auto_reverse,
2284 const unsigned int repeat_cnt )
2288 void _elm_fx_imageanimation_op( void* data, Elm_Animator* animator, const double frame )
2290 Elm_Fx_Image_Animation* image_animation = (Elm_Fx_Image_Animation *)data;
2292 if ( image_animation->icon == NULL ) {
2296 image_animation->count = floor( frame * image_animation->item_num );
2298 elm_icon_file_set( image_animation->icon, image_animation->images[image_animation->count], NULL );
2304 * Add ImageAnimation effect.
2306 * @param images Images for animation.
2307 * @return ImageAnimation Effect.
2309 EAPI Elm_Effect* elm_fx_imageanimation_add( const Evas_Object* icon, const char** images, const unsigned int item_num )
2311 #ifdef ELM_FX_EXCEPTION_ENABLE
2312 ELM_FX_NULL_CHECK_WITH_RET( images, NULL );
2315 Elm_Effect* effect = calloc( 1, sizeof( Elm_Effect ) );
2317 if( effect == NULL ) {
2318 fprintf( stderr, "Failed to allocate Elm_Effect!\n" );
2322 if( images == NULL || *images == NULL ) {
2323 fprintf( stderr, "Failed to load NULL images!\n" );
2327 Elm_Fx_Image_Animation* image_animation = calloc( 1, sizeof( Elm_Fx_Image_Animation) );
2329 if( image_animation == NULL ) {
2330 fprintf( stderr, "Failed to allocate Elm_Effect!\n" );
2335 image_animation->icon = icon;
2336 image_animation->images = images;
2337 image_animation->count = 0;
2338 image_animation->item_num = item_num;
2340 effect->begin_op = _elm_fx_imageanimation_begin;
2341 effect->end_op = _elm_fx_imageanimation_end;
2342 effect->animation_op = _elm_fx_imageanimation_op;
2343 effect->user_data = image_animation ;