Add slideshow back into ephoto. Works pretty well for now.
SVN revision: 57039
This commit is contained in:
parent
05531c003c
commit
48d7093b5e
|
@ -17,6 +17,7 @@ _sources = \
|
|||
ephoto.c \
|
||||
ephoto_main.c \
|
||||
ephoto_flow_browser.c \
|
||||
ephoto_slideshow.c \
|
||||
ephoto_thumb_browser.c
|
||||
|
||||
_libs = @ELEMENTARY_LIBS@ @EFREET_MIME_LIBS@ @EIO_LIBS@ @EXIF_LIBS@
|
||||
|
|
|
@ -41,6 +41,7 @@ void ephoto_flow_browser_show(void);
|
|||
|
||||
Evas_Object *ephoto_slideshow_add(void);
|
||||
void ephoto_slideshow_del(void);
|
||||
void ephoto_slideshow_show(void);
|
||||
|
||||
Evas_Object *ephoto_thumb_browser_add(void);
|
||||
void ephoto_thumb_browser_thumb_append(Eina_List *node);
|
||||
|
|
|
@ -7,6 +7,7 @@ static void _ephoto_flow_back(void *data __UNUSED__, Evas_Object *o __UNUSED__,
|
|||
static void _ephoto_flow_prev(void *data __UNUSED__, Evas_Object *o __UNUSED__, void *event_info __UNUSED__);
|
||||
static void _ephoto_flow_next(void *data __UNUSED__, Evas_Object *o __UNUSED__, void *event_info __UNUSED__);
|
||||
static void _ephoto_center_image_clicked(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__);
|
||||
static void _ephoto_show_slideshow(void *data __UNUSED__, Evas_Object *o __UNUSED__, void *event_info __UNUSED__);
|
||||
static void _ephoto_key_down(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *o __UNUSED__, void *event_info);
|
||||
static void _ephoto_mouse_wheel(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *o __UNUSED__, void *event_info);
|
||||
|
||||
|
@ -84,7 +85,7 @@ ephoto_flow_browser_add(void)
|
|||
(efb->toolbar, "go-next", "Next", _ephoto_flow_next, NULL);
|
||||
elm_toolbar_item_priority_set(efb->action.go_next, 2);
|
||||
efb->action.slideshow = elm_toolbar_item_append
|
||||
(efb->toolbar, "media-playback-start", "Slideshow", NULL, NULL);
|
||||
(efb->toolbar, "media-playback-start", "Slideshow", _ephoto_show_slideshow, NULL);
|
||||
elm_toolbar_item_priority_set(efb->action.slideshow, 3);
|
||||
|
||||
elm_toolbar_icon_size_set(efb->toolbar, 32);
|
||||
|
@ -381,6 +382,14 @@ _ephoto_center_image_clicked(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Obj
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_ephoto_show_slideshow(void *data __UNUSED__, Evas_Object *o __UNUSED__, void *event_info __UNUSED__)
|
||||
{
|
||||
elm_toolbar_item_selected_set(efb->action.slideshow, EINA_FALSE);
|
||||
|
||||
ephoto_slideshow_show();
|
||||
}
|
||||
|
||||
static void
|
||||
_ephoto_key_down(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
|
||||
{
|
||||
|
|
|
@ -44,6 +44,9 @@ ephoto_window_add(void)
|
|||
else if (ephoto->file)
|
||||
ephoto->directory = eina_stringshare_add(ecore_file_dir_get(ephoto->file));
|
||||
|
||||
ephoto->slideshow = ephoto_slideshow_add();
|
||||
elm_pager_content_push(ephoto->pager, ephoto->slideshow);
|
||||
|
||||
ephoto->flow_browser = ephoto_flow_browser_add();
|
||||
elm_pager_content_push(ephoto->pager, ephoto->flow_browser);
|
||||
|
||||
|
|
|
@ -1,193 +1,75 @@
|
|||
#include "ephoto.h"
|
||||
|
||||
typedef struct _Ephoto_Slideshow Ephoto_Slideshow;
|
||||
static Evas_Object *_ephoto_slideshow_item_get(void *data, Evas_Object *obj);
|
||||
static void _ephoto_mouse_down(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *o __UNUSED__, void *event_info __UNUSED__);
|
||||
|
||||
struct _Ephoto_Slideshow
|
||||
{
|
||||
Ephoto *ephoto;
|
||||
Evas_Object *slideshow;
|
||||
Ephoto_Entry *entry;
|
||||
};
|
||||
|
||||
static void
|
||||
_key_down(void *data, Evas *e __UNUSED__, Evas_Object *o __UNUSED__, void *event_info)
|
||||
{
|
||||
Ephoto_Slideshow *ss = data;
|
||||
Evas_Event_Key_Down *ev = event_info;
|
||||
const char *k = ev->keyname;
|
||||
|
||||
if (!strcmp(k, "Escape"))
|
||||
{
|
||||
Evas_Object *win = ss->ephoto->win;
|
||||
Elm_Slideshow_Item *item;
|
||||
Ephoto_Entry *entry;
|
||||
|
||||
if (elm_win_fullscreen_get(win))
|
||||
elm_win_fullscreen_set(win, EINA_FALSE);
|
||||
|
||||
item = elm_slideshow_item_current_get(ss->slideshow);
|
||||
if (item) entry = elm_slideshow_item_data_get(item);
|
||||
else entry = ss->entry;
|
||||
evas_object_smart_callback_call(ss->slideshow, "back", entry);
|
||||
}
|
||||
else if (!strcmp(k, "F11"))
|
||||
{
|
||||
Evas_Object *win = ss->ephoto->win;
|
||||
elm_win_fullscreen_set(win, !elm_win_fullscreen_get(win));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_mouse_down(void *data, Evas *e __UNUSED__, Evas_Object *o __UNUSED__, void *event_info __UNUSED__)
|
||||
{
|
||||
Ephoto_Slideshow *ss = data;
|
||||
evas_object_smart_callback_call(ss->slideshow, "back", ss->entry);
|
||||
}
|
||||
|
||||
static void
|
||||
_entry_free(void *data, const Ephoto_Entry *entry __UNUSED__)
|
||||
{
|
||||
Ephoto_Slideshow *ss = data;
|
||||
ss->entry = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
_slideshow_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
|
||||
{
|
||||
Ephoto_Slideshow *ss = data;
|
||||
if (ss->entry)
|
||||
ephoto_entry_free_listener_del(ss->entry, _entry_free, ss);
|
||||
free(ss);
|
||||
}
|
||||
static Evas_Object *slideshow;
|
||||
static const Elm_Slideshow_Item_Class _ephoto_item_cls = {{_ephoto_slideshow_item_get, NULL}};
|
||||
|
||||
Evas_Object *
|
||||
ephoto_slideshow_add(Ephoto *ephoto, Evas_Object *parent)
|
||||
ephoto_slideshow_add(void)
|
||||
{
|
||||
Evas_Object *slideshow = elm_slideshow_add(parent);
|
||||
Ephoto_Slideshow *ss;
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(slideshow, NULL);
|
||||
|
||||
ss = calloc(1, sizeof(Ephoto_Slideshow));
|
||||
EINA_SAFETY_ON_NULL_GOTO(ss, error);
|
||||
ss->ephoto = ephoto;
|
||||
ss->slideshow = slideshow;
|
||||
evas_object_event_callback_add
|
||||
(slideshow, EVAS_CALLBACK_DEL, _slideshow_del, ss);
|
||||
evas_object_event_callback_add
|
||||
(slideshow, EVAS_CALLBACK_KEY_DOWN, _key_down, ss);
|
||||
evas_object_event_callback_add
|
||||
(slideshow, EVAS_CALLBACK_MOUSE_DOWN, _mouse_down, ss);
|
||||
evas_object_data_set(slideshow, "slideshow", ss);
|
||||
|
||||
elm_slideshow_loop_set(slideshow, EINA_TRUE);
|
||||
slideshow = elm_slideshow_add(ephoto->win);
|
||||
elm_slideshow_layout_set(slideshow, "fullscreen");
|
||||
elm_slideshow_loop_set(slideshow, EINA_TRUE);
|
||||
elm_slideshow_transition_set(slideshow, "fade");
|
||||
elm_slideshow_timeout_set(slideshow, 3);
|
||||
evas_object_size_hint_weight_set
|
||||
(slideshow, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(slideshow, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
evas_object_event_callback_add
|
||||
(slideshow, EVAS_CALLBACK_MOUSE_DOWN, _ephoto_mouse_down, NULL);
|
||||
|
||||
return ss->slideshow;
|
||||
return slideshow;
|
||||
}
|
||||
|
||||
error:
|
||||
void
|
||||
ephoto_slideshow_del(void)
|
||||
{
|
||||
evas_object_del(slideshow);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
_image_resized(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *image, void *event_info __UNUSED__)
|
||||
void
|
||||
ephoto_slideshow_show(void)
|
||||
{
|
||||
Evas_Map *map = evas_map_new(4);
|
||||
Evas_Coord cx, cy, x, y, w, h;
|
||||
int orient = (long)evas_object_data_get(image, "orient");
|
||||
Eina_List *l;
|
||||
const char *image;
|
||||
|
||||
evas_object_geometry_get(image, &x, &y, &w, &h);
|
||||
evas_map_util_points_populate_from_geometry(map, x, y, w, h, 0);
|
||||
cx = x + w / 2;
|
||||
cy = y + h / 2;
|
||||
ephoto->prev_state = ephoto->state;
|
||||
ephoto->state = EPHOTO_STATE_SLIDESHOW;
|
||||
elm_pager_content_promote(ephoto->pager, ephoto->slideshow);
|
||||
|
||||
switch (orient)
|
||||
elm_slideshow_clear(slideshow);
|
||||
elm_win_fullscreen_set(ephoto->win, EINA_TRUE);
|
||||
EINA_LIST_FOREACH(ephoto->images, l, image)
|
||||
{
|
||||
case EPHOTO_ORIENT_0:
|
||||
break;
|
||||
case EPHOTO_ORIENT_90:
|
||||
evas_map_util_rotate(map, 90.0, cx, cy);
|
||||
evas_object_map_enable_set(image, EINA_TRUE);
|
||||
evas_object_map_set(image, map);
|
||||
printf("rotated 90 around %d,%d (%dx%d)\n", cx, cy, w, h);
|
||||
break;
|
||||
case EPHOTO_ORIENT_180:
|
||||
evas_map_util_rotate(map, 180.0, cx, cy);
|
||||
evas_object_map_enable_set(image, EINA_TRUE);
|
||||
evas_object_map_set(image, map);
|
||||
printf("rotated 180 around %d,%d (%d,%d %dx%d)\n", cx, cy, x, y, w, h);
|
||||
break;
|
||||
case EPHOTO_ORIENT_270:
|
||||
evas_map_util_rotate(map, 270.0, cx, cy);
|
||||
evas_object_map_enable_set(image, EINA_TRUE);
|
||||
evas_object_map_set(image, map);
|
||||
printf("rotated 270 around %d,%d (%dx%d)\n", cx, cy, w, h);
|
||||
break;
|
||||
default:
|
||||
ERR("unknown orient %d", orient);
|
||||
Elm_Slideshow_Item *item;
|
||||
|
||||
item = elm_slideshow_item_add(slideshow, &_ephoto_item_cls, image);
|
||||
if (l == ephoto->current_index)
|
||||
elm_slideshow_show(item);
|
||||
}
|
||||
}
|
||||
|
||||
evas_map_free(map);
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
_slideshow_item_get(void *data, Evas_Object *obj)
|
||||
static
|
||||
Evas_Object *_ephoto_slideshow_item_get(void *data, Evas_Object *obj)
|
||||
{
|
||||
Ephoto_Entry *entry = data;
|
||||
/* TODO use viewer from ephoto_flow_browser.c */
|
||||
/* TODO consider using exif rotation, see ephoto_flow_browser.c */
|
||||
const char *file = data;
|
||||
|
||||
Evas_Object *image = elm_photo_add(obj);
|
||||
elm_photo_file_set(image, entry->path);
|
||||
elm_photo_file_set(image, file);
|
||||
elm_photo_fill_inside_set(image, EINA_TRUE);
|
||||
elm_object_style_set(image, "shadow");
|
||||
|
||||
evas_object_data_set
|
||||
(image, "orient", (void*)(long)ephoto_file_orient_get(entry->path));
|
||||
evas_object_event_callback_add
|
||||
(image, EVAS_CALLBACK_RESIZE, _image_resized, NULL);
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
static const Elm_Slideshow_Item_Class _item_cls = {{_slideshow_item_get, NULL}};
|
||||
|
||||
void
|
||||
ephoto_slideshow_entry_set(Evas_Object *obj, Ephoto_Entry *entry)
|
||||
static void
|
||||
_ephoto_mouse_down(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *o __UNUSED__, void *event_info __UNUSED__)
|
||||
{
|
||||
Ephoto_Slideshow *ss = evas_object_data_get(obj, "slideshow");
|
||||
Ephoto_Config *conf;
|
||||
Ephoto_Entry *itr;
|
||||
const Eina_List *l;
|
||||
EINA_SAFETY_ON_NULL_RETURN(ss);
|
||||
|
||||
conf = ss->ephoto->config;
|
||||
|
||||
DBG("entry %p, was %p", entry, ss->entry);
|
||||
|
||||
if (ss->entry)
|
||||
ephoto_entry_free_listener_del(ss->entry, _entry_free, ss);
|
||||
|
||||
ss->entry = entry;
|
||||
|
||||
if (entry)
|
||||
ephoto_entry_free_listener_add(entry, _entry_free, ss);
|
||||
|
||||
elm_slideshow_loop_set(ss->slideshow, EINA_TRUE); /* move to config? */
|
||||
elm_slideshow_transition_set(ss->slideshow, conf->slideshow_transition);
|
||||
elm_slideshow_timeout_set(ss->slideshow, conf->slideshow_timeout);
|
||||
elm_slideshow_clear(ss->slideshow);
|
||||
if (!entry) return;
|
||||
|
||||
elm_win_fullscreen_set(ss->ephoto->win, EINA_TRUE);
|
||||
EINA_LIST_FOREACH(ss->ephoto->entries, l, itr)
|
||||
{
|
||||
Elm_Slideshow_Item *item;
|
||||
if (itr->is_dir) continue;
|
||||
item = elm_slideshow_item_add(ss->slideshow, &_item_cls, itr);
|
||||
if (itr == entry) elm_slideshow_show(item);
|
||||
}
|
||||
elm_win_fullscreen_set(ephoto->win, EINA_FALSE);
|
||||
if (ephoto->prev_state == EPHOTO_STATE_THUMB)
|
||||
ephoto_thumb_browser_show();
|
||||
else if (ephoto->prev_state == EPHOTO_STATE_FLOW)
|
||||
ephoto_flow_browser_show();
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ static void _ephoto_change_dir(void *data __UNUSED__, Evas_Object *o __UNUSED__,
|
|||
static void _ephoto_zoom_in(void *data __UNUSED__, Evas_Object *o __UNUSED__, void *event_info __UNUSED__);
|
||||
static void _ephoto_zoom_out(void *data __UNUSED__, Evas_Object *o __UNUSED__, void *event_info __UNUSED__);
|
||||
static void _ephoto_show_flow(void *data __UNUSED__, Evas_Object *o __UNUSED__, void *event_info __UNUSED__);
|
||||
static void _ephoto_show_slideshow(void *data __UNUSED__, Evas_Object *o __UNUSED__, void *event_info __UNUSED__);
|
||||
|
||||
static const Elm_Gengrid_Item_Class _ephoto_thumbnail_class = {
|
||||
"thumb",
|
||||
|
@ -73,7 +74,7 @@ ephoto_thumb_browser_add(void)
|
|||
(etb->toolbar, "image", "View Flow", _ephoto_show_flow, NULL);
|
||||
elm_toolbar_item_priority_set(etb->action.view_flow, 2);
|
||||
etb->action.slideshow = elm_toolbar_item_append
|
||||
(etb->toolbar, "media-playback-start", "Slideshow", NULL, NULL);
|
||||
(etb->toolbar, "media-playback-start", "Slideshow", _ephoto_show_slideshow, NULL);
|
||||
elm_toolbar_item_priority_set(etb->action.slideshow, 3);
|
||||
|
||||
elm_toolbar_icon_size_set(etb->toolbar, 32);
|
||||
|
@ -228,3 +229,11 @@ _ephoto_show_flow(void *data __UNUSED__, Evas_Object *o __UNUSED__, void *event_
|
|||
|
||||
ephoto_flow_browser_show();
|
||||
}
|
||||
|
||||
static void
|
||||
_ephoto_show_slideshow(void *data __UNUSED__, Evas_Object *o __UNUSED__, void *event_info __UNUSED__)
|
||||
{
|
||||
elm_toolbar_item_selected_set(etb->action.slideshow, EINA_FALSE);
|
||||
|
||||
ephoto_slideshow_show();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue