support mouse key handling in view_home 94/43894/2
authorSoohye Shin <soohye.shin@samsung.com>
Wed, 15 Jul 2015 06:20:29 +0000 (15:20 +0900)
committerSoohye Shin <soohye.shin@samsung.com>
Wed, 15 Jul 2015 06:22:17 +0000 (15:22 +0900)
- select home item
- select recent down button
- modify recent layout for focus animation

Change-Id: I2a6ebec2ff2609205e28b0e73f5a8e8967767774
Signed-off-by: Soohye Shin <soohye.shin@samsung.com>
edje/view/home.edc
src/view/view_home.c

index e6b1f06..e8df094 100644 (file)
@@ -189,15 +189,61 @@ group {
                                min, 0 10;
                                rel1 {
                                        to, "text";
+                                       relative, 0.0 1.0;
+                               }
+                               rel2.to, "text";
+                               fixed, 0 1;
+                               align, 0.5 0.0;
+                               visible, 0;
+                       }
+               }
+               part {
+                       name, "focus";
+                       type, RECT;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               rel1 {
                                        relative, 0.5 1.0;
+                                       to, "pad.arrow";
                                }
                                rel2 {
-                                       to, "text";
                                        relative, 0.5 1.0;
+                                       to, "pad.arrow";
                                }
+                               min, 98 56;
                                fixed, 1 1;
                                align, 0.5 0.0;
-                               visible, 0;
+                               color, 0 0 0 0;
+                       }
+                       description {
+                               state, "focus" 0.0;
+                               inherit, "default" 0.0;
+                               color, 0 119 246 255;
+                       }
+               }
+               part {
+                       name, "bounce.arrow";
+                       type, RECT;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               rel1 {
+                                       relative, 0.5 1.0;
+                                       to, "pad.arrow";
+                               }
+                               rel2 {
+                                       relative, 0.5 1.0;
+                                       to, "pad.arrow";
+                               }
+                               min, 0 0;
+                               align, 0.5 0.0;
+                               fixed, 1 1;
+                       }
+                       description {
+                               state, "focus" 0.0;
+                               inherit, "default" 0.0;
+                               min, 0 5;
                        }
                }
                part {
@@ -208,12 +254,12 @@ group {
                                state, "default" 0.0;
                                min, 98 34;
                                rel1 {
-                                       relative, 1.0 1.0;
-                                       to, "pad.arrow";
+                                       relative, 0.5 1.0;
+                                       to, "bounce.arrow";
                                }
                                rel2 {
-                                       relative, 1.0 1.0;
-                                       to, "pad.arrow";
+                                       relative, 0.5 1.0;
+                                       to, "bounce.arrow";
                                }
                                image.normal, "btn_navigation_down.png";
                                align, 0.5 0.0;
@@ -221,6 +267,26 @@ group {
                        }
                }
        }
