summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaehyun Cho <jae_hyun.cho@samsung.com>2017-08-25 10:47:26 +0900
committerJaehyun Cho <jae_hyun.cho@samsung.com>2017-09-18 20:47:12 +0900
commit30961e3c2c1ca760bec742499af182fe0446cbc9 (patch)
tree467f3988417b7f5253a417cc60f25628d2e637c5
parent8a1ff2d6c4d9ba514d35c58dedc84ea34509de72 (diff)
downloadefl-30961e3c2c1ca760bec742499af182fe0446cbc9.tar.gz
efl_animation: Add alpha animation instance
-rw-r--r--src/Makefile_Evas.am5
-rw-r--r--src/lib/evas/Evas_Common.h7
-rw-r--r--src/lib/evas/Evas_Eo.h1
-rw-r--r--src/lib/evas/Evas_Internal.h5
-rw-r--r--src/lib/evas/canvas/efl_animation_alpha.c26
-rw-r--r--src/lib/evas/canvas/efl_animation_alpha.eo1
-rw-r--r--src/lib/evas/canvas/efl_animation_instance_alpha.c106
-rw-r--r--src/lib/evas/canvas/efl_animation_instance_alpha.eo10
-rw-r--r--src/lib/evas/canvas/efl_animation_instance_alpha_private.h36
9 files changed, 196 insertions, 1 deletions
diff --git a/src/Makefile_Evas.am b/src/Makefile_Evas.am
index 0e9dbebdb5..19290e2d8e 100644
--- a/src/Makefile_Evas.am
+++ b/src/Makefile_Evas.am
@@ -47,6 +47,7 @@ evas_eolian_pub_files = \
lib/evas/canvas/efl_animation.eo \
lib/evas/canvas/efl_animation_alpha.eo \
lib/evas/canvas/efl_animation_instance.eo \
+ lib/evas/canvas/efl_animation_instance_alpha.eo \
$(NULL)
evas_eolian_legacy_files = \
@@ -127,7 +128,8 @@ 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_instance_private.h
+lib/evas/canvas/efl_animation_instance_private.h \
+lib/evas/canvas/efl_animation_instance_alpha_private.h
# Linebreak
@@ -216,6 +218,7 @@ 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_instance.c \
+lib/evas/canvas/efl_animation_instance_alpha.c \
$(NULL)
EXTRA_DIST2 += \
diff --git a/src/lib/evas/Evas_Common.h b/src/lib/evas/Evas_Common.h
index 41bf75662a..48669eb0d6 100644
--- a/src/lib/evas/Evas_Common.h
+++ b/src/lib/evas/Evas_Common.h
@@ -3344,6 +3344,13 @@ typedef Eo Efl_Animation_Instance;
#endif
+#ifndef _EFL_ANIMATION_INSTANCE_ALPHA_EO_CLASS_TYPE
+#define _EFL_ANIMATION_INSTANCE_ALPHA_EO_CLASS_TYPE
+
+typedef Eo Efl_Animation_Instance_Alpha;
+
+#endif
+
struct _Efl_Animation_Instance_Animate_Event_Info
{
double progress;
diff --git a/src/lib/evas/Evas_Eo.h b/src/lib/evas/Evas_Eo.h
index d00b4fa283..59fbbfeaca 100644
--- a/src/lib/evas/Evas_Eo.h
+++ b/src/lib/evas/Evas_Eo.h
@@ -58,6 +58,7 @@
#include "canvas/efl_animation.eo.h"
#include "canvas/efl_animation_alpha.eo.h"
#include "canvas/efl_animation_instance.eo.h"
+#include "canvas/efl_animation_instance_alpha.eo.h"
#endif /* EFL_EO_API_SUPPORT */
diff --git a/src/lib/evas/Evas_Internal.h b/src/lib/evas/Evas_Internal.h
index 2eed0e2e31..9f995dabb3 100644
--- a/src/lib/evas/Evas_Internal.h
+++ b/src/lib/evas/Evas_Internal.h
@@ -94,6 +94,11 @@ EWAPI extern const Efl_Event_Description _EFL_ANIMATION_INSTANCE_EVENT_PRE_ANIMA
#define EFL_ANIMATION_INSTANCE_EVENT_PRE_ANIMATE (&(_EFL_ANIMATION_INSTANCE_EVENT_PRE_ANIMATE))
/* Efl.Animation.Instance END */
+/* Efl.Animation.Instance.Alpha */
+EOAPI void efl_animation_instance_alpha_set(Eo *obj, double from_alpha, double to_alpha);
+EOAPI void efl_animation_instance_alpha_get(const Eo *obj, double *from_alpha, double *to_alpha);
+/* Efl.Animation.Instance.Alpha END */
+
#ifdef __cplusplus
}
#endif
diff --git a/src/lib/evas/canvas/efl_animation_alpha.c b/src/lib/evas/canvas/efl_animation_alpha.c
index 1a7fc469c8..3758ac767d 100644
--- a/src/lib/evas/canvas/efl_animation_alpha.c
+++ b/src/lib/evas/canvas/efl_animation_alpha.c
@@ -42,6 +42,32 @@ _efl_animation_alpha_efl_animation_duration_set(Eo *eo_obj,
efl_animation_duration_set(efl_super(eo_obj, MY_CLASS), duration);
}
+EOLIAN static Efl_Animation_Instance *
+_efl_animation_alpha_efl_animation_instance_create(Eo *eo_obj,
+ Efl_Animation_Alpha_Data *pd)
+{
+ EFL_ANIMATION_ALPHA_CHECK_OR_RETURN(eo_obj, NULL);
+
+ Efl_Animation_Instance_Alpha *instance
+ = efl_add(EFL_ANIMATION_INSTANCE_ALPHA_CLASS, NULL);
+
+ Efl_Canvas_Object *target = efl_animation_target_get(eo_obj);
+ efl_animation_instance_target_set(instance, target);
+
+ Eina_Bool state_keep = efl_animation_final_state_keep_get(eo_obj);
+ efl_animation_instance_final_state_keep_set(instance, state_keep);
+
+ double duration = efl_animation_duration_get(eo_obj);
+ efl_animation_instance_duration_set(instance, duration);
+
+ double total_duration = efl_animation_total_duration_get(eo_obj);
+ efl_animation_instance_total_duration_set(instance, total_duration);
+
+ efl_animation_instance_alpha_set(instance, pd->from.alpha, pd->to.alpha);
+
+ return instance;
+}
+
EOLIAN static Efl_Object *
_efl_animation_alpha_efl_object_constructor(Eo *eo_obj,
Efl_Animation_Alpha_Data *pd)
diff --git a/src/lib/evas/canvas/efl_animation_alpha.eo b/src/lib/evas/canvas/efl_animation_alpha.eo
index d773d5be4c..70401318dd 100644
--- a/src/lib/evas/canvas/efl_animation_alpha.eo
+++ b/src/lib/evas/canvas/efl_animation_alpha.eo
@@ -19,5 +19,6 @@ class Efl.Animation.Alpha (Efl.Animation)
implements {
Efl.Object.constructor;
Efl.Animation.duration { set; }
+ Efl.Animation.instance_create;
}
}
diff --git a/src/lib/evas/canvas/efl_animation_instance_alpha.c b/src/lib/evas/canvas/efl_animation_instance_alpha.c
new file mode 100644
index 0000000000..ffe5831226
--- /dev/null
+++ b/src/lib/evas/canvas/efl_animation_instance_alpha.c
@@ -0,0 +1,106 @@
+#include "efl_animation_instance_alpha_private.h"
+
+EOLIAN static void
+_efl_animation_instance_alpha_alpha_set(Eo *eo_obj,
+ Efl_Animation_Instance_Alpha_Data *pd,
+ double from_alpha,
+ double to_alpha)
+{
+ EFL_ANIMATION_INSTANCE_ALPHA_CHECK_OR_RETURN(eo_obj);
+
+ pd->from.alpha = from_alpha;
+ pd->to.alpha = to_alpha;
+}
+
+EOLIAN static void
+_efl_animation_instance_alpha_alpha_get(Eo *eo_obj EINA_UNUSED,
+ Efl_Animation_Instance_Alpha_Data *pd,
+ double *from_alpha,
+ double *to_alpha)
+{
+ EFL_ANIMATION_INSTANCE_ALPHA_CHECK_OR_RETURN(eo_obj);
+
+ if (from_alpha)
+ *from_alpha = pd->from.alpha;
+ if (to_alpha)
+ *to_alpha = pd->to.alpha;
+}
+
+EOLIAN static void
+_efl_animation_instance_alpha_efl_animation_instance_duration_set(Eo *eo_obj,
+ Efl_Animation_Instance_Alpha_Data *pd EINA_UNUSED,
+ double duration)
+{
+ EFL_ANIMATION_INSTANCE_ALPHA_CHECK_OR_RETURN(eo_obj);
+
+ /* For a single animation instance, duration should be equal to or bigger
+ * than 0.0. */
+ if (duration < 0.0) return;
+
+ //For a single animation instance, total duration is the same as duration.
+ efl_animation_instance_total_duration_set(eo_obj, duration);
+
+ efl_animation_instance_duration_set(efl_super(eo_obj, MY_CLASS), duration);
+}
+
+static void
+_progress_set(Eo *eo_obj, double progress)
+{
+ EFL_ANIMATION_INSTANCE_ALPHA_DATA_GET(eo_obj, pd);
+
+ Efl_Canvas_Object *target = efl_animation_instance_target_get(eo_obj);
+ if (!target) return;
+
+ double alpha
+ = (pd->from.alpha * (1.0 - progress)) + (pd->to.alpha * progress);
+
+ int r[4], g[4], b[4], a[4];
+ int i;
+ for (i = 0; i < 4; i++)
+ efl_gfx_map_color_get(target, i, &r[i], &g[i], &b[i], &a[i]);
+
+ for (i = 0; i < 4; i++)
+ {
+ r[i] = (int)(r[i] * alpha);
+ g[i] = (int)(g[i] * alpha);
+ b[i] = (int)(b[i] * alpha);
+ a[i] = (int)(a[i] * alpha);
+ efl_gfx_map_color_set(target, i, r[i], g[i], b[i], a[i]);
+ }
+}
+
+static void
+_pre_animate_cb(void *data EINA_UNUSED, const Efl_Event *event)
+{
+ Efl_Animation_Instance_Animate_Event_Info *event_info = event->info;
+
+ _progress_set(event->object, event_info->progress);
+}
+
+EOLIAN static Efl_Object *
+_efl_animation_instance_alpha_efl_object_constructor(Eo *eo_obj,
+ Efl_Animation_Instance_Alpha_Data *pd)
+{
+ eo_obj = efl_constructor(efl_super(eo_obj, MY_CLASS));
+
+ pd->from.alpha = 1.0;
+ pd->to.alpha = 1.0;
+
+ //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);
+
+ return eo_obj;
+}
+
+/* Internal EO APIs */
+
+EOAPI EFL_VOID_FUNC_BODYV(efl_animation_instance_alpha_set, EFL_FUNC_CALL(from_alpha, to_alpha), double from_alpha, double to_alpha);
+EOAPI EFL_VOID_FUNC_BODYV_CONST(efl_animation_instance_alpha_get, EFL_FUNC_CALL(from_alpha, to_alpha), double *from_alpha, double *to_alpha);
+
+#define EFL_ANIMATION_INSTANCE_ALPHA_EXTRA_OPS \
+ EFL_OBJECT_OP_FUNC(efl_animation_instance_alpha_set, _efl_animation_instance_alpha_alpha_set), \
+ EFL_OBJECT_OP_FUNC(efl_animation_instance_alpha_get, _efl_animation_instance_alpha_alpha_get), \
+ EFL_OBJECT_OP_FUNC(efl_animation_instance_duration_set, _efl_animation_instance_alpha_efl_animation_instance_duration_set)
+
+#include "efl_animation_instance_alpha.eo.c"
diff --git a/src/lib/evas/canvas/efl_animation_instance_alpha.eo b/src/lib/evas/canvas/efl_animation_instance_alpha.eo
new file mode 100644
index 0000000000..a654db5016
--- /dev/null
+++ b/src/lib/evas/canvas/efl_animation_instance_alpha.eo
@@ -0,0 +1,10 @@
+import efl_animation_types;
+
+class Efl.Animation.Instance.Alpha (Efl.Animation.Instance)
+{
+ [[Efl alpha animation instance class]]
+ data: Efl_Animation_Instance_Alpha_Data;
+ implements {
+ Efl.Object.constructor;
+ }
+}
diff --git a/src/lib/evas/canvas/efl_animation_instance_alpha_private.h b/src/lib/evas/canvas/efl_animation_instance_alpha_private.h
new file mode 100644
index 0000000000..97c0220775
--- /dev/null
+++ b/src/lib/evas/canvas/efl_animation_instance_alpha_private.h
@@ -0,0 +1,36 @@
+#define EFL_ANIMATION_INSTANCE_PROTECTED
+#define EFL_ANIMATION_INSTANCE_ALPHA_PROTECTED
+
+#include "evas_common_private.h"
+
+#define MY_CLASS EFL_ANIMATION_INSTANCE_ALPHA_CLASS
+#define MY_CLASS_NAME efl_class_name_get(MY_CLASS)
+
+#define MY_CLASS EFL_ANIMATION_INSTANCE_ALPHA_CLASS
+#define MY_CLASS_NAME efl_class_name_get(MY_CLASS)
+
+#define EFL_ANIMATION_INSTANCE_ALPHA_CHECK_OR_RETURN(inst, ...) \
+ do { \
+ if (!inst) { \
+ CRI("Efl_Animation_Instance " # inst " is NULL!"); \
+ return __VA_ARGS__; \
+ } \
+ if (efl_animation_instance_is_deleted(inst)) { \
+ ERR("Efl_Animation_Instance " # inst " has already been deleted!"); \
+ return __VA_ARGS__; \
+ } \
+ } while (0)
+
+#define EFL_ANIMATION_INSTANCE_ALPHA_DATA_GET(o, pd) \
+ Efl_Animation_Instance_Alpha_Data *pd = efl_data_scope_get(o, EFL_ANIMATION_INSTANCE_ALPHA_CLASS)
+
+typedef struct _Efl_Animation_Instance_Alpha_Property
+{
+ double alpha;
+} Efl_Animation_Instance_Alpha_Property;
+
+typedef struct _Efl_Animation_Instance_Alpha_Data
+{
+ Efl_Animation_Instance_Alpha_Property from;
+ Efl_Animation_Instance_Alpha_Property to;
+} Efl_Animation_Instance_Alpha_Data;