From d98fd15b7a6a9b908deb01157545522c9c26266d Mon Sep 17 00:00:00 2001 From: Marcel Hollerbach Date: Wed, 30 Oct 2019 15:29:59 +0100 Subject: [PATCH] efl_canvas_animation_rotate: adjust API Summary: in task T8288 we concluded that a few APIs need to be adjusted in order to stabelize animation classes at some point. This also adds a new macro to eina in order to create EINA_VECTOR2 values more easily. ref T8288 Reviewers: Jaehyun_Cho, segfaultxavi, zmike Reviewed By: zmike Subscribers: cedric, #reviewers, #committers Tags: #efl Maniphest Tasks: T8288 Differential Revision: https://phab.enlightenment.org/D10350 --- src/bin/elementary/test_efl_anim_group_parallel.c | 4 +- .../elementary/test_efl_anim_group_sequential.c | 4 +- src/bin/elementary/test_efl_anim_rotate.c | 12 +++--- src/lib/eina/eina_vector.h | 1 + src/lib/evas/canvas/efl_canvas_animation_rotate.c | 44 ++++++++-------------- src/lib/evas/canvas/efl_canvas_animation_rotate.eo | 8 +--- .../canvas/efl_canvas_animation_rotate_private.h | 9 +---- 7 files changed, 31 insertions(+), 51 deletions(-) diff --git a/src/bin/elementary/test_efl_anim_group_parallel.c b/src/bin/elementary/test_efl_anim_group_parallel.c index 6283e22..ec4c3ea 100644 --- a/src/bin/elementary/test_efl_anim_group_parallel.c +++ b/src/bin/elementary/test_efl_anim_group_parallel.c @@ -90,7 +90,7 @@ test_efl_anim_group_parallel(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSE //Rotate from 45 to 0 degrees Animation Efl_Canvas_Animation *ccw_45_degrees_anim = efl_add(EFL_CANVAS_ANIMATION_ROTATE_CLASS, win); - efl_animation_rotate_set(ccw_45_degrees_anim, 45.0, 0.0, NULL, 0.5, 0.5); + efl_animation_rotate_set(ccw_45_degrees_anim, 45.0, 0.0, NULL, EINA_VECTOR2(0.5, 0.5)); //Scale Animation to zoom out Efl_Canvas_Animation *scale_half_anim = efl_add(EFL_CANVAS_ANIMATION_SCALE_CLASS, win); @@ -113,7 +113,7 @@ test_efl_anim_group_parallel(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSE //Rotate from 0 to 45 degrees Animation Efl_Canvas_Animation *cw_45_degrees_anim = efl_add(EFL_CANVAS_ANIMATION_ROTATE_CLASS, win); - efl_animation_rotate_set(cw_45_degrees_anim, 0.0, 45.0, NULL, 0.5, 0.5); + efl_animation_rotate_set(cw_45_degrees_anim, 0.0, 45.0, NULL, EINA_VECTOR2(0.5, 0.5)); //Scale Animation to zoom in Efl_Canvas_Animation *scale_double_anim = efl_add(EFL_CANVAS_ANIMATION_SCALE_CLASS, win); diff --git a/src/bin/elementary/test_efl_anim_group_sequential.c b/src/bin/elementary/test_efl_anim_group_sequential.c index 3488149..2d09354 100644 --- a/src/bin/elementary/test_efl_anim_group_sequential.c +++ b/src/bin/elementary/test_efl_anim_group_sequential.c @@ -86,7 +86,7 @@ test_efl_anim_group_sequential(void *data EINA_UNUSED, Evas_Object *obj EINA_UNU /* Animations to hide button */ //Rotate from 0 to 45 degrees Animation Efl_Canvas_Animation *cw_45_degrees_anim = efl_add(EFL_CANVAS_ANIMATION_ROTATE_CLASS, win); - efl_animation_rotate_set(cw_45_degrees_anim, 0.0, 45.0, NULL, 0.5, 0.5); + efl_animation_rotate_set(cw_45_degrees_anim, 0.0, 45.0, NULL, EINA_VECTOR2(0.5, 0.5)); //Scale Animation to zoom in Efl_Canvas_Animation *scale_double_anim = efl_add(EFL_CANVAS_ANIMATION_SCALE_CLASS, win); @@ -120,7 +120,7 @@ test_efl_anim_group_sequential(void *data EINA_UNUSED, Evas_Object *obj EINA_UNU //Rotate from 45 to 0 degrees Animation Efl_Canvas_Animation *ccw_45_degrees_anim = efl_add(EFL_CANVAS_ANIMATION_ROTATE_CLASS, win); - efl_animation_rotate_set(ccw_45_degrees_anim, 45.0, 0.0, NULL, 0.5, 0.5); + efl_animation_rotate_set(ccw_45_degrees_anim, 45.0, 0.0, NULL, EINA_VECTOR2(0.5, 0.5)); efl_animation_duration_set(ccw_45_degrees_anim, 1.0); //Show Sequential Group Animation diff --git a/src/bin/elementary/test_efl_anim_rotate.c b/src/bin/elementary/test_efl_anim_rotate.c index 10df8ca..ea8b94a 100644 --- a/src/bin/elementary/test_efl_anim_rotate.c +++ b/src/bin/elementary/test_efl_anim_rotate.c @@ -84,13 +84,13 @@ test_efl_anim_rotate(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void //Rotate from 0 to 45 degrees Animation Efl_Canvas_Animation *cw_45_degrees_anim = efl_add(EFL_CANVAS_ANIMATION_ROTATE_CLASS, win); - efl_animation_rotate_set(cw_45_degrees_anim, 0.0, 45.0,NULL, 0.5, 0.5); + efl_animation_rotate_set(cw_45_degrees_anim, 0.0, 45.0, NULL, EINA_VECTOR2(0.5, 0.5)); efl_animation_duration_set(cw_45_degrees_anim, 1.0); efl_animation_final_state_keep_set(cw_45_degrees_anim, EINA_TRUE); //Rotate from 45 to 0 degrees Animation Efl_Canvas_Animation *ccw_45_degrees_anim = efl_add(EFL_CANVAS_ANIMATION_ROTATE_CLASS, win); - efl_animation_rotate_set(ccw_45_degrees_anim, 45.0, 0.0, NULL, 0.5, 0.5); + efl_animation_rotate_set(ccw_45_degrees_anim, 45.0, 0.0, NULL, EINA_VECTOR2(0.5, 0.5)); efl_animation_duration_set(ccw_45_degrees_anim, 1.0); efl_animation_final_state_keep_set(ccw_45_degrees_anim, EINA_TRUE); @@ -151,13 +151,13 @@ test_efl_anim_rotate_relative(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUS //Rotate from 0 to 45 degrees Animation Efl_Canvas_Animation *cw_45_degrees_anim = efl_add(EFL_CANVAS_ANIMATION_ROTATE_CLASS, win); - efl_animation_rotate_set(cw_45_degrees_anim, 0.0, 45.0, pivot, 0.5, 0.5); + efl_animation_rotate_set(cw_45_degrees_anim, 0.0, 45.0, pivot, EINA_VECTOR2(0.5, 0.5)); efl_animation_duration_set(cw_45_degrees_anim, 1.0); efl_animation_final_state_keep_set(cw_45_degrees_anim, EINA_TRUE); //Rotate from 45 to 0 degrees Animation Efl_Canvas_Animation *ccw_45_degrees_anim = efl_add(EFL_CANVAS_ANIMATION_ROTATE_CLASS, win); - efl_animation_rotate_set(ccw_45_degrees_anim, 45.0, 0.0, pivot, 0.5, 0.5); + efl_animation_rotate_set(ccw_45_degrees_anim, 45.0, 0.0, pivot, EINA_VECTOR2(0.5, 0.5)); efl_animation_duration_set(ccw_45_degrees_anim, 1.0); efl_animation_final_state_keep_set(ccw_45_degrees_anim, EINA_TRUE); @@ -219,13 +219,13 @@ test_efl_anim_rotate_absolute(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUS //Rotate from 0 to 45 degrees Animation Efl_Canvas_Animation *cw_45_degrees_anim = efl_add(EFL_CANVAS_ANIMATION_ROTATE_CLASS, win); - efl_animation_rotate_absolute_set(cw_45_degrees_anim, 0.0, 45.0, 0, 0); + efl_animation_rotate_absolute_set(cw_45_degrees_anim, 0.0, 45.0, EINA_POSITION2D(0, 0)); efl_animation_duration_set(cw_45_degrees_anim, 1.0); efl_animation_final_state_keep_set(cw_45_degrees_anim, EINA_TRUE); //Rotate from 45 to 0 degrees Animation Efl_Canvas_Animation *ccw_45_degrees_anim = efl_add(EFL_CANVAS_ANIMATION_ROTATE_CLASS, win); - efl_animation_rotate_absolute_set(ccw_45_degrees_anim, 45.0, 0.0, 0, 0); + efl_animation_rotate_absolute_set(ccw_45_degrees_anim, 45.0, 0.0, EINA_POSITION2D(0, 0)); efl_animation_duration_set(ccw_45_degrees_anim, 1.0); efl_animation_final_state_keep_set(ccw_45_degrees_anim, EINA_TRUE); diff --git a/src/lib/eina/eina_vector.h b/src/lib/eina/eina_vector.h index fca2dcc..3c3d9e6 100644 --- a/src/lib/eina/eina_vector.h +++ b/src/lib/eina/eina_vector.h @@ -32,6 +32,7 @@ typedef struct _Eina_Vector2 Eina_Vector2; typedef struct _Eina_Vector3 Eina_Vector3; +#define EINA_VECTOR2(x, y) ((Eina_Vector2) {(x), (y)}) /** * @internal * @defgroup Eina_Vector2 Vectors in floating point diff --git a/src/lib/evas/canvas/efl_canvas_animation_rotate.c b/src/lib/evas/canvas/efl_canvas_animation_rotate.c index fe713de..ba07733 100644 --- a/src/lib/evas/canvas/efl_canvas_animation_rotate.c +++ b/src/lib/evas/canvas/efl_canvas_animation_rotate.c @@ -8,16 +8,14 @@ _efl_canvas_animation_rotate_rotate_set(Eo *eo_obj EINA_UNUSED, double from_degree, double to_degree, Efl_Canvas_Object *pivot, - double cx, - double cy) + Eina_Vector2 center_point) { pd->from.degree = from_degree; pd->to.degree = to_degree; //TODO: check whether ref for pivot should be added. pd->rel_pivot.obj = pivot; - pd->rel_pivot.cx = cx; - pd->rel_pivot.cy = cy; + pd->rel_pivot.pos = center_point; pd->use_rel_pivot = EINA_TRUE; } @@ -27,8 +25,7 @@ _efl_canvas_animation_rotate_rotate_get(const Eo *eo_obj EINA_UNUSED, double *from_degree, double *to_degree, Efl_Canvas_Object **pivot, - double *cx, - double *cy) + Eina_Vector2 *center_point) { if (!pd->use_rel_pivot) { @@ -45,11 +42,8 @@ _efl_canvas_animation_rotate_rotate_get(const Eo *eo_obj EINA_UNUSED, if (pivot) *pivot = pd->rel_pivot.obj; - if (cx) - *cx = pd->rel_pivot.cx; - - if (cy) - *cy = pd->rel_pivot.cy; + if (center_point) + *center_point = pd->rel_pivot.pos; } EOLIAN static void @@ -57,14 +51,12 @@ _efl_canvas_animation_rotate_rotate_absolute_set(Eo *eo_obj EINA_UNUSED, Efl_Canvas_Animation_Rotate_Data *pd, double from_degree, double to_degree, - Evas_Coord cx, - Evas_Coord cy) + Eina_Position2D abs) { pd->from.degree = from_degree; pd->to.degree = to_degree; - pd->abs_pivot.cx = cx; - pd->abs_pivot.cy = cy; + pd->abs_pivot = abs; pd->use_rel_pivot = EINA_FALSE; } @@ -73,8 +65,7 @@ _efl_canvas_animation_rotate_rotate_absolute_get(const Eo *eo_obj EINA_UNUSED, Efl_Canvas_Animation_Rotate_Data *pd, double *from_degree, double *to_degree, - Evas_Coord *cx, - Evas_Coord *cy) + Eina_Position2D *abs) { if (pd->use_rel_pivot) { @@ -88,11 +79,8 @@ _efl_canvas_animation_rotate_rotate_absolute_get(const Eo *eo_obj EINA_UNUSED, if (to_degree) *to_degree = pd->to.degree; - if (cx) - *cx = pd->abs_pivot.cx; - - if (cy) - *cy = pd->abs_pivot.cy; + if (abs) + *abs = pd->abs_pivot; } EOLIAN static double @@ -113,13 +101,13 @@ _efl_canvas_animation_rotate_efl_canvas_animation_animation_apply(Eo *eo_obj, efl_gfx_mapping_rotate(target, new_degree, (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_rotate_absolute(target, new_degree, - pd->abs_pivot.cx, pd->abs_pivot.cy); + pd->abs_pivot.x, pd->abs_pivot.y); } return progress; @@ -135,11 +123,11 @@ _efl_canvas_animation_rotate_efl_object_constructor(Eo *eo_obj, pd->to.degree = 0.0; pd->rel_pivot.obj = NULL; - pd->rel_pivot.cx = 0.5; - pd->rel_pivot.cy = 0.5; + pd->rel_pivot.pos.x = 0.5; + pd->rel_pivot.pos.y = 0.5; - pd->abs_pivot.cx = 0; - pd->abs_pivot.cy = 0; + pd->abs_pivot.x = 0; + pd->abs_pivot.y = 0; pd->use_rel_pivot = EINA_TRUE; diff --git a/src/lib/evas/canvas/efl_canvas_animation_rotate.eo b/src/lib/evas/canvas/efl_canvas_animation_rotate.eo index 169ddd3..3c1d8af 100644 --- a/src/lib/evas/canvas/efl_canvas_animation_rotate.eo +++ b/src/lib/evas/canvas/efl_canvas_animation_rotate.eo @@ -15,10 +15,7 @@ class @beta Efl.Canvas.Animation_Rotate extends Efl.Canvas.Animation to_degree: double; [[Rotation degree when animation ends]] pivot: Efl.Canvas.Object; [[Pivot object for the center point. If the pivot object is $NULL, then the object is rotated 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).]] + center_point : Eina.Vector2; [[Relative coordinate of the center point.]] } } @property rotate_absolute { @@ -30,8 +27,7 @@ class @beta Efl.Canvas.Animation_Rotate extends Efl.Canvas.Animation values { from_degree: double; [[Rotation degree when animation starts]] to_degree: double; [[Rotation degree when animation ends]] - cx: int; [[X absolute coordinate of the center point.]] - cy: int; [[Y absolute coordinate of the center point.]] + center_pointer : Eina.Position2D; [[absolute coordinate of the center point.]] } } } diff --git a/src/lib/evas/canvas/efl_canvas_animation_rotate_private.h b/src/lib/evas/canvas/efl_canvas_animation_rotate_private.h index e50db39..64c5887 100644 --- a/src/lib/evas/canvas/efl_canvas_animation_rotate_private.h +++ b/src/lib/evas/canvas/efl_canvas_animation_rotate_private.h @@ -12,15 +12,10 @@ typedef struct _Efl_Canvas_Animation_Rotate_Property double degree; } Efl_Canvas_Animation_Rotate_Property; -typedef struct _Efl_Canvas_Animation_Rotate_Absolute_Pivot -{ - Evas_Coord cx, cy; -} Efl_Canvas_Animation_Rotate_Absolute_Pivot; - typedef struct _Efl_Canvas_Animation_Rotate_Relative_Pivot { Efl_Canvas_Object *obj; - double cx, cy; + Eina_Vector2 pos; } Efl_Canvas_Animation_Rotate_Relative_Pivot; typedef struct _Efl_Canvas_Animation_Rotate_Data @@ -28,7 +23,7 @@ typedef struct _Efl_Canvas_Animation_Rotate_Data Efl_Canvas_Animation_Rotate_Property from; Efl_Canvas_Animation_Rotate_Property to; - Efl_Canvas_Animation_Rotate_Absolute_Pivot abs_pivot; + Eina_Position2D abs_pivot; Efl_Canvas_Animation_Rotate_Relative_Pivot rel_pivot; Eina_Bool use_rel_pivot; -- 2.7.4