From: Hyojung Jo Date: Tue, 14 Jul 2015 07:40:02 +0000 (+0900) Subject: View: Applied the random color for app thumb X-Git-Tag: submit/tizen/20150728.063352~9 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=922a5ccf15e082a297bf5a5f64c10c6d115e41ae;p=profile%2Ftv%2Fapps%2Fnative%2Fair_apps.git View: Applied the random color for app thumb Change-Id: I6bd1395e2deaa326853e64c4a7fa3cbc20e2ae98 Signed-off-by: Hyojung Jo --- diff --git a/include/define.h b/include/define.h index fb7c275..f9430de 100644 --- a/include/define.h +++ b/include/define.h @@ -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_APP_THUMB_BG "grp.app.thumb.bg" /* Part for EDC */ #define PART_TOP_TITLE "part.top.title" @@ -36,6 +37,10 @@ #define PART_APP_COUNT "part.app.count" #define PART_NO_CONTENTS "part.no.contents" #define PART_FAVORITE_ICON "part.favorite.icon" +#define PART_THUMB_BG "part.thumb.bg" +#define PART_THUMB_ICON "part.thumb.icon" +#define PART_THUMB_ICON_BG "part.thumb.icon.bg" +#define PART_THUMB_TEXT_BG "part.thumb.text.bg" /* Style */ #define STYLE_MENU_BTN "style.menu.button" diff --git a/res/view/base.edc b/res/view/base.edc index 1ec536a..f0ec2e2 100644 --- a/res/view/base.edc +++ b/res/view/base.edc @@ -257,3 +257,41 @@ group { } } } + +group { + name, GRP_APP_THUMB_BG; + parts { + part { + name, PART_THUMB_ICON_BG; + type, SWALLOW; + scale, 1; + description { + state, "default" 0.0; + min, 212 212; + rel2.relative, 0.0 0.0; + align, 0.0 0.0; + fixed, 1 1; + } + } + + part { + name, PART_THUMB_TEXT_BG; + type, SWALLOW; + scale, 1; + description { + state, "default" 0.0; + min, 212 82; + rel1 { + to, PART_THUMB_ICON_BG; + relative, 0.0 1.0; + } + rel2 { + to, PART_THUMB_ICON_BG; + relative, 0.0 1.0; + } + align, 0.0 0.0; + fixed, 1 1; + } + } + } +} diff --git a/res/widget/gengrid.edc b/res/widget/gengrid.edc index 42b44ef..80e4e23 100644 --- a/res/widget/gengrid.edc +++ b/res/widget/gengrid.edc @@ -18,7 +18,7 @@ group { name, "elm/gengrid/item/style.app/default"; data.item, "focus_highlight" "on"; data.item, "texts" "elm.text"; - data.item, "contents" "elm.swallow.icon"; + data.item, "contents" "part.thumb.icon part.thumb.bg"; images { image, FAVORITE_ICON_PNG COMP; } @@ -38,12 +38,11 @@ group { } part { - name, "bg"; - type, RECT; + name, PART_THUMB_BG; + type, SWALLOW; scale, 1; description { state, "default" 0.0; - color, 255 255 255 255; min, 212 294; rel2 { to, "padding.bottom.right"; @@ -54,13 +53,12 @@ group { } part { - name, "text.bg"; + name, "part.focus.text"; type, RECT; scale, 1; description { state, "default" 0.0; - /* FIXME: The color is temporarily defined. */ - color, 113 128 147 100; + color, 0 119 246 255; min, 212 82; rel1.to, "padding.bottom.right"; rel2 { @@ -69,11 +67,12 @@ group { } align, 1.0 1.0; fixed, 1 1; + visible, 0; } description { state, "focused" 0.0; inherit, "default" 0.0; - color, 0 119 246 255; + visible, 1; } } @@ -84,9 +83,9 @@ group { description { state, "default" 0.0; min, 18 0; - rel1.to, "text.bg"; + rel1.to, "part.focus.text"; rel2 { - to, "text.bg"; + to, "part.focus.text"; relative, 0.0 1.0; } align, 0.0 0.5; @@ -171,7 +170,7 @@ group { } part { - name, "elm.swallow.icon"; + name, PART_THUMB_ICON; type, SWALLOW; scale, 1; description { @@ -292,7 +291,7 @@ group { target, "part.focus.left"; target, "part.focus.down"; target, "part.focus.right"; - target, "text.bg"; + target, "part.focus.text"; after, "item_focused"; } @@ -305,7 +304,7 @@ group { target, "part.focus.left"; target, "part.focus.down"; target, "part.focus.right"; - target, "text.bg"; + target, "part.focus.text"; } program { diff --git a/src/grid/grid_myapps.c b/src/grid/grid_myapps.c index 53fe74c..32506f8 100644 --- a/src/grid/grid_myapps.c +++ b/src/grid/grid_myapps.c @@ -21,6 +21,37 @@ #include "define.h" #include "data/app.h" +/* It is temporarily used. */ +#define COUNT_COLOR 7 + +struct color { + int r; + int g; + int b; + int a; +}; + +static struct color color_icon[] = { + {84, 79, 73, 255}, + {92, 122, 190, 255}, + {73, 155, 173, 255}, + {79, 187, 165, 255}, + {97, 109, 124, 255}, + {169, 54, 54, 255}, + {206, 118, 70, 255} +}; + +static struct color color_text[] = +{ + {73, 68, 62, 255}, + {75, 102, 163, 255}, + {55, 143, 162, 255}, + {47, 175, 149, 255}, + {86, 98, 113, 255}, + {155, 46, 46, 255}, + {200, 99, 45, 255} +}; + static char *_text_get(void *data, Evas_Object *obj, const char *part) { struct app_data *adata; @@ -37,8 +68,9 @@ static char *_text_get(void *data, Evas_Object *obj, const char *part) static Evas_Object *_content_get(void *data, Evas_Object *obj, const char *part) { struct app_data *adata; - Evas_Object *img; + Evas_Object *img, *ly, *icon_bg, *text_bg; char *icon; + int idx; if (!data || !obj) { _ERR("Invalid argument."); @@ -46,21 +78,64 @@ static Evas_Object *_content_get(void *data, Evas_Object *obj, const char *part) } adata = data; - icon = get_app_icon(adata); + if (!strcmp(part, PART_THUMB_ICON)) { + icon = get_app_icon(adata); - img = elm_image_add(obj); - if (!img) { - _ERR("elm_image_add failed."); - return NULL; - } + img = elm_image_add(obj); + if (!img) { + _ERR("elm_image_add failed."); + return NULL; + } - if (!icon || !strcmp(icon, STR_NULL)) - /* FIXME: The default icon image should be registerd. */ - elm_image_file_set(img, NULL, NULL); - else - elm_image_file_set(img, icon, NULL); + if (!icon || !strcmp(icon, STR_NULL)) + /* FIXME: The default icon image should be registerd. */ + elm_image_file_set(img, NULL, NULL); + else + elm_image_file_set(img, icon, NULL); + + return img; + } else if (!strcmp(part, PART_THUMB_BG)) { + ly = elm_layout_add(obj); + if (!ly) { + _ERR("elm_bg_add failed."); + return NULL; + } + + elm_layout_file_set(ly, EDJEFILE, GRP_APP_THUMB_BG); + evas_object_show(ly); + + icon_bg = evas_object_rectangle_add(ly); + if (!icon_bg) { + _ERR("elm_rectangle_add failed."); + evas_object_del(ly); + return NULL; + } + + text_bg = evas_object_rectangle_add(icon_bg); + if (!text_bg) { + _ERR("elm_rectangle_add failed."); + evas_object_del(ly); + return NULL;; + } + + /* FIXME: The color will be changed as GUI later. */ + idx = rand() % COUNT_COLOR; + + evas_object_color_set(icon_bg, + color_icon[idx].r, color_icon[idx].g, + color_icon[idx].b, color_icon[idx].a); + + evas_object_color_set(text_bg, + color_text[idx].r, color_text[idx].g, + color_text[idx].b, color_text[idx].a); + + elm_object_part_content_set(ly, PART_THUMB_ICON_BG, icon_bg); + elm_object_part_content_set(ly, PART_THUMB_TEXT_BG, text_bg); + + return ly; + } - return img; + return NULL; } static struct grid_class _gclass = {