diff options
author | Jaehyun Cho <jae_hyun.cho@samsung.com> | 2017-06-09 15:41:58 +0900 |
---|---|---|
committer | Jaehyun Cho <jae_hyun.cho@samsung.com> | 2017-06-30 17:28:35 +0900 |
commit | 7c4dee9a30ce99c0be0795f55612a6f71d7d8da1 (patch) | |
tree | 01991f2400201c651f4cecff186b813c70a2b46c | |
parent | cf35a8245c7dceb507ba6a89e2475122a52f1739 (diff) | |
download | efl-7c4dee9a30ce99c0be0795f55612a6f71d7d8da1.tar.gz |
efl_animation: Code refactorying scale animation
-rw-r--r-- | src/lib/evas/canvas/efl_animation_instance.c | 13 | ||||
-rw-r--r-- | src/lib/evas/canvas/efl_animation_instance_scale.c | 282 | ||||
-rw-r--r-- | src/lib/evas/canvas/efl_animation_instance_scale.eo | 39 | ||||
-rw-r--r-- | src/lib/evas/canvas/efl_animation_scale.c | 244 | ||||
-rw-r--r-- | src/lib/evas/canvas/efl_animation_scale.eo | 39 |
5 files changed, 368 insertions, 249 deletions
diff --git a/src/lib/evas/canvas/efl_animation_instance.c b/src/lib/evas/canvas/efl_animation_instance.c index ca3c1a90c7..dd5a106afd 100644 --- a/src/lib/evas/canvas/efl_animation_instance.c +++ b/src/lib/evas/canvas/efl_animation_instance.c @@ -25,10 +25,6 @@ typedef struct _Target_State { int r, g, b, a; - - Evas_Map *map; - - Eina_Bool map_enable : 1; } Target_State; struct _Evas_Object_Animation_Instance_Data @@ -150,12 +146,6 @@ _target_state_save(Eo *target, Target_State *target_state) target_state->g = g; target_state->b = b; target_state->a = a; - - if (target_state->map) - evas_map_free(target_state->map); - - target_state->map = evas_map_dup(evas_object_map_get(target)); - target_state->map_enable = evas_object_map_enable_get(target); } static void @@ -171,9 +161,6 @@ _target_state_restore(Eo *target, Target_State *target_state) evas_object_color_set(target, r, g, b, a); - evas_object_map_set(target, target_state->map); - evas_object_map_enable_set(target, target_state->map_enable); - if (efl_gfx_map_has(target)) efl_gfx_map_reset(target); } diff --git a/src/lib/evas/canvas/efl_animation_instance_scale.c b/src/lib/evas/canvas/efl_animation_instance_scale.c index 05cf0de128..c758f7e344 100644 --- a/src/lib/evas/canvas/efl_animation_instance_scale.c +++ b/src/lib/evas/canvas/efl_animation_instance_scale.c @@ -23,151 +23,199 @@ typedef struct _Evas_Object_Animation_Instance_Scale_Property { - double scale_x, scale_y, scale_z; + double scale_x, scale_y; } Evas_Object_Animation_Instance_Scale_Property; +typedef struct _Evas_Object_Animation_Instance_Scale_Absolute_Pivot +{ + Evas_Coord cx, cy; +} Evas_Object_Animation_Instance_Scale_Absolute_Pivot; + +typedef struct _Evas_Object_Animation_Instance_Scale_Relative_Pivot +{ + Efl_Canvas_Object *obj; + double cx, cy; +} Evas_Object_Animation_Instance_Scale_Relative_Pivot; + struct _Evas_Object_Animation_Instance_Scale_Data { Evas_Object_Animation_Instance_Scale_Property from; Evas_Object_Animation_Instance_Scale_Property to; - Evas_Map *map; + Evas_Object_Animation_Instance_Scale_Absolute_Pivot abs_pivot; + Evas_Object_Animation_Instance_Scale_Relative_Pivot rel_pivot; + + Eina_Bool use_rel_pivot; }; EOLIAN static void -_efl_animation_instance_scale_scale_set(Eo *eo_obj, Evas_Object_Animation_Instance_Scale_Data *pd, double from_scale, double to_scale) +_efl_animation_instance_scale_scale_set(Eo *eo_obj, Evas_Object_Animation_Instance_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_ANIMATION_INSTANCE_SCALE_CHECK_OR_RETURN(eo_obj); - pd->from.scale_x = from_scale; - pd->from.scale_y = from_scale; - pd->from.scale_z = from_scale; + pd->from.scale_x = from_scale_x; + pd->from.scale_y = from_scale_y; - pd->to.scale_x = to_scale; - pd->to.scale_y = to_scale; - pd->to.scale_z = to_scale; -} - -EOLIAN static void -_efl_animation_instance_scale_scale_get(Eo *eo_obj, Evas_Object_Animation_Instance_Scale_Data *pd, double *from_scale, double *to_scale) -{ - EFL_ANIMATION_INSTANCE_SCALE_CHECK_OR_RETURN(eo_obj); + pd->to.scale_x = to_scale_x; + pd->to.scale_y = to_scale_y; - if (from_scale) - *from_scale = pd->from.scale_x; + pd->rel_pivot.obj = pivot; + pd->rel_pivot.cx = cx; + pd->rel_pivot.cy = cy; - if (to_scale) - *to_scale = pd->to.scale_x; -} + //Update absolute pivot based on relative pivot + Evas_Coord x = 0; + Evas_Coord y = 0; + Evas_Coord w = 0; + Evas_Coord h = 0; -EOLIAN static void -_efl_animation_instance_scale_scale_x_set(Eo *eo_obj, Evas_Object_Animation_Instance_Scale_Data *pd, double from_x, double to_x) -{ - EFL_ANIMATION_INSTANCE_SCALE_CHECK_OR_RETURN(eo_obj); + if (pivot) + evas_object_geometry_get(pivot, &x, &y, &w, &h); + else + { + Eo *target = efl_animation_instance_target_get(eo_obj); + if (target) + evas_object_geometry_get(target, &x, &y, &w, &h); + } - pd->from.scale_x = from_x; + pd->abs_pivot.cx = x + (w * cx); + pd->abs_pivot.cy = y + (h * cy); - pd->to.scale_x = to_x; + pd->use_rel_pivot = EINA_TRUE; } EOLIAN static void -_efl_animation_instance_scale_scale_x_get(Eo *eo_obj, Evas_Object_Animation_Instance_Scale_Data *pd, double *from_x, double *to_x) +_efl_animation_instance_scale_scale_get(Eo *eo_obj, Evas_Object_Animation_Instance_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_ANIMATION_INSTANCE_SCALE_CHECK_OR_RETURN(eo_obj); - if (from_x) - *from_x = pd->from.scale_x; + //Update relative pivot based on absolute pivot + if (!pd->use_rel_pivot) + { + Evas_Coord x = 0; + Evas_Coord y = 0; + Evas_Coord w = 0; + Evas_Coord h = 0; + + Eo *target = efl_animation_instance_target_get(eo_obj); + if (target) + evas_object_geometry_get(target, &x, &y, &w, &h); + + if (w != 0) + pd->rel_pivot.cx = (double)(pd->abs_pivot.cx - x) / w; + else + pd->rel_pivot.cx = 0.0; + + if (h != 0) + pd->rel_pivot.cy = (double)(pd->abs_pivot.cy - y) / h; + else + pd->rel_pivot.cy = 0.0; + } - if (to_x) - *to_x = pd->to.scale_x; -} + if (from_scale_x) + *from_scale_x = pd->from.scale_x; -EOLIAN static void -_efl_animation_instance_scale_scale_y_set(Eo *eo_obj, Evas_Object_Animation_Instance_Scale_Data *pd, double from_y, double to_y) -{ - EFL_ANIMATION_INSTANCE_SCALE_CHECK_OR_RETURN(eo_obj); + if (from_scale_y) + *from_scale_y = pd->from.scale_y; - pd->from.scale_y = from_y; + if (to_scale_x) + *to_scale_x = pd->to.scale_x; - pd->to.scale_y = to_y; -} + if (to_scale_y) + *to_scale_y = pd->to.scale_y; -EOLIAN static void -_efl_animation_instance_scale_scale_y_get(Eo *eo_obj, Evas_Object_Animation_Instance_Scale_Data *pd, double *from_y, double *to_y) -{ - EFL_ANIMATION_INSTANCE_SCALE_CHECK_OR_RETURN(eo_obj); + if (pivot) + *pivot = pd->rel_pivot.obj; - if (from_y) - *from_y = pd->from.scale_y; + if (cx) + *cx = pd->rel_pivot.cx; - if (to_y) - *to_y = pd->to.scale_y; + if (cy) + *cy = pd->rel_pivot.cy; } EOLIAN static void -_efl_animation_instance_scale_scale_z_set(Eo *eo_obj, Evas_Object_Animation_Instance_Scale_Data *pd, double from_z, double to_z) +_efl_animation_instance_scale_scale_absolute_set(Eo *eo_obj, Evas_Object_Animation_Instance_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_ANIMATION_INSTANCE_SCALE_CHECK_OR_RETURN(eo_obj); - pd->from.scale_z = from_z; + pd->from.scale_x = from_scale_x; + pd->from.scale_y = from_scale_y; - pd->to.scale_z = to_z; -} + pd->to.scale_x = to_scale_x; + pd->to.scale_y = to_scale_y; -EOLIAN static void -_efl_animation_instance_scale_scale_z_get(Eo *eo_obj, Evas_Object_Animation_Instance_Scale_Data *pd, double *from_z, double *to_z) -{ - EFL_ANIMATION_INSTANCE_SCALE_CHECK_OR_RETURN(eo_obj); + pd->abs_pivot.cx = cx; + pd->abs_pivot.cy = cy; - if (from_z) - *from_z = pd->from.scale_z; + //Update relative pivot based on absolute pivot + Evas_Coord x = 0; + Evas_Coord y = 0; + Evas_Coord w = 0; + Evas_Coord h = 0; - if (to_z) - *to_z = pd->to.scale_z; -} + Eo *target = efl_animation_instance_target_get(eo_obj); + if (target) + evas_object_geometry_get(target, &x, &y, &w, &h); -static Evas_Map * -_map_dup(Eo *target) -{ - if (!target) return NULL; + pd->rel_pivot.obj = NULL; - Evas_Map *map = NULL; + if (w != 0) + pd->rel_pivot.cx = (double)(cx - x) / w; + else + pd->rel_pivot.cx = 0.0; - if (evas_object_map_enable_get(target) && evas_object_map_get(target)) - { - map = evas_map_dup(evas_object_map_get(target)); - if (!map) return NULL; - } + if (h != 0) + pd->rel_pivot.cy = (double)(cy - y) / h; else - { - map = evas_map_new(4); - if (!map) return NULL; - evas_map_util_points_populate_from_object_full(map, target, 0); - } + pd->rel_pivot.cy = 0.0; - return map; + pd->use_rel_pivot = EINA_FALSE; } -static void -_map_init(Evas_Map *map) +EOLIAN static void +_efl_animation_instance_scale_scale_absolute_get(Eo *eo_obj, Evas_Object_Animation_Instance_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) { - evas_map_util_object_move_sync_set(map, EINA_TRUE); + EFL_ANIMATION_INSTANCE_SCALE_CHECK_OR_RETURN(eo_obj); - //FIXME: Need to consider smooth of map -} + //Update absolute pivot based on relative pivot + if (pd->use_rel_pivot) + { + Evas_Coord x = 0; + Evas_Coord y = 0; + Evas_Coord w = 0; + Evas_Coord h = 0; + + if (pd->rel_pivot.obj) + evas_object_geometry_get(pd->rel_pivot.obj, &x, &y, &w, &h); + else + { + Eo *target = efl_animation_instance_target_get(eo_obj); + if (target) + evas_object_geometry_get(target, &x, &y, &w, &h); + } + + pd->abs_pivot.cx = x + (w * pd->rel_pivot.cx); + pd->abs_pivot.cy = y + (h * pd->rel_pivot.cy); + } -static void -_pre_start_cb(void *data EINA_UNUSED, const Efl_Event *event) -{ - EFL_ANIMATION_INSTANCE_SCALE_DATA_GET(event->object, pd); + if (from_scale_x) + *from_scale_x = pd->from.scale_x; - Eo *target = efl_animation_instance_target_get(event->object); - if (!target) return; + if (from_scale_y) + *from_scale_y = pd->from.scale_y; - pd->map = _map_dup(target); - if (!pd->map) return; + if (to_scale_x) + *to_scale_x = pd->to.scale_x; - _map_init(pd->map); + 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; } static void @@ -187,34 +235,22 @@ _pre_animate_cb(void *data EINA_UNUSED, const Efl_Event *event) double scale_y = (pd->from.scale_y * (1.0 - progress)) + (pd->to.scale_y * progress); - if (!pd->map) - { - pd->map = _map_dup(target); - if (!pd->map) return; + if (efl_gfx_map_has(target)) + efl_gfx_map_reset(target); - _map_init(pd->map); + if (pd->use_rel_pivot) + { + efl_gfx_map_zoom(target, + scale_x, scale_y, + pd->rel_pivot.obj, + pd->rel_pivot.cx, pd->rel_pivot.cy); + } + else + { + efl_gfx_map_zoom_absolute(target, + scale_x, scale_y, + pd->abs_pivot.cx, pd->abs_pivot.cy); } - - Evas_Map *map = evas_map_dup(pd->map); - - Evas_Coord x, y, w, h; - evas_object_geometry_get(target, &x, &y, &w, &h); - - evas_map_util_zoom(map, scale_x, scale_y, x + (w / 2), y + (h / 2)); - - evas_object_map_set(target, map); - evas_object_map_enable_set(target, EINA_TRUE); - - evas_map_free(map); -} - -static void -_pre_end_cb(void *data EINA_UNUSED, const Efl_Event *event) -{ - EFL_ANIMATION_INSTANCE_SCALE_DATA_GET(event->object, pd); - - evas_map_free(pd->map); - pd->map = NULL; } EOLIAN static Efl_Object * @@ -224,17 +260,19 @@ _efl_animation_instance_scale_efl_object_constructor(Eo *eo_obj, Evas_Object_Ani pd->from.scale_x = 1.0; pd->from.scale_y = 1.0; - pd->from.scale_z = 1.0; - //pre start event is supported within class only (protected event) - efl_event_callback_add(eo_obj, EFL_ANIMATION_INSTANCE_EVENT_PRE_START, _pre_start_cb, NULL); + 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->use_rel_pivot = EINA_TRUE; //pre animate event is supported within class only (protected event) efl_event_callback_add(eo_obj, EFL_ANIMATION_INSTANCE_EVENT_PRE_ANIMATE, _pre_animate_cb, NULL); - //pre end event is supported within class only (protected event) - efl_event_callback_add(eo_obj, EFL_ANIMATION_INSTANCE_EVENT_PRE_END, _pre_end_cb, NULL); - return eo_obj; } diff --git a/src/lib/evas/canvas/efl_animation_instance_scale.eo b/src/lib/evas/canvas/efl_animation_instance_scale.eo index 1e9e0213a9..cda237fd3e 100644 --- a/src/lib/evas/canvas/efl_animation_instance_scale.eo +++ b/src/lib/evas/canvas/efl_animation_instance_scale.eo @@ -12,38 +12,27 @@ class Efl.Animation.Instance.Scale (Efl.Animation.Instance) get { } values { - from_scale: double; [[Scale factor when animation starts]] - to_scale: double; [[Scale factor when animation ends]] + 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]] + 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).]] } } - @property scale_x @protected /* @internal */ { + @property scale_absolute @protected /* @internal */ { set { } get { } values { - from_x: double; [[Scale factor along x axis when animation starts]] - to_x: double; [[Scale factor along x axis when animation ends]] - } - } - @property scale_y @protected /* @internal */ { - set { - } - get { - } - values { - from_y: double; [[Scale factor along y axis when animation starts]] - to_y: double; [[Scale factor along y axis when animation ends]] - } - } - @property scale_z @protected /* @internal */ { - set { - } - get { - } - values { - from_z: double; [[Scale factor along z axis when animation starts]] - to_z: double; [[Scale factor along z axis when animation ends]] + 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.]] } } } diff --git a/src/lib/evas/canvas/efl_animation_scale.c b/src/lib/evas/canvas/efl_animation_scale.c index d805169cf7..16c5c08dcc 100644 --- a/src/lib/evas/canvas/efl_animation_scale.c +++ b/src/lib/evas/canvas/efl_animation_scale.c @@ -23,105 +23,199 @@ typedef struct _Evas_Object_Animation_Scale_Property { - double scale_x, scale_y, scale_z; + double scale_x, scale_y; } Evas_Object_Animation_Scale_Property; +typedef struct _Evas_Object_Animation_Scale_Absolute_Pivot +{ + Evas_Coord cx, cy; +} Evas_Object_Animation_Scale_Absolute_Pivot; + +typedef struct _Evas_Object_Animation_Scale_Relative_Pivot +{ + Efl_Canvas_Object *obj; + double cx, cy; +} Evas_Object_Animation_Scale_Relative_Pivot; + struct _Evas_Object_Animation_Scale_Data { Evas_Object_Animation_Scale_Property from; Evas_Object_Animation_Scale_Property to; + + Evas_Object_Animation_Scale_Absolute_Pivot abs_pivot; + Evas_Object_Animation_Scale_Relative_Pivot rel_pivot; + + Eina_Bool use_rel_pivot; }; EOLIAN static void -_efl_animation_scale_scale_set(Eo *eo_obj, Evas_Object_Animation_Scale_Data *pd, double from_scale, double to_scale) +_efl_animation_scale_scale_set(Eo *eo_obj, Evas_Object_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_ANIMATION_SCALE_CHECK_OR_RETURN(eo_obj); - pd->from.scale_x = from_scale; - pd->from.scale_y = from_scale; - pd->from.scale_z = from_scale; + pd->from.scale_x = from_scale_x; + pd->from.scale_y = from_scale_y; - pd->to.scale_x = to_scale; - pd->to.scale_y = to_scale; - pd->to.scale_z = to_scale; -} + pd->to.scale_x = to_scale_x; + pd->to.scale_y = to_scale_y; -EOLIAN static void -_efl_animation_scale_scale_get(Eo *eo_obj, Evas_Object_Animation_Scale_Data *pd, double *from_scale, double *to_scale) -{ - EFL_ANIMATION_SCALE_CHECK_OR_RETURN(eo_obj); + pd->rel_pivot.obj = pivot; + pd->rel_pivot.cx = cx; + pd->rel_pivot.cy = cy; + + //Update absolute pivot based on relative pivot + Evas_Coord x = 0; + Evas_Coord y = 0; + Evas_Coord w = 0; + Evas_Coord h = 0; + + if (pivot) + evas_object_geometry_get(pivot, &x, &y, &w, &h); + else + { + Eo *target = efl_animation_target_get(eo_obj); + if (target) + evas_object_geometry_get(target, &x, &y, &w, &h); + } - if (from_scale) - *from_scale = pd->from.scale_x; + pd->abs_pivot.cx = x + (w * cx); + pd->abs_pivot.cy = y + (h * cy); - if (to_scale) - *to_scale = pd->to.scale_x; + pd->use_rel_pivot = EINA_TRUE; } EOLIAN static void -_efl_animation_scale_scale_x_set(Eo *eo_obj, Evas_Object_Animation_Scale_Data *pd, double from_x, double to_x) +_efl_animation_scale_scale_get(Eo *eo_obj, Evas_Object_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_ANIMATION_SCALE_CHECK_OR_RETURN(eo_obj); - pd->from.scale_x = from_x; + //Update relative pivot based on absolute pivot + if (!pd->use_rel_pivot) + { + Evas_Coord x = 0; + Evas_Coord y = 0; + Evas_Coord w = 0; + Evas_Coord h = 0; - pd->to.scale_x = to_x; -} + Eo *target = efl_animation_target_get(eo_obj); + if (target) + evas_object_geometry_get(target, &x, &y, &w, &h); -EOLIAN static void -_efl_animation_scale_scale_x_get(Eo *eo_obj, Evas_Object_Animation_Scale_Data *pd, double *from_x, double *to_x) -{ - EFL_ANIMATION_SCALE_CHECK_OR_RETURN(eo_obj); + if (w != 0) + pd->rel_pivot.cx = (double)(pd->abs_pivot.cx - x) / w; + else + pd->rel_pivot.cx = 0.0; - if (from_x) - *from_x = pd->from.scale_x; + if (h != 0) + pd->rel_pivot.cy = (double)(pd->abs_pivot.cy - y) / h; + else + pd->rel_pivot.cy = 0.0; + } - if (to_x) - *to_x = pd->to.scale_x; -} + if (from_scale_x) + *from_scale_x = pd->from.scale_x; -EOLIAN static void -_efl_animation_scale_scale_y_set(Eo *eo_obj, Evas_Object_Animation_Scale_Data *pd, double from_y, double to_y) -{ - EFL_ANIMATION_SCALE_CHECK_OR_RETURN(eo_obj); + if (from_scale_y) + *from_scale_y = pd->from.scale_y; - pd->from.scale_y = from_y; + if (to_scale_x) + *to_scale_x = pd->to.scale_x; - pd->to.scale_y = to_y; -} + if (to_scale_y) + *to_scale_y = pd->to.scale_y; -EOLIAN static void -_efl_animation_scale_scale_y_get(Eo *eo_obj, Evas_Object_Animation_Scale_Data *pd, double *from_y, double *to_y) -{ - EFL_ANIMATION_SCALE_CHECK_OR_RETURN(eo_obj); + if (pivot) + *pivot = pd->rel_pivot.obj; - if (from_y) - *from_y = pd->from.scale_y; + if (cx) + *cx = pd->rel_pivot.cx; - if (to_y) - *to_y = pd->to.scale_y; + if (cy) + *cy = pd->rel_pivot.cy; } EOLIAN static void -_efl_animation_scale_scale_z_set(Eo *eo_obj, Evas_Object_Animation_Scale_Data *pd, double from_z, double to_z) +_efl_animation_scale_scale_absolute_set(Eo *eo_obj, Evas_Object_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_ANIMATION_SCALE_CHECK_OR_RETURN(eo_obj); - pd->from.scale_z = from_z; + pd->from.scale_x = from_scale_x; + pd->from.scale_y = from_scale_y; - pd->to.scale_z = to_z; + pd->to.scale_x = to_scale_x; + pd->to.scale_y = to_scale_y; + + pd->abs_pivot.cx = cx; + pd->abs_pivot.cy = cy; + + //Update relative pivot based on absolute pivot + Evas_Coord x = 0; + Evas_Coord y = 0; + Evas_Coord w = 0; + Evas_Coord h = 0; + + Eo *target = efl_animation_target_get(eo_obj); + if (target) + evas_object_geometry_get(target, &x, &y, &w, &h); + + pd->rel_pivot.obj = NULL; + + if (w != 0) + pd->rel_pivot.cx = (double)(cx - x) / w; + else + pd->rel_pivot.cx = 0.0; + + if (h != 0) + pd->rel_pivot.cy = (double)(cy - y) / h; + else + pd->rel_pivot.cy = 0.0; + + pd->use_rel_pivot = EINA_FALSE; } EOLIAN static void -_efl_animation_scale_scale_z_get(Eo *eo_obj, Evas_Object_Animation_Scale_Data *pd, double *from_z, double *to_z) +_efl_animation_scale_scale_absolute_get(Eo *eo_obj, Evas_Object_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_ANIMATION_SCALE_CHECK_OR_RETURN(eo_obj); - if (from_z) - *from_z = pd->from.scale_z; + //Update absolute pivot based on relative pivot + if (pd->use_rel_pivot) + { + Evas_Coord x = 0; + Evas_Coord y = 0; + Evas_Coord w = 0; + Evas_Coord h = 0; + + if (pd->rel_pivot.obj) + evas_object_geometry_get(pd->rel_pivot.obj, &x, &y, &w, &h); + else + { + Eo *target = efl_animation_target_get(eo_obj); + if (target) + evas_object_geometry_get(target, &x, &y, &w, &h); + } + + pd->abs_pivot.cx = x + (w * pd->rel_pivot.cx); + pd->abs_pivot.cy = y + (h * pd->rel_pivot.cy); + } + + if (from_scale_x) + *from_scale_x = pd->from.scale_x; + + if (from_scale_y) + *from_scale_y = pd->from.scale_y; - if (to_z) - *to_z = pd->to.scale_z; + 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; } EOLIAN static Efl_Animation * @@ -144,11 +238,18 @@ _efl_animation_scale_efl_animation_dup(Eo *eo_obj, Evas_Object_Animation_Scale_D new_pd->from.scale_x = pd->from.scale_x; new_pd->from.scale_y = pd->from.scale_y; - new_pd->from.scale_z = pd->from.scale_z; new_pd->to.scale_x = pd->to.scale_x; new_pd->to.scale_y = pd->to.scale_y; - new_pd->to.scale_z = pd->to.scale_z; + + new_pd->rel_pivot.obj = pd->rel_pivot.obj; + new_pd->rel_pivot.cx = pd->rel_pivot.cx; + new_pd->rel_pivot.cy = pd->rel_pivot.cy; + + new_pd->abs_pivot.cx = pd->rel_pivot.cx; + new_pd->abs_pivot.cy = pd->rel_pivot.cy; + + new_pd->use_rel_pivot = pd->use_rel_pivot; return animation; } @@ -170,14 +271,21 @@ _efl_animation_scale_efl_animation_instance_create(Eo *eo_obj, Evas_Object_Anima double duration = efl_animation_duration_get(eo_obj); efl_animation_instance_duration_set(instance, duration); - efl_animation_instance_scale_x_set(instance, - pd->from.scale_x, pd->to.scale_x); - - efl_animation_instance_scale_y_set(instance, - pd->from.scale_y, pd->to.scale_y); - - efl_animation_instance_scale_z_set(instance, - pd->from.scale_z, pd->to.scale_z); + if (pd->use_rel_pivot) + { + efl_animation_instance_scale_set(instance, + pd->from.scale_x, pd->from.scale_y, + pd->to.scale_x, pd->to.scale_y, + pd->rel_pivot.obj, + pd->rel_pivot.cx, pd->rel_pivot.cy); + } + else + { + efl_animation_instance_scale_absolute_set(instance, + pd->from.scale_x, pd->from.scale_y, + pd->to.scale_x, pd->to.scale_y, + pd->abs_pivot.cx, pd->abs_pivot.cy); + } return instance; } @@ -189,7 +297,15 @@ _efl_animation_scale_efl_object_constructor(Eo *eo_obj, Evas_Object_Animation_Sc pd->from.scale_x = 1.0; pd->from.scale_y = 1.0; - pd->from.scale_z = 1.0; + + 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->use_rel_pivot = EINA_TRUE; return eo_obj; } diff --git a/src/lib/evas/canvas/efl_animation_scale.eo b/src/lib/evas/canvas/efl_animation_scale.eo index 5b6b594f56..0a2a5c58a8 100644 --- a/src/lib/evas/canvas/efl_animation_scale.eo +++ b/src/lib/evas/canvas/efl_animation_scale.eo @@ -12,38 +12,27 @@ class Efl.Animation.Scale (Efl.Animation) get { } values { - from_scale: double; [[Scale factor when animation starts]] - to_scale: double; [[Scale factor when animation ends]] + 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]] + 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).]] } } - @property scale_x { + @property scale_absolute { set { } get { } values { - from_x: double; [[Scale factor along x axis when animation starts]] - to_x: double; [[Scale factor along x axis when animation ends]] - } - } - @property scale_y { - set { - } - get { - } - values { - from_y: double; [[Scale factor along y axis when animation starts]] - to_y: double; [[Scale factor along y axis when animation ends]] - } - } - @property scale_z { - set { - } - get { - } - values { - from_z: double; [[Scale factor along z axis when animation starts]] - to_z: double; [[Scale factor along z axis when animation ends]] + 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.]] } } } |