#include <Elementary.h>
#include <app_debug.h>
+#include <app_contents.h>
#include <inputmgr.h>
#include <viewmgr.h>
#include "define.h"
+#include "view.h"
#include "util/util.h"
#define TEXT_LIVETV "Live TV"
+#define TEXT_FAVORITE "Favorite"
+
+#define VIDEO_COPYRIGHT "Unknown"
#define MAX_NUM_MENU 4
enum _object_type {
ACTION_LIVETV_BTN = 0,
- ACTION_MENU_BTN
+ ACTION_MENU_BTN,
+ ACTION_FAVORITE_GRID
+};
+
+enum _content_type {
+ E_CONTENT_MOVIE = 0,
+ E_CONTENT_GALLERY,
+ E_CONTENT_MUSIC,
+ E_CONTENT_MAX
};
struct _priv {
Evas_Object *tv_btn;
Evas_Object *menu_btn[MAX_NUM_MENU];
+ Evas_Object *grid;
};
struct _menu_info {
Eina_Bool disabled;
};
+struct _content_info {
+ int grid_x;
+ int grid_y;
+ const char *style;
+
+ int app_contents_type;
+};
+
static struct _menu_info menu_info[] = {
{
.title = "Favorite",
}
};
+struct _content_info content_info[] = {
+ {
+ .grid_x = GRID_ITEM_X_MOVIE,
+ .grid_y = GRID_ITEM_Y_MOVIE,
+ .style = STYLE_GRID_MOVIE_ITEM_FAVORITE,
+ .app_contents_type = CONTENTS_MOVIE
+ },
+ {
+ .grid_x = GRID_ITEM_X_GALLERY,
+ .grid_y = GRID_ITEM_Y_GALLERY,
+ .style = STYLE_GRID_GALLERY_ITEM_FAVORITE,
+ .app_contents_type = CONTENTS_GALLERY
+ },
+ {
+ .grid_x = GRID_ITEM_X_MUSIC,
+ .grid_y = GRID_ITEM_Y_MUSIC,
+ .style = STYLE_GRID_SONG_ITEM_FAVORITE,
+ .app_contents_type = CONTENTS_MUSIC
+ }
+};
+
static void _key_down_cb(int id, void *data, Evas *e, Evas_Object *obj,
Evas_Event_Key_Down *ev)
{
static void _mouse_move_cb(int id, void *data, Evas *e, Evas_Object *obj,
Evas_Event_Mouse_Move *ev)
{
- if (!obj)
+ Elm_Object_Item *it;
+
+ if (!obj || !ev)
return;
- if (!elm_object_focus_get(obj))
- elm_object_focus_set(obj, EINA_TRUE);
+ switch (id) {
+ case ACTION_LIVETV_BTN:
+ case ACTION_MENU_BTN:
+ if (!elm_object_focus_get(obj))
+ elm_object_focus_set(obj, EINA_TRUE);
+
+ break;
+ case ACTION_FAVORITE_GRID:
+ it = elm_gengrid_at_xy_item_get(obj, ev->cur.canvas.x,
+ ev->cur.canvas.y, NULL, NULL);
+
+ if (!it)
+ return;
+
+ if (!elm_object_item_focus_get(it))
+ elm_object_item_focus_set(it, EINA_TRUE);
+
+ break;
+ }
}
static input_handler _handler = {
.mouse_move = _mouse_move_cb
};
+static bool _check_movie_type(app_media_info *info)
+{
+ return strcmp(info->video->copyright, VIDEO_COPYRIGHT);
+}
+
+static int _get_content_type(app_media_info *info)
+{
+ int type;
+
+ type = E_CONTENT_MAX;
+ switch (info->media_type) {
+ case MEDIA_CONTENT_TYPE_IMAGE:
+ type = E_CONTENT_GALLERY;
+ break;
+ case MEDIA_CONTENT_TYPE_VIDEO:
+ if (_check_movie_type(info))
+ type = E_CONTENT_MOVIE;
+ else
+ type = E_CONTENT_GALLERY;
+ break;
+ case MEDIA_CONTENT_TYPE_MUSIC:
+ type = E_CONTENT_MUSIC;
+ break;
+ default:
+ break;
+ }
+
+ return type;
+}
+
static bool _draw_livetv_btn(struct _priv *priv)
{
Evas_Object *btn;
return true;
}
+static bool _draw_favorite_area(struct _priv *priv)
+{
+ Evas_Object *grid;
+
+ elm_object_part_text_set(priv->base, PART_ACTION_FAVORITE_TITLE,
+ TEXT_FAVORITE);
+
+ grid = util_add_gengrid(priv->base, 0, 0, EINA_FALSE);
+ if (!grid) {
+ _ERR("failed to create gengrid object");
+ return false;
+ }
+
+ inputmgr_add_callback(grid, ACTION_FAVORITE_GRID, &_handler, priv);
+
+ elm_object_focus_next_object_set(grid, grid, ELM_FOCUS_LEFT);
+ elm_object_focus_next_object_set(grid, grid, ELM_FOCUS_RIGHT);
+
+ elm_object_part_content_set(priv->base,
+ PART_ACTION_FAVORITE_AREA, grid);
+
+ priv->grid = grid;
+
+ return true;
+}
+
+static void _update_favorite_area(struct _priv *priv, int type)
+{
+ /* It will implemented later */
+}
+
static bool _draw_items(struct _priv *priv)
{
if (!_draw_livetv_btn(priv)) {
return false;
}
+ if (!_draw_favorite_area(priv)) {
+ _ERR("failed to draw favorite area");
+ return false;
+ }
+
if (!_draw_menu_area(priv)) {
_ERR("failed to draw menu button");
return false;
return true;
}
+static bool _update_items(struct _priv *priv, struct view_update_data *vdata)
+{
+ app_media *am;
+ app_media_info *mi;
+ int type;
+
+ am = eina_list_nth(vdata->list, vdata->index);
+ if (!am) {
+ _ERR("failed to get app media");
+ return false;
+ }
+
+ mi = app_media_get_info(am);
+ if (!mi) {
+ _ERR("failed to get app media info");
+ return false;
+ }
+
+ type = _get_content_type(mi);
+
+ _update_favorite_area(priv, type);
+
+ return true;
+}
+
static Evas_Object *_create(Evas_Object *win, void *data)
{
struct _priv *priv;
evas_object_hide(priv->base);
}
+static void _update(void *view_data, int update_type, void *data)
+{
+ struct _priv *priv;
+
+ if (!view_data) {
+ _ERR("failed to get view data");
+ return;
+ }
+
+ if (!data) {
+ _ERR("invalid argument");
+ return;
+ }
+
+ priv = view_data;
+
+ switch (update_type) {
+ case UPDATE_CONTENT:
+ _update_items(priv, data);
+ break;
+ default:
+ break;
+ }
+}
+
static void _destroy(void *view_data)
{
struct _priv *priv;
priv = view_data;
inputmgr_remove_callback(priv->tv_btn, &_handler);
+ inputmgr_remove_callback(priv->grid, &_handler);
for (i = 0; i < MAX_NUM_MENU; i++)
inputmgr_remove_callback(priv->menu_btn[i], &_handler);
.create = _create,
.show = _show,
.hide = _hide,
+ .update = _update,
.destroy = _destroy,
};