summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJaehyun Cho <jae_hyun.cho@samsung.com>2017-08-25 17:17:24 +0900
committerJaehyun Cho <jae_hyun.cho@samsung.com>2017-10-12 21:03:49 +0900
commit861a90415c6b41c02a2599f4b2deb50f254dba02 (patch)
tree17f7aae6e1545494c90e9f765c33e927b80911c7 /src
parente1a73fffb9a8e3ededcf4a06c47b034536c33e9c (diff)
downloadefl-861a90415c6b41c02a2599f4b2deb50f254dba02.tar.gz
efl_animation: Add group animation object
Diffstat (limited to 'src')
-rw-r--r--src/Makefile_Evas.am5
-rw-r--r--src/lib/evas/Evas_Common.h8
-rw-r--r--src/lib/evas/Evas_Eo.h1
-rw-r--r--src/lib/evas/Evas_Internal.h7
-rw-r--r--src/lib/evas/canvas/efl_animation_object_group.c188
-rw-r--r--src/lib/evas/canvas/efl_animation_object_group.eo13
-rw-r--r--src/lib/evas/canvas/efl_animation_object_group_private.h26
7 files changed, 247 insertions, 1 deletions
diff --git a/src/Makefile_Evas.am b/src/Makefile_Evas.am
index 68c1b1817a..96f133e0c2 100644
--- a/src/Makefile_Evas.am
+++ b/src/Makefile_Evas.am
@@ -55,6 +55,7 @@ evas_eolian_pub_files = \
lib/evas/canvas/efl_animation_object_rotate.eo \
lib/evas/canvas/efl_animation_object_scale.eo \
lib/evas/canvas/efl_animation_object_translate.eo \
+ lib/evas/canvas/efl_animation_object_group.eo \
$(NULL)
evas_eolian_legacy_files = \
@@ -143,7 +144,8 @@ lib/evas/canvas/efl_animation_object_private.h \
lib/evas/canvas/efl_animation_object_alpha_private.h \
lib/evas/canvas/efl_animation_object_rotate_private.h \
lib/evas/canvas/efl_animation_object_scale_private.h \
-lib/evas/canvas/efl_animation_object_translate_private.h
+lib/evas/canvas/efl_animation_object_translate_private.h \
+lib/evas/canvas/efl_animation_object_group_private.h
# Linebreak
@@ -240,6 +242,7 @@ lib/evas/canvas/efl_animation_object_alpha.c \
lib/evas/canvas/efl_animation_object_rotate.c \
lib/evas/canvas/efl_animation_object_scale.c \
lib/evas/canvas/efl_animation_object_translate.c \
+lib/evas/canvas/efl_animation_object_group.c \
$(NULL)
EXTRA_DIST2 += \
diff --git a/src/lib/evas/Evas_Common.h b/src/lib/evas/Evas_Common.h
index 7c39fb21df..79f2f4c08a 100644
--- a/src/lib/evas/Evas_Common.h
+++ b/src/lib/evas/Evas_Common.h
@@ -3407,12 +3407,20 @@ typedef Eo Efl_Animation_Object_Translate;
#endif
+#ifndef _EFL_ANIMATION_OBJECT_GROUP_EO_CLASS_TYPE
+#define _EFL_ANIMATION_OBJECT_GROUP_EO_CLASS_TYPE
+
+typedef Eo Efl_Animation_Object_Group;
+
+#endif
+
struct _Efl_Animation_Object_Running_Event_Info
{
double progress;
};
#define EFL_ANIMATION_GROUP_DURATION_NONE -1
+#define EFL_ANIMATION_OBJECT_GROUP_DURATION_NONE -1
/**
* @}
diff --git a/src/lib/evas/Evas_Eo.h b/src/lib/evas/Evas_Eo.h
index 6f52e0c809..b0a2d25924 100644
--- a/src/lib/evas/Evas_Eo.h
+++ b/src/lib/evas/Evas_Eo.h
@@ -66,6 +66,7 @@
#include "canvas/efl_animation_object_rotate.eo.h"
#include "canvas/efl_animation_object_scale.eo.h"
#include "canvas/efl_animation_object_translate.eo.h"
+#include "canvas/efl_animation_object_group.eo.h"
#endif /* EFL_EO_API_SUPPORT */
diff --git a/src/lib/evas/Evas_Internal.h b/src/lib/evas/Evas_Internal.h
index a406abc5e7..721eba618d 100644
--- a/src/lib/evas/Evas_Internal.h
+++ b/src/lib/evas/Evas_Internal.h
@@ -131,6 +131,13 @@ EOAPI void efl_animation_object_translate_absolute_set(Eo *obj, int from_x, int
EOAPI void efl_animation_object_translate_absolute_get(const Eo *obj, int *from_x, int *from_y, int *to_x, int *to_y);
/* Efl.Animation.Object.Translate END */
+/* Efl.Animation.Object.Group */
+EOAPI void efl_animation_object_group_object_add(Eo *obj, Efl_Animation_Object *anim_obj);
+EOAPI void efl_animation_object_group_object_del(Eo *obj, Efl_Animation_Object *anim_obj);
+
+EOAPI Eina_List *efl_animation_object_group_objects_get(Eo *obj);
+/* Efl.Animation.Object.Group END */
+
#ifdef __cplusplus
}
#endif
diff --git a/src/lib/evas/canvas/efl_animation_object_group.c b/src/lib/evas/canvas/efl_animation_object_group.c
new file mode 100644
index 0000000000..d3799b40ca
--- /dev/null
+++ b/src/lib/evas/canvas/efl_animation_object_group.c
@@ -0,0 +1,188 @@
+#include "efl_animation_object_group_private.h"
+
+EOLIAN static void
+_efl_animation_object_group_object_add(Eo *eo_obj,
+ Efl_Animation_Object_Group_Data *pd,
+ Efl_Animation_Object *anim_obj)
+{
+ EFL_ANIMATION_OBJECT_GROUP_CHECK_OR_RETURN(eo_obj);
+
+ if (!anim_obj) return;
+
+ Efl_Canvas_Object *target = efl_animation_object_target_get(eo_obj);
+ if (target)
+ efl_animation_object_target_set(anim_obj, target);
+
+ double duration = efl_animation_object_duration_get(eo_obj);
+ /* if group animation object duration is available value, then the duration
+ * is propagated to its child. */
+ if (duration != EFL_ANIMATION_OBJECT_GROUP_DURATION_NONE)
+ efl_animation_object_duration_set(anim_obj, duration);
+
+ Eina_Bool state_keep = efl_animation_object_final_state_keep_get(eo_obj);
+ efl_animation_object_final_state_keep_set(anim_obj, state_keep);
+
+ pd->anim_objs = eina_list_append(pd->anim_objs, anim_obj);
+}
+
+EOLIAN static void
+_efl_animation_object_group_object_del(Eo *eo_obj,
+ Efl_Animation_Object_Group_Data *pd,
+ Efl_Animation_Object *anim_obj)
+{
+ EFL_ANIMATION_OBJECT_GROUP_CHECK_OR_RETURN(eo_obj);
+
+ if (!anim_obj) return;
+
+ pd->anim_objs = eina_list_remove(pd->anim_objs, anim_obj);
+}
+
+EOLIAN static Eina_List *
+_efl_animation_object_group_objects_get(Eo *eo_obj,
+ Efl_Animation_Object_Group_Data *pd)
+{
+ EFL_ANIMATION_OBJECT_GROUP_CHECK_OR_RETURN(eo_obj, NULL);
+
+ return pd->anim_objs;
+}
+
+EOLIAN static void
+_efl_animation_object_group_efl_animation_object_target_set(Eo *eo_obj,
+ Efl_Animation_Object_Group_Data *pd,
+ Efl_Canvas_Object *target)
+{
+ EFL_ANIMATION_OBJECT_GROUP_CHECK_OR_RETURN(eo_obj);
+
+ Eina_List *l;
+ Efl_Animation_Object *anim_obj;
+
+ EINA_LIST_FOREACH(pd->anim_objs, l, anim_obj)
+ {
+ efl_animation_object_target_set(anim_obj, target);
+ }
+
+ efl_animation_object_target_set(efl_super(eo_obj, MY_CLASS), target);
+}
+
+EOLIAN static void
+_efl_animation_object_group_efl_animation_object_duration_set(Eo *eo_obj,
+ Efl_Animation_Object_Group_Data *pd,
+ double duration)
+{
+ EFL_ANIMATION_OBJECT_GROUP_CHECK_OR_RETURN(eo_obj);
+
+ if (duration == EFL_ANIMATION_OBJECT_GROUP_DURATION_NONE) goto end;
+
+ if (duration < 0.0) return;
+
+ Eina_List *l;
+ Efl_Animation_Object *anim_obj;
+
+ EINA_LIST_FOREACH(pd->anim_objs, l, anim_obj)
+ {
+ efl_animation_object_duration_set(anim_obj, duration);
+ }
+
+end:
+ efl_animation_object_duration_only_set(efl_super(eo_obj, MY_CLASS),
+ duration);
+
+ /* efl_animation_object_total_duration_get() should calculate the new total
+ * duration. */
+ double total_duration = efl_animation_object_total_duration_get(eo_obj);
+ efl_animation_object_total_duration_set(eo_obj, total_duration);
+}
+
+EOLIAN static void
+_efl_animation_object_group_efl_animation_object_final_state_keep_set(Eo *eo_obj,
+ Efl_Animation_Object_Group_Data *pd,
+ Eina_Bool state_keep)
+{
+ EFL_ANIMATION_OBJECT_GROUP_CHECK_OR_RETURN(eo_obj);
+
+ Eina_List *l;
+ Efl_Animation_Object *anim_obj;
+
+ EINA_LIST_FOREACH(pd->anim_objs, l, anim_obj)
+ {
+ efl_animation_object_final_state_keep_set(anim_obj, state_keep);
+ }
+
+ efl_animation_object_final_state_keep_set(efl_super(eo_obj, MY_CLASS),
+ state_keep);
+}
+
+EOLIAN static Efl_Object *
+_efl_animation_object_group_efl_object_constructor(Eo *eo_obj,
+ Efl_Animation_Object_Group_Data *pd)
+{
+ eo_obj = efl_constructor(efl_super(eo_obj, MY_CLASS));
+
+ pd->anim_objs = NULL;
+
+ //group animation object does not affect its child duration by default.
+ efl_animation_object_duration_only_set(efl_super(eo_obj, MY_CLASS),
+ EFL_ANIMATION_OBJECT_GROUP_DURATION_NONE);
+
+ return eo_obj;
+}
+
+EOLIAN static void
+_efl_animation_object_group_efl_object_destructor(Eo *eo_obj,
+ Efl_Animation_Object_Group_Data *pd)
+{
+ Efl_Animation_Object *anim_obj;
+
+ EINA_LIST_FREE(pd->anim_objs, anim_obj)
+ efl_del(anim_obj);
+
+ efl_destructor(efl_super(eo_obj, MY_CLASS));
+}
+
+EOLIAN static void
+_efl_animation_object_group_efl_animation_object_target_state_save(Eo *eo_obj,
+ Efl_Animation_Object_Group_Data *pd)
+{
+ EFL_ANIMATION_OBJECT_GROUP_CHECK_OR_RETURN(eo_obj);
+
+ Eina_List *l;
+ Efl_Animation_Object *anim_obj;
+
+ EINA_LIST_FOREACH(pd->anim_objs, l, anim_obj)
+ {
+ efl_animation_object_target_state_save(anim_obj);
+ }
+}
+
+EOLIAN static void
+_efl_animation_object_group_efl_animation_object_target_state_reset(Eo *eo_obj,
+ Efl_Animation_Object_Group_Data *pd)
+{
+ EFL_ANIMATION_OBJECT_GROUP_CHECK_OR_RETURN(eo_obj);
+
+ Eina_List *l;
+ Efl_Animation_Object *anim_obj;
+
+ EINA_LIST_FOREACH(pd->anim_objs, l, anim_obj)
+ {
+ efl_animation_object_target_state_reset(anim_obj);
+ }
+}
+
+/* Internal EO APIs */
+
+EOAPI EFL_VOID_FUNC_BODYV(efl_animation_object_group_object_add, EFL_FUNC_CALL(anim_obj), Efl_Animation_Object *anim_obj);
+
+EOAPI EFL_VOID_FUNC_BODYV(efl_animation_object_group_object_del, EFL_FUNC_CALL(anim_obj), Efl_Animation_Object *anim_obj);
+
+EOAPI EFL_FUNC_BODY(efl_animation_object_group_objects_get, Eina_List *, NULL);
+
+#define EFL_ANIMATION_OBJECT_GROUP_EXTRA_OPS \
+ EFL_OBJECT_OP_FUNC(efl_animation_object_group_object_add, _efl_animation_object_group_object_add), \
+ EFL_OBJECT_OP_FUNC(efl_animation_object_group_object_del, _efl_animation_object_group_object_del), \
+ EFL_OBJECT_OP_FUNC(efl_animation_object_group_objects_get, _efl_animation_object_group_objects_get), \
+ EFL_OBJECT_OP_FUNC(efl_animation_object_target_set, _efl_animation_object_group_efl_animation_object_target_set), \
+ EFL_OBJECT_OP_FUNC(efl_animation_object_duration_set, _efl_animation_object_group_efl_animation_object_duration_set), \
+ EFL_OBJECT_OP_FUNC(efl_animation_object_final_state_keep_set, _efl_animation_object_group_efl_animation_object_final_state_keep_set)
+
+#include "efl_animation_object_group.eo.c"
diff --git a/src/lib/evas/canvas/efl_animation_object_group.eo b/src/lib/evas/canvas/efl_animation_object_group.eo
new file mode 100644
index 0000000000..cdde1ec78b
--- /dev/null
+++ b/src/lib/evas/canvas/efl_animation_object_group.eo
@@ -0,0 +1,13 @@
+import efl_animation_types;
+
+abstract Efl.Animation.Object.Group (Efl.Animation.Object)
+{
+ [[Efl group animation object abstract class]]
+ data: Efl_Animation_Object_Group_Data;
+ implements {
+ Efl.Object.constructor;
+ Efl.Object.destructor;
+ Efl.Animation.Object.target_state_save;
+ Efl.Animation.Object.target_state_reset;
+ }
+}
diff --git a/src/lib/evas/canvas/efl_animation_object_group_private.h b/src/lib/evas/canvas/efl_animation_object_group_private.h
new file mode 100644
index 0000000000..a710b462e7
--- /dev/null
+++ b/src/lib/evas/canvas/efl_animation_object_group_private.h
@@ -0,0 +1,26 @@
+#define EFL_ANIMATION_OBJECT_PROTECTED
+
+#include "evas_common_private.h"
+
+#define MY_CLASS EFL_ANIMATION_OBJECT_GROUP_CLASS
+#define MY_CLASS_NAME efl_class_name_get(MY_CLASS)
+
+#define EFL_ANIMATION_OBJECT_GROUP_CHECK_OR_RETURN(anim_obj, ...) \
+ do { \
+ if (!anim_obj) { \
+ CRI("Efl_Animation_Object " # anim_obj " is NULL!"); \
+ return __VA_ARGS__; \
+ } \
+ if (efl_animation_object_is_deleted(anim_obj)) { \
+ ERR("Efl_Animation_Object " # anim_obj " has already been deleted!"); \
+ return __VA_ARGS__; \
+ } \
+ } while (0)
+
+#define EFL_ANIMATION_OBJECT_GROUP_DATA_GET(o, pd) \
+ Efl_Animation_Object_Group_Data *pd = efl_data_scope_get(o, EFL_ANIMATION_OBJECT_GROUP_CLASS)
+
+typedef struct _Efl_Animation_Object_Group_Data
+{
+ Eina_List *anim_objs;
+} Efl_Animation_Object_Group_Data;