Fixed the action menu be scrolled entirely 43/47543/1
authorHyojung Jo <hj903.jo@samsung.com>
Fri, 4 Sep 2015 11:02:49 +0000 (20:02 +0900)
committerHyojung Jo <hj903.jo@samsung.com>
Fri, 4 Sep 2015 11:02:49 +0000 (20:02 +0900)
Change-Id: Iadd2821c082c54f06d27a4499124ea7bfcde2f27
Signed-off-by: Hyojung Jo <hj903.jo@samsung.com>
include/define.h
include/utils.h
res/view/action_menu.edc
res/widget/button.edc
src/utils.c
src/view/view_action_menu.c
src/view/view_base.c

index 58d8c1dadbe6d5fd60272f3ea158621003e82ac7..95059cd2b92b09881e4b4892edf98dd5f67a9cdc 100644 (file)
@@ -27,6 +27,7 @@
 /* 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"
 
 /* Part for EDC */
 #define PART_TOP_TITLE "part.top.title"
@@ -46,6 +47,7 @@
 #define PART_BUTTON1 "button1"
 #define PART_BUTTON2 "button2"
 #define PART_POPUP_TITLE "title,text"
+#define PART_ACTION_MENU "part.action.menu"
 
 /* Style */
 #define STYLE_MENU_BTN "style.menu.button"
 #define SIZE_ACTION_TABLE_BORDER 0
 #define SIZE_COL_MAX 4
 #define SIZE_TOAST_TIMEOUT 5.0
+#define SIZE_FAVORITE_COL_MAX 2
 
 /* Image */
 #define DEFAULT_APP_ICON_PNG IMGDIR"/ico_default.png"
index 068b2a6ab912cd6ac0fe2a655b0ac83e7a4afd68..c6134e592be95445697ecdbdd0d46259f99e3220 100644 (file)
@@ -20,7 +20,8 @@
 #include <inputmgr.h>
 
 Evas_Object *utils_add_window(const char *name);
-Evas_Object *utils_add_layout(Evas_Object *parent, const char *group);
+Evas_Object *utils_add_layout(Evas_Object *parent, const char *group,
+               Eina_Bool win_resize);
 Evas_Object *utils_add_box(Evas_Object *parent, const char *part,
                Eina_Bool horizontal, Evas_Coord padding_h,
                Evas_Coord padding_v);
@@ -37,6 +38,8 @@ Evas_Object *utils_add_popup(Evas_Object *parent, const char *style,
                const char *popup_title, const char *popup_text);
 Evas_Object *utils_add_ctxpopup(Evas_Object *parent, int opt_size, int *opt_id,
                const char **opt_text, input_handler *opt_handler, void *data);
+Evas_Object *utils_add_scroller(Evas_Object *parent, const char *part,
+               Evas_Object *content);
 bool utils_launch_app(const char *appid);
 bool utils_uninstall_app(const char *pkgid, const char *pkgtype);
 
index 802f7b99b31ac456632c5125419bb095a8df4a5a..3302c5d2477eeb08e08bc880155096e5dbdb9630 100644 (file)
@@ -42,57 +42,49 @@ group {
                }
 
                part {
-                       name, "view.divider";
-                       type, RECT;
+                       name, PART_ACTION_MENU;
+                       type, SWALLOW;
                        scale, 1;
                        description {
                                state, "default" 0.0;
-                               color, 0 0 0 25;
                                rel1.to, "bg";
-                               rel2 {
-                                       to, "bg";
-                                       relative, 0.0 1.0;
-                               }
-                               min, 1 0;
-                               align, 1.0 0.5;
-                               fixed, 1 0;
+                               rel2.to, "bg";
                        }
                }
 
                part {
-                       name, "padding.livetv.btn";
-                       type, SPACER;
+                       name, "view.divider";
+                       type, RECT;
                        scale, 1;
                        description {
                                state, "default" 0.0;
+                               color, 0 0 0 25;
                                rel1.to, "bg";
                                rel2 {
                                        to, "bg";
-                                       relative, 1.0 0.0;
+                                       relative, 0.0 1.0;
                                }
-                               min, 0 120;
-                               align, 0.5 0.0;
-                               fixed, 0 1;
+                               min, 0;
+                               align, 1.0 0.5;
+                               fixed, 1 0;
                        }
                }
