efl_animation: Add efl_animation

Efl.Animation is a class which contains basic properties of animation
for Efl.Canvas.Object.
This commit is contained in:
Jaehyun Cho 2017-08-24 20:45:52 +09:00
parent 72f1fbf4f1
commit 5038223b61
7 changed files with 201 additions and 2 deletions

View File

@ -44,6 +44,7 @@ evas_eolian_pub_files = \
lib/evas/canvas/efl_input_hold.eo \
lib/evas/canvas/efl_input_focus.eo \
lib/evas/canvas/efl_gfx_map.eo \
lib/evas/canvas/efl_animation.eo \
$(NULL)
evas_eolian_legacy_files = \
@ -60,7 +61,8 @@ evas_eolian_priv_files = \
lib/evas/include/evas_ector_buffer.eo
evas_eolian_type_files = \
lib/evas/canvas/evas_canvas3d_types.eot
lib/evas/canvas/evas_canvas3d_types.eot \
lib/evas/canvas/efl_animation_types.eot
evas_eolian_priv_c = $(evas_eolian_priv_files:%.eo=%.eo.c)
evas_eolian_priv_h = $(evas_eolian_priv_files:%.eo=%.eo.h) \
@ -120,7 +122,8 @@ lib/evas/canvas/evas_vg_private.h \
lib/evas/canvas/evas_image_private.h \
lib/evas/canvas/evas_polygon_private.h \
lib/evas/canvas/efl_canvas_surface.h \
lib/evas/common3d/primitives/primitive_common.h
lib/evas/common3d/primitives/primitive_common.h \
lib/evas/canvas/efl_animation_private.h
# Linebreak
@ -206,6 +209,7 @@ lib/evas/canvas/efl_input_key.c \
lib/evas/canvas/efl_input_pointer.c \
lib/evas/canvas/efl_input_hold.c \
lib/evas/canvas/efl_input_focus.c \
lib/evas/canvas/efl_animation.c \
$(NULL)
EXTRA_DIST2 += \

View File

@ -3330,6 +3330,13 @@ EAPI const Eina_List *evas_font_path_global_list(void) EINA_WARN_UNUSED_R
*/
EAPI void evas_font_reinit(void);
#ifndef _EFL_ANIMATION_EO_CLASS_TYPE
#define _EFL_ANIMATION_EO_CLASS_TYPE
typedef Eo Efl_Animation;
#endif
/**
* @}
*/

View File

@ -51,7 +51,12 @@
* @}
*/
#include "canvas/efl_animation_types.eot.h"
#include "canvas/efl_canvas_object.eo.h"
#include "canvas/efl_animation.eo.h"
#endif /* EFL_EO_API_SUPPORT */
#if defined(EFL_BETA_API_SUPPORT) && defined(EFL_EO_API_SUPPORT)

View File

@ -0,0 +1,107 @@
#include "efl_animation_private.h"
static void
_target_del_cb(void *data, const Efl_Event *event EINA_UNUSED)
{
Eo *eo_obj = data;
EFL_ANIMATION_CHECK_OR_RETURN(eo_obj);
EFL_ANIMATION_DATA_GET(eo_obj, pd);
pd->target = NULL;
}
EOLIAN static void
_efl_animation_target_set(Eo *eo_obj,
Efl_Animation_Data *pd,
Efl_Canvas_Object *target)
{
EFL_ANIMATION_CHECK_OR_RETURN(eo_obj);
efl_event_callback_add(target, EFL_EVENT_DEL, _target_del_cb, eo_obj);
pd->target = target;
}
EOLIAN static Efl_Canvas_Object *
_efl_animation_target_get(Eo *eo_obj, Efl_Animation_Data *pd)
{
EFL_ANIMATION_CHECK_OR_RETURN(eo_obj, NULL);
return pd->target;
}
EOLIAN static void
_efl_animation_duration_set(Eo *eo_obj,
Efl_Animation_Data *pd,
double duration)
{
EFL_ANIMATION_CHECK_OR_RETURN(eo_obj);
pd->duration = duration;
}
EOLIAN static double
_efl_animation_duration_get(Eo *eo_obj, Efl_Animation_Data *pd)
{
EFL_ANIMATION_CHECK_OR_RETURN(eo_obj, 0.0);
return pd->duration;
}
EOLIAN static Eina_Bool
_efl_animation_is_deleted(Eo *eo_obj, Efl_Animation_Data *pd)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(eo_obj, EINA_TRUE);
return pd->is_deleted;
}
EOLIAN static void
_efl_animation_final_state_keep_set(Eo *eo_obj,
Efl_Animation_Data *pd,
Eina_Bool keep_final_state)
{
EFL_ANIMATION_CHECK_OR_RETURN(eo_obj);
if (pd->keep_final_state == keep_final_state) return;
pd->keep_final_state = !!keep_final_state;
}
EOLIAN static Eina_Bool
_efl_animation_final_state_keep_get(Eo *eo_obj, Efl_Animation_Data *pd)
{
EFL_ANIMATION_CHECK_OR_RETURN(eo_obj, EINA_FALSE);
return pd->keep_final_state;
}
EOLIAN static Efl_Object *
_efl_animation_efl_object_constructor(Eo *eo_obj,
Efl_Animation_Data *pd)
{
eo_obj = efl_constructor(efl_super(eo_obj, MY_CLASS));
pd->target = NULL;
pd->duration = 0.0;
pd->is_deleted = EINA_FALSE;
pd->keep_final_state = EINA_FALSE;
return eo_obj;
}
EOLIAN static void
_efl_animation_efl_object_destructor(Eo *eo_obj, Efl_Animation_Data *pd)
{
pd->is_deleted = EINA_TRUE;
if (pd->target)
efl_event_callback_del(pd->target, EFL_EVENT_DEL, _target_del_cb, eo_obj);
efl_destructor(efl_super(eo_obj, MY_CLASS));
}
#include "efl_animation.eo.c"

View File

@ -0,0 +1,43 @@
import efl_animation_types;
class Efl.Animation (Efl.Object)
{
[[Efl animation class]]
data: Efl_Animation_Data;
methods {
@property target {
set {
}
get {
}
values {
target: Efl.Canvas.Object; [[Target object which is applied animation.]]
}
}
@property final_state_keep {
set {
}
get {
}
values {
keep_final_state: bool; [[$true to keep final state, $false otherwise.]]
}
}
@property duration {
set {
}
get {
}
values {
duration: double; [[Duration value.]]
}
}
is_deleted @protected {
return: bool; [[$true if animation is deleted, $false otherwise.]]
}
}
implements {
Efl.Object.constructor;
Efl.Object.destructor;
}
}

View File

@ -0,0 +1,31 @@
#define EFL_ANIMATION_PROTECTED
#include "evas_common_private.h"
#define MY_CLASS EFL_ANIMATION_CLASS
#define MY_CLASS_NAME efl_class_name_get(MY_CLASS)
typedef struct _Efl_Animation_Data
{
Efl_Canvas_Object *target;
double duration;
Eina_Bool is_deleted : 1;
Eina_Bool keep_final_state : 1;
} Efl_Animation_Data;
#define EFL_ANIMATION_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_DATA_GET(o, pd) \
Efl_Animation_Data *pd = efl_data_scope_get(o, EFL_ANIMATION_CLASS)

View File

@ -0,0 +1,2 @@
// ----------------------------------------------------------------------------
// All the below types are for Efl Animation