efl_canvas_animation_scale: move from 2 doubles to vectors

Summary:
with this the passing of positions is getting more easy. Additionally,
Reading the API call gets easier, as parameters are semantically
grouped.
Depends on D10558

Reviewers: segfaultxavi, Jaehyun_Cho

Reviewed By: segfaultxavi

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Maniphest Tasks: T8288

Differential Revision: https://phab.enlightenment.org/D10559
This commit is contained in:
Marcel Hollerbach 2019-10-30 15:30:18 +01:00 committed by Xavi Artigas
parent 92a4fab5d7
commit e2a011f56b
6 changed files with 64 additions and 128 deletions

View File

@ -94,7 +94,7 @@ test_efl_anim_group_parallel(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSE
//Scale Animation to zoom out
Efl_Canvas_Animation *scale_half_anim = efl_add(EFL_CANVAS_ANIMATION_SCALE_CLASS, win);
efl_animation_scale_set(scale_half_anim, 2.0, 2.0, 1.0, 1.0, NULL, 0.5, 0.5);
efl_animation_scale_set(scale_half_anim, EINA_VECTOR2(2.0, 2.0), EINA_VECTOR2(1.0, 1.0), NULL, EINA_VECTOR2(0.5, 0.5));
//Show Parallel Group Animation
Efl_Canvas_Animation *parallel_show_anim = efl_add(EFL_CANVAS_ANIMATION_GROUP_PARALLEL_CLASS, win);
@ -117,7 +117,7 @@ test_efl_anim_group_parallel(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSE
//Scale Animation to zoom in
Efl_Canvas_Animation *scale_double_anim = efl_add(EFL_CANVAS_ANIMATION_SCALE_CLASS, win);
efl_animation_scale_set(scale_double_anim, 1.0, 1.0, 2.0, 2.0, NULL, 0.5, 0.5);
efl_animation_scale_set(scale_double_anim, EINA_VECTOR2(1.0, 1.0), EINA_VECTOR2(2.0, 2.0), NULL, EINA_VECTOR2(0.5, 0.5));
//Hide Parallel Group Animation
Efl_Canvas_Animation *parallel_hide_anim = efl_add(EFL_CANVAS_ANIMATION_GROUP_PARALLEL_CLASS, win);

View File

@ -90,7 +90,7 @@ test_efl_anim_group_sequential(void *data EINA_UNUSED, Evas_Object *obj EINA_UNU
//Scale Animation to zoom in
Efl_Canvas_Animation *scale_double_anim = efl_add(EFL_CANVAS_ANIMATION_SCALE_CLASS, win);
efl_animation_scale_set(scale_double_anim, 1.0, 1.0, 2.0, 2.0, NULL, 0.5, 0.5);
efl_animation_scale_set(scale_double_anim, EINA_VECTOR2(1.0, 1.0), EINA_VECTOR2(2.0, 2.0), NULL, EINA_VECTOR2(0.5, 0.5));
//Hide Animation
Efl_Canvas_Animation *hide_anim = efl_add(EFL_CANVAS_ANIMATION_ALPHA_CLASS, win);
@ -115,7 +115,7 @@ test_efl_anim_group_sequential(void *data EINA_UNUSED, Evas_Object *obj EINA_UNU
//Scale Animation to zoom out
Efl_Canvas_Animation *scale_half_anim = efl_add(EFL_CANVAS_ANIMATION_SCALE_CLASS, win);
efl_animation_scale_set(scale_half_anim, 2.0, 2.0, 1.0, 1.0, NULL, 0.5, 0.5);
efl_animation_scale_set(scale_half_anim, EINA_VECTOR2(2.0, 2.0), EINA_VECTOR2(1.0, 1.0), NULL, EINA_VECTOR2(0.5, 0.5));
efl_animation_duration_set(scale_half_anim, 1.0);
//Rotate from 45 to 0 degrees Animation

View File

@ -84,13 +84,13 @@ test_efl_anim_scale(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *
//Scale Animation to zoom in
Efl_Canvas_Animation *scale_double_anim = efl_add(EFL_CANVAS_ANIMATION_SCALE_CLASS, win);
efl_animation_scale_set(scale_double_anim, 1.0, 1.0, 2.0, 2.0, NULL, 0.5, 0.5);
efl_animation_scale_set(scale_double_anim, EINA_VECTOR2(1.0, 1.0), EINA_VECTOR2(2.0, 2.0), NULL, EINA_VECTOR2(0.5, 0.5));
efl_animation_duration_set(scale_double_anim, 1.0);
efl_animation_final_state_keep_set(scale_double_anim, EINA_TRUE);
//Scale Animation to zoom out
Efl_Canvas_Animation *scale_half_anim = efl_add(EFL_CANVAS_ANIMATION_SCALE_CLASS, win);
efl_animation_scale_set(scale_half_anim, 2.0, 2.0, 1.0, 1.0, NULL, 0.5, 0.5);
efl_animation_scale_set(scale_half_anim, EINA_VECTOR2(2.0, 2.0), EINA_VECTOR2(1.0, 1.0), NULL, EINA_VECTOR2(0.5, 0.5));
efl_animation_duration_set(scale_half_anim, 1.0);
efl_animation_final_state_keep_set(scale_half_anim, EINA_TRUE);
@ -153,13 +153,13 @@ test_efl_anim_scale_relative(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSE
//Scale Animation to zoom in
Efl_Canvas_Animation *scale_double_anim = efl_add(EFL_CANVAS_ANIMATION_SCALE_CLASS, win);
efl_animation_scale_set(scale_double_anim, 1.0, 1.0, 2.0, 2.0, pivot, 0.5, 0.5);
efl_animation_scale_set(scale_double_anim, EINA_VECTOR2(1.0, 1.0), EINA_VECTOR2(2.0, 2.0), pivot, EINA_VECTOR2(0.5, 0.5));
efl_animation_duration_set(scale_double_anim, 1.0);
efl_animation_final_state_keep_set(scale_double_anim, EINA_TRUE);
//Scale Animation to zoom out
Efl_Canvas_Animation *scale_half_anim = efl_add(EFL_CANVAS_ANIMATION_SCALE_CLASS, win);
efl_animation_scale_set(scale_half_anim, 2.0, 2.0, 1.0, 1.0, pivot, 0.5, 0.5);
efl_animation_scale_set(scale_half_anim, EINA_VECTOR2(2.0, 2.0), EINA_VECTOR2(1.0, 1.0), pivot, EINA_VECTOR2(0.5, 0.5));
efl_animation_duration_set(scale_half_anim, 1.0);
efl_animation_final_state_keep_set(scale_half_anim, EINA_TRUE);
@ -219,13 +219,13 @@ test_efl_anim_scale_absolute(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSE
//Scale Animation to zoom in
Efl_Canvas_Animation *scale_double_anim = efl_add(EFL_CANVAS_ANIMATION_SCALE_CLASS, win);
efl_animation_scale_absolute_set(scale_double_anim, 1.0, 1.0, 2.0, 2.0, 0, 0);
efl_animation_scale_absolute_set(scale_double_anim, EINA_VECTOR2(1.0, 1.0), EINA_VECTOR2(2.0, 2.0), EINA_POSITION2D(0, 0));
efl_animation_duration_set(scale_double_anim, 1.0);
efl_animation_final_state_keep_set(scale_double_anim, EINA_TRUE);
//Scale Animation to zoom out
Efl_Canvas_Animation *scale_half_anim = efl_add(EFL_CANVAS_ANIMATION_SCALE_CLASS, win);
efl_animation_scale_absolute_set(scale_half_anim, 2.0, 2.0, 1.0, 1.0, 0, 0);
efl_animation_scale_absolute_set(scale_half_anim, EINA_VECTOR2(2.0, 2.0), EINA_VECTOR2(1.0, 1.0), EINA_POSITION2D(0, 0));
efl_animation_duration_set(scale_half_anim, 1.0);
efl_animation_final_state_keep_set(scale_half_anim, EINA_TRUE);

View File

@ -5,37 +5,26 @@
EOLIAN static void
_efl_canvas_animation_scale_scale_set(Eo *eo_obj EINA_UNUSED,
Efl_Canvas_Animation_Scale_Data *pd,
double from_scale_x,
double from_scale_y,
double to_scale_x,
double to_scale_y,
Eina_Vector2 from_scale,
Eina_Vector2 to_scale,
Efl_Canvas_Object *pivot,
double cx,
double cy)
Eina_Vector2 rel_pivot_pos)
{
pd->from.scale_x = from_scale_x;
pd->from.scale_y = from_scale_y;
pd->from = from_scale;
pd->to.scale_x = to_scale_x;
pd->to.scale_y = to_scale_y;
pd->to = to_scale;
pd->rel_pivot.obj = pivot;
pd->rel_pivot.cx = cx;
pd->rel_pivot.cy = cy;
pd->rel_pivot.pos = rel_pivot_pos;
pd->use_rel_pivot = EINA_TRUE;
}
EOLIAN static void
_efl_canvas_animation_scale_scale_get(const Eo *eo_obj EINA_UNUSED,
Efl_Canvas_Animation_Scale_Data *pd,
double *from_scale_x,
double *from_scale_y,
double *to_scale_x,
double *to_scale_y,
Efl_Canvas_Object **pivot,
double *cx,
double *cy)
_efl_canvas_animation_scale_scale_get(const Eo *obj EINA_UNUSED,
Efl_Canvas_Animation_Scale_Data *pd,
Eina_Vector2 *from_scale, Eina_Vector2 *to_scale,
Efl_Canvas_Object **pivot, Eina_Vector2 *pivot_pos)
{
if (!pd->use_rel_pivot)
{
@ -43,59 +32,39 @@ _efl_canvas_animation_scale_scale_get(const Eo *eo_obj EINA_UNUSED,
return;
}
if (from_scale_x)
*from_scale_x = pd->from.scale_x;
if (from_scale)
*from_scale = pd->from;
if (from_scale_y)
*from_scale_y = pd->from.scale_y;
if (to_scale_x)
*to_scale_x = pd->to.scale_x;
if (to_scale_y)
*to_scale_y = pd->to.scale_y;
if (to_scale)
*to_scale = pd->to;
if (pivot)
*pivot = pd->rel_pivot.obj;
if (cx)
*cx = pd->rel_pivot.cx;
if (cy)
*cy = pd->rel_pivot.cy;
if (pivot_pos)
*pivot_pos = pd->rel_pivot.pos;
}
EOLIAN static void
_efl_canvas_animation_scale_scale_absolute_set(Eo *eo_obj EINA_UNUSED,
Efl_Canvas_Animation_Scale_Data *pd,
double from_scale_x,
double from_scale_y,
double to_scale_x,
double to_scale_y,
Evas_Coord cx,
Evas_Coord cy)
_efl_canvas_animation_scale_scale_absolute_set(Eo *obj EINA_UNUSED,
Efl_Canvas_Animation_Scale_Data *pd,
Eina_Vector2 from_scale, Eina_Vector2 to_scale,
Eina_Position2D pos)
{
pd->from.scale_x = from_scale_x;
pd->from.scale_y = from_scale_y;
pd->from = from_scale;
pd->to.scale_x = to_scale_x;
pd->to.scale_y = to_scale_y;
pd->to = to_scale;
pd->abs_pivot.cx = cx;
pd->abs_pivot.cy = cy;
pd->pos = pos;
pd->use_rel_pivot = EINA_FALSE;
}
EOLIAN static void
_efl_canvas_animation_scale_scale_absolute_get(const Eo *eo_obj EINA_UNUSED,
Efl_Canvas_Animation_Scale_Data *pd,
double *from_scale_x,
double *from_scale_y,
double *to_scale_x,
double *to_scale_y,
Evas_Coord *cx,
Evas_Coord *cy)
_efl_canvas_animation_scale_scale_absolute_get(const Eo *obj EINA_UNUSED,
Efl_Canvas_Animation_Scale_Data *pd,
Eina_Vector2 *from_scale, Eina_Vector2 *to_scale,
Eina_Position2D *pos)
{
if (pd->use_rel_pivot)
{
@ -103,23 +72,14 @@ _efl_canvas_animation_scale_scale_absolute_get(const Eo *eo_obj EINA_UNUSED,
return;
}
if (from_scale_x)
*from_scale_x = pd->from.scale_x;
if (from_scale)
*from_scale = pd->from;
if (from_scale_y)
*from_scale_y = pd->from.scale_y;
if (to_scale)
*to_scale = pd->to;
if (to_scale_x)
*to_scale_x = pd->to.scale_x;
if (to_scale_y)
*to_scale_y = pd->to.scale_y;
if (cx)
*cx = pd->abs_pivot.cx;
if (cy)
*cy = pd->abs_pivot.cy;
if (pos)
*pos = pd->pos;
}
EOLIAN static double
@ -128,26 +88,26 @@ _efl_canvas_animation_scale_efl_canvas_animation_animation_apply(Eo *eo_obj,
double progress,
Efl_Canvas_Object *target)
{
Efl_Canvas_Animation_Scale_Property new_scale;
Eina_Vector2 new_scale;
progress = efl_animation_apply(efl_super(eo_obj, MY_CLASS), progress, target);
if (!target) return progress;
new_scale.scale_x = GET_STATUS(pd->from.scale_x, pd->to.scale_x, progress);
new_scale.scale_y = GET_STATUS(pd->from.scale_y, pd->to.scale_y, progress);
new_scale.x = GET_STATUS(pd->from.x, pd->to.x, progress);
new_scale.y = GET_STATUS(pd->from.y, pd->to.y, progress);
if (pd->use_rel_pivot)
{
efl_gfx_mapping_zoom(target,
new_scale.scale_x, new_scale.scale_y,
new_scale.x, new_scale.y,
(pd->rel_pivot.obj) ? pd->rel_pivot.obj : target,
pd->rel_pivot.cx, pd->rel_pivot.cy);
pd->rel_pivot.pos.x , pd->rel_pivot.pos.y);
}
else
{
efl_gfx_mapping_zoom_absolute(target,
new_scale.scale_x, new_scale.scale_y,
pd->abs_pivot.cx, pd->abs_pivot.cy);
new_scale.x, new_scale.y,
pd->pos.x, pd->pos.y);
}
return progress;
@ -159,17 +119,11 @@ _efl_canvas_animation_scale_efl_object_constructor(Eo *eo_obj,
{
eo_obj = efl_constructor(efl_super(eo_obj, MY_CLASS));
pd->from.scale_x = 1.0;
pd->from.scale_y = 1.0;
pd->to.scale_x = 1.0;
pd->to.scale_y = 1.0;
pd->from = EINA_VECTOR2(1.0, 1.0);
pd->to = EINA_VECTOR2(1.0, 1.0);
pd->rel_pivot.pos = EINA_VECTOR2(0.5, 0.5);
pd->rel_pivot.obj = NULL;
pd->rel_pivot.cx = 0.5;
pd->rel_pivot.cy = 0.5;
pd->abs_pivot.cx = 0;
pd->abs_pivot.cy = 0;
pd->pos = EINA_POSITION2D(0, 0);
pd->use_rel_pivot = EINA_TRUE;

View File

@ -11,16 +11,11 @@ class @beta Efl.Canvas.Animation_Scale extends Efl.Canvas.Animation
get {
}
values {
from_scale_x: double; [[Scale factor along x axis when animation starts]]
from_scale_y: double; [[Scale factor along y axis when animation starts]]
to_scale_x: double; [[Scale factor along x axis when animation ends]]
to_scale_y: double; [[Scale factor along y axis when animation ends]]
from_scale : Eina.Vector2; [[Scale factor when animation starts]]
to_scale : Eina.Vector2; [[Scale factor when animation ends]]
pivot: Efl.Canvas.Object; [[Pivot object for the center point. If the pivot object is $NULL, then the object
is scaled on itself.]]
cx: double; [[X relative coordinate of the center point. The left end is 0.0 and the right end is 1.0
(the center is 0.5).]]
cy: double; [[Y relative coordinate of the center point. The top end is 0.0 and the bottom end is 1.0
(the center is 0.5).]]
pivot_pos : Eina.Vector2; [[Relative coordinates of the center point. 0.0,0.0 is upper left.]]
}
}
@property scale_absolute {
@ -30,12 +25,9 @@ class @beta Efl.Canvas.Animation_Scale extends Efl.Canvas.Animation
get {
}
values {
from_scale_x: double; [[Scale factor along x axis when animation starts]]
from_scale_y: double; [[Scale factor along y axis when animation starts]]
to_scale_x: double; [[Scale factor along x axis when animation ends]]
to_scale_y: double; [[Scale factor along y axis when animation ends]]
cx: int; [[X absolute coordinate of the center point.]]
cy: int; [[Y absolute coordinate of the center point.]]
from_scale : Eina.Vector2; [[Scale factor when animation starts]]
to_scale : Eina.Vector2; [[Scale factor when animation ends]]
pos : Eina.Position2D; [[Absolut coordinates in canvas space]]
}
}
}

View File

@ -7,28 +7,18 @@
#define EFL_ANIMATION_SCALE_DATA_GET(o, pd) \
Efl_Canvas_Animation_Scale_Data *pd = efl_data_scope_get(o, EFL_CANVAS_ANIMATION_SCALE_CLASS)
typedef struct _Efl_Canvas_Animation_Scale_Property
{
double scale_x, scale_y;
} Efl_Canvas_Animation_Scale_Property;
typedef struct _Efl_Canvas_Animation_Scale_Absolute_Pivot
{
Evas_Coord cx, cy;
} Efl_Canvas_Animation_Scale_Absolute_Pivot;
typedef struct _Efl_Canvas_Animation_Scale_Relative_Pivot
{
Efl_Canvas_Object *obj;
double cx, cy;
Eina_Vector2 pos;
} Efl_Canvas_Animation_Scale_Relative_Pivot;
typedef struct _Efl_Canvas_Animation_Scale_Data
{
Efl_Canvas_Animation_Scale_Property from;
Efl_Canvas_Animation_Scale_Property to;
Eina_Vector2 from;
Eina_Vector2 to;
Efl_Canvas_Animation_Scale_Absolute_Pivot abs_pivot;
Eina_Position2D pos;
Efl_Canvas_Animation_Scale_Relative_Pivot rel_pivot;
Eina_Bool use_rel_pivot;