From 9e590e9e15fecd2b26b39ae8b2e5bc018795ebab Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Mon, 5 Nov 2018 14:22:58 +0900 Subject: [PATCH] elementary transit: add a new api - elm_transit_progress_value_set() Summary: This API sets current time progression of the animation. It intervenes current progress instantly when it requires to jump onto a specific frame position. @feature Reviewers: #committers Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D7211 Change-Id: I2519a21b746a6c33d282ef38bf9020dac08166fe --- src/lib/elementary/elm_transit.c | 35 +++++++++++++++++++++++++---------- src/lib/elementary/elm_transit.h | 19 +++++++++++++++++++ 2 files changed, 44 insertions(+), 10 deletions(-) diff --git a/src/lib/elementary/elm_transit.c b/src/lib/elementary/elm_transit.c index a38d785..9aaabe9 100644 --- a/src/lib/elementary/elm_transit.c +++ b/src/lib/elementary/elm_transit.c @@ -60,7 +60,10 @@ struct _Elm_Transit Eina_Bool reverse; } repeat; double progress; - double revert_begin_progress, revert_duration, total_revert_time; + double inter_progress; + double revert_begin_progress; + double revert_duration; + double total_revert_time; unsigned int effects_pending_del; int walking; double v[4]; @@ -339,9 +342,6 @@ _transit_animate_cb(void *data) elapsed_time = (transit->time.current - transit->time.begin - transit->time.delayed) - (2 * transit->total_revert_time); duration = transit->time.duration; - if (elapsed_time > duration) - elapsed_time = duration; - transit->progress = elapsed_time / duration; if (transit->revert_mode && transit->revert_begin_progress == 0) @@ -358,6 +358,9 @@ _transit_animate_cb(void *data) transit->progress = transit->revert_begin_progress - revert_progress; } + /* Intervention Progress */ + transit->progress += transit->inter_progress; + switch (transit->tween_mode) { case ELM_TRANSIT_TWEEN_MODE_LINEAR: @@ -410,11 +413,8 @@ _transit_animate_cb(void *data) /* Reverse? */ if (transit->repeat.reverse) transit->progress = 1 - transit->progress; - if (duration > 0) - { - if (!_transit_animate_op(transit, transit->progress)) - return ECORE_CALLBACK_CANCEL; - } + if (!_transit_animate_op(transit, transit->progress)) + return ECORE_CALLBACK_CANCEL; if (transit->revert_mode && (transit->progress <= 0 || transit->progress >= 1)) { @@ -422,6 +422,7 @@ _transit_animate_cb(void *data) transit->time.begin = ecore_loop_time_get(); transit->time.revert_delayed = 0; transit->total_revert_time = 0; + transit->inter_progress = 0; if ((transit->repeat.count >= 0) && (transit->repeat.current == transit->repeat.count) && ((!transit->auto_reverse) || transit->repeat.reverse)) @@ -435,7 +436,9 @@ _transit_animate_cb(void *data) } /* Not end. Keep going. */ - if (elapsed_time < duration || transit->revert_mode) return ECORE_CALLBACK_RENEW; + if ((!transit->repeat.reverse && transit->progress < 1) || + (transit->repeat.reverse && transit->progress > 0) || + transit->revert_mode) return ECORE_CALLBACK_RENEW; /* Repeat and reverse and time done! */ if ((transit->repeat.count >= 0) && @@ -458,6 +461,7 @@ _transit_animate_cb(void *data) transit->time.begin = ecore_loop_time_get(); transit->time.delayed = 0; transit->total_revert_time = 0; + transit->inter_progress = 0; return ECORE_CALLBACK_RENEW; } @@ -944,6 +948,17 @@ elm_transit_paused_get(const Elm_Transit *transit) return EINA_TRUE; } +EAPI void +elm_transit_progress_value_set(Elm_Transit *transit, double progress) +{ + ELM_TRANSIT_CHECK_OR_RETURN(transit); + + if (progress < 0) progress = 0; + else if (progress > 1) progress = 1; + + transit->inter_progress = (progress - transit->progress); +} + EAPI double elm_transit_progress_value_get(const Elm_Transit *transit) { diff --git a/src/lib/elementary/elm_transit.h b/src/lib/elementary/elm_transit.h index fb90def..a045af2 100644 --- a/src/lib/elementary/elm_transit.h +++ b/src/lib/elementary/elm_transit.h @@ -674,6 +674,25 @@ EAPI Eina_Bool elm_transit_paused_get(const Elm_Transit *transit); */ EAPI double elm_transit_progress_value_get(const Elm_Transit *transit); + +/** + * Set current time progression of the animation. + * + * Intervene current progress instantly when it requires to jump onto a specific frame position. + * + * @note @p transit can not be NULL + * + * @param transit The transit object. + * @param progress The time progression value. The value must be in range of (0.0 ~ 1.0). + * + * @see elm_transit_progress_value_get() + * + * @since 1.22 + * + * @ingroup Elm_Transit + */ +EAPI void elm_transit_progress_value_set(Elm_Transit *transit, double progress); + /** * Makes the chain relationship between two transits. * -- 2.7.4