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;
83 int mdx, mdy, mmx, mmy;
88 // Global value declaration.
89 static const char *widtype = NULL;
91 static const char SIG_CLICKED[] = "clicked";
93 // Internal function declaration.
94 static void _del_hook(Evas_Object *obj);
96 static void _theme_hook(Evas_Object *obj);
98 static void _sizing_eval(Evas_Object *obj);
100 static void _imageslider_move(void *data, Evas * e, Evas_Object *obj, void *event_info);
101 static void _imageslider_resize(void *data, Evas * e, Evas_Object *obj, void *event_info);
102 static void _imageslider_show(void *data, Evas * e, Evas_Object *obj, void *event_info);
103 static void _imageslider_hide(void *data, Evas * e, Evas_Object *obj, void *event_info);
104 static void _imageslider_update(Widget_Data * wd);
106 static void _imageslider_update_pos(Widget_Data * wd, Evas_Coord x, Evas_Coord y, Evas_Coord w);
107 static void _imageslider_update_center_pos(Widget_Data * wd, Evas_Coord x, Evas_Coord my, Evas_Coord y, Evas_Coord w);
109 static void _imageslider_obj_shift(Widget_Data * wd, Eina_Bool left);
111 static void _imageslider_obj_move(Widget_Data * wd, Evas_Coord step);
113 static Eina_Bool _icon_to_image(void *data);
115 static int _check_drag(int state, void *data);
117 static void _check_zoom(void *data);
119 static void _anim(Widget_Data * wd);
121 static Eina_Bool _timer_cb(void *data);
123 //static void _signal_clicked(void *data, Evas_Object *obj, const char *emission, const char *source);
124 static void _ev_imageslider_down_cb(void *data, Evas * e, Evas_Object *obj, void *event_info);
125 static void _ev_imageslider_up_cb(void *data, Evas * e, Evas_Object *obj, void *event_info);
126 static void _ev_imageslider_move_cb(void *data, Evas * e, Evas_Object *obj, void *event_info);
128 // Whenever the Image Slider item is deleted, Call this funtion.
130 _del_hook(Evas_Object *obj)
136 wd = elm_widget_data_get(obj);
141 for (i = 0; i < BLOCK_MAX; i++)
143 elm_widget_sub_object_del(wd->obj, wd->ly[i]);
144 evas_object_del(wd->ly[i]);
149 eina_list_free(wd->its);
155 ecore_idler_del(wd->queue_idler);
156 wd->queue_idler = NULL;
161 ecore_timer_del(wd->anim_timer);
162 wd->anim_timer = NULL;
170 // Whenever require processing theme, Call this function
172 _theme_hook(Evas_Object *obj)
178 wd = elm_widget_data_get(obj);
183 for (i = 0; i < BLOCK_MAX; i++)
185 wd->ly[i] = elm_layout_add(obj);
186 _elm_theme_object_set(obj, wd->ly[i], "imageslider", "base", "default");
187 evas_object_show(wd->ly[i]);
193 // Resize Image Slider item.
195 _sizing_eval(Evas_Object *obj)
199 Widget_Data *wd = elm_widget_data_get(obj);
204 e = evas_object_evas_get(wd->obj);
206 _imageslider_move(obj, e, obj, NULL);
207 _imageslider_resize(obj, e, obj, NULL);
211 // Whenever MOVE event occurs, Call this function.
213 _imageslider_move(void *data, Evas * e, Evas_Object *obj, void *event_info)
222 wd = elm_widget_data_get((Evas_Object *) data);
226 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
230 _imageslider_update_pos(wd, wd->x, wd->y, wd->w);
234 // Whenever RESIZE event occurs, Call this fucntion.
236 _imageslider_resize(void *data, Evas * e, Evas_Object *obj, void *event_info)
247 wd = elm_widget_data_get((Evas_Object *) data);
251 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
252 fprintf(stderr, "%d %d -resize\n", w, h);
256 for (i = 0; i < BLOCK_MAX; i++)
258 evas_object_resize(wd->ly[i], w, h);
261 _imageslider_update_pos(wd, wd->x, wd->y, wd->w);
265 // Whenever SHOW event occurs, Call this function.
267 _imageslider_show(void *data, Evas * e, Evas_Object *obj, void *event_info)
276 wd = elm_widget_data_get((Evas_Object *) data);
279 evas_object_show(wd->clip);
282 // Whenever HIDE event occurs, Call this function.
284 _imageslider_hide(void *data, Evas * e, Evas_Object *obj, void *event_info)
290 wd = elm_widget_data_get((Evas_Object *) data);
292 evas_object_hide(wd->clip);
295 // Update Image Slider item position.
297 _imageslider_update_pos(Widget_Data * wd, Evas_Coord x, Evas_Coord y, Evas_Coord w)
300 evas_object_move(wd->ly[BLOCK_LEFT], x - (w + INTERVAL_WIDTH), y);
301 evas_object_move(wd->ly[BLOCK_CENTER], x, y);
302 evas_object_move(wd->ly[BLOCK_RIGHT], x + (w + INTERVAL_WIDTH), y);
303 //making sure that the clipping happens for all three layouts based on clipper's geometry
304 for (i = 0; i < BLOCK_MAX; i++)
305 evas_object_clip_set(wd->ly[i], wd->clip);
306 evas_render_idle_flush(evas_object_evas_get(wd->obj));
309 // Update the center position of Image Slider item.
311 _imageslider_update_center_pos(Widget_Data * wd, Evas_Coord x, Evas_Coord my, Evas_Coord y, Evas_Coord w)
313 Evas_Coord ix, iy, iw, ih;
314 const Evas_Object *eo = elm_layout_content_get((const Evas_Object*)(wd->ly[BLOCK_CENTER]), "swl.photo");
315 evas_object_geometry_get(eo, &ix, &iy, &iw, &ih);
316 if ((ix > 0) || (ix + iw < wd->w))
318 edje_object_signal_emit(elm_layout_edje_get(wd->ly[BLOCK_CENTER]), "block.on", "block");
319 _imageslider_update_pos(wd, x, y, w);
320 wd->on_zoom = EINA_FALSE;
324 // Shift next/previous Image Slider item in layouts.
326 _imageslider_obj_shift(Widget_Data * wd, Eina_Bool left)
330 Evas_Object *ly_temp;
331 ly_temp = wd->ly[BLOCK_LEFT];
332 wd->ly[BLOCK_LEFT] = wd->ly[BLOCK_CENTER];
333 wd->ly[BLOCK_CENTER] = wd->ly[BLOCK_RIGHT];
334 wd->ly[BLOCK_RIGHT] = ly_temp;
335 elm_layout_content_set(wd->ly[BLOCK_RIGHT], "swl.photo", NULL);
339 Evas_Object *ly_temp;
340 ly_temp = wd->ly[BLOCK_RIGHT];
341 wd->ly[BLOCK_RIGHT] = wd->ly[BLOCK_CENTER];
342 wd->ly[BLOCK_CENTER] = wd->ly[BLOCK_LEFT];
343 wd->ly[BLOCK_LEFT] = ly_temp;
344 elm_layout_content_set(wd->ly[BLOCK_LEFT], "swl.photo", NULL);
348 // Move the current Image Slider item and update.
350 _imageslider_obj_move(Widget_Data * wd, Evas_Coord step)
354 wd->cur = eina_list_next(wd->cur);
357 wd->cur = eina_list_last(wd->its);
362 wd->step = -ANI_STEP;
364 _imageslider_obj_shift(wd, 0);
370 wd->cur = eina_list_prev(wd->cur);
374 wd->step = -ANI_STEP;
380 _imageslider_obj_shift(wd, 1);
389 wd->step = -ANI_STEP;
393 _imageslider_update(wd);
396 // Whenever MOUSE DOWN event occurs, Call this function.
398 _ev_imageslider_down_cb(void *data, Evas * e, Evas_Object *obj, void *event_info)
400 Widget_Data *wd = data;
402 Evas_Event_Mouse_Down *ev = event_info;
404 Evas_Coord ix, iy, iw, ih;
406 Evas_Object *eo = NULL;
411 wd->down_pos = ev->canvas;
412 wd->timestamp = ev->timestamp;
413 wd->move_cnt = MOVE_STEP;
415 wd->dx = ev->canvas.x;
416 wd->dy = ev->canvas.y;
417 wd->mx = ev->canvas.x;
418 wd->my = ev->canvas.y;
423 eo = (Evas_Object*)elm_layout_content_get((const Evas_Object*)obj, "swl.photo");
425 evas_object_geometry_get(eo, &ix, &iy, &iw, &ih);
429 wd->on_zoom = EINA_TRUE;
430 edje_object_signal_emit(elm_layout_edje_get(obj), "block.off", "block");
435 // Whenever MOUSE UP event occurs, Call this function.
436 // And make Click Event also.
438 _ev_imageslider_up_cb(void *data, Evas * e, Evas_Object *obj, void *event_info)
440 Widget_Data *wd = data;
442 Evas_Event_Mouse_Up *ev = event_info;
456 step = wd->down_pos.x - ev->canvas.x;
457 interval = ev->timestamp - wd->timestamp;
458 if (step == 0 || interval == 0)
460 fprintf(stderr, "[[[ DEBUG ]]]: case1: emit CLICK event\n");
461 evas_object_smart_callback_call(wd->obj, SIG_CLICKED, NULL);
464 if (interval < CLICK_TIME_MAX)
466 if (step < CLICK_WIDTH_MIN && step > CLICK_WIDTH_MIN)
468 fprintf(stderr, "[[[ DEBUG ]]]: case2: emit CLICK event\n");
469 evas_object_smart_callback_call(wd->obj, SIG_CLICKED, NULL);
474 if (interval < FLICK_TIME_MAX)
476 if (step < FLICK_WIDTH_MIN && step > FLICK_WIDTH_MIN)
478 fprintf(stderr, "[[[ DEBUG ]]]:_ev_imageslider_up_cb-black zone (1)\n");
480 _imageslider_obj_move(wd, 0);
484 fprintf(stderr, "[[[ DEBUG ]]]:_ev_imageslider_up_cb-black zone (2)\n");
486 _imageslider_obj_move(wd, step);
492 step = (wd->x - wd->move_x) << 1;
493 if (step <= wd->w && step >= -(wd->w))
495 fprintf(stderr, "[[[ DEBUG ]]]:_ev_imageslider_up_cb-white zone (1)\n");
497 _imageslider_obj_move(wd, 0);
501 fprintf(stderr, "[[[ DEBUG ]]]:_ev_imageslider_up_cb-white zone (2)\n");
503 _imageslider_obj_move(wd, step);
510 // Whenever MOUSE MOVE event occurs, Call this API.
512 _ev_imageslider_move_cb(void *data, Evas * e, Evas_Object *obj, void *event_info)
520 Widget_Data *wd = data;
522 Evas_Event_Mouse_Move *ev = event_info;
524 Elm_Imageslider_Item *it;
529 if (wd->move_cnt == MOVE_STEP)
531 if (wd->on_hold == EINA_FALSE)
537 step = ev->cur.canvas.x - wd->down_pos.x;
543 wd->move_x = wd->x + ((ev->cur.canvas.x - wd->down_pos.x));
544 wd->move_y = wd->y + ((ev->cur.canvas.y - wd->down_pos.y));
548 _imageslider_update_center_pos(wd, wd->move_x, wd->move_y, wd->y, wd->w);
552 _imageslider_update_pos(wd, wd->move_x, wd->y, wd->w);
558 wd->mx = ev->cur.canvas.x;
559 wd->my = ev->cur.canvas.y;
562 sqrt((wd->mx - wd->mmx) * (wd->mx - wd->mmx) + (wd->my - wd->mmy) * (wd->my - wd->mmy));
564 eo = (Evas_Object*)elm_layout_content_get((const Evas_Object*)obj, "swl.photo");
567 it = eina_list_data_get(wd->cur);
568 if (((it->w * wd->ratio / wd->dratio) / it->ow) < MAX_ZOOM_SIZE)
570 edje_object_part_unswallow(elm_layout_edje_get(obj), eo);
571 evas_object_resize(eo, it->w * wd->ratio / wd->dratio, it->h * wd->ratio / wd->dratio);
572 evas_object_size_hint_min_set(eo, it->w * wd->ratio / wd->dratio, it->h * wd->ratio / wd->dratio);
573 elm_layout_content_set(obj, "swl.photo", eo);
583 // Whenever CLICK event occurs, Call this API
584 // But, DONOT emit CLICK event.
585 // DO NOT use this callback function. Remove later.
587 _signal_clicked(void *data, Evas_Object *obj, const char *emission, const char *source)
589 fprintf(stderr, "[[[ DEBUG ]]]: Call the callback function about Click event!, But DONOT emit CLICK event in the callback function!\n");
594 time_get(Evas_Coord x, Evas_Coord w)
598 time = (-sin(x / w) + 1) / 500;
607 _icon_to_image(void *data)
609 Widget_Data *wd = data;
612 _imageslider_update(wd);
616 ecore_idler_del(wd->queue_idler);
617 wd->queue_idler = NULL;
619 return ECORE_CALLBACK_CANCEL;
623 _check_drag(int state, void *data)
625 Widget_Data *wd = data;
627 Elm_Imageslider_Item *it;
629 Evas_Coord ix, iy, iw, ih;
633 Eina_List *l[BLOCK_MAX];
635 Evas_Object *eo = NULL;
637 l[BLOCK_LEFT] = eina_list_prev(wd->cur);
638 l[BLOCK_CENTER] = wd->cur;
639 l[BLOCK_RIGHT] = eina_list_next(wd->cur);
641 it = eina_list_data_get(l[state]);
643 eo = (Evas_Object*)elm_layout_content_get(wd->ly[state], "swl.photo");
645 evas_object_geometry_get(eo, &ix, &iy, &iw, &ih);
646 edje_object_part_drag_value_get(elm_layout_edje_get(wd->ly[state]), "swl.photo", &dx, &dy);
648 if ((iw != wd->w) || ((dx != 0) || (dy != 0)))
650 elm_layout_content_set(wd->ly[state], "swl.photo", NULL);
659 _check_zoom(void *data)
661 Widget_Data *wd = data;
663 Elm_Imageslider_Item *it;
665 Evas_Coord ix, iy, iw, ih;
669 Evas_Object *eo = NULL;
671 it = eina_list_data_get(wd->cur);
673 eo = (Evas_Object*)elm_layout_content_get(wd->ly[BLOCK_CENTER], "swl.photo");
675 evas_object_geometry_get(eo, &ix, &iy, &iw, &ih);
676 evas_object_geometry_get(eo, &ix, &iy, &iw, &ih);
677 edje_object_part_drag_value_get(elm_layout_edje_get(wd->ly[BLOCK_CENTER]), "swl.photo", &dx, &dy);
679 if ((iw != wd->w) || ((dx != 0) || (dy != 0)))
681 wd->on_zoom = EINA_TRUE;
682 edje_object_signal_emit(elm_layout_edje_get(wd->ly[BLOCK_CENTER]), "block.off", "block");
686 wd->on_zoom = EINA_FALSE;
687 edje_object_signal_emit(elm_layout_edje_get(wd->ly[BLOCK_CENTER]), "block.on", "block");
692 _timer_cb(void *data)
696 Elm_Imageslider_Item *it;
705 if (wd->ani_lock == 0)
708 gettimeofday(&tv, NULL);
710 t = (tv.tv_sec - wd->tv.tv_sec) * 1000 + (tv.tv_usec - wd->tv.tv_usec) / 1000;
711 gettimeofday(&wd->tv, NULL);
713 t = t / ANI_TIME_MSEC;
714 if (t <= STEP_WEIGHT_MIN)
716 else if (t > STEP_WEIGHT_MAX)
719 wd->move_x += (wd->step) * t;
721 if (wd->step < 0 && wd->move_x < wd->x)
723 else if (wd->step > 0 && wd->move_x > wd->x)
726 _imageslider_update_pos(wd, wd->move_x, wd->y, wd->w);
728 if (wd->move_x == wd->x)
733 it = eina_list_data_get(wd->cur);
735 it->func(it->data, wd->obj, it);
739 it = eina_list_data_get(wd->cur);
740 evas_object_smart_callback_call(wd->obj, "changed", it);
743 ret = _check_drag(BLOCK_LEFT, wd);
744 ret = _check_drag(BLOCK_RIGHT, wd);
747 if (!wd->queue_idler)
748 wd->queue_idler = ecore_idler_add(_icon_to_image, wd);
752 ecore_timer_del(wd->anim_timer);
753 wd->anim_timer = NULL;
756 return ECORE_CALLBACK_CANCEL;
759 return ECORE_CALLBACK_RENEW;
763 _anim(Widget_Data * wd)
767 if (wd->x == wd->move_x)
769 _imageslider_update_pos(wd, wd->move_x, wd->y, wd->w);
776 gettimeofday(&wd->tv, NULL);
779 wd->anim_timer = ecore_timer_add(ANI_TIME, _timer_cb, wd);
782 // Update Image Slider Items.
784 _imageslider_update(Widget_Data * wd)
788 Eina_List *l[BLOCK_MAX];
790 Elm_Imageslider_Item *it;
797 if (!wd->cur) return;
799 l[BLOCK_LEFT] = eina_list_prev(wd->cur);
800 l[BLOCK_CENTER] = wd->cur;
801 l[BLOCK_RIGHT] = eina_list_next(wd->cur);
803 for (i = 0; i < BLOCK_MAX; i++)
805 eo = (Evas_Object*)elm_layout_content_get((const Evas_Object*)wd->ly[i], "swl.photo");
808 elm_layout_content_set(wd->ly[i], "swl.photo", NULL);
812 it = eina_list_data_get(l[i]);
818 eo = elm_image_add(wd->obj);
819 elm_layout_content_set(wd->ly[i], "swl.photo", eo);
820 //elm_image_prescale_set(eo, wd->w);
821 elm_image_file_set(eo, it->photo_file, NULL);
822 elm_image_object_size_get(eo, &it->w, &it->h);
823 evas_object_geometry_get(eo, &it->ox, &it->oy, &it->ow, &it->oh);
826 elm_layout_content_set(wd->ly[i], "swl.photo", eo);
829 if (wd->moving != it->moving)
831 it->moving = wd->moving;
834 //elm_image_prescale_set(eo, MOVING_IMAGE_SIZE);
838 //elm_image_prescale_set(eo, it->w > it->h ? it->w : it->h);
848 * Add an Image Slider widget
850 * @param parent The parent object
851 * @return The new Image slider object or NULL if it cannot be created
853 * @ingroup Imageslider
856 elm_imageslider_add(Evas_Object *parent)
860 Evas_Object *obj = NULL;
862 Widget_Data *wd = NULL;
869 wd = ELM_NEW(Widget_Data);
870 e = evas_object_evas_get(parent);
871 if (e == NULL) return NULL;
873 obj = elm_widget_add(e);
874 ELM_SET_WIDTYPE(widtype, "imageslider");
875 elm_widget_type_set(obj, "imageslider");
876 elm_widget_sub_object_add(parent, obj);
877 elm_widget_data_set(obj, wd);
878 elm_widget_del_hook_set(obj, _del_hook);
879 elm_widget_theme_hook_set(obj, _theme_hook);
881 wd->clip = evas_object_rectangle_add(e);
882 elm_widget_resize_object_set(obj, wd->clip);
884 for (i = 0; i < BLOCK_MAX; i++)
886 wd->ly[i] = elm_layout_add(obj);
887 elm_layout_theme_set(wd->ly[i], "imageslider", "base", "default");
888 elm_widget_sub_object_add(obj, wd->ly[i]);
889 evas_object_smart_member_add(wd->ly[i], obj);
891 //edje_object_signal_callback_add(elm_layout_edje_get(wd->ly[i]), "elm,photo,clicked", "", _signal_clicked, obj);
892 evas_object_event_callback_add(wd->ly[i], EVAS_CALLBACK_MOUSE_DOWN, _ev_imageslider_down_cb, wd);
893 evas_object_event_callback_add(wd->ly[i], EVAS_CALLBACK_MOUSE_UP, _ev_imageslider_up_cb, wd);
894 evas_object_event_callback_add(wd->ly[i], EVAS_CALLBACK_MOUSE_MOVE, _ev_imageslider_move_cb, wd);
895 evas_object_clip_set(wd->ly[i], wd->clip);
896 evas_object_show(wd->ly[i]);
901 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _imageslider_resize, obj);
902 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE, _imageslider_move, obj);
903 evas_object_event_callback_add(obj, EVAS_CALLBACK_SHOW, _imageslider_show, obj);
904 evas_object_event_callback_add(obj, EVAS_CALLBACK_HIDE, _imageslider_hide, obj);
912 * Append an Image Slider item
914 * @param obj The Image Slider object
915 * @param photo_file photo file path
916 * @param func callback function
917 * @param data callback data
918 * @return The Image Slider item handle or NULL
920 * @ingroup Imageslider
922 EAPI Elm_Imageslider_Item *
923 elm_imageslider_item_append(Evas_Object *obj, const char *photo_file, Elm_Imageslider_Cb func, void *data)
925 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
928 Elm_Imageslider_Item *it;
930 if (!obj || !(wd = elm_widget_data_get(obj)))
933 it = (Elm_Imageslider_Item *) calloc(1, sizeof(Elm_Imageslider_Item));
936 it->photo_file = eina_stringshare_add(photo_file);
940 wd->its = eina_list_append(wd->its, it);
945 _imageslider_update(wd);
951 * Insert an Image Slider item into the Image Slider Widget by using the given index.
953 * @param obj The Image Slider object
954 * @param photo_file photo file path
955 * @param func callback function
956 * @param index required position
957 * @param data callback data
958 * @return The Image Slider item handle or NULL
960 * @ingroup Imageslider
962 EAPI Elm_Imageslider_Item *
963 elm_imageslider_item_append_relative(Evas_Object *obj, const char *photo_file, Elm_Imageslider_Cb func, unsigned int index, void *data)
965 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
968 Elm_Imageslider_Item *it;
970 fprintf(stderr, "[[[ DEBUG ]]]:: New elm_imageslider_item_append_relative()\n");
972 if (!obj || !(wd = elm_widget_data_get(obj)))
975 it = (Elm_Imageslider_Item *) calloc(1, sizeof(Elm_Imageslider_Item));
980 it->photo_file = eina_stringshare_add(photo_file);
985 eina_list_append_relative(wd->its, it, eina_list_nth(wd->its, index - 2));
990 _imageslider_update(wd);
996 * Prepend Image Slider item
998 * @param obj The Image Slider object
999 * @param photo_file photo file path
1000 * @param func callback function
1001 * @param data callback data
1002 * @return The imageslider item handle or NULL
1004 * @ingroup Imageslider
1006 EAPI Elm_Imageslider_Item *
1007 elm_imageslider_item_prepend(Evas_Object *obj, const char *photo_file, Elm_Imageslider_Cb func, void *data)
1009 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1012 Elm_Imageslider_Item *it;
1014 if (!obj || !(wd = elm_widget_data_get(obj)))
1017 it = (Elm_Imageslider_Item *) calloc(1, sizeof(Elm_Imageslider_Item));
1018 it->photo_file = eina_stringshare_add(photo_file);
1022 wd->its = eina_list_prepend(wd->its, it);
1027 _imageslider_update(wd);
1033 * Delete the selected Image Slider item
1035 * @param it The selected Image Slider item handle
1037 * @ingroup Imageslider
1040 elm_imageslider_item_del(Elm_Imageslider_Item * it)
1044 Elm_Imageslider_Item *_it;
1048 if (!it || !(wd = elm_widget_data_get(it->obj)))
1051 EINA_LIST_FOREACH(wd->its, l, _it)
1056 wd->cur = eina_list_prev(wd->cur);
1057 wd->its = eina_list_remove(wd->its, it);
1064 _imageslider_update(wd);
1069 * Get the selected Image Slider item
1071 * @param obj The Image Slider object
1072 * @return The selected Image Slider item or NULL
1074 * @ingroup Imageslider
1076 EAPI Elm_Imageslider_Item *
1077 elm_imageslider_selected_item_get(Evas_Object *obj)
1079 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1082 if (!obj || (!(wd = elm_widget_data_get(obj))))
1088 return eina_list_data_get(wd->cur);
1092 * Get whether an Image Slider item is selected or not
1094 * @param it the selected Image Slider item
1095 * @return EINA_TRUE or EINA_FALSE
1097 * @ingroup Imageslider
1100 elm_imageslider_item_selected_get(Elm_Imageslider_Item * it)
1104 if (!it || !it->obj || (!(wd = elm_widget_data_get(it->obj))))
1110 if (eina_list_data_get(wd->cur) == it)
1118 * Set the selected Image Slider item
1120 * @param it The Imaga Slider item
1122 * @ingroup Imageslider
1125 elm_imageslider_item_selected_set(Elm_Imageslider_Item * it)
1131 Elm_Imageslider_Item *_it;
1137 if (!it || !it->obj || (!(wd = elm_widget_data_get(it->obj))))
1140 EINA_LIST_FOREACH(wd->its, l, _it)
1146 for (i = 0; i < BLOCK_MAX; i++)
1148 eo = (Evas_Object*)elm_layout_content_get(wd->ly[i], "swl.photo");
1151 elm_layout_content_set(wd->ly[i], "swl.photo", NULL);
1155 _imageslider_update(wd);
1160 * Get the photo file path of given Image Slider item
1162 * @param it The Image Slider item
1163 * @return The photo file path or NULL;
1165 * @ingroup Imageslider
1168 elm_imageslider_item_photo_file_get(Elm_Imageslider_Item * it)
1170 if (!it) return NULL;
1172 return it->photo_file;
1176 * Sets the photo file path of given Image Slider item
1178 * @param it The Image Slider item
1179 * @param photo_file The photo file path or NULL;
1181 * @ingroup Imageslider
1184 elm_imageslider_item_photo_file_set(Elm_Imageslider_Item *it, const char *photo_file)
1187 ELM_CHECK_WIDTYPE(it->obj, widtype);
1191 eina_stringshare_replace(&(it->photo_file), photo_file);
1192 elm_imageslider_item_update(it);
1197 * Get the previous Image Slider item
1199 * @param it The Image Slider item
1200 * @return The previous Image Slider item or NULL
1202 * @ingroup Imageslider
1204 EAPI Elm_Imageslider_Item *
1205 elm_imageslider_item_prev(Elm_Imageslider_Item * it)
1209 Elm_Imageslider_Item *_it;
1213 if (!it || (!(wd = elm_widget_data_get(it->obj))))
1216 EINA_LIST_FOREACH(wd->its, l, _it)
1220 l = eina_list_prev(l);
1223 return eina_list_data_get(l);
1231 * Get the next Image Slider item
1233 * @param it The Image Slider item
1234 * @return The next Image Slider item or NULL
1236 * @ingroup Imageslider
1238 EAPI Elm_Imageslider_Item *
1239 elm_imageslider_item_next(Elm_Imageslider_Item * it)
1243 Elm_Imageslider_Item *_it;
1247 if (!it || (!(wd = elm_widget_data_get(it->obj))))
1250 EINA_LIST_FOREACH(wd->its, l, _it)
1254 l = eina_list_next(l);
1257 return eina_list_data_get(l);
1265 * Move to the previous Image Slider item
1267 * @param obj The Image Slider object
1269 * @ingroup Imageslider
1272 elm_imageslider_prev(Evas_Object *obj)
1274 ELM_CHECK_WIDTYPE(obj, widtype);
1277 if (!obj || (!(wd = elm_widget_data_get(obj))))
1283 _imageslider_obj_move(wd, -1);
1287 * Move to the next Image Slider item
1289 * @param obj The Image Slider object
1291 * @ingroup Imageslider
1294 elm_imageslider_next(Evas_Object * obj)
1296 ELM_CHECK_WIDTYPE(obj, widtype);
1299 if (!obj || (!(wd = elm_widget_data_get(obj))))
1305 _imageslider_obj_move(wd, 1);
1310 * Updates an Image Slider item
1312 * @param it The Image Slider item
1314 * @ingroup Imageslider
1317 elm_imageslider_item_update(Elm_Imageslider_Item *it)
1322 if (!it || (!(wd = elm_widget_data_get(it->obj)))) return;
1323 ELM_CHECK_WIDTYPE(it->obj, widtype);
1325 if (it == eina_list_data_get(eina_list_prev(wd->cur)))
1326 elm_layout_content_set(wd->ly[BLOCK_LEFT], "swl.photo", NULL);
1327 else if (it == eina_list_data_get(wd->cur))
1328 elm_layout_content_set(wd->ly[BLOCK_CENTER], "swl.photo", NULL);
1329 else if (it == eina_list_data_get(eina_list_prev(wd->cur)))
1330 elm_layout_content_set(wd->ly[BLOCK_RIGHT], "swl.photo", NULL);
1332 _imageslider_update(wd);