music: set default thumbnail image for album and artist item 85/54185/1
authorJehun Lim <jehun.lim@samsung.com>
Mon, 14 Dec 2015 04:49:17 +0000 (13:49 +0900)
committerJehun Lim <jehun.lim@samsung.com>
Mon, 14 Dec 2015 04:49:17 +0000 (13:49 +0900)
Change-Id: I303e57628b99e8707bd3a3b84e17e95336ee6312
Signed-off-by: Jehun Lim <jehun.lim@samsung.com>
include/define.h
include/view/base.h
res/edc/widgets/gengrid.edc
res/images/ic_thumbnail_artist_default.png [new file with mode: 0644]
res/images/ic_thumbnail_song_default.png [new file with mode: 0644]
src/grid/grid_music.c
src/view/detail.c

index 59c5923..f55eaec 100644 (file)
@@ -74,6 +74,7 @@
 #define PART_ELM_TEXT_COUNT "elm.text.count"
 #define PART_ELM_SWALLOW_THUMBNAIL "elm.swallow.thumbnail"
 #define PART_ELM_SWALLOW_PICTURE "elm.swallow.picture"
+#define PART_ELM_SWALLOW_ICON "elm.swallow.icon"
 #define PART_ELM_SWALLOW_VIDEO "elm.swallow.video"
 #define PART_ELM_SWALLOW_FAVORITE "elm.swallow.favorite"
 #define PART_ELM_SWALLOW_BG "elm.swallow.bg"
index d658f72..fa7bb0a 100644 (file)
@@ -39,6 +39,8 @@
 #define IMAGE_PREVIEW_PLAY "ic_preview_play.png"
 #define IMAGE_THUMBNAIL_PICTURE IMAGEDIR"/ic_thumbnail_picture.png"
 #define IMAGE_THUMBNAIL_SONG "ic_thumbnail_song.png"
+#define IMAGE_THUMBNAIL_SONG_ALBUM IMAGEDIR"/ic_thumbnail_song_default.png"
+#define IMAGE_THUMBNAIL_ARTIST IMAGEDIR"/ic_thumbnail_artist_default.png"
 #define IMAGE_THUMBNAIL_PLAY IMAGEDIR"/ic_thumbnail_play.png"
 #define IMAGE_THUMBNAIL_FAVORITE IMAGEDIR"/ic_thumbnail_favorite.png"
 #define IMAGE_PLAY_INFO_FAVORITE "ic_title_favorite.png"