+       programs {
+               program {
+                       name, "sig,focus";
+                       signal, SIG_FOCUS;
+                       source, SRC_PROG;
+                       action, STATE_SET "focus" 0.0;
+                       transition, DECEL 0.5;
+                       target, "focus";
+                       target, "bounce.arrow";
+               }
+               program {
+                       name, "sig,unfocus";
+                       signal, SIG_UNFOCUS;
+                       source, SRC_PROG;
+                       action, STATE_SET "default" 0.0;
+                       transition, DECEL 0.2;
+                       target, "focus";
+                       target, "bounce.arrow";
+               }
+       }
 }
 
 group {
index 05dffa8..7954945 100644 (file)
 #include "datamgr.h"
 #include "utils.h"
 
+enum input_handler_type {
+       INPUT_HANDLER_TYPE_BASE,
+       INPUT_HANDLER_TYPE_EO,
+       INPUT_HANDLER_TYPE_DOWN
+};
+
 struct _priv {
        Evas_Object *win;
        Evas_Object *base;
+       Evas_Object *down;
        Eina_List *list;
 
        struct datamgr *dm;
@@ -42,54 +49,116 @@ struct bar_item {
        struct _priv *priv;
 };
 
-static bool _add_navigations(Evas_Object *base)
+static void _focused(int id, void *data, Evas_Object *obj,
+               Elm_Object_Item *item)
 {
-       Evas_Object *ly;
+       struct _priv *priv;
+       struct bar_item *bi;
 
-       if (!base) {
-               _ERR("Invalid argument");
-               return false;
+       switch (id) {
+       case INPUT_HANDLER_TYPE_EO:
+               if (!data) {
+                       _ERR("Invalid argument");
+                       return;
+               }
+               bi = data;
+               priv = bi->priv;
+               priv->foc = bi;
+               /* fallthrough */
+       case INPUT_HANDLER_TYPE_DOWN:
+               elm_object_signal_emit(obj, SIG_FOCUS, SRC_PROG);
+               break;
+       default:
+               return;
        }
+}
 
-       ly = utils_add_layout(base, GRP_HOME_DOWN_ARROW, true,
-                       PART_HOME_DOWN_ARROW);
-       if (!ly) {
-               _ERR("failed to add layout");
-               return false;
+static void _unfocused(int id, void *data, Evas_Object *obj,
+               Elm_Object_Item *item)
+{
+       switch (id) {
+       case INPUT_HANDLER_TYPE_EO:
+       case INPUT_HANDLER_TYPE_DOWN:
+               elm_object_signal_emit(obj, SIG_UNFOCUS, SRC_PROG);
+               break;
+       default:
+               return;
        }
-
-       return true;
 }
 
-static void _focused(int id, void *data, Evas_Object *obj,
-               Elm_Object_Item *item)
+static void _key_down(int id, void *data, Evas *e, Evas_Object *obj,
+               Evas_Event_Key_Down *ev)
 {
        struct _priv *priv;
-       struct bar_item *bi;
+
+       if (id != INPUT_HANDLER_TYPE_BASE)
+               return;
 
        if (!data) {
                _ERR("Invalid argument");
                return;
        }
 
-       bi = data;
-       priv = bi->priv;
-       priv->foc = bi;
+       priv = data;
 
-       elm_object_signal_emit(obj, SIG_FOCUS, SRC_PROG);
+       if (!strcmp(ev->keyname, KEY_DOWN)) {
+               viewmgr_push_view(VIEW_RECENT);
+       } else if (!strcmp(ev->keyname, KEY_ENTER) ||
+                       !strcmp(ev->keyname, KEY_ENTER_REMOTE)) {
+               datamgr_select_item(priv->dm, priv->foc->di);
+       } else if (!strcmp(ev->keyname, KEY_BACK) ||
+                       !strcmp(ev->keyname, KEY_BACK_REMOTE)) {
+               /* It should be implemented later */
+       }
 }
 
-static void _unfocused(int id, void *data, Evas_Object *obj,
-               Elm_Object_Item *item)
+static void _mouse_down(int id, void *data, Evas *e, Evas_Object *obj,
+               Evas_Event_Mouse_Down *ev)
 {
-       elm_object_signal_emit(obj, SIG_UNFOCUS, SRC_PROG);
+       struct _priv *priv;
+       struct bar_item *bi;
+
+       switch (id) {
+       case INPUT_HANDLER_TYPE_EO:
+               if (!data)
+                       return;
+
+               bi = data;
+               priv = bi->priv;
+               datamgr_select_item(priv->dm, priv->foc->di);
+               break;
+       case INPUT_HANDLER_TYPE_DOWN:
+               viewmgr_push_view(VIEW_RECENT);
+               break;
+       default:
+               return;
+       }
 }
 
-static input_handler eo_handler = {
+static input_handler handler = {
        .focused = _focused,
-       .unfocused = _unfocused
+       .unfocused = _unfocused,
+       .key_down = _key_down,
+       .mouse_down = _mouse_down
 };
 
+static bool _add_navigations(struct _priv *priv, Evas_Object *base)
+{
+       Evas_Object *ly;
+
+       ly = utils_add_layout(base, GRP_HOME_DOWN_ARROW, true,
+                       PART_HOME_DOWN_ARROW);
+       if (!ly) {
+               _ERR("failed to add layout");
+               return false;
+       }
+
+       inputmgr_add_callback(ly, INPUT_HANDLER_TYPE_DOWN, &handler, priv);
+       priv->down = ly;
+
+       return true;
+}
+
 static struct bar_item *_pack_bar_item(struct _priv *priv, Evas_Object *box,
                struct datamgr_item *di)
 {
@@ -137,7 +206,7 @@ static struct bar_item *_pack_bar_item(struct _priv *priv, Evas_Object *box,
        if (!bg)
                goto err;
 
-       inputmgr_add_callback(eo, 0, &eo_handler, bi);
+       inputmgr_add_callback(eo, INPUT_HANDLER_TYPE_EO, &handler, bi);
        elm_box_pack_end(box, eo);
        evas_object_show(eo);
 
@@ -161,11 +230,6 @@ static bool _add_home_menu(struct _priv *priv, Evas_Object *base)
        struct bar_item *bi;
        struct datamgr_item *di;
 
-       if (!priv || !base) {
-               _ERR("Invalid argument");
-               return false;
-       }
-
        scr = utils_add_scroller(base);
        if (!scr) {
                _ERR("failed to add scroller");
@@ -201,12 +265,8 @@ static bool _add_home_menu(struct _priv *priv, Evas_Object *base)
 
 static bool _add_home(struct _priv *priv, Evas_Object *base)
 {
-       if (!priv || !base) {
-               _ERR("Invalid argument");
-               return false;
-       }
 
-       if (!_add_navigations(base)) {
+       if (!_add_navigations(priv, base)) {
                _ERR("failed to add navigations");
                return false;
        }
@@ -219,44 +279,12 @@ static bool _add_home(struct _priv *priv, Evas_Object *base)
        return true;
 }
 
-static void _key_down(int id, void *data, Evas *e, Evas_Object *obj,
-               Evas_Event_Key_Down *ev)
-{
-       struct _priv *priv;
-
-       if (!data) {
-               _ERR("Invalid argument");
-               return;
-       }
-
-       priv = data;
-
-       if (!strcmp(ev->keyname, KEY_DOWN)) {
-               viewmgr_push_view(VIEW_RECENT);
-       } else if (!strcmp(ev->keyname, KEY_ENTER) ||
-                       !strcmp(ev->keyname, KEY_ENTER_REMOTE)) {
-               datamgr_select_item(priv->dm, priv->foc->di);
-       } else if (!strcmp(ev->keyname, KEY_BACK) ||
-                       !strcmp(ev->keyname, KEY_BACK_REMOTE)) {
-               /* It should be implemented later */
-       }
-}
-
-static input_handler base_handler = {
-       .key_down = _key_down
-};
-
 static Evas_Object *_create(Evas_Object *win, void *data)
 {
        struct _priv *priv;
        struct datamgr *dm;
        Evas_Object *base;
 
-       if (!win) {
-               _ERR("Invalid argument");
-               return NULL;
-       }
-
        priv = calloc(1, sizeof(*priv));
        if (!priv) {
                _ERR("failed to calloc priv");
@@ -294,7 +322,7 @@ static Evas_Object *_create(Evas_Object *win, void *data)
        }
 
        viewmgr_set_view_data(VIEW_HOME, priv);
-       inputmgr_add_callback(base, 0, &base_handler, priv);
+       inputmgr_add_callback(base, INPUT_HANDLER_TYPE_BASE, &handler, priv);
 
        return base;
 }
@@ -346,13 +374,14 @@ static void _destroy(void *data)
        priv = data;
 
        EINA_LIST_FREE(priv->list, bi) {
-               inputmgr_remove_callback(bi->eo, &eo_handler);
+               inputmgr_remove_callback(bi->eo, &handler);
                evas_object_del(bi->eo);
                free(bi);
        }
 
        datamgr_fini(priv->dm);
-       inputmgr_remove_callback(priv->base, &base_handler);
+       inputmgr_remove_callback(priv->base, &handler);
+       inputmgr_remove_callback(priv->down, &handler);
        evas_object_del(priv->base);
 
        priv->list = NULL;