Efl_Animation *hide_anim;
Efl_Animation_Object *anim_obj;
+ Evas_Object *start_btn;
Evas_Object *repeat_count_spin;
+ Evas_Object *repeat_mode_spin;
Eina_Bool is_btn_visible;
} App_Data;
+Efl_Animation_Repeat_Mode
+_anim_repeat_mode_get(Evas_Object *spinner)
+{
+ int value = elm_spinner_value_get(spinner);
+
+ if (value == 0)
+ return EFL_ANIMATION_REPEAT_MODE_RESTART;
+ else
+ return EFL_ANIMATION_REPEAT_MODE_REVERSE;
+}
+
static void
_anim_started_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
{
printf("Animation has been ended!\n");
+ Efl_Animation_Repeat_Mode repeat_mode = _anim_repeat_mode_get(ad->repeat_mode_spin);
+ if (repeat_mode == EFL_ANIMATION_REPEAT_MODE_REVERSE)
+ {
+ int repeat_count = elm_spinner_value_get(ad->repeat_count_spin);
+ if (repeat_count % 2 == 1)
+ {
+ ad->is_btn_visible = !(ad->is_btn_visible);
+
+ if (ad->is_btn_visible)
+ elm_object_text_set(ad->start_btn, "Start Alpha Animation from 1.0 to 0.0");
+ else
+ elm_object_text_set(ad->start_btn, "Start Alpha Animation from 0.0 to 1.0");
+ }
+ }
+
elm_object_disabled_set(ad->repeat_count_spin, EINA_FALSE);
+ elm_object_disabled_set(ad->repeat_mode_spin, EINA_FALSE);
ad->anim_obj = NULL;
}
int repeat_count = elm_spinner_value_get(ad->repeat_count_spin);
elm_object_disabled_set(ad->repeat_count_spin, EINA_TRUE);
+ Efl_Animation_Repeat_Mode repeat_mode = _anim_repeat_mode_get(ad->repeat_mode_spin);
+ elm_object_disabled_set(ad->repeat_mode_spin, EINA_TRUE);
+
if (ad->is_btn_visible)
{
//Set animation repeat count
efl_animation_repeat_count_set(ad->show_anim, repeat_count);
+ //Set animation repeat mode
+ efl_animation_repeat_mode_set(ad->show_anim, repeat_mode);
+
//Create Animation Object from Animation
ad->anim_obj = efl_animation_object_create(ad->show_anim);
elm_object_text_set(obj, "Start Alpha Animation from 1.0 to 0.0");
//Set animation repeat count
efl_animation_repeat_count_set(ad->hide_anim, repeat_count);
+ //Set animation repeat mode
+ efl_animation_repeat_mode_set(ad->hide_anim, repeat_mode);
+
//Create Animation Object from Animation
ad->anim_obj = efl_animation_object_create(ad->hide_anim);
elm_object_text_set(obj, "Start Alpha Animation from 0.0 to 1.0");
evas_object_move(repeat_count_spin, 100, 350);
evas_object_show(repeat_count_spin);
+ //Spinner to set animation repeat mode
+ Evas_Object *repeat_mode_spin = elm_spinner_add(win);
+ elm_spinner_label_format_set(repeat_mode_spin, "Repeat Mode: %s");
+ elm_spinner_editable_set(repeat_mode_spin, EINA_FALSE);
+ elm_spinner_min_max_set(repeat_mode_spin, 0, 1);
+ elm_spinner_value_set(repeat_mode_spin, 0);
+ elm_spinner_special_value_add(repeat_mode_spin, 0, "Restart");
+ elm_spinner_special_value_add(repeat_mode_spin, 1, "Reverse");
+ evas_object_resize(repeat_mode_spin, 200, 50);
+ evas_object_move(repeat_mode_spin, 100, 400);
+ evas_object_show(repeat_mode_spin);
+
//Initialize App Data
ad->show_anim = show_anim;
ad->hide_anim = hide_anim;
ad->anim_obj = NULL;
+ ad->start_btn = start_btn;
ad->repeat_count_spin = repeat_count_spin;
+ ad->repeat_mode_spin = repeat_mode_spin;
ad->is_btn_visible = EINA_TRUE;
- evas_object_resize(win, 400, 450);
+ evas_object_resize(win, 400, 500);
evas_object_show(win);
}
EOAPI void efl_animation_object_start_delay_set(Eo *obj, double delay_time);
EOAPI double efl_animation_object_start_delay_get(const Eo *obj);
+typedef enum
+{
+ EFL_ANIMATION_OBJECT_REPEAT_MODE_RESTART = 0,
+ EFL_ANIMATION_OBJECT_REPEAT_MODE_REVERSE
+} Efl_Animation_Object_Repeat_Mode;
+
+EOAPI void efl_animation_object_repeat_mode_set(Eo *obj, Efl_Animation_Object_Repeat_Mode mode);
+EOAPI Efl_Animation_Object_Repeat_Mode efl_animation_object_repeat_mode_get(const Eo *obj);
+
EOAPI void efl_animation_object_repeat_count_set(Eo *obj, int count);
EOAPI int efl_animation_object_repeat_count_get(const Eo *obj);
}
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)
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 {
}
double start_delay_time = efl_animation_start_delay_get(eo_obj);
efl_animation_object_start_delay_set(anim_obj, start_delay_time);
+ Efl_Animation_Object_Repeat_Mode repeat_mode =
+ (Efl_Animation_Object_Repeat_Mode)efl_animation_repeat_mode_get(eo_obj);
+ efl_animation_object_repeat_mode_set(anim_obj, repeat_mode);
+
int repeat_count = efl_animation_repeat_count_get(eo_obj);
efl_animation_object_repeat_count_set(anim_obj, repeat_count);
double start_delay_time = efl_animation_start_delay_get(eo_obj);
efl_animation_object_start_delay_set(group_anim_obj, start_delay_time);
+ Efl_Animation_Object_Repeat_Mode repeat_mode =
+ (Efl_Animation_Object_Repeat_Mode)efl_animation_repeat_mode_get(eo_obj);
+ efl_animation_object_repeat_mode_set(group_anim_obj, repeat_mode);
+
int repeat_count = efl_animation_repeat_count_get(eo_obj);
efl_animation_object_repeat_count_set(group_anim_obj, repeat_count);
double start_delay_time = efl_animation_start_delay_get(eo_obj);
efl_animation_object_start_delay_set(group_anim_obj, start_delay_time);
+ Efl_Animation_Object_Repeat_Mode repeat_mode =
+ (Efl_Animation_Object_Repeat_Mode)efl_animation_repeat_mode_get(eo_obj);
+ efl_animation_object_repeat_mode_set(group_anim_obj, repeat_mode);
+
int repeat_count = efl_animation_repeat_count_get(eo_obj);
efl_animation_object_repeat_count_set(group_anim_obj, repeat_count);
}
EOLIAN static void
+_efl_animation_object_repeat_mode_set(Eo *eo_obj,
+ Efl_Animation_Object_Data *pd,
+ Efl_Animation_Object_Repeat_Mode mode)
+{
+ EFL_ANIMATION_OBJECT_CHECK_OR_RETURN(eo_obj);
+
+ if ((mode == EFL_ANIMATION_OBJECT_REPEAT_MODE_RESTART) ||
+ (mode == EFL_ANIMATION_OBJECT_REPEAT_MODE_REVERSE))
+ pd->repeat_mode = mode;
+}
+
+EOLIAN static Efl_Animation_Object_Repeat_Mode
+_efl_animation_object_repeat_mode_get(const Eo *eo_obj,
+ Efl_Animation_Object_Data *pd)
+{
+ EFL_ANIMATION_OBJECT_CHECK_OR_RETURN((Eo *)eo_obj,
+ EFL_ANIMATION_OBJECT_REPEAT_MODE_RESTART);
+
+ return pd->repeat_mode;
+}
+
+EOLIAN static void
_efl_animation_object_repeat_count_set(Eo *eo_obj,
Efl_Animation_Object_Data *pd,
int count)
else
pd->progress = (elapsed_time - paused_time) / total_duration;
+ if (!pd->is_direction_forward)
+ pd->progress = 1.0 - pd->progress;
+
+ //If the direction is changed, then reset the target state.
+ if (pd->is_direction_changed)
+ {
+ pd->is_direction_changed = EINA_FALSE;
+ efl_animation_object_target_state_reset(eo_obj);
+ }
+
//Reset previous animation effect before applying animation effect
/* FIXME: When the target state is saved, it may not be finished to calculate
* target geometry.
pd->time.begin = ecore_loop_time_get();
pd->paused_time = 0.0;
- efl_animation_object_target_state_reset(eo_obj);
+ if (pd->repeat_mode == EFL_ANIMATION_OBJECT_REPEAT_MODE_REVERSE)
+ {
+ pd->is_direction_forward = !pd->is_direction_forward;
+ pd->is_direction_changed = EINA_TRUE;
+ }
return ECORE_CALLBACK_RENEW;
}
pd->is_started = EINA_TRUE;
pd->is_cancelled = EINA_FALSE;
pd->is_ended = EINA_FALSE;
+ pd->is_direction_forward = EINA_TRUE;
+ pd->is_direction_changed = EINA_FALSE;
pd->paused_time = 0.0;
if ((progress < 0.0) || (progress > 1.0)) return;
+ if (!pd->is_direction_forward)
+ pd->progress = 1.0 - pd->progress;
+
Efl_Animation_Object_Running_Event_Info event_info;
event_info.progress = progress;
pd->duration = 0.0;
pd->total_duration = 0.0;
+ pd->repeat_mode = EFL_ANIMATION_OBJECT_REPEAT_MODE_RESTART;
pd->repeat_count = 0;
pd->auto_del = EINA_TRUE;
EOAPI EFL_VOID_FUNC_BODYV(efl_animation_object_start_delay_set, EFL_FUNC_CALL(delay_time), double delay_time);
EOAPI EFL_FUNC_BODY_CONST(efl_animation_object_start_delay_get, double, 0);
+EOAPI EFL_VOID_FUNC_BODYV(efl_animation_object_repeat_mode_set, EFL_FUNC_CALL(mode), Efl_Animation_Object_Repeat_Mode mode);
+EOAPI EFL_FUNC_BODY_CONST(efl_animation_object_repeat_mode_get, Efl_Animation_Object_Repeat_Mode, 0);
+
EOAPI EFL_VOID_FUNC_BODYV(efl_animation_object_repeat_count_set, EFL_FUNC_CALL(count), int count);
EOAPI EFL_FUNC_BODY_CONST(efl_animation_object_repeat_count_get, int, 0);
EFL_OBJECT_OP_FUNC(efl_animation_object_total_duration_get, _efl_animation_object_total_duration_get), \
EFL_OBJECT_OP_FUNC(efl_animation_object_start_delay_set, _efl_animation_object_start_delay_set), \
EFL_OBJECT_OP_FUNC(efl_animation_object_start_delay_get, _efl_animation_object_start_delay_get), \
+ EFL_OBJECT_OP_FUNC(efl_animation_object_repeat_mode_set, _efl_animation_object_repeat_mode_set), \
+ EFL_OBJECT_OP_FUNC(efl_animation_object_repeat_mode_get, _efl_animation_object_repeat_mode_get), \
EFL_OBJECT_OP_FUNC(efl_animation_object_repeat_count_set, _efl_animation_object_repeat_count_set), \
EFL_OBJECT_OP_FUNC(efl_animation_object_repeat_count_get, _efl_animation_object_repeat_count_get)
double start_delay = efl_animation_object_start_delay_get(anim_obj);
double anim_obj_progress;
+ Eina_Bool start_repeat = EINA_FALSE;
+
if (total_duration == 0.0)
anim_obj_progress = 1.0;
else
{
repeated_count++;
_repeated_count_set(pd, anim_obj, repeated_count);
+
+ start_repeat = EINA_TRUE;
}
}
}
}
+ /* If object is repeated with reverse mode, then the progress value
+ * should be modified as (1.0 - progress). */
+ Efl_Animation_Object_Repeat_Mode repeat_mode
+ = efl_animation_object_repeat_mode_get(anim_obj);
+ if (repeat_mode == EFL_ANIMATION_OBJECT_REPEAT_MODE_REVERSE)
+ {
+ int repeated_count = _repeated_count_get(pd, anim_obj);
+ if (repeated_count > 0)
+ {
+ if ((((repeated_count % 2) == 1) && (!start_repeat)) ||
+ (((repeated_count % 2) == 0) && (start_repeat)))
+ anim_obj_progress = 1.0 - anim_obj_progress;
+ }
+ }
+
efl_animation_object_progress_set(anim_obj, anim_obj_progress);
}
double start_delay = efl_animation_object_start_delay_get(anim_obj);
double anim_obj_progress;
+ Eina_Bool start_repeat = EINA_FALSE;
+
if (total_duration == 0.0)
anim_obj_progress = 1.0;
else
{
repeated_count++;
_repeated_count_set(pd, anim_obj, repeated_count);
+
+ start_repeat = EINA_TRUE;
}
}
}
* delays */
sum_prev_total_duration += (total_duration + start_delay);
- if ((anim_obj_progress == 1.0) &&
- !efl_animation_object_final_state_keep_get(anim_obj))
+ if ((anim_obj_progress == 1.0) && (!start_repeat) &&
+ (!efl_animation_object_final_state_keep_get(anim_obj)))
continue;
+ /* If object is repeated with reverse mode, then the progress value
+ * should be modified as (1.0 - progress). */
+ Efl_Animation_Object_Repeat_Mode repeat_mode
+ = efl_animation_object_repeat_mode_get(anim_obj);
+ if (repeat_mode == EFL_ANIMATION_OBJECT_REPEAT_MODE_REVERSE)
+ {
+ int repeated_count = _repeated_count_get(pd, anim_obj);
+ if (repeated_count > 0)
+ {
+ if ((((repeated_count % 2) == 1) && (!start_repeat)) ||
+ (((repeated_count % 2) == 0) && (start_repeat)))
+ anim_obj_progress = 1.0 - anim_obj_progress;
+ }
+ }
+
efl_animation_object_progress_set(anim_obj, anim_obj_progress);
}
typedef struct _Efl_Animation_Object_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 {
double begin;
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_Object_Repeat_Mode repeat_mode;
+ int repeat_count;
+ int remaining_repeat_count;
- Eina_Bool auto_del : 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 auto_del : 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;
+ Eina_Bool is_direction_changed : 1;
} Efl_Animation_Object_Data;
#define EFL_ANIMATION_OBJECT_CHECK_OR_RETURN(anim_obj, ...) \
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, ...) \
double start_delay_time = efl_animation_start_delay_get(eo_obj);
efl_animation_object_start_delay_set(anim_obj, start_delay_time);
+ Efl_Animation_Object_Repeat_Mode repeat_mode =
+ (Efl_Animation_Object_Repeat_Mode)efl_animation_repeat_mode_get(eo_obj);
+ efl_animation_object_repeat_mode_set(anim_obj, repeat_mode);
+
int repeat_count = efl_animation_repeat_count_get(eo_obj);
efl_animation_object_repeat_count_set(anim_obj, repeat_count);
double start_delay_time = efl_animation_start_delay_get(eo_obj);
efl_animation_object_start_delay_set(anim_obj, start_delay_time);
+ Efl_Animation_Object_Repeat_Mode repeat_mode =
+ (Efl_Animation_Object_Repeat_Mode)efl_animation_repeat_mode_get(eo_obj);
+ efl_animation_object_repeat_mode_set(anim_obj, repeat_mode);
+
int repeat_count = efl_animation_repeat_count_get(eo_obj);
efl_animation_object_repeat_count_set(anim_obj, repeat_count);
double start_delay_time = efl_animation_start_delay_get(eo_obj);
efl_animation_object_start_delay_set(anim_obj, start_delay_time);
+ Efl_Animation_Object_Repeat_Mode repeat_mode =
+ (Efl_Animation_Object_Repeat_Mode)efl_animation_repeat_mode_get(eo_obj);
+ efl_animation_object_repeat_mode_set(anim_obj, repeat_mode);
+
int repeat_count = efl_animation_repeat_count_get(eo_obj);
efl_animation_object_repeat_count_set(anim_obj, repeat_count);
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.]]
+}