diff options
author | jinwoo.shin <jw0227.shin@samsung.com> | 2015-08-21 15:42:07 +0900 |
---|---|---|
committer | jinwoo.shin <jw0227.shin@samsung.com> | 2015-08-21 15:45:47 +0900 |
commit | c14da7b0782bca3f37ff1a7b508a2bcbaeb95ce6 (patch) | |
tree | 2ac2c6a5acb6ad36a2f6e91c861088f5a9c21586 | |
parent | bdd9c587914eb6136336436dc0c5b045dddb240e (diff) | |
download | air_livetv-c14da7b0782bca3f37ff1a7b508a2bcbaeb95ce6.tar.gz air_livetv-c14da7b0782bca3f37ff1a7b508a2bcbaeb95ce6.tar.bz2 air_livetv-c14da7b0782bca3f37ff1a7b508a2bcbaeb95ce6.zip |
Add favorite list on action menusubmit/tizen/20150821.101452accepted/tizen/tv/20150821.130444
Change-Id: Idfa294546094fa3e00f6acef2eb4dc10cd2a7d19
Signed-off-by: jinwoo.shin <jw0227.shin@samsung.com>
-rw-r--r-- | data/view/action_menu.edc | 175 | ||||
-rw-r--r-- | data/widget/button.edc | 185 | ||||
-rw-r--r-- | include/define.h | 5 | ||||
-rw-r--r-- | include/strings.h | 1 | ||||
-rw-r--r-- | include/tv.h | 1 | ||||
-rw-r--r-- | include/view.h | 2 | ||||
-rw-r--r-- | res/images/ic_default_tv.png | bin | 0 -> 647828 bytes | |||
-rw-r--r-- | src/tv.c | 35 | ||||
-rw-r--r-- | src/util.c | 4 | ||||
-rw-r--r-- | src/view_action_menu.c | 95 |
10 files changed, 494 insertions, 9 deletions
diff --git a/data/view/action_menu.edc b/data/view/action_menu.edc index 973423d..1905e50 100644 --- a/data/view/action_menu.edc +++ b/data/view/action_menu.edc @@ -175,6 +175,162 @@ group { } part { + name, "padding.favorite"; + type, SPACER; + scale, 1; + description { + state, "default" 0.0; + rel1 { + to, "padding.menu.divider.down"; + relative, 0.0 1.0; + } + rel2 { + to, "padding.menu.divider.down"; + relative, 1.0 1.0; + } + min, 0 40; + align, 0.0 0.0; + fixed, 1 1; + } + } + + part { + name, "part.favorite.title"; + type, TEXT; + scale, 1; + description { + state: "default" 0.0; + rel1 { + to, "padding.favorite"; + relative, 0.5 1.0; + } + rel2 { + to, "padding.favorite"; + relative, 0.5 1.0; + } + text { + font, FONT_LIGHT; + size, 32; + align, 0.0 0.5; + text, STR_BUTTON_FAVORITE; + } + color, 77 77 77 255; + min, 440 32; + align, 0.5 0.0; + fixed, 1 1; + } + } + + part { + name, "padding.favorite.list"; + type, SPACER; + scale, 1; + description { + state, "default" 0.0; + rel1 { + to, "part.favorite.title"; + relative, 0.0 1.0; + } + rel2 { + to, "part.favorite.title"; + relative, 1.0 1.0; + } + min, 0 30; + align, 0.0 0.0; + fixed, 1 1; + } + } + + part { + name, PART_FAVORITE; + type, SWALLOW; + scale, 1; + description { + state, "default" 0.0; + rel1 { + to, "padding.favorite.list"; + relative, 0.5 1.0; + } + rel2 { + to, "padding.favorite.list"; + relative, 0.5 1.0; + } + min, 440 0; + align, 0.5 0.0; + fixed, 1 1; + } + } + + part { + name, "padding.favorite.list_bottom"; + type, SPACER; + scale, 1; + description { + state, "default" 0.0; + rel1 { + to, "menu_area"; + relative, 0.0 1.0; + } + rel2 { + to, "menu_area"; + relative, 1.0 1.0; + } + min, 0 32; + align, 0.0 1.0; + fixed, 1 1; + } + } + + part { + name, "part.favorite.no_favorite"; + type, RECT; + scale, 1; + description { + state, "default" 0.0; + rel1 { + to, "padding.favorite.list"; + relative, 0.5 1.0; + } + rel2 { + to, "padding.favorite.list_bottom"; + relative, 0.5 0.0; + } + min, 440 0; + align, 0.5 0.0; + fixed, 1 1; + color, COLOR_NOFAVORITE_BG; + visible, 0; + } + description { + state, "no_favorite" 0.0; + inherit, "default" 0.0; + visible, 1; + } + + part { + name, "part.favorite.no_favorite.text"; + type, TEXT; + scale, 1; + description { + state, "default" 0.0; + text { + font, FONT_LIGHT; + size, 28; + align, 0.5 0.5; + text, STR_NOFAVORITE; + } + color, COLOR_NOFAVORITE_TEXT; + visible, 0; + } + description { + state, "no_favorite" 0.0; + inherit, "default" 0.0; + visible, 1; + } + } + } + + part { name, "padding.channelinfo"; type, SPACER; scale, 1; @@ -208,4 +364,23 @@ group { } } } + + programs { + program { + name, "no_favorite"; + signal, SIGNAL_NO_FAVORITE; + source, SOURCE_ELM; + action, STATE_SET "no_favorite" 0.0; + target, "part.favorite.no_favorite"; + target, "part.favorite.no_favorite.text"; + } + program { + name, "favorite"; + signal, SIGNAL_FAVORITE; + action, STATE_SET "default" 0.0; + source, SOURCE_ELM; + target, "part.favorite.no_favorite"; + target, "part.favorite.no_favorite.text"; + } + } } diff --git a/data/widget/button.edc b/data/widget/button.edc index 8899e1c..9e745dc 100644 --- a/data/widget/button.edc +++ b/data/widget/button.edc @@ -1012,3 +1012,188 @@ group { } } +group { + name, "elm/button/base/style.action.menu.favorite"; + data.item: "focus_highlight" "on"; + parts { + part { + name: "area"; + type: SPACER; + description { + state: "default" 0.0; + min: 440 292; + fixed: 0 0; + } + } + part { + name: "elm.swallow.content"; + type: SWALLOW; + scale: 1; + description { + state: "default" 0.0; + rel1.relative: 0.0 0.0; + rel2.relative: 1.0 0.0; + align: 0.0 0.0; + min: 440 210; + fixed: 1 1; + } + } + part { + name: "content.border_top"; + type: RECT; + mouse_events: 0; + scale: 1; + description { + state: "default" 0.0; + rel1.to: "elm.swallow.content"; + rel2 { + to: "elm.swallow.content"; + relative: 1.0 0.0; + } + min: 0 6; + align: 0.5 0.0; + color: 0 119 246 255; + fixed: 0 1; + visible: 0; + } + description { + state: "focused" 0.0; + inherit: "default" 0.0; + visible: 1; + } + } + part { + name: "content.border_left"; + type: RECT; + mouse_events: 0; + scale: 1; + description { + state: "default" 0.0; + rel1.to: "elm.swallow.content"; + rel2 { + to: "elm.swallow.content"; + relative: 0.0 1.0; + } + min: 6 0; + align: 0.0 0.5; + color: 0 119 246 255; + fixed: 1 0; + visible: 0; + } + description { + state: "focused" 0.0; + inherit: "default" 0.0; + visible: 1; + } + } + part { + name: "content.border_right"; + type: RECT; + mouse_events: 0; + scale: 1; + description { + state: "default" 0.0; + rel1 { + to: "elm.swallow.content"; + relative: 1.0 0.0; + } + rel2 { + to: "elm.swallow.content"; + relative: 1.0 1.0; + } + min: 6 0; + align: 1.0 0.5; + color: 0 119 246 255; + fixed: 1 0; + visible: 0; + } + description { + state: "focused" 0.0; + inherit: "default" 0.0; + visible: 1; + } + } + part { + name: "text.bg"; + type: RECT; + scale: 1; + description { + state: "default" 0.0; + rel1.relative: 0.0 1.0; + rel2.relative: 1.0 1.0; + min: 440 82; + align: 0.0 1.0; + color: 100 100 100 255; + fixed: 1 1; + } + description { + state: "focused" 0.0; + inherit: "default" 0.0; + color: 0 119 246 255; + } + } + part { + name: "elm.text"; + type: TEXT; + scale: 1; + description { + state: "default" 0.0; + rel1 { + to: "text.bg"; + relative: 0.5 0.5; + } + rel2 { + to: "text.bg"; + relative: 0.5 0.5; + } + text { + font: FONT_LIGHT; + size: 28; + align: 0.0 0.5; + } + align: 0.5 0.5; + color: 255 255 255 255; + min: 404 28; + fixed: 1 1; + } + } + part { + name: "event"; + type: RECT; + description { + state: "default" 0.0; + color: 0 0 0 0; + } + } + } + programs { + program { + name: "go_active"; + signal: "elm,action,focus"; + source: "elm"; + action: STATE_SET "focused" 0.0; + target: "elm.swallow.content"; + target: "content.border_top"; + target: "content.border_left"; + target: "content.border_right"; + target: "text.bg"; + } + program { + name: "go_passive"; + signal: "elm,action,unfocus"; + source: "elm"; + action: STATE_SET "default" 0.0; + target: "elm.swallow.content"; + target: "content.border_top"; + target: "content.border_left"; + target: "content.border_right"; + target: "text.bg"; + } + program { + name, "mouse_unclick_after"; + signal, "mouse,clicked,1"; + source, "event"; + action, SIGNAL_EMIT "elm,action,click" ""; + } + } +} diff --git a/include/define.h b/include/define.h index b967015..5196c43 100644 --- a/include/define.h +++ b/include/define.h @@ -43,6 +43,7 @@ #define SIGNAL_LAST "elm,state,last" #define SIGNAL_LOCKED "elm,state,locked" #define SIGNAL_FAVORITE "elm,state,favorite" +#define SIGNAL_NO_FAVORITE "elm,state,no_favorite" #define SIGNAL_TOGGLE "elm,state,toggle" #define SIGNAL_UNTOGGLE "elm,state,untoggle" @@ -58,6 +59,8 @@ #define COLOR_OPTION_TEXT_NORMAL 87 87 87 255 #define COLOR_OPTION_TEXT_FOCUSED 255 255 255 255 #define COLOR_OPTION_BORDER 154 154 154 255 +#define COLOR_NOFAVORITE_BG 229 229 229 255 +#define COLOR_NOFAVORITE_TEXT 0 0 0 178 #define IMAGE_FAV_NOR IMAGEDIR"/btn_menu_favorite_nor.png" #define IMAGE_FAV_FOC IMAGEDIR"/btn_menu_favorite_foc.png" @@ -71,6 +74,7 @@ #define IMAGE_UNLOCK_FOC IMAGEDIR"/btn_menu_unlock_foc.png" #define IMAGE_UNLOCK_SEL IMAGEDIR"/btn_menu_unlock_sel.png" #define IMAGE_UNLOCK_DIS IMAGEDIR"/btn_menu_unlock_dis.png" +#define IMAGE_FAVORITE_DEFAULT IMAGEDIR"/ic_default_tv.png" #define VIEW_CHANNELINFO "VIEW_CHANNELINFO" #define LAYOUT_CHANNELINFO "LAYOUT_CHANNELINFO" @@ -108,6 +112,7 @@ #define GRP_VIEW_ACTION_MENU "grp.view.action_menu" #define PART_TOP_BUTTON "part.top.button" #define PART_MENU "part.menu" +#define PART_FAVORITE "part.favorite" #define PART_CHANNELINFO "part.channelinfo" #endif /* __LIVETV_DEFINE_H__*/ diff --git a/include/strings.h b/include/strings.h index 9722632..6652c6d 100644 --- a/include/strings.h +++ b/include/strings.h @@ -19,6 +19,7 @@ #define STR_NOTITLE "No Information" #define STR_NOTIME "No Data" +#define STR_NOFAVORITE "No favorite channels" #define STR_CHANNEL_PREFIX "CH." #define STR_NOCHANNEL_TITLE "No Channel" #define STR_NOCHANNEL_TEXT "The channel is not found" diff --git a/include/tv.h b/include/tv.h index 40a1458..129b18b 100644 --- a/include/tv.h +++ b/include/tv.h @@ -69,6 +69,7 @@ int tv_resume(void); int tv_overlay_set(void *window_id); Eina_List *tv_channel_get_list(void); +Eina_List *tv_channel_get_favorite_list(void); Eina_List *tv_channel_search_by_number(long major, long minor); void tv_channel_del_list(Eina_List *channel_list); int tv_get_current_service_id(int *service_id); diff --git a/include/view.h b/include/view.h index 2ad1f15..327bedd 100644 --- a/include/view.h +++ b/include/view.h @@ -25,7 +25,7 @@ enum _update_type { UPDATE_TYPE_INPUT_KEY_UP, UPDATE_TYPE_NOCHANNEL, UPDATE_TYPE_NOSIGNAL, - UPDATE_TYPE_CHANNELINFO, + UPDATE_TYPE_ACTION_MENU, }; enum _update_op { diff --git a/res/images/ic_default_tv.png b/res/images/ic_default_tv.png Binary files differnew file mode 100644 index 0000000..eed7a94 --- /dev/null +++ b/res/images/ic_default_tv.png @@ -492,6 +492,41 @@ Eina_List *tv_channel_get_list() return channel_list; } +/** + * Gets a favorite channel list. + * + * @return Favorite channel list, or NULL if fails + */ +Eina_List *tv_channel_get_favorite_list() +{ + GList *tvs_list = NULL; + Eina_List *channel_list = NULL; + TvServiceChannel *tvs_data = NULL; + const struct tv_channel_info *channel_info; + int r, i; + + r = tv_service_get_channel_list( + TV_SERVICE_CHANNEL_MODE_FAVORITE, + TV_SERVICE_ANTENNA_TYPE_ALL, &tvs_list); + if (r != TVS_ERROR_OK) { + _ERR("failed to get channel list"); + return NULL; + } + + for (i = 0; i < g_list_length(tvs_list); i++) { + tvs_data = (TvServiceChannel *) g_list_nth_data(tvs_list, i); + if (tvs_data) { + channel_info = _tv_channel_get_info(tvs_data); + if (channel_info) + channel_list = eina_list_append(channel_list, + channel_info); + free(tvs_data); + } + } + + return channel_list; +} + TvServiceFilterNode *_tv_channel_get_filter( TvServiceChannelDataAttr attribute, int type, void *data) { @@ -122,8 +122,8 @@ Evas_Object *util_add_icon(Evas_Object *parent, const char *file, if (part) elm_object_part_content_set(parent, part, ic); - elm_image_resizable_set(ic, EINA_FALSE, EINA_FALSE); - elm_image_no_scale_set(ic, EINA_TRUE); + elm_image_fill_outside_set(ic, EINA_TRUE); + evas_object_show(ic); return ic; diff --git a/src/view_action_menu.c b/src/view_action_menu.c index 6e167de..8e5438c 100644 --- a/src/view_action_menu.c +++ b/src/view_action_menu.c @@ -23,12 +23,15 @@ #include "util.h" #include "view.h" +#define BUF_MAX 128 #define BUTTON_MAX 16 #define BUTTON_BORDER 1 #define ITEMS_IN_ROW 4 +#define FAVORITE_PADDING_Y 32 #define STYLE_LIVETV_BTN "style.livetv.button" #define STYLE_ACTION_MENU_BTN "style.action.menu.button" +#define STYLE_ACTION_MENU_FAVORITE "style.action.menu.favorite" #define UNTOGGLE 0 #define TOGGLE 1 @@ -51,6 +54,7 @@ struct _priv { Evas_Object *base; Evas_Object *channel_info; Evas_Object *menu_btn[BUTTON_MAX]; + Evas_Object *favorite; }; struct _button_data { @@ -77,7 +81,7 @@ static void _fav_clicked(void) if (r < 0) _ERR("failed to set favorite"); - viewmgr_update_view(VIEW_ACTION_MENU, UPDATE_TYPE_CHANNELINFO, NULL); + viewmgr_update_view(VIEW_ACTION_MENU, UPDATE_TYPE_ACTION_MENU, NULL); tv_channel_del_info(channel_info); } @@ -244,6 +248,16 @@ static input_handler button_handler = { .mouse_move = _button_mouse_move_cb }; +static void _favorite_clicked_cb(int id, void *data, Evas_Object *obj) +{ + if (id > 0) + tv_channel_tune_with_service_id(id); +} + +static input_handler favorite_handler = { + .clicked = _favorite_clicked_cb, +}; + static void _update_channel_info(struct _priv *priv) { const struct tv_channel_info *channel_info; @@ -259,6 +273,59 @@ static void _update_channel_info(struct _priv *priv) tv_channel_del_info(channel_info); } +static void _update_favorite(struct _priv *priv) +{ + Eina_List *channel_list, *l; + const struct tv_channel_info *channel_info; + Evas_Object *btn, *obj; + char buf[BUF_MAX]; + int i; + + channel_list = tv_channel_get_favorite_list(); + + i = 0; + while ((obj = elm_table_child_get(priv->favorite, 0, i++))) + inputmgr_remove_callback(obj, &favorite_handler); + + elm_table_clear(priv->favorite, EINA_TRUE); + + if (!channel_list) { + elm_object_signal_emit(priv->base, + SIGNAL_NO_FAVORITE, SOURCE_ELM); + return; + } + + elm_object_signal_emit(priv->base, SIGNAL_FAVORITE, SOURCE_ELM); + + i = 0; + EINA_LIST_FOREACH(channel_list, l, channel_info) { + if (channel_info->channel_minor > 0 && + channel_info->channel_minor < MINOR_MAX) + snprintf(buf, sizeof(buf), "%lu-%lu %s", + channel_info->channel_major, + channel_info->channel_minor, + channel_info->channel_name); + else + snprintf(buf, sizeof(buf), "%lu %s", + channel_info->channel_major, + channel_info->channel_name); + btn = util_add_button(priv->base, NULL, buf, + STYLE_ACTION_MENU_FAVORITE); + if (!btn) { + _ERR("Add button failed."); + continue; + } + + util_add_icon(btn, IMAGE_FAVORITE_DEFAULT, PART_CONTENT); + inputmgr_add_callback(btn, channel_info->service_id, + &favorite_handler, NULL); + + elm_table_pack(priv->favorite, btn, 0, i++, 1, 1); + } + + tv_channel_del_list(channel_list); +} + static bool _draw_channel_info(struct _priv *priv) { Evas_Object *layout; @@ -377,7 +444,18 @@ static bool _draw_menu_area(struct _priv *priv) static bool _draw_bottom_area(struct _priv *priv) { - /* It will be implemented later */ + Evas_Object *table; + + table = elm_table_add(priv->base); + if (!table) { + _ERR("Add table failed."); + return false; + } + elm_table_padding_set(table, 0, FAVORITE_PADDING_Y); + evas_object_show(table); + elm_object_part_content_set(priv->base, PART_FAVORITE, table); + + priv->favorite = table; return true; } @@ -457,6 +535,7 @@ static void _show(void *data) priv = data; _update_channel_info(priv); + _update_favorite(priv); evas_object_show(priv->base); @@ -479,6 +558,7 @@ static void _hide(void *data) static void _destroy(void *data) { struct _priv *priv; + Evas_Object *obj; int i; if (!data) { @@ -495,6 +575,10 @@ static void _destroy(void *data) i++; } + i = 0; + while ((obj = elm_table_child_get(priv->favorite, 0, i++))) + inputmgr_remove_callback(obj, &favorite_handler); + evas_object_del(priv->base); free(priv); @@ -521,13 +605,12 @@ static void _update(void *view_data, int type, void *data) return; } - if (!strcmp(ev->keyname, KEY_MENU) || - !strcmp(ev->keyname, KEY_MENU_REMOTE)) - viewmgr_show_view(VIEW_ACTION_MENU); + viewmgr_show_view(VIEW_ACTION_MENU); break; } - case UPDATE_TYPE_CHANNELINFO: + case UPDATE_TYPE_ACTION_MENU: _update_channel_info(priv); + _update_favorite(priv); break; } } |