3 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
7 #include <Elementary.h>
11 * @defgroup Imageslider Imageslider
14 * By flicking images on the screen,
15 * you can see the images in specific path.
18 typedef struct _Widget_Data Widget_Data;
20 #define ANI_STEP (14 * elm_scale_get())
21 #define ANI_TIME (0.005)
22 #define ANI_TIME_MSEC (12)
23 #define CLICK_TIME_MAX (180)
24 #define CLICK_WIDTH_MIN (elm_finger_size_get() >> 1)
25 #define FLICK_TIME_MAX (200)
26 #define FLICK_WIDTH_MIN (elm_finger_size_get() >> 2)
28 #define STEP_WEIGHT_DEF (1)
29 #define STEP_WEIGHT_MAX (2)
30 #define STEP_WEIGHT_MIN (0)
31 #define MOVING_IMAGE_SIZE (128)
32 #define MAX_ZOOM_SIZE (6)
33 #define INTERVAL_WIDTH (15)
34 #define MULTITOUCHDEVICE (11)
36 // Enumeration for layout.
46 struct _Imageslider_Item
49 const char *photo_file;
50 void (*func)(void *data, Evas_Object *obj, void *event_info);
52 Evas_Coord x, y, w, h;
53 Evas_Coord ox, oy, ow, oh;
57 // Image Slider Widget Data.
60 Evas_Object *ly[BLOCK_MAX];
64 Evas_Coord x, y, w, h;
66 Ecore_Idler *queue_idler;
67 Ecore_Timer *anim_timer;
69 Evas_Coord_Point down_pos;
74 unsigned int timestamp;
80 Eina_Bool on_zoom : 1;
81 Eina_Bool on_hold : 1;
83 int mdx, mdy, mmx, mmy;
88 // Global value definition.
89 static const char *widtype = NULL;
90 static const char SIG_CLICKED[] = "clicked";
92 // Internal function definition.
93 static void _del_hook(Evas_Object *obj);
94 static void _theme_hook(Evas_Object *obj);
95 static void _sizing_eval(Evas_Object *obj);
96 static void _imageslider_del_all(Widget_Data *wd);
97 static void _imageslider_move(void *data,Evas *e, Evas_Object *obj, void *event_info);
98 static void _imageslider_resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
99 static void _imageslider_show(void * data, Evas * e, Evas_Object * obj, void * event_info);
100 static void _imageslider_hide(void * data, Evas * e, Evas_Object * obj, void * event_info);
101 static void _imageslider_update(Widget_Data *wd);
102 static void _imageslider_update_pos(Widget_Data *wd, Evas_Coord x, Evas_Coord y, Evas_Coord w);
103 static void _imageslider_update_center_pos(Widget_Data *wd, Evas_Coord x, Evas_Coord my, Evas_Coord y, Evas_Coord w);
104 static Evas_Object *_imageslider_add_obj(Widget_Data *wd);
105 static void _imageslider_obj_shift(Widget_Data *wd, Eina_Bool left);
106 static void _imageslider_obj_move(Widget_Data *wd, Evas_Coord step);
107 static Eina_Bool _icon_to_image(void *data);
108 static int _check_drag(int state, void *data);
109 static void _check_zoom(void *data);
110 static void _anim(Widget_Data *wd);
111 static Eina_Bool _timer_cb(void *data);
112 //static void _signal_clicked(void *data, Evas_Object *obj, const char *emission, const char *source);
113 static void ev_imageslider_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
114 static void ev_imageslider_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
115 static void ev_imageslider_move_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
118 // Whenever the Image Slider item is deleted, Call this funtion.
119 static void _del_hook(Evas_Object * obj)
123 wd = elm_widget_data_get(obj);
127 for (i = 0; i < BLOCK_MAX; i++) {
128 evas_object_del(wd->ly[i]);
132 eina_list_free(wd->its);
136 if (wd->queue_idler) {
137 ecore_idler_del(wd->queue_idler);
138 wd->queue_idler = NULL;
141 if (wd->anim_timer) {
142 ecore_timer_del(wd->anim_timer);
143 wd->anim_timer = NULL;
150 // Whenever require processing theme, Call this function
151 static void _theme_hook(Evas_Object * obj)
155 wd = elm_widget_data_get(obj);
157 if (!wd || !wd->ly ) {
161 for (i=0; i < BLOCK_MAX; i++) {
162 wd->ly[i] = elm_layout_add(obj);
163 _elm_theme_object_set(obj, wd->ly[i], "imageslider", "base", "default");
164 elm_widget_resize_object_set(obj, wd->ly[i]);
165 evas_object_show(wd->ly[i]);
171 // Resize Image Slider item.
172 static void _sizing_eval(Evas_Object * obj)
175 Widget_Data *wd = elm_widget_data_get(obj);
181 e = evas_object_evas_get(wd->obj);
183 _imageslider_move(obj, e, obj, NULL);
184 _imageslider_resize(obj, e, obj, NULL);
188 // Whenever MOVE event occurs, Call this function.
189 static void _imageslider_move(void * data, Evas * e, Evas_Object * obj, void * event_info)
198 wd = elm_widget_data_get((Evas_Object *) data);
203 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
206 evas_object_move(wd->clip, x, y);
208 _imageslider_update_pos(wd, wd->x, wd->y, wd->w);
212 // Whenever RESIZE event occurs, Call this fucntion.
213 static void _imageslider_resize(void * data, Evas * e, Evas_Object * obj, void * event_info)
223 wd = elm_widget_data_get((Evas_Object *) data);
224 if (!wd || !wd->ly) {
228 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
229 fprintf( stderr, "%d %d -resize\n" , w, h );
233 for (i = 0; i < BLOCK_MAX; i++) {
234 evas_object_resize(wd->ly[i], w, h);
237 evas_object_resize(wd->clip, w, h);
239 _imageslider_update_pos(wd, wd->x, wd->y, wd->w);
243 // Whenever SHOW event occurs, Call this function.
244 static void _imageslider_show(void *data, Evas *e, Evas_Object * obj, void *event_info)
252 wd = elm_widget_data_get((Evas_Object *) data);
257 evas_object_show(wd->clip);
260 // Whenever HIDE event occurs, Call this function.
261 static void _imageslider_hide(void *data, Evas *e, Evas_Object *obj, void *event_info)
269 wd = elm_widget_data_get((Evas_Object *) data);
273 evas_object_hide(wd->clip);
276 // Delete all Image Slider items.
277 static void _imageslider_del_all(Widget_Data * wd)
286 for (i = 0; i < BLOCK_MAX; i++) {
287 evas_object_del(wd->ly[i]);
291 // Update Image Slider item position.
292 static void _imageslider_update_pos(Widget_Data * wd, Evas_Coord x, Evas_Coord y, Evas_Coord w)
294 evas_object_move(wd->ly[BLOCK_LEFT], x - (w + INTERVAL_WIDTH), y);
295 evas_object_move(wd->ly[BLOCK_CENTER], x, y);
296 evas_object_move(wd->ly[BLOCK_RIGHT], x + (w + INTERVAL_WIDTH), y);
297 evas_render_idle_flush(evas_object_evas_get(wd->obj));
300 // Update the center position of Image Slider item.
301 static void _imageslider_update_center_pos(Widget_Data * wd, Evas_Coord x, Evas_Coord my, Evas_Coord y, Evas_Coord w)
304 Evas_Coord ix, iy, iw, ih;
306 eo = edje_object_part_swallow_get(elm_layout_edje_get(wd->ly[BLOCK_CENTER]), "swl.photo");
307 evas_object_geometry_get(eo, &ix, &iy, &iw, &ih);
309 if ((ix > 0) || (ix + iw < wd->w)) {
310 edje_object_signal_emit(elm_layout_edje_get(wd->ly[BLOCK_CENTER]), "block.on", "block");
311 _imageslider_update_pos(wd, x, y, w);
312 wd->on_zoom = EINA_FALSE;
316 // Add previous/next Image Slider item.
317 static Evas_Object *_imageslider_add_obj(Widget_Data *wd)
320 eo = elm_layout_add(wd->obj);
321 elm_layout_theme_set(eo, "imageslider", "base", "default");
322 elm_widget_resize_object_set(wd->obj, eo);
323 //evas_object_smart_member_add(eo, wd->obj);
325 //edje_object_signal_callback_add(elm_layout_edje_get(eo), "elm,photo,clicked", "", _signal_clicked, wd->obj);
326 evas_object_event_callback_add(eo, EVAS_CALLBACK_MOUSE_DOWN, ev_imageslider_down_cb, wd);
327 evas_object_event_callback_add(eo, EVAS_CALLBACK_MOUSE_UP, ev_imageslider_up_cb, wd);
328 evas_object_event_callback_add(eo, EVAS_CALLBACK_MOUSE_MOVE, ev_imageslider_move_cb, wd);
329 evas_object_resize(eo, wd->w, wd->h);
330 evas_object_move(eo, wd->w + INTERVAL_WIDTH, wd->y);
331 evas_object_clip_set(eo, wd->clip);
332 evas_object_show(eo);
337 // Shift next/previous Image Slider item in layouts.
338 static void _imageslider_obj_shift(Widget_Data *wd, Eina_Bool left)
341 if (wd->ly[BLOCK_LEFT]) {
342 evas_object_del(wd->ly[BLOCK_LEFT]);
343 wd->ly[BLOCK_LEFT] = NULL;
346 wd->ly[BLOCK_LEFT] = wd->ly[BLOCK_CENTER];
347 wd->ly[BLOCK_CENTER]= wd->ly[BLOCK_RIGHT];
348 wd->ly[BLOCK_RIGHT] = _imageslider_add_obj(wd);
350 if (wd->ly[BLOCK_RIGHT]) {
351 evas_object_del(wd->ly[BLOCK_RIGHT]);
352 wd->ly[BLOCK_RIGHT] = NULL;
355 wd->ly[BLOCK_RIGHT]= wd->ly[BLOCK_CENTER];
356 wd->ly[BLOCK_CENTER]= wd->ly[BLOCK_LEFT];
357 wd->ly[BLOCK_LEFT]= _imageslider_add_obj(wd);
361 // Move the current Image Slider item and update.
362 static void _imageslider_obj_move(Widget_Data * wd, Evas_Coord step)
365 wd->cur = eina_list_next(wd->cur);
366 if (wd->cur == NULL) {
367 wd->cur = eina_list_last(wd->its);
370 wd->step = -ANI_STEP;
372 _imageslider_obj_shift(wd, 0);
375 } else if (step < 0) {
376 wd->cur = eina_list_prev(wd->cur);
377 if (wd->cur == NULL) {
379 wd->step = -ANI_STEP;
383 _imageslider_obj_shift(wd, 1);
387 if (wd->move_x < 0) wd->step = ANI_STEP;
388 else wd->step = -ANI_STEP;
392 _imageslider_update(wd);
395 // Whenever MOUSE DOWN event occurs, Call this function.
396 static void ev_imageslider_down_cb(void * data, Evas * e, Evas_Object * obj, void * event_info)
398 Widget_Data *wd = data;
399 Evas_Event_Mouse_Down *ev = event_info;
400 Evas_Coord ix, iy, iw, ih;
401 Evas_Object *eo = NULL;
403 if (wd->ani_lock) return;
405 wd->down_pos = ev->canvas;
406 wd->timestamp = ev->timestamp;
407 wd->move_cnt = MOVE_STEP;
409 wd->dx = ev->canvas.x;
410 wd->dy = ev->canvas.y;
411 wd->mx = ev->canvas.x;
412 wd->my = ev->canvas.y;
417 eo = edje_object_part_swallow_get(elm_layout_edje_get(obj), "swl.photo");
418 if (eo) evas_object_geometry_get(eo, &ix, &iy, &iw, &ih);
421 wd->on_zoom = EINA_TRUE;
422 edje_object_signal_emit(elm_layout_edje_get(obj), "block.off", "block");
428 // Whenever MOUSE UP event occurs, Call this function.
429 // And make Click Event also.
430 static void ev_imageslider_up_cb(void * data, Evas * e, Evas_Object * obj, void * event_info)
432 Widget_Data *wd = data;
433 Evas_Event_Mouse_Up *ev = event_info;
437 if (wd->ani_lock) return;
441 step = wd->down_pos.x - ev->canvas.x;
442 interval = ev->timestamp - wd->timestamp;
443 if (step == 0 || interval == 0) {
444 fprintf(stderr, "[[[ DEBUG ]]]: case1: emit CLICK event\n");
445 evas_object_smart_callback_call(wd->obj, SIG_CLICKED, NULL);
448 if (interval < CLICK_TIME_MAX) {
449 if (step < CLICK_WIDTH_MIN && step > CLICK_WIDTH_MIN) {
450 fprintf(stderr, "[[[ DEBUG ]]]: case2: emit CLICK event\n");
451 evas_object_smart_callback_call(wd->obj, SIG_CLICKED, NULL);
456 if (interval < FLICK_TIME_MAX) {
458 if (step < FLICK_WIDTH_MIN && step > FLICK_WIDTH_MIN) {
459 fprintf(stderr, "[[[ DEBUG ]]]:ev_imageslider_up_cb-black zone (1)\n");
461 _imageslider_obj_move(wd, 0);
463 fprintf(stderr, "[[[ DEBUG ]]]:ev_imageslider_up_cb-black zone (2)\n");
465 _imageslider_obj_move(wd, step);
469 step = (wd->x - wd->move_x) << 1;
470 if (step <= wd->w && step >= -(wd->w)) {
471 fprintf(stderr, "[[[ DEBUG ]]]:ev_imageslider_up_cb-white zone (1)\n");
473 _imageslider_obj_move(wd, 0);
475 fprintf(stderr, "[[[ DEBUG ]]]:ev_imageslider_up_cb-white zone (2)\n");
477 _imageslider_obj_move(wd, step);
484 // Whenever MOUSE MOVE event occurs, Call this API.
485 static void ev_imageslider_move_cb(void * data, Evas * e, Evas_Object * obj, void * event_info)
490 Widget_Data *wd = data;
491 Evas_Event_Mouse_Move *ev = event_info;
492 Elm_Imageslider_Item *it;
494 if (wd->ani_lock) return;
496 if (wd->move_cnt == MOVE_STEP) {
497 if (wd->on_hold == EINA_FALSE) {
501 step = ev->cur.canvas.x - wd->down_pos.x;
502 if (step > 0) idx = BLOCK_LEFT;
503 else idx = BLOCK_RIGHT;
505 wd->move_x = wd->x + ((ev->cur.canvas.x - wd->down_pos.x));
506 wd->move_y = wd->y + ((ev->cur.canvas.y - wd->down_pos.y));
509 _imageslider_update_center_pos(wd, wd->move_x, wd->move_y, wd->y, wd->w);
511 _imageslider_update_pos(wd, wd->move_x, wd->y, wd->w);
515 wd->mx = ev->cur.canvas.x;
516 wd->my = ev->cur.canvas.y;
518 wd->ratio = sqrt((wd->mx -wd->mmx)*(wd->mx -wd->mmx) + (wd->my - wd->mmy)*(wd->my - wd->mmy));
520 eo = edje_object_part_swallow_get(elm_layout_edje_get(obj), "swl.photo");
522 it = eina_list_data_get(wd->cur);
523 if (((it->w * wd->ratio/wd->dratio)/it->ow) < MAX_ZOOM_SIZE ) {
524 edje_object_part_unswallow(elm_layout_edje_get(obj), eo);
525 evas_object_resize(eo, it->w * wd->ratio/wd->dratio, it->h * wd->ratio/wd->dratio);
526 evas_object_size_hint_min_set(eo, it->w * wd->ratio/wd->dratio, it->h * wd->ratio/wd->dratio);
527 edje_object_part_swallow(elm_layout_edje_get(obj), "swl.photo", eo);
538 // Whenever CLICK event occurs, Call this API
539 // But, DONOT emit CLICK event.
540 // DO NOT use this callback function. Remove later.
542 _signal_clicked(void *data, Evas_Object *obj, const char *emission, const char *source)
544 fprintf(stderr, "[[[ DEBUG ]]]: Call the callback function about Click event!, But DONOT emit CLICK event in the callback function!\n");
548 static inline double time_get(Evas_Coord x, Evas_Coord w)
551 time = (-sin(x / w) + 1) / 500;
553 if (time == 0) time = ANI_TIME;
558 static Eina_Bool _icon_to_image(void *data)
560 Widget_Data *wd = data;
562 _imageslider_update(wd);
564 if (wd->queue_idler) {
565 ecore_idler_del(wd->queue_idler);
566 wd->queue_idler = NULL;
568 return ECORE_CALLBACK_CANCEL;
571 static int _check_drag(int state, void *data)
573 Widget_Data *wd = data;
574 Elm_Imageslider_Item *it;
575 Evas_Coord ix, iy, iw, ih;
577 Eina_List *l[BLOCK_MAX];
578 Evas_Object *eo = NULL;
579 l[BLOCK_LEFT] = eina_list_prev(wd->cur);
580 l[BLOCK_CENTER] = wd->cur;
581 l[BLOCK_RIGHT] = eina_list_next(wd->cur);
583 it = eina_list_data_get(l[state]);
585 eo = edje_object_part_swallow_get(elm_layout_edje_get(wd->ly[state]), "swl.photo");
586 if (eo) evas_object_geometry_get(eo, &ix, &iy, &iw, &ih);
587 evas_object_geometry_get(eo, &ix, &iy, &iw, &ih);
588 edje_object_part_drag_value_get(elm_layout_edje_get(wd->ly[state]), "swl.photo", &dx, &dy);
590 if ((iw != wd->w) || ((dx != 0 ) || (dy != 0 ))) {
592 evas_object_del(wd->ly[state]);
593 wd->ly[state] = NULL;
595 wd->ly[state] = _imageslider_add_obj(wd);
604 static void _check_zoom(void *data)
606 Widget_Data *wd = data;
607 Elm_Imageslider_Item *it;
608 Evas_Coord ix, iy, iw, ih;
610 Evas_Object *eo = NULL;
612 it = eina_list_data_get(wd->cur);
614 eo = edje_object_part_swallow_get(elm_layout_edje_get(wd->ly[BLOCK_CENTER]), "swl.photo");
615 if (eo) evas_object_geometry_get(eo, &ix, &iy, &iw, &ih);
616 evas_object_geometry_get(eo, &ix, &iy, &iw, &ih);
617 edje_object_part_drag_value_get(elm_layout_edje_get(wd->ly[BLOCK_CENTER]), "swl.photo", &dx, &dy);
619 if ((iw != wd->w) || ((dx != 0) || (dy != 0))) {
620 wd->on_zoom = EINA_TRUE;
621 edje_object_signal_emit(elm_layout_edje_get(wd->ly[BLOCK_CENTER]), "block.off", "block");
624 wd->on_zoom = EINA_FALSE;
625 edje_object_signal_emit(elm_layout_edje_get(wd->ly[BLOCK_CENTER]), "block.on", "block");
630 static Eina_Bool _timer_cb(void *data)
633 Elm_Imageslider_Item *it;
638 if (wd->ani_lock == 0 ) return 0;
640 gettimeofday(&tv, NULL);
642 t = (tv.tv_sec - wd->tv.tv_sec) * 1000 + (tv.tv_usec - wd->tv.tv_usec) / 1000;
643 gettimeofday(&wd->tv, NULL);
645 t = t / ANI_TIME_MSEC;
646 if (t <= STEP_WEIGHT_MIN) t = STEP_WEIGHT_DEF;
647 else if (t > STEP_WEIGHT_MAX) t = STEP_WEIGHT_MAX;
649 wd->move_x += (wd->step) * t;
651 if (wd->step < 0 && wd->move_x < wd->x) wd->move_x = wd->x;
652 else if (wd->step > 0 && wd->move_x > wd->x) wd->move_x = wd->x;
654 _imageslider_update_pos(wd, wd->move_x, wd->y, wd->w);
656 if (wd->move_x == wd->x) {
659 it = eina_list_data_get(wd->cur);
660 if (it->func) it->func(it->data, wd->obj, it);
663 it = eina_list_data_get(wd->cur);
664 evas_object_smart_callback_call(wd->obj, "changed", it);
667 ret = _check_drag(BLOCK_LEFT, wd);
668 ret = _check_drag(BLOCK_RIGHT, wd);
671 if (!wd->queue_idler) wd->queue_idler = ecore_idler_add(_icon_to_image, wd);
674 ecore_timer_del(wd->anim_timer);
675 wd->anim_timer = NULL;
678 return ECORE_CALLBACK_CANCEL;
681 return ECORE_CALLBACK_RENEW;
685 static void _anim(Widget_Data *wd)
689 if (wd->x == wd->move_x) {
690 _imageslider_update_pos(wd, wd->move_x, wd->y, wd->w);
697 gettimeofday(&wd->tv, NULL);
699 if (!wd->anim_timer) {
700 wd->anim_timer = ecore_timer_add(ANI_TIME, _timer_cb, wd);
704 // Update Image Slider Items.
705 static void _imageslider_update(Widget_Data *wd)
708 Eina_List *l[BLOCK_MAX];
709 Elm_Imageslider_Item *it;
717 _imageslider_del_all(wd);
721 l[BLOCK_LEFT] = eina_list_prev(wd->cur);
722 l[BLOCK_CENTER] = wd->cur;
723 l[BLOCK_RIGHT] = eina_list_next(wd->cur);
725 for (i = 0; i < BLOCK_MAX; i++) {
726 eo = edje_object_part_swallow_get(elm_layout_edje_get(wd->ly[i]), "swl.photo");
728 elm_layout_content_set(wd->ly[i], "swl.photo", NULL);
731 it = eina_list_data_get(l[i]);
735 eo = elm_image_add(wd->obj);
736 elm_layout_content_set(wd->ly[i], "swl.photo", eo);
737 elm_image_prescale_set(eo, wd->w);
738 elm_image_file_set(eo, it->photo_file, NULL);
739 elm_image_object_size_get(eo, &it->w, &it->h);
740 evas_object_geometry_get(eo, &it->ox, &it->oy, &it->ow, &it->oh);
745 if (wd->moving != it->moving) {
746 it->moving = wd->moving;
748 elm_image_prescale_set(eo, MOVING_IMAGE_SIZE);
750 elm_image_prescale_set(eo, it->w > it->h ? it->w : it->h);
762 * Add an Image Slider widget
764 * @param parent The parent object
765 * @return The new Image slider object or NULL if it cannot be created
767 * @ingroup Imageslider
770 elm_imageslider_add(Evas_Object * parent)
773 Evas_Object *obj = NULL;
774 Widget_Data *wd = NULL;
781 wd = ELM_NEW(Widget_Data);
782 e = evas_object_evas_get(parent);
787 obj = elm_widget_add(e);
788 ELM_SET_WIDTYPE(widtype, "imageslider");
789 elm_widget_type_set(obj, "imageslider");
790 elm_widget_sub_object_add(parent, obj);
791 elm_widget_data_set(obj, wd);
792 //wd->parent = parent;
793 elm_widget_del_hook_set(obj, _del_hook);
794 elm_widget_theme_hook_set(obj, _theme_hook);
796 wd->clip = evas_object_rectangle_add(e);
798 for (i=0; i < BLOCK_MAX; i++) {
799 wd->ly[i] = elm_layout_add(obj);
800 elm_layout_theme_set(wd->ly[i], "imageslider", "base", "default");
801 elm_widget_resize_object_set(obj, wd->ly[i]);
802 evas_object_smart_member_add(wd->ly[i], obj);
804 //edje_object_signal_callback_add(elm_layout_edje_get(wd->ly[i]), "elm,photo,clicked", "", _signal_clicked, obj);
805 evas_object_event_callback_add(wd->ly[i], EVAS_CALLBACK_MOUSE_DOWN, ev_imageslider_down_cb, wd);
806 evas_object_event_callback_add(wd->ly[i], EVAS_CALLBACK_MOUSE_UP, ev_imageslider_up_cb, wd);
807 evas_object_event_callback_add(wd->ly[i], EVAS_CALLBACK_MOUSE_MOVE, ev_imageslider_move_cb, wd);
808 evas_object_clip_set(wd->ly[i], wd->clip);
809 evas_object_show(wd->ly[i]);
814 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _imageslider_resize, obj);
815 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE, _imageslider_move, obj);
816 evas_object_event_callback_add(obj, EVAS_CALLBACK_SHOW, _imageslider_show, obj);
817 evas_object_event_callback_add(obj, EVAS_CALLBACK_HIDE, _imageslider_hide, obj);
826 * Append an Image Slider item
828 * @param obj The Image Slider object
829 * @param photo_file photo file path
830 * @param func callback function
831 * @param data callback data
832 * @return The Image Slider item handle or NULL
834 * @ingroup Imageslider
836 EAPI Elm_Imageslider_Item *
837 elm_imageslider_item_append(Evas_Object * obj, const char * photo_file, Elm_Imageslider_Cb func, void * data)
839 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
841 Elm_Imageslider_Item *it;
843 if (!obj || !(wd = elm_widget_data_get(obj))) {
847 it = (Elm_Imageslider_Item *)calloc(1, sizeof(Elm_Imageslider_Item));
848 if (!it) return NULL;
849 it->photo_file = eina_stringshare_add(photo_file);
853 wd->its = eina_list_append(wd->its, it);
855 if (!wd->cur) wd->cur = wd->its;
857 _imageslider_update(wd);
863 * Insert an Image Slider item into the Image Slider Widget by using the given index.
865 * @param obj The Image Slider object
866 * @param photo_file photo file path
867 * @param func callback function
868 * @param index required position
869 * @param data callback data
870 * @return The Image Slider item handle or NULL
872 * @ingroup Imageslider
874 EAPI Elm_Imageslider_Item *
875 elm_imageslider_item_append_relative(Evas_Object *obj, const char *photo_file, Elm_Imageslider_Cb func, unsigned int index, void *data)
877 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
879 Elm_Imageslider_Item *it;
881 fprintf(stderr, "[[[ DEBUG ]]]:: New elm_imageslider_item_append_relative()\n");
883 if (!obj || !(wd = elm_widget_data_get(obj))) {
887 it = (Elm_Imageslider_Item *)calloc(1, sizeof(Elm_Imageslider_Item));
888 if (!it) return NULL;
891 it->photo_file = eina_stringshare_add(photo_file);
895 wd->its = eina_list_append_relative(wd->its, it, eina_list_nth(wd->its, index-2));
897 if (!wd->cur) wd->cur = wd->its;
899 _imageslider_update(wd);
906 * Prepend Image Slider item
908 * @param obj The Image Slider object
909 * @param photo_file photo file path
910 * @param func callback function
911 * @param data callback data
912 * @return The imageslider item handle or NULL
914 * @ingroup Imageslider
916 EAPI Elm_Imageslider_Item *
917 elm_imageslider_item_prepend(Evas_Object * obj, const char * photo_file, Elm_Imageslider_Cb func, void * data)
919 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
921 Elm_Imageslider_Item *it;
923 if (!obj || !(wd = elm_widget_data_get(obj))) {
927 it = (Elm_Imageslider_Item *)calloc(1, sizeof(Elm_Imageslider_Item));
928 it->photo_file = eina_stringshare_add(photo_file);
932 wd->its = eina_list_prepend(wd->its, it );
934 if (!wd->cur) wd->cur = wd->its;
936 _imageslider_update(wd);
944 * Delete the selected Image Slider item
946 * @param it The selected Image Slider item handle
948 * @ingroup Imageslider
951 elm_imageslider_item_del(Elm_Imageslider_Item * it)
954 Elm_Imageslider_Item *_it;
957 if (!it || !(wd = elm_widget_data_get(it->obj))) {
961 EINA_LIST_FOREACH(wd->its, l, _it) {
963 if (l == wd->cur) wd->cur = eina_list_prev(wd->cur);
964 wd->its = eina_list_remove(wd->its, it);
965 if (!wd->cur) wd->cur = wd->its;
970 _imageslider_update(wd);
976 * Get the selected Image Slider item
978 * @param obj The Image Slider object
979 * @return The selected Image Slider item or NULL
981 * @ingroup Imageslider
983 EAPI Elm_Imageslider_Item *
984 elm_imageslider_selected_item_get(Evas_Object * obj)
986 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
989 if (!obj || (!(wd = elm_widget_data_get(obj)))) {
993 if (!wd->cur) return NULL;
995 return eina_list_data_get(wd->cur);
999 * Get whether an Image Slider item is selected or not
1001 * @param it the selected Image Slider item
1002 * @return EINA_TRUE or EINA_FALSE
1004 * @ingroup Imageslider
1007 elm_imageslider_item_selected_get(Elm_Imageslider_Item * it)
1011 if (!it || !it->obj || (!(wd = elm_widget_data_get(it->obj)))) {
1015 if (!wd->cur) return EINA_FALSE;
1017 if (eina_list_data_get(wd->cur) == it ) return EINA_TRUE;
1018 else return EINA_FALSE;
1023 * Set the selected Image Slider item
1025 * @param it The Imaga Slider item
1027 * @ingroup Imageslider
1030 elm_imageslider_item_selected_set(Elm_Imageslider_Item * it)
1034 Elm_Imageslider_Item *_it;
1038 if (!it || !it->obj || (!(wd = elm_widget_data_get(it->obj)))) {
1042 EINA_LIST_FOREACH(wd->its, l, _it) {
1048 for (i = 0; i < BLOCK_MAX; i++) {
1049 eo = edje_object_part_swallow_get(elm_layout_edje_get(wd->ly[i]), "swl.photo");
1051 elm_layout_content_set(wd->ly[i], "swl.photo", NULL);
1052 evas_object_del(eo);
1056 _imageslider_update(wd);
1062 * Get the photo file path of given Image Slider item
1064 * @param it The Image Slider item
1065 * @return The photo file path or NULL;
1067 * @ingroup Imageslider
1070 elm_imageslider_item_photo_file_get(Elm_Imageslider_Item * it)
1076 return it->photo_file;
1081 * Get the previous Image Slider item
1083 * @param it The Image Slider item
1084 * @return The previous Image Slider item or NULL
1086 * @ingroup Imageslider
1088 EAPI Elm_Imageslider_Item *
1089 elm_imageslider_item_prev(Elm_Imageslider_Item * it)
1092 Elm_Imageslider_Item *_it;
1095 if (!it || (!(wd = elm_widget_data_get(it->obj)))) {
1099 EINA_LIST_FOREACH(wd->its, l, _it) {
1101 l = eina_list_prev(l);
1103 return eina_list_data_get(l);
1112 * Get the next Image Slider item
1114 * @param it The Image Slider item
1115 * @return The next Image Slider item or NULL
1117 * @ingroup Imageslider
1119 EAPI Elm_Imageslider_Item *
1120 elm_imageslider_item_next(Elm_Imageslider_Item * it)
1123 Elm_Imageslider_Item *_it;
1126 if (!it || (!(wd = elm_widget_data_get(it->obj)))) {
1130 EINA_LIST_FOREACH(wd->its, l, _it) {
1132 l = eina_list_next(l);
1134 return eina_list_data_get(l);
1143 * Move to the previous Image Slider item
1145 * @param obj The Image Slider object
1147 * @ingroup Imageslider
1150 elm_imageslider_prev(Evas_Object * obj)
1152 ELM_CHECK_WIDTYPE(obj, widtype);
1155 if (!obj || (!(wd = elm_widget_data_get(obj)))) {
1159 if (wd->ani_lock) return;
1161 _imageslider_obj_move(wd, -1);
1166 * Move to the next Image Slider item
1168 * @param obj The Image Slider object
1170 * @ingroup Imageslider
1173 elm_imageslider_next(Evas_Object * obj)
1175 ELM_CHECK_WIDTYPE(obj, widtype);
1178 if (!obj || (!(wd = elm_widget_data_get(obj)))) {
1182 if (wd->ani_lock) return;
1184 _imageslider_obj_move(wd, 1);