Select first menu button after [down] key press on tab button 72/59772/7
authorRadek Kintop <r.kintop@samsung.com>
Thu, 18 Feb 2016 10:11:52 +0000 (11:11 +0100)
committerRadek Kintop <r.kintop@samsung.com>
Mon, 22 Feb 2016 14:08:42 +0000 (06:08 -0800)
Change-Id: I2e5212a20fea961a8981dff3dcc5079b217d119e
Signed-off-by: Radek Kintop <r.kintop@samsung.com>
include/common/layoutmgr.h
include/common/menumgr.h
src/common/layoutmgr.c
src/common/menumgr.c
src/layout/layout_picture.c
src/layout/layout_support.c
src/layout/layout_system.c
src/layout/layout_voice.c
src/view/view_base.c

index db16fa2..c39c7bf 100644 (file)
@@ -144,4 +144,5 @@ bool layoutmgr_update_layout(layoutmgr *lmgr, const char *view_id,
 bool layoutmgr_set_layout_data(layoutmgr *lmgr, const char *layout_id,
                void *layout_data);
 
+
 #endif
index 795f2f8..e65c009 100644 (file)
@@ -28,7 +28,7 @@ struct menumgr_info {
        void (*selected)(void *data, int id);
 };
 
-struct menumgr *menumgr_create(Evas_Object *table,
+struct menumgr *menumgr_create(Evas_Object *table, Evas_Object **first_menu_option,
                struct menumgr_info *info, int len, void *data);
 void menumgr_destroy(struct menumgr *m);
 
index 526bfec..2444a96 100644 (file)
@@ -96,7 +96,7 @@ Evas_Object *layoutmgr_get_base(layoutmgr *lmgr)
 {
        if (!lmgr) {
                _ERR("Layout manager didn't initialized.");
-               return false;
+               return NULL;
        }
 
        return lmgr->base;
index fd36ad7..8f8a44a 100644 (file)
@@ -129,16 +129,17 @@ void menumgr_update(struct menumgr *m)
        }
 }
 
-struct menumgr *menumgr_create(Evas_Object *table,
+struct menumgr *menumgr_create(Evas_Object *table, Evas_Object **first_menu_option,
                struct menumgr_info *info, int len, void *data)
 {
        SETTING_TRACE_BEGIN;
        struct menumgr *m = NULL;
        Evas_Object *btn = NULL;
-       int i;
-       int col, row;
+       int i = 0;
+       int col = 0;
+       int row = 0;
 
-       m = calloc(1, sizeof(*m));
+       m = calloc(1, sizeof(struct menumgr));
        if (!m) {
                _ERR("Calloc failed.");
                return NULL;
@@ -158,6 +159,9 @@ struct menumgr *menumgr_create(Evas_Object *table,
                        return NULL;
                }
 
+               if (i == 0 && first_menu_option)
+                       *first_menu_option = btn;
+
                elm_object_disabled_set(btn, info[i].disabled);
                evas_object_size_hint_align_set(btn, 0, 0);
 
index 82499c8..61898d5 100644 (file)
 #define PADDING_X 26
 #define PADDING_Y 26
 
-#define SCREEN_DEFAULT "16:9"
-
 struct _priv {
        Evas_Object *base;
        Evas_Object *ly;
        Evas_Object *table;
+       Evas_Object *first_menu_option;
        layoutmgr *lmgr;
        struct menumgr *menu;
 };
@@ -57,6 +56,14 @@ static char *_get_color(void *data, int id);
 static char *_get_tint(void *data, int id);
 static char *_get_screen_adj(void *data, int id);
 static void _selected(void *data, int id);
+static bool _add_layout_contents(struct _priv *priv);
+
+/* Class functions: */
+static bool _create(layoutmgr *lmgr, void *data);
+static void _show(void *layout_data);
+static void _hide(void *layout_data);
+static void _destroy(void *layout_data);
+static void _update(void *layout_data, int update_type, void *data);
 
 static struct menumgr_info menu_info[] = {
        {
@@ -117,6 +124,21 @@ static struct menumgr_info menu_info[] = {
        },
 };
 
+static layout_class _lclass = {
+       .layout_id = LAYOUT_ID_PICTURE,
+       .create = _create,
+       .show = _show,
+       .hide = _hide,
+       .destroy = _destroy,
+       .update = _update
+};
+
+layout_class *layout_picture_get_lclass(void)
+{
+       SETTING_TRACE_BEGIN;
+       return &_lclass;
+}
+
 static char *_get_picture_mode(void *data, int id)
 {
        if(settings_picture_get_picture_mode() == PICTURE_MODE_STANDARD) {
@@ -182,7 +204,7 @@ static char *_get_tint(void *data, int id)
 static char *_get_screen_adj(void *data, int id)
 {
        SETTING_TRACE_BEGIN;
-       return strdup(SCREEN_DEFAULT);
+       return NULL;
 }
 
 static void _selected(void *data, int id)
@@ -220,7 +242,6 @@ static bool _add_layout_contents(struct _priv *priv)
 {
        SETTING_TRACE_BEGIN;
        Evas_Object *table = NULL;
-       struct menumgr *menu = NULL;
 
        if (!priv) {
                _ERR("Invalid argument");
@@ -237,62 +258,60 @@ static bool _add_layout_contents(struct _priv *priv)
 
        elm_object_part_content_set(priv->ly, PART_PICTURE, table);
 
-       menu = menumgr_create(table, menu_info, ARRAY_SIZE(menu_info), priv);
-       if (!menu) {
+       priv->menu = menumgr_create(table, &priv->first_menu_option, menu_info,
+                                                               ARRAY_SIZE(menu_info), priv);
+       if (!priv->menu) {
                _ERR("failed to create menu manager");
                evas_object_del(table);
                return false;
        }
 
-       priv->menu = menu;
-
        return true;
 }
 
-static bool _create(layoutmgr *lmgr, void *data)
+static bool _create(layoutmgr *lmgr, void *tab_button)
 {
        SETTING_TRACE_BEGIN;
+
        struct _priv *priv = NULL;
-       Evas_Object *base = NULL;
-       Evas_Object *ly = NULL;
+       Evas_Object *tab_button_evas = (Evas_Object *)tab_button;
 
        if (!lmgr) {
                _ERR("Invalid argument.");
                return false;
        }
 
-       base = layoutmgr_get_base(lmgr);
-       if (!base) {
-               _ERR("Get base layout failed.");
+       priv = calloc(1, sizeof(*priv));
+       if (!priv) {
+               _ERR("Calloc failed.");
                return false;
        }
 
-       ly = utils_add_layout(base, GRP_LAYOUT_PICTURE, EINA_FALSE);
-       if (!ly) {
-               _ERR("Add layout failed.");
+       priv->base = layoutmgr_get_base(lmgr);
+       if (!priv->base) {
+               _ERR("Get base layout failed.");
+               free(priv);
                return false;
        }
 
-       priv = calloc(1, sizeof(*priv));
-       if (!priv) {
-               _ERR("Calloc failed.");
-               evas_object_del(ly);
+       priv->ly = utils_add_layout(priv->base, GRP_LAYOUT_PICTURE, EINA_FALSE);
+       if (!priv->ly) {
+               _ERR("Add layout failed.");
+               free(priv);
                return false;
        }
 
        priv->lmgr = lmgr;
-       priv->base = base;
-       priv->ly = ly;
 
        if (!_add_layout_contents(priv)) {
                _ERR("Add layout contents failed.");
-               evas_object_del(ly);
+               evas_object_del(priv->ly);
                free(priv);
                return false;
        }
-
+       elm_object_focus_next_object_set(tab_button_evas, priv->first_menu_option, ELM_FOCUS_DOWN);
        layoutmgr_set_layout_data(lmgr, LAYOUT_ID_PICTURE, priv);
-
+       SETTING_TRACE_END;
        return true;
 }
 
@@ -330,7 +349,7 @@ static void _hide(void *layout_data)
        elm_object_part_content_unset(priv->base, PART_CONTENT);
 }
 
-static void _update(void *layout_data, int update_type, void *data)
+static void _destroy(void *layout_data)
 {
        SETTING_TRACE_BEGIN;
        struct _priv *priv = NULL;
@@ -341,11 +360,13 @@ static void _update(void *layout_data, int update_type, void *data)
        }
 
        priv = layout_data;
+       menumgr_destroy(priv->menu);
 
-       menumgr_update(priv->menu);
+       evas_object_del(priv->ly);
+       free(priv);
 }
 
-static void _destroy(void *layout_data)
+static void _update(void *layout_data, int update_type, void *data)
 {
        SETTING_TRACE_BEGIN;
        struct _priv *priv = NULL;
@@ -356,25 +377,6 @@ static void _destroy(void *layout_data)
        }
 
        priv = layout_data;
-
-       menumgr_destroy(priv->menu);
-
-       evas_object_del(priv->ly);
-
-       free(priv);
+       menumgr_update(priv->menu);
 }
 
-static layout_class _lclass = {
-       .layout_id = LAYOUT_ID_PICTURE,
-       .create = _create,
-       .show = _show,
-       .hide = _hide,
-       .destroy = _destroy,
-       .update = _update
-};
-
-layout_class *layout_picture_get_lclass(void)
-{
-       SETTING_TRACE_BEGIN;
-       return &_lclass;
-}
index 8a50306..f72dd3b 100644 (file)
@@ -141,7 +141,7 @@ static bool _add_layout_contents(struct _priv *priv)
 
        elm_object_part_content_set(priv->ly, PART_SUPPORT, table);
 
-       menu = menumgr_create(table, menu_info, ARRAY_SIZE(menu_info), priv);
+       menu = menumgr_create(table, NULL, menu_info, ARRAY_SIZE(menu_info), priv);
        if (!menu) {
                _ERR("failed to create menu manager");
                evas_object_del(table);
index 4f6441a..ab4eb39 100644 (file)
@@ -46,6 +46,7 @@ struct _priv {
        Evas_Object *ly;
        Evas_Object *table;
        layoutmgr *lmgr;
+       Evas_Object *first_menu_option;
        struct menumgr *menu;
 };
 
@@ -284,7 +285,7 @@ static bool _add_layout_contents(struct _priv *priv)
 
        elm_object_part_content_set(priv->ly, PART_SYSTEM, table);
 
-       menu = menumgr_create(table, menu_info, ARRAY_SIZE(menu_info), priv);
+       menu = menumgr_create(table, &priv->first_menu_option, menu_info, ARRAY_SIZE(menu_info), priv);
        if (!menu) {
                _ERR("failed to create menu manager");
                evas_object_del(table);
@@ -296,11 +297,12 @@ static bool _add_layout_contents(struct _priv *priv)
        return true;
 }
 
-static bool _create(layoutmgr *lmgr, void *data)
+static bool _create(layoutmgr *lmgr, void *tab_button)
 {
        struct _priv *priv = NULL;
        Evas_Object *base = NULL;
        Evas_Object *ly = NULL;
+       Evas_Object *tab_button_evas = (Evas_Object *)tab_button;
 
        if (!lmgr) {
                _ERR("Invalid argument.");
@@ -338,7 +340,7 @@ static bool _create(layoutmgr *lmgr, void *data)
                free(priv);
                return false;
        }
-
+       elm_object_focus_next_object_set(tab_button_evas, priv->first_menu_option, ELM_FOCUS_DOWN);
        layoutmgr_set_layout_data(lmgr, LAYOUT_ID_SYSTEM, priv);
 
        return true;
index 016061b..aee849d 100644 (file)
@@ -104,7 +104,7 @@ static bool _add_layout_contents(struct _priv *priv)
 
        elm_object_part_content_set(priv->ly, PART_VOICE, table);
 
-       menu = menumgr_create(table, menu_info, ARRAY_SIZE(menu_info), priv);
+       menu = menumgr_create(table, NULL, menu_info, ARRAY_SIZE(menu_info), priv);
        if (!menu) {
                _ERR("failed to create menu manager");
                evas_object_del(table);
index 289af83..1391af5 100644 (file)
@@ -108,7 +108,9 @@ static void _mouse_move_cb(int id, void *data, Evas *e, Evas_Object *obj,
 static void _menu_key_down_cb(int id, void *data, Evas *e, Evas_Object *obj,
                Evas_Event_Key_Down *ev)
 {
-       if (!obj || !ev) {
+       struct _priv *priv = (struct _priv *)data;
+
+       if (!obj || !ev || !priv) {
                _ERR("Invalid argument.");
                return;
        }
@@ -208,55 +210,56 @@ static bool _draw_menu_area(struct _priv *priv)
 
 static Evas_Object *_create(Evas_Object *win, void *data)
 {
-       struct _priv *priv;
-       Evas_Object *base;
-       layoutmgr *lmgr;
-       int i;
+       struct _priv *priv = NULL;
+       int i = 0;
 
        if (!win) {
                _ERR("Get window object failed.");
                return NULL;
        }
 
-       priv = calloc(1, sizeof(*priv));
+       priv = calloc(1, sizeof(struct _priv));
        if (!priv) {
                _ERR("Calloc failed.");
                return NULL;
        }
 
-       base = utils_add_layout(win, GRP_VIEW_BASE, EINA_TRUE);
-       if (!base) {
+       priv->base = utils_add_layout(win, GRP_VIEW_BASE, EINA_TRUE);
+       if (!priv->base) {
                _ERR("Add layout failed.");
                free(priv);
                return NULL;
        }
 
-       lmgr = layoutmgr_create(base);
-       if (!lmgr) {
+       priv->lmgr = layoutmgr_create(priv->base);
+       if (!priv->lmgr) {
                _ERR("Create layoutmgr failed.");
-               evas_object_del(base);
+               evas_object_del(priv->base);
+               free(priv);
+               return NULL;
+       }
+
+       if (!_draw_menu_area(priv)) {
+               _ERR("Create menu area failed.");
+               evas_object_del(priv->base);
                free(priv);
                return NULL;
        }
 
        for (i = 0; i < LAYOUT_MAX; i++)
-               layoutmgr_add_layout(lmgr, _mdata[i].get_lclass(), NULL);
+               layoutmgr_add_layout(priv->lmgr, _mdata[i].get_lclass(), priv->menu[i]);
 
        priv->win = win;
-       priv->base = base;
-       priv->lmgr = lmgr;
        priv->cur_menu = LAYOUT_MAX;
 
        if (!viewmgr_set_view_data(VIEW_BASE, priv)) {
                _ERR("Set view data failed.");
-               evas_object_del(base);
+               evas_object_del(priv->base);
                free(priv);
                return NULL;
        }
 
-       _draw_menu_area(priv);
-
-       return base;
+       return priv->base;
 }
 
 static void _show(void *data)