summaryrefslogtreecommitdiff
path: root/src/view/viewer.c
diff options
context:
space:
mode:
authorMinkyu Kang <mk7.kang@samsung.com>2015-09-14 20:49:13 +0900
committerMinkyu Kang <mk7.kang@samsung.com>2015-09-14 20:49:13 +0900
commit9b250fabf4960e8cc9e12259f206f5d8cf4c3828 (patch)
treee992fb24f44b0654b9570622f2d40997ca3b9f61 /src/view/viewer.c
parentcd93594a7b043b19dd0409d9b0ff79661244db9f (diff)
downloadair_mediahub-9b250fabf4960e8cc9e12259f206f5d8cf4c3828.tar.gz
air_mediahub-9b250fabf4960e8cc9e12259f206f5d8cf4c3828.tar.bz2
air_mediahub-9b250fabf4960e8cc9e12259f206f5d8cf4c3828.zip
viewer: adds support slide show
Change-Id: Ia9d03f1051f2c90f865f46e5f7199604254889eb Signed-off-by: Minkyu Kang <mk7.kang@samsung.com>
Diffstat (limited to 'src/view/viewer.c')
-rw-r--r--src/view/viewer.c114
1 files changed, 108 insertions, 6 deletions
diff --git a/src/view/viewer.c b/src/view/viewer.c
index 5e007ab..3c460bd 100644
--- a/src/view/viewer.c
+++ b/src/view/viewer.c
@@ -40,6 +40,7 @@
#define POSITION_MARGIN 500
#define VIEWER_TIMEOUT 3.0
#define VIEWER_SEPARATOR "/ "
+#define SLIDE_SHOW_INTERVAL 3.0
#define VIDEO_COPYRIGHT "Unknown"
#define BTN_LOC_NONE -1
@@ -48,6 +49,7 @@
#define BTN_LOC_NEXT 4
#define BTN_LOC_ROTATE 5
#define BTN_LOC_ZOOM 6
+#define BTN_LOC_SLIDE 8
enum {
VIEWER_MOVIE,
@@ -67,6 +69,11 @@ struct _playlist {
int cur;
};
+struct _slideshow {
+ Ecore_Timer *timer;
+ bool enable;
+};
+
struct _priv {
Evas_Object *win;
Evas_Object *base;
@@ -78,6 +85,7 @@ struct _priv {
struct timeout_handler *timeout;
struct playermgr *player;
struct progressbar *progress;
+ struct _slideshow slideshow;
bool bar_show;
};
@@ -119,6 +127,10 @@ static struct _btn_info btn_photo[] = {
.name = SRC_BTN_ZOOM,
.loc = BTN_LOC_ZOOM,
},
+ {
+ .name = SRC_BTN_SLIDE,
+ .loc = BTN_LOC_SLIDE,
+ },
};
static struct _btn_info btn_video[] = {
@@ -134,6 +146,10 @@ static struct _btn_info btn_video[] = {
.name = SRC_BTN_GALLERY_NEXT,
.loc = BTN_LOC_NEXT,
},
+ {
+ .name = SRC_BTN_SLIDE,
+ .loc = BTN_LOC_SLIDE,
+ },
};
struct _viewer_info {
@@ -150,6 +166,10 @@ 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 void _slideshow_set(struct _priv *priv);
+static void _slideshow_enable(struct _priv *priv);
+static void _slideshow_disable(struct _priv *priv);
+
static struct _viewer_info viewer_info[] = {
{
.btns = btn_movie,
@@ -159,13 +179,13 @@ static struct _viewer_info viewer_info[] = {
},
{
.btns = btn_photo,
- .btn_count = 4,
+ .btn_count = 5,
.focus_loc = BTN_LOC_NEXT,
.callback = _callback_photo,
},
{
.btns = btn_video,
- .btn_count = 3,
+ .btn_count = 4,
.focus_loc = BTN_LOC_NEXT,
.callback = _callback_video,
},
@@ -279,8 +299,14 @@ static void _draw_contents(struct _priv *priv, int id, app_media_info *mi)
_player_play(priv);
return;
} else if (id == VIEWER_VIDEO) {
- _draw_thumbnail(priv, mi);
+ if (priv->slideshow.enable)
+ _player_play(priv);
+ else
+ _draw_thumbnail(priv, mi);
return;
+ } else if (id == VIEWER_PHOTO) {
+ if (priv->slideshow.enable)
+ _slideshow_set(priv);
}
if (!mi->file_path)
@@ -535,7 +561,8 @@ static bool _viewer_show(struct _priv *priv)
ctl = priv->viewer.ctl[id];
priv->viewer.cur = id;
- ctl->ops->show(ctl->handle);
+ if (!priv->slideshow.enable)
+ ctl->ops->show(ctl->handle);
loc = priv->viewer.foc;
if (loc == BTN_LOC_NONE) {
@@ -684,6 +711,49 @@ static void _hide_bar(struct _priv *priv)
ctl->ops->disable(ctl->handle);
}
+static Eina_Bool _slideshow_next(void *data)
+{
+ struct _priv *priv;
+
+ if (!data)
+ return ECORE_CALLBACK_CANCEL;
+
+ priv = data;
+
+ priv->slideshow.timer = NULL;
+
+ if (!priv->slideshow.enable)
+ return ECORE_CALLBACK_CANCEL;
+
+ _viewer_next(priv);
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
+static void _slideshow_set(struct _priv *priv)
+{
+ if (priv->slideshow.timer)
+ return;
+
+ priv->slideshow.timer = ecore_timer_add(SLIDE_SHOW_INTERVAL,
+ _slideshow_next, priv);
+}
+
+static void _slideshow_enable(struct _priv *priv)
+{
+ priv->slideshow.enable = true;
+}
+
+static void _slideshow_disable(struct _priv *priv)
+{
+ priv->slideshow.enable = false;
+
+ if (priv->slideshow.timer) {
+ ecore_timer_del(priv->slideshow.timer);
+ priv->slideshow.timer = NULL;
+ }
+}
+
static void _pop_view(struct _priv *priv)
{
struct view_update_data vdata;
@@ -864,8 +934,11 @@ static void _player_complete_cb(void *data)
_pop_view(priv);
} else if (priv->viewer.cur == VIEWER_VIDEO) {
_player_stop(priv);
- _viewer_show(priv);
- _show_bar(data);
+
+ if (priv->slideshow.enable)
+ _viewer_next(priv);
+ else
+ _viewer_show(priv);
}
}
@@ -910,6 +983,10 @@ static void _callback_photo(void *data, const char *ev)
_viewer_show(priv);
} else if (!strcmp(ev, SRC_BTN_ZOOM)) {
_set_image_zoom(priv);
+ } else if (!strcmp(ev, SRC_BTN_SLIDE)) {
+ _slideshow_enable(priv);
+ _hide_bar(priv);
+ _viewer_show(priv);
}
}
@@ -930,6 +1007,10 @@ static void _callback_video(void *data, const char *ev)
_viewer_next(priv);
} else if (!strcmp(ev, SRC_BTN_PLAY)) {
_player_play_pause(priv);
+ } else if (!strcmp(ev, SRC_BTN_SLIDE)) {
+ _slideshow_enable(priv);
+ _hide_bar(priv);
+ _viewer_show(priv);
}
}
@@ -957,6 +1038,20 @@ static Eina_Bool _event_cb(void *data, int type, void *ei)
ev = ei;
+ if (priv->slideshow.enable) {
+ if (!strcmp(ev->keyname, KEY_BACK) ||
+ !strcmp(ev->keyname, KEY_BACK_REMOTE)) {
+ if (priv->viewer.cur == VIEWER_VIDEO)
+ _player_stop(priv);
+
+ _slideshow_disable(priv);
+ _viewer_show(priv);
+ _show_bar(priv);
+ }
+
+ return ECORE_CALLBACK_DONE;
+ }
+
if (!strcmp(ev->keyname, KEY_BACK) ||
!strcmp(ev->keyname, KEY_BACK_REMOTE)) {
if (priv->bar_show) {
@@ -996,6 +1091,9 @@ static Eina_Bool _event_cb(void *data, int type, void *ei)
_viewer_prev(priv);
}
}
+ } else {
+ if (priv->slideshow.enable)
+ return ECORE_CALLBACK_DONE;
}
_show_bar(data);
@@ -1078,6 +1176,8 @@ static Evas_Object *_create(Evas_Object *win, void *data)
priv->playlist.cur = 0;
priv->viewer.foc = BTN_LOC_NONE;
+ _slideshow_disable(priv);
+
player = playermgr_create(win);
if (!player) {
_ERR("failed to create player");
@@ -1156,6 +1256,7 @@ static void _hide(void *view_data)
priv = view_data;
+ _slideshow_disable(priv);
_viewer_hide(priv);
timeout_handler_enable(priv->timeout, false);
@@ -1187,6 +1288,7 @@ static void _update(void *view_data, int update_type, void *data)
priv->playlist.list = vdata->list;
priv->playlist.cur = vdata->index;
priv->viewer.foc = BTN_LOC_NONE;
+ priv->slideshow.enable = false;
break;
default:
break;