summaryrefslogtreecommitdiff
path: root/src/view/viewer.c
diff options
context:
space:
mode:
authorMinkyu Kang <mk7.kang@samsung.com>2015-08-31 15:26:42 +0900
committerMinkyu Kang <mk7.kang@samsung.com>2015-08-31 15:26:42 +0900
commit2402daa162b8e90309fe03482bc1d8a5dd640dfa (patch)
tree6b01d67dfa90251bdfbd2b901070ddf3a8dcdf73 /src/view/viewer.c
parent7e5a2cfcc325051357db973300b17cfabb789b63 (diff)
downloadair_mediahub-2402daa162b8e90309fe03482bc1d8a5dd640dfa.tar.gz
air_mediahub-2402daa162b8e90309fe03482bc1d8a5dd640dfa.tar.bz2
air_mediahub-2402daa162b8e90309fe03482bc1d8a5dd640dfa.zip
viewer: adds support rotating image
Change-Id: I058640a6d39668a20b491ddc5eb9dbd020f40763 Signed-off-by: Minkyu Kang <mk7.kang@samsung.com>
Diffstat (limited to 'src/view/viewer.c')
-rw-r--r--src/view/viewer.c74
1 files changed, 53 insertions, 21 deletions
diff --git a/src/view/viewer.c b/src/view/viewer.c
index 6fd38d5..a29d1d8 100644
--- a/src/view/viewer.c
+++ b/src/view/viewer.c
@@ -41,6 +41,7 @@
#define VIEWER_SEPARATOR "/ "
#define VIDEO_COPYRIGHT "Unknown"
+#define BTN_LOC_NONE -1
#define BTN_LOC_PREV 0
#define BTN_LOC_PLAY 2
#define BTN_LOC_NEXT 4
@@ -53,21 +54,15 @@ enum {
VIEWER_MAX
};
-enum {
- DIR_NONE,
- DIR_PREV,
- DIR_NEXT
-};
-
struct _viewer {
struct controller *ctl[VIEWER_MAX];
int cur;
+ int foc;
};
struct _playlist {
Eina_List *list;
int cur;
- int dir;
};
struct _priv {
@@ -432,6 +427,44 @@ static void _set_played_position(struct _priv *priv, int position)
app_media_update(am);
}
+static void _set_image_orientation(struct _priv *priv)
+{
+ app_media *am;
+ app_media_info *mi;
+ Evas_Object *image, *obj;
+
+ am = eina_list_nth(priv->playlist.list, priv->playlist.cur);
+ if (!am) {
+ _ERR("failed to get app_media");
+ return;
+ }
+
+ mi = _get_current_media_info(priv);
+ if (!mi) {
+ _ERR("failed to getting media info");
+ return;
+ }
+
+ image = elm_image_add(priv->base);
+ if (!image) {
+ _ERR("failed to add image");
+ return;
+ }
+
+ elm_image_file_set(image, mi->file_path, NULL);
+ elm_image_orient_set(image, ELM_IMAGE_ROTATE_270);
+
+ obj = elm_image_object_get(image);
+ if (!obj) {
+ _ERR("failed to get image object");
+ return;
+ }
+
+ evas_object_image_save(obj, mi->file_path, NULL, "quality=100");
+
+ app_media_update(am);
+}
+
static void _update_to_player(struct _priv *priv)
{
viewmgr_update_view(VIEW_MPLAYER, UPDATE_PLAYER, NULL);
@@ -471,22 +504,15 @@ static bool _viewer_show(struct _priv *priv)
ctl->ops->show(ctl->handle);
- switch (priv->playlist.dir) {
- case DIR_PREV:
- loc = BTN_LOC_PREV;
- break;
- case DIR_NEXT:
- loc = BTN_LOC_NEXT;
- break;
- case DIR_NONE:
- default:
+ loc = priv->viewer.foc;
+ if (loc == BTN_LOC_NONE) {
loc = info->focus_loc;
if (id == VIEWER_MOVIE) {
ctl->ops->signal(ctl->handle,
BTN_LOC_PLAY, SIG_SET_PAUSE);
}
- break;
}
+
ctl->ops->signal(ctl->handle, loc, SIG_SET_FOCUS);
ctl->ops->focus(ctl->handle, loc, true);
@@ -565,7 +591,7 @@ static bool _viewer_prev(struct _priv *priv)
else
priv->playlist.cur--;
- priv->playlist.dir = DIR_PREV;
+ priv->viewer.foc = BTN_LOC_PREV;
r = _viewer_show(priv);
@@ -590,7 +616,7 @@ static bool _viewer_next(struct _priv *priv)
else
priv->playlist.cur++;
- priv->playlist.dir = DIR_NEXT;
+ priv->viewer.foc = BTN_LOC_NEXT;
r = _viewer_show(priv);
@@ -850,6 +876,12 @@ static void _callback_photo(void *data, const char *ev)
_viewer_prev(priv);
else if (!strcmp(ev, SRC_BTN_GALLERY_NEXT))
_viewer_next(priv);
+ else if (!strcmp(ev, SRC_BTN_ROTATE)) {
+ _set_image_orientation(priv);
+
+ priv->viewer.foc = BTN_LOC_ROTATE;
+ _viewer_show(priv);
+ }
}
static void _callback_video(void *data, const char *ev)
@@ -1015,7 +1047,7 @@ static Evas_Object *_create(Evas_Object *win, void *data)
priv->playlist.list = NULL;
priv->playlist.cur = 0;
- priv->playlist.dir = DIR_NONE;
+ priv->viewer.foc = BTN_LOC_NONE;
player = playermgr_create(win);
if (!player) {
@@ -1125,7 +1157,7 @@ static void _update(void *view_data, int update_type, void *data)
priv->playlist.list = vdata->list;
priv->playlist.cur = vdata->index;
- priv->playlist.dir = DIR_NONE;
+ priv->viewer.foc = BTN_LOC_NONE;
break;
default:
break;