From: Radek Kintop Date: Fri, 11 Mar 2016 15:43:39 +0000 (+0100) Subject: Added back/esc button functionality on gengrid list items X-Git-Tag: accepted/tizen/tv/20160314.113326~3^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3d63c8b89c861ed5fa10f8b6dce0c9abeda274a2;p=profile%2Ftv%2Fapps%2Fnative%2Fair_settings.git Added back/esc button functionality on gengrid list items Change-Id: I0063c739a183a96636b9061ecaab73c90c5ad695 Signed-off-by: Bartlomiej Uliasz --- diff --git a/src/layout/layout_sound.c b/src/layout/layout_sound.c index 275a2e0..53dc0c1 100644 --- a/src/layout/layout_sound.c +++ b/src/layout/layout_sound.c @@ -68,6 +68,7 @@ struct _priv { layoutmgr *lmgr; struct listmgr *list_mgr; + Evas_Object *tab_btn; Eina_List *sound_modes_list; Eina_List *speakers_list; Elm_Object_Item *selected_sound_mode; @@ -89,6 +90,8 @@ static void _destroy(void *layout_data); static void _update(void *layout_data, int update_type, void *data); static void _grid_focused(int id, void *data, Evas_Object *obj, Elm_Object_Item *item); +static void _key_down_cb(int id, void *data, Evas *e, Evas_Object *obj, + Evas_Event_Key_Down *ev); static layout_class _lclass = { .layout_id = LAYOUT_ID_SOUND, @@ -100,9 +103,28 @@ static layout_class _lclass = { }; static input_handler grid_handler = { - .focused = _grid_focused + .focused = _grid_focused, + .key_down = _key_down_cb }; + +static void _key_down_cb(int id, void *data, Evas *e, Evas_Object *obj, + Evas_Event_Key_Down *ev) +{ + SETTING_TRACE_BEGIN; + + struct _priv *priv = data; + + if (!ev || !priv) { + _ERR("Invalid argument."); + return; + } + + if (!strcmp(ev->keyname, KEY_BACK) || !strcmp(ev->keyname, KEY_ESC)) { + elm_object_focus_set(priv->tab_btn, EINA_TRUE); + } +} + layout_class *layout_sound_get_lclass(void) { return &_lclass; @@ -166,7 +188,7 @@ static bool _create(layoutmgr *lmgr, void *data) return false; } - listmgr_add_inner_grid_cb(priv->list_mgr, LIST_SOUND_MODES_ID, &grid_handler, NULL); + listmgr_add_inner_grid_cb(priv->list_mgr, LIST_SOUND_MODES_ID, &grid_handler, priv); if (!listmgr_add_list(priv->list_mgr, LIST_SPEAKERS_ID, get_sound_grid_class(), _speaker_selected_cb, priv)) { @@ -177,13 +199,14 @@ static bool _create(layoutmgr *lmgr, void *data) return false; } - listmgr_add_inner_grid_cb(priv->list_mgr, LIST_SPEAKERS_ID, &grid_handler, NULL); + listmgr_add_inner_grid_cb(priv->list_mgr, LIST_SPEAKERS_ID, &grid_handler, priv); - if(data) { + priv->tab_btn = (Evas_Object *)data; + if(priv->tab_btn) { listmgr_set_list_next_focus(priv->list_mgr, LIST_SOUND_MODES_ID, - (Evas_Object *)data, ELM_FOCUS_UP, EINA_TRUE, ELM_FOCUS_DOWN); + priv->tab_btn, ELM_FOCUS_UP, EINA_TRUE, ELM_FOCUS_DOWN); listmgr_set_list_next_focus(priv->list_mgr, LIST_SPEAKERS_ID, - (Evas_Object *)data, ELM_FOCUS_UP, EINA_FALSE, ELM_FOCUS_UP); + priv->tab_btn, ELM_FOCUS_UP, EINA_FALSE, ELM_FOCUS_UP); } if (!_fill_lists(priv)) { diff --git a/src/view/system/view_location.c b/src/view/system/view_location.c index 93b12b2..17a6553 100644 --- a/src/view/system/view_location.c +++ b/src/view/system/view_location.c @@ -53,11 +53,16 @@ enum object_type { static void _btn_clicked_cb(int id, void *data, Evas_Object *obj); static void _btn_key_down_cb(int id, void *data, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev); + static input_handler _input_handler = { .clicked = _btn_clicked_cb, .key_down = _btn_key_down_cb }; +static input_handler _grid_input_handler = { + .key_down = _btn_key_down_cb +}; + static void _data_event_cb(enum event_type type, void *data) { SETTING_TRACE_BEGIN; @@ -180,9 +185,7 @@ static void _btn_key_down_cb(int id, void *data, Evas *e, Evas_Object *obj, { SETTING_TRACE_BEGIN; - struct _priv *priv = data; - - if (!ev || !priv) { + if (!ev) { _ERR("Invalid argument."); return; } @@ -238,9 +241,9 @@ static Evas_Object *_create(Evas_Object *win, void *data) { SETTING_TRACE_BEGIN; struct _priv *priv = NULL; - struct datamgr *dmgr = NULL; + struct datamgr *data_mgr = NULL; Evas_Object *base = NULL; - struct listmgr *listmgr = NULL; + struct listmgr *list_mgr = NULL; if (!win) { _ERR("Get window object failed."); @@ -262,47 +265,48 @@ static Evas_Object *_create(Evas_Object *win, void *data) priv->base = base; - dmgr = datamgr_create(get_location_data_class(), _data_event_cb, priv); - if (!dmgr) { + data_mgr = datamgr_create(get_location_data_class(), _data_event_cb, priv); + if (!data_mgr) { _ERR("Create datamgr failed."); free(priv); evas_object_del(base); return NULL; } - listmgr = listmgr_create(base); - if (!listmgr) { + list_mgr = listmgr_create(base); + if (!list_mgr) { _ERR("Create listmgr failed."); - datamgr_destroy(dmgr); + datamgr_destroy(data_mgr); free(priv); evas_object_del(base); return NULL; } - if (!listmgr_add_list(listmgr, LOCATION_LIST_ID, get_location_grid_class(), + if (!listmgr_add_list(list_mgr, LOCATION_LIST_ID, get_location_grid_class(), _country_selected_cb, priv)) { _ERR("Add location list failed."); - listmgr_destroy(listmgr); - datamgr_destroy(dmgr); + listmgr_destroy(list_mgr); + datamgr_destroy(data_mgr); free(priv); evas_object_del(base); return NULL; } + listmgr_add_inner_grid_cb(list_mgr, LOCATION_LIST_ID, &_grid_input_handler, NULL); priv->win = win; - priv->list_mgr = listmgr; - priv->country_data_mgr = dmgr; + priv->list_mgr = list_mgr; + priv->country_data_mgr = data_mgr; if (!viewmgr_set_view_data(VIEW_LOCATION, priv)) { _ERR("Set view data failed."); - listmgr_destroy(listmgr); - datamgr_destroy(dmgr); + listmgr_destroy(list_mgr); + datamgr_destroy(data_mgr); evas_object_del(base); free(priv); return NULL; } - data_location_fill_list_data(listmgr, &priv->configured_country, NULL); + data_location_fill_list_data(list_mgr, &priv->configured_country, NULL); _draw_menu_area(priv);