From: Hyojung Jo Date: Wed, 19 Aug 2015 06:40:39 +0000 (+0900) Subject: View: Fixed the action menu to use table instead of box X-Git-Tag: submit/tizen/20150821.101452~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=82954bc4893b368a5100e2363df69ce46a6f6c38;p=profile%2Ftv%2Fapps%2Fnative%2Fair_apps.git View: Fixed the action menu to use table instead of box Change-Id: I024bb65207b2ffb865e0ff2acb0761ccccb5a533 Signed-off-by: Hyojung Jo --- diff --git a/include/define.h b/include/define.h index d8d2b84..447075c 100644 --- a/include/define.h +++ b/include/define.h @@ -69,6 +69,7 @@ #define SIG_VISIBLE "visible" #define SIG_INVISIBLE "invisible" #define SIG_DISABLE "disable" +#define SIG_BTN_DISABLE "elm,state,disabled"; /* Signal Source */ #define SRC_MYAPPS "source.myapps" @@ -112,6 +113,8 @@ #define SIZE_SORT_BOX_PAD_H 0 #define SIZE_SORT_BOX_PAD_V 0 #define SIZE_ICON_MAX 100 +#define SIZE_ACTION_TABLE_BORDER 0 +#define SIZE_COL_MAX 4 /* Image */ #define DEFAULT_APP_ICON_PNG IMGDIR"/ico_default.png" diff --git a/include/utils.h b/include/utils.h index e550a8e..6089c17 100644 --- a/include/utils.h +++ b/include/utils.h @@ -25,6 +25,8 @@ Evas_Object *utils_add_box(Evas_Object *parent, const char *part, Evas_Object *utils_add_button(Evas_Object *parent, const char *part, const char *text, const char *style); Evas_Object *utils_add_gengrid(Evas_Object *parent); +Evas_Object *utils_add_table(Evas_Object *table, const char *part, + int padding_x, int padding_y); bool utils_launch_app(const char *appid); #endif /* __AIR_APPS_UTILS_H__ */ diff --git a/res/widget/button.edc b/res/widget/button.edc index 612553b..24ec972 100644 --- a/res/widget/button.edc +++ b/res/widget/button.edc @@ -992,12 +992,19 @@ group { } group { - name, "elm/button/base/style.action.menu.button"; + name, "elm/button/base/style.action.menu.favorite.button"; data.item, "focus_highlight" "on"; script { public cur_state; } + images { + image, ACTION_FAV_NOR_PNG COMP; + image, ACTION_FAV_FOC_PNG COMP; + image, ACTION_FAV_SEL_PNG COMP; + image, ACTION_FAV_DIS_PNG COMP; + } + parts { part { name, "part.bg"; @@ -1098,6 +1105,7 @@ group { scale, 1; description { state, "default" 0.0; + image.normal, ACTION_FAV_NOR_PNG; rel1 { to, "part.icon.bg"; relative, 0.5 0.5; @@ -1113,14 +1121,17 @@ group { description { state, "focused" 0.0; inherit, "default" 0.0; + image.normal, ACTION_FAV_FOC_PNG; } description { - state, "focused" 0.0; + state, "selected" 0.0; inherit, "default" 0.0; + image.normal, ACTION_FAV_SEL_PNG; } description { - state, "focused" 0.0; + state, "disable" 0.0; inherit, "default" 0.0; + image.normal, ACTION_FAV_DIS_PNG; } } @@ -1247,9 +1258,9 @@ group { } program { - name, SIG_DISABLE; - signal, SIG_DISABLE; - source, SRC_ACTION_BTN; + name, SIG_BTN_DISABLE; + signal, SIG_BTN_DISABLE; + source, "elm"; script { set_int(cur_state, STATE_DISABLE); set_state(PART:"part.bg", "disable", 0.0); @@ -1260,58 +1271,9 @@ group { } } -group { - name, "elm/button/base/style.action.menu.favorite.button"; - inherit, "elm/button/base/style.action.menu.button"; - data.item, "focus_highlight" "on"; - images { - image, ACTION_FAV_NOR_PNG COMP; - image, ACTION_FAV_FOC_PNG COMP; - image, ACTION_FAV_SEL_PNG COMP; - image, ACTION_FAV_DIS_PNG COMP; - } - parts { - part { - name, "part.icon"; - type, IMAGE; - scale, 1; - description { - state, "default" 0.0; - rel1 { - to, "part.icon.bg"; - relative, 0.5 0.5; - } - rel2 { - to, "part.icon.bg"; - relative, 0.5 0.5; - } - align, 0.5 0.5; - fixed, 1 1; - min, 60 60; - image.normal, ACTION_FAV_NOR_PNG; - } - description { - state, "focused" 0.0; - inherit, "default" 0.0; - image.normal, ACTION_FAV_FOC_PNG; - } - description { - state, "selected" 0.0; - inherit, "default" 0.0; - image.normal, ACTION_FAV_SEL_PNG; - } - description { - state, "disable" 0.0; - inherit, "default" 0.0; - image.normal, ACTION_FAV_DIS_PNG; - } - } - } -} - group { name, "elm/button/base/style.action.menu.lock.button"; - inherit, "elm/button/base/style.action.menu.button"; + inherit, "elm/button/base/style.action.menu.favorite.button"; data.item, "focus_highlight" "on"; images { image, ACTION_LOCK_NOR_PNG COMP; @@ -1360,7 +1322,7 @@ group { group { name, "elm/button/base/style.action.menu.uninstall.button"; - inherit, "elm/button/base/style.action.menu.button"; + inherit, "elm/button/base/style.action.menu.favorite.button"; data.item, "focus_highlight" "on"; images { image, ACTION_UNINSTALL_NOR_PNG COMP; diff --git a/src/utils.c b/src/utils.c index 1eff322..d26d77a 100644 --- a/src/utils.c +++ b/src/utils.c @@ -160,6 +160,31 @@ Evas_Object *utils_add_gengrid(Evas_Object *parent) return grid; } +Evas_Object *utils_add_table(Evas_Object *parent, const char *part, + int padding_x, int padding_y) +{ + Evas_Object *table; + + if (!parent) { + _ERR("Invalid argument."); + return NULL; + } + + table = elm_table_add(parent); + if (!table) { + _ERR("elm_table_add failed."); + return NULL; + } + + elm_table_padding_set(table, padding_x, padding_y); + evas_object_show(table); + + if (part) + elm_object_part_content_set(parent, part, table); + + return table; +} + bool utils_launch_app(const char *appid) { app_control_h app_ctrl; diff --git a/src/view/view_action_menu.c b/src/view/view_action_menu.c index 38c3db8..8a96a6c 100644 --- a/src/view/view_action_menu.c +++ b/src/view/view_action_menu.c @@ -29,18 +29,28 @@ struct _priv { Evas_Object *menu_btn[ACTION_MENU_COUNT]; }; -const char *str_action[] = { - STR_FAVORITE, - STR_LOCK, - STR_UNINSTALL, - NULL +struct _action_info { + const char *title; + const char *style; + Eina_Bool disable; }; -const char *style_action[] = { - STYLE_ACTION_MENU_FAV_BTN, - STYLE_ACTION_MENU_LOCK_BTN, - STYLE_ACTION_MENU_UNINSTALL_BTN, - NULL +static struct _action_info action_info[] = { + { + .title = STR_FAVORITE, + .style = STYLE_ACTION_MENU_FAV_BTN, + .disable = EINA_FALSE + }, + { + .title = STR_LOCK, + .style = STYLE_ACTION_MENU_LOCK_BTN, + .disable = EINA_TRUE + }, + { + .title = STR_UNINSTALL, + .style = STYLE_ACTION_MENU_UNINSTALL_BTN, + .disable = EINA_TRUE + } }; static void _mouse_move_cb(int id, void *data, Evas *e, Evas_Object *obj, @@ -55,17 +65,43 @@ static void _mouse_move_cb(int id, void *data, Evas *e, Evas_Object *obj, elm_object_focus_set(obj, EINA_TRUE); } +static void _livetv_key_down_cb(int id, void *data, Evas *e, Evas_Object *obj, + Evas_Event_Key_Down *ev) +{ + if (!ev) { + _ERR("Invalid argument."); + return; + } + + if (!strcmp(ev->keyname, KEY_BACK) + || !strcmp(ev->keyname, KEY_BACK_REMOTE)) + viewmgr_hide_view(VIEW_ACTION_MENU); +} + +static void _action_key_down_cb(int id, void *data, Evas *e, Evas_Object *obj, + Evas_Event_Key_Down *ev) +{ + if (!ev) { + _ERR("Invalid argument."); + return; + } + + if (!strcmp(ev->keyname, KEY_BACK) + || !strcmp(ev->keyname, KEY_BACK_REMOTE)) + viewmgr_hide_view(VIEW_ACTION_MENU); +} + static input_handler _livetv_input_handler = { - .mouse_move = _mouse_move_cb - /* It will be implemented later. */ + .mouse_move = _mouse_move_cb, + .key_down = _livetv_key_down_cb }; static input_handler _action_input_handler = { - .mouse_move = _mouse_move_cb - /* It will be implemented later. */ + .mouse_move = _mouse_move_cb, + .key_down = _action_key_down_cb }; -static bool _draw_top_area(struct _priv *priv) +static bool _draw_livetv_area(struct _priv *priv) { Evas_Object *btn; @@ -83,6 +119,10 @@ static bool _draw_top_area(struct _priv *priv) inputmgr_add_callback(btn, 0, &_livetv_input_handler, priv); + elm_object_focus_next_object_set(btn, btn, ELM_FOCUS_UP); + elm_object_focus_next_object_set(btn, btn, ELM_FOCUS_LEFT); + elm_object_focus_next_object_set(btn, btn, ELM_FOCUS_RIGHT); + priv->live_btn = btn; return true; @@ -90,37 +130,39 @@ static bool _draw_top_area(struct _priv *priv) static bool _draw_menu_area(struct _priv *priv) { - Evas_Object *box, *btn; - int i; + Evas_Object *table, *btn; + int i, row = 0, col = 0; if (!priv || !priv->base) { _ERR("Invalid argument."); return false; } - box = utils_add_box(priv->base, PART_MENU, EINA_TRUE, 0, 0); - if (!box) { - _ERR("Add box failed."); + table = utils_add_table(priv->base, PART_MENU, + SIZE_ACTION_TABLE_BORDER, SIZE_ACTION_TABLE_BORDER); + if (!table) { + _ERR("Add table failed."); return false; } for (i = 0; i < ACTION_MENU_COUNT; i++) { - btn = utils_add_button(priv->base, NULL, str_action[i], - style_action[i]); + btn = utils_add_button(priv->base, NULL, action_info[i].title, + action_info[i].style); if (!btn) { _ERR("Add button failed."); - evas_object_del(box); + evas_object_del(table); return false; } inputmgr_add_callback(btn, i, &_action_input_handler, priv); - /* 'Lock' and 'Uninstall' is not supported, so emit disable. */ - if (i != 0) - elm_object_signal_emit(btn, - SIG_DISABLE, SRC_ACTION_BTN); + if (action_info[i].disable) + elm_object_disabled_set(btn, EINA_TRUE); + + col = i % SIZE_COL_MAX; + row = i / SIZE_COL_MAX; - elm_box_pack_end(box, btn); + elm_table_pack(table, btn, col, row, 1, 1); priv->menu_btn[i] = btn; } @@ -136,7 +178,7 @@ static bool _draw_menu_area(struct _priv *priv) return true; } -static bool _draw_bottom_area(struct _priv *priv) +static bool _draw_favorite_area(struct _priv *priv) { if (!priv || !priv->base) { _ERR("Invalid argument."); @@ -155,8 +197,8 @@ static void _draw_view_content(struct _priv *priv) return; } - if (!_draw_top_area(priv)) { - _ERR("Draw top area failed."); + if (!_draw_livetv_area(priv)) { + _ERR("Draw livetv area failed."); return; } @@ -165,8 +207,8 @@ static void _draw_view_content(struct _priv *priv) return; } - if (!_draw_bottom_area(priv)) - _ERR("Draw bottom area failed."); + if (!_draw_favorite_area(priv)) + _ERR("Draw favorite area failed."); } static Evas_Object *_create(Evas_Object *win, void *data)