forked from enlightenment/efl
efl_animation: Add rotate animation
This commit is contained in:
parent
58dd0bebaa
commit
d4f96f9728
|
@ -46,6 +46,7 @@ evas_eolian_pub_files = \
|
|||
lib/evas/canvas/efl_gfx_map.eo \
|
||||
lib/evas/canvas/efl_animation.eo \
|
||||
lib/evas/canvas/efl_animation_alpha.eo \
|
||||
lib/evas/canvas/efl_animation_rotate.eo \
|
||||
lib/evas/canvas/efl_animation_object.eo \
|
||||
lib/evas/canvas/efl_animation_object_alpha.eo \
|
||||
$(NULL)
|
||||
|
@ -128,6 +129,7 @@ lib/evas/canvas/efl_canvas_surface.h \
|
|||
lib/evas/common3d/primitives/primitive_common.h \
|
||||
lib/evas/canvas/efl_animation_private.h \
|
||||
lib/evas/canvas/efl_animation_alpha_private.h \
|
||||
lib/evas/canvas/efl_animation_rotate_private.h \
|
||||
lib/evas/canvas/efl_animation_object_private.h \
|
||||
lib/evas/canvas/efl_animation_object_alpha_private.h
|
||||
|
||||
|
@ -217,6 +219,7 @@ lib/evas/canvas/efl_input_hold.c \
|
|||
lib/evas/canvas/efl_input_focus.c \
|
||||
lib/evas/canvas/efl_animation.c \
|
||||
lib/evas/canvas/efl_animation_alpha.c \
|
||||
lib/evas/canvas/efl_animation_rotate.c \
|
||||
lib/evas/canvas/efl_animation_object.c \
|
||||
lib/evas/canvas/efl_animation_object_alpha.c \
|
||||
$(NULL)
|
||||
|
|
|
@ -3344,6 +3344,13 @@ typedef Eo Efl_Animation_Alpha;
|
|||
|
||||
#endif
|
||||
|
||||
#ifndef _EFL_ANIMATION_ROTATE_EO_CLASS_TYPE
|
||||
#define _EFL_ANIMATION_ROTATE_EO_CLASS_TYPE
|
||||
|
||||
typedef Eo Efl_Animation_Rotate;
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef _EFL_ANIMATION_OBJECT_EO_CLASS_TYPE
|
||||
#define _EFL_ANIMATION_OBJECT_EO_CLASS_TYPE
|
||||
|
||||
|
|
|
@ -57,6 +57,7 @@
|
|||
|
||||
#include "canvas/efl_animation.eo.h"
|
||||
#include "canvas/efl_animation_alpha.eo.h"
|
||||
#include "canvas/efl_animation_rotate.eo.h"
|
||||
#include "canvas/efl_animation_object.eo.h"
|
||||
#include "canvas/efl_animation_object_alpha.eo.h"
|
||||
|
||||
|
|
|
@ -0,0 +1,198 @@
|
|||
#include "efl_animation_rotate_private.h"
|
||||
|
||||
EOLIAN static void
|
||||
_efl_animation_rotate_rotate_set(Eo *eo_obj,
|
||||
Efl_Animation_Rotate_Data *pd,
|
||||
double from_degree,
|
||||
double to_degree,
|
||||
Efl_Canvas_Object *pivot,
|
||||
double cx,
|
||||
double cy)
|
||||
{
|
||||
EFL_ANIMATION_ROTATE_CHECK_OR_RETURN(eo_obj);
|
||||
|
||||
pd->from.degree = from_degree;
|
||||
pd->to.degree = to_degree;
|
||||
|
||||
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
|
||||
{
|
||||
Efl_Canvas_Object *target = efl_animation_target_get(eo_obj);
|
||||
if (target)
|
||||
evas_object_geometry_get(target, &x, &y, &w, &h);
|
||||
}
|
||||
|
||||
pd->abs_pivot.cx = x + (w * cx);
|
||||
pd->abs_pivot.cy = y + (h * cy);
|
||||
|
||||
pd->use_rel_pivot = EINA_TRUE;
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_efl_animation_rotate_rotate_get(Eo *eo_obj,
|
||||
Efl_Animation_Rotate_Data *pd,
|
||||
double *from_degree,
|
||||
double *to_degree,
|
||||
Efl_Canvas_Object **pivot,
|
||||
double *cx,
|
||||
double *cy)
|
||||
{
|
||||
EFL_ANIMATION_ROTATE_CHECK_OR_RETURN(eo_obj);
|
||||
|
||||
//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;
|
||||
|
||||
Efl_Canvas_Object *target = efl_animation_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 (from_degree)
|
||||
*from_degree = pd->from.degree;
|
||||
|
||||
if (to_degree)
|
||||
*to_degree = pd->to.degree;
|
||||
|
||||
if (pivot)
|
||||
*pivot = pd->rel_pivot.obj;
|
||||
|
||||
if (cx)
|
||||
*cx = pd->rel_pivot.cx;
|
||||
|
||||
if (cy)
|
||||
*cy = pd->rel_pivot.cy;
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_efl_animation_rotate_rotate_absolute_set(Eo *eo_obj,
|
||||
Efl_Animation_Rotate_Data *pd,
|
||||
double from_degree,
|
||||
double to_degree,
|
||||
Evas_Coord cx,
|
||||
Evas_Coord cy)
|
||||
{
|
||||
EFL_ANIMATION_ROTATE_CHECK_OR_RETURN(eo_obj);
|
||||
|
||||
pd->from.degree = from_degree;
|
||||
pd->to.degree = to_degree;
|
||||
|
||||
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;
|
||||
|
||||
Efl_Canvas_Object *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_rotate_rotate_absolute_get(Eo *eo_obj,
|
||||
Efl_Animation_Rotate_Data *pd,
|
||||
double *from_degree,
|
||||
double *to_degree,
|
||||
Evas_Coord *cx,
|
||||
Evas_Coord *cy)
|
||||
{
|
||||
EFL_ANIMATION_ROTATE_CHECK_OR_RETURN(eo_obj);
|
||||
|
||||
//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;
|
||||
|
||||
if (pd->rel_pivot.obj)
|
||||
evas_object_geometry_get(pd->rel_pivot.obj, &x, &y, &w, &h);
|
||||
else
|
||||
{
|
||||
Efl_Canvas_Object *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_degree)
|
||||
*from_degree = pd->from.degree;
|
||||
|
||||
if (to_degree)
|
||||
*to_degree = pd->to.degree;
|
||||
|
||||
if (cx)
|
||||
*cx = pd->abs_pivot.cx;
|
||||
|
||||
if (cy)
|
||||
*cy = pd->abs_pivot.cy;
|
||||
}
|
||||
|
||||
EOLIAN static Efl_Object *
|
||||
_efl_animation_rotate_efl_object_constructor(Eo *eo_obj,
|
||||
Efl_Animation_Rotate_Data *pd)
|
||||
{
|
||||
eo_obj = efl_constructor(efl_super(eo_obj, MY_CLASS));
|
||||
|
||||
pd->from.degree = 0.0;
|
||||
pd->to.degree = 0.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;
|
||||
}
|
||||
|
||||
#include "efl_animation_rotate.eo.c"
|
|
@ -0,0 +1,37 @@
|
|||
import efl_animation_types;
|
||||
|
||||
class Efl.Animation.Rotate (Efl.Animation)
|
||||
{
|
||||
[[Efl rotate animation class]]
|
||||
data: Efl_Animation_Rotate_Data;
|
||||
methods {
|
||||
@property rotate {
|
||||
set {
|
||||
}
|
||||
get {
|
||||
}
|
||||
values {
|
||||
from_degree: double; [[Rotation degree when animation starts]]
|
||||
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).]]
|
||||
}
|
||||
}
|
||||
@property rotate_absolute {
|
||||
set {
|
||||
}
|
||||
get {
|
||||
}
|
||||
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.]]
|
||||
}
|
||||
}
|
||||
}
|
||||
implements {
|
||||
Efl.Object.constructor;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
#define EFL_ANIMATION_PROTECTED
|
||||
|
||||
#include "evas_common_private.h"
|
||||
|
||||
#define MY_CLASS EFL_ANIMATION_ROTATE_CLASS
|
||||
#define MY_CLASS_NAME efl_class_name_get(MY_CLASS)
|
||||
|
||||
#define EFL_ANIMATION_ROTATE_CHECK_OR_RETURN(anim, ...) \
|
||||
do { \
|
||||
if (!anim) { \
|
||||
CRI("Efl_Animation " # anim " is NULL!"); \
|
||||
return __VA_ARGS__; \
|
||||
} \
|
||||
if (efl_animation_is_deleted(anim)) { \
|
||||
ERR("Efl_Animation " # anim " has already been deleted!"); \
|
||||
return __VA_ARGS__; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define EFL_ANIMATION_ROTATE_DATA_GET(o, pd) \
|
||||
Efl_Animation_Rotate_Data *pd = efl_data_scope_get(o, EFL_ANIMATION_ROTATE_CLASS)
|
||||
|
||||
typedef struct _Efl_Animation_Rotate_Property
|
||||
{
|
||||
double degree;
|
||||
} Efl_Animation_Rotate_Property;
|
||||
|
||||
typedef struct _Efl_Animation_Rotate_Absolute_Pivot
|
||||
{
|
||||
Evas_Coord cx, cy;
|
||||
} Efl_Animation_Rotate_Absolute_Pivot;
|
||||
|
||||
typedef struct _Efl_Animation_Rotate_Relative_Pivot
|
||||
{
|
||||
Efl_Canvas_Object *obj;
|
||||
double cx, cy;
|
||||
} Efl_Animation_Rotate_Relative_Pivot;
|
||||
|
||||
typedef struct _Efl_Animation_Rotate_Data
|
||||
{
|
||||
Efl_Animation_Rotate_Property from;
|
||||
Efl_Animation_Rotate_Property to;
|
||||
|
||||
Efl_Animation_Rotate_Absolute_Pivot abs_pivot;
|
||||
Efl_Animation_Rotate_Relative_Pivot rel_pivot;
|
||||
|
||||
Eina_Bool use_rel_pivot;
|
||||
} Efl_Animation_Rotate_Data;
|
Loading…
Reference in New Issue