aboutsummaryrefslogtreecommitdiffstats
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
commitcb8a5cb38c01b275df78b596398b734d502c5123 (patch)
treeb191bf1bff51a35217022358bffd3c6eeb6e176a
parenthoversel: improve key_action_move to handle disabled items (diff)
downloadefl-cb8a5cb38c01b275df78b596398b734d502c5123.tar.gz
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 https://phab.enlightenment.org/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--legacy/elementary/src/bin/test_transit.c109
-rw-r--r--legacy/elementary/src/bin/test_transit_bezier.c19
-rw-r--r--legacy/elementary/src/lib/elm_authors.h2
-rw-r--r--legacy/elementary/src/lib/elm_transit.c62
-rw-r--r--legacy/elementary/src/lib/elm_transit.h19
5 files changed, 194 insertions, 17 deletions
diff --git a/legacy/elementary/src/bin/test_transit.c b/legacy/elementary/src/bin/test_transit.c
index fb4e524560..bfdd2d95a3 100644
--- a/legacy/elementary/src/bin/test_transit.c
+++ b/legacy/elementary/src/bin/test_transit.c
@@ -22,6 +22,21 @@ struct _Custom_Effect
};
static void
+_transit_revert(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
+{
+ Elm_Transit *trans = (Elm_Transit*)data;
+ elm_transit_revert_go(trans);
+}
+
+static void
+_transit_rev_cb_del(void *data, Elm_Transit *trans EINA_UNUSED)
+{
+ Evas_Object *rev_bt = (Evas_Object*)data;
+ evas_object_smart_callback_del(rev_bt, "clicked", _transit_revert);
+ elm_object_disabled_set(rev_bt, EINA_TRUE);
+}
+
+static void
_custom_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
{
if (!effect) return;
@@ -145,13 +160,16 @@ _transit_image_animation(void *data, Evas_Object *obj, void *event_info EINA_UNU
}
static void
-_transit_resizing(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
+_transit_resizing(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
{
Elm_Transit *trans;
-
+ Evas_Object *rev_bt = (Evas_Object*)data;
+ elm_object_disabled_set(rev_bt, EINA_FALSE);
trans = elm_transit_add();
elm_transit_object_add(trans, obj);
+ elm_transit_del_cb_set(trans, _transit_rev_cb_del, rev_bt);
+ evas_object_smart_callback_add(rev_bt, "clicked", _transit_revert, trans);
elm_transit_effect_resizing_add(trans, 100, 50, 300, 150);
elm_transit_duration_set(trans, 5.0);
@@ -163,11 +181,15 @@ _transit_flip(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
{
Elm_Transit *trans;
Evas_Object *obj2 = data;
+ Evas_Object *rev_bt = (Evas_Object*)evas_object_data_get(obj, "revert");
+ elm_object_disabled_set(rev_bt, EINA_FALSE);
trans = elm_transit_add();
elm_transit_object_add(trans, obj);
elm_transit_object_add(trans, obj2);
+ elm_transit_del_cb_set(trans, _transit_rev_cb_del, rev_bt);
+ evas_object_smart_callback_add(rev_bt, "clicked", _transit_revert, trans);
elm_transit_effect_flip_add(trans, ELM_TRANSIT_EFFECT_FLIP_AXIS_X, EINA_TRUE);
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
Elm_Transit *trans;
trans = elm_transit_add();
+ Evas_Object *rev_bt = (Evas_Object*)data;
+ elm_object_disabled_set(rev_bt, EINA_FALSE);
elm_transit_object_add(trans, obj);
+ elm_transit_del_cb_set(trans, _transit_rev_cb_del, rev_bt);
+ evas_object_smart_callback_add(rev_bt, "clicked", _transit_revert, trans);
elm_transit_effect_zoom_add(trans, 1.0, 3.0);
elm_transit_duration_set(trans, 5.0);
@@ -193,10 +219,15 @@ _transit_blend(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
{
Elm_Transit *trans;
Evas_Object *obj2 = data;
+ Evas_Object *rev_bt = (Evas_Object*)evas_object_data_get(obj, "revert");
+ elm_object_disabled_set(rev_bt, EINA_FALSE);
trans = elm_transit_add();
elm_transit_object_add(trans, obj);
elm_transit_object_add(trans, obj2);
+ elm_transit_del_cb_set(trans, _transit_rev_cb_del, rev_bt);
+
+ evas_object_smart_callback_add(rev_bt, "clicked", _transit_revert, trans);
elm_transit_effect_blend_add(trans);
@@ -209,10 +240,15 @@ _transit_fade(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
{
Elm_Transit *trans;
Evas_Object *obj2 = data;
+ Evas_Object *rev_bt = (Evas_Object*)evas_object_data_get(obj, "revert");
+ elm_object_disabled_set(rev_bt, EINA_FALSE);
trans = elm_transit_add();
elm_transit_object_add(trans, obj);
elm_transit_object_add(trans, obj2);
+ elm_transit_del_cb_set(trans, _transit_rev_cb_del, rev_bt);
+
+ evas_object_smart_callback_add(rev_bt, "clicked", _transit_revert, trans);
elm_transit_effect_fade_add(trans);
@@ -358,7 +394,7 @@ test_transit(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_i
void
test_transit_resizing(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
- Evas_Object *win, *bt;
+ Evas_Object *win, *bt, *rev_bt;
win = elm_win_util_standard_add("transit2", "Transit Resizing");
elm_win_autodel_set(win, EINA_TRUE);
@@ -368,7 +404,15 @@ test_transit_resizing(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void
evas_object_show(bt);
evas_object_move(bt, 50, 100);
evas_object_resize(bt, 100, 50);
- evas_object_smart_callback_add(bt, "clicked", _transit_resizing, NULL);
+
+ rev_bt = elm_button_add(win);
+ elm_object_text_set(rev_bt, "Revert");
+ evas_object_resize(rev_bt, 100, 50);
+ evas_object_move(rev_bt, 50, 300);
+ evas_object_show(rev_bt);
+ elm_object_disabled_set(rev_bt, EINA_TRUE);
+
+ evas_object_smart_callback_add(bt, "clicked", _transit_resizing, rev_bt);
evas_object_resize(win, 400, 400);
evas_object_show(win);
@@ -378,7 +422,7 @@ test_transit_resizing(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void
void
test_transit_flip(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
- Evas_Object *win, *bt, *bt2;
+ Evas_Object *win, *bt, *bt2, *rev_bt;
win = elm_win_util_standard_add("transit3", "Transit Flip");
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
evas_object_move(bt2, 50, 50);
evas_object_resize(bt2, 200, 200);
- evas_object_resize(win, 300, 300);
+ rev_bt = elm_button_add(win);
+ elm_object_text_set(rev_bt, "Revert");
+ evas_object_resize(rev_bt, 100, 50);
+ evas_object_move(rev_bt, 50, 300);
+ evas_object_show(rev_bt);
+ elm_object_disabled_set(rev_bt, EINA_TRUE);
+ evas_object_data_set(bt, "revert", rev_bt);
+ evas_object_data_set(bt2, "revert", rev_bt);
+
+ evas_object_resize(win, 400, 400);
evas_object_show(win);
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
void
test_transit_zoom(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
- Evas_Object *win, *bt;
+ Evas_Object *win, *bt, *rev_bt;
win = elm_win_util_standard_add("transit4", "Transit Zoom");
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
evas_object_move(bt, 100, 125);
evas_object_show(bt);
- evas_object_smart_callback_add(bt, "clicked", _transit_zoom, NULL);
+ rev_bt = elm_button_add(win);
+ elm_object_text_set(rev_bt, "Revert");
+ evas_object_resize(rev_bt, 100, 50);
+ evas_object_move(rev_bt, 100, 250);
+ evas_object_show(rev_bt);
+ elm_object_disabled_set(rev_bt, EINA_TRUE);
+
+ evas_object_smart_callback_add(bt, "clicked", _transit_zoom, rev_bt);
evas_object_resize(win, 300, 300);
evas_object_show(win);
@@ -426,7 +486,7 @@ test_transit_zoom(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *ev
void
test_transit_blend(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
- Evas_Object *win, *bt, *bt2, *ic;
+ Evas_Object *win, *bt, *bt2, *ic, *rev_bt;
char buf[PATH_MAX];
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
evas_object_move(bt2, 25, 125);
evas_object_resize(bt2, 250, 50);
- evas_object_resize(win, 300, 300);
+ rev_bt = elm_button_add(win);
+ elm_object_text_set(rev_bt, "Revert");
+ evas_object_resize(rev_bt, 100, 50);
+ evas_object_move(rev_bt, 50, 300);
+ evas_object_show(rev_bt);
+ elm_object_disabled_set(rev_bt, EINA_TRUE);
+ evas_object_data_set(bt, "revert", rev_bt);
+ evas_object_data_set(bt2, "revert", rev_bt);
+
+ evas_object_resize(win, 300, 400);
evas_object_show(win);
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
void
test_transit_fade(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
- Evas_Object *win, *bt, *bt2, *ic;
+ Evas_Object *win, *bt, *bt2, *ic, *rev_bt;
char buf[PATH_MAX];
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
evas_object_move(bt2, 25, 125);
evas_object_resize(bt2, 250, 50);
- evas_object_resize(win, 300, 300);
+ rev_bt = elm_button_add(win);
+ elm_object_text_set(rev_bt, "Revert");
+ evas_object_resize(rev_bt, 100, 50);
+ evas_object_move(rev_bt, 50, 300);
+ evas_object_show(rev_bt);
+ elm_object_disabled_set(rev_bt, EINA_TRUE);
+ evas_object_data_set(bt, "revert", rev_bt);
+ evas_object_data_set(bt2, "revert", rev_bt);
+
+ evas_object_resize(win, 300, 400);
evas_object_show(win);
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 *
elm_transit_repeat_times_set(trans, -1);
elm_transit_go(trans);
+ bt = elm_button_add(win);
+ elm_object_text_set(bt, "Revert");
+ evas_object_resize(bt, 150, 50);
+ evas_object_move(bt, 50, 250);
+ evas_object_show(bt);
+ evas_object_smart_callback_add(bt, "clicked", _transit_revert, trans);
+
evas_object_resize(win, 400, 400);
evas_object_show(win);
}
diff --git a/legacy/elementary/src/bin/test_transit_bezier.c b/legacy/elementary/src/bin/test_transit_bezier.c
index a8a05d2b5f..24966e8ccb 100644
--- a/legacy/elementary/src/bin/test_transit_bezier.c
+++ b/legacy/elementary/src/bin/test_transit_bezier.c
@@ -14,6 +14,7 @@ typedef struct
{
Evas *e;
Evas_Object *win;
+ Evas_Object *rev_btn;
Evas_Object *ctrl_pt1;
Evas_Object *ctrl_pt2;
Evas_Object *ctrl_pt1_line;
@@ -25,6 +26,13 @@ typedef struct
} transit_data;
static void
+_transit_revert(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
+{
+ Elm_Transit *trans = (Elm_Transit*)data;
+ elm_transit_revert_go(trans);
+}
+
+static void
v_get(transit_data *td, double *v1, double *v2, double *v3, double *v4)
{
Evas_Coord x, w, y, h;
@@ -171,6 +179,8 @@ transit_del_cb(void *data, Elm_Transit *transit EINA_UNUSED)
evas_object_show(td->ctrl_pt2);
evas_object_show(td->ctrl_pt1_line);
evas_object_show(td->ctrl_pt2_line);
+ evas_object_smart_callback_del(td->rev_btn, "clicked", _transit_revert);
+ elm_object_disabled_set(td->rev_btn, EINA_TRUE);
}
static void
@@ -189,6 +199,8 @@ btn_clicked_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
elm_transit_del_cb_set(transit, transit_del_cb, td);
elm_transit_duration_set(transit, 1);
elm_transit_go(transit);
+ evas_object_smart_callback_add(td->rev_btn, "clicked", _transit_revert, transit);
+ elm_object_disabled_set(td->rev_btn, EINA_FALSE);
evas_object_hide(td->ctrl_pt1);
evas_object_hide(td->ctrl_pt2);
@@ -281,6 +293,13 @@ test_transit_bezier(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *
evas_object_pass_events_set(td.label, EINA_TRUE);
evas_object_show(td.label);
+ td.rev_btn = elm_button_add(td.win);
+ elm_object_text_set(td.rev_btn, "Revert");
+ evas_object_resize(td.rev_btn, 50, 50);
+ evas_object_move(td.rev_btn, 100, 0);
+ evas_object_show(td.rev_btn);
+ elm_object_disabled_set(td.rev_btn, EINA_TRUE);
+
//Button
Evas_Object *btn = elm_button_add(td.win);
elm_object_text_set(btn, "Go");
diff --git a/legacy/elementary/src/lib/elm_authors.h b/legacy/elementary/src/lib/elm_authors.h
index 5d583a168d..dd9cbd50d5 100644
--- a/legacy/elementary/src/lib/elm_authors.h
+++ b/legacy/elementary/src/lib/elm_authors.h
@@ -162,7 +162,7 @@
* @author yinsc <shouchen.yin@@samsung.com>
* @author Subodh Kumar <s7158.kumar@@samsung.com>
* @author Kumar Navneet <k.navneet@@samsung.com>
- * @author Godly T Alias <godly.talias@@samsung.com>
+ * @author Godly T Alias <godly.talias@@samsung.com> <godlytalias@@yahoo.co.in>
* @author Divyesh Purohit <div.purohit@samsung.com> <purohit.div@gmail.com>
* @author Minkyu Kang <mk7.kang@samsung.com>
* @author Jinyong Park <j4939.park@samsung.com>
diff --git a/legacy/elementary/src/lib/elm_transit.c b/legacy/elementary/src/lib/elm_transit.c
index 939825cc78..ea70529b2e 100644
--- a/legacy/elementary/src/lib/elm_transit.c
+++ b/legacy/elementary/src/lib/elm_transit.c
@@ -48,6 +48,8 @@ struct _Elm_Transit
double duration;
double begin;
double current;
+ double revert_start;
+ double revert_elapsed;
} time;
struct
{
@@ -56,6 +58,7 @@ struct _Elm_Transit
Eina_Bool reverse;
} repeat;
double progress;
+ double revert_begin_progress, revert_duration, total_revert_time;
unsigned int effects_pending_del;
int walking;
double v[4];
@@ -65,6 +68,7 @@ struct _Elm_Transit
Eina_Bool state_keep : 1;
Eina_Bool finished : 1;
Eina_Bool smooth : 1;
+ Eina_Bool revert_mode : 1;
};
struct _Elm_Transit_Effect_Module
@@ -327,16 +331,28 @@ static Eina_Bool
_transit_animate_cb(void *data)
{
Elm_Transit *transit = data;
- double elapsed_time, duration;
+ double elapsed_time, duration, revert_progress;
transit->time.current = ecore_loop_time_get();
- elapsed_time = transit->time.current - transit->time.begin;
+ elapsed_time = transit->time.current - transit->time.begin - 2 * transit->total_revert_time;
duration = transit->time.duration + transit->time.delayed;
-
if (elapsed_time > duration)
elapsed_time = duration;
transit->progress = elapsed_time / duration;
+ if (transit->revert_mode && transit->revert_begin_progress == 0)
+ {
+ transit->revert_begin_progress = transit->progress;
+ transit->time.revert_start = transit->time.current;
+ }
+
+ if (transit->revert_mode)
+ {
+ transit->time.revert_elapsed = transit->time.current - transit->time.revert_start;
+ revert_progress = transit->time.revert_elapsed / duration;
+ transit->progress = transit->revert_begin_progress - revert_progress;
+ }
+
switch (transit->tween_mode)
{
case ELM_TRANSIT_TWEEN_MODE_LINEAR:
@@ -395,8 +411,25 @@ _transit_animate_cb(void *data)
return ECORE_CALLBACK_CANCEL;
}
+ if (transit->revert_mode && (transit->progress <= 0 || transit->progress >= 1))
+ {
+ transit->revert_mode = EINA_FALSE;
+ transit->time.begin = ecore_loop_time_get();
+ transit->total_revert_time = 0;
+ if ((transit->repeat.count >= 0) &&
+ (transit->repeat.current == transit->repeat.count) &&
+ ((!transit->auto_reverse) || transit->repeat.reverse))
+ {
+ transit->finished = EINA_TRUE;
+ elm_transit_del(transit);
+ return ECORE_CALLBACK_CANCEL;
+ }
+ else
+ return ECORE_CALLBACK_RENEW;
+ }
+
/* Not end. Keep going. */
- if (elapsed_time < duration) return ECORE_CALLBACK_RENEW;
+ if (elapsed_time < duration || transit->revert_mode) return ECORE_CALLBACK_RENEW;
/* Repeat and reverse and time done! */
if ((transit->repeat.count >= 0) &&
@@ -417,6 +450,7 @@ _transit_animate_cb(void *data)
else transit->repeat.reverse = EINA_TRUE;
transit->time.begin = ecore_loop_time_get();
+ transit->total_revert_time = 0;
return ECORE_CALLBACK_RENEW;
}
@@ -495,6 +529,7 @@ elm_transit_add(void)
transit->v[0] = 1.0;
transit->v[1] = 0.0;
+ transit->revert_mode = EINA_FALSE;
transit->smooth = EINA_TRUE;
return transit;
@@ -739,6 +774,23 @@ elm_transit_duration_get(const Elm_Transit *transit)
}
EAPI void
+elm_transit_revert_go(Elm_Transit *transit)
+{
+ ELM_TRANSIT_CHECK_OR_RETURN(transit);
+ if (transit->revert_mode)
+ {
+ transit->total_revert_time += transit->time.revert_elapsed;
+ transit->revert_mode = EINA_FALSE;
+ }
+ else
+ {
+ transit->revert_mode = EINA_TRUE;
+ transit->time.revert_elapsed = 0;
+ transit->revert_begin_progress = 0;
+ }
+}
+
+EAPI void
elm_transit_go(Elm_Transit *transit)
{
ELM_TRANSIT_CHECK_OR_RETURN(transit);
@@ -761,6 +813,8 @@ elm_transit_go(Elm_Transit *transit)
transit->time.paused = 0;
transit->time.delayed = 0;
+ transit->total_revert_time = 0;
+ transit->revert_mode = EINA_FALSE;
transit->time.begin = ecore_loop_time_get();
transit->animator = ecore_animator_add(_transit_animate_cb, transit);
diff --git a/legacy/elementary/src/lib/elm_transit.h b/legacy/elementary/src/lib/elm_transit.h
index 90938d5ffe..6464d52c63 100644
--- a/legacy/elementary/src/lib/elm_transit.h
+++ b/legacy/elementary/src/lib/elm_transit.h
@@ -579,6 +579,25 @@ EAPI double elm_transit_duration_get(const Elm_Transit *transit)
EAPI void elm_transit_go(Elm_Transit *transit);
/**
+ * This API can be used to reverse play an ongoing transition.
+ * It shows effect only when an animation is going on.
+ * If this API is called twice transition will go in forward direction as normal one.
+ * If a repeat count is set, this API call will revert just the ongoing cycle and once
+ * it is reverted back completely, the transition will go in forward direction.
+ * If an autoreverse is set for the transition and this API is called in the midst of
+ * the transition the ongoing transition will be reverted and once it is done, the
+ * transition will begin again and complete a full auto reverse cycle.
+ *
+ * @note @p transit can not be NULL
+ *
+ * @param transit The transit object.
+ *
+ * @since 1.18
+ * @ingroup Transit
+ */
+EAPI void elm_transit_revert_go(Elm_Transit *transit);
+
+/**
* Starts the transition in given seconds.
*
* @note @p transit can not be NULL