From: Bartlomiej Uliasz Date: Mon, 29 Feb 2016 15:31:22 +0000 (+0100) Subject: Fixed incorrect focus on ctxpopup items X-Git-Tag: accepted/tizen/tv/20160308.101500~11 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a5a3a4d01a43c585629d8b659696316ed2b12a0f;p=profile%2Ftv%2Fapps%2Fnative%2Fair_settings.git Fixed incorrect focus on ctxpopup items Change-Id: Ic558fb665f7eb2b6ce889f01b47648bcf86dbeb8 Signed-off-by: Bartlomiej Uliasz --- diff --git a/include/common/utils.h b/include/common/utils.h index ea501c9..4376a7f 100644 --- a/include/common/utils.h +++ b/include/common/utils.h @@ -32,7 +32,7 @@ Evas_Object *utils_add_popup(Evas_Object *parent, const char *style, const char *popup_title, const char *popup_text); Evas_Object *utils_add_table(Evas_Object *parent, int padding_x, int padding_y); Evas_Object *utils_add_ctxpopup(Evas_Object *parent, int opt_size, int *opt_id, - const char **opt_text, void *opt_handler, void *data); + const char **opt_text, void *opt_handler, void *data, int selected); Evas_Object *utils_add_gengrid(Evas_Object *parent, Eina_Bool horizontal, int width, int height); Evas_Object *utils_add_entry(Evas_Object *parent, const char *part, diff --git a/src/common/utils.c b/src/common/utils.c index 2158608..ef34e9d 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -196,9 +196,9 @@ Evas_Object *utils_add_table(Evas_Object *parent, int padding_x, int padding_y) } Evas_Object *utils_add_ctxpopup(Evas_Object *parent, int opt_size, int *opt_id, - const char **opt_text, void *opt_handler, void *data) + const char **opt_text, void *opt_handler, void *data, int selected) { - Evas_Object *ctxpopup, *box, *btn, *firstbtn; + Evas_Object *ctx_popup, *box, *btn, *first_btn; int i; if (!parent || opt_size <= 0 || !opt_text) { @@ -206,30 +206,30 @@ Evas_Object *utils_add_ctxpopup(Evas_Object *parent, int opt_size, int *opt_id, return NULL; } - ctxpopup = elm_ctxpopup_add(parent); - if (!ctxpopup) { + ctx_popup = elm_ctxpopup_add(parent); + if (!ctx_popup) { _ERR("elm_ctxpopup_add failed."); return NULL; } - box = utils_add_box(ctxpopup, NULL, EINA_FALSE, 0, 0); + box = utils_add_box(ctx_popup, NULL, EINA_FALSE, 0, 0); if (!box) { _ERR("Add box failed."); - evas_object_del(ctxpopup); + evas_object_del(ctx_popup); return NULL; } - elm_object_style_set(ctxpopup, STYLE_CTXPOPUP); - elm_object_content_set(ctxpopup, box); - elm_ctxpopup_direction_priority_set(ctxpopup, 0, 0, 0, 0); - evas_object_show(ctxpopup); + elm_object_style_set(ctx_popup, STYLE_CTXPOPUP); + elm_object_content_set(ctx_popup, box); + elm_ctxpopup_direction_priority_set(ctx_popup, 0, 0, 0, 0); + evas_object_show(ctx_popup); for (i = 0; i < opt_size; i++) { btn = utils_add_button(box, NULL, STYLE_OPTION_LIST_BTN, opt_text[i]); if (!btn) { _ERR("Add button failed."); - evas_object_del(ctxpopup); + evas_object_del(ctx_popup); return NULL; } @@ -240,13 +240,16 @@ Evas_Object *utils_add_ctxpopup(Evas_Object *parent, int opt_size, int *opt_id, opt_handler, data); if (i == 0) - firstbtn = btn; + first_btn = btn; + + if (i == selected) + elm_object_focus_set(btn, EINA_TRUE); } - elm_object_focus_next_object_set(firstbtn, btn, ELM_FOCUS_UP); - elm_object_focus_next_object_set(btn, firstbtn, ELM_FOCUS_DOWN); + elm_object_focus_next_object_set(first_btn, btn, ELM_FOCUS_UP); + elm_object_focus_next_object_set(btn, first_btn, ELM_FOCUS_DOWN); - return ctxpopup; + return ctx_popup; } Evas_Object *utils_add_gengrid(Evas_Object *parent, Eina_Bool horizontal, diff --git a/src/layout/layout_network.c b/src/layout/layout_network.c index e2d79eb..708812d 100644 --- a/src/layout/layout_network.c +++ b/src/layout/layout_network.c @@ -109,7 +109,7 @@ static void _network_type_option_selected(struct _priv *priv, int id, Evas_Object *preserve; _destroy_network_type_popup(priv); - elm_object_text_set(priv->network_type_btn, elm_object_text_get(obj)); + elm_object_text_set(priv->network_type_btn, str_network_type_opt[id]); switch (id) { case TYPE_WIRELESS: @@ -228,7 +228,7 @@ static void _draw_network_type_popup(struct _priv *priv) ctxpopup = utils_add_ctxpopup(priv->base, COUNT_NETWORK_TYPE, id_network_type_opt, str_network_type_opt, - &_network_type_option_input_handler, priv); + &_network_type_option_input_handler, priv, priv->cur_type); if (!ctxpopup) { _ERR("Add ctxpopup failed."); return; @@ -239,8 +239,6 @@ static void _draw_network_type_popup(struct _priv *priv) evas_object_size_hint_min_set(ctxpopup, w, 0); priv->network_type_popup = ctxpopup; - - elm_object_focus_set(priv->network_type_popup, EINA_TRUE); } static void _network_type_mouse_down_cb(int id, void *data, Evas *e, @@ -845,7 +843,7 @@ static bool _draw_network_buttons(struct _priv *priv) Evas_Object *btn1, *btn2; btn1 = utils_add_button(priv->ly, PART_NETWORK_TYPE, STYLE_OPTION_BTN, - STR_WIRELESS); + str_network_type_opt[priv->cur_type]); if (!btn1) { _ERR("Add button failed."); return false; @@ -866,7 +864,6 @@ static bool _draw_network_buttons(struct _priv *priv) priv->network_type_btn = btn1; priv->action_btn = btn2; - priv->cur_type = TYPE_WIRELESS; return true; } @@ -942,6 +939,8 @@ static bool _create(layoutmgr *lmgr, void *data) priv->listmgr = listmgr; priv->wireless_support = true; priv->wireless_update_requested = false; + // TODO: detect currently selected network type + priv->cur_type = TYPE_WIRELESS; if (!_draw_network_buttons(priv)) { _ERR("Draw network buttons failed."); diff --git a/src/view/system/view_clock.c b/src/view/system/view_clock.c index 037b34e..b008f35 100644 --- a/src/view/system/view_clock.c +++ b/src/view/system/view_clock.c @@ -159,7 +159,7 @@ static void _draw_setup_type_popup(clock_view_priv_data *priv) ctxpopup = utils_add_ctxpopup(priv->base, TYPE_MAX, id_setup_type_opt, str_setup_type_opt, - &_auto_manual_setup_option_selection_input_handler, priv); + &_auto_manual_setup_option_selection_input_handler, priv, priv->cur_type); if (!ctxpopup) { _ERR("Add ctxpopup failed.");