Update notification layout and focus event 42/44542/3
authorjinwoo.shin <jw0227.shin@samsung.com>
Thu, 23 Jul 2015 06:04:08 +0000 (15:04 +0900)
committerjinwoo.shin <jw0227.shin@samsung.com>
Thu, 23 Jul 2015 12:35:54 +0000 (21:35 +0900)
Change-Id: Ic18aae4241b53c687145cdc7fdc2d45d490d1dd8
Signed-off-by: jinwoo.shin <jw0227.shin@samsung.com>
data/view/notification_view.edc
data/widget/button.edc
images/ic_thumb_down_dis.png [new file with mode: 0644]
images/ic_thumb_down_foc.png [new file with mode: 0644]
images/ic_thumb_down_nor.png [new file with mode: 0644]
images/ic_thumb_up_dis.png [new file with mode: 0644]
images/ic_thumb_up_foc.png [new file with mode: 0644]
images/ic_thumb_up_nor.png [new file with mode: 0644]
src/main.c
src/notification_view.c

index d5d8b7e..e8cc3d4 100644 (file)
@@ -102,6 +102,7 @@ group {
                                        to_y, PART_NOTIFICATION_CONTENT_BG;
                                        relative, 1.0 0.0;
                                }
+                               align, 0.0 0.0;
                                min, 0 116;
                                fixed, 1 1;
                        }
@@ -256,7 +257,7 @@ group {
                                        to_y, PART_NOTIFICATION_CATEGORY_TITLE;
                                        relative, 1.0 1.0;
                                }
-                               min, 0 28;
+                               min, 0 12;
                                align, 0.0 0.0;
                                fixed, 0 1;
                        }
