summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGodly T Alias <godlytalias@yahoo.co.in>2016-02-05 08:08:16 +0100
committerCedric BAIL <cedric@osg.samsung.com>2016-02-05 08:45:19 +0100
commit54223c656f6e0a1d7223f2106d0569d624a6f836 (patch)
tree345e5fe5c498dbce7b8cf730b9018d08c8471230
parentd195270b6415c165f842f4f3debba8f0fc43525d (diff)
transit: add possibility to revert an ongoing transition during play
Summary: Currently the feature available in transit to reverse play a transition is auto-reverse which will play a transition in reverse mode once a transition is complete. This feature helps the user to revert a transition at any point of time when transition is going on. New API added. @feature T3019 Use Case: While doing pinch zoom, we will be doing zoom transit effect from one step to other, during that transit if user do the pinch in reverse direction this API can be called so that transition will be reverted easily. Signed-off-by: godly.talias <godly.talias@samsung.com> Test Plan: elementary_test Transit Resizing / Transit Zoom / Transit Bezier / Transit Custom / Transit Fade / Transit Flip Reviewers: raster, prince.dubey, shilpasingh, Hermet, seoz, cedric Subscribers: rajeshps, govi Differential Revision: https://phab.enlightenment.org/D3567 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
-rw-r--r--src/bin/test_transit.c109
-rw-r--r--src/bin/test_transit_bezier.c19
-rw-r--r--src/lib/elm_authors.h2
-rw-r--r--src/lib/elm_transit.c62
-rw-r--r--src/lib/elm_transit.h19
5 files changed, 194 insertions, 17 deletions
diff --git a/src/bin/test_transit.c b/src/bin/test_transit.c
index fb4e52456..bfdd2d95a 100644
--- a/src/bin/test_transit.c
+++ b/src/bin/test_transit.c
@@ -22,6 +22,21 @@ struct _Custom_Effect
22}; 22};
23 23
24static void 24static void
25_transit_revert(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
26{
27 Elm_Transit *trans = (Elm_Transit*)data;
28 elm_transit_revert_go(trans);
29}
30
31static void
32_transit_rev_cb_del(void *data, Elm_Transit *trans EINA_UNUSED)
33{
34 Evas_Object *rev_bt = (Evas_Object*)data;
35 evas_object_smart_callback_del(rev_bt, "clicked", _transit_revert);
36 elm_object_disabled_set(rev_bt, EINA_TRUE);
37}
38
39static void
25_custom_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress) 40_custom_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
26{ 41{
27 if (!effect) return; 42 if (!effect) return;
@@ -145,13 +160,16 @@ _transit_image_animation(void *data, Evas_Object *obj, void *event_info EINA_UNU
145} 160}
146 161
147static void 162static void
148_transit_resizing(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED) 163_transit_resizing(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
149{ 164{
150 Elm_Transit *trans; 165 Elm_Transit *trans;
151 166 Evas_Object *rev_bt = (Evas_Object*)data;
167 elm_object_disabled_set(rev_bt, EINA_FALSE);
152 trans = elm_transit_add(); 168 trans = elm_transit_add();
153 elm_transit_object_add(trans, obj); 169 elm_transit_object_add(trans, obj);
170 elm_transit_del_cb_set(trans, _transit_rev_cb_del, rev_bt);
154 171
172 evas_object_smart_callback_add(rev_bt, "clicked", _transit_revert, trans);
155 elm_transit_effect_resizing_add(trans, 100, 50, 300, 150); 173 elm_transit_effect_resizing_add(trans, 100, 50, 300, 150);
156 174
157 elm_transit_duration_set(trans, 5.0); 175 elm_transit_duration_set(trans, 5.0);
@@ -163,11 +181,15 @@ _transit_flip(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
163{ 181{
164 Elm_Transit *trans; 182 Elm_Transit *trans;
165 Evas_Object *obj2 = data; 183 Evas_Object *obj2 = data;
184 Evas_Object *rev_bt = (Evas_Object*)evas_object_data_get(obj, "revert");
185 elm_object_disabled_set(rev_bt, EINA_FALSE);
166 186
167 trans = elm_transit_add(); 187 trans = elm_transit_add();
168 elm_transit_object_add(trans, obj); 188 elm_transit_object_add(trans, obj);
169 elm_transit_object_add(trans, obj2); 189 elm_transit_object_add(trans, obj2);
190 elm_transit_del_cb_set(trans, _transit_rev_cb_del, rev_bt);
170 191
192 evas_object_smart_callback_add(rev_bt, "clicked", _transit_revert, trans);
171 elm_transit_effect_flip_add(trans, ELM_TRANSIT_EFFECT_FLIP_AXIS_X, EINA_TRUE); 193 elm_transit_effect_flip_add(trans, ELM_TRANSIT_EFFECT_FLIP_AXIS_X, EINA_TRUE);
172 194
173 elm_transit_duration_set(trans, 5.0); 195 elm_transit_duration_set(trans, 5.0);
@@ -180,8 +202,12 @@ _transit_zoom(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UN
180 Elm_Transit *trans; 202 Elm_Transit *trans;
181 203
182 trans = elm_transit_add(); 204 trans = elm_transit_add();
205 Evas_Object *rev_bt = (Evas_Object*)data;
206 elm_object_disabled_set(rev_bt, EINA_FALSE);
183 elm_transit_object_add(trans, obj); 207 elm_transit_object_add(trans, obj);
208 elm_transit_del_cb_set(trans, _transit_rev_cb_del, rev_bt);
184 209
210 evas_object_smart_callback_add(rev_bt, "clicked", _transit_revert, trans);
185 elm_transit_effect_zoom_add(trans, 1.0, 3.0); 211 elm_transit_effect_zoom_add(trans, 1.0, 3.0);
186 212
187 elm_transit_duration_set(trans, 5.0); 213 elm_transit_duration_set(trans, 5.0);
@@ -193,10 +219,15 @@ _transit_blend(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
193{ 219{
194 Elm_Transit *trans; 220 Elm_Transit *trans;
195 Evas_Object *obj2 = data; 221 Evas_Object *obj2 = data;
222 Evas_Object *rev_bt = (Evas_Object*)evas_object_data_get(obj, "revert");
223 elm_object_disabled_set(rev_bt, EINA_FALSE);
196 224
197 trans = elm_transit_add(); 225 trans = elm_transit_add();
198 elm_transit_object_add(trans, obj); 226 elm_transit_object_add(trans, obj);
199 elm_transit_object_add(trans, obj2); 227 elm_transit_object_add(trans, obj2);
228 elm_transit_del_cb_set(trans, _transit_rev_cb_del, rev_bt);
229
230 evas_object_smart_callback_add(rev_bt, "clicked", _transit_revert, trans);
200 231
201 elm_transit_effect_blend_add(trans); 232 elm_transit_effect_blend_add(trans);
202 233
@@ -209,10 +240,15 @@ _transit_fade(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
209{ 240{
210 Elm_Transit *trans; 241 Elm_Transit *trans;
211 Evas_Object *obj2 = data; 242 Evas_Object *obj2 = data;
243 Evas_Object *rev_bt = (Evas_Object*)evas_object_data_get(obj, "revert");
244 elm_object_disabled_set(rev_bt, EINA_FALSE);
212 245
213 trans = elm_transit_add(); 246 trans = elm_transit_add();
214 elm_transit_object_add(trans, obj); 247 elm_transit_object_add(trans, obj);
215 elm_transit_object_add(trans, obj2); 248 elm_transit_object_add(trans, obj2);
249 elm_transit_del_cb_set(trans, _transit_rev_cb_del, rev_bt);
250
251 evas_object_smart_callback_add(rev_bt, "clicked", _transit_revert, trans);
216 252
217 elm_transit_effect_fade_add(trans); 253 elm_transit_effect_fade_add(trans);
218 254
@@ -358,7 +394,7 @@ test_transit(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_i
358void 394void
359test_transit_resizing(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 395test_transit_resizing(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
360{ 396{
361 Evas_Object *win, *bt; 397 Evas_Object *win, *bt, *rev_bt;
362 398
363 win = elm_win_util_standard_add("transit2", "Transit Resizing"); 399 win = elm_win_util_standard_add("transit2", "Transit Resizing");
364 elm_win_autodel_set(win, EINA_TRUE); 400 elm_win_autodel_set(win, EINA_TRUE);
@@ -368,7 +404,15 @@ test_transit_resizing(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void
368 evas_object_show(bt); 404 evas_object_show(bt);
369 evas_object_move(bt, 50, 100); 405 evas_object_move(bt, 50, 100);
370 evas_object_resize(bt, 100, 50); 406 evas_object_resize(bt, 100, 50);
371 evas_object_smart_callback_add(bt, "clicked", _transit_resizing, NULL); 407
408 rev_bt = elm_button_add(win);
409 elm_object_text_set(rev_bt, "Revert");
410 evas_object_resize(rev_bt, 100, 50);
411 evas_object_move(rev_bt, 50, 300);
412 evas_object_show(rev_bt);
413 elm_object_disabled_set(rev_bt, EINA_TRUE);
414
415 evas_object_smart_callback_add(bt, "clicked", _transit_resizing, rev_bt);
372 416
373 evas_object_resize(win, 400, 400); 417 evas_object_resize(win, 400, 400);
374 evas_object_show(win); 418 evas_object_show(win);
@@ -378,7 +422,7 @@ test_transit_resizing(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void
378void 422void
379test_transit_flip(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 423test_transit_flip(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
380{ 424{
381 Evas_Object *win, *bt, *bt2; 425 Evas_Object *win, *bt, *bt2, *rev_bt;
382 426
383 win = elm_win_util_standard_add("transit3", "Transit Flip"); 427 win = elm_win_util_standard_add("transit3", "Transit Flip");
384 elm_win_autodel_set(win, EINA_TRUE); 428 elm_win_autodel_set(win, EINA_TRUE);
@@ -394,7 +438,16 @@ test_transit_flip(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *ev
394 evas_object_move(bt2, 50, 50); 438 evas_object_move(bt2, 50, 50);
395 evas_object_resize(bt2, 200, 200); 439 evas_object_resize(bt2, 200, 200);
396 440
397 evas_object_resize(win, 300, 300); 441 rev_bt = elm_button_add(win);
442 elm_object_text_set(rev_bt, "Revert");
443 evas_object_resize(rev_bt, 100, 50);
444 evas_object_move(rev_bt, 50, 300);
445 evas_object_show(rev_bt);
446 elm_object_disabled_set(rev_bt, EINA_TRUE);
447 evas_object_data_set(bt, "revert", rev_bt);
448 evas_object_data_set(bt2, "revert", rev_bt);
449
450 evas_object_resize(win, 400, 400);
398 evas_object_show(win); 451 evas_object_show(win);
399 452
400 evas_object_smart_callback_add(bt, "clicked", _transit_flip, bt2); 453 evas_object_smart_callback_add(bt, "clicked", _transit_flip, bt2);
@@ -405,7 +458,7 @@ test_transit_flip(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *ev
405void 458void
406test_transit_zoom(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 459test_transit_zoom(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
407{ 460{
408 Evas_Object *win, *bt; 461 Evas_Object *win, *bt, *rev_bt;
409 462
410 win = elm_win_util_standard_add("transit4", "Transit Zoom"); 463 win = elm_win_util_standard_add("transit4", "Transit Zoom");
411 elm_win_autodel_set(win, EINA_TRUE); 464 elm_win_autodel_set(win, EINA_TRUE);
@@ -416,7 +469,14 @@ test_transit_zoom(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *ev
416 evas_object_move(bt, 100, 125); 469 evas_object_move(bt, 100, 125);
417 evas_object_show(bt); 470 evas_object_show(bt);
418 471
419 evas_object_smart_callback_add(bt, "clicked", _transit_zoom, NULL); 472 rev_bt = elm_button_add(win);
473 elm_object_text_set(rev_bt, "Revert");
474 evas_object_resize(rev_bt, 100, 50);
475 evas_object_move(rev_bt, 100, 250);
476 evas_object_show(rev_bt);
477 elm_object_disabled_set(rev_bt, EINA_TRUE);
478
479 evas_object_smart_callback_add(bt, "clicked", _transit_zoom, rev_bt);
420 480
421 evas_object_resize(win, 300, 300); 481 evas_object_resize(win, 300, 300);
422 evas_object_show(win); 482 evas_object_show(win);
@@ -426,7 +486,7 @@ test_transit_zoom(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *ev
426void 486void
427test_transit_blend(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 487test_transit_blend(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
428{ 488{
429 Evas_Object *win, *bt, *bt2, *ic; 489 Evas_Object *win, *bt, *bt2, *ic, *rev_bt;
430 char buf[PATH_MAX]; 490 char buf[PATH_MAX];
431 491
432 win = elm_win_util_standard_add("transit5", "Transit Blend"); 492 win = elm_win_util_standard_add("transit5", "Transit Blend");
@@ -455,7 +515,16 @@ test_transit_blend(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *e
455 evas_object_move(bt2, 25, 125); 515 evas_object_move(bt2, 25, 125);
456 evas_object_resize(bt2, 250, 50); 516 evas_object_resize(bt2, 250, 50);
457 517
458 evas_object_resize(win, 300, 300); 518 rev_bt = elm_button_add(win);
519 elm_object_text_set(rev_bt, "Revert");
520 evas_object_resize(rev_bt, 100, 50);
521 evas_object_move(rev_bt, 50, 300);
522 evas_object_show(rev_bt);
523 elm_object_disabled_set(rev_bt, EINA_TRUE);
524 evas_object_data_set(bt, "revert", rev_bt);
525 evas_object_data_set(bt2, "revert", rev_bt);
526
527 evas_object_resize(win, 300, 400);
459 evas_object_show(win); 528 evas_object_show(win);
460 529
461 evas_object_smart_callback_add(bt, "clicked", _transit_blend, bt2); 530 evas_object_smart_callback_add(bt, "clicked", _transit_blend, bt2);
@@ -466,7 +535,7 @@ test_transit_blend(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *e
466void 535void
467test_transit_fade(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 536test_transit_fade(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
468{ 537{
469 Evas_Object *win, *bt, *bt2, *ic; 538 Evas_Object *win, *bt, *bt2, *ic, *rev_bt;
470 char buf[PATH_MAX]; 539 char buf[PATH_MAX];
471 540
472 win = elm_win_util_standard_add("transit6","Transit Fade"); 541 win = elm_win_util_standard_add("transit6","Transit Fade");
@@ -495,7 +564,16 @@ test_transit_fade(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *ev
495 evas_object_move(bt2, 25, 125); 564 evas_object_move(bt2, 25, 125);
496 evas_object_resize(bt2, 250, 50); 565 evas_object_resize(bt2, 250, 50);
497 566
498 evas_object_resize(win, 300, 300); 567 rev_bt = elm_button_add(win);
568 elm_object_text_set(rev_bt, "Revert");
569 evas_object_resize(rev_bt, 100, 50);
570 evas_object_move(rev_bt, 50, 300);
571 evas_object_show(rev_bt);
572 elm_object_disabled_set(rev_bt, EINA_TRUE);
573 evas_object_data_set(bt, "revert", rev_bt);
574 evas_object_data_set(bt2, "revert", rev_bt);
575
576 evas_object_resize(win, 300, 400);
499 evas_object_show(win); 577 evas_object_show(win);
500 578
501 evas_object_smart_callback_add(bt, "clicked", _transit_fade, bt2); 579 evas_object_smart_callback_add(bt, "clicked", _transit_fade, bt2);
@@ -559,6 +637,13 @@ test_transit_custom(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *
559 elm_transit_repeat_times_set(trans, -1); 637 elm_transit_repeat_times_set(trans, -1);
560 elm_transit_go(trans); 638 elm_transit_go(trans);
561 639
640 bt = elm_button_add(win);
641 elm_object_text_set(bt, "Revert");
642 evas_object_resize(bt, 150, 50);
643 evas_object_move(bt, 50, 250);
644 evas_object_show(bt);
645 evas_object_smart_callback_add(bt, "clicked", _transit_revert, trans);
646
562 evas_object_resize(win, 400, 400); 647 evas_object_resize(win, 400, 400);
563 evas_object_show(win); 648 evas_object_show(win);
564} 649}
diff --git a/src/bin/test_transit_bezier.c b/src/bin/test_transit_bezier.c
index a8a05d2b5..24966e8cc 100644
--- a/src/bin/test_transit_bezier.c
+++ b/src/bin/test_transit_bezier.c
@@ -14,6 +14,7 @@ typedef struct
14{ 14{
15 Evas *e; 15 Evas *e;
16 Evas_Object *win; 16 Evas_Object *win;
17 Evas_Object *rev_btn;
17 Evas_Object *ctrl_pt1; 18 Evas_Object *ctrl_pt1;
18 Evas_Object *ctrl_pt2; 19 Evas_Object *ctrl_pt2;
19 Evas_Object *ctrl_pt1_line; 20 Evas_Object *ctrl_pt1_line;
@@ -25,6 +26,13 @@ typedef struct
25} transit_data; 26} transit_data;
26 27
27static void 28static void
29_transit_revert(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
30{
31 Elm_Transit *trans = (Elm_Transit*)data;
32 elm_transit_revert_go(trans);
33}
34
35static void
28v_get(transit_data *td, double *v1, double *v2, double *v3, double *v4) 36v_get(transit_data *td, double *v1, double *v2, double *v3, double *v4)
29{ 37{
30 Evas_Coord x, w, y, h; 38 Evas_Coord x, w, y, h;
@@ -171,6 +179,8 @@ transit_del_cb(void *data, Elm_Transit *transit EINA_UNUSED)
171 evas_object_show(td->ctrl_pt2); 179 evas_object_show(td->ctrl_pt2);
172 evas_object_show(td->ctrl_pt1_line); 180 evas_object_show(td->ctrl_pt1_line);
173 evas_object_show(td->ctrl_pt2_line); 181 evas_object_show(td->ctrl_pt2_line);
182 evas_object_smart_callback_del(td->rev_btn, "clicked", _transit_revert);
183 elm_object_disabled_set(td->rev_btn, EINA_TRUE);
174} 184}
175 185
176static void 186static void
@@ -189,6 +199,8 @@ btn_clicked_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
189 elm_transit_del_cb_set(transit, transit_del_cb, td); 199 elm_transit_del_cb_set(transit, transit_del_cb, td);
190 elm_transit_duration_set(transit, 1); 200 elm_transit_duration_set(transit, 1);
191 elm_transit_go(transit); 201 elm_transit_go(transit);
202 evas_object_smart_callback_add(td->rev_btn, "clicked", _transit_revert, transit);
203 elm_object_disabled_set(td->rev_btn, EINA_FALSE);
192 204
193 evas_object_hide(td->ctrl_pt1); 205 evas_object_hide(td->ctrl_pt1);
194 evas_object_hide(td->ctrl_pt2); 206 evas_object_hide(td->ctrl_pt2);
@@ -281,6 +293,13 @@ test_transit_bezier(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *
281 evas_object_pass_events_set(td.label, EINA_TRUE); 293 evas_object_pass_events_set(td.label, EINA_TRUE);
282 evas_object_show(td.label); 294 evas_object_show(td.label);
283 295
296 td.rev_btn = elm_button_add(td.win);
297 elm_object_text_set(td.rev_btn, "Revert");
298 evas_object_resize(td.rev_btn, 50, 50);
299 evas_object_move(td.rev_btn, 100, 0);
300 evas_object_show(td.rev_btn);
301 elm_object_disabled_set(td.rev_btn, EINA_TRUE);
302
284 //Button 303 //Button
285 Evas_Object *btn = elm_button_add(td.win); 304 Evas_Object *btn = elm_button_add(td.win);
286 elm_object_text_set(btn, "Go"); 305 elm_object_text_set(btn, "Go");
diff --git a/src/lib/elm_authors.h b/src/lib/elm_authors.h
index 5d583a168..dd9cbd50d 100644
--- a/src/lib/elm_authors.h
+++ b/src/lib/elm_authors.h
@@ -162,7 +162,7 @@
162 * @author yinsc <shouchen.yin@@samsung.com> 162 * @author yinsc <shouchen.yin@@samsung.com>
163 * @author Subodh Kumar <s7158.kumar@@samsung.com> 163 * @author Subodh Kumar <s7158.kumar@@samsung.com>
164 * @author Kumar Navneet <k.navneet@@samsung.com> 164 * @author Kumar Navneet <k.navneet@@samsung.com>
165 * @author Godly T Alias <godly.talias@@samsung.com> 165 * @author Godly T Alias <godly.talias@@samsung.com> <godlytalias@@yahoo.co.in>
166 * @author Divyesh Purohit <div.purohit@samsung.com> <purohit.div@gmail.com> 166 * @author Divyesh Purohit <div.purohit@samsung.com> <purohit.div@gmail.com>
167 * @author Minkyu Kang <mk7.kang@samsung.com> 167 * @author Minkyu Kang <mk7.kang@samsung.com>
168 * @author Jinyong Park <j4939.park@samsung.com> 168 * @author Jinyong Park <j4939.park@samsung.com>
diff --git a/src/lib/elm_transit.c b/src/lib/elm_transit.c
index 939825cc7..ea70529b2 100644
--- a/src/lib/elm_transit.c
+++ b/src/lib/elm_transit.c
@@ -48,6 +48,8 @@ struct _Elm_Transit
48 double duration; 48 double duration;
49 double begin; 49 double begin;
50 double current; 50 double current;
51 double revert_start;
52 double revert_elapsed;
51 } time; 53 } time;
52 struct 54 struct
53 { 55 {
@@ -56,6 +58,7 @@ struct _Elm_Transit
56 Eina_Bool reverse; 58 Eina_Bool reverse;
57 } repeat; 59 } repeat;
58 double progress; 60 double progress;
61 double revert_begin_progress, revert_duration, total_revert_time;
59 unsigned int effects_pending_del; 62 unsigned int effects_pending_del;
60 int walking; 63 int walking;
61 double v[4]; 64 double v[4];
@@ -65,6 +68,7 @@ struct _Elm_Transit
65 Eina_Bool state_keep : 1; 68 Eina_Bool state_keep : 1;
66 Eina_Bool finished : 1; 69 Eina_Bool finished : 1;
67 Eina_Bool smooth : 1; 70 Eina_Bool smooth : 1;
71 Eina_Bool revert_mode : 1;
68}; 72};
69 73
70struct _Elm_Transit_Effect_Module 74struct _Elm_Transit_Effect_Module
@@ -327,16 +331,28 @@ static Eina_Bool
327_transit_animate_cb(void *data) 331_transit_animate_cb(void *data)
328{ 332{
329 Elm_Transit *transit = data; 333 Elm_Transit *transit = data;
330 double elapsed_time, duration; 334 double elapsed_time, duration, revert_progress;
331 335
332 transit->time.current = ecore_loop_time_get(); 336 transit->time.current = ecore_loop_time_get();
333 elapsed_time = transit->time.current - transit->time.begin; 337 elapsed_time = transit->time.current - transit->time.begin - 2 * transit->total_revert_time;
334 duration = transit->time.duration + transit->time.delayed; 338 duration = transit->time.duration + transit->time.delayed;
335
336 if (elapsed_time > duration) 339 if (elapsed_time > duration)
337 elapsed_time = duration; 340 elapsed_time = duration;
338 341
339 transit->progress = elapsed_time / duration; 342 transit->progress = elapsed_time / duration;
343 if (transit->revert_mode && transit->revert_begin_progress == 0)
344 {
345 transit->revert_begin_progress = transit->progress;
346 transit->time.revert_start = transit->time.current;
347 }
348
349 if (transit->revert_mode)
350 {
351 transit->time.revert_elapsed = transit->time.current - transit->time.revert_start;
352 revert_progress = transit->time.revert_elapsed / duration;
353 transit->progress = transit->revert_begin_progress - revert_progress;
354 }
355
340 switch (transit->tween_mode) 356 switch (transit->tween_mode)
341 { 357 {
342 case ELM_TRANSIT_TWEEN_MODE_LINEAR: 358 case ELM_TRANSIT_TWEEN_MODE_LINEAR:
@@ -395,8 +411,25 @@ _transit_animate_cb(void *data)
395 return ECORE_CALLBACK_CANCEL; 411 return ECORE_CALLBACK_CANCEL;
396 } 412 }
397 413
414 if (transit->revert_mode && (transit->progress <= 0 || transit->progress >= 1))
415 {
416 transit->revert_mode = EINA_FALSE;
417 transit->time.begin = ecore_loop_time_get();
418 transit->total_revert_time = 0;
419 if ((transit->repeat.count >= 0) &&
420 (transit->repeat.current == transit->repeat.count) &&
421 ((!transit->auto_reverse) || transit->repeat.reverse))
422 {
423 transit->finished = EINA_TRUE;
424 elm_transit_del(transit);
425 return ECORE_CALLBACK_CANCEL;
426 }
427 else
428 return ECORE_CALLBACK_RENEW;
429 }
430
398 /* Not end. Keep going. */ 431 /* Not end. Keep going. */
399 if (elapsed_time < duration) return ECORE_CALLBACK_RENEW; 432 if (elapsed_time < duration || transit->revert_mode) return ECORE_CALLBACK_RENEW;
400 433
401 /* Repeat and reverse and time done! */ 434 /* Repeat and reverse and time done! */
402 if ((transit->repeat.count >= 0) && 435 if ((transit->repeat.count >= 0) &&
@@ -417,6 +450,7 @@ _transit_animate_cb(void *data)
417 else transit->repeat.reverse = EINA_TRUE; 450 else transit->repeat.reverse = EINA_TRUE;
418 451
419 transit->time.begin = ecore_loop_time_get(); 452 transit->time.begin = ecore_loop_time_get();
453 transit->total_revert_time = 0;
420 454
421 return ECORE_CALLBACK_RENEW; 455 return ECORE_CALLBACK_RENEW;
422} 456}
@@ -495,6 +529,7 @@ elm_transit_add(void)
495 529
496 transit->v[0] = 1.0; 530 transit->v[0] = 1.0;
497 transit->v[1] = 0.0; 531 transit->v[1] = 0.0;
532 transit->revert_mode = EINA_FALSE;
498 transit->smooth = EINA_TRUE; 533 transit->smooth = EINA_TRUE;
499 534
500 return transit; 535 return transit;
@@ -739,6 +774,23 @@ elm_transit_duration_get(const Elm_Transit *transit)
739} 774}
740 775
741EAPI void 776EAPI void
777elm_transit_revert_go(Elm_Transit *transit)
778{
779 ELM_TRANSIT_CHECK_OR_RETURN(transit);
780 if (transit->revert_mode)
781 {
782 transit->total_revert_time += transit->time.revert_elapsed;
783 transit->revert_mode = EINA_FALSE;
784 }
785 else
786 {
787 transit->revert_mode = EINA_TRUE;
788 transit->time.revert_elapsed = 0;
789 transit->revert_begin_progress = 0;
790 }
791}
792
793EAPI void
742elm_transit_go(Elm_Transit *transit) 794elm_transit_go(Elm_Transit *transit)
743{ 795{
744 ELM_TRANSIT_CHECK_OR_RETURN(transit); 796 ELM_TRANSIT_CHECK_OR_RETURN(transit);
@@ -761,6 +813,8 @@ elm_transit_go(Elm_Transit *transit)
761 813
762 transit->time.paused = 0; 814 transit->time.paused = 0;
763 transit->time.delayed = 0; 815 transit->time.delayed = 0;
816 transit->total_revert_time = 0;
817 transit->revert_mode = EINA_FALSE;
764 transit->time.begin = ecore_loop_time_get(); 818 transit->time.begin = ecore_loop_time_get();
765 transit->animator = ecore_animator_add(_transit_animate_cb, transit); 819 transit->animator = ecore_animator_add(_transit_animate_cb, transit);
766 820
diff --git a/src/lib/elm_transit.h b/src/lib/elm_transit.h
index 90938d5ff..6464d52c6 100644
--- a/src/lib/elm_transit.h
+++ b/src/lib/elm_transit.h
@@ -579,6 +579,25 @@ EAPI double elm_transit_duration_get(const Elm_Transit *transit)
579EAPI void elm_transit_go(Elm_Transit *transit); 579EAPI void elm_transit_go(Elm_Transit *transit);
580 580
581/** 581/**
582 * This API can be used to reverse play an ongoing transition.
583 * It shows effect only when an animation is going on.
584 * If this API is called twice transition will go in forward direction as normal one.
585 * If a repeat count is set, this API call will revert just the ongoing cycle and once
586 * it is reverted back completely, the transition will go in forward direction.
587 * If an autoreverse is set for the transition and this API is called in the midst of
588 * the transition the ongoing transition will be reverted and once it is done, the
589 * transition will begin again and complete a full auto reverse cycle.
590 *
591 * @note @p transit can not be NULL
592 *
593 * @param transit The transit object.
594 *
595 * @since 1.18
596 * @ingroup Transit
597 */
598EAPI void elm_transit_revert_go(Elm_Transit *transit);
599
600/**
582 * Starts the transition in given seconds. 601 * Starts the transition in given seconds.
583 * 602 *
584 * @note @p transit can not be NULL 603 * @note @p transit can not be NULL