View: Draw more button on action menu 03/48603/1 accepted/tizen/tv/20150925.040820 submit/tizen/20150925.013207
authorHyojung Jo <hj903.jo@samsung.com>
Wed, 23 Sep 2015 11:46:36 +0000 (20:46 +0900)
committerHyojung Jo <hj903.jo@samsung.com>
Wed, 23 Sep 2015 11:46:36 +0000 (20:46 +0900)
Change-Id: I53d90b52c499fe5d009b4a7da58f687d9035e427
Signed-off-by: Hyojung Jo <hj903.jo@samsung.com>
include/define.h
res/view/action_menu.edc
res/widget/button.edc
src/utils.c
src/view/view_action_menu.c

index c0c39e3..a2fdcbe 100644 (file)
@@ -27,7 +27,8 @@
 /* Group for EDC */
 #define GRP_VIEW_BASE "grp.view.base"
 #define GRP_VIEW_ACTION_MENU "grp.view.action.menu"
-#define GRP_ACTION_MENU "grp.action.menu"
+#define GRP_ACTION_MENU_CONTENTS "grp.action.menu.contents"
+#define GRP_ACTION_MENU_NO_FAVORITE "grp.action.menu.no.favorite"
 
 /* Part for EDC */
 #define PART_TOP_TITLE "part.top.title"
@@ -43,6 +44,7 @@
 #define PART_THUMB_TEXT_BROWSER "part.thumb.text.browser"
 #define PART_TOP_BTN "part.top.button"
 #define PART_FAVORITE "part.favorite"
+#define PART_NO_FAVORITE "part.no.favorite"
 #define PART_BUTTON1 "button1"
 #define PART_BUTTON2 "button2"
 #define PART_POPUP_TITLE "title,text"
@@ -56,6 +58,7 @@
 #define STYLE_MYAPP "style.myapp"
 #define STYLE_FAVORITE "style.favorite"
 #define STYLE_LIVETV_BTN "style.livetv.button"
+#define STYLE_MORE_BTN "style.more.button"
 #define STYLE_ACTION_MENU_FAV_BTN "style.action.menu.favorite.button"
 #define STYLE_ACTION_MENU_UNINSTALL_BTN "style.action.menu.uninstall.button"
 #define STYLE_TOAST "style.toast"
@@ -74,8 +77,6 @@
 #define SIG_INVISIBLE "invisible"
 #define SIG_DISABLE "elm,state,disabled"
 #define SIG_TOGGLE "toggle"
-#define SIG_NO_CONTENT "no.content"
-#define SIG_CONTENT "content"
 #define SIG_TIMEOUT "timeout"
 #define SIG_SHOW "show"
 #define SIG_HIDE "hide"
@@ -87,7 +88,6 @@
 #define SRC_SORT_BTN "source.sort.btn"
 #define SRC_LIVETV_BTN "source.livetv.btn"
 #define SRC_ACTION_BTN "source.action.btn"
-#define SRC_FAVORITE_AREA "source.favorite.area"
 #define SRC_FAVORITE_ICON "source.favorite.icon"
 
 /* Font */
 #define STR_TPK "tpk"
 #define STR_OK "Ok"
 #define STR_CANCEL "Cancel"
+#define STR_MORE "More"
 
 /* Count */
 #define MENU_COUNT 2
 #define SIZE_COL_MAX 4
 #define SIZE_TOAST_TIMEOUT 5.0
 #define SIZE_FAVORITE_COL_MAX 2
+#define SIZE_SCROLLER_STEP 312
 
 /* Image */
 #define DEFAULT_APP_ICON_PNG IMGDIR"/ico_default.png"
