efl/legacy/elementary/src/bin/test_slideshow.c

218 lines
7.1 KiB
C
Raw Normal View History

#include "elementary_config.h"
#include <Elementary.h>
static Evas_Object *slideshow, *bt_start, *bt_stop;
static Elm_Slideshow_Item_Class itc;
static const char *img1 = PACKAGE_DATA_DIR"/images/logo.png";
static const char *img2 = PACKAGE_DATA_DIR"/images/plant_01.jpg";
static const char *img3 = PACKAGE_DATA_DIR"/images/rock_01.jpg";
static const char *img4 = PACKAGE_DATA_DIR"/images/rock_02.jpg";
static const char *img5 = PACKAGE_DATA_DIR"/images/sky_01.jpg";
static const char *img6 = PACKAGE_DATA_DIR"/images/sky_04.jpg";
static const char *img7 = PACKAGE_DATA_DIR"/images/wood_01.jpg";
static const char *img8 = PACKAGE_DATA_DIR"/images/mystrale.jpg";
static const char *img9 = PACKAGE_DATA_DIR"/images/mystrale_2.jpg";
static void
2013-08-31 18:18:03 -07:00
_notify_show(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
evas_object_show(data);
}
static void
2013-08-31 18:18:03 -07:00
_next(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
elm_slideshow_next(data);
}
static void
2013-08-31 18:18:03 -07:00
_previous(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
elm_slideshow_previous(data);
}
static void
2013-08-31 18:18:03 -07:00
_mouse_in(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
elm_notify_timeout_set(data, 0.0);
evas_object_show(data);
}
static void
2013-08-31 18:18:03 -07:00
_mouse_out(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
elm_notify_timeout_set(data, 3.0);
}
static void
_hv_select(void *data, Evas_Object *obj, void *event_info)
{
elm_slideshow_transition_set(slideshow, data);
elm_object_text_set(obj, elm_object_item_text_get(event_info));
}
static void
2013-08-31 18:18:03 -07:00
_layout_select(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
{
elm_slideshow_layout_set(slideshow, data);
elm_object_text_set(obj, data);
}
static void
2013-08-31 18:18:03 -07:00
_start(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
elm_slideshow_timeout_set(slideshow, elm_spinner_value_get(data));
elm_object_disabled_set(bt_start, EINA_TRUE);
elm_object_disabled_set(bt_stop, EINA_FALSE);
}
static void
2013-08-31 18:18:03 -07:00
_stop(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
elm_slideshow_timeout_set(slideshow, 0.0);
elm_object_disabled_set(bt_start, EINA_FALSE);
elm_object_disabled_set(bt_stop, EINA_TRUE);
}
static void
2013-08-31 18:18:03 -07:00
_spin(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
if (elm_slideshow_timeout_get(slideshow) > 0)
elm_slideshow_timeout_set(slideshow, elm_spinner_value_get(data));
}
static Evas_Object *
_get(void *data, Evas_Object *obj)
{
//Evas_Object *photo = elm_photocam_add(obj);
//elm_photocam_file_set(photo, data);
//elm_photocam_zoom_mode_set(photo, ELM_PHOTOCAM_ZOOM_MODE_AUTO_FIT);
2013-07-31 02:15:05 -07:00
Evas_Object *photo = elm_image_add(obj);
elm_image_file_set(photo, data, NULL);
elm_image_fill_outside_set(photo, EINA_FALSE);
return photo;
}
From: Rajeev Ranjan (Rajeev) <rajeev.r@samsung.com> <rajeev.jnnce@gmail.com> Subject: Re: [E-devel] [Patch] elm_slideshow patch From: PRINCE KUMAR DUBEY <prince.dubey@samsung.com> On behalf of Rajeev Ranjan, I am submitting the elm_slideshow patch which add support for getting notification when transition completes. Change Log: new signal “transition,end” has been introduced to get notification when transition completes. Detail Description: The actual requirement is to get user notified when the last item is visible in the slideshow. In this case, user wants to take some action, say updating button text to Restart if the slideshow does not have loop. The current implementation of slideshow has a signal called “changed” which has current visible item as event_info parameter in the callback. User can compare it with the last appended item and come to know that the last item is visible if even_info is equal to the data passed which should be the last appended item. The only problem is that this signal is emitted by C code asynchronously to the transition, hence if the transition involves an animation, user will most likely get it even before the transition completes. This may look bad to the user if the button label gets updated to Restart even before the last transition gets over. In order to fulfill the requirement, I have introduced another signal “transition,end” which is emitted once the transition is over. The same requirement could have been fulfilled by emitting “changed” signal after the transition gets over but then this will be different from the existing implementation for other widgets, hence I introduced the new signal “transition,end”. SVN revision: 65951
2011-12-06 01:03:01 -08:00
static void
2013-08-31 18:18:03 -07:00
_slide_transition(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
From: Rajeev Ranjan (Rajeev) <rajeev.r@samsung.com> <rajeev.jnnce@gmail.com> Subject: Re: [E-devel] [Patch] elm_slideshow patch From: PRINCE KUMAR DUBEY <prince.dubey@samsung.com> On behalf of Rajeev Ranjan, I am submitting the elm_slideshow patch which add support for getting notification when transition completes. Change Log: new signal “transition,end” has been introduced to get notification when transition completes. Detail Description: The actual requirement is to get user notified when the last item is visible in the slideshow. In this case, user wants to take some action, say updating button text to Restart if the slideshow does not have loop. The current implementation of slideshow has a signal called “changed” which has current visible item as event_info parameter in the callback. User can compare it with the last appended item and come to know that the last item is visible if even_info is equal to the data passed which should be the last appended item. The only problem is that this signal is emitted by C code asynchronously to the transition, hence if the transition involves an animation, user will most likely get it even before the transition completes. This may look bad to the user if the button label gets updated to Restart even before the last transition gets over. In order to fulfill the requirement, I have introduced another signal “transition,end” which is emitted once the transition is over. The same requirement could have been fulfilled by emitting “changed” signal after the transition gets over but then this will be different from the existing implementation for other widgets, hence I introduced the new signal “transition,end”. SVN revision: 65951
2011-12-06 01:03:01 -08:00
{
Elm_Object_Item *slide_it = (Elm_Object_Item *) event_info;
if (data == slide_it)
From: Rajeev Ranjan (Rajeev) <rajeev.r@samsung.com> <rajeev.jnnce@gmail.com> Subject: Re: [E-devel] [Patch] elm_slideshow patch From: PRINCE KUMAR DUBEY <prince.dubey@samsung.com> On behalf of Rajeev Ranjan, I am submitting the elm_slideshow patch which add support for getting notification when transition completes. Change Log: new signal “transition,end” has been introduced to get notification when transition completes. Detail Description: The actual requirement is to get user notified when the last item is visible in the slideshow. In this case, user wants to take some action, say updating button text to Restart if the slideshow does not have loop. The current implementation of slideshow has a signal called “changed” which has current visible item as event_info parameter in the callback. User can compare it with the last appended item and come to know that the last item is visible if even_info is equal to the data passed which should be the last appended item. The only problem is that this signal is emitted by C code asynchronously to the transition, hence if the transition involves an animation, user will most likely get it even before the transition completes. This may look bad to the user if the button label gets updated to Restart even before the last transition gets over. In order to fulfill the requirement, I have introduced another signal “transition,end” which is emitted once the transition is over. The same requirement could have been fulfilled by emitting “changed” signal after the transition gets over but then this will be different from the existing implementation for other widgets, hence I introduced the new signal “transition,end”. SVN revision: 65951
2011-12-06 01:03:01 -08:00
printf("Reaches to End of slides\n");
}
2009-09-28 13:02:10 -07:00
void
2013-08-31 18:18:03 -07:00
test_slideshow(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
Evas_Object *win, *notify, *bx, *bt, *hv, *spin;
const Eina_List *l;
const char *transition, *layout;
Elm_Object_Item *slide_last_it;
win = elm_win_util_standard_add("slideshow", "Slideshow");
elm_win_autodel_set(win, EINA_TRUE);
slideshow = elm_slideshow_add(win);
elm_slideshow_loop_set(slideshow, EINA_TRUE);
evas_object_size_hint_weight_set(slideshow, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, slideshow);
evas_object_show(slideshow);
itc.func.get = _get;
itc.func.del = NULL;
elm_slideshow_item_add(slideshow, &itc, img1);
elm_slideshow_item_add(slideshow, &itc, img2);
elm_slideshow_item_add(slideshow, &itc, img3);
elm_slideshow_item_add(slideshow, &itc, img4);
elm_slideshow_item_add(slideshow, &itc, img9);
elm_slideshow_item_add(slideshow, &itc, img5);
elm_slideshow_item_add(slideshow, &itc, img6);
elm_slideshow_item_add(slideshow, &itc, img7);
slide_last_it = elm_slideshow_item_add(slideshow, &itc, img8);
evas_object_smart_callback_add(slideshow, "transition,end", _slide_transition, slide_last_it);
notify = elm_notify_add(win);
elm_notify_align_set(notify, 0.5, 1.0);
evas_object_size_hint_weight_set(notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, notify);
elm_notify_timeout_set(notify, 3.0);
bx = elm_box_add(win);
elm_box_horizontal_set(bx, EINA_TRUE);
elm_object_content_set(notify, bx);
evas_object_show(bx);
evas_object_event_callback_add(bx, EVAS_CALLBACK_MOUSE_IN, _mouse_in,
notify);
evas_object_event_callback_add(bx, EVAS_CALLBACK_MOUSE_OUT, _mouse_out,
notify);
bt = elm_button_add(win);
elm_object_text_set(bt, "Previous");
evas_object_smart_callback_add(bt, "clicked", _previous, slideshow);
elm_box_pack_end(bx, bt);
evas_object_show(bt);
bt = elm_button_add(win);
elm_object_text_set(bt, "Next");
evas_object_smart_callback_add(bt, "clicked", _next, slideshow);
elm_box_pack_end(bx, bt);
evas_object_show(bt);
hv = elm_hoversel_add(win);
elm_box_pack_end(bx, hv);
elm_hoversel_hover_parent_set(hv, win);
EINA_LIST_FOREACH(elm_slideshow_transitions_get(slideshow), l, transition)
elm_hoversel_item_add(hv, transition, NULL, 0, _hv_select, transition);
elm_hoversel_item_add(hv, "None", NULL, 0, _hv_select, NULL);
elm_object_text_set(hv, eina_list_data_get(elm_slideshow_transitions_get(slideshow)));
evas_object_show(hv);
hv = elm_hoversel_add(win);
elm_box_pack_end(bx, hv);
elm_hoversel_hover_parent_set(hv, win);
EINA_LIST_FOREACH(elm_slideshow_layouts_get(slideshow), l, layout)
elm_hoversel_item_add(hv, layout, NULL, 0, _layout_select, layout);
elm_object_text_set(hv, elm_slideshow_layout_get(slideshow));
evas_object_show(hv);
spin = elm_spinner_add(win);
elm_spinner_label_format_set(spin, "%2.0f secs.");
evas_object_smart_callback_add(spin, "changed", _spin, spin);
elm_spinner_step_set(spin, 1);
elm_spinner_min_max_set(spin, 1, 30);
elm_spinner_value_set(spin, 3);
elm_box_pack_end(bx, spin);
evas_object_show(spin);
bt = elm_button_add(win);
bt_start = bt;
elm_object_text_set(bt, "Start");
evas_object_smart_callback_add(bt, "clicked", _start, spin);
elm_box_pack_end(bx, bt);
evas_object_show(bt);
bt = elm_button_add(win);
bt_stop = bt;
elm_object_text_set(bt, "Stop");
evas_object_smart_callback_add(bt, "clicked", _stop, spin);
elm_box_pack_end(bx, bt);
elm_object_disabled_set(bt, EINA_TRUE);
evas_object_show(bt);
evas_object_event_callback_add(slideshow, EVAS_CALLBACK_MOUSE_UP,
_notify_show, notify);
evas_object_event_callback_add(slideshow, EVAS_CALLBACK_MOUSE_MOVE,
_notify_show, notify);
evas_object_resize(win, 500, 400);
evas_object_show(win);
}