From: Enlightenment S. <no-...@en...> - 2010-11-10 18:05:52
|
Log: Elm_Transit: Following the style of efl ELM_FX is now ELM_TRANSIT_EFFECT Curve style like in edje Changing names: CURVE_IN -> TWEEN_DECELERATE CURVE_OUT -> TWEEN_ACCELERATE CURVE_IN_OUT -> TWEEN_SINUSOIDAL Curve_Style -> Tween_Mode Now, the calculation is done like in edje. Changing function of type function() to function(void) Elm_Transit: Changing calloc(1, to ELM_NEW Author: Helen Fornazier <hel...@pr...> Author: tiago Date: 2010-11-10 10:05:45 -0800 (Wed, 10 Nov 2010) New Revision: 54417 Modified: trunk/TMP/st/elementary/src/bin/test_transit.c trunk/TMP/st/elementary/src/lib/Elementary.h.in trunk/TMP/st/elementary/src/lib/elm_transit.c Modified: trunk/TMP/st/elementary/src/bin/test_transit.c =================================================================== --- trunk/TMP/st/elementary/src/bin/test_transit.c 2010-11-10 18:05:42 UTC (rev 54416) +++ trunk/TMP/st/elementary/src/bin/test_transit.c 2010-11-10 18:05:45 UTC (rev 54417) @@ -165,8 +165,8 @@ elm_transit_object_add(trans, bt); /* Wipe Effect */ - effect_context = elm_transit_effect_wipe_context_new(ELM_FX_WIPE_TYPE_HIDE, - ELM_FX_WIPE_DIR_RIGHT); + effect_context = elm_transit_effect_wipe_context_new(ELM_TRANSIT_EFFECT_WIPE_TYPE_HIDE, + ELM_TRANSIT_EFFECT_WIPE_DIR_RIGHT); elm_transit_effect_add(trans, elm_transit_effect_wipe_op, effect_context, elm_transit_effect_wipe_context_free); @@ -246,7 +246,7 @@ trans = elm_transit_add(5.0); elm_transit_object_add(trans, bt); elm_transit_object_add(trans, bt2); - effect_context = elm_transit_effect_flip_context_new(ELM_FX_FLIP_AXIS_X, + effect_context = elm_transit_effect_flip_context_new(ELM_TRANSIT_EFFECT_FLIP_AXIS_X, EINA_TRUE); elm_transit_effect_add(trans, elm_transit_effect_flip_op, effect_context, @@ -425,7 +425,7 @@ /* Adding Transit */ effect_context = \ - elm_transit_effect_resizable_flip_context_new(ELM_FX_FLIP_AXIS_X, + elm_transit_effect_resizable_flip_context_new(ELM_TRANSIT_EFFECT_FLIP_AXIS_X, EINA_TRUE); trans = elm_transit_add(5.0); elm_transit_object_add(trans, bt2); @@ -465,6 +465,7 @@ /* Adding Transit */ trans = elm_transit_add(5.0); elm_transit_auto_reverse_set(trans, EINA_TRUE); + elm_transit_tween_mode_set(trans, ELM_TRANSIT_TWEEN_MODE_DECELERATE); elm_transit_repeat_times_set(trans, -1); effect_context = _custom_context_new(100, 100, 250, 250); elm_transit_object_add(trans, bt); Modified: trunk/TMP/st/elementary/src/lib/Elementary.h.in =================================================================== --- trunk/TMP/st/elementary/src/lib/Elementary.h.in 2010-11-10 18:05:42 UTC (rev 54416) +++ trunk/TMP/st/elementary/src/lib/Elementary.h.in 2010-11-10 18:05:45 UTC (rev 54417) @@ -2315,27 +2315,27 @@ /* transit */ typedef enum { - ELM_TRANSIT_CURVE_LINEAR, - ELM_TRANSIT_CURVE_IN_OUT, - ELM_TRANSIT_CURVE_IN, - ELM_TRANSIT_CURVE_OUT - } Elm_Transit_Curve_Style; + ELM_TRANSIT_TWEEN_MODE_LINEAR, + ELM_TRANSIT_TWEEN_MODE_SINUSOIDAL, + ELM_TRANSIT_TWEEN_MODE_DECELERATE, + ELM_TRANSIT_TWEEN_MODE_ACCELERATE + } Elm_Transit_Tween_Mode; typedef enum { - ELM_FX_FLIP_AXIS_X, - ELM_FX_FLIP_AXIS_Y + ELM_TRANSIT_EFFECT_FLIP_AXIS_X, + ELM_TRANSIT_EFFECT_FLIP_AXIS_Y } Elm_Fx_Flip_Axis; typedef enum { - ELM_FX_WIPE_DIR_LEFT, - ELM_FX_WIPE_DIR_RIGHT, - ELM_FX_WIPE_DIR_UP, - ELM_FX_WIPE_DIR_DOWN + ELM_TRANSIT_EFFECT_WIPE_DIR_LEFT, + ELM_TRANSIT_EFFECT_WIPE_DIR_RIGHT, + ELM_TRANSIT_EFFECT_WIPE_DIR_UP, + ELM_TRANSIT_EFFECT_WIPE_DIR_DOWN } Elm_Fx_Wipe_Dir; typedef enum { - ELM_FX_WIPE_TYPE_HIDE, - ELM_FX_WIPE_TYPE_SHOW + ELM_TRANSIT_EFFECT_WIPE_TYPE_HIDE, + ELM_TRANSIT_EFFECT_WIPE_TYPE_SHOW } Elm_Fx_Wipe_Type; typedef struct _Elm_Transit Elm_Transit; @@ -2349,7 +2349,7 @@ EAPI void elm_transit_repeat_times_set(Elm_Transit *transit, int repeat); EAPI void elm_transit_auto_reverse_set(Elm_Transit *transit, Eina_Bool reverse); - EAPI void elm_transit_curve_style_set(Elm_Transit *transit, Elm_Transit_Curve_Style cs); + EAPI void elm_transit_tween_mode_set(Elm_Transit *transit, Elm_Transit_Tween_Mode tween_mode); EAPI void elm_transit_event_block_set(Elm_Transit *transit, Eina_Bool disabled); EAPI Eina_Bool elm_transit_event_block_get(const Elm_Transit *transit); @@ -2384,11 +2384,11 @@ EAPI void elm_transit_effect_color_op(void *data, Elm_Transit *transit, double progress); EAPI void elm_transit_effect_color_context_free(void *data, Elm_Transit *transit); - EAPI void *elm_transit_effect_fade_context_new(); + EAPI void *elm_transit_effect_fade_context_new(void); EAPI void elm_transit_effect_fade_op(void *data, Elm_Transit *transit, double progress); EAPI void elm_transit_effect_fade_context_free(void *data, Elm_Transit *tranasit); - EAPI void *elm_transit_effect_blend_context_new(); + EAPI void *elm_transit_effect_blend_context_new(void); EAPI void elm_transit_effect_blend_op(void *data, Elm_Transit *transit, double progress); EAPI void elm_transit_effect_blend_context_free(void *data, Elm_Transit *transit); Modified: trunk/TMP/st/elementary/src/lib/elm_transit.c =================================================================== --- trunk/TMP/st/elementary/src/lib/elm_transit.c 2010-11-10 18:05:42 UTC (rev 54416) +++ trunk/TMP/st/elementary/src/lib/elm_transit.c 2010-11-10 18:05:45 UTC (rev 54417) @@ -29,7 +29,7 @@ double duration; int repeat_cnt; int cur_repeat_cnt; - double (*curve_op) (double progress); + Elm_Transit_Tween_Mode tween_mode; Eina_Bool auto_reverse:1; }; @@ -48,10 +48,6 @@ static void _remove_dead_effects(Elm_Transit *transit); static void _elm_transit_object_remove_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__); static void _elm_transit_object_remove(Elm_Transit *transit, Evas_Object *obj); -static double _animator_curve_linear(double progress); -static double _animator_curve_in_out(double progress); -static double _animator_curve_in(double progress); -static double _animator_curve_out(double progress); static Eina_Bool _animator_animate_cb(void *data); static unsigned int _animator_compute_no_reverse_repeat_count(unsigned int cnt); static unsigned int _animator_compute_reverse_repeat_count(unsigned int cnt); @@ -121,7 +117,7 @@ EINA_LIST_FOREACH(transit->effect_list, elist, effect) if ((effect->animation_op == cb) && (effect->user_data == data)) return; - effect = calloc(1, sizeof(Elm_Effect)); + effect = ELM_NEW(Elm_Effect); if (!effect) return; effect->user_data_free = data_free_cb; @@ -276,62 +272,34 @@ } static double -_animator_curve_linear(double progress) +_tween_progress_calc(Elm_Transit *transit, double progress) { - return progress; + switch (transit->tween_mode) + { + case ELM_TRANSIT_TWEEN_MODE_ACCELERATE: + return 1.0 - sin((ELM_PI / 2.0) + (progress * ELM_PI / 2.0)); + case ELM_TRANSIT_TWEEN_MODE_DECELERATE: + return sin(progress * ELM_PI / 2.0); + case ELM_TRANSIT_TWEEN_MODE_SINUSOIDAL: + return (1.0 - cos(progress * ELM_PI)) / 2.0; + default: + return progress; + } } -static double -_animator_curve_in_out(double progress) -{ - if (progress < 0.5) - return _animator_curve_out(progress * 2) * 0.5; - else - return (_animator_curve_in(progress * 2 - 1) * 0.5) + 0.5; -} - -static double -_animator_curve_in(double progress) -{ - return sqrt(1 - pow(progress - 1, 2)); -} - -static double -_animator_curve_out(double progress) -{ - return 1 - sqrt(1 - pow(progress, 2)); -} - /** * Set the transit animation acceleration style. * * @param transit Transit - * @param cs Curve style(Please refer elm_animator_curve_style_set) + * @param tween_mode The tween type * * @ingroup Transit */ EAPI void -elm_transit_curve_style_set(Elm_Transit *transit, Elm_Transit_Curve_Style cs) +elm_transit_tween_mode_set(Elm_Transit *transit, Elm_Transit_Tween_Mode tween_mode) { if (!transit) return; - switch (cs) - { - case ELM_TRANSIT_CURVE_LINEAR: - transit->curve_op = _animator_curve_linear; - break; - case ELM_TRANSIT_CURVE_IN_OUT: - transit->curve_op = _animator_curve_in_out; - break; - case ELM_TRANSIT_CURVE_IN: - transit->curve_op = _animator_curve_in; - break; - case ELM_TRANSIT_CURVE_OUT: - transit->curve_op = _animator_curve_out; - break; - default: - transit->curve_op = _animator_curve_linear; - break; - } + transit->tween_mode = tween_mode; } /** @@ -345,11 +313,11 @@ EAPI Elm_Transit * elm_transit_add(double duration) { - Elm_Transit *transit = calloc(1, sizeof(Elm_Transit)); + Elm_Transit *transit = ELM_NEW(Elm_Transit); if (!transit) return NULL; - elm_transit_curve_style_set(transit, ELM_TRANSIT_CURVE_LINEAR); + elm_transit_tween_mode_set(transit, ELM_TRANSIT_TWEEN_MODE_LINEAR); transit->duration = duration; @@ -369,7 +337,8 @@ if (elapsed_time > transit->duration) elapsed_time = transit->duration; - double progress = transit->curve_op(elapsed_time / transit->duration); + double progress = _tween_progress_calc(transit, + elapsed_time / transit->duration); /* Reverse? */ if (transit->auto_reverse) @@ -423,7 +392,7 @@ transit->objs = eina_list_append(transit->objs, obj); - state = calloc(1, sizeof(Eina_Bool)); + state = ELM_NEW(Eina_Bool); *state = evas_object_pass_events_get(obj); evas_object_data_set(obj, _transit_key, state); @@ -649,7 +618,7 @@ { Elm_Fx_Resizing *resizing; - resizing = calloc(1, sizeof(Elm_Fx_Resizing)); + resizing = ELM_NEW(Elm_Fx_Resizing); if (!resizing) return NULL; resizing->from.w = from_w; @@ -737,7 +706,7 @@ { Elm_Fx_Translation *translation; - translation = calloc(1, sizeof(Elm_Fx_Translation)); + translation = ELM_NEW(Elm_Fx_Translation); if (!translation) return NULL; @@ -831,7 +800,7 @@ { Elm_Fx_Zoom *zoom; - zoom = calloc(1, sizeof(Elm_Fx_Zoom)); + zoom = ELM_NEW(Elm_Fx_Zoom); if (!zoom) return NULL; zoom->from = (10000 - (from_rate * 10000)) * (1 / from_rate); @@ -945,7 +914,7 @@ Evas_Coord half_h = (h / 2); - if (flip->axis == ELM_FX_FLIP_AXIS_Y) + if (flip->axis == ELM_TRANSIT_EFFECT_FLIP_AXIS_Y) { if ((degree >= 90) || (degree <= -90)) { @@ -993,7 +962,7 @@ { Elm_Fx_Flip *flip; - flip = calloc(1, sizeof(Elm_Fx_Flip)); + flip = ELM_NEW(Elm_Fx_Flip); if (!flip) return NULL; flip->cw = cw; @@ -1182,7 +1151,7 @@ half_w = (Evas_Coord) (w / 2); half_h = (Evas_Coord) (h / 2); - if (resizable_flip->axis == ELM_FX_FLIP_AXIS_Y) + if (resizable_flip->axis == ELM_TRANSIT_EFFECT_FLIP_AXIS_Y) { _set_image_uv_by_axis_y(map, resizable_flip_node, degree); evas_map_util_3d_rotate(map, 0, degree, @@ -1217,7 +1186,7 @@ count = eina_list_count(transit->objs); for (i = 0; i < count-1; i+=2) { - resizable_flip_node = calloc(1, sizeof(Elm_Fx_ResizableFlip_Node)); + resizable_flip_node = ELM_NEW(Elm_Fx_ResizableFlip_Node); if (!resizable_flip_node) { eina_list_free(data_list); @@ -1264,7 +1233,7 @@ { Elm_Fx_ResizableFlip *resizable_flip; - resizable_flip = calloc(1, sizeof(Elm_Fx_ResizableFlip)); + resizable_flip = ELM_NEW(Elm_Fx_ResizableFlip); if (!resizable_flip) return NULL; resizable_flip->cw = cw; @@ -1317,7 +1286,7 @@ switch (dir) { - case ELM_FX_WIPE_DIR_LEFT: + case ELM_TRANSIT_EFFECT_WIPE_DIR_LEFT: w2 = w - (w * progress); h2 = (y + h); evas_map_point_image_uv_set(map, 0, 0, 0); @@ -1329,7 +1298,7 @@ evas_map_point_coord_set(map, 2, x + w2, h2, 0); evas_map_point_coord_set(map, 3, x, h2, 0); break; - case ELM_FX_WIPE_DIR_RIGHT: + case ELM_TRANSIT_EFFECT_WIPE_DIR_RIGHT: w2 = (w * progress); h2 = (y + h); evas_map_point_image_uv_set(map, 0, w2, 0); @@ -1341,7 +1310,7 @@ evas_map_point_coord_set(map, 2, x + w, h2, 0); evas_map_point_coord_set(map, 3, x + w2, h2, 0); break; - case ELM_FX_WIPE_DIR_UP: + case ELM_TRANSIT_EFFECT_WIPE_DIR_UP: w2 = (x + w); h2 = h - (h * progress); evas_map_point_image_uv_set(map, 0, 0, 0); @@ -1353,7 +1322,7 @@ evas_map_point_coord_set(map, 2, w2, h2, 0); evas_map_point_coord_set(map, 3, x, h2, 0); break; - case ELM_FX_WIPE_DIR_DOWN: + case ELM_TRANSIT_EFFECT_WIPE_DIR_DOWN: w2 = (x + w); h2 = (h * progress); evas_map_point_image_uv_set(map, 0, 0, h2); @@ -1379,7 +1348,7 @@ switch (dir) { - case ELM_FX_WIPE_DIR_LEFT: + case ELM_TRANSIT_EFFECT_WIPE_DIR_LEFT: w2 = (w - (w * progress)); h2 = (y + h); evas_map_point_image_uv_set(map, 0, w2, 0); @@ -1391,7 +1360,7 @@ evas_map_point_coord_set(map, 2, w, h2, 0); evas_map_point_coord_set(map, 3, x + w2, h2, 0); break; - case ELM_FX_WIPE_DIR_RIGHT: + case ELM_TRANSIT_EFFECT_WIPE_DIR_RIGHT: w2 = (w * progress); h2 = (y + h); evas_map_point_image_uv_set(map, 0, 0, 0); @@ -1403,7 +1372,7 @@ evas_map_point_coord_set(map, 2, x + w2, h2, 0); evas_map_point_coord_set(map, 3, x, h2, 0); break; - case ELM_FX_WIPE_DIR_UP: + case ELM_TRANSIT_EFFECT_WIPE_DIR_UP: w2 = (x + w); h2 = (h - (h * progress)); evas_map_point_image_uv_set(map, 0, 0, h2); @@ -1415,7 +1384,7 @@ evas_map_point_coord_set(map, 2, w2, y + h, 0); evas_map_point_coord_set(map, 3, x, y + h, 0); break; - case ELM_FX_WIPE_DIR_DOWN: + case ELM_TRANSIT_EFFECT_WIPE_DIR_DOWN: w2 = (x + w); h2 = (h * progress); evas_map_point_image_uv_set(map, 0, 0, 0); @@ -1467,7 +1436,7 @@ { evas_object_geometry_get(obj, &_x, &_y, &_w, &_h); - if (wipe->type == ELM_FX_WIPE_TYPE_SHOW) + if (wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_SHOW) _elm_fx_wipe_show(map, wipe->dir, _x, _y, _w, _h, (float)progress); else @@ -1495,7 +1464,7 @@ { Elm_Fx_Wipe *wipe; - wipe = calloc(1, sizeof(Elm_Fx_Wipe)); + wipe = ELM_NEW(Elm_Fx_Wipe); if (!wipe) return NULL; wipe->type = type; @@ -1589,7 +1558,7 @@ { Elm_Fx_Color *color; - color = calloc(1, sizeof(Elm_Fx_Color)); + color = ELM_NEW(Elm_Fx_Color); if (!color) return NULL; color->from.r = from_r; @@ -1740,7 +1709,7 @@ count = eina_list_count(transit->objs); for (i = 0; i < count-1; i+=2) { - fade = calloc(1, sizeof(Elm_Fx_Fade_Node)); + fade = ELM_NEW(Elm_Fx_Fade_Node); if (!fade) { eina_list_free(data_list); @@ -1776,10 +1745,10 @@ * @ingroup Transit */ EAPI void * -elm_transit_effect_fade_context_new() +elm_transit_effect_fade_context_new(void) { Elm_Fx_Fade *fade; - fade = calloc(1, sizeof(Elm_Fx_Fade)); + fade = ELM_NEW(Elm_Fx_Fade); if (!fade) return NULL; return fade; } @@ -1886,7 +1855,7 @@ count = eina_list_count(transit->objs); for (i = 0; i < count-1; i+=2) { - blend_node = calloc(1, sizeof(Elm_Fx_Blend_Node)); + blend_node = ELM_NEW(Elm_Fx_Blend_Node); if (!blend_node) { eina_list_free(data_list); @@ -1918,11 +1887,11 @@ * @ingroup Transit */ EAPI void * -elm_transit_effect_blend_context_new() +elm_transit_effect_blend_context_new(void) { Elm_Fx_Blend *blend; - blend = calloc(1, sizeof(Elm_Fx_Blend)); + blend = ELM_NEW(Elm_Fx_Blend); if (!blend) return NULL; return blend; @@ -2027,7 +1996,7 @@ { Elm_Fx_Rotation *rotation; - rotation = calloc(1, sizeof(Elm_Fx_Rotation)); + rotation = ELM_NEW(Elm_Fx_Rotation); if (!rotation) return NULL; rotation->from = from_degree; @@ -2136,7 +2105,7 @@ { Elm_Fx_Image_Animation *image_animation; - image_animation = calloc(1, sizeof(Elm_Fx_Image_Animation)); + image_animation = ELM_NEW(Elm_Fx_Image_Animation); if (!image_animation) return NULL; |