index c371701..6dce83a 100644 (file)
@@ -128,7 +128,7 @@ group {
 }
 
 group {
-       name, GRP_ACTION_MENU;
+       name, GRP_ACTION_MENU_CONTENTS;
        parts {
                part {
                        name, PART_TOP_BTN;
@@ -297,18 +297,24 @@ group {
                }
 
                part {
-                       name, "padding.no.content.bottomright";
-                       type, SPACER;
+                       name, PART_NO_FAVORITE;
+                       type, SWALLOW;
                        scale, 1;
                        description {
                                state, "default" 0.0;
-                               min, 30 32;
-                               rel1.relative, 1.0 1.0;
-                               align, 1.0 1.0;
-                               fixed, 1 1;
+                               min, 440 616;
+                               rel1 {
+                                       to, "padding.favorite.top";
+                                       relative, 0.0 1.0;
+                               }
                        }
                }
+       }
+}
 
+group {
+       name, GRP_ACTION_MENU_NO_FAVORITE;
+       parts {
                part {
                        name, "part.no.content.bg";
                        type, RECT;
@@ -316,22 +322,12 @@ group {
                        description {
                                state, "default" 0.0;
                                color, 229 229 229 255;
-                               rel1 {
-                                       to, "padding.favorite.top";
-                                       relative, 0.0 1.0;
-                               }
-                               rel2 {
-                                       to, "padding.no.content.bottomright";
-                                       relative, 0.0 0.0;
-                               }
-                               visible, 0;
+                               rel2.relative, 0.0 0.0;
+                               min, 440 616;
+                               max, 440 616;
+                               align, 0.0 0.0;
                                fixed, 1 1;
                        }
-                       description {
-                               state, "visible" 0.0;
-                               inherit, "default" 0.0;
-                               visible, 1;
-                       }
                }
 
                part {
@@ -349,33 +345,7 @@ group {
                                        size, 28;
                                        align, 0.5 0.5;
                                }
-                               visible, 0;
                        }
-                       description {
-                               state, "visible" 0.0;
-                               inherit, "default" 0.0;
-                               visible, 1;
-                       }
-               }
-       }
-
-       programs {
-               program {
-                       name, SIG_NO_CONTENT;
-                       signal, SIG_NO_CONTENT;
-                       source, SRC_FAVORITE_AREA;
-                       action, STATE_SET "visible" 0.0;
-                       target, "part.no.content.bg";
-                       target, "part.no.content.text";
-               }
-
-               program {
-                       name, SIG_CONTENT;
-                       signal, SIG_CONTENT;
-                       source, SRC_FAVORITE_AREA;
-                       action, STATE_SET "default" 0.0;
-                       target, "part.no.content.bg";
-                       target, "part.no.content.text";
                }
        }
 }
index 69fc401..820ce08 100644 (file)
@@ -776,6 +776,7 @@ group {
                        scale, 1;
                        description {
                                state, "default" 0.0;
+                               min, 500 120;
                                color, 0 0 0 0;
                                visible, 0;
                        }
@@ -1032,6 +1033,50 @@ group {
 }
 
 group {
+       name, "elm/button/base/style.more.button";
+       inherit, "elm/button/base/style.livetv.button";
+       data.item, "focus_highlight" "on";
+       parts {
+               part {
+                       name, "part.bg";
+                       type, RECT;
+                       mouse_events, 0;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               min, 500 116;
+                               color, 0 0 0 0;
+                               visible, 0;
+                       }
+               }
+
+               part {
+                       name, "part.button.area";
+                       type, RECT;
+                       mouse_events, 1;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               min, 184 60;
+                               rel1.relative, 0.5 0.5;
+                               rel2.relative, 0.5 0.5;
+                               align, 0.5 0.5;
+                               fixed, 1 1;
+                       }
+                       description {
+                               state, "focused" 0.0;
+                               inherit, "default" 0.0;
+                               color, COLOR_ITEM_FOCUS;
+                       }
+                       description {
+                               state, "disable" 0.0;
+                               inherit, "default" 0.0;
+                       }
+               }
+       }
+}
+
+group {
        name, "elm/button/base/style.action.menu.favorite.button";
        data.item, "focus_highlight" "on";
        script {
index 3bb452a..9a94d96 100644 (file)
@@ -92,12 +92,12 @@ Evas_Object *utils_add_box(Evas_Object *parent, const char *part,
        elm_box_horizontal_set(box, horizontal);
        elm_box_padding_set(box, padding_h, padding_v);
 
-       evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND,
-                       EVAS_HINT_EXPAND);
        evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
 
        if (part)
                elm_object_part_content_set(parent, part, box);
+       else
+               elm_object_content_set(parent, box);
 
        evas_object_show(box);
 
index e7216fe..4695657 100644 (file)
@@ -33,16 +33,20 @@ enum button_type {
        BTN_UNINSTALL,
        BTN_OK,
        BTN_CANCEL,
+       BTN_MORE,
 };
 
 struct _priv {
        struct app_data *adata;
        Evas_Object *win;
        Evas_Object *base;
-       Evas_Object *menu_area;
+       Evas_Object *scroller;
+       Evas_Object *box;
        Evas_Object *grid;
+       Evas_Object *contents_ly;
        Evas_Object *live_btn;
        Evas_Object *menu[ACTION_MENU_COUNT];
+       Evas_Object *more_btn;
        Evas_Object *popup;
        struct gridmgr *gmgr;
        Eina_List *fav_list;
@@ -329,12 +333,12 @@ static input_handler _grid_input_handler = {
        .key_down = _key_down_cb
 };
 
-static bool _draw_livetv_area(struct _priv *priv)
+static bool _add_livetv_button(struct _priv *priv)
 {
        Evas_Object *btn;
 
-       btn = utils_add_button(priv->menu_area,
-                       PART_TOP_BTN, STR_LIVETV, STYLE_LIVETV_BTN);
+       btn = utils_add_button(priv->contents_ly, PART_TOP_BTN,
+                       STR_LIVETV, STYLE_LIVETV_BTN);
        if (!btn) {
                _ERR("Add button failed.");
                return false;
@@ -347,6 +351,89 @@ static bool _draw_livetv_area(struct _priv *priv)
        return true;
 }
 
+static bool _add_grid(struct _priv *priv)
+{
+       struct grid_class *gclass;
+       Evas_Object *grid;
+
+       grid = utils_add_gengrid(priv->contents_ly, EINA_FALSE,
+                       SIZE_FAVORITE_GRID_WIDTH, SIZE_FAVORITE_GRID_HEIGHT);
+       if (!grid) {
+               _ERR("Add gengrid failed.");
+               return false;
+       }
+
+       inputmgr_add_callback(grid, 0, &_grid_input_handler, priv);
+
+       gclass = get_favorite_grid_class();
+       if (!gclass) {
+               _ERR("Get favorite grid class failed.");
+               evas_object_del(grid);
+               return false;
+       }
+
+       if (!gridmgr_add_grid(priv->gmgr, STR_FAVORITE, grid, gclass)) {
+               _ERR("Gridmgr add grid failed.");
+               evas_object_del(grid);
+               return false;
+       }
+
+       priv->grid = grid;
+
+       return true;
+}
+
+static bool _add_more_button(struct _priv *priv)
+{
+       Evas_Object *btn;
+
+       btn = utils_add_button(priv->box, NULL, STR_MORE, STYLE_MORE_BTN);
+       if (!btn) {
+               _ERR("Add button failed.");
+               return false;
+       }
+
+       inputmgr_add_callback(btn, BTN_MORE, &_btn_input_handler, priv);
+
+       elm_box_pack_end(priv->box, btn);
+
+       priv->more_btn = btn;
+
+       return true;
+}
+
+static void _add_view_contents(struct _priv *priv)
+{
+       priv->contents_ly = utils_add_layout(priv->box,
+                       GRP_ACTION_MENU_CONTENTS, EINA_FALSE);
+       if (!priv->contents_ly) {
+               _ERR("Add layout failed.");
+               return;
+       }
+
+       evas_object_show(priv->contents_ly);
+       elm_box_pack_end(priv->box, priv->contents_ly);
+
+       if (!_add_livetv_button(priv)) {
+               _ERR("Add livetv button failed.");
+               return;
+       }
+
+       if (!_add_grid(priv)) {
+               _ERR("Add grid failed.");
+               return;
+       }
+
+       if (!_add_more_button(priv))
+               _ERR("Add more button failed.");
+}
+
+static void _hide_done_cb(void *data, Evas_Object *obj,
+               const char *emission, const char *source)
+{
+       viewmgr_hide_view(VIEW_ACTION_MENU);
+}
+
 static void _set_action_state(int idx, Evas_Object *btn, struct _priv *priv)
 {
        char *pkgtype;
@@ -358,7 +445,8 @@ static void _set_action_state(int idx, Evas_Object *btn, struct _priv *priv)
        } else if (action_info[idx].id == BTN_UNINSTALL) {
                /* The 'rpm' type package uninstallation is not supported */
                pkgtype = get_pkg_type(priv->adata);
-               if (!strcmp(pkgtype, STR_WGT) || !strcmp(pkgtype, STR_TPK))
+               if (pkgtype && (!strcmp(pkgtype, STR_WGT)
+                                       || !strcmp(pkgtype, STR_TPK)))
                        action_info[idx].disable = EINA_FALSE;
                else
                        action_info[idx].disable = EINA_TRUE;
@@ -368,12 +456,12 @@ static void _set_action_state(int idx, Evas_Object *btn, struct _priv *priv)
                elm_object_disabled_set(btn, EINA_TRUE);
 }
 
-static bool _draw_action_area(struct _priv *priv)
+static bool _update_action_area(struct _priv *priv)
 {
        Evas_Object *table, *btn;
        int i, row = 0, col = 0;
 
-       table = utils_add_table(priv->menu_area, PART_MENU,
+       table = utils_add_table(priv->contents_ly, PART_MENU,
                        SIZE_ACTION_TABLE_BORDER, SIZE_ACTION_TABLE_BORDER);
        if (!table) {
                _ERR("Add table failed.");
@@ -405,37 +493,19 @@ static bool _draw_action_area(struct _priv *priv)
        return true;
 }
 
-static void _set_focus_policy(struct _priv *priv)
+static void _draw_no_contents(struct _priv *priv)
 {
-       int i;
-
-       elm_object_focus_next_object_set(priv->live_btn, priv->live_btn,
-                       ELM_FOCUS_UP);
-       elm_object_focus_next_object_set(priv->live_btn, priv->live_btn,
-                       ELM_FOCUS_LEFT);
-       elm_object_focus_next_object_set(priv->live_btn, priv->live_btn,
-                       ELM_FOCUS_RIGHT);
-       elm_object_focus_next_object_set(priv->live_btn, priv->menu[0],
-                       ELM_FOCUS_DOWN);
+       Evas_Object *ly;
 
-       for (i = 0; i < ACTION_MENU_COUNT; i++) {
-               if (priv->fav_list)
-                       elm_object_focus_next_object_set(priv->menu[i],
-                                       priv->grid, ELM_FOCUS_DOWN);
-               else
-                       elm_object_focus_next_object_set(priv->menu[i],
-                                       priv->menu[i], ELM_FOCUS_DOWN);
+       ly = utils_add_layout(priv->contents_ly, GRP_ACTION_MENU_NO_FAVORITE,
+                       EINA_FALSE);
+       if (!ly) {
+               _ERR("Add layout failed.");
+               return;
        }
 
-       elm_object_focus_next_object_set(priv->menu[0], priv->menu[0],
-                       ELM_FOCUS_LEFT);
-       elm_object_focus_next_object_set(priv->menu[ACTION_MENU_COUNT - 1],
-                priv->menu[ACTION_MENU_COUNT - 1], ELM_FOCUS_RIGHT);
-
-       elm_object_focus_next_object_set(priv->grid, priv->menu[0],
-                       ELM_FOCUS_UP);
-       elm_object_focus_next_object_set(priv->grid, priv->grid,
-                       ELM_FOCUS_LEFT);
+       elm_object_focus_allow_set(priv->contents_ly, EINA_FALSE);
+       elm_object_part_content_set(priv->contents_ly, PART_NO_FAVORITE, ly);
 }
 
 static int _get_favorite_grid_height(int cnt)
@@ -452,19 +522,17 @@ static int _get_favorite_grid_height(int cnt)
        return height;
 }
 
-static bool _draw_favorite_area(struct _priv *priv)
+static bool _update_favorite_area(struct _priv *priv)
 {
        int cnt;
 
        if (!priv->fav_list) {
-               elm_object_signal_emit(priv->menu_area,
-                               SIG_NO_CONTENT, SRC_FAVORITE_AREA);
-               _set_focus_policy(priv);
-
+               elm_gengrid_clear(priv->grid);
+               _draw_no_contents(priv);
                return true;
        }
 
-       elm_object_signal_emit(priv->menu_area, SIG_CONTENT, SRC_FAVORITE_AREA);
+       elm_object_part_content_unset(priv->contents_ly, PART_NO_FAVORITE);
 
        if (!gridmgr_append_list(priv->gmgr, STR_FAVORITE, priv->fav_list)) {
                _ERR("Gridmgr append list failed.");
@@ -477,54 +545,56 @@ static bool _draw_favorite_area(struct _priv *priv)
                        SIZE_FAVORITE_GRID_WIDTH * SIZE_FAVORITE_COL_MAX,
                        _get_favorite_grid_height(cnt));
 
-       elm_object_part_content_set(priv->menu_area, PART_FAVORITE, priv->grid);
-
-       _set_focus_policy(priv);
+       elm_object_part_content_set(priv->contents_ly,
+                       PART_FAVORITE, priv->grid);
 
        return true;
 }
 
-static Evas_Object *_add_grid(struct _priv *priv)
+static void _set_focus_policy(struct _priv *priv)
 {
-       struct grid_class *gclass;
-       Evas_Object *grid;
-
-       grid = utils_add_gengrid(priv->menu_area, EINA_FALSE,
-                       SIZE_FAVORITE_GRID_WIDTH, SIZE_FAVORITE_GRID_HEIGHT);
-       if (!grid) {
-               _ERR("Add gengrid failed.");
-               return NULL;
-       }
+       int i;
 
-       inputmgr_add_callback(grid, 0, &_grid_input_handler, priv);
+       elm_object_focus_next_object_set(priv->live_btn, priv->live_btn,
+                       ELM_FOCUS_LEFT);
+       elm_object_focus_next_object_set(priv->live_btn, priv->menu[0],
+                       ELM_FOCUS_DOWN);
 
-       gclass = get_favorite_grid_class();
-       if (!gclass) {
-               _ERR("Get favorite grid class failed.");
-               evas_object_del(grid);
-               return NULL;
+       for (i = 0; i < ACTION_MENU_COUNT; i++) {
+               if (priv->fav_list)
+                       elm_object_focus_next_object_set(priv->menu[i],
+                                       priv->grid, ELM_FOCUS_DOWN);
+               else
+                       elm_object_focus_next_object_set(priv->menu[i],
+                                       priv->more_btn, ELM_FOCUS_DOWN);
        }
 
-       if (!gridmgr_add_grid(priv->gmgr, STR_FAVORITE, grid, gclass)) {
-               _ERR("Gridmgr add grid failed.");
-               evas_object_del(grid);
-               return NULL;
-       }
+       elm_object_focus_next_object_set(priv->menu[0], priv->menu[0],
+                       ELM_FOCUS_LEFT);
+       elm_object_focus_next_object_set(priv->menu[ACTION_MENU_COUNT - 1],
+                priv->menu[ACTION_MENU_COUNT - 1], ELM_FOCUS_RIGHT);
 
-       return grid;
-}
+       elm_object_focus_next_object_set(priv->grid, priv->menu[0],
+                       ELM_FOCUS_UP);
+       elm_object_focus_next_object_set(priv->grid, priv->grid,
+                       ELM_FOCUS_LEFT);
 
-static void _hide_done_cb(void *data, Evas_Object *obj,
-               const char *emission, const char *source)
-{
-       viewmgr_hide_view(VIEW_ACTION_MENU);
+       if (!priv->fav_list)
+               elm_object_focus_next_object_set(priv->more_btn, priv->menu[0],
+                               ELM_FOCUS_UP);
+       else
+               elm_object_focus_next_object_set(priv->more_btn, priv->grid,
+                               ELM_FOCUS_UP);
+
+       elm_object_focus_next_object_set(priv->more_btn, priv->more_btn,
+                       ELM_FOCUS_LEFT);
 }
 
 static Evas_Object *_create(Evas_Object *win, void *data)
 {
        struct _priv *priv;
        struct gridmgr *gmgr;
-       Evas_Object *base, *menu_area, *scr, *grid;
+       Evas_Object *base, *scr, *box;
 
        if (!win) {
                _ERR("Get window object failed.");
@@ -544,18 +614,22 @@ static Evas_Object *_create(Evas_Object *win, void *data)
                return NULL;
        }
 
-       menu_area = utils_add_layout(base, GRP_ACTION_MENU, EINA_FALSE);
-       if (!menu_area) {
-               _ERR("Add layout failed.");
+       scr = utils_add_scroller(base, PART_ACTION_MENU, NULL);
+       if (!scr) {
+               _ERR("Add scroller failed.");
                goto end;
        }
 
-       scr = utils_add_scroller(base, PART_ACTION_MENU, menu_area);
-       if (!scr) {
-               _ERR("Add scroller failed.");
+       elm_scroller_step_size_set(scr, 0, SIZE_SCROLLER_STEP);
+
+       box = utils_add_box(scr, NULL, EINA_FALSE, 0.0, 0.0);
+       if (!box) {
+               _ERR("Add box failed.");
                goto end;
        }
 
+       elm_box_align_set(box, 0.5, 0.0);
+
        gmgr = gridmgr_create();
        if (!gmgr) {
                _ERR("Create gridmgr failed.");
@@ -564,17 +638,11 @@ static Evas_Object *_create(Evas_Object *win, void *data)
 
        priv->win = win;
        priv->base = base;
-       priv->menu_area = menu_area;
+       priv->scroller = scr;
+       priv->box = box;
        priv->gmgr = gmgr;
 
-       grid = _add_grid(priv);
-       if (!grid) {
-               _ERR("Add grid failed.");
-               gridmgr_destroy(gmgr);
-               goto end;
-       }
-
-       priv->grid = grid;
+       _add_view_contents(priv);
 
        if (!viewmgr_set_view_data(VIEW_ACTION_MENU, priv)) {
                _ERR("Set view data failed.");
@@ -594,13 +662,6 @@ end:
        return NULL;
 }
 
-static void _draw_action_menu(struct _priv *priv)
-{
-       _draw_livetv_area(priv);
-       _draw_action_area(priv);
-       _draw_favorite_area(priv);
-}
-
 static void _show(void *data)
 {
        struct _priv *priv;
@@ -611,11 +672,23 @@ static void _show(void *data)
        }
        priv = data;
 
+       elm_scroller_region_show(priv->scroller, 0, 0, 0, 0);
+
+       if (!_update_action_area(priv)) {
+               _ERR("Update action area failed.");
+               return;
+       }
+
+       if (!_update_favorite_area(priv)) {
+               _ERR("Update favorite area failed.");
+               return;
+       }
+
+       _set_focus_policy(priv);
+
        if (priv->base)
                evas_object_show(priv->base);
 
-       _draw_action_menu(priv);
-
        elm_object_signal_emit(priv->base, SIG_SHOW, SIG_SOURCE_EDC);
        elm_object_focus_set(priv->live_btn, EINA_TRUE);
 }