index 16cac88..b8a3da5 100644 (file)
@@ -18,7 +18,7 @@ group {
        name: "elm/gengrid/item/album_item/default";
        data.item: "selectraise" "on";
        data.item: "texts" "elm.text.title";
-       data.item: "contents" "elm.swallow.thumbnail elm.swallow.textbg";
+       data.item: "contents" "elm.swallow.thumbnail elm.swallow.icon elm.swallow.textbg";
        data.item: "focus_highlight" "on";
        parts {
                part {
@@ -80,6 +80,24 @@ group {
                        }
                }
                part {
+                       name: PART_ELM_SWALLOW_ICON;
+                       type: SWALLOW;
+                       scale: 1;
+                       description {
+                               state: "default" 0.0;
+                               rel1 {
+                                       to: PART_ELM_SWALLOW_THUMBNAIL;
+                                       relative: 0.5 0.5;
+                               }
+                               rel2 {
+                                       to: PART_ELM_SWALLOW_THUMBNAIL;
+                                       relative: 0.5 0.5;
+                               }
+                               min: 128 128;
+                               fixed: 1 1;
+                       }
+               }
+               part {
                        name: "padding_favorite";
                        type: SPACER;
                        scale: 1;
diff --git a/res/images/ic_thumbnail_artist_default.png b/res/images/ic_thumbnail_artist_default.png
new file mode 100644 (file)
index 0000000..1c28312
Binary files /dev/null and b/res/images/ic_thumbnail_artist_default.png differ
diff --git a/res/images/ic_thumbnail_song_default.png b/res/images/ic_thumbnail_song_default.png
new file mode 100644 (file)
index 0000000..93c6c3f
Binary files /dev/null and b/res/images/ic_thumbnail_song_default.png differ
index 12bd7af..d55e7c3 100644 (file)
@@ -111,6 +111,63 @@ static char *_album_text_get(void *data, Evas_Object *obj, const char *part)
        return strdup(ai->name);
 }
 
+static Evas_Object *_album_content_get(void *data, Evas_Object *obj,
+                       const char *part)
+{
+       Evas_Object *eo;
+       struct album_info *ai;
+       struct color_data bg;
+
+       if (!data)
+               return NULL;
+
+       ai = data;
+
+       eo = NULL;
+       if (!strcmp(part, PART_ELM_SWALLOW_THUMBNAIL)) {
+               if (ai->album_art) {
+                       eo = util_add_image(obj, ai->album_art);
+                       if (!eo) {
+                               _ERR("failed to create image object");
+                               return NULL;
+                       }
+               } else {
+                       eo = evas_object_rectangle_add(obj);
+                       if (!eo) {
+                               _ERR("failed to create rectangle object");
+                               return NULL;
+
+                       }
+
+                       app_contents_get_color(ai->name, &bg, NULL);
+                       evas_object_color_set(eo, bg.r, bg.g, bg.b, bg.a);
+               }
+       } else if (!strcmp(part, PART_ELM_SWALLOW_ICON)) {
+               if (ai->album_art)
+                       return NULL;
+
+               eo = util_add_image(obj, IMAGE_THUMBNAIL_SONG_ALBUM);
+               if (!eo) {
+                       _ERR("failed to create image object");
+                       return NULL;
+               }
+       } else if (!strcmp(part, PART_ELM_SWALLOW_TEXTBG)) {
+               eo = evas_object_rectangle_add(obj);
+               if (!eo) {
+                       _ERR("failed to create rectangle object");
+                       return NULL;
+               }
+
+               app_contents_get_color(ai->name, NULL, &bg);
+               evas_object_color_set(eo, bg.r, bg.g, bg.b, bg.a);
+       }
+
+       if (eo)
+               evas_object_show(eo);
+
+       return eo;
+}
+
 static char *_artist_text_get(void *data, Evas_Object *obj, const char *part)
 {
        struct album_info *ai;
@@ -123,7 +180,7 @@ static char *_artist_text_get(void *data, Evas_Object *obj, const char *part)
        return strdup(ai->artist);
 }
 
-static Evas_Object *_album_content_get(void *data, Evas_Object *obj,
+static Evas_Object *_artist_content_get(void *data, Evas_Object *obj,
                        const char *part)
 {
        Evas_Object *eo;
@@ -137,7 +194,28 @@ static Evas_Object *_album_content_get(void *data, Evas_Object *obj,
 
        eo = NULL;
        if (!strcmp(part, PART_ELM_SWALLOW_THUMBNAIL)) {
-               eo = util_add_image(obj, ai->album_art);
+               if (ai->album_art) {
+                       eo = util_add_image(obj, ai->album_art);
+                       if (!eo) {
+                               _ERR("failed to create image object");
+                               return NULL;
+                       }
+               } else {
+                       eo = evas_object_rectangle_add(obj);
+                       if (!eo) {
+                               _ERR("failed to create rectangle object");
+                               return NULL;
+
+                       }
+
+                       app_contents_get_color(ai->name, &bg, NULL);
+                       evas_object_color_set(eo, bg.r, bg.g, bg.b, bg.a);
+               }
+       } else if (!strcmp(part, PART_ELM_SWALLOW_ICON)) {
+               if (ai->album_art)
+                       return NULL;
+
+               eo = util_add_image(obj, IMAGE_THUMBNAIL_ARTIST);
                if (!eo) {
                        _ERR("failed to create image object");
                        return NULL;
@@ -497,7 +575,7 @@ static struct grid_class _gclass[] = {
        [E_MUSIC_ARTIST] = {
                .item_style = STYLE_MUSIC_ARTIST,
                .text_get = _artist_text_get,
-               .content_get = _album_content_get
+               .content_get = _artist_content_get
        },
        [E_MUSIC_GENRE] = {
                .item_style = STYLE_MUSIC_GENRE,
index 05a0326..9a8e2a0 100644 (file)
@@ -520,7 +520,28 @@ static Evas_Object *_album_content_get(void *data, Evas_Object *obj,
 
        eo = NULL;
        if (!strcmp(part, PART_ELM_SWALLOW_THUMBNAIL)) {
-               eo = util_add_image(obj, ai->album_art);
+               if (ai->album_art) {
+                       eo = util_add_image(obj, ai->album_art);
+                       if (!eo) {
+                               _ERR("failed to create image object");
+                               return NULL;
+                       }
+               } else {
+                       eo = evas_object_rectangle_add(obj);
+                       if (!eo) {
+                               _ERR("failed to create rectangle object");
+                               return NULL;
+
+                       }
+
+                       app_contents_get_color(ai->name, &bg, NULL);
+                       evas_object_color_set(eo, bg.r, bg.g, bg.b, bg.a);
+               }
+       } else if (!strcmp(part, PART_ELM_SWALLOW_ICON)) {
+               if (ai->album_art)
+                       return NULL;
+
+               eo = util_add_image(obj, IMAGE_THUMBNAIL_SONG_ALBUM);
                if (!eo) {
                        _ERR("failed to create image object");
                        return NULL;