From 2e92cbfc969c98d8eb54f65e7093a44864f83785 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Briano?= Date: Tue, 28 Sep 2010 16:54:11 +0000 Subject: [PATCH] Killed the bottom object. It will come back once the stacking issues are resolved or decided how to handle. But that's minor and non-important, the real deal here is animating the focus highlight object, entirely in the theme. SVN revision: 52853 --- legacy/elementary/data/themes/default.edc | 72 +++++++++++++ legacy/elementary/src/lib/elm_win.c | 119 ++++++++++++++-------- 2 files changed, 146 insertions(+), 45 deletions(-) diff --git a/legacy/elementary/data/themes/default.edc b/legacy/elementary/data/themes/default.edc index 179d97d8fa..b569433d7e 100644 --- a/legacy/elementary/data/themes/default.edc +++ b/legacy/elementary/data/themes/default.edc @@ -13,6 +13,78 @@ collections { images { image: "emo-unhappy.png" COMP; } + + data { + item: "animate" "on"; + } + + script { + public s_x, s_y, s_w, s_h; /* source */ + public difx, dify, difw, difh; + + public animator1(val, Float:pos) { + new x, y, w, h, dx, dy, dw, dh; + + dx = round(float_mul(float(get_int(difx)), pos)); + x = get_int(s_x) + dx; + dy = round(float_mul(float(get_int(dify)), pos)); + y = get_int(s_y) + dy; + dw = round(float_mul(float(get_int(difw)), pos)); + w = get_int(s_w) + dw; + dy = round(float_mul(float(get_int(difh)), pos)); + h = get_int(s_h) + dh; + + update_offset(x, y, w, h); + + if (pos >= 1.0) { + emit("elm,action,focus,anim,end", ""); + set_state(PART:"shine", "default", 0.0); + } + } + + public update_offset(x, y, w, h) { + new x1, y1, x2, y2; + x1 = x + w - 15; + y1 = y - 15; + x2 = x + w + 14; + y2 = y + 14; + set_state_val(PART:"shine", STATE_REL1_OFFSET, x1, y1); + set_state_val(PART:"shine", STATE_REL2_OFFSET, x2, y2); + } + + public message(Msg_Type:type, id, ...) { + if ((type == MSG_INT_SET) && (id == 1)) { + new x1, y1, w1, h1; + new x2, y2, w2, h2; + + x1 = getarg(2); + y1 = getarg(3); + w1 = getarg(4); + h1 = getarg(5); + x2 = getarg(6); + y2 = getarg(7); + w2 = getarg(8); + h2 = getarg(9); + set_int(s_x, x1); + set_int(s_y, y1); + set_int(s_w, w1); + set_int(s_h, h1); + set_int(difx, x2 - x1); + set_int(dify, y2 - y1); + set_int(difw, w2 - w1); + set_int(difh, h2 - h1); + + custom_state(PART:"shine", "default", 0.0); + set_state_val(PART:"shine", STATE_REL1, 0.0, 0.0); + set_state_val(PART:"shine", STATE_REL2, 0.0, 0.0); + update_offset(x1, y1, w1, h1); + set_state(PART:"shine", "custom", 0.0); + + anim(0.2, "animator1", 1); + } + } + } + parts { part { name: "base"; type: RECT; diff --git a/legacy/elementary/src/lib/elm_win.c b/legacy/elementary/src/lib/elm_win.c index 8ef5947775..4e1d9404b1 100644 --- a/legacy/elementary/src/lib/elm_win.c +++ b/legacy/elementary/src/lib/elm_win.c @@ -32,7 +32,7 @@ struct _Elm_Win } screen; struct { - Evas_Object *bottom, *top; + Evas_Object *top; Evas_Object *previous, *target; Ecore_Job *reconf_job; @@ -42,6 +42,7 @@ struct _Elm_Win Eina_Bool visible : 1; Eina_Bool handled : 1; Eina_Bool was_handled : 1; + Eina_Bool top_animate : 1; } focus_highlight; }; @@ -64,6 +65,7 @@ static void _elm_win_focus_highlight_shutdown(Elm_Win *win); static void _elm_win_focus_highlight_visible_set(Elm_Win *win, Eina_Bool visible); static void _elm_win_focus_highlight_reconfigure_job_start(Elm_Win *win); static void _elm_win_focus_highlight_reconfigure_job_stop(Elm_Win *win); +static void _elm_win_focus_highlight_anim_end(void *data, Evas_Object *obj, const char *emission, const char *source); static void _elm_win_focus_highlight_reconfigure(Elm_Win *win); Eina_List *_elm_win_list = NULL; @@ -602,8 +604,6 @@ _elm_win_object_focus_out(void *data, Evas *e, void *event_info __UNUSED__) if (!win->focus_highlight.handled) _elm_win_focus_target_callbacks_del(win); - win->focus_highlight.was_handled = win->focus_highlight.handled; - win->focus_highlight.previous = win->focus_highlight.target; win->focus_highlight.target = NULL; win->focus_highlight.handled = EINA_FALSE; @@ -627,15 +627,14 @@ _elm_win_focus_highlight_init(Elm_Win *win) win->focus_highlight.target = evas_focus_get(win->evas); - win->focus_highlight.bottom = edje_object_add(win->evas); win->focus_highlight.top = edje_object_add(win->evas); win->focus_highlight.changed_theme = EINA_TRUE; - edje_object_signal_callback_add(win->focus_highlight.bottom, - "elm,action,focus,hide,end", "", - _elm_win_focus_highlight_hide, NULL); edje_object_signal_callback_add(win->focus_highlight.top, "elm,action,focus,hide,end", "", _elm_win_focus_highlight_hide, NULL); + edje_object_signal_callback_add(win->focus_highlight.top, + "elm,action,focus,anim,end", "", + _elm_win_focus_highlight_anim_end, win); _elm_win_focus_highlight_reconfigure_job_start(win); } @@ -647,11 +646,6 @@ _elm_win_focus_highlight_shutdown(Elm_Win *win) _elm_win_focus_target_callbacks_del(win); win->focus_highlight.target = NULL; } - if (win->focus_highlight.bottom) - { - evas_object_del(win->focus_highlight.bottom); - win->focus_highlight.bottom = NULL; - } if (win->focus_highlight.top) { evas_object_del(win->focus_highlight.top); @@ -669,17 +663,11 @@ _elm_win_focus_highlight_shutdown(Elm_Win *win) static void _elm_win_focus_highlight_visible_set(Elm_Win *win, Eina_Bool visible) { - Evas_Object *bottom, *top; + Evas_Object *top; - bottom = win->focus_highlight.bottom; top = win->focus_highlight.top; if (visible) { - if (bottom) - { - evas_object_show(bottom); - edje_object_signal_emit(bottom, "elm,action,focus,show", "elm"); - } if (top) { evas_object_show(top); @@ -688,8 +676,6 @@ _elm_win_focus_highlight_visible_set(Elm_Win *win, Eina_Bool visible) } else { - if (bottom) - edje_object_signal_emit(bottom, "elm,action,focus,hide", "elm"); if (top) edje_object_signal_emit(top, "elm,action,focus,hide", "elm"); } @@ -719,24 +705,72 @@ _elm_win_focus_highlight_reconfigure_job_stop(Elm_Win *win) } static void -_elm_win_focus_highlight_reconfigure(Elm_Win *win) +_elm_win_focus_highlight_simple_setup(Elm_Win *win, Evas_Object *obj) +{ + Evas_Object *clip, *target = win->focus_highlight.target; + Evas_Coord x, y, w, h; + + clip = evas_object_clip_get(target); + evas_object_geometry_get(target, &x, &y, &w, &h); + + evas_object_move(obj, x, y); + evas_object_resize(obj, w, h); + evas_object_clip_set(obj, clip); +} + +static void +_elm_win_focus_highlight_anim_setup(Elm_Win *win, Evas_Object *obj) { Evas_Coord tx, ty, tw, th; + Evas_Coord w, h, px, py, pw, ph; + Edje_Message_Int_Set *m; + Evas_Object *previous = win->focus_highlight.previous; + Evas_Object *target = win->focus_highlight.target; + + evas_object_geometry_get(win->win_obj, NULL, NULL, &w, &h); + evas_object_geometry_get(target, &tx, &ty, &tw, &th); + evas_object_geometry_get(previous, &px, &py, &pw, &ph); + evas_object_move(obj, 0, 0); + evas_object_resize(obj, tw, th); + evas_object_clip_unset(obj); + + m = alloca(sizeof(*m) + (sizeof(int) * 8)); + m->count = 8; + m->val[0] = px; + m->val[1] = py; + m->val[2] = pw; + m->val[3] = ph; + m->val[4] = tx; + m->val[5] = ty; + m->val[6] = tw; + m->val[7] = th; + edje_object_message_send(obj, EDJE_MESSAGE_INT_SET, 1, m); +} + +static void +_elm_win_focus_highlight_anim_end(void *data, Evas_Object *obj, const char *emission, const char *source) +{ + Elm_Win *win = data; + _elm_win_focus_highlight_simple_setup(win, obj); +} + +static void +_elm_win_focus_highlight_reconfigure(Elm_Win *win) +{ Evas_Object *target = win->focus_highlight.target; Evas_Object *previous = win->focus_highlight.previous; - Evas_Object *bottom, *top, *clip; + Evas_Object *top = win->focus_highlight.top; Eina_Bool common_visible; const char *sig = NULL; _elm_win_focus_highlight_reconfigure_job_stop(win); - bottom = win->focus_highlight.bottom; - top = win->focus_highlight.top; - if (previous && win->focus_highlight.was_handled) elm_widget_signal_emit(previous, "elm,action,focus_highlight,hide", "elm"); - if (win->focus_highlight.handled) + if (!target) + common_visible = EINA_FALSE; + else if (win->focus_highlight.handled) { common_visible = EINA_FALSE; if (win->focus_highlight.visible) @@ -751,35 +785,30 @@ _elm_win_focus_highlight_reconfigure(Elm_Win *win) if (sig) elm_widget_signal_emit(target, sig, "elm"); - if (!target || win->focus_highlight.handled) + if (!target || !common_visible || win->focus_highlight.handled) goto the_end; if (win->focus_highlight.changed_theme) { - _elm_theme_object_set(win->win_obj, bottom, "focus_highlight", "bottom", - "default"); /* FIXME: use style */ + const char *str; _elm_theme_object_set(win->win_obj, top, "focus_highlight", "top", - "default"); + "default"); /* FIXME: use style */ win->focus_highlight.changed_theme = EINA_FALSE; + + str = edje_object_data_get(win->focus_highlight.top, "animate"); + win->focus_highlight.top_animate = (str && !strcmp(str, "on")); } - evas_object_geometry_get(target, &tx, &ty, &tw, &th); - - clip = evas_object_clip_get(target); - - evas_object_move(bottom, tx, ty); - evas_object_resize(bottom, tw, th); - evas_object_lower(bottom); - evas_object_clip_set(bottom, clip); - - evas_object_move(top, tx, ty); - evas_object_resize(top, tw, th); + if (win->focus_highlight.top_animate && previous && + !win->focus_highlight.was_handled) + _elm_win_focus_highlight_anim_setup(win, top); + else + _elm_win_focus_highlight_simple_setup(win, top); evas_object_raise(top); - evas_object_clip_set(top, clip); the_end: - win->focus_highlight.previous = NULL; - win->focus_highlight.was_handled = EINA_FALSE; + win->focus_highlight.previous = target; + win->focus_highlight.was_handled = win->focus_highlight.handled; } /**