index 778cc35..8d44dce 100644 (file)
@@ -24,15 +24,6 @@ group {
        data.item: "focus_highlight" "on";
        parts {
                part {
-                       name: "bg";
-                       type: RECT;
-                       scale: 1;
-                       description {
-                               state: "default" 0.0;
-                               color: 0 0 0 0;
-                       }
-               }
-               part {
                        name: "bg_text";
                        type: RECT;
                        scale: 1;
diff --git a/images/ic_thumb_down_dis.png b/images/ic_thumb_down_dis.png
new file mode 100644 (file)
index 0000000..177dbfe
Binary files /dev/null and b/images/ic_thumb_down_dis.png differ
diff --git a/images/ic_thumb_down_foc.png b/images/ic_thumb_down_foc.png
new file mode 100644 (file)
index 0000000..eb60eee
Binary files /dev/null and b/images/ic_thumb_down_foc.png differ
diff --git a/images/ic_thumb_down_nor.png b/images/ic_thumb_down_nor.png
new file mode 100644 (file)
index 0000000..7def504
Binary files /dev/null and b/images/ic_thumb_down_nor.png differ
diff --git a/images/ic_thumb_up_dis.png b/images/ic_thumb_up_dis.png
new file mode 100644 (file)
index 0000000..9ed63b6
Binary files /dev/null and b/images/ic_thumb_up_dis.png differ
diff --git a/images/ic_thumb_up_foc.png b/images/ic_thumb_up_foc.png
new file mode 100644 (file)
index 0000000..7fdf3ef
Binary files /dev/null and b/images/ic_thumb_up_foc.png differ
diff --git a/images/ic_thumb_up_nor.png b/images/ic_thumb_up_nor.png
new file mode 100644 (file)
index 0000000..bdd372b
Binary files /dev/null and b/images/ic_thumb_up_nor.png differ
index 60dec80..d854735 100644 (file)
@@ -40,7 +40,7 @@ static Evas_Object *_add_win(const char *name)
                return NULL;
        }
        elm_win_alpha_set(win, EINA_FALSE);
-       elm_win_focus_highlight_enabled_set(win, EINA_FALSE);
+       elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
        elm_win_focus_highlight_style_set(win, "invisible");
 
        evas_object_show(win);
index c4e9490..fddad23 100644 (file)
@@ -28,7 +28,9 @@
 
 #define NOTIFICATION_CATEGORY_PADDING_X 62
 #define NOTIFICATION_CATEGORY_PADDING_Y 0
-#define NOTIFICATION_CATEGORY_HEIGHT 620
+#define NOTIFICATION_CATEGORY_WIDTH (1920 - NOTIFICATION_CATEGORY_PADDING_X)
+#define NOTIFICATION_CATEGORY_HEIGHT 614
+#define NOTIFICATION_CATEGORY_STEP_SIZE 70
 #define NOTIFICATION_ITEM_WIDTH 489
 #define NOTIFICATION_ITEM_HEIGHT 134
 #define NOTIFICATION_ITEM_PADDING 26
@@ -47,12 +49,17 @@ enum notification_category {
        CATEGORY_MAX
 };
 
+struct _category {
+       Evas_Object *title;
+       Evas_Object *grid;
+};
+
 struct _priv {
        Evas_Object *base;
        Evas_Object *clear_btn;
        Evas_Object *category_container;
-       Evas_Object *category[CATEGORY_MAX];
        Elm_Gengrid_Item_Class *grid_class;
+       struct _category *category[CATEGORY_MAX];
 };
 
 static void _base_key_up_cb(int id, void *data, Evas *e, Evas_Object *obj,
@@ -61,6 +68,8 @@ static void _clear_key_up_cb(int id, void *data,
                Evas *e, Evas_Object *obj, Evas_Event_Key_Up *ev);
 static void _clear_mouse_up_cb(int id, void *data,
                Evas *e, Evas_Object *obj, Evas_Event_Mouse_Up *ev);
+static void _category_unfocused_cb(int id, void *data,
+               Evas_Object *obj, Elm_Object_Item *it);
 
 static input_handler base_handler = {
        .key_up = _base_key_up_cb,
@@ -69,6 +78,9 @@ static input_handler clear_handler = {
        .key_up = _clear_key_up_cb,
        .mouse_up = _clear_mouse_up_cb
 };
+static input_handler category_handler = {
+       .unfocused = _category_unfocused_cb,
+};
 
 static const char *_get_category_title(int category)
 {
@@ -94,29 +106,52 @@ static const char *_get_category_title(int category)
        }
 }
 
-static void _draw_category_title(Evas_Object *base, int category)
+static Evas_Object *_add_category_title(Evas_Object *base, int category)
 {
        Evas_Object *btn;
 
        btn = elm_button_add(base);
        if (!btn) {
                _ERR("failed to create button object");
-               return;
+               return NULL;
        }
 
        elm_object_style_set(btn, STYLE_CATEGORY_TITLE);
        elm_object_text_set(btn, _get_category_title(category));
+       elm_object_focus_allow_set(btn, EINA_TRUE);
 
        elm_object_part_content_set(base,
                        PART_NOTIFICATION_CATEGORY_TITLE, btn);
+
+       return btn;
 }
 
-static void _draw_category(struct _priv *priv, int category,
-               notification_list_h noti_list)
+static Evas_Object *_add_category_grid(Evas_Object *base)
 {
-       notification_h noti;
-       Evas_Object *ly;
-       int count = 0, col, w;
+       Evas_Object *grid;
+
+       grid = elm_gengrid_add(base);
+       if (!grid) {
+               _ERR("failed to create grid object");
+               return NULL;
+       }
+
+       elm_gengrid_item_size_set(grid,
+                       NOTIFICATION_ITEM_WIDTH + NOTIFICATION_ITEM_PADDING,
+                       NOTIFICATION_ITEM_HEIGHT + NOTIFICATION_ITEM_PADDING);
+       elm_gengrid_align_set(grid, 0.0, 0.0);
+       elm_gengrid_horizontal_set(grid, EINA_TRUE);
+       evas_object_size_hint_weight_set(grid,
+                       EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+
+       elm_object_content_set(base, grid);
+
+       return grid;
+}
+
+static void _draw_category(struct _priv *priv, int category)
+{
+       Evas_Object *ly, *title, *grid;
 
        if (category < CATEGORY_FIRST ||
                        category >= CATEGORY_MAX) {
@@ -124,30 +159,79 @@ static void _draw_category(struct _priv *priv, int category,
                return;
        }
 
+       priv->category[category] =
+                       calloc(1, sizeof(*priv->category[category]));
+
+       if (!priv->category[category]) {
+               _ERR("failed to allocate category");
+               return;
+       }
+
        ly = elm_layout_add(priv->category_container);
+       if (!ly) {
+               _ERR("failed to create category layout");
+               goto error;
+       }
        elm_layout_file_set(ly, EDJEFILE, GRP_NOTIFICATION_CATEGORY);
        evas_object_size_hint_align_set(ly, 0.0, 0.0);
 
-       _draw_category_title(ly, category);
+       title = _add_category_title(ly, category);
+       if (!title) {
+               _ERR("failed to create title");
+               goto error;
+       }
 
-       priv->category[category] = elm_gengrid_add(ly);
-       elm_gengrid_item_size_set(priv->category[category],
-                       NOTIFICATION_ITEM_WIDTH + NOTIFICATION_ITEM_PADDING,
-                       NOTIFICATION_ITEM_HEIGHT + NOTIFICATION_ITEM_PADDING);
-       elm_gengrid_align_set(priv->category[category], 0.0, 0.0);
-       elm_gengrid_horizontal_set(priv->category[category], EINA_TRUE);
-       elm_scroller_policy_set(priv->category[category],
-                       ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
-       evas_object_size_hint_weight_set(priv->category[category],
-                       EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-       elm_object_content_set(ly, priv->category[category]);
+       grid = _add_category_grid(ly);
+       if (!grid) {
+               _ERR("failed to create grid");
+               goto error;
+       }
+
+       elm_object_focus_next_object_set(title, priv->clear_btn, ELM_FOCUS_UP);
+       elm_object_focus_next_object_set(grid, title, ELM_FOCUS_UP);
+       elm_object_focus_next_object_set(grid, grid, ELM_FOCUS_RIGHT);
+
+       inputmgr_add_callback(title, category, &category_handler, priv);
+       inputmgr_add_callback(grid, category, &category_handler, priv);
 
        elm_box_pack_end(priv->category_container, ly);
+       evas_object_show(grid);
        evas_object_show(ly);
 
+       priv->category[category]->title = title;
+       priv->category[category]->grid = grid;
+
+       return;
+
+error:
+       if (priv->category[category])
+               free(priv->category[category]);
+       if (ly)
+               evas_object_del(ly);
+}
+
+static void _draw_notification(struct _priv *priv, int category,
+               notification_list_h noti_list)
+{
+       notification_h noti;
+       int count = 0, col, w;
+
+       if (category < CATEGORY_FIRST ||
+                       category >= CATEGORY_MAX) {
+               _ERR("Undefined category");
+               return;
+       }
+
+       if (!priv->category[category]) {
+               _ERR("failed to get category");
+               return;
+       }
+
+       elm_gengrid_clear(priv->category[category]->grid);
+
        while (noti_list != NULL) {
                noti = notification_list_get_data(noti_list);
-               elm_gengrid_item_append(priv->category[category],
+               elm_gengrid_item_append(priv->category[category]->grid,
                                priv->grid_class, noti, NULL, noti);
 
                noti_list = notification_list_remove(noti_list, noti);
@@ -155,10 +239,11 @@ static void _draw_category(struct _priv *priv, int category,
        }
 
        col = ceil(count / NOTIFICATION_ITEMS_IN_COL);
-       w = col * NOTIFICATION_ITEM_WIDTH
-                       + (col - 1) * NOTIFICATION_ITEM_PADDING;
-       evas_object_size_hint_min_set(priv->category[category],
-                       w + NOTIFICATION_ITEM_PADDING,
+       w = col * (NOTIFICATION_ITEM_WIDTH + NOTIFICATION_ITEM_PADDING);
+       if (w > NOTIFICATION_CATEGORY_WIDTH)
+               w = NOTIFICATION_CATEGORY_WIDTH;
+       evas_object_size_hint_min_set(priv->category[category]->grid,
+                       w,
                        NOTIFICATION_CATEGORY_HEIGHT +
                        NOTIFICATION_ITEM_PADDING);
 }
@@ -166,20 +251,34 @@ static void _draw_category(struct _priv *priv, int category,
 static void _update_list(struct _priv *priv)
 {
        notification_list_h noti_list = NULL;
-
-       elm_box_clear(priv->category_container);
+       Elm_Object_Item *it;
 
        notification_get_list(NOTIFICATION_TYPE_NOTI, -1, &noti_list);
-       if (noti_list) {
-               elm_object_signal_emit(priv->base,
-                               SIGNAL_NOTIFICATION, SOURCE_PROGRAM);
-               elm_object_disabled_set(priv->clear_btn, EINA_FALSE);
-
-               _draw_category(priv, CATEGORY_TODAY, noti_list);
-       } else {
+       if (!noti_list) {
                elm_object_signal_emit(priv->base,
                                SIGNAL_NO_NOTIFICATION, SOURCE_PROGRAM);
                elm_object_disabled_set(priv->clear_btn, EINA_TRUE);
+               elm_object_focus_allow_set(priv->base, EINA_TRUE);
+               elm_object_focus_set(priv->base, EINA_TRUE);
+
+               return;
+       }
+
+       elm_object_signal_emit(priv->base,
+                       SIGNAL_NOTIFICATION, SOURCE_PROGRAM);
+       elm_object_disabled_set(priv->clear_btn, EINA_FALSE);
+       elm_object_focus_allow_set(priv->base, EINA_FALSE);
+
+       if (!priv->category[CATEGORY_TODAY])
+               _draw_category(priv, CATEGORY_TODAY);
+
+       _draw_notification(priv, CATEGORY_TODAY, noti_list);
+
+       if (priv->category[CATEGORY_TODAY]) {
+               it = elm_gengrid_first_item_get(
+                               priv->category[CATEGORY_TODAY]->grid);
+               if (it)
+                       elm_object_item_focus_set(it, EINA_TRUE);
        }
 }
 
@@ -271,25 +370,24 @@ static Evas_Object *_create(Evas_Object *win, void *data)
                return NULL;
        }
        elm_layout_file_set(priv->base, EDJEFILE, GRP_NOTIFICATION_VIEW);
-
        evas_object_size_hint_weight_set(priv->base,
                        EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
        elm_win_resize_object_add(win, priv->base);
-       elm_object_focus_allow_set(priv->base, EINA_TRUE);
        inputmgr_add_callback(priv->base, 0, &base_handler, NULL);
 
        scroller = elm_scroller_add(priv->base);
        evas_object_size_hint_align_set(scroller, 0.0, 0.0);
        elm_object_content_set(priv->base, scroller);
+       elm_scroller_step_size_set(scroller,
+                       NOTIFICATION_CATEGORY_STEP_SIZE, 0);
 
-       priv->category_container = elm_box_add(priv->base);
-       elm_object_content_set(priv->base, priv->category_container);
+       priv->category_container = elm_box_add(scroller);
+       elm_object_content_set(scroller, priv->category_container);
        elm_box_align_set(priv->category_container, 0.0, 0.0);
        elm_box_horizontal_set(priv->category_container, EINA_TRUE);
        elm_box_padding_set(priv->category_container,
                        NOTIFICATION_CATEGORY_PADDING_X,
                        NOTIFICATION_CATEGORY_PADDING_Y);
-       evas_object_show(priv->category_container);
 
        priv->clear_btn = elm_layout_add(priv->base);
        elm_layout_file_set(priv->clear_btn, EDJEFILE, GRP_NOTIFICATION_CLEAR);
@@ -344,6 +442,7 @@ static void _hide(void *view_data)
 static void _destroy(void *view_data)
 {
        struct _priv *priv;
+       int i;
 
        if (!view_data) {
                _ERR("failed to get view data");
@@ -353,11 +452,22 @@ static void _destroy(void *view_data)
        priv = (struct _priv *) view_data;
 
        inputmgr_remove_callback(priv->clear_btn, &clear_handler);
+       inputmgr_remove_callback(priv->base, &base_handler);
 
        evas_object_del(priv->base);
 
        elm_gengrid_item_class_free(priv->grid_class);
 
+       for (i = CATEGORY_FIRST; i < CATEGORY_MAX; i++) {
+               if (priv->category[i]) {
+                       inputmgr_remove_callback(priv->category[i]->title,
+                                       &category_handler);
+                       inputmgr_remove_callback(priv->category[i]->grid,
+                                       &category_handler);
+                       free(priv->category[i]);
+               }
+       }
+
        free(priv);
 }
 
@@ -391,6 +501,23 @@ static void _clear_mouse_up_cb(int id, void *data, Evas *e,
        notification_delete_all(NOTIFICATION_TYPE_NOTI);
 }
 
+static void _category_unfocused_cb(int id, void *data,
+               Evas_Object *obj, Elm_Object_Item *it)
+{
+       struct _priv *priv;
+
+       if (!data) {
+               _ERR("failed to get data");
+               return;
+       }
+
+       priv = data;
+
+       if (priv->category[id])
+               elm_object_focus_next_object_set(priv->clear_btn,
+                               priv->category[id]->title, ELM_FOCUS_DOWN);
+}
+
 view_class *notification_view_get_vclass(void)
 {
        return &vclass;