From 924da909486660b90c78758bf9861033138b9462 Mon Sep 17 00:00:00 2001 From: Minkyu Kang Date: Wed, 24 Jun 2015 18:28:40 +0900 Subject: [PATCH 01/16] add transition for buttons Change-Id: Id08e1e47af5449382ee46d34a1690211f72a4516 Signed-off-by: Minkyu Kang --- res/edc/widgets/button.edc | 71 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 53 insertions(+), 18 deletions(-) diff --git a/res/edc/widgets/button.edc b/res/edc/widgets/button.edc index f58ba5c..1c65ac3 100644 --- a/res/edc/widgets/button.edc +++ b/res/edc/widgets/button.edc @@ -16,6 +16,7 @@ #define STATE_PLAY 0 #define STATE_PAUSE 1 +#define TRANSITION_TIME 0.17 group { name: "elm/button/base/menu_btn"; @@ -109,7 +110,7 @@ group { target: "bg"; target: "elm.text"; target: "bottom_line"; - transition: LINEAR 0.17; + transition: LINEAR TRANSITION_TIME; } program { name: "unfocused"; @@ -119,7 +120,7 @@ group { target: "bg"; target: "elm.text"; target: "bottom_line"; - transition: LINEAR 0.17; + transition: LINEAR TRANSITION_TIME; } } } @@ -184,19 +185,19 @@ group { name: "focused"; signal: "elm,action,focus"; source: "elm"; - script { - set_state(PART:"bg", "selected", 0.0); - set_state(PART:"color", "selected", 0.0); - } + action: STATE_SET "selected" 0.0; + target: "bg"; + target: "color"; + transition: LINEAR TRANSITION_TIME; } program { name: "unfocused"; signal: "elm,action,unfocus"; source: "elm"; - script { - set_state(PART:"bg", "default", 0.0); - set_state(PART:"color", "default", 0.0); - } + action: STATE_SET "default" 0.0; + target: "bg"; + target: "color"; + transition: LINEAR TRANSITION_TIME; } } } @@ -317,6 +318,16 @@ group { } parts { part { + name: "color"; + description { + state: "default_pause" 0.0; + } + description { + state: "selected_pause" 0.0; + color: COLOR_BTN_FOCUS; + } + } + part { name: "bg"; scale: 1; description { @@ -414,11 +425,9 @@ group { state = get_int(cur_state); if (state == STATE_PLAY) - set_state(PART:"bg", "selected", 0.0); + run_program(PROGRAM:"focused,play"); else - set_state(PART:"bg", "selected_pause", 0.0); - - set_state(PART:"color", "selected", 0.0); + run_program(PROGRAM:"focused,pause"); } } program { @@ -430,12 +439,38 @@ group { state = get_int(cur_state); if (state == STATE_PLAY) - set_state(PART:"bg", "default", 0.0); + run_program(PROGRAM:"unfocused,play"); else - set_state(PART:"bg", "default_pause", 0.0); - - set_state(PART:"color", "default", 0.0); + run_program(PROGRAM:"unfocused,pause"); } } + program { + name: "focused,play"; + action: STATE_SET "selected" 0.0; + target: "bg"; + target: "color"; + transition: LINEAR TRANSITION_TIME; + } + program { + name: "focused,pause"; + action: STATE_SET "selected_pause" 0.0; + target: "bg"; + target: "color"; + transition: LINEAR TRANSITION_TIME; + } + program { + name: "unfocused,play"; + action: STATE_SET "default" 0.0; + target: "bg"; + target: "color"; + transition: LINEAR TRANSITION_TIME; + } + program { + name: "unfocused,pause"; + action: STATE_SET "default_pause" 0.0; + target: "bg"; + target: "color"; + transition: LINEAR TRANSITION_TIME; + } } } -- 2.7.4 From 125beccbf516484393bd186706890c785b2eb144 Mon Sep 17 00:00:00 2001 From: Minkyu Kang Date: Wed, 24 Jun 2015 21:18:27 +0900 Subject: [PATCH 02/16] viewer: add prev/next button for photo viewer Change-Id: Ia198f3df32f0dfadbc32617b0f2b4368a7025468 Signed-off-by: Minkyu Kang --- res/edc/widgets/button.edc | 68 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/res/edc/widgets/button.edc b/res/edc/widgets/button.edc index 1c65ac3..92b6046 100644 --- a/res/edc/widgets/button.edc +++ b/res/edc/widgets/button.edc @@ -305,6 +305,74 @@ group { } group { + name: "elm/button/base/viewer_btn_prev_photo"; + inherit: "elm/button/base/viewer_btn_prev"; + images { + image: IMAGE_VIEWER_PHOTO_PREV_NORMAL COMP; + image: IMAGE_VIEWER_PHOTO_PREV_FOCUS COMP; + } + parts { + part { + name: "bg"; + scale: 1; + description { + state: "default" 0.0; + image { + normal: IMAGE_VIEWER_PHOTO_PREV_NORMAL; + } + } + description { + state: "selected" 0.0; + inherit: "default" 0.0; + image { + normal: IMAGE_VIEWER_PHOTO_PREV_FOCUS; + } + } + } + } + programs { + program { + name: "emit,signal"; + action: SIGNAL_EMIT SIG_BTN_CALLBACK "prev"; + } + } +} + +group { + name: "elm/button/base/viewer_btn_next_photo"; + inherit: "elm/button/base/viewer_btn_prev"; + images { + image: IMAGE_VIEWER_PHOTO_NEXT_NORMAL COMP; + image: IMAGE_VIEWER_PHOTO_NEXT_FOCUS COMP; + } + parts { + part { + name: "bg"; + scale: 1; + description { + state: "default" 0.0; + image { + normal: IMAGE_VIEWER_PHOTO_NEXT_NORMAL; + } + } + description { + state: "selected" 0.0; + inherit: "default" 0.0; + image { + normal: IMAGE_VIEWER_PHOTO_NEXT_FOCUS; + } + } + } + } + programs { + program { + name: "emit,signal"; + action: SIGNAL_EMIT SIG_BTN_CALLBACK "next"; + } + } +} + +group { name: "elm/button/base/viewer_btn_play"; inherit: "elm/button/base/viewer_btn_prev"; images { -- 2.7.4 From c797c6a1d5df48baf0692feff3dcdb3c2de22190 Mon Sep 17 00:00:00 2001 From: Minkyu Kang Date: Thu, 25 Jun 2015 13:27:32 +0900 Subject: [PATCH 03/16] add defines for images Change-Id: I4c0687865e4432310d6cbdce190d643a805f6c31 Signed-off-by: Minkyu Kang --- include/view/viewer.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/view/viewer.h b/include/view/viewer.h index 685e1f7..f50bc40 100644 --- a/include/view/viewer.h +++ b/include/view/viewer.h @@ -52,5 +52,9 @@ #define IMAGE_VIEWER_FF_NORMAL "btn_view_contr_forward_nor.png" #define IMAGE_VIEWER_NEXT_FOCUS "btn_view_contr_next_foc.png" #define IMAGE_VIEWER_NEXT_NORMAL "btn_view_contr_next_nor.png" +#define IMAGE_VIEWER_PHOTO_PREV_FOCUS "btn_view_slide_previous_foc.png" +#define IMAGE_VIEWER_PHOTO_PREV_NORMAL "btn_view_slide_previous_nor.png" +#define IMAGE_VIEWER_PHOTO_NEXT_FOCUS "btn_view_slide_next_foc.png" +#define IMAGE_VIEWER_PHOTO_NEXT_NORMAL "btn_view_slide_next_nor.png" #endif /* __AIR_MEDIAHUB_VIEW_VIEWER_H__ */ -- 2.7.4 From 2ed28c4a6d51095df454ae2ef7f9be1264d5e816 Mon Sep 17 00:00:00 2001 From: Jehun Lim Date: Thu, 25 Jun 2015 10:59:09 +0900 Subject: [PATCH 04/16] data: add mediadata for creating media list Change-Id: I65a5626abcbdbe5d62c93367cbbf51bbfbb9ce65 Signed-off-by: Jehun Lim --- CMakeLists.txt | 1 + include/data/mediadata.h | 40 ++++++++ src/data/mediadata.c | 246 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 287 insertions(+) create mode 100644 include/data/mediadata.h create mode 100644 src/data/mediadata.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 27ecebe..15adc8e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,6 +55,7 @@ src/layout/gallery.c src/layout/music.c src/util/gridmgr.c src/util/controller.c +src/data/mediadata.c ) SET(TARGET_EDJ "${PROJECT_NAME}.edj") diff --git a/include/data/mediadata.h b/include/data/mediadata.h new file mode 100644 index 0000000..59431b4 --- /dev/null +++ b/include/data/mediadata.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _AIR_MEDIAHUB_MEDIADATA_H__ +#define _AIR_MEDIAHUB_MEDIADATA_H__ + +#include + +struct mediadata; + +enum source_type { + E_SOURCE_INTERNAL = 0, + E_SOURCE_EXTERNAL, + E_SOURCE_ALL, + E_SOURCE_MAX +}; + +struct folderdata { + char *name; + time_t modified_time; + Eina_List *list; +}; + +struct mediadata *mediadata_create(const char *media_type, int source_type); +void mediadata_destroy(struct mediadata *md); + +#endif /* _AIR_MEDIAHUB_MEDIADATA_H__ */ diff --git a/src/data/mediadata.c b/src/data/mediadata.c new file mode 100644 index 0000000..ce8858c --- /dev/null +++ b/src/data/mediadata.c @@ -0,0 +1,246 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include + +#include "data/mediadata.h" + +enum _filter_type { + E_FILTER_FOLDER = 0, + E_FILTER_MEDIA +}; + +struct mediadata { + Eina_List *list; +}; + +struct _data { + const char *media_type; + int source_type; + Eina_List *item_list; + Eina_List *folder_list; +}; + +static bool _create_filter(struct _data *data, filter_h *filter, int type) +{ + filter_h tmp_filter; + int ret; + char buf[1024]; + + ret = media_filter_create(&tmp_filter); + if (ret != MEDIA_CONTENT_ERROR_NONE) { + _ERR("failed to create media filter"); + return false; + } + + snprintf(buf, sizeof(buf), "%s", data->media_type); + + if (type == E_FILTER_FOLDER && data->source_type != E_SOURCE_ALL) { + char s[64]; + + snprintf(s, sizeof(s), " AND MEDIA_STORAGE_TYPE=%d", + data->source_type); + strcat(buf, s); + } + + media_filter_set_condition(tmp_filter, buf, + MEDIA_CONTENT_COLLATE_DEFAULT); + media_filter_set_order(tmp_filter, MEDIA_CONTENT_ORDER_DESC, + MEDIA_MODIFIED_TIME, MEDIA_CONTENT_COLLATE_NOCASE); + + *filter = tmp_filter; + + return true; +} + +static void _destroy_medialist(Eina_List *list) +{ + struct folderdata *fd; + app_media *am; + + EINA_LIST_FREE(list, fd) { + free(fd->name); + EINA_LIST_FREE(fd->list, am) + app_media_destroy(am); + fd->list = NULL; + } +} + +static bool _get_each_media_info(media_info_h media_h, void *dt) +{ + app_media *am; + struct _data *data; + + if (!dt) + return false; + + data = dt; + + am = app_media_create(media_h); + if (!am) { + _ERR("failed to create app media"); + return false; + } + + data->item_list = eina_list_append(data->item_list, am); + + return true; +} + +static bool _get_each_folder_info(media_folder_h folder, void *dt) +{ + filter_h filter; + struct _data *data; + struct folderdata *fd; + int ret; + char *uuid; + + if (!dt) + return false; + + data = dt; + + fd = calloc(1, sizeof(*fd)); + if (!fd) { + _ERR("failed to create folderdata"); + return false; + } + + if (media_folder_get_name(folder, &(fd->name)) + != MEDIA_CONTENT_ERROR_NONE) { + _ERR("Media folder id Fetch error"); + goto err; + } + + if (media_folder_get_modified_time(folder, &(fd->modified_time)) + != MEDIA_CONTENT_ERROR_NONE) { + _ERR("Media folder modified time Fetch error"); + goto err; + } + + if (media_folder_get_folder_id(folder, &uuid) + != MEDIA_CONTENT_ERROR_NONE) { + _ERR("failed to fetch media folder id"); + goto err; + } + + if (!_create_filter(data, &filter, E_FILTER_MEDIA)) { + _ERR("failed to create filter"); + goto err; + } + + ret = media_folder_foreach_media_from_db(uuid, filter, + _get_each_media_info, data); + if (ret != MEDIA_CONTENT_ERROR_NONE) { + _ERR("failed to get media info"); + goto err; + } + + fd->list = data->item_list; + data->item_list = NULL; + + data->folder_list = eina_list_append(data->folder_list, fd); + + media_filter_destroy(filter); + free(uuid); + + return true; + +err: + media_filter_destroy(filter); + free(uuid); + _destroy_medialist(data->folder_list); + return false; +} + +static bool _get_medialist(struct _data *data) +{ + filter_h filter; + int ret; + + if (!_create_filter(data, &filter, E_FILTER_FOLDER)) { + _ERR("failed to create filter"); + return false; + } + + ret = media_folder_foreach_folder_from_db(filter, + _get_each_folder_info, data); + if (ret != MEDIA_CONTENT_ERROR_NONE) { + _ERR("failed to get folder info"); + media_filter_destroy(filter); + return false; + } + + media_filter_destroy(filter); + + return true; +} + +struct mediadata *mediadata_create(const char *media_type, int source_type) +{ + struct mediadata *md; + struct _data data; + int ret; + + if (!media_type || source_type < 0 || source_type >= E_SOURCE_MAX) { + _ERR("invalid argument"); + return NULL; + } + + md = calloc(1, sizeof(*md)); + if (!md) { + _ERR("failed to create mediadata"); + return NULL; + } + + ret = media_content_connect(); + if (ret != MEDIA_CONTENT_ERROR_NONE) { + _ERR("failed to connect to media content"); + free(md); + return NULL; + } + + data.media_type = media_type; + data.source_type = source_type; + data.item_list = NULL; + data.folder_list = NULL; + + if (!_get_medialist(&data)) { + _ERR("failed to get medialist"); + free(md); + media_content_disconnect(); + return NULL; + } + + media_content_disconnect(); + + md->list = data.folder_list; + + return md; +} + +void mediadata_destroy(struct mediadata *md) +{ + if (!md) { + _ERR("failed to get mediadata"); + return; + } + + _destroy_medialist(md->list); +} -- 2.7.4 From 76620eb9ec0edad160228b74ea0e96dd00c082e6 Mon Sep 17 00:00:00 2001 From: Minkyu Kang Date: Thu, 25 Jun 2015 17:58:31 +0900 Subject: [PATCH 05/16] viewer: add movie/video/photo viewer Initiall support for UI of viewers. This patch is including test codes for making media list. Change-Id: I896f5a3463643f38bdb5644f806b070442b1b402 Signed-off-by: Minkyu Kang --- CMakeLists.txt | 1 + include/view/viewer.h | 3 +- res/edc/view/viewer.edc | 10 +- res/{edc => }/images/ic_title_favorite.png | Bin src/view/viewer.c | 382 +++++++++++++++++++++++++++++ 5 files changed, 387 insertions(+), 9 deletions(-) rename res/{edc => }/images/ic_title_favorite.png (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 15adc8e..5f67dbe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -83,4 +83,5 @@ CONFIGURE_FILE(${PACKAGE_NAME}.xml.in ${PACKAGE_NAME}.xml) INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${BINDIR}) INSTALL(FILES ${PACKAGE_NAME}.xml DESTINATION ${PACKAGEDIR}) +INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/res/images DESTINATION ${RESDIR}) ADD_SUBDIRECTORY(res/edc) diff --git a/include/view/viewer.h b/include/view/viewer.h index f50bc40..c9e5f32 100644 --- a/include/view/viewer.h +++ b/include/view/viewer.h @@ -30,6 +30,7 @@ #define PART_VIEWER_PAGE "part.viewer_page" #define PART_VIEWER_PROGRESS "part.viewer_progress" #define PART_VIEWER_TOTAL "part.viewer_total" +#define PART_VIEWER_FAVORITE "part.viewer_favorite" /* signal */ #define SIG_SET_PLAY "set,play,icon" @@ -38,7 +39,7 @@ #define SIG_BTN_CALLBACK "btn,callback" /* images */ -#define IMAGE_VIEWER_FAVORITE "ic_title_favorite.png" +#define IMAGE_VIEWER_FAVORITE IMAGEDIR"/ic_title_favorite.png" #define IMAGE_VIEWER_PREV_FOCUS "btn_view_contr_previous_foc.png" #define IMAGE_VIEWER_PREV_NORMAL "btn_view_contr_previous_nor.png" diff --git a/res/edc/view/viewer.edc b/res/edc/view/viewer.edc index 84cb95a..e3c6573 100644 --- a/res/edc/view/viewer.edc +++ b/res/edc/view/viewer.edc @@ -16,9 +16,6 @@ group { name: GRP_VIEWER_VIEW; - images { - image: IMAGE_VIEWER_FAVORITE COMP; - } parts { part { name: "bg"; @@ -187,7 +184,8 @@ group { } } part { - name: "favorite_icon"; + name: PART_VIEWER_FAVORITE; + type: SWALLOW; scale: 1; description { state: "default" 0.0; @@ -200,10 +198,6 @@ group { to: "padding_right"; relative: 0.0 0.5; } - /* It will be modified to SWALLOW area */ - image { - normal: IMAGE_VIEWER_FAVORITE; - } fixed: 1 1; align: 1.0 0.5; } diff --git a/res/edc/images/ic_title_favorite.png b/res/images/ic_title_favorite.png similarity index 100% rename from res/edc/images/ic_title_favorite.png rename to res/images/ic_title_favorite.png diff --git a/src/view/viewer.c b/src/view/viewer.c index 656ae4d..4202bac 100644 --- a/src/view/viewer.c +++ b/src/view/viewer.c @@ -18,18 +18,377 @@ #include #include #include +#include +#include +#include #include "define.h" +#include "util/controller.h" + +#define STYLE_VIEWER_BTN "viewer_btn" +#define PART_VIEWER_BTN "control_btn" + +#define VIDEO_COPYRIGHT "Unknown" + +enum { + VIEWER_MOVIE, + VIEWER_PHOTO, + VIEWER_VIDEO, + VIEWER_MAX +}; + +struct _viewer { + struct controller *ctl[VIEWER_MAX]; + int cur; +}; + +struct _playlist { + Eina_List *list; + int cur; +}; struct _priv { Evas_Object *win; Evas_Object *base; + + struct _viewer viewer; + struct _playlist playlist; +}; + +struct _btn_info { + const char *name; + int loc; +}; + +static struct _btn_info btn_movie[] = { + { + .name = "prev", + .loc = 0, + }, + { + .name = "rew", + .loc = 1, + }, + { + .name = "play", + .loc = 2, + }, + { + .name = "ff", + .loc = 3, + }, + { + .name = "next", + .loc = 4, + }, +}; + +static struct _btn_info btn_photo[] = { + { + .name = "prev_photo", + .loc = 0, + }, + { + .name = "next_photo", + .loc = 4, + }, +}; + +static struct _btn_info btn_video[] = { + { + .name = "prev", + .loc = 0, + }, + { + .name = "rew", + .loc = 1, + }, + { + .name = "play", + .loc = 2, + }, + { + .name = "ff", + .loc = 3, + }, + { + .name = "next", + .loc = 4, + }, +}; + +struct _viewer_info { + struct _btn_info *btns; + int btn_count; + int focus_loc; +}; + +static struct _viewer_info viewer_info[] = { + { + .btns = btn_movie, + .btn_count = 5, + .focus_loc = 2, + }, + { + .btns = btn_photo, + .btn_count = 2, + .focus_loc = 1, + }, + { + .btns = btn_video, + .btn_count = 5, + .focus_loc = 4, + }, }; +/* FIXME: test function */ +static bool _media(media_info_h media_h, void *dt) +{ + struct _priv *priv; + app_media *am; + + priv = dt; + + am = app_media_create(media_h); + + priv->playlist.list = eina_list_append(priv->playlist.list, am); + + return true; +} + +static void _media_test(struct _priv *priv, int mode) +{ + char *path = "/home/owner/content/Videos/Xmen-Days_of_Future_Past.mp4"; + filter_h filter; + char buf[1024]; + int r; + + r = media_filter_create(&filter); + if (r != MEDIA_CONTENT_ERROR_NONE) { + _ERR("Media Filter Creation Failed"); + return; + } + + if (mode) + snprintf(buf, sizeof(buf), "MEDIA_PATH = \"%s\"", path); + else + snprintf(buf, sizeof(buf), "MEDIA_TYPE=0 OR MEDIA_TYPE=1"); + + r = media_filter_set_condition(filter, buf, + MEDIA_CONTENT_COLLATE_DEFAULT); + if (r != MEDIA_CONTENT_ERROR_NONE) { + _ERR("Fail to set filter condition"); + media_filter_destroy(filter); + return; + } + + media_content_connect(); + + r = media_info_foreach_media_from_db(filter, _media, priv); + if (r != MEDIA_CONTENT_ERROR_NONE) { + _ERR("MEDIA CONTENT ERROR: %d", r); + media_filter_destroy(filter); + media_content_disconnect(); + return; + } + + media_filter_destroy(filter); + media_content_disconnect(); +} +/* FIXME: test function end */ + +/* + * NOTE: Workaround + * we assumed that if video content have the copyright then it's a movie. + */ +static inline bool _check_movie_type(app_media_info *mi) +{ + return strcmp(mi->video->copyright, VIDEO_COPYRIGHT); +} + +static void _get_timestr(char *str, int size, unsigned int ms) +{ + int sec; + + sec = ms / 1000; + + snprintf(str, size, "%02d:%02d:%02d", + sec / 3600, (sec % 3600) / 60, sec % 60); +} + +static void _draw_title_bar(struct _priv *priv, int id, app_media_info *mi) +{ + char buf[32] = {0,}; + struct tm tm; + + if (id == VIEWER_MOVIE) { + elm_object_part_text_set(priv->base, + PART_VIEWER_TITLE, mi->title); + } else { + localtime_r(&mi->modified_time, &tm); + strftime(buf, sizeof(buf), "%a, %d %b", &tm); + + elm_object_part_text_set(priv->base, PART_VIEWER_DATE, buf); + + snprintf(buf, sizeof(buf), "%d / %d", priv->playlist.cur + 1, + eina_list_count(priv->playlist.list)); + elm_object_part_text_set(priv->base, PART_VIEWER_PAGE, buf); + } +} + +static void _draw_time_info(struct _priv *priv, int id, app_media_info *mi) +{ + char progress[32] = {0,}; + char duration[32] = {0,}; + char total[32] = {0,}; + + if (id != VIEWER_PHOTO) { + _get_timestr(progress, sizeof(progress), mi->video->position); + _get_timestr(duration, sizeof(duration), mi->video->duration); + snprintf(total, sizeof(total), "/ %s", duration); + } + + elm_object_part_text_set(priv->base, PART_VIEWER_PROGRESS, progress); + elm_object_part_text_set(priv->base, PART_VIEWER_TOTAL, total); +} + +static void _draw_favorite_icon(struct _priv *priv, int id, app_media_info *mi) +{ + Evas_Object *img; + + if (!mi->favorite) + return; + + img = elm_image_add(priv->base); + if (!img) + return; + + elm_image_file_set(img, IMAGE_VIEWER_FAVORITE, NULL); + + evas_object_show(img); + elm_object_part_content_set(priv->base, PART_VIEWER_FAVORITE, img); +} + +static bool _viewer_show(struct _priv *priv, int cur) +{ + struct _viewer_info *info; + struct controller *ctl; + int id; + app_media *am; + app_media_info *mi; + + am = eina_list_nth(priv->playlist.list, cur); + if (!am) { + _ERR("failed to get app_media"); + return false; + } + + priv->playlist.cur = cur; + + mi = app_media_get_info(am); + if (!mi) { + _ERR("failed to getting media info"); + return false; + } + + switch (mi->media_type) { + case MEDIA_CONTENT_TYPE_IMAGE: + id = VIEWER_PHOTO; + break; + case MEDIA_CONTENT_TYPE_VIDEO: + if (_check_movie_type(mi)) + id = VIEWER_MOVIE; + else + id = VIEWER_VIDEO; + break; + default: + return false; + } + + info = &viewer_info[id]; + ctl = priv->viewer.ctl[id]; + priv->viewer.cur = id; + + ctl->ops->show(ctl->handle); + ctl->ops->focus(ctl->handle, info->focus_loc, true); + + _draw_title_bar(priv, id, mi); + _draw_time_info(priv, id, mi); + _draw_favorite_icon(priv, id, mi); + + return true; +} + +static void _viewer_hide(struct _priv *priv) +{ + struct controller *ctl; + + ctl = priv->viewer.ctl[priv->viewer.cur]; + ctl->ops->hide(ctl->handle); + + elm_object_part_content_unset(priv->base, PART_VIEWER_FAVORITE); +} + +static bool _viewer_add(struct _priv *priv, int id) +{ + struct _viewer_info *info; + struct controller *ctl; + int i; + + info = &viewer_info[id]; + + ctl = controller_create(priv->base); + if (!ctl) { + _ERR("failed to create controller"); + return false; + } + + for (i = 0; i < info->btn_count; i++) { + ctl->ops->add_control(ctl->handle, + info->btns[i].name, info->btns[i].loc, + STYLE_VIEWER_BTN, PART_VIEWER_BTN); + } + + priv->viewer.ctl[id] = ctl; + + return true; +} + +static void _viewer_delete(struct _priv *priv) +{ + struct controller *ctl; + int i; + + for (i = 0; i < VIEWER_MAX; i++) { + ctl = priv->viewer.ctl[i]; + if (ctl) + controller_destroy(ctl->handle); + } +} + +static bool _ui_init(struct _priv *priv) +{ + bool r; + int i; + + for (i = 0; i < VIEWER_MAX; i++) { + r = _viewer_add(priv, i); + if (!r) + goto err; + } + + return true; + +err: + _viewer_delete(priv); + return false; +} + static Evas_Object *_create(Evas_Object *win, void *data) { struct _priv *priv; Evas_Object *base; + bool r; if (!win) { _ERR("failed to get win object"); @@ -58,6 +417,18 @@ static Evas_Object *_create(Evas_Object *win, void *data) priv->win = win; priv->base = base; + priv->playlist.list = NULL; + priv->playlist.cur = 0; + + r = _ui_init(priv); + if (!r) { + _ERR("failed to init UI"); + return NULL; + } + + /* FIXME: test code */ + _media_test(priv, 0); + viewmgr_set_view_data(VIEW_VIEWER, priv); return base; @@ -74,6 +445,9 @@ static void _show(void *view_data) priv = view_data; + /* FIXME: test code */ + _viewer_show(priv, 1); + evas_object_show(priv->base); } @@ -88,12 +462,15 @@ static void _hide(void *view_data) priv = view_data; + _viewer_hide(priv); + evas_object_hide(priv->base); } static void _destroy(void *view_data) { struct _priv *priv; + app_media *am; if (!view_data) { _ERR("failed to get view data"); @@ -102,6 +479,11 @@ static void _destroy(void *view_data) priv = view_data; + _viewer_delete(priv); + + EINA_LIST_FREE(priv->playlist.list, am) + app_media_destroy(am); + evas_object_del(priv->base); free(priv); -- 2.7.4 From 18d4b9607e55df52c7278c741ac53923d59a7f33 Mon Sep 17 00:00:00 2001 From: Minkyu Kang Date: Fri, 26 Jun 2015 19:55:15 +0900 Subject: [PATCH 06/16] viewer: add callback functions Change-Id: I97773d360e04cd352b4995f8cf07f04b6fe32304 Signed-off-by: Minkyu Kang --- include/view/viewer.h | 9 +++ res/edc/widgets/button.edc | 14 ++--- src/util/controller.c | 2 +- src/view/viewer.c | 134 ++++++++++++++++++++++++++++++++++++++++----- 4 files changed, 136 insertions(+), 23 deletions(-) diff --git a/include/view/viewer.h b/include/view/viewer.h index c9e5f32..33cdc14 100644 --- a/include/view/viewer.h +++ b/include/view/viewer.h @@ -38,6 +38,15 @@ #define SIG_BTN_CLICKED "btn,clicked" #define SIG_BTN_CALLBACK "btn,callback" +/* source */ +#define SRC_BTN_PREV "prev" +#define SRC_BTN_REW "rew" +#define SRC_BTN_PLAY "play" +#define SRC_BTN_FF "ff" +#define SRC_BTN_NEXT "next" +#define SRC_BTN_PHOTO_PREV "prev_photo" +#define SRC_BTN_PHOTO_NEXT "next_photo" + /* images */ #define IMAGE_VIEWER_FAVORITE IMAGEDIR"/ic_title_favorite.png" diff --git a/res/edc/widgets/button.edc b/res/edc/widgets/button.edc index 92b6046..b049524 100644 --- a/res/edc/widgets/button.edc +++ b/res/edc/widgets/button.edc @@ -179,7 +179,7 @@ group { } program { name: "emit,signal"; - action: SIGNAL_EMIT SIG_BTN_CALLBACK "prev"; + action: SIGNAL_EMIT SIG_BTN_CALLBACK SRC_BTN_PREV; } program { name: "focused"; @@ -231,7 +231,7 @@ group { programs { program { name: "emit,signal"; - action: SIGNAL_EMIT SIG_BTN_CALLBACK "rew"; + action: SIGNAL_EMIT SIG_BTN_CALLBACK SRC_BTN_REW; } } } @@ -265,7 +265,7 @@ group { programs { program { name: "emit,signal"; - action: SIGNAL_EMIT SIG_BTN_CALLBACK "ff"; + action: SIGNAL_EMIT SIG_BTN_CALLBACK SRC_BTN_FF; } } } @@ -299,7 +299,7 @@ group { programs { program { name: "emit,signal"; - action: SIGNAL_EMIT SIG_BTN_CALLBACK "next"; + action: SIGNAL_EMIT SIG_BTN_CALLBACK SRC_BTN_NEXT; } } } @@ -333,7 +333,7 @@ group { programs { program { name: "emit,signal"; - action: SIGNAL_EMIT SIG_BTN_CALLBACK "prev"; + action: SIGNAL_EMIT SIG_BTN_CALLBACK SRC_BTN_PHOTO_PREV; } } } @@ -367,7 +367,7 @@ group { programs { program { name: "emit,signal"; - action: SIGNAL_EMIT SIG_BTN_CALLBACK "next"; + action: SIGNAL_EMIT SIG_BTN_CALLBACK SRC_BTN_PHOTO_NEXT; } } } @@ -482,7 +482,7 @@ group { } program { name: "emit,signal"; - action: SIGNAL_EMIT SIG_BTN_CALLBACK "play"; + action: SIGNAL_EMIT SIG_BTN_CALLBACK SRC_BTN_PLAY; } program { name: "focused"; diff --git a/src/util/controller.c b/src/util/controller.c index f4b3799..1be6e8c 100644 --- a/src/util/controller.c +++ b/src/util/controller.c @@ -80,7 +80,6 @@ static Evas_Object *_add_btn(Evas_Object *base, const char *style) return NULL; elm_object_style_set(btn, style); - evas_object_show(btn); return btn; } @@ -218,6 +217,7 @@ static void _hide(void *handle) continue; evas_object_freeze_events_set(ctl->obj, EINA_TRUE); + elm_object_focus_set(ctl->obj, false); elm_object_focus_allow_set(ctl->obj, EINA_FALSE); evas_object_hide(ctl->obj); diff --git a/src/view/viewer.c b/src/view/viewer.c index 4202bac..c306ab6 100644 --- a/src/view/viewer.c +++ b/src/view/viewer.c @@ -37,6 +37,12 @@ enum { VIEWER_MAX }; +enum { + DIR_NONE, + DIR_PREV, + DIR_NEXT +}; + struct _viewer { struct controller *ctl[VIEWER_MAX]; int cur; @@ -62,57 +68,57 @@ struct _btn_info { static struct _btn_info btn_movie[] = { { - .name = "prev", + .name = SRC_BTN_PREV, .loc = 0, }, { - .name = "rew", + .name = SRC_BTN_REW, .loc = 1, }, { - .name = "play", + .name = SRC_BTN_PLAY, .loc = 2, }, { - .name = "ff", + .name = SRC_BTN_FF, .loc = 3, }, { - .name = "next", + .name = SRC_BTN_NEXT, .loc = 4, }, }; static struct _btn_info btn_photo[] = { { - .name = "prev_photo", + .name = SRC_BTN_PHOTO_PREV, .loc = 0, }, { - .name = "next_photo", + .name = SRC_BTN_PHOTO_NEXT, .loc = 4, }, }; static struct _btn_info btn_video[] = { { - .name = "prev", + .name = SRC_BTN_PREV, .loc = 0, }, { - .name = "rew", + .name = SRC_BTN_REW, .loc = 1, }, { - .name = "play", + .name = SRC_BTN_PLAY, .loc = 2, }, { - .name = "ff", + .name = SRC_BTN_FF, .loc = 3, }, { - .name = "next", + .name = SRC_BTN_NEXT, .loc = 4, }, }; @@ -121,23 +127,31 @@ struct _viewer_info { struct _btn_info *btns; int btn_count; int focus_loc; + void (*callback)(void *, const char *); }; +static void _callback_movie(void *data, const char *ev); +static void _callback_photo(void *data, const char *ev); +static void _callback_video(void *data, const char *ev); + static struct _viewer_info viewer_info[] = { { .btns = btn_movie, .btn_count = 5, .focus_loc = 2, + .callback = _callback_movie, }, { .btns = btn_photo, .btn_count = 2, .focus_loc = 1, + .callback = _callback_photo, }, { .btns = btn_video, .btn_count = 5, .focus_loc = 4, + .callback = _callback_video, }, }; @@ -269,11 +283,12 @@ static void _draw_favorite_icon(struct _priv *priv, int id, app_media_info *mi) elm_object_part_content_set(priv->base, PART_VIEWER_FAVORITE, img); } -static bool _viewer_show(struct _priv *priv, int cur) +static bool _viewer_show(struct _priv *priv, int cur, int foc) { struct _viewer_info *info; struct controller *ctl; int id; + int loc; app_media *am; app_media_info *mi; @@ -310,7 +325,20 @@ static bool _viewer_show(struct _priv *priv, int cur) priv->viewer.cur = id; ctl->ops->show(ctl->handle); - ctl->ops->focus(ctl->handle, info->focus_loc, true); + + switch (foc) { + case DIR_PREV: + loc = 0; + break; + case DIR_NEXT: + loc = info->btn_count - 1; + break; + case DIR_NONE: + default: + loc = info->focus_loc; + break; + } + ctl->ops->focus(ctl->handle, loc, true); _draw_title_bar(priv, id, mi); _draw_time_info(priv, id, mi); @@ -349,6 +377,8 @@ static bool _viewer_add(struct _priv *priv, int id) STYLE_VIEWER_BTN, PART_VIEWER_BTN); } + ctl->ops->add_callback(ctl->handle, info->callback, priv); + priv->viewer.ctl[id] = ctl; return true; @@ -366,6 +396,44 @@ static void _viewer_delete(struct _priv *priv) } } +static bool _viewer_prev(struct _priv *priv) +{ + int total; + bool r; + + _viewer_hide(priv); + + total = eina_list_count(priv->playlist.list); + + if (priv->playlist.cur == 0) + priv->playlist.cur = total - 1; + else + priv->playlist.cur--; + + r = _viewer_show(priv, priv->playlist.cur, DIR_PREV); + + return r; +} + +static bool _viewer_next(struct _priv *priv) +{ + int total; + bool r; + + _viewer_hide(priv); + + total = eina_list_count(priv->playlist.list); + + if (priv->playlist.cur == total - 1) + priv->playlist.cur = 0; + else + priv->playlist.cur++; + + r = _viewer_show(priv, priv->playlist.cur, DIR_NEXT); + + return r; +} + static bool _ui_init(struct _priv *priv) { bool r; @@ -384,6 +452,42 @@ err: return false; } +static void _callback_movie(void *data, const char *ev) +{ +} + +static void _callback_photo(void *data, const char *ev) +{ + struct _priv *priv; + + if (!data || !ev) + return; + + priv = data; + + if (!strcmp(ev, SRC_BTN_PHOTO_PREV)) { + _viewer_prev(priv); + } else if (!strcmp(ev, SRC_BTN_PHOTO_NEXT)) { + _viewer_next(priv); + } +} + +static void _callback_video(void *data, const char *ev) +{ + struct _priv *priv; + + if (!data || !ev) + return; + + priv = data; + + if (!strcmp(ev, SRC_BTN_PREV)) { + _viewer_prev(priv); + } else if (!strcmp(ev, SRC_BTN_NEXT)) { + _viewer_next(priv); + } +} + static Evas_Object *_create(Evas_Object *win, void *data) { struct _priv *priv; @@ -446,7 +550,7 @@ static void _show(void *view_data) priv = view_data; /* FIXME: test code */ - _viewer_show(priv, 1); + _viewer_show(priv, priv->playlist.cur, DIR_NONE); evas_object_show(priv->base); } -- 2.7.4 From 6b3081f58f8d2644118929a8ef16b4b167e43578 Mon Sep 17 00:00:00 2001 From: Minkyu Kang Date: Fri, 26 Jun 2015 20:04:33 +0900 Subject: [PATCH 07/16] viewer: weekday string to upper case Change-Id: I679495fcd6d7cb23ed2bd5309a80d1b78aeea0f4 Signed-off-by: Minkyu Kang --- src/view/viewer.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/view/viewer.c b/src/view/viewer.c index c306ab6..fedf010 100644 --- a/src/view/viewer.c +++ b/src/view/viewer.c @@ -220,7 +220,7 @@ static inline bool _check_movie_type(app_media_info *mi) return strcmp(mi->video->copyright, VIDEO_COPYRIGHT); } -static void _get_timestr(char *str, int size, unsigned int ms) +static void _time_string(char *str, int size, unsigned int ms) { int sec; @@ -230,9 +230,19 @@ static void _get_timestr(char *str, int size, unsigned int ms) sec / 3600, (sec % 3600) / 60, sec % 60); } +static void _up_string(char *str) +{ + while (*str) { + *str = toupper(*str); + str++; + } +} + static void _draw_title_bar(struct _priv *priv, int id, app_media_info *mi) { char buf[32] = {0,}; + char day[32] = {0,}; + char date[32] = {0,}; struct tm tm; if (id == VIEWER_MOVIE) { @@ -240,7 +250,12 @@ static void _draw_title_bar(struct _priv *priv, int id, app_media_info *mi) PART_VIEWER_TITLE, mi->title); } else { localtime_r(&mi->modified_time, &tm); - strftime(buf, sizeof(buf), "%a, %d %b", &tm); + + strftime(date, sizeof(date), "%d %b", &tm); + strftime(day, sizeof(day), "%a", &tm); + _up_string(day); + + snprintf(buf, sizeof(buf), "%s, %s", day, date); elm_object_part_text_set(priv->base, PART_VIEWER_DATE, buf); @@ -257,8 +272,8 @@ static void _draw_time_info(struct _priv *priv, int id, app_media_info *mi) char total[32] = {0,}; if (id != VIEWER_PHOTO) { - _get_timestr(progress, sizeof(progress), mi->video->position); - _get_timestr(duration, sizeof(duration), mi->video->duration); + _time_string(progress, sizeof(progress), mi->video->position); + _time_string(duration, sizeof(duration), mi->video->duration); snprintf(total, sizeof(total), "/ %s", duration); } -- 2.7.4 From 64cd29d25fd0210bf22ef765dcd785ceacc2fe8e Mon Sep 17 00:00:00 2001 From: Minkyu Kang Date: Mon, 29 Jun 2015 19:37:12 +0900 Subject: [PATCH 08/16] viewer: show image files to content area Change-Id: I757c6a5056ab848121f560f6a153e020fd69b058 Signed-off-by: Minkyu Kang --- src/view/viewer.c | 139 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 129 insertions(+), 10 deletions(-) diff --git a/src/view/viewer.c b/src/view/viewer.c index fedf010..96a05b6 100644 --- a/src/view/viewer.c +++ b/src/view/viewer.c @@ -56,6 +56,9 @@ struct _playlist { struct _priv { Evas_Object *win; Evas_Object *base; + Evas_Object *photo; + Evas_Object *photo_pre; + Evas_Object *favorite; struct _viewer viewer; struct _playlist playlist; @@ -238,6 +241,118 @@ static void _up_string(char *str) } } +static void _draw_thumbnail(struct _priv *priv, int id, app_media_info *mi) +{ + Evas_Object *obj; + + if (priv->photo_pre) { + evas_object_del(priv->photo_pre); + priv->photo_pre = NULL; + } + + if (priv->photo) { + evas_object_del(priv->photo); + priv->photo = NULL; + } + + obj = elm_image_add(priv->base); + if (!obj) { + _ERR("failed to adding image"); + return; + } + + elm_image_file_set(obj, mi->thumbnail_path, NULL); + elm_object_part_content_set(priv->base, PART_VIEWER_CONTENT, obj); + + priv->photo = obj; +} + +static void _image_loaded(void *data, Evas_Object *obj, void *ev) +{ + struct _priv *priv; + + if (!data || !obj) + return; + + priv = data; + + if (priv->photo != priv->photo_pre) { + if (priv->photo) + evas_object_del(priv->photo); + + priv->photo = obj; + } + + elm_object_part_content_set(priv->base, PART_VIEWER_CONTENT, obj); +} + +static void _image_loaded_detail(void *data, Evas_Object *obj, void *ev) +{ + struct _priv *priv; + + if (!data) + return; + + priv = data; + + priv->photo_pre = NULL; +} + +static void _load_image_file(struct _priv *priv, int id, app_media_info *mi) +{ + Evas_Object *obj; + int w, h; + int mode; + + if (id == VIEWER_MOVIE) { + elm_object_part_content_unset(priv->base, PART_VIEWER_CONTENT); + return; + } else if (id == VIEWER_VIDEO) { + _draw_thumbnail(priv, id, mi); + return; + } + + if (!mi->file_path) + return; + + if (priv->photo_pre) { + obj = priv->photo_pre; + } else { + obj = elm_photocam_add(priv->base); + if (!obj) { + _ERR("failed to adding photocam"); + return; + } + + evas_object_smart_callback_add(obj, "loaded", + _image_loaded, priv); + evas_object_smart_callback_add(obj, "loaded,detail", + _image_loaded_detail, priv); + + elm_object_focus_allow_set(obj, EINA_FALSE); + elm_scroller_policy_set(obj, + ELM_SCROLLER_POLICY_AUTO, + ELM_SCROLLER_POLICY_AUTO); + + /* + * set this photocam object to photo_pre (preloaded photo) + * On "loaded" callback, photo_pre object will pass to photo + * On "loaded,detail" callback, photo_pre object will set to NULL + */ + priv->photo_pre = obj; + } + + elm_photocam_file_set(obj, mi->file_path); + + elm_photocam_image_size_get(obj, &w, &h); + if (h > w) + mode = ELM_PHOTOCAM_ZOOM_MODE_AUTO_FIT; + else + mode = ELM_PHOTOCAM_ZOOM_MODE_AUTO_FILL; + + elm_photocam_zoom_mode_set(obj, mode); +} + static void _draw_title_bar(struct _priv *priv, int id, app_media_info *mi) { char buf[32] = {0,}; @@ -283,19 +398,11 @@ static void _draw_time_info(struct _priv *priv, int id, app_media_info *mi) static void _draw_favorite_icon(struct _priv *priv, int id, app_media_info *mi) { - Evas_Object *img; - if (!mi->favorite) return; - img = elm_image_add(priv->base); - if (!img) - return; - - elm_image_file_set(img, IMAGE_VIEWER_FAVORITE, NULL); - - evas_object_show(img); - elm_object_part_content_set(priv->base, PART_VIEWER_FAVORITE, img); + elm_object_part_content_set(priv->base, + PART_VIEWER_FAVORITE, priv->favorite); } static bool _viewer_show(struct _priv *priv, int cur, int foc) @@ -355,6 +462,8 @@ static bool _viewer_show(struct _priv *priv, int cur, int foc) } ctl->ops->focus(ctl->handle, loc, true); + _load_image_file(priv, id, mi); + _draw_title_bar(priv, id, mi); _draw_time_info(priv, id, mi); _draw_favorite_icon(priv, id, mi); @@ -451,6 +560,7 @@ static bool _viewer_next(struct _priv *priv) static bool _ui_init(struct _priv *priv) { + Evas_Object *obj; bool r; int i; @@ -460,6 +570,15 @@ static bool _ui_init(struct _priv *priv) goto err; } + obj = elm_image_add(priv->base); + if (!obj) { + _ERR("failed to adding image"); + goto err; + } + + elm_image_file_set(obj, IMAGE_VIEWER_FAVORITE, NULL); + priv->favorite = obj; + return true; err: -- 2.7.4 From dc4c22994b5439d4b8328f70170d2330d7e7b0c3 Mon Sep 17 00:00:00 2001 From: Minkyu Kang Date: Mon, 29 Jun 2015 22:12:58 +0900 Subject: [PATCH 09/16] viewer: fix crash issue when destory controller Change-Id: I9fb504b5efd2388dcc3cdcbdd9c6a6fd9a0c307c Signed-off-by: Minkyu Kang --- src/view/viewer.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/view/viewer.c b/src/view/viewer.c index 96a05b6..52c5bc7 100644 --- a/src/view/viewer.c +++ b/src/view/viewer.c @@ -510,14 +510,10 @@ static bool _viewer_add(struct _priv *priv, int id) static void _viewer_delete(struct _priv *priv) { - struct controller *ctl; int i; - for (i = 0; i < VIEWER_MAX; i++) { - ctl = priv->viewer.ctl[i]; - if (ctl) - controller_destroy(ctl->handle); - } + for (i = 0; i < VIEWER_MAX; i++) + controller_destroy(priv->viewer.ctl[i]); } static bool _viewer_prev(struct _priv *priv) -- 2.7.4 From aaa9928f69335cd746c127e133d83e270b70d6d2 Mon Sep 17 00:00:00 2001 From: Jehun Lim Date: Tue, 30 Jun 2015 13:38:59 +0900 Subject: [PATCH 10/16] add button and gengrid edc : button for index in thumbnail area and gengrid for movie item Change-Id: Ic3a5c112a5d9e79ea33ae9c5e48d25e57ad62080 Signed-off-by: Jehun Lim --- include/define.h | 3 + include/view/base.h | 2 +- res/edc/mediahub-theme.edc | 1 + res/edc/widgets/button.edc | 51 +++++- res/edc/widgets/gengrid.edc | 392 ++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 447 insertions(+), 2 deletions(-) create mode 100644 res/edc/widgets/gengrid.edc diff --git a/include/define.h b/include/define.h index c0e2317..56003cb 100644 --- a/include/define.h +++ b/include/define.h @@ -42,5 +42,8 @@ #define COLOR_TEXT_DISABLED 87 87 87 128 #define COLOR_BTN_FOCUS 0 119 246 255 #define COLOR_BTN_SELECTED 64 136 211 255 +#define COLOR_ITEM_BG 56 55 59 255 +#define COLOR_ITEM_FOCUS 0 119 246 255 +#define COLOR_ITEM_FOCUS_0 0 119 246 0 #endif /* __AIR_MEDIAHUB_DEFINE_H__ */ diff --git a/include/view/base.h b/include/view/base.h index 965493c..470bc93 100644 --- a/include/view/base.h +++ b/include/view/base.h @@ -26,6 +26,6 @@ #define PART_THUMBNAIL_AREA "part.thumbnail_area" #define PART_BOTTOM_AREA "part.bottom_area" -#define STYLE_MENU_BTN "menu_btn" +#define STYLE_MENU_BTN "base_btn_menu" #endif /* __AIR_MEDIAHUB_VIEW_BASE_H__ */ diff --git a/res/edc/mediahub-theme.edc b/res/edc/mediahub-theme.edc index 8f01d57..4187a48 100644 --- a/res/edc/mediahub-theme.edc +++ b/res/edc/mediahub-theme.edc @@ -18,4 +18,5 @@ collections { #include "widgets/button.edc" + #include "widgets/gengrid.edc" } diff --git a/res/edc/widgets/button.edc b/res/edc/widgets/button.edc index b049524..2113a5b 100644 --- a/res/edc/widgets/button.edc +++ b/res/edc/widgets/button.edc @@ -19,7 +19,7 @@ #define TRANSITION_TIME 0.17 group { - name: "elm/button/base/menu_btn"; + name: "elm/button/base/base_btn_menu"; data.item: "focus_highlight" "on"; parts { part { @@ -126,6 +126,55 @@ group { } group { + name: "elm/button/base/base_btn_index"; + inherit: "elm/button/base/base_btn_menu"; + data.item: "focus_highlight" "on"; + parts { + part { + name: "bg"; + scale: 1; + description { + state: "default" 0.0; + min: 0 36; + color: 0 0 0 0; + fixed: 0 1; + } + description { + state: "focused" 0.0; + inherit: "default" 0.0; + color: COLOR_BTN_FOCUS; + } + } + part { + name: "elm.text"; + type: TEXT; + scale: 1; + description { + state: "default" 0.0; + rel1.to: "bg"; + rel2.to: "bg"; + text { + font: FONT_LIGHT; + size: 36; + align: 0.0 0.5; + } + min: 82 0; + align: 0.0 0.5; + color: COLOR_TEXT_INDEX; + align: 0.0 0.0; + fixed: 1 1; + } + description { + state: "focused" 0.0; + inherit: "default" 0.0; + text.font: "TizenSans"; + color: COLOR_TEXT_FOCUS; + } + } + } +} + +group { name: "elm/button/base/viewer_btn_prev"; data.item, "focus_highlight" "on"; images { diff --git a/res/edc/widgets/gengrid.edc b/res/edc/widgets/gengrid.edc new file mode 100644 index 0000000..3e9a631 --- /dev/null +++ b/res/edc/widgets/gengrid.edc @@ -0,0 +1,392 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +group { + name: "elm/gengrid/item/movie_item/default"; + data.item: "selectraise" "on"; + data.item: "texts" "elm.text"; + data.item: "contents" "elm.swallow.icon"; + data.item: "focus_highlight" "on"; + parts { + part { + name: "elm.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: "clicked" 0.0; + inherit: "default" 0.0; + perspective.zplane: -100; + } + } + part { + name: "bg"; + type: RECT; + scale: 1; + description { + state: "default" 0.0; + rel2 { + to: "elm.padding.bottom_right"; + relative: 0.0 0.0; + } + fixed: 1 1; + visible: 0; + } + } + part { + name: "defaultbg"; + type: RECT; + scale: 1; + description { + state: "default" 0.0; + rel1.to: "bg"; + rel2 { + to: "elm.bg.text"; + relative: 1.0 0.0; + } + color: 0 0 0 115; + map { + perspective_on: 1; + perspective: "map"; + } + } + description { + state: "selected" 0.0; + inherit: "default" 0.0; + map.on: 1; + } + } + part { + name: "elm.swallow.icon"; + type: SWALLOW; + scale: 1; + mouse_events: 1; + description { + state : "default" 0.0; + rel1.to: "defaultbg"; + rel2.to: "defaultbg"; + map { + perspective_on: 1; + perspective: "map"; + } + } + description { + state: "selected" 0.0; + inherit: "default" 0.0; + map.on: 1; + } + } + part { + name: "part_focus1"; + type: RECT; + mouse_events: 0; + scale: 1; + description { + state: "default" 0.0; + rel1.to: "bg"; + rel2 { + to: "bg"; + relative: 1.0 0.0; + } + min: 0 3; + align: 0.5 0.0; + color: COLOR_ITEM_FOCUS; + fixed: 0 1; + visible: 0; + map { + perspective_on: 1; + perspective: "map"; + } + } + description { + state: "selected" 0.0; + inherit: "default" 0.0; + map.on: 1; + visible: 1; + } + description { + state: "selected_0" 0.0; + inherit: "default" 0.0; + visible: 1; + color: COLOR_ITEM_FOCUS_0; + } + } + part { + name: "part_focus2"; + type: RECT; + mouse_events: 0; + scale: 1; + description { + state: "default" 0.0; + rel1 { + to: "part_focus1"; + relative: 0.0 1.0; + } + rel2 { + to: "elm.bg.text"; + relative: 0.0 0.0; + } + min: 3 0; + align: 0.0 0.5; + color: COLOR_ITEM_FOCUS; + fixed: 1 0; + visible: 0; + map { + perspective_on: 1; + perspective: "map"; + } + } + description { + state: "selected" 0.0; + inherit: "default" 0.0; + map.on: 1; + visible: 1; + } + description { + state: "selected_0" 0.0; + inherit: "default" 0.0; + visible: 1; + color: COLOR_ITEM_FOCUS_0; + } + } + part { + name: "part_focus3"; + type: RECT; + mouse_events: 0; + scale: 1; + description { + state: "default" 0.0; + rel1 { + to: "part_focus1"; + relative: 1.0 1.0; + } + rel2 { + to: "elm.bg.text"; + relative: 1.0 0.0; + } + min: 3 0; + align: 1.0 0.5; + color: COLOR_ITEM_FOCUS; + fixed: 1 0; + visible: 0; + map { + perspective_on: 1; + perspective: "map"; + } + } + description { + state: "selected" 0.0; + inherit: "default" 0.0; + map.on: 1; + visible: 1; + } + description { + state: "selected_0" 0.0; + inherit: "default" 0.0; + visible: 1; + color: COLOR_ITEM_FOCUS_0; + } + } + part { + name: "defaultbg_text"; + type: RECT; + mouse_events: 0; + scale: 1; + description { + state: "default" 0.0; + rel1 { + to: "bg"; + relative: 0.0 1.0; + } + rel2.to: "bg"; + min: 0 82; + align: 0.5 1.0; + color: COLOR_ITEM_BG; + fixed: 0 1; + } + } + part { + name: "elm.bg.text"; + type: RECT; + mouse_events: 0; + scale: 1; + description { + state: "default" 0.0; + rel1.to: "defaultbg_text"; + rel2.to: "defaultbg_text"; + color: COLOR_ITEM_BG; + map { + perspective_on: 1; + perspective: "map"; + } + } + description { + state: "selected" 0.0; + inherit: "default" 0.0; + color: COLOR_ITEM_FOCUS; + map.on: 1; + } + description { + state: "selected_0" 0.0; + inherit: "default" 0.0; + color: COLOR_ITEM_FOCUS_0; + } + } + part { + name: "elm.padding.text.left"; + type: SPACER; + scale: 1; + description { + state: "default" 0.0; + rel1.to: "elm.bg.text"; + rel2 { + to: "elm.bg.text"; + relative: 0.0 0.0; + } + min: 18 82; + align: 0.0 0.0; + fixed: 1 1; + } + } + part { + name: "elm.padding.text.right"; + type: SPACER; + scale: 1; + description { + state: "default" 0.0; + rel1 { + to: "elm.bg.text"; + relative: 1.0 0.0; + } + rel2 { + to: "elm.bg.text"; + relative: 1.0 0.0; + } + min: 18 82; + align: 1.0 0.0; + fixed: 1 1; + } + } + part { + name: "elm.text"; + type: TEXT; + scale: 1; + description { + state: "default" 0.0; + rel1 { + to: "elm.padding.text.left"; + relative: 1.0 0.0; + } + rel2 { + to: "elm.padding.text.right"; + relative: 0.0 1.0; + } + text { + font: FONT_LIGHT; + size: 28; + align: 0.0 0.5; + } + color: COLOR_TEXT_FOCUS; + map { + perspective_on: 1; + perspective: "map"; + } + } + description { + state: "selected" 0.0; + inherit: "default" 0.0; + color: COLOR_TEXT_FOCUS; + map.on: 1; + } + description { + state: "selected_0" 0.0; + inherit: "selected" 0.0; + } + } + } + programs { + program { + name: "go_active"; + signal: "elm,state,focused"; + source: "elm"; + action: STATE_SET "selected_0" 0.0; + target: "part_focus1"; + target: "part_focus2"; + target: "part_focus3"; + target: "elm.bg.text"; + target: "elm.text"; + after: "focus,in,anim"; + } + program { + name: "focus,in,anim"; + action: STATE_SET "selected" 0.0; + target: "defaultbg"; + target: "elm.swallow.icon"; + target: "part_focus1"; + target: "part_focus2"; + target: "part_focus3"; + target: "elm.bg.text"; + transition: LINEAR 0.17; + } + program { + name: "go_passive"; + signal: "elm,state,unfocused"; + source: "elm"; + action: STATE_SET "default" 0.0; + target: "elm.text"; + after: "focus,out,anim"; + } + program { + name: "focus,out,anim"; + action: STATE_SET "selected_0" 0.0; + target: "part_focus1"; + target: "part_focus2"; + target: "part_focus3"; + target: "elm.bg.text"; + transition: LINEAR 0.17; + after: "focus,out,anim,3"; + } + program { + name: "focus,out,anim,3"; + action: STATE_SET "default" 0.0; + target: "elm.swallow.icon"; + target: "defaultbg"; + target: "part_focus1"; + target: "part_focus2"; + target: "part_focus3"; + target: "elm.bg.text"; + } + } +} -- 2.7.4 From 7751cd59ff62f53dcd8d5f006db4f2f083f5fe75 Mon Sep 17 00:00:00 2001 From: Minkyu Kang Date: Tue, 30 Jun 2015 16:23:37 +0900 Subject: [PATCH 11/16] fix rpmlint issue Change-Id: I3c207a4be5a51f3adf7c598ed0b5389ff36d0199 Signed-off-by: Minkyu Kang --- packaging/org.tizen.mediahub.spec | 1 + 1 file changed, 1 insertion(+) diff --git a/packaging/org.tizen.mediahub.spec b/packaging/org.tizen.mediahub.spec index d5a7724..2a6c12a 100644 --- a/packaging/org.tizen.mediahub.spec +++ b/packaging/org.tizen.mediahub.spec @@ -25,6 +25,7 @@ Media Hub Application %setup -q cp %{SOURCE1} . +%build cmake \ -DCMAKE_INSTALL_PREFIX=%{_appdir} \ -DPACKAGE_NAME=%{name} \ -- 2.7.4 From 241e5fc9ffb0689f3fded34c719a037e219b284f Mon Sep 17 00:00:00 2001 From: Minkyu Kang Date: Tue, 30 Jun 2015 19:58:51 +0900 Subject: [PATCH 12/16] add timeout_handler for show/hide the bar Change-Id: If65892b0199abf91fec094727c8b08ea258040fa Signed-off-by: Minkyu Kang --- CMakeLists.txt | 1 + include/util/controller.h | 2 + include/util/timeout_handler.h | 32 +++++++++ include/view/viewer.h | 3 + res/edc/view/viewer.edc | 28 ++++++++ src/util/controller.c | 51 ++++++++++++++- src/util/timeout_handler.c | 144 +++++++++++++++++++++++++++++++++++++++++ src/view/viewer.c | 54 ++++++++++++++++ 8 files changed, 312 insertions(+), 3 deletions(-) create mode 100644 include/util/timeout_handler.h create mode 100644 src/util/timeout_handler.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 5f67dbe..848459a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,6 +55,7 @@ src/layout/gallery.c src/layout/music.c src/util/gridmgr.c src/util/controller.c +src/util/timeout_handler.c src/data/mediadata.c ) diff --git a/include/util/controller.h b/include/util/controller.h index 8a6a4c3..6c3cead 100644 --- a/include/util/controller.h +++ b/include/util/controller.h @@ -19,6 +19,8 @@ struct controller; struct controller_ops { void (*show)(void *handle); void (*hide)(void *handle); + void (*enable)(void *handle); + void (*disable)(void *handle); bool (*add_control)(void *handle, const char *name, int loc, const char *style, const char *part); void (*add_callback)(void *handle, diff --git a/include/util/timeout_handler.h b/include/util/timeout_handler.h new file mode 100644 index 0000000..29dd6e1 --- /dev/null +++ b/include/util/timeout_handler.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + +#ifndef __AIR_MEDIAHUB_TIMEOUT_HANDLER_H__ +#define __AIR_MEDIAHUB_TIMEOUT_HANDLER_H__ + +struct timeout_handler; + +typedef void (*timeout_event_cb)(void *data, int type, void *ei); + +struct timeout_handler *timeout_handler_init(double timeout, + timeout_event_cb timeout_cb, void *timeout_data, + timeout_event_cb event_cb, void *event_data); + +void timeout_handler_fini(struct timeout_handler *handle); + +void timeout_handler_reset(struct timeout_handler *handle); + +#endif diff --git a/include/view/viewer.h b/include/view/viewer.h index 33cdc14..1babe1c 100644 --- a/include/view/viewer.h +++ b/include/view/viewer.h @@ -37,6 +37,9 @@ #define SIG_SET_PAUSE "set,pause,icon" #define SIG_BTN_CLICKED "btn,clicked" #define SIG_BTN_CALLBACK "btn,callback" +#define SIG_HIDE_BAR "hide,bar" +#define SIG_SHOW_BAR "show,bar" +#define SIG_SHOWED_BAR "showed,bar" /* source */ #define SRC_BTN_PREV "prev" diff --git a/res/edc/view/viewer.edc b/res/edc/view/viewer.edc index e3c6573..a8007a1 100644 --- a/res/edc/view/viewer.edc +++ b/res/edc/view/viewer.edc @@ -14,6 +14,8 @@ * limitations under the License. */ +#define TRANSITION_TIME 0.25 + group { name: GRP_VIEWER_VIEW; parts { @@ -426,4 +428,30 @@ group { } } } + + programs { + program { + name: SIG_HIDE_BAR; + signal: SIG_HIDE_BAR; + source: ""; + action: STATE_SET "hide" 0.0; + target: "toparea"; + target: "bottomarea"; + transition: LINEAR TRANSITION_TIME; + } + program { + name: SIG_SHOW_BAR; + signal: SIG_SHOW_BAR; + source: ""; + action: STATE_SET "default" 0.0; + target: "toparea"; + target: "bottomarea"; + transition: LINEAR TRANSITION_TIME; + after: SIG_SHOWED_BAR; + } + program { + name: SIG_SHOWED_BAR; + action: SIGNAL_EMIT SIG_SHOWED_BAR ""; + } + } } diff --git a/src/util/controller.c b/src/util/controller.c index 1be6e8c..b43c4f9 100644 --- a/src/util/controller.c +++ b/src/util/controller.c @@ -174,7 +174,7 @@ static void _signal(void *handle, int loc, const char *signal) elm_object_signal_emit(ctl->obj, signal, ""); } -static void _show(void *handle) +static void _enable(void *handle) { struct _priv *p; struct _control *ctl; @@ -193,10 +193,53 @@ static void _show(void *handle) evas_object_freeze_events_set(ctl->obj, EINA_FALSE); elm_object_focus_allow_set(ctl->obj, EINA_TRUE); + } +} + +static void _disable(void *handle) +{ + struct _priv *p; + struct _control *ctl; + Eina_List *l; + + if (!handle) { + _ERR("invalid parameter"); + return; + } + + p = handle; + + EINA_LIST_FOREACH(p->list, l, ctl) { + if (!ctl->obj) + continue; + + evas_object_freeze_events_set(ctl->obj, EINA_TRUE); + elm_object_focus_allow_set(ctl->obj, EINA_FALSE); + } +} + +static void _show(void *handle) +{ + struct _priv *p; + struct _control *ctl; + Eina_List *l; + + if (!handle) { + _ERR("invalid parameter"); + return; + } + + p = handle; + + EINA_LIST_FOREACH(p->list, l, ctl) { + if (!ctl->obj) + continue; evas_object_show(ctl->obj); elm_object_part_content_set(p->base, ctl->part, ctl->obj); } + + _enable(handle); } static void _hide(void *handle) @@ -216,13 +259,13 @@ static void _hide(void *handle) if (!ctl->obj) continue; - evas_object_freeze_events_set(ctl->obj, EINA_TRUE); elm_object_focus_set(ctl->obj, false); - elm_object_focus_allow_set(ctl->obj, EINA_FALSE); evas_object_hide(ctl->obj); elm_object_part_content_unset(p->base, ctl->part); } + + _disable(handle); } static struct controller_ops _operations = { @@ -230,6 +273,8 @@ static struct controller_ops _operations = { .add_callback = _add_callback, .focus = _focus, .signal = _signal, + .enable = _enable, + .disable = _disable, .show = _show, .hide = _hide, }; diff --git a/src/util/timeout_handler.c b/src/util/timeout_handler.c new file mode 100644 index 0000000..e35f571 --- /dev/null +++ b/src/util/timeout_handler.c @@ -0,0 +1,144 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ +#include +#include +#include + +#include "define.h" +#include "util/timeout_handler.h" + +struct timeout_handler { + Eina_List *list; + Ecore_Timer *timer; + + timeout_event_cb event_cb; + void *event_data; + + timeout_event_cb timeout_cb; + void *timeout_data; + + double timeout; +}; + +static Eina_Bool _timer_cb(void *data) +{ + struct timeout_handler *handle; + + if (!data) + return ECORE_CALLBACK_CANCEL; + + handle = data; + + handle->timeout_cb(handle->timeout_data, 0, NULL); + handle->timer = NULL; + + return ECORE_CALLBACK_CANCEL; +} + +static Eina_Bool _event_occured(void *data, int type, void *event) +{ + struct timeout_handler *handle; + + if (!data) + return ECORE_CALLBACK_PASS_ON; + + handle = data; + + handle->event_cb(handle->event_data, type, event); + + timeout_handler_reset(handle); + + return ECORE_CALLBACK_PASS_ON; +} + +void timeout_handler_reset(struct timeout_handler *handle) +{ + if (!handle) { + _ERR("invalid parameter"); + return; + } + + if (handle->timer) + ecore_timer_reset(handle->timer); + else + handle->timer = ecore_timer_add(handle->timeout, + _timer_cb, handle); +} + +struct timeout_handler *timeout_handler_init(double timeout, + timeout_event_cb timeout_cb, void *timeout_data, + timeout_event_cb event_cb, void *event_data) +{ + struct timeout_handler *handle; + Ecore_Event_Handler *ev; + int i; + int event_type[] = { + ECORE_EVENT_KEY_UP, + ECORE_EVENT_KEY_DOWN, + ECORE_EVENT_MOUSE_BUTTON_DOWN, + ECORE_EVENT_MOUSE_BUTTON_UP, + ECORE_EVENT_MOUSE_MOVE, + ECORE_EVENT_MOUSE_WHEEL + }; + + handle = calloc(1, sizeof(*handle)); + if (!handle) { + _ERR("failed to allocate"); + return NULL; + } + + for (i = 0; i < sizeof(event_type) / sizeof(*event_type); i++) { + ev = ecore_event_handler_add(event_type[i], + _event_occured, handle); + if (!ev) + goto error; + + handle->list = eina_list_append(handle->list, ev); + } + + handle->timer = ecore_timer_add(timeout, _timer_cb, handle); + if (!handle->timer) + goto error; + + handle->event_cb = event_cb; + handle->event_data = event_data; + handle->timeout_cb = timeout_cb; + handle->timeout_data = timeout_data; + handle->timeout = timeout; + + return handle; + +error: + timeout_handler_fini(handle); + + return NULL; +} + +void timeout_handler_fini(struct timeout_handler *handle) +{ + Ecore_Event_Handler *ev; + + if (!handle) + return; + + EINA_LIST_FREE(handle->list, ev) + ecore_event_handler_del(ev); + + ecore_timer_del(handle->timer); + handle->timer = NULL; + + free(handle); +} diff --git a/src/view/viewer.c b/src/view/viewer.c index 52c5bc7..f09ad46 100644 --- a/src/view/viewer.c +++ b/src/view/viewer.c @@ -24,10 +24,13 @@ #include "define.h" #include "util/controller.h" +#include "util/timeout_handler.h" #define STYLE_VIEWER_BTN "viewer_btn" #define PART_VIEWER_BTN "control_btn" +#define VIEWER_TIMEOUT 3.0 + #define VIDEO_COPYRIGHT "Unknown" enum { @@ -62,6 +65,9 @@ struct _priv { struct _viewer viewer; struct _playlist playlist; + struct timeout_handler *timeout; + + bool bar_show; }; struct _btn_info { @@ -554,6 +560,44 @@ static bool _viewer_next(struct _priv *priv) return r; } +static void _show_bar(struct _priv *priv) +{ + struct controller *ctl; + + if (priv->bar_show) + return; + + elm_object_signal_emit(priv->base, SIG_SHOW_BAR, ""); + priv->bar_show = true; + + ctl = priv->viewer.ctl[priv->viewer.cur]; + ctl->ops->enable(ctl->handle); +} + +static void _hide_bar(struct _priv *priv) +{ + struct controller *ctl; + + if (!priv->bar_show) + return; + + elm_object_signal_emit(priv->base, SIG_HIDE_BAR, ""); + priv->bar_show = false; + + ctl = priv->viewer.ctl[priv->viewer.cur]; + ctl->ops->disable(ctl->handle); +} + +static void _timeout_cb(void *data, int type, void *ei) +{ + _hide_bar(data); +} + +static void _event_cb(void *data, int type, void *ei) +{ + _show_bar(data); +} + static bool _ui_init(struct _priv *priv) { Evas_Object *obj; @@ -575,6 +619,12 @@ static bool _ui_init(struct _priv *priv) elm_image_file_set(obj, IMAGE_VIEWER_FAVORITE, NULL); priv->favorite = obj; + priv->timeout = timeout_handler_init(VIEWER_TIMEOUT, + _timeout_cb, priv, + _event_cb, priv); + + priv->bar_show = true; + return true; err: @@ -682,6 +732,8 @@ static void _show(void *view_data) /* FIXME: test code */ _viewer_show(priv, priv->playlist.cur, DIR_NONE); + timeout_handler_reset(priv->timeout); + evas_object_show(priv->base); } @@ -718,6 +770,8 @@ static void _destroy(void *view_data) EINA_LIST_FREE(priv->playlist.list, am) app_media_destroy(am); + timeout_handler_fini(priv->timeout); + evas_object_del(priv->base); free(priv); -- 2.7.4 From 68103740bf6f970b46006e9d0dac0d5317073f76 Mon Sep 17 00:00:00 2001 From: Minkyu Kang Date: Tue, 30 Jun 2015 20:56:08 +0900 Subject: [PATCH 13/16] viewer: set zoom mode to auto fit Change-Id: I52ffc9c0705d6728854bdcc5223748d009f0a07a Signed-off-by: Minkyu Kang --- src/view/viewer.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/view/viewer.c b/src/view/viewer.c index f09ad46..91c09be 100644 --- a/src/view/viewer.c +++ b/src/view/viewer.c @@ -307,8 +307,6 @@ static void _image_loaded_detail(void *data, Evas_Object *obj, void *ev) static void _load_image_file(struct _priv *priv, int id, app_media_info *mi) { Evas_Object *obj; - int w, h; - int mode; if (id == VIEWER_MOVIE) { elm_object_part_content_unset(priv->base, PART_VIEWER_CONTENT); @@ -349,14 +347,7 @@ static void _load_image_file(struct _priv *priv, int id, app_media_info *mi) } elm_photocam_file_set(obj, mi->file_path); - - elm_photocam_image_size_get(obj, &w, &h); - if (h > w) - mode = ELM_PHOTOCAM_ZOOM_MODE_AUTO_FIT; - else - mode = ELM_PHOTOCAM_ZOOM_MODE_AUTO_FILL; - - elm_photocam_zoom_mode_set(obj, mode); + elm_photocam_zoom_mode_set(obj, ELM_PHOTOCAM_ZOOM_MODE_AUTO_FIT); } static void _draw_title_bar(struct _priv *priv, int id, app_media_info *mi) -- 2.7.4 From 29f90918ae0a4634f5e28e09653fa416644a622a Mon Sep 17 00:00:00 2001 From: Jehun Lim Date: Tue, 30 Jun 2015 19:13:30 +0900 Subject: [PATCH 14/16] mediadata: add media_list in struct mediadata Change-Id: I68f640f2782fb64abdcb8d49e854acda316fcaee Signed-off-by: Jehun Lim --- include/data/mediadata.h | 11 +++- src/data/mediadata.c | 129 ++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 114 insertions(+), 26 deletions(-) diff --git a/include/data/mediadata.h b/include/data/mediadata.h index 59431b4..0715cc8 100644 --- a/include/data/mediadata.h +++ b/include/data/mediadata.h @@ -28,13 +28,20 @@ enum source_type { E_SOURCE_MAX }; -struct folderdata { +enum sort_type { + E_SORT_DATE = 0, + E_SORT_NAME, + E_SORT_MAX +}; + +struct folder_info { char *name; time_t modified_time; Eina_List *list; }; -struct mediadata *mediadata_create(const char *media_type, int source_type); +struct mediadata *mediadata_create(const char *media_type, + int source_type, int sort_type); void mediadata_destroy(struct mediadata *md); #endif /* _AIR_MEDIAHUB_MEDIADATA_H__ */ diff --git a/src/data/mediadata.c b/src/data/mediadata.c index ce8858c..abef770 100644 --- a/src/data/mediadata.c +++ b/src/data/mediadata.c @@ -21,20 +21,45 @@ #include "data/mediadata.h" +static int _compare_cb_date(const void *, const void *); +static int _compare_cb_name(const void *, const void *); + enum _filter_type { E_FILTER_FOLDER = 0, E_FILTER_MEDIA }; struct mediadata { - Eina_List *list; + Eina_List *folder_list; + Eina_List *media_list; }; struct _data { const char *media_type; int source_type; + int sort_type; Eina_List *item_list; Eina_List *folder_list; + Eina_List *media_list; +}; + +struct _sort_info { + int order_type; + const char *order_keyword; + Eina_Compare_Cb func; +}; + +static struct _sort_info g_sort_info[E_SORT_MAX] = { + [E_SORT_DATE] = { + .order_type = MEDIA_CONTENT_ORDER_DESC, + .order_keyword = MEDIA_MODIFIED_TIME, + .func = _compare_cb_date, + }, + [E_SORT_NAME] = { + .order_type = MEDIA_CONTENT_ORDER_ASC, + .order_keyword = MEDIA_TITLE, + .func = _compare_cb_name + } }; static bool _create_filter(struct _data *data, filter_h *filter, int type) @@ -61,24 +86,73 @@ static bool _create_filter(struct _data *data, filter_h *filter, int type) media_filter_set_condition(tmp_filter, buf, MEDIA_CONTENT_COLLATE_DEFAULT); - media_filter_set_order(tmp_filter, MEDIA_CONTENT_ORDER_DESC, - MEDIA_MODIFIED_TIME, MEDIA_CONTENT_COLLATE_NOCASE); + + media_filter_set_order(tmp_filter, + g_sort_info[data->sort_type].order_type, + g_sort_info[data->sort_type].order_keyword, + MEDIA_CONTENT_COLLATE_NOCASE); *filter = tmp_filter; return true; } -static void _destroy_medialist(Eina_List *list) +static int _compare_cb_date(const void *data1, const void *data2) +{ + app_media *am1, *am2; + app_media_info *info1, *info2; + + am1 = (app_media *)data1; + am2 = (app_media *)data2; + + info1 = app_media_get_info(am1); + info2 = app_media_get_info(am2); + + if (!info1 || !info2) + return -1; + + if (info1->modified_time > info2->modified_time) + return 1; + + return -1; +} + +static int _compare_cb_name(const void *data1, const void *data2) +{ + app_media *am1, *am2; + app_media_info *info1, *info2; + + am1 = (app_media *)data1; + am2 = (app_media *)data2; + + info1 = app_media_get_info(am1); + info2 = app_media_get_info(am2); + + if (!info1 || !info2 || !info1->display_name || !info2->display_name) + return -1; + + return strcasecmp(info1->display_name, info2->display_name); +} + +static Eina_List *_sort_list(Eina_List *list, int sort) +{ + Eina_List *sorted_list; + + sorted_list = eina_list_sort(list, 0, g_sort_info[sort].func); + + return sorted_list; +} + +static void _destroy_folderlist(Eina_List *list) { - struct folderdata *fd; + struct folder_info *fi; app_media *am; - EINA_LIST_FREE(list, fd) { - free(fd->name); - EINA_LIST_FREE(fd->list, am) + EINA_LIST_FREE(list, fi) { + free(fi->name); + EINA_LIST_FREE(fi->list, am) app_media_destroy(am); - fd->list = NULL; + free(fi); } } @@ -107,7 +181,7 @@ static bool _get_each_folder_info(media_folder_h folder, void *dt) { filter_h filter; struct _data *data; - struct folderdata *fd; + struct folder_info *fi; int ret; char *uuid; @@ -116,19 +190,19 @@ static bool _get_each_folder_info(media_folder_h folder, void *dt) data = dt; - fd = calloc(1, sizeof(*fd)); - if (!fd) { + fi = calloc(1, sizeof(*fi)); + if (!fi) { _ERR("failed to create folderdata"); return false; } - if (media_folder_get_name(folder, &(fd->name)) + if (media_folder_get_name(folder, &(fi->name)) != MEDIA_CONTENT_ERROR_NONE) { _ERR("Media folder id Fetch error"); goto err; } - if (media_folder_get_modified_time(folder, &(fd->modified_time)) + if (media_folder_get_modified_time(folder, &(fi->modified_time)) != MEDIA_CONTENT_ERROR_NONE) { _ERR("Media folder modified time Fetch error"); goto err; @@ -152,10 +226,11 @@ static bool _get_each_folder_info(media_folder_h folder, void *dt) goto err; } - fd->list = data->item_list; + fi->list = eina_list_clone(data->item_list); + data->media_list = eina_list_merge(data->media_list, data->item_list); data->item_list = NULL; - data->folder_list = eina_list_append(data->folder_list, fd); + data->folder_list = eina_list_append(data->folder_list, fi); media_filter_destroy(filter); free(uuid); @@ -165,11 +240,11 @@ static bool _get_each_folder_info(media_folder_h folder, void *dt) err: media_filter_destroy(filter); free(uuid); - _destroy_medialist(data->folder_list); + _destroy_folderlist(data->folder_list); return false; } -static bool _get_medialist(struct _data *data) +static bool _get_folderlist(struct _data *data) { filter_h filter; int ret; @@ -192,13 +267,15 @@ static bool _get_medialist(struct _data *data) return true; } -struct mediadata *mediadata_create(const char *media_type, int source_type) +struct mediadata *mediadata_create(const char *media_type, + int source_type, int sort_type) { struct mediadata *md; struct _data data; int ret; - if (!media_type || source_type < 0 || source_type >= E_SOURCE_MAX) { + if (!media_type || source_type < 0 || source_type >= E_SOURCE_MAX + || sort_type < 0 || sort_type >= E_SORT_MAX) { _ERR("invalid argument"); return NULL; } @@ -218,11 +295,13 @@ struct mediadata *mediadata_create(const char *media_type, int source_type) data.media_type = media_type; data.source_type = source_type; + data.sort_type = sort_type; data.item_list = NULL; data.folder_list = NULL; + data.media_list = NULL; - if (!_get_medialist(&data)) { - _ERR("failed to get medialist"); + if (!_get_folderlist(&data)) { + _ERR("failed to get folderlist"); free(md); media_content_disconnect(); return NULL; @@ -230,7 +309,8 @@ struct mediadata *mediadata_create(const char *media_type, int source_type) media_content_disconnect(); - md->list = data.folder_list; + md->folder_list = data.folder_list; + md->media_list = _sort_list(data.media_list, data.sort_type); return md; } @@ -242,5 +322,6 @@ void mediadata_destroy(struct mediadata *md) return; } - _destroy_medialist(md->list); + _destroy_folderlist(md->folder_list); + eina_list_free(md->media_list); } -- 2.7.4 From b81aa668ac86b55ccfcc5ac6d67c5a1a20487b61 Mon Sep 17 00:00:00 2001 From: Jehun Lim Date: Wed, 1 Jul 2015 16:09:39 +0900 Subject: [PATCH 15/16] mediadata: add function to create list with media name Change-Id: Idbfeb52c19bd52deb461b2917e4ce546e664bf59 Signed-off-by: Jehun Lim --- include/data/mediadata.h | 11 ++++- src/data/mediadata.c | 123 ++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 114 insertions(+), 20 deletions(-) diff --git a/include/data/mediadata.h b/include/data/mediadata.h index 0715cc8..006eaac 100644 --- a/include/data/mediadata.h +++ b/include/data/mediadata.h @@ -34,9 +34,13 @@ enum sort_type { E_SORT_MAX }; -struct folder_info { +enum list_type { + E_LIST_NAME = 0, + E_LIST_MAX +}; + +struct group_info { char *name; - time_t modified_time; Eina_List *list; }; @@ -44,4 +48,7 @@ struct mediadata *mediadata_create(const char *media_type, int source_type, int sort_type); void mediadata_destroy(struct mediadata *md); +Eina_List *mediadata_get_list(struct mediadata *md, int list_type); +void mediadata_free_list(Eina_List *list); + #endif /* _AIR_MEDIAHUB_MEDIADATA_H__ */ diff --git a/src/data/mediadata.c b/src/data/mediadata.c index abef770..04556b0 100644 --- a/src/data/mediadata.c +++ b/src/data/mediadata.c @@ -21,9 +21,15 @@ #include "data/mediadata.h" +typedef int (*media_compare)(struct group_info *gi, app_media_info *info); +typedef char *(*group_name_get)(app_media_info *info); + static int _compare_cb_date(const void *, const void *); static int _compare_cb_name(const void *, const void *); +static int _compare_title(struct group_info *, app_media_info *); +static char *_get_title(app_media_info *); + enum _filter_type { E_FILTER_FOLDER = 0, E_FILTER_MEDIA @@ -49,6 +55,11 @@ struct _sort_info { Eina_Compare_Cb func; }; +struct _list_info { + media_compare media_cmp; + group_name_get name_get; +}; + static struct _sort_info g_sort_info[E_SORT_MAX] = { [E_SORT_DATE] = { .order_type = MEDIA_CONTENT_ORDER_DESC, @@ -58,7 +69,14 @@ static struct _sort_info g_sort_info[E_SORT_MAX] = { [E_SORT_NAME] = { .order_type = MEDIA_CONTENT_ORDER_ASC, .order_keyword = MEDIA_TITLE, - .func = _compare_cb_name + .func = _compare_cb_name, + } +}; + +static struct _list_info g_list_info[E_LIST_MAX] = { + [E_LIST_NAME] = { + .media_cmp = _compare_title, + .name_get = _get_title, } }; @@ -97,6 +115,22 @@ static bool _create_filter(struct _data *data, filter_h *filter, int type) return true; } +static int _compare_title(struct group_info *gi, app_media_info *info) +{ + if (!gi || !gi->name || !info->title) + return -1; + + return strncasecmp(gi->name, info->title, 1); +} + +static char *_get_title(app_media_info *info) +{ + if (!info->title) + return NULL; + + return strndup(info->title, 1); +} + static int _compare_cb_date(const void *data1, const void *data2) { app_media *am1, *am2; @@ -145,14 +179,14 @@ static Eina_List *_sort_list(Eina_List *list, int sort) static void _destroy_folderlist(Eina_List *list) { - struct folder_info *fi; + struct group_info *gi; app_media *am; - EINA_LIST_FREE(list, fi) { - free(fi->name); - EINA_LIST_FREE(fi->list, am) + EINA_LIST_FREE(list, gi) { + free(gi->name); + EINA_LIST_FREE(gi->list, am) app_media_destroy(am); - free(fi); + free(gi); } } @@ -181,7 +215,7 @@ static bool _get_each_folder_info(media_folder_h folder, void *dt) { filter_h filter; struct _data *data; - struct folder_info *fi; + struct group_info *gi; int ret; char *uuid; @@ -190,24 +224,18 @@ static bool _get_each_folder_info(media_folder_h folder, void *dt) data = dt; - fi = calloc(1, sizeof(*fi)); - if (!fi) { + gi = calloc(1, sizeof(*gi)); + if (!gi) { _ERR("failed to create folderdata"); return false; } - if (media_folder_get_name(folder, &(fi->name)) + if (media_folder_get_name(folder, &(gi->name)) != MEDIA_CONTENT_ERROR_NONE) { _ERR("Media folder id Fetch error"); goto err; } - if (media_folder_get_modified_time(folder, &(fi->modified_time)) - != MEDIA_CONTENT_ERROR_NONE) { - _ERR("Media folder modified time Fetch error"); - goto err; - } - if (media_folder_get_folder_id(folder, &uuid) != MEDIA_CONTENT_ERROR_NONE) { _ERR("failed to fetch media folder id"); @@ -226,11 +254,11 @@ static bool _get_each_folder_info(media_folder_h folder, void *dt) goto err; } - fi->list = eina_list_clone(data->item_list); + gi->list = eina_list_clone(data->item_list); data->media_list = eina_list_merge(data->media_list, data->item_list); data->item_list = NULL; - data->folder_list = eina_list_append(data->folder_list, fi); + data->folder_list = eina_list_append(data->folder_list, gi); media_filter_destroy(filter); free(uuid); @@ -325,3 +353,62 @@ void mediadata_destroy(struct mediadata *md) _destroy_folderlist(md->folder_list); eina_list_free(md->media_list); } + +Eina_List *mediadata_get_list(struct mediadata *md, int list_type) +{ + Eina_List *list, *l; + struct group_info *gi; + app_media *am; + app_media_info *info; + + if (!md) { + _ERR("failed to get mediadata"); + return NULL; + } + + if (list_type < 0 || list_type >= E_LIST_MAX) { + _ERR("invalid argument"); + return NULL; + } + + gi = NULL; + list = NULL; + EINA_LIST_FOREACH(md->media_list, l, am) { + info = app_media_get_info(am); + if (!info) { + _ERR("failed to get media info"); + mediadata_free_list(list); + return NULL; + } + + if (g_list_info[list_type].media_cmp(gi, info)) { + gi = calloc(1, sizeof(*gi)); + if (!gi) { + _ERR("failed to create group info"); + mediadata_free_list(list); + return NULL; + } + + gi->name = g_list_info[list_type].name_get(info); + + list = eina_list_append(list, gi); + } + + gi->list = eina_list_append(gi->list, am); + } + + return list; +} + +void mediadata_free_list(Eina_List *list) +{ + Eina_List *l; + struct group_info *gi; + + EINA_LIST_FOREACH(list, l, gi) { + free(gi->name); + eina_list_free(gi->list); + + free(gi); + } +} -- 2.7.4 From cb05893c72d7bd17c8074a0f6a6d9aa6e84b2cac Mon Sep 17 00:00:00 2001 From: Jehun Lim Date: Wed, 1 Jul 2015 21:50:46 +0900 Subject: [PATCH 16/16] remove gridmgr Change-Id: I7514b7e397626238bee8a3f40203b44042ea691c Signed-off-by: Jehun Lim --- CMakeLists.txt | 1 - include/util/gridmgr.h | 39 ------------ src/util/gridmgr.c | 169 ------------------------------------------------- 3 files changed, 209 deletions(-) delete mode 100644 include/util/gridmgr.h delete mode 100644 src/util/gridmgr.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 848459a..747150e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,7 +53,6 @@ src/view/viewer.c src/layout/movie.c src/layout/gallery.c src/layout/music.c -src/util/gridmgr.c src/util/controller.c src/util/timeout_handler.c src/data/mediadata.c diff --git a/include/util/gridmgr.h b/include/util/gridmgr.h deleted file mode 100644 index 97ba910..0000000 --- a/include/util/gridmgr.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _AIR_MEDIAHUB_GRIDMGR_H__ -#define _AIR_MEDIAHUB_GRIDMGR_H__ - -#include - -struct gridmgr; - -struct grid_class { - const char *grid_style; - - char *(*text_get)(void *data, Evas_Object *obj, const char *part); - Evas_Object *(*content_get)(void *data, Evas_Object *obj, - const char *part); - /* It will be added later */ -}; - -struct gridmgr *gridmgr_create(void); -bool gridmgr_destroy(struct gridmgr *gmgr); -bool gridmgr_add_grid(struct gridmgr *gmgr, const char *grid_id, - Evas_Object *grid, struct grid_class *gclass); -bool gridmgr_update_grid(struct gridmgr *gmgr, const char *grid_id, Eina_List *item_list); - -#endif /* _AIR_MEDIAHUB_GRIDMGR_H__ */ diff --git a/src/util/gridmgr.c b/src/util/gridmgr.c deleted file mode 100644 index 2a7cad9..0000000 --- a/src/util/gridmgr.c +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include - -#include "define.h" -#include "util/gridmgr.h" - -struct gridmgr { - Eina_List *list; -}; - -struct grid_item { - const char *id; - Evas_Object *grid; - struct grid_class *gclass; -}; - -struct grid_item *_get_item_from_id(struct gridmgr *gmgr, const char *id) -{ - Eina_List *l; - struct grid_item *gitem; - - if (!gmgr || !id) - return NULL; - - gitem = NULL; - EINA_LIST_FOREACH(gmgr->list, l, gitem) { - if (!strcmp(gitem->id, id)) - break; - } - - return gitem; -} - -Elm_Gengrid_Item_Class *_get_item_class(struct grid_class *gclass) -{ - Elm_Gengrid_Item_Class *ic; - - if (!gclass) - return NULL; - - ic = elm_gengrid_item_class_new(); - if (!ic) { - _ERR("failed to create item class"); - return NULL; - } - - ic->func.text_get = gclass->text_get; - ic->func.content_get = gclass->content_get; - - ic->item_style = gclass->grid_style; - - return ic; -} - -struct gridmgr *gridmgr_create(void) -{ - struct gridmgr *gmgr; - - gmgr = calloc(1, sizeof(*gmgr)); - if (!gmgr) { - _ERR("failed to create gridmgr"); - return NULL; - } - - return gmgr; -} - -bool gridmgr_destroy(struct gridmgr *gmgr) -{ - struct grid_item *gitem; - - if (!gmgr) { - _ERR("failed to get gridmgr"); - return false; - } - - EINA_LIST_FREE(gmgr->list, gitem) - free(gitem); - - free(gmgr); - gmgr = NULL; - - return true; -} - -bool gridmgr_add_grid(struct gridmgr *gmgr, const char *grid_id, - Evas_Object *grid, struct grid_class *gclass) -{ - struct grid_item *gitem; - - if (!gmgr) { - _ERR("failed to get gridmgr"); - return false; - } - - if (!gclass || !gclass->text_get || !gclass->content_get) { - _ERR("failed to get grid class"); - return false; - } - - gitem = calloc(1, sizeof(*gitem)); - if (!gitem) { - _ERR("failed to create gengrid item"); - return false; - } - - gitem->id = grid_id; - gitem->grid = grid; - gitem->gclass = gclass; - - gmgr->list = eina_list_append(gmgr->list, gitem); - - return true; -} - -bool gridmgr_update_grid(struct gridmgr *gmgr, const char *grid_id, - Eina_List *item_list) -{ - Eina_List *l; - Elm_Object_Item *it; - Elm_Gengrid_Item_Class *ic; - struct grid_item *gitem; - void *data; - - if (!gmgr) { - _ERR("failed to get gridmgr"); - return false; - } - - gitem = _get_item_from_id(gmgr, grid_id); - if (!gitem) { - _ERR("%s doesn't exist", grid_id); - return false; - } - - elm_gengrid_clear(gitem->grid); - - ic = _get_item_class(gitem->gclass); - if (!ic) { - _ERR("failed to get item class"); - return false; - } - - EINA_LIST_FOREACH(item_list, l, data) { - it = elm_gengrid_item_append(gitem->grid, ic, data, NULL, NULL); - - elm_object_item_data_set(it, data); - } - - elm_gengrid_item_class_free(ic); - - return true; -} -- 2.7.4