summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHermet Park <hermetpark@gmail.com>2018-11-05 14:22:58 +0900
committerHermet Park <hermetpark@gmail.com>2018-11-05 14:22:58 +0900
commitc4e0d3f69d8203ad3ff4f3fdeb0a0adfaffdd1cd (patch)
tree9f7508f4140a29c9d4fb686e891cdfa00535ab23
parentad567a15a22101f0f8398faa537253fab5499ae1 (diff)
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
-rw-r--r--src/lib/elementary/elm_transit.c35
-rw-r--r--src/lib/elementary/elm_transit.h19
2 files changed, 44 insertions, 10 deletions
diff --git a/src/lib/elementary/elm_transit.c b/src/lib/elementary/elm_transit.c
index a38d785139..9aaabe9d83 100644
--- a/src/lib/elementary/elm_transit.c
+++ b/src/lib/elementary/elm_transit.c
@@ -60,7 +60,10 @@ struct _Elm_Transit
60 Eina_Bool reverse; 60 Eina_Bool reverse;
61 } repeat; 61 } repeat;
62 double progress; 62 double progress;
63 double revert_begin_progress, revert_duration, total_revert_time; 63 double inter_progress;
64 double revert_begin_progress;
65 double revert_duration;
66 double total_revert_time;
64 unsigned int effects_pending_del; 67 unsigned int effects_pending_del;
65 int walking; 68 int walking;
66 double v[4]; 69 double v[4];
@@ -339,9 +342,6 @@ _transit_animate_cb(void *data)
339 elapsed_time = (transit->time.current - transit->time.begin - transit->time.delayed) 342 elapsed_time = (transit->time.current - transit->time.begin - transit->time.delayed)
340 - (2 * transit->total_revert_time); 343 - (2 * transit->total_revert_time);
341 duration = transit->time.duration; 344 duration = transit->time.duration;
342 if (elapsed_time > duration)
343 elapsed_time = duration;
344
345 transit->progress = elapsed_time / duration; 345 transit->progress = elapsed_time / duration;
346 346
347 if (transit->revert_mode && transit->revert_begin_progress == 0) 347 if (transit->revert_mode && transit->revert_begin_progress == 0)
@@ -358,6 +358,9 @@ _transit_animate_cb(void *data)
358 transit->progress = transit->revert_begin_progress - revert_progress; 358 transit->progress = transit->revert_begin_progress - revert_progress;
359 } 359 }
360 360
361 /* Intervention Progress */
362 transit->progress += transit->inter_progress;
363
361 switch (transit->tween_mode) 364 switch (transit->tween_mode)
362 { 365 {
363 case ELM_TRANSIT_TWEEN_MODE_LINEAR: 366 case ELM_TRANSIT_TWEEN_MODE_LINEAR:
@@ -410,11 +413,8 @@ _transit_animate_cb(void *data)
410 /* Reverse? */ 413 /* Reverse? */
411 if (transit->repeat.reverse) transit->progress = 1 - transit->progress; 414 if (transit->repeat.reverse) transit->progress = 1 - transit->progress;
412 415
413 if (duration > 0) 416 if (!_transit_animate_op(transit, transit->progress))
414 { 417 return ECORE_CALLBACK_CANCEL;
415 if (!_transit_animate_op(transit, transit->progress))
416 return ECORE_CALLBACK_CANCEL;
417 }
418 418
419 if (transit->revert_mode && (transit->progress <= 0 || transit->progress >= 1)) 419 if (transit->revert_mode && (transit->progress <= 0 || transit->progress >= 1))
420 { 420 {
@@ -422,6 +422,7 @@ _transit_animate_cb(void *data)
422 transit->time.begin = ecore_loop_time_get(); 422 transit->time.begin = ecore_loop_time_get();
423 transit->time.revert_delayed = 0; 423 transit->time.revert_delayed = 0;
424 transit->total_revert_time = 0; 424 transit->total_revert_time = 0;
425 transit->inter_progress = 0;
425 if ((transit->repeat.count >= 0) && 426 if ((transit->repeat.count >= 0) &&
426 (transit->repeat.current == transit->repeat.count) && 427 (transit->repeat.current == transit->repeat.count) &&
427 ((!transit->auto_reverse) || transit->repeat.reverse)) 428 ((!transit->auto_reverse) || transit->repeat.reverse))
@@ -435,7 +436,9 @@ _transit_animate_cb(void *data)
435 } 436 }
436 437
437 /* Not end. Keep going. */ 438 /* Not end. Keep going. */
438 if (elapsed_time < duration || transit->revert_mode) return ECORE_CALLBACK_RENEW; 439 if ((!transit->repeat.reverse && transit->progress < 1) ||
440 (transit->repeat.reverse && transit->progress > 0) ||
441 transit->revert_mode) return ECORE_CALLBACK_RENEW;
439 442
440 /* Repeat and reverse and time done! */ 443 /* Repeat and reverse and time done! */
441 if ((transit->repeat.count >= 0) && 444 if ((transit->repeat.count >= 0) &&
@@ -458,6 +461,7 @@ _transit_animate_cb(void *data)
458 transit->time.begin = ecore_loop_time_get(); 461 transit->time.begin = ecore_loop_time_get();
459 transit->time.delayed = 0; 462 transit->time.delayed = 0;
460 transit->total_revert_time = 0; 463 transit->total_revert_time = 0;
464 transit->inter_progress = 0;
461 465
462 return ECORE_CALLBACK_RENEW; 466 return ECORE_CALLBACK_RENEW;
463} 467}
@@ -944,6 +948,17 @@ elm_transit_paused_get(const Elm_Transit *transit)
944 return EINA_TRUE; 948 return EINA_TRUE;
945} 949}
946 950
951EAPI void
952elm_transit_progress_value_set(Elm_Transit *transit, double progress)
953{
954 ELM_TRANSIT_CHECK_OR_RETURN(transit);
955
956 if (progress < 0) progress = 0;
957 else if (progress > 1) progress = 1;
958
959 transit->inter_progress = (progress - transit->progress);
960}
961
947EAPI double 962EAPI double
948elm_transit_progress_value_get(const Elm_Transit *transit) 963elm_transit_progress_value_get(const Elm_Transit *transit)
949{ 964{
diff --git a/src/lib/elementary/elm_transit.h b/src/lib/elementary/elm_transit.h
index fb90def0d1..a045af265e 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);
674 */ 674 */
675EAPI double elm_transit_progress_value_get(const Elm_Transit *transit); 675EAPI double elm_transit_progress_value_get(const Elm_Transit *transit);
676 676
677
678/**
679 * Set current time progression of the animation.
680 *
681 * Intervene current progress instantly when it requires to jump onto a specific frame position.
682 *
683 * @note @p transit can not be NULL
684 *
685 * @param transit The transit object.
686 * @param progress The time progression value. The value must be in range of (0.0 ~ 1.0).
687 *
688 * @see elm_transit_progress_value_get()
689 *
690 * @since 1.22
691 *
692 * @ingroup Elm_Transit
693 */
694EAPI void elm_transit_progress_value_set(Elm_Transit *transit, double progress);
695
677/** 696/**
678 * Makes the chain relationship between two transits. 697 * Makes the chain relationship between two transits.
679 * 698 *