summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJehun Lim <jehun.lim@samsung.com>2015-09-04 13:15:25 +0900
committerJehun Lim <jehun.lim@samsung.com>2015-09-04 13:24:28 +0900
commit743cb3ad51d3319cf2088aa38d034cf152ce61bd (patch)
tree7ef25c44cd02621454812515d4d3f688e82b3eeb
parentadb8da498d89db262adb90769661dc2e21b09ad2 (diff)
downloadair_mediahub-743cb3ad51d3319cf2088aa38d034cf152ce61bd.tar.gz
air_mediahub-743cb3ad51d3319cf2088aa38d034cf152ce61bd.tar.bz2
air_mediahub-743cb3ad51d3319cf2088aa38d034cf152ce61bd.zip
separate grid related code from layout
Change-Id: Ibe8b46bc30a08248891adcf747a065956919aa7e Signed-off-by: Jehun Lim <jehun.lim@samsung.com>
-rw-r--r--CMakeLists.txt3
-rw-r--r--include/grid/grid.h76
-rw-r--r--src/grid/grid_gallery.c167
-rw-r--r--src/grid/grid_movie.c157
-rw-r--r--src/grid/grid_music.c154
5 files changed, 557 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9baba92..d0eb0e7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -73,6 +73,9 @@ src/util/playermgr.c
src/util/ctxpopup.c
src/util/progressbar.c
src/data/mediadata.c
+src/grid/grid_movie.c
+src/grid/grid_gallery.c
+src/grid/grid_music.c
)
SET(TARGET_EDJ "${PROJECT_NAME}.edj")
diff --git a/include/grid/grid.h b/include/grid/grid.h
new file mode 100644
index 0000000..425843c
--- /dev/null
+++ b/include/grid/grid.h
@@ -0,0 +1,76 @@
+/*
+ * 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_GRID_H__
+#define __AIR_MEDIAHUB_GRID_H__
+
+enum movie_grid_type {
+ E_MOVIE_NAME = 0,
+ E_MOVIE_GENRE,
+ E_MOVIE_DATE,
+ E_MOVIE_FOLDER,
+ E_MOVIE_MAX
+};
+
+enum gallery_grid_type {
+ E_GALLERY_EVENT,
+ E_GALLERY_PLACE,
+ E_GALLERY_VIDEO,
+ E_GALLERY_FOLDER,
+ E_GALLERY_MAX
+};
+
+enum music_grid_type {
+ E_MUSIC_SONG,
+ E_MUSIC_ALBUM,
+ E_MUSIC_ARTIST,
+ E_MUSIC_GENRE,
+ E_MUSIC_FOLDER,
+ E_MUSIC_MAX
+};
+
+struct grid_data {
+ int item_x;
+ int item_y;
+ int item_num;
+ struct grid_class *gclass;
+ Eina_List *(*get_item_list)(struct mediadata *md);
+ void (*item_selected)(Eina_List *list, app_media *am);
+};
+
+struct grid_data *get_movie_grid_data(int type);
+struct grid_data *get_gallery_grid_data(int type);
+struct grid_data *get_music_grid_data(int type);
+
+#define STYLE_MOVIE_NAME "movie_item"
+#define MOVIE_NAME_PADDING 26
+#define MOVIE_NAME_ITEM_X (378 + MOVIE_NAME_PADDING)
+#define MOVIE_NAME_ITEM_Y (294 + MOVIE_NAME_PADDING)
+#define MOVIE_NAME_ITEM_NUM 2
+
+#define STYLE_GALLERY_EVENT "gallery_item"
+#define GALLERY_EVENT_PADDING 6
+#define GALLERY_EVENT_ITEM_X (200 + GALLERY_EVENT_PADDING)
+#define GALLERY_EVENT_ITEM_Y (200 + GALLERY_EVENT_PADDING)
+#define GALLERY_EVENT_ITEM_NUM 3
+
+#define STYLE_MUSIC_SONG "song_item"
+#define MUSIC_SONG_PADDING 26
+#define MUSIC_SONG_ITEM_X (488 + MUSIC_SONG_PADDING)
+#define MUSIC_SONG_ITEM_Y (134 + MUSIC_SONG_PADDING)
+#define MUSIC_SONG_ITEM_NUM 4
+
+#endif /* __AIR_MEDIAHUB_GRID_H__ */
diff --git a/src/grid/grid_gallery.c b/src/grid/grid_gallery.c
new file mode 100644
index 0000000..5e5f1dd
--- /dev/null
+++ b/src/grid/grid_gallery.c
@@ -0,0 +1,167 @@
+/*
+ * 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 <Elementary.h>
+#include <media_content.h>
+#include <app_debug.h>
+#include <app_contents.h>
+#include <app_media.h>
+#include <gridmgr.h>
+#include <viewmgr.h>
+
+#include "define.h"
+#include "view.h"
+#include "data/mediadata.h"
+#include "grid/grid.h"
+#include "util/util.h"
+
+static char *_grid_text_get(void *data, Evas_Object *obj, const char *part)
+{
+ app_media *am;
+ app_media_info *info;
+ char buf[32];
+
+ if (!data)
+ return NULL;
+
+ am = data;
+
+ info = app_media_get_info(am);
+ if (!info) {
+ _ERR("failed to get media info");
+ return NULL;
+ }
+
+ if (info->media_type != MEDIA_CONTENT_TYPE_VIDEO)
+ return NULL;
+
+ if (!strcmp(part, PART_ELM_TEXT_PLAYTIME)) {
+ util_time_string(buf, sizeof(buf),
+ info->video->duration, false);
+
+ return strdup(buf);
+ }
+
+ return NULL;
+}
+
+static Evas_Object *_grid_content_get(void *data,
+ Evas_Object *obj, const char *part)
+{
+ Evas_Object *eo;
+ app_media *am;
+ app_media_info *info;
+
+ if (!data)
+ return NULL;
+
+ am = data;
+
+ info = app_media_get_info(am);
+ if (!info) {
+ _ERR("failed to get media info");
+ return NULL;
+ }
+
+ eo = NULL;
+ if (!strcmp(part, PART_ELM_SWALLOW_THUMBNAIL)) {
+ eo = util_add_image(obj, info->thumbnail_path);
+ if (!eo) {
+ _ERR("failed to create image object");
+ return NULL;
+ }
+ } else if (!strcmp(part, PART_ELM_SWALLOW_VIDEO)) {
+ if (info->media_type != MEDIA_CONTENT_TYPE_VIDEO)
+ return NULL;
+
+ eo = util_add_image(obj, IMAGE_THUMBNAIL_PLAY);
+ if (!eo) {
+ _ERR("failed to create image object");
+ return NULL;
+ }
+ } else if (!strcmp(part, PART_ELM_SWALLOW_FAVORITE)) {
+ if (!info->favorite)
+ return NULL;
+
+ eo = util_add_image(obj, IMAGE_THUMBNAIL_FAVORITE);
+ if (!eo) {
+ _ERR("failed to create image object");
+ return NULL;
+ }
+ }
+
+ if (eo)
+ evas_object_show(eo);
+
+ return eo;
+}
+
+static Eina_List *_get_item_list(struct mediadata *md)
+{
+ if (!md) {
+ _ERR("invalid argument");
+ return NULL;
+ }
+
+ return mediadata_get_list(md, E_LIST_DATE);
+}
+
+static void _item_selected(Eina_List *list, app_media *am)
+{
+ struct view_update_data vdata;
+
+ if (!list || !am) {
+ _ERR("invalid argument");
+ return;
+ }
+
+ vdata.list = list;
+ vdata.index = util_get_media_index(list, am);
+
+ viewmgr_update_view(VIEW_VIEWER, UPDATE_CONTENT, &vdata);
+ viewmgr_push_view(VIEW_VIEWER);
+}
+
+static struct grid_class _gclass[] = {
+ [E_GALLERY_EVENT] = {
+ .item_style = STYLE_GALLERY_EVENT,
+ .text_get = _grid_text_get,
+ .content_get = _grid_content_get
+ },
+ /* Other view mode class will be added later */
+};
+
+static struct grid_data _gdata[] = {
+ [E_GALLERY_EVENT] = {
+ .item_x = GALLERY_EVENT_ITEM_X,
+ .item_y = GALLERY_EVENT_ITEM_Y,
+ .item_num = GALLERY_EVENT_ITEM_NUM,
+ .gclass = &_gclass[E_GALLERY_EVENT],
+ .get_item_list = _get_item_list,
+ .item_selected = _item_selected
+ },
+ /* Other view mode data will be added later */
+};
+
+struct grid_data *get_gallery_grid_data(int type)
+{
+ if (type < 0 || type >= E_GALLERY_MAX) {
+ _ERR("invalid argument");
+ return NULL;
+ }
+
+ return &_gdata[type];
+}
diff --git a/src/grid/grid_movie.c b/src/grid/grid_movie.c
new file mode 100644
index 0000000..60ab310
--- /dev/null
+++ b/src/grid/grid_movie.c
@@ -0,0 +1,157 @@
+/*
+ * 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 <Elementary.h>
+#include <media_content.h>
+#include <app_debug.h>
+#include <app_contents.h>
+#include <app_media.h>
+#include <gridmgr.h>
+#include <viewmgr.h>
+
+#include "define.h"
+#include "view.h"
+#include "data/mediadata.h"
+#include "grid/grid.h"
+#include "util/util.h"
+
+static char *_grid_text_get(void *data, Evas_Object *obj, const char *part)
+{
+ app_media *am;
+ app_media_info *info;
+
+ if (!data)
+ return NULL;
+
+ am = data;
+
+ info = app_media_get_info(am);
+ if (!info) {
+ _ERR("failed to get media info");
+ return NULL;
+ }
+
+ return strdup(info->title);
+}
+
+static Evas_Object *_grid_content_get(void *data, Evas_Object *obj,
+ const char *part)
+{
+ Evas_Object *eo;
+ app_media *am;
+ app_media_info *info;
+ struct color_data bg;
+
+ if (!data)
+ return NULL;
+
+ am = data;
+
+ info = app_media_get_info(am);
+ if (!info) {
+ _ERR("failed to get media info");
+ return NULL;
+ }
+
+ eo = NULL;
+ if (!strcmp(part, PART_ELM_SWALLOW_THUMBNAIL)) {
+ eo = util_add_image(obj, info->thumbnail_path);
+ if (!eo) {
+ _ERR("failed to create image object");
+ return NULL;
+ }
+ } else if (!strcmp(part, PART_ELM_SWALLOW_FAVORITE)) {
+ if (!info->favorite)
+ return NULL;
+
+ eo = util_add_image(obj, IMAGE_THUMBNAIL_FAVORITE);
+ if (!eo) {
+ _ERR("failed to create image object");
+ return NULL;
+ }
+ } else if (!strcmp(part, PART_ELM_SWALLOW_TEXTBG)) {
+ eo = evas_object_rectangle_add(obj);
+ if (!eo) {
+ _ERR("failed to create rectangle object");
+ return NULL;
+ }
+
+ app_contents_get_color(info->title, NULL, &bg);
+ evas_object_color_set(eo, bg.r, bg.g, bg.b, bg.a);
+ }
+
+ if (eo)
+ evas_object_show(eo);
+
+ return eo;
+}
+
+static Eina_List *_get_item_list(struct mediadata *md)
+{
+ if (!md) {
+ _ERR("invalid argument");
+ return NULL;
+ }
+
+ return mediadata_get_list(md, E_LIST_NAME);
+}
+
+static void _item_selected(Eina_List *list, app_media *am)
+{
+ struct view_update_data vdata;
+
+ if (!list || !am) {
+ _ERR("invalid argument");
+ return;
+ }
+
+ vdata.list = list;
+ vdata.index = util_get_media_index(list, am);
+
+ viewmgr_update_view(VIEW_VIEWER, UPDATE_CONTENT, &vdata);
+ viewmgr_push_view(VIEW_VIEWER);
+}
+
+static struct grid_class _gclass[] = {
+ [E_MOVIE_NAME] = {
+ .item_style = STYLE_MOVIE_NAME,
+ .text_get = _grid_text_get,
+ .content_get = _grid_content_get
+ },
+ /* Other view mode class will be added later */
+};
+
+static struct grid_data _gdata[] = {
+ [E_MOVIE_NAME] = {
+ .item_x = MOVIE_NAME_ITEM_X,
+ .item_y = MOVIE_NAME_ITEM_Y,
+ .item_num = MOVIE_NAME_ITEM_NUM,
+ .gclass = &_gclass[E_MOVIE_NAME],
+ .get_item_list = _get_item_list,
+ .item_selected = _item_selected
+ },
+ /* Other view mode data will be added later */
+};
+
+struct grid_data *get_movie_grid_data(int type)
+{
+ if (type < 0 || type >= E_MOVIE_MAX) {
+ _ERR("invalid argument");
+ return NULL;
+ }
+
+ return &_gdata[type];
+}
diff --git a/src/grid/grid_music.c b/src/grid/grid_music.c
new file mode 100644
index 0000000..c4e7573
--- /dev/null
+++ b/src/grid/grid_music.c
@@ -0,0 +1,154 @@
+/*
+ * 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 <Elementary.h>
+#include <media_content.h>
+#include <app_debug.h>
+#include <app_contents.h>
+#include <app_media.h>
+#include <gridmgr.h>
+#include <viewmgr.h>
+
+#include "define.h"
+#include "view.h"
+#include "data/mediadata.h"
+#include "grid/grid.h"
+#include "util/util.h"
+
+static char *_grid_text_get(void *data, Evas_Object *obj, const char *part)
+{
+ app_media *am;
+ app_media_info *info;
+
+ if (!data)
+ return NULL;
+
+ am = data;
+
+ info = app_media_get_info(am);
+ if (!info) {
+ _ERR("failed to get media info");
+ return NULL;
+ }
+
+ if (!strcmp(part, PART_ELM_TEXT_TITLE))
+ return strdup(info->title);
+ else if (!strcmp(part, PART_ELM_TEXT_ARTIST))
+ return strdup(info->audio->artist);
+ else if (!strcmp(part, PART_ELM_TEXT_ALBUM))
+ return strdup(info->audio->album);
+
+ return NULL;
+}
+
+static Evas_Object *_grid_content_get(void *data,
+ Evas_Object *obj, const char *part)
+{
+ Evas_Object *eo;
+ app_media *am;
+ app_media_info *info;
+
+ if (!data)
+ return NULL;
+
+ am = data;
+
+ info = app_media_get_info(am);
+ if (!info) {
+ _ERR("failed to get media info");
+ return NULL;
+ }
+
+ eo = NULL;
+ if (!strcmp(part, PART_ELM_SWALLOW_THUMBNAIL)) {
+ eo = util_add_image(obj, info->thumbnail_path);
+ if (!eo) {
+ _ERR("failed to create image object");
+ return NULL;
+ }
+ } else if (!strcmp(part, PART_ELM_SWALLOW_FAVORITE)) {
+ if (!info->favorite)
+ return NULL;
+
+ eo = util_add_image(obj, IMAGE_THUMBNAIL_FAVORITE);
+ if (!eo) {
+ _ERR("failed to create image object");
+ return NULL;
+ }
+ }
+
+ if (eo)
+ evas_object_show(eo);
+
+ return eo;
+}
+
+static Eina_List *_get_item_list(struct mediadata *md)
+{
+ if (!md) {
+ _ERR("invalid argument");
+ return NULL;
+ }
+
+ return mediadata_get_list(md, E_LIST_NAME);
+}
+
+static void _item_selected(Eina_List *list, app_media *am)
+{
+ struct view_update_data vdata;
+
+ if (!list || !am) {
+ _ERR("invalid argument");
+ return;
+ }
+
+ vdata.list = list;
+ vdata.index = util_get_media_index(list, am);
+
+ viewmgr_update_view(VIEW_MPLAYER, UPDATE_CONTENT, &vdata);
+ viewmgr_push_view(VIEW_MPLAYER);
+}
+
+static struct grid_class _gclass[] = {
+ [E_MUSIC_SONG] = {
+ .item_style = STYLE_MUSIC_SONG,
+ .text_get = _grid_text_get,
+ .content_get = _grid_content_get
+ },
+ /* Other view mode class will be added later */
+};
+
+static struct grid_data _gdata[] = {
+ [E_MUSIC_SONG] = {
+ .item_x = MUSIC_SONG_ITEM_X,
+ .item_y = MUSIC_SONG_ITEM_Y,
+ .item_num = MUSIC_SONG_ITEM_NUM,
+ .gclass = &_gclass[E_MUSIC_SONG],
+ .get_item_list = _get_item_list,
+ .item_selected = _item_selected
+ },
+ /* Other view mode data will be added later */
+};
+
+struct grid_data *get_music_grid_data(int type)
+{
+ if (type < 0 || type >= E_MUSIC_MAX) {
+ _ERR("invalid argument");
+ return NULL;
+ }
+
+ return &_gdata[type];
+}