diff options
-rw-r--r-- | include/view/detail.h | 5 | ||||
-rw-r--r-- | res/edc/view/detail.edc | 43 | ||||
-rw-r--r-- | src/util/util.c | 8 | ||||
-rw-r--r-- | src/view/detail.c | 167 |
4 files changed, 176 insertions, 47 deletions
diff --git a/include/view/detail.h b/include/view/detail.h index cba2791..2f36bed 100644 --- a/include/view/detail.h +++ b/include/view/detail.h @@ -25,8 +25,13 @@ /* part */ #define PART_DETAIL_TITLE "part.detail_title" +#define PART_DETAIL_THUMBNAIL "part.detail_thumbnail" #define PART_DETAIL_CONTENT_INFO "part.detail_content_info" #define PART_DETAIL_THUMBNAIL_AREA "part.detail_thumbnail_area" #define PART_DETAIL_PLAYING_INFO "part.detail_playing_info" +/* signal */ +#define SIG_SHOW_THUMBNAIL "show,thumbnail" +#define SIG_HIDE_THUMBNAIL "hide,thumbnail" + #endif /* __AIR_MEDIAHUB_VIEW_DETAIL_H__ */ diff --git a/res/edc/view/detail.edc b/res/edc/view/detail.edc index 90fbddd..9be3cd2 100644 --- a/res/edc/view/detail.edc +++ b/res/edc/view/detail.edc @@ -40,12 +40,39 @@ group { } } part { + name: PART_DETAIL_THUMBNAIL; + type: SWALLOW; + scale: 1; + description { + state: "default" 0.0; + rel2 { + to: "toparea_bg"; + relative: 0.0 1.0; + } + min: 0 0; + align: 0.0 0.5; + fixed: 1 0; + } + description { + state: "show" 0.0; + inherit: "default" 0.0; + min: 134 0; + } + } + part { name: "padding_title_left"; type: SPACER; scale: 1; description { state: "default" 0.0; - rel2.relative: 0.0 0.0; + rel1 { + to: PART_DETAIL_THUMBNAIL; + relative: 1.0 0.0; + } + rel2 { + to: PART_DETAIL_THUMBNAIL; + relative: 1.0 0.0; + } min: 36 22; align: 0.0 0.0; fixed: 1 1; @@ -215,5 +242,19 @@ group { action: STATE_SET "default" 0.0; target: "curtain"; } + program { + name: SIG_SHOW_THUMBNAIL; + signal: SIG_SHOW_THUMBNAIL; + source: SIG_SOURCE_SRC; + action: STATE_SET "show" 0.0; + target: PART_DETAIL_THUMBNAIL; + } + program { + name: SIG_HIDE_THUMBNAIL; + signal: SIG_HIDE_THUMBNAIL; + source: SIG_SOURCE_SRC; + action: STATE_SET "default" 0.0; + target: PART_DETAIL_THUMBNAIL; + } } } diff --git a/src/util/util.c b/src/util/util.c index c698a3d..80c2328 100644 --- a/src/util/util.c +++ b/src/util/util.c @@ -182,7 +182,7 @@ Evas_Object *util_add_image(Evas_Object *base, const char *file) { Evas_Object *image; - if (!base || !file) + if (!base) return NULL; image = elm_image_add(base); @@ -191,8 +191,10 @@ Evas_Object *util_add_image(Evas_Object *base, const char *file) return NULL; } - elm_image_file_set(image, file, NULL); - elm_image_aspect_fixed_set(image, EINA_FALSE); + if (file) { + elm_image_file_set(image, file, NULL); + elm_image_aspect_fixed_set(image, EINA_FALSE); + } return image; } diff --git a/src/view/detail.c b/src/view/detail.c index f7ec7de..f14d85b 100644 --- a/src/view/detail.c +++ b/src/view/detail.c @@ -28,6 +28,8 @@ #include "grid/grid.h" #include "util/util.h" +struct _priv; + static char *_grid_text_get(void *data, Evas_Object *obj, const char *part); static Evas_Object *_grid_content_get(void *data, Evas_Object *obj, const char *part); @@ -36,10 +38,10 @@ static char *_album_text_get(void *data, Evas_Object *obj, const char *part); static Evas_Object *_album_content_get(void *data, Evas_Object *obj, const char *part); -static void _get_movie_count(char *str, int size, Eina_List *list); -static void _get_gallery_count(char *str, int size, Eina_List *list); -static void _get_song_count(char *str, int size, Eina_List *list); -static void _get_album_count(char *str, int size, Eina_List *list); +static void _get_movie_info(struct _priv *priv, const char *title); +static void _get_gallery_info(struct _priv *priv, const char *title); +static void _get_song_info(struct _priv *priv, const char *title); +static void _get_album_info(struct _priv *priv, const char *title); static void _album_selected(void *data); @@ -55,7 +57,7 @@ struct _view_info { char *(*get_grid_text)(void *data, Evas_Object *obj, const char *part); Evas_Object *(*get_grid_content)(void *data, Evas_Object *obj, const char *part); - void (*get_content_info)(char *str, int size, Eina_List *list); + void (*get_content_info)(struct _priv *priv, const char *title); void (*selected)(void *data); bool detail_update; @@ -68,7 +70,7 @@ static struct _view_info view_info[E_DETAIL_MAX] = { .grid_item_y = MOVIE_NAME_ITEM_Y, .get_grid_text = _grid_text_get, .get_grid_content = _grid_content_get, - .get_content_info = _get_movie_count, + .get_content_info = _get_movie_info, .detail_update = EINA_FALSE, }, [E_DETAIL_GALLERY_PLACE] = { @@ -77,7 +79,7 @@ static struct _view_info view_info[E_DETAIL_MAX] = { .grid_item_y = GALLERY_EVENT_ITEM_Y, .get_grid_text = _grid_text_get, .get_grid_content = _grid_content_get, - .get_content_info = _get_gallery_count, + .get_content_info = _get_gallery_info, .detail_update = EINA_FALSE, }, [E_DETAIL_MUSIC_ALBUM] = { @@ -86,7 +88,7 @@ static struct _view_info view_info[E_DETAIL_MAX] = { .grid_item_y = MUSIC_SONG_ITEM_Y, .get_grid_text = _grid_text_get, .get_grid_content = _grid_content_get, - .get_content_info = _get_song_count, + .get_content_info = _get_song_info, .detail_update = EINA_FALSE, }, [E_DETAIL_MUSIC_ARTIST] = { @@ -95,7 +97,7 @@ static struct _view_info view_info[E_DETAIL_MAX] = { .grid_item_y = MUSIC_ALBUM_ITEM_Y, .get_grid_text = _album_text_get, .get_grid_content = _album_content_get, - .get_content_info = _get_album_count, + .get_content_info = _get_album_info, .selected = _album_selected, .detail_update = EINA_TRUE, }, @@ -105,7 +107,7 @@ static struct _view_info view_info[E_DETAIL_MAX] = { .grid_item_y = MUSIC_SONG_ITEM_Y, .get_grid_text = _grid_text_get, .get_grid_content = _grid_content_get, - .get_content_info = _get_song_count, + .get_content_info = _get_song_info, .detail_update = EINA_FALSE, }, }; @@ -114,6 +116,7 @@ struct _priv { Evas_Object *win; Evas_Object *base; Evas_Object *grid; + Evas_Object *thumbnail; Elm_Object_Item *focused_it; @@ -464,19 +467,54 @@ static Elm_Gengrid_Item_Class *_get_grid_item_class(struct _view_info *vinfo) return ic; } -static void _get_movie_count(char *str, int size, Eina_List *list) +static void _get_place_title(const char *title, char *str, int size) { - snprintf(str, size, "%d movies", eina_list_count(list)); + char buf[64], s[64]; + char *city, *country, *tmp; + + strcpy(buf, title); + + city = strtok_r(buf, "/", &tmp); + country = strtok_r(tmp, "", &tmp); + + snprintf(str, size, "%s", city); + + if (country) { + snprintf(s, sizeof(s), ", %s", country); + strcat(str, s); + } } -static void _get_gallery_count(char *str, int size, Eina_List *list) +static void _get_movie_info(struct _priv *priv, const char *title) +{ + char buf[64]; + + elm_object_part_text_set(priv->base, PART_DETAIL_TITLE, title); + + elm_object_signal_emit(priv->base, + SIG_HIDE_THUMBNAIL, SIG_SOURCE_SRC); + + snprintf(buf, sizeof(buf), "%d movies", + eina_list_count(priv->media_list)); + + elm_object_part_text_set(priv->base, PART_DETAIL_CONTENT_INFO, buf); +} + +static void _get_gallery_info(struct _priv *priv, const char *title) { Eina_List *l; app_media *am; app_media_info *mi; int count[E_FILE_MAX] = {0}; + char buf[64]; - EINA_LIST_FOREACH(list, l, am) { + _get_place_title(title, buf, sizeof(buf)); + elm_object_part_text_set(priv->base, PART_DETAIL_TITLE, buf); + + elm_object_signal_emit(priv->base, + SIG_HIDE_THUMBNAIL, SIG_SOURCE_SRC); + + EINA_LIST_FOREACH(priv->media_list, l, am) { mi = app_media_get_info(am); if (!mi) continue; @@ -484,53 +522,64 @@ static void _get_gallery_count(char *str, int size, Eina_List *list) count[mi->media_type]++; } - snprintf(str, size, "%d contents | %d photos, %d videos", - eina_list_count(list), + snprintf(buf, sizeof(buf), "%d contents | %d photos, %d videos", + eina_list_count(priv->media_list), count[E_FILE_PHOTO], count[E_FILE_VIDEO]); -} - -static void _get_song_count(char *str, int size, Eina_List *list) -{ - snprintf(str, size, "%d songs", eina_list_count(list)); -} -static void _get_album_count(char *str, int size, Eina_List *list) -{ - snprintf(str, size, "%d albums", eina_list_count(list)); + elm_object_part_text_set(priv->base, PART_DETAIL_CONTENT_INFO, buf); } -static void _get_place_title(const char *title, char *str, int size) +static void _get_song_info(struct _priv *priv, const char *title) { - char buf[64], s[64]; - char *city, *country, *tmp; + app_media *am; + app_media_info *mi; + char buf[64]; - strcpy(buf, title); + elm_object_part_text_set(priv->base, PART_DETAIL_TITLE, title); - city = strtok_r(buf, "/", &tmp); - country = strtok_r(tmp, "", &tmp); + if (priv->view_type == E_DETAIL_MUSIC_ALBUM) { + am = eina_list_nth(priv->media_list, 0); + mi = app_media_get_info(am); - snprintf(str, size, "%s", city); + if (mi && mi->thumbnail_path) { + elm_image_file_set(priv->thumbnail, + mi->thumbnail_path, NULL); + elm_image_aspect_fixed_set(priv->thumbnail, EINA_FALSE); - if (country) { - snprintf(s, sizeof(s), ", %s", country); - strcat(str, s); + elm_object_signal_emit(priv->base, SIG_SHOW_THUMBNAIL, + SIG_SOURCE_SRC); + } + } else { + elm_object_signal_emit(priv->base, SIG_HIDE_THUMBNAIL, + SIG_SOURCE_SRC); } + + snprintf(buf, sizeof(buf), "%d songs", + eina_list_count(priv->media_list)); + + elm_object_part_text_set(priv->base, PART_DETAIL_CONTENT_INFO, buf); } -static void _update_title_area(struct _priv *priv, const char *title) +static void _get_album_info(struct _priv *priv, const char *title) { char buf[64]; - if (priv->view_type == E_DETAIL_GALLERY_PLACE) { - _get_place_title(title, buf, sizeof(buf)); - elm_object_part_text_set(priv->base, PART_DETAIL_TITLE, buf); - } else - elm_object_part_text_set(priv->base, PART_DETAIL_TITLE, title); + elm_object_part_text_set(priv->base, PART_DETAIL_TITLE, title); + + elm_object_signal_emit(priv->base, + SIG_HIDE_THUMBNAIL, SIG_SOURCE_SRC); + + snprintf(buf, sizeof(buf), "%d albums", + eina_list_count(priv->media_list)); - priv->vinfo->get_content_info(buf, sizeof(buf), priv->media_list); elm_object_part_text_set(priv->base, PART_DETAIL_CONTENT_INFO, buf); } +static void _update_title_area(struct _priv *priv, const char *title) +{ + view_info[priv->view_type].get_content_info(priv, title); +} + static bool _update_thumbnail_area(struct _priv *priv) { Eina_List *l; @@ -563,6 +612,23 @@ static bool _update_thumbnail_area(struct _priv *priv) return true; } +static bool _draw_title_area(struct _priv *priv) +{ + Evas_Object *img; + + img = util_add_image(priv->base, NULL); + if (!img) { + _ERR("failed to add image"); + return false; + } + + elm_object_part_content_set(priv->base, PART_DETAIL_THUMBNAIL, img); + + priv->thumbnail = img; + + return true; +} + static bool _draw_thumbnail_area(struct _priv *priv) { Evas_Object *grid; @@ -583,6 +649,21 @@ static bool _draw_thumbnail_area(struct _priv *priv) return true; } +static bool _draw_items(struct _priv *priv) +{ + if (!_draw_title_area(priv)) { + _ERR("failed to draw title area"); + return false; + } + + if (!_draw_thumbnail_area(priv)) { + _ERR("failed to draw thumbnail area"); + return false; + } + + return true; +} + static Evas_Object *_create(Evas_Object *win, void *data) { struct _priv *priv; @@ -624,7 +705,7 @@ static Evas_Object *_create(Evas_Object *win, void *data) priv->base = base; priv->dmgr = dmgr; - if (!_draw_thumbnail_area(priv)) { + if (!_draw_items(priv)) { _ERR("failed to draw items"); datamgr_destroy(dmgr); free(priv); |