From a0f5ff64cf9d48c6d530bae55880ae4365a1c116 Mon Sep 17 00:00:00 2001 From: Gwanglim Lee Date: Mon, 17 Aug 2015 16:36:31 +0900 Subject: [PATCH] sysinfo: added zoom effect Change-Id: I9eeb4e219049945f3fca90c219781643a4f0e9fe --- src/e_mod_main.c | 11 +- src/e_mod_sysinfo.c | 312 +++++++++++++++++++++++++++++++++++++++++++++------- src/e_mod_sysinfo.h | 1 + 3 files changed, 279 insertions(+), 45 deletions(-) diff --git a/src/e_mod_main.c b/src/e_mod_main.c index 9392e40..3fa54f4 100644 --- a/src/e_mod_main.c +++ b/src/e_mod_main.c @@ -689,17 +689,14 @@ _pol_cb_client_resize(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) e_zone_useful_geometry_get(ec->zone, NULL, NULL, NULL, &zh); evas_object_move(ec->frame, 0, (zh / 2) - (ec->h / 2)); } - /* - else if (e_mod_pol_client_is_sysinfo(ec)) - { - e_zone_useful_geometry_get(ec->zone, NULL, NULL, NULL, &zh); - evas_object_move(ec->frame, 0, (zh / 2) - (ec->h / 2)); - } - */ /* calculate e_client visibility */ e_mod_pol_visibility_calc(); +#ifdef HAVE_WAYLAND_ONLY + e_mod_pol_sysinfo_client_resize(ec); +#endif + return ECORE_CALLBACK_PASS_ON; } diff --git a/src/e_mod_sysinfo.c b/src/e_mod_sysinfo.c index e074ad4..606e980 100644 --- a/src/e_mod_sysinfo.c +++ b/src/e_mod_sysinfo.c @@ -7,17 +7,22 @@ #include #include -#define WIN_WIDTH 500 -#define WIN_HEIGHT 1080 +#define WIN_WIDTH 500 +#define WIN_HEIGHT 1080 +#define SCR_WIDTH 1920 +#define SCR_HEIGHT 1080 +#define SCR_MARGIN_W 30 typedef struct _E_Sysinfo { Eina_Bool show; E_Client *ec; Evas_Object *btn; + Evas_Object *bg; - // FPS - Evas_Object *fps, *fps_text; + /* FPS */ + Evas_Object *fps; + Evas_Object *fps_text; Ecore_Animator *fps_anim; double fps_src; double fps_target; @@ -31,12 +36,90 @@ typedef struct _E_Sysinfo Elm_Transit *trans; } effect; + struct + { + double noti_factor; + double noti_factor_src; + double noti_factor_target; + double normal_factor; + double normal_factor_src; + double normal_factor_target; + Eina_List *noti_list; /* list of E_Client */ + Eina_List *normal_list; /* list of E_Client */ + } zoom; + } E_Sysinfo; static E_Sysinfo *e_sysinfo = NULL; static Eina_List *handlers = NULL; static void +_win_map_apply(E_Client *ec, double factor) +{ + Evas_Map *map; + + if (!ec->frame) return; + + map = evas_map_new(4); + evas_map_util_points_populate_from_geometry(map, ec->client.x, ec->client.y, ec->client.w, ec->client.h, 0); + evas_map_util_zoom(map, factor, factor, SCR_WIDTH - 500, SCR_HEIGHT/2); + evas_map_util_object_move_sync_set(map, EINA_TRUE); + evas_object_map_set(ec->frame, map); + evas_object_map_enable_set(ec->frame, EINA_TRUE); + evas_map_free(map); +} + +static void +_win_effect_zoom(Eina_Bool show, double progress) +{ + Eina_List *l; + double col, zoom, factor; + Evas_Map *map; + E_Client *ec; + + factor = 0.4f; + if (show) zoom = 1.0 - (factor * progress); + else zoom = (1.0 - factor) + (factor * progress); + + EINA_LIST_FOREACH(e_sysinfo->zoom.normal_list, l, ec) + { + if (e_object_is_del(E_OBJECT(ec))) continue; + _win_map_apply(ec, zoom); + } + + factor = 0.25f; + if (show) zoom = 1.0 - (factor * progress); + else zoom = (1.0 - factor) + (factor * progress); + + EINA_LIST_FOREACH(e_sysinfo->zoom.noti_list, l, ec) + { + if (e_object_is_del(E_OBJECT(ec))) continue; + _win_map_apply(ec, zoom); + } + + factor = 0.1f; + if (show) + { + col = 255 - (120 * progress); + zoom = 1.0 - (factor * progress); + } + else + { + col = 135 + (120 * progress); + zoom = (1.0 - factor) + (factor * progress); + } + + evas_object_color_set(e_sysinfo->bg, col, col, col, 255); + + map = evas_map_new(4); + evas_map_util_points_populate_from_geometry(map, 0, 0, SCR_WIDTH, SCR_HEIGHT, 0); + evas_map_util_zoom(map, zoom, zoom, SCR_WIDTH/2, SCR_HEIGHT/2); + evas_object_map_set(e_sysinfo->bg, map); + evas_object_map_enable_set(e_sysinfo->bg, EINA_TRUE); + evas_map_free(map); +} + +static void _win_effect_cb_trans(Elm_Transit_Effect *eff EINA_UNUSED, Elm_Transit *trans EINA_UNUSED, double progress) { E_Client *ec; @@ -72,13 +155,19 @@ _win_effect_cb_trans(Elm_Transit_Effect *eff EINA_UNUSED, Elm_Transit *trans EIN evas_object_color_set(e_sysinfo->fps, col, col, col, col); evas_object_move(e_sysinfo->fps, 155, fps_y); - ELOGF("SYSINFO", "EFF DO |t:0x%08x prog:%.3f", NULL, NULL, (unsigned int)e_sysinfo->effect.trans, progress); + _win_effect_zoom(e_sysinfo->show, progress); } static void _win_effect_cb_trans_end(Elm_Transit_Effect *eff EINA_UNUSED, Elm_Transit *trans EINA_UNUSED) { ELOGF("SYSINFO", "EFF END |t:0x%08x", NULL, NULL, (unsigned int)e_sysinfo->effect.trans); + if (e_sysinfo->zoom.noti_list) eina_list_free(e_sysinfo->zoom.noti_list); + if (e_sysinfo->zoom.normal_list) eina_list_free(e_sysinfo->zoom.normal_list); + e_sysinfo->zoom.noti_list = NULL; + e_sysinfo->zoom.normal_list = NULL; + e_sysinfo->zoom.noti_factor = e_sysinfo->zoom.noti_factor_target; + e_sysinfo->zoom.normal_factor = e_sysinfo->zoom.normal_factor_target; e_sysinfo->effect.trans = NULL; } @@ -86,12 +175,26 @@ static void _win_effect_cb_trans_del(void *data EINA_UNUSED, Elm_Transit *transit EINA_UNUSED) { ELOGF("SYSINFO", "EFF DEL |t:0x%08x", NULL, NULL, (unsigned int)e_sysinfo->effect.trans); + if (e_sysinfo->zoom.noti_list) eina_list_free(e_sysinfo->zoom.noti_list); + if (e_sysinfo->zoom.normal_list) eina_list_free(e_sysinfo->zoom.normal_list); + e_sysinfo->zoom.noti_list = NULL; + e_sysinfo->zoom.normal_list = NULL; + e_sysinfo->zoom.noti_factor = e_sysinfo->zoom.noti_factor_target; + e_sysinfo->zoom.normal_factor = e_sysinfo->zoom.normal_factor_target; e_sysinfo->effect.trans = NULL; } static void _win_effect_init(void) { + E_Client *ec; + Evas_Object *o; + Eina_Tiler *t; + Eina_Rectangle r, *_r; + Eina_Iterator *it; + Eina_Bool canvas_vis = EINA_TRUE; + Eina_Bool ec_vis, ec_opaque; + if (e_sysinfo->effect.trans) { elm_transit_del_cb_set(e_sysinfo->effect.trans, NULL, NULL); @@ -110,11 +213,81 @@ _win_effect_init(void) elm_transit_tween_mode_set(e_sysinfo->effect.trans, ELM_TRANSIT_TWEEN_MODE_DECELERATE); elm_transit_objects_final_state_keep_set(e_sysinfo->effect.trans, EINA_FALSE); elm_transit_duration_set(e_sysinfo->effect.trans, 0.8f); + + // add E_Client + if (e_sysinfo->zoom.noti_list) eina_list_free(e_sysinfo->zoom.noti_list); + if (e_sysinfo->zoom.normal_list) eina_list_free(e_sysinfo->zoom.normal_list); + + t = eina_tiler_new(SCR_WIDTH, SCR_HEIGHT); + eina_tiler_tile_size_set(t, 1, 1); + + EINA_RECTANGLE_SET(&r, 0, 0, SCR_WIDTH, SCR_HEIGHT); + eina_tiler_rect_add(t, &r); + + o = evas_object_top_get(e_comp->evas); + for (; o; o = evas_object_below_get(o)) + { + ec = evas_object_data_get(o, "E_Client"); + + if (!ec) continue; + if (e_object_is_del(E_OBJECT(ec))) continue; + if (e_client_util_ignored_get(ec)) continue; + if ((e_sysinfo->ec) && (e_sysinfo->ec == ec)) continue; + + ec_vis = ec_opaque = EINA_FALSE; + + /* check visible state */ + if ((!ec->visible) || + (ec->iconic) || + (!evas_object_visible_get(ec->frame))) + { + ; /* do nothing */ + } + else + { + it = eina_tiler_iterator_new(t); + EINA_ITERATOR_FOREACH(it, _r) + { + if (E_INTERSECTS(ec->x, ec->y, ec->w, ec->h, + _r->x, _r->y, _r->w, _r->h)) + { + ec_vis = EINA_TRUE; + break; + } + } + eina_iterator_free(it); + } + + if (ec_vis) + { + if ((ec->visibility.opaque > 0) && (ec->argb)) + ec_opaque = EINA_TRUE; + + if ((!ec->argb) || (ec_opaque)) + { + EINA_RECTANGLE_SET(&r, ec->x, ec->y, ec->w, ec->h); + eina_tiler_rect_del(t, &r); + + if (eina_tiler_empty(t)) + canvas_vis = EINA_FALSE; + } + + if (!e_util_strcmp("e_demo", ec->icccm.window_role)) + e_sysinfo->zoom.noti_list = eina_list_append(e_sysinfo->zoom.noti_list, ec); + else + e_sysinfo->zoom.normal_list = eina_list_append(e_sysinfo->zoom.normal_list, ec); + } + + if (!canvas_vis) break; + } + eina_tiler_free(t); } static void _win_show(void) { + Evas_Object *o; + if ((!e_sysinfo->ec) || (!e_sysinfo->ec->frame)) return; e_comp->calc_fps = EINA_TRUE; @@ -130,6 +303,28 @@ _win_show(void) evas_object_show(e_sysinfo->fps); } + if (!e_sysinfo->bg) + { + o = edje_object_add(e_comp->evas); + edje_object_file_set(o, "/usr/share/enlightenment/data/backgrounds/Wetleaf.edj", + "e/desktop/background"); + if (edje_object_data_get(o, "noanimation")) + edje_object_animation_set(o, EINA_FALSE); + evas_object_move(o, 0, 0); + evas_object_resize(o, SCR_WIDTH, SCR_HEIGHT); + evas_object_layer_set(o, E_LAYER_BG); + evas_object_show(o); + e_sysinfo->bg = o; + } + + e_sysinfo->zoom.noti_factor = 1.0; + e_sysinfo->zoom.noti_factor_src = 1.0; + e_sysinfo->zoom.noti_factor_target = 0.75; + + e_sysinfo->zoom.normal_factor = 1.0; + e_sysinfo->zoom.normal_factor_src = 1.0; + e_sysinfo->zoom.normal_factor_target = 0.6; + elm_transit_go(e_sysinfo->effect.trans); } @@ -145,6 +340,14 @@ _win_hide(void) ELOGF("SYSINFO", "EFF HIDE |t:0x%08x", NULL, NULL, (unsigned int)e_sysinfo->effect.trans); + e_sysinfo->zoom.noti_factor = 0.75; + e_sysinfo->zoom.noti_factor_src = 0.75; + e_sysinfo->zoom.noti_factor_target = 1.0; + + e_sysinfo->zoom.normal_factor = 0.6; + e_sysinfo->zoom.normal_factor_src = 0.6; + e_sysinfo->zoom.normal_factor_target = 1.0; + elm_transit_go(e_sysinfo->effect.trans); } @@ -160,31 +363,66 @@ _btn_cb_mouse_up(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSE void e_mod_pol_sysinfo_client_add(E_Client *ec) { - if (!e_mod_pol_client_is_sysinfo(ec)) return; - ELOGF("SYSINFO", - "ADD |internale_elm_win:0x%08x %dx%d", - ec->pixmap, ec, - (unsigned int)ec->internal_elm_win, - ec->w, ec->h); - - e_sysinfo->ec = ec; + "ADD |%dx%d frame:0x%08x vis:%d", + ec->pixmap, ec, ec->w, ec->h, + (unsigned int)ec->frame, + ec->frame ? evas_object_visible_get(ec->frame) : 0); - if (e_sysinfo->show) _win_show(); + if (e_mod_pol_client_is_sysinfo(ec)) + { + e_sysinfo->ec = ec; + if (e_sysinfo->show) _win_show(); + } } void e_mod_pol_sysinfo_client_del(E_Client *ec) { - if (e_sysinfo->ec != ec) return; - ELOGF("SYSINFO", - "DEL |internale_elm_win:0x%08x %dx%d", - ec->pixmap, ec, - (unsigned int)ec->internal_elm_win, - ec->w, ec->h); + "DEL |%dx%d frame:0x%08x vis:%d", + ec->pixmap, ec, ec->w, ec->h, + (unsigned int)ec->frame, + ec->frame ? evas_object_visible_get(ec->frame) : 0); - e_sysinfo->ec = NULL; + if (e_sysinfo->ec == ec) + { + e_sysinfo->ec = NULL; + } + else + { + if (eina_list_data_find(e_sysinfo->zoom.normal_list, ec)) + e_sysinfo->zoom.normal_list = eina_list_remove(e_sysinfo->zoom.normal_list, ec); + else if (eina_list_data_find(e_sysinfo->zoom.noti_list, ec)) + e_sysinfo->zoom.noti_list = eina_list_remove(e_sysinfo->zoom.noti_list, ec); + } +} + +void +e_mod_pol_sysinfo_client_resize(E_Client *ec) +{ + ELOGF("SYSINFO", + "REZ |%dx%d frame:0x%08x vis:%d", + ec->pixmap, ec, ec->w, ec->h, + (unsigned int)ec->frame, + ec->frame ? evas_object_visible_get(ec->frame) : 0); + + if (!e_mod_pol_client_is_sysinfo(ec) && + (e_sysinfo->zoom.normal_factor < 1.0) && + (ec->w >= 300) && (ec->h >= 300) && + (ec->visible) && + (ec->frame) && + evas_object_visible_get(ec->frame)) + { + if (!evas_object_data_get(ec->frame, "client_mapped")) + { + if (!e_util_strcmp("e_demo", ec->icccm.window_role)) + _win_map_apply(ec, e_sysinfo->zoom.noti_factor); + else + _win_map_apply(ec, e_sysinfo->zoom.normal_factor); + evas_object_data_set(ec->frame, "client_mapped", (void*)1); + } + } } static Eina_Bool @@ -250,37 +488,34 @@ _sysinfo_cb_comp_fps_update(void *data EINA_UNUSED, int type EINA_UNUSED, void * Eina_Bool e_mod_pol_sysinfo_init(void) { - Evas_Object *o, *comp_obj, *text; + Evas_Object *o, *comp_obj; e_sysinfo = E_NEW(E_Sysinfo, 1); EINA_SAFETY_ON_NULL_RETURN_VAL(e_sysinfo, EINA_FALSE); + o = evas_object_text_add(e_comp->evas); + evas_object_text_font_set(o, "TizenSans", 75); + evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.0); + evas_object_text_text_set(o, "0.0"); + evas_object_move(o, 200, 200); + comp_obj = e_comp_object_util_add(o, E_COMP_OBJECT_TYPE_NONE); + evas_object_layer_set(comp_obj, E_LAYER_POPUP); + e_sysinfo->fps_text = o; + e_sysinfo->fps = comp_obj; + e_sysinfo->fps_src = 0.0f; + e_sysinfo->fps_target = 0.0f; + e_sysinfo->fps_curr = 0.0f; + o = evas_object_rectangle_add(e_comp->evas); evas_object_color_set(o, 0, 0, 0, 0); evas_object_resize(o, 64, 64); evas_object_move(o, 0, 0); - comp_obj = e_comp_object_util_add(o, E_COMP_OBJECT_TYPE_NONE); evas_object_layer_set(comp_obj, E_LAYER_POPUP); evas_object_event_callback_add(comp_obj, EVAS_CALLBACK_MOUSE_UP, _btn_cb_mouse_up, NULL); evas_object_show(comp_obj); - e_sysinfo->btn = comp_obj; - text = evas_object_text_add(e_comp->evas); - evas_object_text_font_set(text, "TizenSans", 75); - evas_object_size_hint_align_set(text, EVAS_HINT_FILL, 0.0); - evas_object_text_text_set(text, "0.0"); - evas_object_move(text, 200, 200); - comp_obj = e_comp_object_util_add(text, E_COMP_OBJECT_TYPE_NONE); - evas_object_layer_set(comp_obj, E_LAYER_POPUP); - - e_sysinfo->fps_text = text; - e_sysinfo->fps = comp_obj; - e_sysinfo->fps_src = 0.0f; - e_sysinfo->fps_target = 0.0f; - e_sysinfo->fps_curr = 0.0f; - E_LIST_HANDLER_APPEND(handlers, E_EVENT_COMPOSITOR_FPS_UPDATE, _sysinfo_cb_comp_fps_update, NULL); return EINA_TRUE; @@ -303,6 +538,7 @@ e_mod_pol_sysinfo_shutdown(void) e_sysinfo->effect.trans = NULL; } + evas_object_del(e_sysinfo->bg); evas_object_del(e_sysinfo->fps); evas_object_del(e_sysinfo->btn); diff --git a/src/e_mod_sysinfo.h b/src/e_mod_sysinfo.h index b326bc4..2866999 100644 --- a/src/e_mod_sysinfo.h +++ b/src/e_mod_sysinfo.h @@ -11,6 +11,7 @@ Eina_Bool e_mod_pol_sysinfo_init(void); void e_mod_pol_sysinfo_shutdown(void); void e_mod_pol_sysinfo_client_add(E_Client *ec); void e_mod_pol_sysinfo_client_del(E_Client *ec); +void e_mod_pol_sysinfo_client_resize(E_Client *ec); #endif /* HAVE_WAYLAND_ONLY */ #endif /* E_MOD_SYSINFO_H */ -- 2.7.4