+       }
+}
 
+group {
+       name, GRP_ACTION_MENU;
+       parts {
                part {
                        name, PART_TOP_BTN;
                        type, SWALLOW;
                        scale, 1;
                        description {
                                state, "default" 0.0;
-                               rel1 {
-                                       to, "padding.livetv.btn";
-                                       relative, 0.5 0.5;
-                               }
-                               rel2 {
-                                       to, "padding.livetv.btn";
-                                       relative, 0.5 0.5;
-                               }
-                               min, 327 64;
-                               align, 0.5 0.5;
-                               fixed, 1 1;
+                               rel2.relative, 1.0 0.0;
+                               min, 0 120;
+                               align, 0.5 0.0;
+                               fixed, 0 1;
                        }
                }
 
@@ -104,10 +96,10 @@ group {
                                state, "default" 0.0;
                                color, 224 224 224 255;
                                rel1 {
-                                       to, "padding.livetv.btn";
+                                       to, PART_TOP_BTN;
                                        relative, 0.0 1.0;
                                }
-                               rel2.to, "padding.livetv.btn";
+                               rel2.to, PART_TOP_BTN;
                                min, 0 1;
                                align, 0.5 1.0;
                                fixed, 0 1;
@@ -236,23 +228,6 @@ group {
                        }
                }
 
-               part {
-                       name, "padding.favorite.bottomright";
-                       type, SPACER;
-                       scale, 1;
-                       description {
-                               state, "default" 0.0;
-                               min, 10 0;
-                               rel1 {
-                                       to, "bg";
-                                       relative, 1.0 0.0;
-                               }
-                               rel2.to, "bg";
-                               align, 1.0 0.5;
-                               fixed, 1 0;
-                       }
-               }
-
                part {
                        name, PART_FAVORITE;
                        type, SWALLOW;
@@ -263,10 +238,6 @@ group {
                                        to, "padding.favorite.top";
                                        relative, 0.0 1.0;
                                }
-                               rel2 {
-                                       to, "padding.favorite.bottomright";
-                                       relative, 0.0 1.0;
-                               }
                        }
                }
 
@@ -277,11 +248,7 @@ group {
                        description {
                                state, "default" 0.0;
                                min, 30 32;
-                               rel1 {
-                                       to, "bg";
-                                       relative, 1.0 1.0;
-                               }
-                               rel2.to, "bg";
+                               rel1.relative, 1.0 1.0;
                                align, 1.0 1.0;
                                fixed, 1 1;
                        }
index affece6644b0379b92a6b20d7bc6705f24deea4b..282b1017da0d04cdbb2422004efe978f8a5a8fdf 100644 (file)
@@ -774,10 +774,27 @@ group {
                part {
                        name, "part.bg";
                        type, RECT;
+                       mouse_events, 0;
                        scale, 1;
                        description {
                                state, "default" 0.0;
-                               min, 0 64;
+                               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, 327 64;
+                               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;
@@ -797,9 +814,9 @@ group {
                        description {
                                state, "default" 0.0;
                                min, 20 0;
-                               rel1.to, "part.bg";
+                               rel1.to, "part.button.area";
                                rel2 {
-                                       to, "part.bg";
+                                       to, "part.button.area";
                                        relative, 0.0 1.0;
                                }
                                align, 0.0 0.5;
@@ -815,10 +832,10 @@ group {
                                state, "default" 0.0;
                                min, 20 0;
                                rel1 {
-                                       to, "part.bg";
+                                       to, "part.button.area";
                                        relative, 1.0 0.0;
                                }
-                               rel2.to, "part.bg";
+                               rel2.to, "part.button.area";
                                align, 1.0 0.5;
                                fixed, 1 0;
                        }
@@ -864,9 +881,9 @@ group {
                        description {
                                state, "default" 0.0;
                                color, 194 194 194 255;
-                               rel1.to, "part.bg";
+                               rel1.to, "part.button.area";
                                rel2 {
-                                       to, "part.bg";
+                                       to, "part.button.area";
                                        relative, 1.0 0.0;
                                }
                                min, 0 1;
@@ -892,7 +909,7 @@ group {
                                        relative, 0.0 1.0;
                                }
                                rel2 {
-                                       to, "part.bg";
+                                       to, "part.button.area";
                                        relative, 0.0 1.0;
                                }
                                min, 1 0;
@@ -917,7 +934,7 @@ group {
                                        to, "part.inside.line.left";
                                        relative, 1.0 1.0;
                                }
-                               rel2.to, "part.bg";
+                               rel2.to, "part.button.area";
                                min, 0 1;
                                align, 0.5 1.0;
                                fixed, 0 1;
@@ -960,6 +977,8 @@ group {
                        type, RECT;
                        description {
                                state, "default" 0.0;
+                               rel1.to, "part.button.area";
+                               rel2.to, "part.button.area";
                                color, 0 0 0 0;
                        }
                        description {
@@ -976,7 +995,7 @@ group {
                        signal, "elm,action,focus";
                        source, "elm";
                        action, STATE_SET "focused" 0.0;
-                       target, "part.bg";
+                       target, "part.button.area";
                        target, "elm.text";
                        transition, TRANSITION_FOCUS;
                }
@@ -986,7 +1005,7 @@ group {
                        signal, "elm,action,unfocus";
                        source, "elm";
                        action, STATE_SET "default" 0.0;
-                       target, "part.bg";
+                       target, "part.button.area";
                        target, "elm.text";
                        transition, TRANSITION_FOCUS;
                }
index ac1064e43764b18971754916e51c76284db04f85..3bb452a52ce68839d7b290f4b97527ea5a1338f2 100644 (file)
@@ -45,7 +45,8 @@ Evas_Object *utils_add_window(const char *name)
        return win;
 }
 
-Evas_Object *utils_add_layout(Evas_Object *parent, const char *group)
+Evas_Object *utils_add_layout(Evas_Object *parent, const char *group,
+               Eina_Bool win_resize)
 {
        Evas_Object *layout;
 
@@ -64,7 +65,9 @@ Evas_Object *utils_add_layout(Evas_Object *parent, const char *group)
 
        evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND,
                        EVAS_HINT_EXPAND);
-       elm_win_resize_object_add(parent, layout);
+
+       if (win_resize)
+               elm_win_resize_object_add(parent, layout);
 
        return layout;
 }
@@ -327,6 +330,35 @@ Evas_Object *utils_add_ctxpopup(Evas_Object *parent, int opt_size, int *opt_id,
        return ctxpopup;
 }
 
+Evas_Object *utils_add_scroller(Evas_Object *parent, const char *part,
+               Evas_Object *content)
+{
+       Evas_Object *scr;
+
+       if (!parent) {
+               _ERR("Invalid argument.");
+               return NULL;
+       }
+
+       scr = elm_scroller_add(parent);
+       if (!scr) {
+               _ERR("elm_scroller_add failed.");
+               return NULL;
+       }
+
+       elm_scroller_policy_set(scr,
+                       ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
+       elm_object_focus_allow_set(scr, EINA_FALSE);
+
+       if (part)
+               elm_object_part_content_set(parent, part, scr);
+
+       if (content)
+               elm_object_content_set(scr, content);
+
+       return scr;
+}
+
 bool utils_launch_app(const char *appid)
 {
        app_control_h app_ctrl;
index 8eecd384a3c70118fe9bce180a842cfd8050508f..4f6918c8bc0710937c43105f5dc0a27c0e759941 100644 (file)
@@ -39,13 +39,13 @@ struct _priv {
        struct app_data *adata;
        Evas_Object *win;
        Evas_Object *base;
+       Evas_Object *menu_area;
        Evas_Object *grid;
        Evas_Object *live_btn;
        Evas_Object *menu[ACTION_MENU_COUNT];
        Evas_Object *popup;
        struct gridmgr *gmgr;
        Eina_List *fav_list;
-       bool uninstallable;
 };
 
 struct _action_info {
@@ -351,7 +351,7 @@ static bool _draw_livetv_area(struct _priv *priv)
 {
        Evas_Object *btn;
 
-       btn = utils_add_button(priv->base,
+       btn = utils_add_button(priv->menu_area,
                        PART_TOP_BTN, STR_LIVETV, STYLE_LIVETV_BTN);
        if (!btn) {
                _ERR("Add button failed.");
@@ -376,13 +376,10 @@ 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 (!strcmp(pkgtype, STR_WGT) || !strcmp(pkgtype, STR_TPK))
                        action_info[idx].disable = EINA_FALSE;
-                       priv->uninstallable = true;
-               } else {
+               else
                        action_info[idx].disable = EINA_TRUE;
-                       priv->uninstallable = false;
-               }
        }
 
        if (action_info[idx].disable)
@@ -394,7 +391,7 @@ static bool _draw_action_area(struct _priv *priv)
        Evas_Object *table, *btn;
        int i, row = 0, col = 0;
 
-       table = utils_add_table(priv->base, PART_MENU,
+       table = utils_add_table(priv->menu_area, PART_MENU,
                        SIZE_ACTION_TABLE_BORDER, SIZE_ACTION_TABLE_BORDER);
        if (!table) {
                _ERR("Add table failed.");
@@ -402,7 +399,7 @@ static bool _draw_action_area(struct _priv *priv)
        }
 
        for (i = 0; i < ACTION_MENU_COUNT; i++) {
-               btn = utils_add_button(priv->base, NULL, action_info[i].title,
+               btn = utils_add_button(table, NULL, action_info[i].title,
                                action_info[i].style);
                if (!btn) {
                        _ERR("Add button failed.");
@@ -448,17 +445,10 @@ static void _set_focus_policy(struct _priv *priv)
                                        priv->menu[i], ELM_FOCUS_DOWN);
        }
 
-       if (priv->uninstallable) {
-               elm_object_focus_next_object_set(priv->menu[0], priv->menu[1],
-                               ELM_FOCUS_LEFT);
-               elm_object_focus_next_object_set(priv->menu[1], priv->menu[0],
-                               ELM_FOCUS_RIGHT);
-       } else {
-               elm_object_focus_next_object_set(priv->menu[0], priv->menu[0],
-                               ELM_FOCUS_LEFT);
-               elm_object_focus_next_object_set(priv->menu[0], priv->menu[0],
-                               ELM_FOCUS_RIGHT);
-       }
+       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);
@@ -466,25 +456,48 @@ static void _set_focus_policy(struct _priv *priv)
                        ELM_FOCUS_LEFT);
 }
 
+static int _get_favorite_grid_height(int cnt)
+{
+       int height;
+       int col;
+
+       if (cnt % SIZE_FAVORITE_COL_MAX == 0)
+               col = cnt / SIZE_FAVORITE_COL_MAX;
+       else
+               col = cnt / SIZE_FAVORITE_COL_MAX + 1;
+
+       height = SIZE_FAVORITE_GRID_HEIGHT * col;
+
+       return height;
+}
+
 static bool _draw_favorite_area(struct _priv *priv)
 {
+       int cnt;
+
        priv->fav_list = get_app_favorite_list();
        if (!priv->fav_list) {
-               elm_object_signal_emit(priv->base,
+               elm_object_signal_emit(priv->menu_area,
                                SIG_NO_CONTENT, SRC_FAVORITE_AREA);
                _set_focus_policy(priv);
 
                return true;
        }
 
-       elm_object_signal_emit(priv->base, SIG_CONTENT, SRC_FAVORITE_AREA);
+       elm_object_signal_emit(priv->menu_area, SIG_CONTENT, SRC_FAVORITE_AREA);
 
        if (!gridmgr_append_list(priv->gmgr, STR_FAVORITE, priv->fav_list)) {
                _ERR("Gridmgr append list failed.");
                return false;
        }
 
-       elm_object_part_content_set(priv->base, PART_FAVORITE, priv->grid);
+       cnt = eina_list_count(priv->fav_list);
+
+       evas_object_size_hint_min_set(priv->grid,
+                       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);
 
@@ -496,7 +509,7 @@ static Evas_Object *_add_grid(struct _priv *priv)
        struct grid_class *gclass;
        Evas_Object *grid;
 
-       grid = utils_add_gengrid(priv->base, EINA_FALSE,
+       grid = utils_add_gengrid(priv->menu_area, EINA_FALSE,
                        SIZE_FAVORITE_GRID_WIDTH, SIZE_FAVORITE_GRID_HEIGHT);
        if (!grid) {
                _ERR("Add gengrid failed.");
@@ -525,7 +538,7 @@ static Evas_Object *_create(Evas_Object *win, void *data)
 {
        struct _priv *priv;
        struct gridmgr *gmgr;
-       Evas_Object *base, *grid;
+       Evas_Object *base, *menu_area, *scr, *grid;
 
        if (!win) {
                _ERR("Get window object failed.");
@@ -538,13 +551,25 @@ static Evas_Object *_create(Evas_Object *win, void *data)
                return NULL;
        }
 
-       base = utils_add_layout(win, GRP_VIEW_ACTION_MENU);
+       base = utils_add_layout(win, GRP_VIEW_ACTION_MENU, EINA_TRUE);
        if (!base) {
                _ERR("Add layout failed.");
                free(priv);
                return NULL;
        }
 
+       menu_area = utils_add_layout(base, GRP_ACTION_MENU, EINA_FALSE);
+       if (!menu_area) {
+               _ERR("Add layout failed.");
+               goto end;
+       }
+
+       scr = utils_add_scroller(base, PART_ACTION_MENU, menu_area);
+       if (!scr) {
+               _ERR("Add scroller failed.");
+               goto end;
+       }
+
        gmgr = gridmgr_create();
        if (!gmgr) {
                _ERR("Create gridmgr failed.");
@@ -553,6 +578,7 @@ static Evas_Object *_create(Evas_Object *win, void *data)
 
        priv->win = win;
        priv->base = base;
+       priv->menu_area = menu_area;
        priv->gmgr = gmgr;
 
        grid = _add_grid(priv);
@@ -570,8 +596,6 @@ static Evas_Object *_create(Evas_Object *win, void *data)
                goto end;
        }
 
-       _draw_livetv_area(priv);
-
        return base;
 
 end:
@@ -611,6 +635,13 @@ static void _hide(void *data)
                evas_object_hide(priv->base);
 }
 
+static void _draw_action_menu(struct _priv *priv)
+{
+       _draw_livetv_area(priv);
+       _draw_action_area(priv);
+       _draw_favorite_area(priv);
+}
+
 static void _update(void *view_data, int update_type, void *data)
 {
        struct _priv *priv;
@@ -627,8 +658,7 @@ static void _update(void *view_data, int update_type, void *data)
 
                priv->adata = data;
 
-               _draw_action_area(priv);
-               _draw_favorite_area(priv);
+               _draw_action_menu(priv);
        }
 }
 
index b01fcf6ff22fac96cae9cdfc0d35f69db69a6a0a..d1b64316cec8146428e2a8b2b0b18074c15bd461 100644 (file)
@@ -648,7 +648,7 @@ static Evas_Object *_create(Evas_Object *win, void *data)
                return NULL;
        }
 
-       base = utils_add_layout(win, GRP_VIEW_BASE);
+       base = utils_add_layout(win, GRP_VIEW_BASE, EINA_TRUE);
        if (!base) {
                _ERR("Add layout failed.");
                free(priv);