summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaehyun Cho <jae_hyun.cho@samsung.com>2017-07-14 10:28:19 +0900
committerJaehyun Cho <jae_hyun.cho@samsung.com>2017-08-18 12:06:01 +0900
commit0edfa0b06ac8d3197831205e90be1a445b3601d6 (patch)
tree07954ae910944c34985a9dd1bf6dcb66e4e0878c
parentc933deacdebb0a61cbbc68cb5cbd13601fdcb2ec (diff)
downloadefl-0edfa0b06ac8d3197831205e90be1a445b3601d6.tar.gz
efl_animation: Show end state of animation if duration is 0
If the duration is 0, then the end state of the animation is displayed and the animation ends. Use animator to start next member instance in group sequence instance. Because without animator, the "end" event of the next member instance happens before the "end" event of the current member instance happens.
-rw-r--r--src/lib/evas/canvas/efl_animation.c3
-rw-r--r--src/lib/evas/canvas/efl_animation_group.c3
-rw-r--r--src/lib/evas/canvas/efl_animation_instance.c17
-rw-r--r--src/lib/evas/canvas/efl_animation_instance_group.c3
-rw-r--r--src/lib/evas/canvas/efl_animation_instance_group_sequential.c32
5 files changed, 44 insertions, 14 deletions
diff --git a/src/lib/evas/canvas/efl_animation.c b/src/lib/evas/canvas/efl_animation.c
index a19b9d2387..24a63499c2 100644
--- a/src/lib/evas/canvas/efl_animation.c
+++ b/src/lib/evas/canvas/efl_animation.c
@@ -77,7 +77,8 @@ _efl_animation_duration_set(Eo *eo_obj,
{
EFL_ANIMATION_CHECK_OR_RETURN(eo_obj);
- if (duration <= 0.0) return;
+ //If duration is 0, then display the end state of animation
+ if (duration < 0.0) return;
pd->duration = duration;
}
diff --git a/src/lib/evas/canvas/efl_animation_group.c b/src/lib/evas/canvas/efl_animation_group.c
index a50f83bed4..7085e1df43 100644
--- a/src/lib/evas/canvas/efl_animation_group.c
+++ b/src/lib/evas/canvas/efl_animation_group.c
@@ -92,7 +92,8 @@ _efl_animation_group_efl_animation_duration_set(Eo *eo_obj,
{
EFL_ANIMATION_GROUP_CHECK_OR_RETURN(eo_obj);
- if (duration <= 0.0) duration = 0.0;
+ //If duration is 0, then display the end state of animation
+ if (duration < 0.0) return;
Eina_List *l;
Efl_Animation *anim;
diff --git a/src/lib/evas/canvas/efl_animation_instance.c b/src/lib/evas/canvas/efl_animation_instance.c
index 9b6f357eb9..38e4fcf074 100644
--- a/src/lib/evas/canvas/efl_animation_instance.c
+++ b/src/lib/evas/canvas/efl_animation_instance.c
@@ -103,7 +103,8 @@ _efl_animation_instance_duration_set(Eo *eo_obj,
{
EFL_ANIMATION_INSTANCE_CHECK_OR_RETURN(eo_obj);
- if (duration <= 0.0) return;
+ //If duration is 0, then show the end state of the animation.
+ if (duration < 0.0) return;
pd->duration = duration;
}
@@ -193,13 +194,21 @@ _animator_cb(void *data)
if (pd->cancelled) goto end;
double duration = pd->duration;
- if (duration <= 0.0) goto end;
+
+ //If duration is 0, then show the end state of the animation.
+ //Therefore, the animator should not be called again.
+ if (duration == 0.0)
+ {
+ ecore_animator_del(pd->animator);
+ pd->animator = NULL;
+ }
pd->time.current = ecore_loop_time_get();
double elapsed_time = pd->time.current - pd->time.begin;
double paused_time = pd->paused_time;
- if ((elapsed_time - paused_time) > duration)
+ //If duration is 0, then show the end state of the animation.
+ if ((duration == 0.0) || ((elapsed_time - paused_time) > duration))
{
elapsed_time = duration + paused_time;
pd->progress = 1.0;
@@ -244,8 +253,6 @@ end:
static void
_start(Eo *eo_obj, Evas_Object_Animation_Instance_Data *pd)
{
- if (pd->duration <= 0.0) return;
-
//Resume animation if animation is paused
if (pd->paused)
{
diff --git a/src/lib/evas/canvas/efl_animation_instance_group.c b/src/lib/evas/canvas/efl_animation_instance_group.c
index 3fdacc6133..341b8f29b3 100644
--- a/src/lib/evas/canvas/efl_animation_instance_group.c
+++ b/src/lib/evas/canvas/efl_animation_instance_group.c
@@ -93,7 +93,8 @@ _efl_animation_instance_group_efl_animation_instance_duration_set(Eo *eo_obj,
{
EFL_ANIMATION_INSTANCE_GROUP_CHECK_OR_RETURN(eo_obj);
- if (duration <= 0.0) duration = 0.0;
+ //If duration is 0, then display the end state of animation
+ if (duration < 0.0) return;
Eina_List *l;
Efl_Animation_Instance *inst;
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 ead54d3a99..d90fe718dc 100644
--- a/src/lib/evas/canvas/efl_animation_instance_group_sequential.c
+++ b/src/lib/evas/canvas/efl_animation_instance_group_sequential.c
@@ -1,5 +1,6 @@
#include "evas_common_private.h"
#include "evas_private.h"
+#include <Ecore.h>
#define MY_CLASS EFL_ANIMATION_INSTANCE_GROUP_SEQUENTIAL_CLASS
#define MY_CLASS_NAME efl_class_name_get(MY_CLASS)
@@ -21,13 +22,15 @@
struct _Evas_Object_Animation_Instance_Group_Sequential_Data
{
- unsigned int current_index;
+ Ecore_Animator *start_animator;
- Eina_List *finished_inst_list;
+ unsigned int current_index;
- Eina_Bool started : 1;
- Eina_Bool paused : 1;
- Eina_Bool is_group_member : 1;
+ Eina_List *finished_inst_list;
+
+ Eina_Bool started : 1;
+ Eina_Bool paused : 1;
+ Eina_Bool is_group_member : 1;
};
static void _index_animation_start(Eo *eo_obj, int index);
@@ -60,6 +63,20 @@ _pre_animate_cb(void *data, const Efl_Event *event)
}
}
+static Eina_Bool
+_start_animator_cb(void *data)
+{
+ Eo *eo_obj = data;
+
+ EFL_ANIMATION_INSTANCE_GROUP_SEQUENTIAL_DATA_GET(eo_obj, pd);
+
+ _index_animation_start(eo_obj, pd->current_index);
+
+ pd->start_animator = NULL;
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
static void
_post_end_cb(void *data, const Efl_Event *event)
{
@@ -93,7 +110,7 @@ _post_end_cb(void *data, const Efl_Event *event)
return;
}
- _index_animation_start(eo_obj, pd->current_index);
+ pd->start_animator = ecore_animator_add(_start_animator_cb, eo_obj);
}
static void
@@ -130,6 +147,9 @@ _index_animation_start(Eo *eo_obj, int index)
static void
_start(Eo *eo_obj, Evas_Object_Animation_Instance_Group_Sequential_Data *pd)
{
+ ecore_animator_del(pd->start_animator);
+ pd->start_animator = NULL;
+
pd->current_index = 0;
pd->started = EINA_TRUE;