summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaehyun Cho <jae_hyun.cho@samsung.com>2017-09-05 11:33:58 +0900
committerJaehyun Cho <jae_hyun.cho@samsung.com>2017-09-18 20:49:34 +0900
commitcf58e61e4d1468d0171e42635a4054d4b25db56d (patch)
treed3d0b33acaa7cdb355009492a96fa17f488f6c9f
parent1931ea7e5cc45ec85d0a6a3d7f50354c627c32ed (diff)
downloadefl-cf58e61e4d1468d0171e42635a4054d4b25db56d.tar.gz
efl_animation: Add repeat_mode property
To not display original state when the reverse repeat starts, the animators in group parallel and group sequential are deleted.
-rw-r--r--src/lib/evas/Evas_Internal.h9
-rw-r--r--src/lib/evas/canvas/efl_animation.c21
-rw-r--r--src/lib/evas/canvas/efl_animation.eo9
-rw-r--r--src/lib/evas/canvas/efl_animation_alpha.c4
-rw-r--r--src/lib/evas/canvas/efl_animation_group_parallel.c4
-rw-r--r--src/lib/evas/canvas/efl_animation_group_sequential.c4
-rw-r--r--src/lib/evas/canvas/efl_animation_instance.c34
-rw-r--r--src/lib/evas/canvas/efl_animation_instance_group_parallel.c19
-rw-r--r--src/lib/evas/canvas/efl_animation_instance_group_sequential.c25
-rw-r--r--src/lib/evas/canvas/efl_animation_instance_private.h36
-rw-r--r--src/lib/evas/canvas/efl_animation_private.h15
-rw-r--r--src/lib/evas/canvas/efl_animation_rotate.c4
-rw-r--r--src/lib/evas/canvas/efl_animation_scale.c4
-rw-r--r--src/lib/evas/canvas/efl_animation_translate.c4
-rw-r--r--src/lib/evas/canvas/efl_animation_types.eot8
15 files changed, 173 insertions, 27 deletions
diff --git a/src/lib/evas/Evas_Internal.h b/src/lib/evas/Evas_Internal.h
index d48c4ac9a6..e94675e20f 100644
--- a/src/lib/evas/Evas_Internal.h
+++ b/src/lib/evas/Evas_Internal.h
@@ -90,6 +90,15 @@ EOAPI double efl_animation_instance_total_duration_get(const Eo *obj);
EOAPI void efl_animation_instance_start_delay_set(Eo *obj, double delay_time);
EOAPI double efl_animation_instance_start_delay_get(const Eo *obj);
+typedef enum
+{
+ EFL_ANIMATION_INSTANCE_REPEAT_MODE_RESTART = 0,
+ EFL_ANIMATION_INSTANCE_REPEAT_MODE_REVERSE
+} Efl_Animation_Instance_Repeat_Mode;
+
+EOAPI void efl_animation_instance_repeat_mode_set(Eo *obj, Efl_Animation_Instance_Repeat_Mode mode);
+EOAPI Efl_Animation_Instance_Repeat_Mode efl_animation_instance_repeat_mode_get(const Eo *obj);
+
EOAPI void efl_animation_instance_repeat_count_set(Eo *obj, int count);
EOAPI int efl_animation_instance_repeat_count_get(const Eo *obj);
diff --git a/src/lib/evas/canvas/efl_animation.c b/src/lib/evas/canvas/efl_animation.c
index b6a8b9f2ce..c85b9157ab 100644
--- a/src/lib/evas/canvas/efl_animation.c
+++ b/src/lib/evas/canvas/efl_animation.c
@@ -96,6 +96,27 @@ _efl_animation_final_state_keep_get(Eo *eo_obj, Efl_Animation_Data *pd)
}
EOLIAN static void
+_efl_animation_repeat_mode_set(Eo *eo_obj,
+ Efl_Animation_Data *pd,
+ Efl_Animation_Repeat_Mode mode)
+{
+ EFL_ANIMATION_CHECK_OR_RETURN(eo_obj);
+
+ if ((mode == EFL_ANIMATION_REPEAT_MODE_RESTART) ||
+ (mode == EFL_ANIMATION_REPEAT_MODE_REVERSE))
+ pd->repeat_mode = mode;
+}
+
+EOLIAN static Efl_Animation_Repeat_Mode
+_efl_animation_repeat_mode_get(Eo *eo_obj, Efl_Animation_Data *pd)
+{
+ EFL_ANIMATION_CHECK_OR_RETURN(eo_obj,
+ EFL_ANIMATION_REPEAT_MODE_RESTART);
+
+ return pd->repeat_mode;
+}
+
+EOLIAN static void
_efl_animation_repeat_count_set(Eo *eo_obj,
Efl_Animation_Data *pd,
int count)
diff --git a/src/lib/evas/canvas/efl_animation.eo b/src/lib/evas/canvas/efl_animation.eo
index 5243b0639e..a23d29477f 100644
--- a/src/lib/evas/canvas/efl_animation.eo
+++ b/src/lib/evas/canvas/efl_animation.eo
@@ -41,6 +41,15 @@ abstract Efl.Animation (Efl.Object)
total_duration: double; [[Total duration value.]]
}
}
+ @property repeat_mode {
+ set {
+ }
+ get {
+ }
+ values {
+ mode: Efl.Animation.Repeat_Mode; [[Repeat mode. EFL_ANIMATION_REPEAT_MODE_RESTART restarts animation when the animation ends and EFL_ANIMATION_REPEAT_MODE_REVERSE reverses animation when the animation ends.]]
+ }
+ }
@property repeat_count {
set {
}
diff --git a/src/lib/evas/canvas/efl_animation_alpha.c b/src/lib/evas/canvas/efl_animation_alpha.c
index b8e91b4949..0a85d806ef 100644
--- a/src/lib/evas/canvas/efl_animation_alpha.c
+++ b/src/lib/evas/canvas/efl_animation_alpha.c
@@ -66,6 +66,10 @@ _efl_animation_alpha_efl_animation_instance_create(Eo *eo_obj,
double start_delay_time = efl_animation_start_delay_get(eo_obj);
efl_animation_instance_start_delay_set(instance, start_delay_time);
+ Efl_Animation_Instance_Repeat_Mode repeat_mode =
+ (Efl_Animation_Instance_Repeat_Mode)efl_animation_repeat_mode_get(eo_obj);
+ efl_animation_instance_repeat_mode_set(instance, repeat_mode);
+
int repeat_count = efl_animation_repeat_count_get(eo_obj);
efl_animation_instance_repeat_count_set(instance, repeat_count);
diff --git a/src/lib/evas/canvas/efl_animation_group_parallel.c b/src/lib/evas/canvas/efl_animation_group_parallel.c
index 14bf3086b6..c75ecac46c 100644
--- a/src/lib/evas/canvas/efl_animation_group_parallel.c
+++ b/src/lib/evas/canvas/efl_animation_group_parallel.c
@@ -109,6 +109,10 @@ _efl_animation_group_parallel_efl_animation_instance_create(Eo *eo_obj,
double start_delay_time = efl_animation_start_delay_get(eo_obj);
efl_animation_instance_start_delay_set(group_inst, start_delay_time);
+ Efl_Animation_Instance_Repeat_Mode repeat_mode =
+ (Efl_Animation_Instance_Repeat_Mode)efl_animation_repeat_mode_get(eo_obj);
+ efl_animation_instance_repeat_mode_set(group_inst, repeat_mode);
+
int repeat_count = efl_animation_repeat_count_get(eo_obj);
efl_animation_instance_repeat_count_set(group_inst, repeat_count);
diff --git a/src/lib/evas/canvas/efl_animation_group_sequential.c b/src/lib/evas/canvas/efl_animation_group_sequential.c
index 9becc66fc0..3fba219388 100644
--- a/src/lib/evas/canvas/efl_animation_group_sequential.c
+++ b/src/lib/evas/canvas/efl_animation_group_sequential.c
@@ -108,6 +108,10 @@ _efl_animation_group_sequential_efl_animation_instance_create(Eo *eo_obj,
double start_delay_time = efl_animation_start_delay_get(eo_obj);
efl_animation_instance_start_delay_set(group_inst, start_delay_time);
+ Efl_Animation_Instance_Repeat_Mode repeat_mode =
+ (Efl_Animation_Instance_Repeat_Mode)efl_animation_repeat_mode_get(eo_obj);
+ efl_animation_instance_repeat_mode_set(group_inst, repeat_mode);
+
int repeat_count = efl_animation_repeat_count_get(eo_obj);
efl_animation_instance_repeat_count_set(group_inst, repeat_count);
diff --git a/src/lib/evas/canvas/efl_animation_instance.c b/src/lib/evas/canvas/efl_animation_instance.c
index f74bced08b..f941d4031e 100644
--- a/src/lib/evas/canvas/efl_animation_instance.c
+++ b/src/lib/evas/canvas/efl_animation_instance.c
@@ -75,6 +75,27 @@ _efl_animation_instance_total_duration_get(Eo *eo_obj, Efl_Animation_Instance_Da
}
EOLIAN static void
+_efl_animation_instance_repeat_mode_set(Eo *eo_obj,
+ Efl_Animation_Instance_Data *pd,
+ Efl_Animation_Instance_Repeat_Mode mode)
+{
+ EFL_ANIMATION_INSTANCE_CHECK_OR_RETURN(eo_obj);
+
+ if ((mode == EFL_ANIMATION_INSTANCE_REPEAT_MODE_RESTART) ||
+ (mode == EFL_ANIMATION_INSTANCE_REPEAT_MODE_REVERSE))
+ pd->repeat_mode = mode;
+}
+
+EOLIAN static Efl_Animation_Instance_Repeat_Mode
+_efl_animation_instance_repeat_mode_get(const Eo *eo_obj,
+ Efl_Animation_Instance_Data *pd)
+{
+ EFL_ANIMATION_INSTANCE_CHECK_OR_RETURN((Eo *)eo_obj, EFL_ANIMATION_INSTANCE_REPEAT_MODE_RESTART);
+
+ return pd->repeat_mode;
+}
+
+EOLIAN static void
_efl_animation_instance_repeat_count_set(Eo *eo_obj,
Efl_Animation_Instance_Data *pd,
int count)
@@ -259,6 +280,9 @@ _animator_cb(void *data)
else
pd->progress = (elapsed_time - paused_time) / total_duration;
+ if (!pd->is_direction_forward)
+ pd->progress = 1.0 - pd->progress;
+
Efl_Animation_Instance_Animate_Event_Info event_info;
event_info.progress = pd->progress;
@@ -293,6 +317,9 @@ end:
pd->time.begin = ecore_loop_time_get();
pd->paused_time = 0.0;
+ if (pd->repeat_mode == EFL_ANIMATION_INSTANCE_REPEAT_MODE_REVERSE)
+ pd->is_direction_forward = !pd->is_direction_forward;
+
efl_animation_instance_target_state_reset(eo_obj);
return ECORE_CALLBACK_RENEW;
@@ -320,6 +347,7 @@ _init_start(Eo *eo_obj, Efl_Animation_Instance_Data *pd)
pd->is_started = EINA_TRUE;
pd->is_cancelled = EINA_FALSE;
pd->is_ended = EINA_FALSE;
+ pd->is_direction_forward = EINA_TRUE;
pd->paused_time = 0.0;
@@ -469,6 +497,7 @@ _efl_animation_instance_efl_object_constructor(Eo *eo_obj,
pd->duration = 0.0;
pd->total_duration = 0.0;
+ pd->repeat_mode = EFL_ANIMATION_INSTANCE_REPEAT_MODE_RESTART;
pd->repeat_count = 0;
pd->is_deleted = EINA_FALSE;
@@ -522,6 +551,9 @@ EOAPI EFL_FUNC_BODY_CONST(efl_animation_instance_total_duration_get, double, 0);
EOAPI EFL_VOID_FUNC_BODYV(efl_animation_instance_start_delay_set, EFL_FUNC_CALL(delay_time), double delay_time);
EOAPI EFL_FUNC_BODY_CONST(efl_animation_instance_start_delay_get, double, 0);
+EOAPI EFL_VOID_FUNC_BODYV(efl_animation_instance_repeat_mode_set, EFL_FUNC_CALL(mode), Efl_Animation_Instance_Repeat_Mode mode);
+EOAPI EFL_FUNC_BODY_CONST(efl_animation_instance_repeat_mode_get, Efl_Animation_Instance_Repeat_Mode, 0);
+
EOAPI EFL_VOID_FUNC_BODYV(efl_animation_instance_repeat_count_set, EFL_FUNC_CALL(count), int count);
EOAPI EFL_FUNC_BODY_CONST(efl_animation_instance_repeat_count_get, int, 0);
@@ -536,6 +568,8 @@ EOAPI EFL_FUNC_BODY_CONST(efl_animation_instance_repeat_count_get, int, 0);
EFL_OBJECT_OP_FUNC(efl_animation_instance_total_duration_get, _efl_animation_instance_total_duration_get), \
EFL_OBJECT_OP_FUNC(efl_animation_instance_start_delay_set, _efl_animation_instance_start_delay_set), \
EFL_OBJECT_OP_FUNC(efl_animation_instance_start_delay_get, _efl_animation_instance_start_delay_get), \
+ EFL_OBJECT_OP_FUNC(efl_animation_instance_repeat_mode_set, _efl_animation_instance_repeat_mode_set), \
+ EFL_OBJECT_OP_FUNC(efl_animation_instance_repeat_mode_get, _efl_animation_instance_repeat_mode_get), \
EFL_OBJECT_OP_FUNC(efl_animation_instance_repeat_count_set, _efl_animation_instance_repeat_count_set), \
EFL_OBJECT_OP_FUNC(efl_animation_instance_repeat_count_get, _efl_animation_instance_repeat_count_get)
diff --git a/src/lib/evas/canvas/efl_animation_instance_group_parallel.c b/src/lib/evas/canvas/efl_animation_instance_group_parallel.c
index 7e565e8d0c..fa6fcfcf33 100644
--- a/src/lib/evas/canvas/efl_animation_instance_group_parallel.c
+++ b/src/lib/evas/canvas/efl_animation_instance_group_parallel.c
@@ -185,6 +185,8 @@ _efl_animation_instance_group_parallel_efl_animation_instance_progress_set(Eo *e
double start_delay = efl_animation_instance_start_delay_get(inst);
double inst_progress;
+ Eina_Bool start_repeat = EINA_FALSE;
+
if (total_duration == 0.0)
inst_progress = 1.0;
else
@@ -221,11 +223,28 @@ _efl_animation_instance_group_parallel_efl_animation_instance_progress_set(Eo *e
{
repeated_count++;
_repeated_count_set(pd, inst, repeated_count);
+
+ start_repeat = EINA_TRUE;
}
}
}
}
+ /* If instance is repeated with reverse mode, then the progress value
+ * should be modified as (1.0 - progress). */
+ Efl_Animation_Instance_Repeat_Mode repeat_mode
+ = efl_animation_instance_repeat_mode_get(inst);
+ if (repeat_mode == EFL_ANIMATION_INSTANCE_REPEAT_MODE_REVERSE)
+ {
+ int repeated_count = _repeated_count_get(pd, inst);
+ if (repeated_count > 0)
+ {
+ if ((((repeated_count % 2) == 1) && (!start_repeat)) ||
+ (((repeated_count % 2) == 0) && (start_repeat)))
+ inst_progress = 1.0 - inst_progress;
+ }
+ }
+
efl_animation_instance_progress_set(inst, inst_progress);
}
}
diff --git a/src/lib/evas/canvas/efl_animation_instance_group_sequential.c b/src/lib/evas/canvas/efl_animation_instance_group_sequential.c
index 2d42a90bcb..248bd31b1f 100644
--- a/src/lib/evas/canvas/efl_animation_instance_group_sequential.c
+++ b/src/lib/evas/canvas/efl_animation_instance_group_sequential.c
@@ -177,6 +177,7 @@ _efl_animation_instance_group_sequential_efl_animation_instance_progress_set(Eo
double elapsed_time = progress * group_total_duration;
double sum_prev_total_duration = 0.0;
+
Eina_List *l;
Efl_Animation_Instance *inst;
EINA_LIST_FOREACH(instances, l, inst)
@@ -187,9 +188,10 @@ _efl_animation_instance_group_sequential_efl_animation_instance_progress_set(Eo
//Sum the current total duration
double total_duration = efl_animation_instance_total_duration_get(inst);
double start_delay = efl_animation_instance_start_delay_get(inst);
-
double inst_progress;
+ Eina_Bool start_repeat = EINA_FALSE;
+
if (total_duration == 0.0)
inst_progress = 1.0;
else
@@ -225,6 +227,8 @@ _efl_animation_instance_group_sequential_efl_animation_instance_progress_set(Eo
{
repeated_count++;
_repeated_count_set(pd, inst, repeated_count);
+
+ start_repeat = EINA_TRUE;
}
}
}
@@ -234,10 +238,25 @@ _efl_animation_instance_group_sequential_efl_animation_instance_progress_set(Eo
* delays */
sum_prev_total_duration += (total_duration + start_delay);
- if ((inst_progress == 1.0) &&
- !efl_animation_instance_final_state_keep_get(inst))
+ if ((inst_progress == 1.0) && (!start_repeat) &&
+ (!efl_animation_instance_final_state_keep_get(inst)))
continue;
+ /* If instance is repeated with reverse mode, then the progress value
+ * should be modified as (1.0 - progress). */
+ Efl_Animation_Instance_Repeat_Mode repeat_mode
+ = efl_animation_instance_repeat_mode_get(inst);
+ if (repeat_mode == EFL_ANIMATION_INSTANCE_REPEAT_MODE_REVERSE)
+ {
+ int repeated_count = _repeated_count_get(pd, inst);
+ if (repeated_count > 0)
+ {
+ if ((((repeated_count % 2) == 1) && (!start_repeat)) ||
+ (((repeated_count % 2) == 0) && (start_repeat)))
+ inst_progress = 1.0 - inst_progress;
+ }
+ }
+
efl_animation_instance_progress_set(inst, inst_progress);
}
}
diff --git a/src/lib/evas/canvas/efl_animation_instance_private.h b/src/lib/evas/canvas/efl_animation_instance_private.h
index f896d014c6..c470dc7bae 100644
--- a/src/lib/evas/canvas/efl_animation_instance_private.h
+++ b/src/lib/evas/canvas/efl_animation_instance_private.h
@@ -17,10 +17,10 @@ typedef struct _Target_State
typedef struct _Efl_Animation_Instance_Data
{
- Ecore_Animator *animator;
+ Ecore_Animator *animator;
- Ecore_Timer *start_delay_timer;
- double start_delay_time;
+ Ecore_Timer *start_delay_timer;
+ double start_delay_time;
struct
{
@@ -29,24 +29,26 @@ typedef struct _Efl_Animation_Instance_Data
double pause_begin;
} time;
- Efl_Canvas_Object *target;
- Target_State *target_state;
+ Efl_Canvas_Object *target;
+ Target_State *target_state;
- double progress;
+ double progress;
- double duration;
- double total_duration;
- double paused_time;
+ double duration;
+ double total_duration;
+ double paused_time;
- int repeat_count;
- int remaining_repeat_count;
+ Efl_Animation_Instance_Repeat_Mode repeat_mode;
+ int repeat_count;
+ int remaining_repeat_count;
- Eina_Bool is_deleted : 1;
- Eina_Bool is_started : 1;
- Eina_Bool is_cancelled : 1;
- Eina_Bool is_ended : 1;
- Eina_Bool is_paused : 1;
- Eina_Bool keep_final_state : 1;
+ Eina_Bool is_deleted : 1;
+ Eina_Bool is_started : 1;
+ Eina_Bool is_cancelled : 1;
+ Eina_Bool is_ended : 1;
+ Eina_Bool is_paused : 1;
+ Eina_Bool keep_final_state : 1;
+ Eina_Bool is_direction_forward : 1;
} Efl_Animation_Instance_Data;
#define EFL_ANIMATION_INSTANCE_CHECK_OR_RETURN(inst, ...) \
diff --git a/src/lib/evas/canvas/efl_animation_private.h b/src/lib/evas/canvas/efl_animation_private.h
index 6c993f4bd3..1cd84d2a59 100644
--- a/src/lib/evas/canvas/efl_animation_private.h
+++ b/src/lib/evas/canvas/efl_animation_private.h
@@ -7,17 +7,18 @@
typedef struct _Efl_Animation_Data
{
- Efl_Canvas_Object *target;
+ Efl_Canvas_Object *target;
- double duration;
- double total_duration;
+ double duration;
+ double total_duration;
- double start_delay_time;
+ double start_delay_time;
- int repeat_count;
+ Efl_Animation_Repeat_Mode repeat_mode;
+ int repeat_count;
- Eina_Bool is_deleted : 1;
- Eina_Bool keep_final_state : 1;
+ Eina_Bool is_deleted : 1;
+ Eina_Bool keep_final_state : 1;
} Efl_Animation_Data;
#define EFL_ANIMATION_CHECK_OR_RETURN(anim, ...) \
diff --git a/src/lib/evas/canvas/efl_animation_rotate.c b/src/lib/evas/canvas/efl_animation_rotate.c
index 4540e88081..3b684437a8 100644
--- a/src/lib/evas/canvas/efl_animation_rotate.c
+++ b/src/lib/evas/canvas/efl_animation_rotate.c
@@ -214,6 +214,10 @@ _efl_animation_rotate_efl_animation_instance_create(Eo *eo_obj,
double start_delay_time = efl_animation_start_delay_get(eo_obj);
efl_animation_instance_start_delay_set(instance, start_delay_time);
+ Efl_Animation_Instance_Repeat_Mode repeat_mode =
+ (Efl_Animation_Instance_Repeat_Mode)efl_animation_repeat_mode_get(eo_obj);
+ efl_animation_instance_repeat_mode_set(instance, repeat_mode);
+
int repeat_count = efl_animation_repeat_count_get(eo_obj);
efl_animation_instance_repeat_count_set(instance, repeat_count);
diff --git a/src/lib/evas/canvas/efl_animation_scale.c b/src/lib/evas/canvas/efl_animation_scale.c
index d97117b274..1cf60bc81e 100644
--- a/src/lib/evas/canvas/efl_animation_scale.c
+++ b/src/lib/evas/canvas/efl_animation_scale.c
@@ -240,6 +240,10 @@ _efl_animation_scale_efl_animation_instance_create(Eo *eo_obj,
double start_delay_time = efl_animation_start_delay_get(eo_obj);
efl_animation_instance_start_delay_set(instance, start_delay_time);
+ Efl_Animation_Instance_Repeat_Mode repeat_mode =
+ (Efl_Animation_Instance_Repeat_Mode)efl_animation_repeat_mode_get(eo_obj);
+ efl_animation_instance_repeat_mode_set(instance, repeat_mode);
+
int repeat_count = efl_animation_repeat_count_get(eo_obj);
efl_animation_instance_repeat_count_set(instance, repeat_count);
diff --git a/src/lib/evas/canvas/efl_animation_translate.c b/src/lib/evas/canvas/efl_animation_translate.c
index a9ccbf006e..d1c7b734a2 100644
--- a/src/lib/evas/canvas/efl_animation_translate.c
+++ b/src/lib/evas/canvas/efl_animation_translate.c
@@ -182,6 +182,10 @@ _efl_animation_translate_efl_animation_instance_create(Eo *eo_obj,
double start_delay_time = efl_animation_start_delay_get(eo_obj);
efl_animation_instance_start_delay_set(instance, start_delay_time);
+ Efl_Animation_Instance_Repeat_Mode repeat_mode =
+ (Efl_Animation_Instance_Repeat_Mode)efl_animation_repeat_mode_get(eo_obj);
+ efl_animation_instance_repeat_mode_set(instance, repeat_mode);
+
int repeat_count = efl_animation_repeat_count_get(eo_obj);
efl_animation_instance_repeat_count_set(instance, repeat_count);
diff --git a/src/lib/evas/canvas/efl_animation_types.eot b/src/lib/evas/canvas/efl_animation_types.eot
index 53da8c6d3c..d48723377a 100644
--- a/src/lib/evas/canvas/efl_animation_types.eot
+++ b/src/lib/evas/canvas/efl_animation_types.eot
@@ -11,3 +11,11 @@ enum Efl.Animation.Event_Type
hide = 1, [["hide" event type]]
clicked = 2 [["clicked" event type]]
}
+
+enum Efl.Animation.Repeat_Mode
+{
+ [[Animation repeat mode]]
+
+ restart = 0, [[Restart animation when the animation ends.]]
+ reverse [[Reverse animation when the animation ends.]]
+}