From 5068e438bcfc4efafbffa0c0d6fc3b0f06ebe483 Mon Sep 17 00:00:00 2001 From: Hyojung Jo Date: Tue, 28 Jul 2015 20:09:16 +0900 Subject: [PATCH] Tv grid: Draw the channel grid thumbnail Change-Id: I781bdaf8071586aa7f3a204c0ac27a6772f08e9a Signed-off-by: Hyojung Jo --- include/define.h | 4 + res/images/ic_default_tv.png | Bin 0 -> 1402 bytes res/widgets/gengrid_tv.edc | 455 ++++++++++++++++++++++++++++++++++++++++++- src/data/channel.c | 37 +++- src/grid/grid_tv.c | 68 ++++++- 5 files changed, 557 insertions(+), 7 deletions(-) create mode 100644 res/images/ic_default_tv.png diff --git a/include/define.h b/include/define.h index d05dc7c..b2306c1 100644 --- a/include/define.h +++ b/include/define.h @@ -40,6 +40,7 @@ #define PART_THUMB_ICON_BG "part.thumb.icon.bg" #define PART_THUMB_TEXT_BG "part.thumb.text.bg" #define PART_THUMB_PLAY_ICON "part.thumb.play.icon" +#define PART_THUMB_DEFAULT_TV_ICON "part.thumb.default.tv.icon" /* Style */ #define STYLE_MENU_BTN "style.menu.button" @@ -72,8 +73,10 @@ #define STR_CNT_APPS "apps" #define STR_CNT_WEBS "bookmark" #define STR_MEDIAHUB_APP_ID "org.tizen.mediahub" +#define STR_LIVETV_APP_ID "org.tizen.live-tv" #define STR_KEY_MEDIA_ID "media_id" #define STR_KEY_SENDER_ID "sender_id" +#define STR_KEY_SERVICE_ID "service_id" /* Font */ #define FONT_TIZENSANS_REGULAR "TizenSans" @@ -96,6 +99,7 @@ #define PLAY_ICON_PNG "ic_thumbnail_play.png" #define DEFAULT_IMAGE_PNG IMGDIR"/ic_thumbnail_picture.png" #define DEFAULT_APP_PNG IMGDIR"/ic_default_app.png" +#define DEFAULT_TV_PNG IMGDIR"/ic_default_tv.png" /* Path */ #define PATH_PLAY_ICON_PNG IMGDIR"/ic_thumbnail_play.png" diff --git a/res/images/ic_default_tv.png b/res/images/ic_default_tv.png new file mode 100644 index 0000000000000000000000000000000000000000..71db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6&)xdg7&+!MV u-aBoT-|>Bk9y|mUm=K|9gj8N<&XqKbLh*2~7Yu)Y-NG literal 0 HcmV?d00001 diff --git a/res/widgets/gengrid_tv.edc b/res/widgets/gengrid_tv.edc index 42afe45..c39e7a1 100644 --- a/res/widgets/gengrid_tv.edc +++ b/res/widgets/gengrid_tv.edc @@ -16,7 +16,460 @@ group { name, "elm/gengrid/item/style.tv/default"; + data.item, "selectraise" "on"; + data.item, "focus_highlight" "on"; + data.item, "texts" "part.thumb.text"; + data.item, "contents" "part.thumb.icon part.thumb.default.tv.icon"; parts { - /* It will be implemented later */ + part { + name, "padding.bottom.right"; + type, SPACER; + scale, 1; + description { + state, "default" 0.0; + rel1.relative, 1.0 1.0; + min, 26 26; + align, 1.0 1.0; + fixed, 1 1; + } + } + + part { + name, "map"; + type, RECT; + scale, 1; + description { + state, "default" 0.0; + perspective { + zplane, 0; + focal, 1000; + } + visible, 0; + } + description { + state, "selected" 0.0; + inherit, "default" 0.0; + perspective.zplane, -100; + } + } + + part { + name, "part.bg"; + type, RECT; + scale, 1; + description { + state, "default" 0.0; + rel2 { + to, "padding.bottom.right"; + relative, 0.0 0.0; + } + fixed, 1 1; + visible, 0; + } + } + + part { + name, "part.default.bg"; + type, RECT; + scale, 1; + description { + state, "default" 0.0; + rel1.to, "part.bg"; + rel2 { + to, "part.thumb.text.bg"; + relative, 1.0 1.0; + } + color, 132 147 166 255; + map { + perspective_on, 1; + perspective, "map"; + } + } + description { + state, "focused" 0.0; + inherit, "default" 0.0; + map.on, 1; + } + } + + part { + name, PART_THUMB_ICON; + type, SWALLOW; + scale, 1; + description { + state, "default" 0.0; + rel1.to, "part.default.bg"; + rel2.to, "part.default.bg"; + map { + perspective_on, 1; + perspective, "map"; + } + } + description { + state, "focused" 0.0; + inherit, "default" 0.0; + map.on, 1; + } + } + + part { + name, "padding.default.icon"; + type, SPACER; + scale, 1; + description { + state, "default" 0.0; + min, 139 56; + rel2.relative, 0.0 0.0; + align, 0.0 0.0; + fixed, 1 1; + } + } + + part { + name, PART_THUMB_DEFAULT_TV_ICON; + type, SWALLOW; + scale, 1; + description { + state, "default" 0.0; + min, 100 100; + rel1 { + to, "padding.default.icon"; + relative, 1.0 1.0; + } + rel2 { + to, "padding.default.icon"; + relative, 1.0 1.0; + } + align, 0.0 0.0; + fixed, 1 1; + map { + perspective_on, 1; + perspective, "map"; + } + } + description { + state, "focused" 0.0; + inherit, "default" 0.0; + map.on, 1; + } + } + + part { + name, "part.focus.up"; + type, RECT; + mouse_events, 0; + scale, 1; + description { + state, "default" 0.0; + color, COLOR_ITEM_FOCUS; + rel1.to, "part.bg"; + rel2 { + to, "part.bg"; + relative, 1.0 0.0; + } + min, 0 6; + align, 0.5 0.0; + fixed, 0 1; + visible, 0; + map { + perspective_on, 1; + perspective, "map"; + } + } + description { + state, "focused" 0.0; + inherit, "default" 0.0; + map.on, 1; + visible, 1; + } + description { + state, "focused_0" 0.0; + inherit, "default" 0.0; + visible, 1; + color, COLOR_ITEM_FOCUS_0; + } + } + + part { + name, "part.focus.left"; + type, RECT; + mouse_events, 0; + scale, 1; + description { + state, "default" 0.0; + color, COLOR_ITEM_FOCUS; + rel1 { + to, "part.focus.up"; + relative, 0.0 1.0; + } + rel2 { + to, "part.thumb.text.bg"; + relative, 0.0 0.0; + } + min, 6 0; + align, 0.0 0.5; + fixed, 1 0; + visible, 0; + map { + perspective_on, 1; + perspective, "map"; + } + } + description { + state, "focused" 0.0; + inherit, "default" 0.0; + visible, 1; + map.on, 1; + } + description { + state, "focused_0" 0.0; + inherit, "default" 0.0; + visible, 1; + color, COLOR_ITEM_FOCUS_0; + } + } + + part { + name, "part.focus.right"; + type, RECT; + mouse_events, 0; + scale, 1; + description { + state, "default" 0.0; + color, COLOR_ITEM_FOCUS; + rel1 { + to, "part.focus.up"; + relative, 1.0 1.0; + } + rel2 { + to, "part.thumb.text.bg"; + relative, 1.0 0.0; + } + min, 6 0; + align, 1.0 0.5; + fixed, 1 0; + visible, 0; + map { + perspective_on, 1; + perspective, "map"; + } + } + description { + state, "focused" 0.0; + inherit, "default" 0.0; + visible, 1; + map.on, 1; + } + description { + state, "focused_0" 0.0; + inherit, "default" 0.0; + visible, 1; + color, COLOR_ITEM_FOCUS_0; + } + } + + part { + name, "part.default.text.bg"; + type, RECT; + mouse_events, 0; + scale, 1; + description { + state, "default" 0.0; + rel1 { + to, "part.bg"; + relative, 0.0 1.0; + } + rel2.to, "part.bg"; + min, 0 82; + align, 0.5 1.0; + color, COLOR_TEXT_BG; + fixed, 0 1; + map { + perspective_on, 1; + perspective, "map"; + } + } + description { + state, "focused" 0.0; + inherit, "default" 0.0; + color, COLOR_ITEM_FOCUS; + map.on, 1; + } + } + + part { + name, "part.thumb.text.bg"; + type, RECT; + mouse_events, 0; + scale, 1; + description { + state, "default" 0.0; + color, COLOR_TEXT_BG; + rel1.to, "part.default.text.bg"; + rel2.to, "part.default.text.bg"; + map { + perspective_on, 1; + perspective, "map"; + } + } + description { + state, "focused" 0.0; + inherit, "default" 0.0; + color, COLOR_ITEM_FOCUS; + map.on, 1; + } + description { + state, "focused_0" 0.0; + inherit, "default" 0.0; + color, COLOR_ITEM_FOCUS_0; + } + } + + part { + name, "padding.thumb.text"; + type, SPACER; + scale, 1; + description { + state, "default" 0.0; + min, 18 0; + rel1.to, "part.thumb.text.bg"; + rel2 { + to, "part.thumb.text.bg"; + relative, 0.0 1.0; + } + align, 0.0 0.5; + fixed, 1 0; + } + } + + part { + name, PART_THUMB_TEXT; + type, TEXT; + scale, 1; + description { + state, "default" 0.0; + color, 255 255 255 255; + min, 342 82; + rel1 { + to, "padding.thumb.text"; + relative, 1.0 0.0; + } + rel2 { + to, "padding.thumb.text"; + relative, 1.0 0.0; + } + align, 0.0 0.0; + fixed, 1 1; + text { + font, FONT_TIZENSANS_LIGHT; + size, 28; + align, 0.0 0.5; + } + map { + perspective_on, 1; + perspective, "map"; + } + } + description { + state, "focused" 0.0; + inherit, "default" 0.0; + map.on, 1; + } + description { + state, "focused_0" 0.0; + inherit, "focused" 0.0; + } + } + } + + programs { + program { + name, SIG_FOCUSED; + signal, "elm,state,focused"; + source, "elm"; + action, STATE_SET "focused_0" 0.0; + target, "part.focus.up"; + target, "part.focus.left"; + target, "part.focus.right"; + target, "part.thumb.text.bg"; + target, PART_THUMB_TEXT; + after, "focus.in.anim"; + } + + program { + name, "focus.in.anim"; + action, STATE_SET "focused" 0.0; + target, "part.default.bg"; + target, PART_THUMB_ICON; + target, PART_THUMB_DEFAULT_TV_ICON; + target, "part.focus.up"; + target, "part.focus.left"; + target, "part.focus.right"; + target, "part.thumb.text.bg"; + transition, TRANSITION_FOCUS; + after, "focus.in.anim.2"; + } + + program { + name, "focus.in.anim.2"; + action, STATE_SET "focused" 0.0; + target, "part.default.text.bg"; + } + + program { + name, SIG_UNFOCUSED; + signal, "elm,state,unfocused"; + source, "elm"; + action, STATE_SET "default" 0.0; + target, PART_THUMB_TEXT; + target, "part.default.text.bg"; + after, "focus.out.anim"; + } + + program { + name, "focus.out.anim"; + action, STATE_SET "focused_0" 0.0; + target, "part.focus.up"; + target, "part.focus.left"; + target, "part.focus.right"; + target, "part.thumb.text.bg"; + transition, TRANSITION_FOCUS; + after, "focus.out.anim.2"; + } + + program { + name, "focus.out.anim.2"; + action, STATE_SET "default" 0.0; + target, PART_THUMB_ICON; + target, PART_THUMB_DEFAULT_TV_ICON; + target, "part.default.bg"; + target, "part.focus.up"; + target, "part.focus.left"; + target, "part.focus.right"; + target, "part.thumb.text.bg"; + } + + program { + name, SIG_SELECTED; + signal, "elm,state,selected"; + source, "elm"; + action, STATE_SET "selected" 0.0; + target, "map"; + transition, TRANSITION_CLICK; + after, "after_selected"; + } + + program { + name, "after_selected"; + action, STATE_SET "default" 0.0; + target, "map"; + transition, TRANSITION_CLICK; + after, "item_selected"; + } + + program { + name, "item_selected"; + action, SIGNAL_EMIT SIG_ITEM_SELECTED SRC_EDC; + } } } diff --git a/src/data/channel.c b/src/data/channel.c index d6e5e1a..7bacdf0 100644 --- a/src/data/channel.c +++ b/src/data/channel.c @@ -17,12 +17,15 @@ #include #include #include +#include +#include #include #include "define.h" #include "datamgr.h" struct channel_data { + int id; char *name; long major; long minor; @@ -48,6 +51,7 @@ static void _channel_favorite_list_foreach(gpointer data, gpointer user_data) return; } + cdata->id = channel->service_id; cdata->major = channel->major; cdata->minor = channel->minor; @@ -129,7 +133,6 @@ static char *_get_data(void *data, enum data_type type) _ERR("Invalid data type."); return NULL; } - } static void _free_favorites(Eina_List *list) @@ -152,7 +155,37 @@ static void _free_favorites(Eina_List *list) static bool _action(Elm_Object_Item *it) { - /* It will be implemented later. */ + struct channel_data *cdata; + bundle *b = NULL; + int r, svcid; + + if (!it) { + _ERR("Invalid argument."); + return false; + } + + cdata = elm_object_item_data_get(it); + if (!cdata) + return false; + + svcid = cdata->id; + + b = bundle_create(); + if (!b) { + _ERR("Bundle create failed."); + return false; + } + + bundle_add_byte(b, STR_KEY_SERVICE_ID, &svcid, sizeof(int)); + + r = aul_launch_app(STR_LIVETV_APP_ID, b); + if (r < 0) { + _ERR("Livetv launch failed."); + bundle_free(b); + return false; + } + + bundle_free(b); return true; } diff --git a/src/grid/grid_tv.c b/src/grid/grid_tv.c index fab325b..4594842 100644 --- a/src/grid/grid_tv.c +++ b/src/grid/grid_tv.c @@ -29,16 +29,58 @@ static char *_text_get(void *data, Evas_Object *obj, const char *part) { - /* It will be implemented later. */ + struct datamgr *dmgr; + char *name; + + if (!data) { + _ERR("Data is NULL."); + return NULL; + } - return NULL; + dmgr = get_channel_datamgr(); + if (!dmgr || !dmgr->get_data) + return NULL; + + name = dmgr->get_data(data, DATA_NAME); + if (!name) + return NULL; + + return name; } static Evas_Object *_content_get(void *data, Evas_Object *obj, const char *part) { - /* It will be implemented later. */ + struct datamgr *dmgr; + Evas_Object *img; + char *thumbnail; + + if (!data || !obj) { + _ERR("Invalid argument."); + return NULL; + } + + dmgr = get_channel_datamgr(); + if (!dmgr || !dmgr->get_data) + return NULL; + + thumbnail = dmgr->get_data(data, DATA_THUMBNAIL); - return NULL; + img = elm_image_add(obj); + if (!img) { + _ERR("elm_image_add failed."); + return NULL; + } + elm_image_aspect_fixed_set(img, EINA_FALSE); + evas_object_show(img); + + if (!strcmp(part, PART_THUMB_ICON) && thumbnail) + elm_image_file_set(img, thumbnail, NULL); + else if (!strcmp(part, PART_THUMB_DEFAULT_TV_ICON) && !thumbnail) + elm_image_file_set(img, DEFAULT_TV_PNG, NULL); + else + img = NULL; + + return img; } static struct grid_class _gclass = { @@ -74,6 +116,23 @@ static void _destroy_item_list(Eina_List *list) dmgr->free_favorites(list); } +static void _item_selected(Elm_Object_Item *it) +{ + struct datamgr *dmgr; + + if (!it) { + _ERR("Invalid argument."); + return; + } + + dmgr = get_channel_datamgr(); + if (!dmgr || !dmgr->action) + return; + + if (!dmgr->action(it)) + _ERR("The item action failed."); +} + static struct grid_data _gdata = { .id = STR_TV, .item_size_x = ITEM_TV_X, @@ -81,6 +140,7 @@ static struct grid_data _gdata = { .gclass = &_gclass, .create_item_list = _create_item_list, .destroy_item_list = _destroy_item_list, + .item_selected = _item_selected, }; struct grid_data *get_tv_grid_data(void) -- 2.7.4