lib/evas/canvas/efl_animation_rotate.eo \
lib/evas/canvas/efl_animation_scale.eo \
lib/evas/canvas/efl_animation_translate.eo \
+ lib/evas/canvas/efl_animation_group.eo \
lib/evas/canvas/efl_animation_object.eo \
lib/evas/canvas/efl_animation_object_alpha.eo \
lib/evas/canvas/efl_animation_object_rotate.eo \
lib/evas/canvas/efl_animation_rotate_private.h \
lib/evas/canvas/efl_animation_scale_private.h \
lib/evas/canvas/efl_animation_translate_private.h \
+lib/evas/canvas/efl_animation_group_private.h \
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_rotate.c \
lib/evas/canvas/efl_animation_scale.c \
lib/evas/canvas/efl_animation_translate.c \
+lib/evas/canvas/efl_animation_group.c \
lib/evas/canvas/efl_animation_object.c \
lib/evas/canvas/efl_animation_object_alpha.c \
lib/evas/canvas/efl_animation_object_rotate.c \
#endif
+#ifndef _EFL_ANIMATION_GROUP_EO_CLASS_TYPE
+#define _EFL_ANIMATION_GROUP_EO_CLASS_TYPE
+
+typedef Eo Efl_Animation_Group;
+
+#endif
+
#ifndef _EFL_ANIMATION_OBJECT_EO_CLASS_TYPE
#define _EFL_ANIMATION_OBJECT_EO_CLASS_TYPE
double progress;
};
+#define EFL_ANIMATION_GROUP_DURATION_NONE -1
+
/**
* @}
*/
#include "canvas/efl_animation_rotate.eo.h"
#include "canvas/efl_animation_scale.eo.h"
#include "canvas/efl_animation_translate.eo.h"
+#include "canvas/efl_animation_group.eo.h"
#include "canvas/efl_animation_object.eo.h"
#include "canvas/efl_animation_object_alpha.eo.h"
#include "canvas/efl_animation_object_rotate.eo.h"
EOAPI void efl_animation_object_duration_set(Eo *obj, double duration);
EOAPI double efl_animation_object_duration_get(const Eo *obj);
+EOAPI void efl_animation_object_duration_only_set(Eo *obj, double duration);
+
+EOAPI void efl_animation_object_total_duration_set(Eo *obj, double total_duration);
+EOAPI double efl_animation_object_total_duration_get(const Eo *obj);
+
EWAPI extern const Efl_Event_Description _EFL_ANIMATION_OBJECT_EVENT_PRE_STARTED;
#define EFL_ANIMATION_OBJECT_EVENT_PRE_STARTED (&(_EFL_ANIMATION_OBJECT_EVENT_PRE_STARTED))
/* Efl.Animation.Object END */
{
EFL_ANIMATION_CHECK_OR_RETURN(eo_obj);
+ efl_animation_total_duration_set(eo_obj, duration);
+
pd->duration = duration;
}
return pd->duration;
}
+EOLIAN static void
+_efl_animation_duration_only_set(Eo *eo_obj,
+ Efl_Animation_Data *pd,
+ double duration)
+{
+ EFL_ANIMATION_CHECK_OR_RETURN(eo_obj);
+
+ pd->duration = duration;
+}
+
+EOLIAN static void
+_efl_animation_total_duration_set(Eo *eo_obj,
+ Efl_Animation_Data *pd,
+ double total_duration)
+{
+ EFL_ANIMATION_CHECK_OR_RETURN(eo_obj);
+
+ pd->total_duration = total_duration;
+}
+
+EOLIAN static double
+_efl_animation_total_duration_get(Eo *eo_obj, Efl_Animation_Data *pd)
+{
+ EFL_ANIMATION_CHECK_OR_RETURN(eo_obj, 0.0);
+
+ return pd->total_duration;
+}
+
EOLIAN static Eina_Bool
_efl_animation_is_deleted(Eo *eo_obj, Efl_Animation_Data *pd)
{
double duration = efl_animation_duration_get(eo_obj);
efl_animation_object_duration_set(anim_obj, duration);
+ double total_duration = efl_animation_total_duration_get(eo_obj);
+ efl_animation_object_total_duration_set(anim_obj, total_duration);
+
return anim_obj;
}
duration: double; [[Duration value.]]
}
}
+ duration_only_set @protected {
+ [[Set duration only without setting total duration.]]
+ params {
+ @in duration: double; [[Duration value.]]
+ }
+ }
+ @property total_duration {
+ set @protected {
+ }
+ get {
+ }
+ values {
+ total_duration: double; [[Total duration value.]]
+ }
+ }
is_deleted @protected {
return: bool; [[$true if animation is deleted, $false otherwise.]]
}
double duration = efl_animation_duration_get(eo_obj);
efl_animation_object_duration_set(anim_obj, duration);
+ double total_duration = efl_animation_total_duration_get(eo_obj);
+ efl_animation_object_total_duration_set(anim_obj, total_duration);
+
efl_animation_object_alpha_set(anim_obj, pd->from.alpha, pd->to.alpha);
return anim_obj;
--- /dev/null
+#include "efl_animation_group_private.h"
+
+EOLIAN static void
+_efl_animation_group_animation_add(Eo *eo_obj,
+ Efl_Animation_Group_Data *pd,
+ Efl_Animation *animation)
+{
+ EFL_ANIMATION_GROUP_CHECK_OR_RETURN(eo_obj);
+
+ if (!animation) return;
+
+ Efl_Canvas_Object *target = efl_animation_target_get(eo_obj);
+ if (target)
+ efl_animation_target_set(animation, target);
+
+ double duration = efl_animation_duration_get(eo_obj);
+ /* if group animation duration is available value, then the duration is
+ * propagated to its child. */
+ if (duration != EFL_ANIMATION_GROUP_DURATION_NONE)
+ efl_animation_duration_set(animation, duration);
+
+ Eina_Bool keep_final_state = efl_animation_final_state_keep_get(eo_obj);
+ efl_animation_final_state_keep_set(animation, keep_final_state);
+
+ pd->animations = eina_list_append(pd->animations, animation);
+}
+
+EOLIAN static void
+_efl_animation_group_animation_del(Eo *eo_obj,
+ Efl_Animation_Group_Data *pd,
+ Efl_Animation*animation)
+{
+ EFL_ANIMATION_GROUP_CHECK_OR_RETURN(eo_obj);
+
+ if (!animation) return;
+
+ pd->animations = eina_list_remove(pd->animations, animation);
+}
+
+EOLIAN static Eina_List *
+_efl_animation_group_animations_get(Eo *eo_obj,
+ Efl_Animation_Group_Data *pd)
+{
+ EFL_ANIMATION_GROUP_CHECK_OR_RETURN(eo_obj, NULL);
+
+ return pd->animations;
+}
+
+EOLIAN static void
+_efl_animation_group_efl_animation_target_set(Eo *eo_obj,
+ Efl_Animation_Group_Data *pd,
+ Efl_Canvas_Object *target)
+{
+ EFL_ANIMATION_GROUP_CHECK_OR_RETURN(eo_obj);
+
+ Eina_List *l;
+ Efl_Animation *anim;
+ EINA_LIST_FOREACH(pd->animations, l, anim)
+ {
+ efl_animation_target_set(anim, target);
+ }
+
+ efl_animation_target_set(efl_super(eo_obj, MY_CLASS), target);
+}
+
+EOLIAN static void
+_efl_animation_group_efl_animation_duration_set(Eo *eo_obj,
+ Efl_Animation_Group_Data *pd,
+ double duration)
+{
+ EFL_ANIMATION_GROUP_CHECK_OR_RETURN(eo_obj);
+
+ if (duration == EFL_ANIMATION_GROUP_DURATION_NONE) goto end;
+
+ if (duration < 0.0) return;
+
+ Eina_List *l;
+ Efl_Animation *anim;
+ EINA_LIST_FOREACH(pd->animations, l, anim)
+ {
+ efl_animation_duration_set(anim, duration);
+ }
+
+end:
+ efl_animation_duration_only_set(efl_super(eo_obj, MY_CLASS), duration);
+
+ //efl_animation_total_duration_get() should calculate the new total duration.
+ double total_duration = efl_animation_total_duration_get(eo_obj);
+ efl_animation_total_duration_set(eo_obj, total_duration);
+}
+
+EOLIAN static void
+_efl_animation_group_efl_animation_final_state_keep_set(Eo *eo_obj,
+ Efl_Animation_Group_Data *pd,
+ Eina_Bool keep_final_state)
+{
+ EFL_ANIMATION_GROUP_CHECK_OR_RETURN(eo_obj);
+
+ Eina_List *l;
+ Efl_Animation *anim;
+ EINA_LIST_FOREACH(pd->animations, l, anim)
+ {
+ efl_animation_final_state_keep_set(anim, keep_final_state);
+ }
+
+ efl_animation_final_state_keep_set(efl_super(eo_obj, MY_CLASS), keep_final_state);
+}
+
+EOLIAN static Efl_Object *
+_efl_animation_group_efl_object_constructor(Eo *eo_obj,
+ Efl_Animation_Group_Data *pd)
+{
+ eo_obj = efl_constructor(efl_super(eo_obj, MY_CLASS));
+
+ pd->animations = NULL;
+
+ //group animation does not affect its child duration by default.
+ efl_animation_duration_only_set(efl_super(eo_obj, MY_CLASS),
+ EFL_ANIMATION_GROUP_DURATION_NONE);
+
+ return eo_obj;
+}
+
+EOLIAN static void
+_efl_animation_group_efl_object_destructor(Eo *eo_obj,
+ Efl_Animation_Group_Data *pd)
+{
+ Efl_Animation *anim;
+
+ EINA_LIST_FREE(pd->animations, anim)
+ efl_del(anim);
+
+ efl_destructor(efl_super(eo_obj, MY_CLASS));
+}
+
+#include "efl_animation_group.eo.c"
--- /dev/null
+import efl_animation_types;
+
+abstract Efl.Animation.Group (Efl.Animation)
+{
+ [[Efl group animation abstract class]]
+ data: Efl_Animation_Group_Data;
+ methods {
+ animation_add {
+ [[Add the given animation to the animation group.]]
+ params {
+ @in animation: Efl.Animation; [[The animation which needs to be added to the animation group]]
+ }
+ }
+ animation_del {
+ [[Delete the given animation from the animation group.]]
+ params {
+ @in animation: Efl.Animation; [[The animation which needs to be deleted from the animation group]]
+ }
+ }
+ animations_get {
+ [[Get the animations of the animation group.]]
+ return: list<Efl.Animation>; [[The animations of the animation group]]
+ }
+ }
+ implements {
+ Efl.Object.constructor;
+ Efl.Object.destructor;
+ Efl.Animation.target { set; }
+ Efl.Animation.duration { set; }
+ Efl.Animation.final_state_keep { set; }
+ }
+}
--- /dev/null
+#define EFL_ANIMATION_PROTECTED
+
+#include "evas_common_private.h"
+
+#define MY_CLASS EFL_ANIMATION_GROUP_CLASS
+#define MY_CLASS_NAME efl_class_name_get(MY_CLASS)
+
+#define EFL_ANIMATION_GROUP_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_GROUP_DATA_GET(o, pd) \
+ Efl_Animation_Group_Data *pd = efl_data_scope_get(o, EFL_ANIMATION_GROUP_CLASS)
+
+typedef struct _Efl_Animation_Group_Data
+{
+ Eina_List *animations;
+} Efl_Animation_Group_Data;
{
EFL_ANIMATION_OBJECT_CHECK_OR_RETURN(eo_obj);
+ efl_animation_object_total_duration_set(eo_obj, duration);
+
pd->duration = duration;
}
return pd->duration;
}
+EOLIAN static void
+_efl_animation_object_duration_only_set(Eo *eo_obj,
+ Efl_Animation_Object_Data *pd,
+ double duration)
+{
+ EFL_ANIMATION_OBJECT_CHECK_OR_RETURN(eo_obj);
+
+ pd->duration = duration;
+}
+
+EOLIAN static void
+_efl_animation_object_total_duration_set(Eo *eo_obj,
+ Efl_Animation_Object_Data *pd,
+ double total_duration)
+{
+ EFL_ANIMATION_OBJECT_CHECK_OR_RETURN(eo_obj);
+
+ pd->total_duration = total_duration;
+}
+
+EOLIAN static double
+_efl_animation_object_total_duration_get(Eo *eo_obj, Efl_Animation_Object_Data *pd)
+{
+ EFL_ANIMATION_OBJECT_CHECK_OR_RETURN(eo_obj, 0.0);
+
+ return pd->total_duration;
+}
+
EOLIAN static Eina_Bool
_efl_animation_object_is_deleted(Eo *eo_obj,
Efl_Animation_Object_Data *pd)
if (pd->is_cancelled) goto end;
- double elapsed_time, duration;
+ double elapsed_time, total_duration;
pd->time.current = ecore_loop_time_get();
elapsed_time = pd->time.current - pd->time.begin;
- duration = pd->duration;
- if (elapsed_time > duration)
- elapsed_time = duration;
+ total_duration = pd->total_duration;
+ if (elapsed_time > total_duration)
+ elapsed_time = total_duration;
- if (duration < 0.0) goto end;
+ if (total_duration < 0.0) goto end;
- if (duration == 0.0)
+ if (total_duration == 0.0)
{
ecore_animator_del(pd->animator);
pd->animator = NULL;
pd->progress = 1.0;
}
else
- pd->progress = elapsed_time / duration;
+ pd->progress = elapsed_time / total_duration;
//Reset previous animation effect before applying animation effect
efl_animation_object_target_state_reset(eo_obj);
efl_animation_object_progress_set(eo_obj, pd->progress);
//Not end. Keep going.
- if (elapsed_time < duration) return ECORE_CALLBACK_RENEW;
+ if (elapsed_time < total_duration) return ECORE_CALLBACK_RENEW;
end:
pd->animator = NULL;
static void
_start(Eo *eo_obj, Efl_Animation_Object_Data *pd)
{
- if (pd->duration < 0.0) return;
+ if (pd->total_duration < 0.0) return;
//Save the current state of the target
efl_animation_object_target_state_save(eo_obj);
pd->progress = 0.0;
pd->duration = 0.0;
+ pd->total_duration = 0.0;
pd->auto_del = EINA_TRUE;
pd->is_deleted = EINA_FALSE;
EOAPI EFL_VOID_FUNC_BODYV(efl_animation_object_duration_set, EFL_FUNC_CALL(duration), double duration);
EOAPI EFL_FUNC_BODY_CONST(efl_animation_object_duration_get, double, 0);
+EOAPI EFL_VOID_FUNC_BODYV(efl_animation_object_duration_only_set, EFL_FUNC_CALL(duration), double duration);
+
+EOAPI EFL_VOID_FUNC_BODYV(efl_animation_object_total_duration_set, EFL_FUNC_CALL(total_duration), double total_duration);
+EOAPI EFL_FUNC_BODY_CONST(efl_animation_object_total_duration_get, double, 0);
+
#define EFL_ANIMATION_OBJECT_EXTRA_OPS \
EFL_OBJECT_OP_FUNC(efl_animation_object_target_set, _efl_animation_object_target_set), \
EFL_OBJECT_OP_FUNC(efl_animation_object_target_get, _efl_animation_object_target_get), \
EFL_OBJECT_OP_FUNC(efl_animation_object_final_state_keep_set, _efl_animation_object_final_state_keep_set), \
EFL_OBJECT_OP_FUNC(efl_animation_object_final_state_keep_get, _efl_animation_object_final_state_keep_get), \
EFL_OBJECT_OP_FUNC(efl_animation_object_duration_set, _efl_animation_object_duration_set), \
- EFL_OBJECT_OP_FUNC(efl_animation_object_duration_get, _efl_animation_object_duration_get)
+ EFL_OBJECT_OP_FUNC(efl_animation_object_duration_get, _efl_animation_object_duration_get), \
+ EFL_OBJECT_OP_FUNC(efl_animation_object_duration_only_set, _efl_animation_object_duration_only_set), \
+ EFL_OBJECT_OP_FUNC(efl_animation_object_total_duration_set, _efl_animation_object_total_duration_set), \
+ EFL_OBJECT_OP_FUNC(efl_animation_object_total_duration_get, _efl_animation_object_total_duration_get)
EWAPI const Efl_Event_Description _EFL_ANIMATION_OBJECT_EVENT_PRE_STARTED =
EFL_EVENT_DESCRIPTION("pre_started");
double progress;
double duration;
+ double total_duration;
Eina_Bool auto_del : 1;
Eina_Bool is_deleted : 1;
Efl_Canvas_Object *target;
double duration;
+ double total_duration;
Eina_Bool is_deleted : 1;
Eina_Bool keep_final_state : 1;
double duration = efl_animation_duration_get(eo_obj);
efl_animation_object_duration_set(anim_obj, duration);
+ double total_duration = efl_animation_total_duration_get(eo_obj);
+ efl_animation_object_total_duration_set(anim_obj, total_duration);
+
if (pd->use_rel_pivot)
{
efl_animation_object_rotate_set(anim_obj,
double duration = efl_animation_duration_get(eo_obj);
efl_animation_object_duration_set(anim_obj, duration);
+ double total_duration = efl_animation_total_duration_get(eo_obj);
+ efl_animation_object_total_duration_set(anim_obj, total_duration);
+
if (pd->use_rel_pivot)
{
efl_animation_object_scale_set(anim_obj,
double duration = efl_animation_duration_get(eo_obj);
efl_animation_object_duration_set(anim_obj, duration);
+ double total_duration = efl_animation_total_duration_get(eo_obj);
+ efl_animation_object_total_duration_set(anim_obj, total_duration);
+
if (pd->use_rel_move)
{
efl_animation_object_translate_set(anim_obj,