/* 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;
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);
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);
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;
};
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);
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;
}
static double
-_animator_curve_linear(double progress)
+_tween_progress_calc(Elm_Transit *transit, double progress)
{
- 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));
+ 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;
+ }
}
/**
* 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;
}
/**
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;
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)
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);
{
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;
{
Elm_Fx_Translation *translation;
- translation = calloc(1, sizeof(Elm_Fx_Translation));
+ translation = ELM_NEW(Elm_Fx_Translation);
if (!translation) return NULL;
{
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);
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))
{
{
Elm_Fx_Flip *flip;
- flip = calloc(1, sizeof(Elm_Fx_Flip));
+ flip = ELM_NEW(Elm_Fx_Flip);
if (!flip) return NULL;
flip->cw = cw;
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,
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);
{
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;
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);
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);
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);
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);
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);
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);
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);
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);
{
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
{
Elm_Fx_Wipe *wipe;
- wipe = calloc(1, sizeof(Elm_Fx_Wipe));
+ wipe = ELM_NEW(Elm_Fx_Wipe);
if (!wipe) return NULL;
wipe->type = type;
{
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;
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);
* @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;
}
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);
* @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;
{
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;
{
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;