viewer: adds support slide show 09/48109/1
authorMinkyu Kang <mk7.kang@samsung.com>
Mon, 14 Sep 2015 11:49:13 +0000 (20:49 +0900)
committerMinkyu Kang <mk7.kang@samsung.com>
Mon, 14 Sep 2015 11:49:13 +0000 (20:49 +0900)
Change-Id: Ia9d03f1051f2c90f865f46e5f7199604254889eb
Signed-off-by: Minkyu Kang <mk7.kang@samsung.com>
include/view/viewer.h
res/edc/images/btn_view_contr_slideshow_foc.png [new file with mode: 0644]
res/edc/images/btn_view_contr_slideshow_nor.png [new file with mode: 0644]
res/edc/view/viewer.edc
res/edc/widgets/button.edc
src/util/controller.c
src/view/viewer.c

index 559402b..11744a2 100644 (file)
@@ -59,6 +59,7 @@
 #define SRC_BTN_GALLERY_NEXT "next_gallery"
 #define SRC_BTN_ROTATE "rotate"
 #define SRC_BTN_ZOOM "zoom"
+#define SRC_BTN_SLIDE "slide"
 
 /* images */
 #define IMAGE_VIEWER_FAVORITE "ic_title_favorite.png"
@@ -82,5 +83,7 @@
 #define IMAGE_VIEWER_ROTATE_NORMAL "btn_view_contr_rotate_nor.png"
 #define IMAGE_VIEWER_ZOOM_FOCUS "btn_view_contr_zoom_foc.png"
 #define IMAGE_VIEWER_ZOOM_NORMAL "btn_view_contr_zoom_nor.png"
+#define IMAGE_VIEWER_SLIDE_FOCUS "btn_view_contr_slideshow_foc.png"
+#define IMAGE_VIEWER_SLIDE_NORMAL "btn_view_contr_slideshow_nor.png"
 
 #endif /* __AIR_MEDIAHUB_VIEW_VIEWER_H__ */
diff --git a/res/edc/images/btn_view_contr_slideshow_foc.png b/res/edc/images/btn_view_contr_slideshow_foc.png
new file mode 100644 (file)
index 0000000..413aefb
Binary files /dev/null and b/res/edc/images/btn_view_contr_slideshow_foc.png differ
diff --git a/res/edc/images/btn_view_contr_slideshow_nor.png b/res/edc/images/btn_view_contr_slideshow_nor.png
new file mode 100644 (file)
index 0000000..e9ec7d2
Binary files /dev/null and b/res/edc/images/btn_view_contr_slideshow_nor.png differ
index 29dd7a6..79f47b8 100644 (file)
@@ -425,6 +425,46 @@ group {
                        }
                }
                part {
+                       name: "control_btn7";
+                       type: SWALLOW;
+                       clip_to: "bottomarea";
+                       scale: 1;
+                       description {
+                               state: "default" 0.0;
+                               min: 114 143;
+                               rel1 {
+                                       to: "control_btn8";
+                                       relative: 0.0 0.5;
+                               }
+                               rel2 {
+                                       to: "control_btn8";
+                                       relative: 0.0 0.5;
+                               }
+                               fixed: 1 1;
+                               align: 1.0 0.5;
+                       }
+               }
+               part {
+                       name: "control_btn8";
+                       type: SWALLOW;
+                       clip_to: "bottomarea";
+                       scale: 1;
+                       description {
+                               state: "default" 0.0;
+                               min: 114 143;
+                               rel1 {
+                                       to: "bottomarea";
+                                       relative: 1.0 0.0;
+                               }
+                               rel2 {
+                                       to: "bottomarea";
+                                       relative: 1.0 1.0;
+                               }
+                               fixed: 1 1;
+                               align: 1.0 0.5;
+                       }
+               }
+               part {
                        name: "padding_time";
                        type: SPACER;
                        scale: 1;
index c77653f..3cade19 100644 (file)
@@ -497,7 +497,7 @@ group {
                        name: SIG_SET_UNFOCUS;
                        signal: SIG_SET_UNFOCUS;
                        source: "";
-                       action: STATE_SET "selected" 0.0;
+                       action: STATE_SET "default" 0.0;
                        target: "bg";
                        target: "color";
                }
@@ -1045,6 +1045,46 @@ group {
 }
 
 group {
+       name: "elm/button/base/viewer_btn_slide";
+       inherit: "elm/button/base/viewer_btn_rotate";
+       images {
+               image: IMAGE_VIEWER_SLIDE_NORMAL COMP;
+               image: IMAGE_VIEWER_SLIDE_FOCUS COMP;
+       }
+       parts {
+               part {
+                       name: "bg";
+                       scale: 1;
+                       description {
+                               state: "default" 0.0;
+                               image {
+                                       normal: IMAGE_VIEWER_SLIDE_NORMAL;
+                               }
+                       }
+                       description {
+                               state: "selected" 0.0;
+                               inherit: "default" 0.0;
+                               image {
+                                       normal: IMAGE_VIEWER_SLIDE_FOCUS;
+                               }
+                       }
+                       description {
+                               state: "clicked" 0.0;
+                               image {
+                                       normal: IMAGE_VIEWER_SLIDE_FOCUS;
+                               }
+                       }
+               }
+       }
+       programs {
+               program {
+                       name: "emit,signal";
+                       action: SIGNAL_EMIT SIG_BTN_CALLBACK SRC_BTN_SLIDE;
+               }
+       }
+}
+
+group {
        name: "elm/button/base/music_btn_prev";
        inherit: "elm/button/base/viewer_btn_prev";
        images {
index 942c201..a6d51d0 100644 (file)
@@ -274,6 +274,7 @@ static void _hide(void *handle)
                if (!ctl->obj)
                        continue;
 
+               elm_object_signal_emit(ctl->obj, SIG_SET_UNFOCUS, "");
                elm_object_focus_set(ctl->obj, false);
 
                evas_object_hide(ctl->obj);
index 5e007ab..3c460bd 100644 (file)
@@ -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;