summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJehun Lim <jehun.lim@samsung.com>2015-09-30 17:42:39 +0900
committerJehun Lim <jehun.lim@samsung.com>2015-09-30 17:42:39 +0900
commit42643ae109ad310f9b356d996be1247aaefaa85d (patch)
tree5cc2c5a889a65392524d6c0160efccc5abc54e32
parent242a22d3de6ce22a806b9d96c5ca73609c236caa (diff)
downloadair_mediahub-42643ae109ad310f9b356d996be1247aaefaa85d.tar.gz
air_mediahub-42643ae109ad310f9b356d996be1247aaefaa85d.tar.bz2
air_mediahub-42643ae109ad310f9b356d996be1247aaefaa85d.zip
ctxpopup: set focus to selected item
Change-Id: I31ebd53fd25532897790765e8287907adaacf226 Signed-off-by: Jehun Lim <jehun.lim@samsung.com>
-rw-r--r--include/util/ctxpopup.h2
-rw-r--r--src/util/ctxpopup.c14
-rw-r--r--src/view/base.c3
3 files changed, 16 insertions, 3 deletions
diff --git a/include/util/ctxpopup.h b/include/util/ctxpopup.h
index b479373..4b6d0b9 100644
--- a/include/util/ctxpopup.h
+++ b/include/util/ctxpopup.h
@@ -21,7 +21,7 @@ struct ctxpopup;
struct ctxpopup *ctxpopup_create(Evas_Object *base,
const char *ctxpopup_style, const char *btn_style,
- const char **text, int text_size);
+ const char **text, int text_size, int cur_index);
void ctxpopup_show(struct ctxpopup *m, int x, int y);
void ctxpopup_set_callback(struct ctxpopup *m, void (*func)(void *, int),
void *data);
diff --git a/src/util/ctxpopup.c b/src/util/ctxpopup.c
index c70f808..d537bf0 100644
--- a/src/util/ctxpopup.c
+++ b/src/util/ctxpopup.c
@@ -30,6 +30,8 @@ struct _selected_cb {
struct ctxpopup {
Evas_Object *popup;
+ Evas_Object *focused_btn;
+
struct _selected_cb cb;
};
@@ -110,6 +112,9 @@ void ctxpopup_show(struct ctxpopup *m, int x, int y)
return;
}
+ if (m->focused_btn)
+ elm_object_focus_set(m->focused_btn, EINA_TRUE);
+
evas_object_move(m->popup, x * elm_config_scale_get(),
y * elm_config_scale_get());
@@ -117,11 +122,13 @@ void ctxpopup_show(struct ctxpopup *m, int x, int y)
}
struct ctxpopup *ctxpopup_create(Evas_Object *base, const char *ctxpopup_style,
- const char *btn_style, const char **text, int text_size)
+ const char *btn_style, const char **text, int text_size,
+ int cur_index)
{
struct ctxpopup *m;
Evas_Object *ctxpopup, *box, *btn;
Evas_Object *firstbtn;
+ Evas_Object *focused_btn;
int i;
if (!base || !text || text_size <= 0) {
@@ -155,6 +162,7 @@ struct ctxpopup *ctxpopup_create(Evas_Object *base, const char *ctxpopup_style,
elm_box_padding_set(box, 0, 0);
+ focused_btn = NULL;
for (i = 0; i < text_size; i++) {
btn = util_add_button(box, btn_style, text[i]);
if (!btn) {
@@ -172,6 +180,9 @@ struct ctxpopup *ctxpopup_create(Evas_Object *base, const char *ctxpopup_style,
if (i == 0)
firstbtn = btn;
+
+ if (i == cur_index)
+ focused_btn = btn;
}
elm_object_focus_next_object_set(firstbtn, btn, ELM_FOCUS_UP);
@@ -183,6 +194,7 @@ struct ctxpopup *ctxpopup_create(Evas_Object *base, const char *ctxpopup_style,
_dismissed_cb, m);
m->popup = ctxpopup;
+ m->focused_btn = focused_btn;
return m;
}
diff --git a/src/view/base.c b/src/view/base.c
index b61387d..3f8150e 100644
--- a/src/view/base.c
+++ b/src/view/base.c
@@ -256,7 +256,8 @@ static void _view_btn_clicked(struct _priv *priv)
cpopup = ctxpopup_create(priv->base, STYLE_CTXPOPUP_VIEW_MODE,
STYLE_BTN_VIEW_OPTION,
g_menu_item[priv->current_layout].text_view_mode,
- g_menu_item[priv->current_layout].text_size);
+ g_menu_item[priv->current_layout].text_size,
+ priv->view_mode[priv->current_layout]);
if (!cpopup) {
_ERR("failed to create ctxpopup");
return;