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 __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
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 __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
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 __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
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 __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
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 __UNUSED__, 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 __UNUSED__, Evas_Object *obj, void *event_info)
400 Widget_Data *wd = data;
401 Evas_Coord ix, iy, iw, ih;
402 Evas_Event_Mouse_Down *ev = event_info;
403 Evas_Object *eo = NULL;
408 wd->down_pos = ev->canvas;
409 wd->timestamp = ev->timestamp;
410 wd->move_cnt = MOVE_STEP;
412 wd->dx = ev->canvas.x;
413 wd->dy = ev->canvas.y;
414 wd->mx = ev->canvas.x;
415 wd->my = ev->canvas.y;
420 eo = (Evas_Object*)elm_layout_content_get((const Evas_Object*)obj, "swl.photo");
422 evas_object_geometry_get(eo, &ix, &iy, &iw, &ih);
426 wd->on_zoom = EINA_TRUE;
427 edje_object_signal_emit(elm_layout_edje_get(obj), "block.off", "block");
432 // Whenever MOUSE UP event occurs, Call this function.
433 // And make Click Event also.
435 _ev_imageslider_up_cb(void *data, Evas * e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
437 Widget_Data *wd = data;
439 Evas_Event_Mouse_Up *ev = event_info;
453 step = wd->down_pos.x - ev->canvas.x;
454 interval = ev->timestamp - wd->timestamp;
455 if (step == 0 || interval == 0)
457 fprintf(stderr, "[[[ DEBUG ]]]: case1: emit CLICK event\n");
458 evas_object_smart_callback_call(wd->obj, SIG_CLICKED, NULL);
461 if (interval < CLICK_TIME_MAX)
463 if (step < CLICK_WIDTH_MIN && step > CLICK_WIDTH_MIN)
465 fprintf(stderr, "[[[ DEBUG ]]]: case2: emit CLICK event\n");
466 evas_object_smart_callback_call(wd->obj, SIG_CLICKED, NULL);
471 if (interval < FLICK_TIME_MAX)
473 if (step < FLICK_WIDTH_MIN && step > FLICK_WIDTH_MIN)
475 fprintf(stderr, "[[[ DEBUG ]]]:_ev_imageslider_up_cb-black zone (1)\n");
477 _imageslider_obj_move(wd, 0);
481 fprintf(stderr, "[[[ DEBUG ]]]:_ev_imageslider_up_cb-black zone (2)\n");
483 _imageslider_obj_move(wd, step);
489 step = (wd->x - wd->move_x) << 1;
490 if (step <= wd->w && step >= -(wd->w))
492 fprintf(stderr, "[[[ DEBUG ]]]:_ev_imageslider_up_cb-white zone (1)\n");
494 _imageslider_obj_move(wd, 0);
498 fprintf(stderr, "[[[ DEBUG ]]]:_ev_imageslider_up_cb-white zone (2)\n");
500 _imageslider_obj_move(wd, step);
507 // Whenever MOUSE MOVE event occurs, Call this API.
509 _ev_imageslider_move_cb(void *data, Evas * e __UNUSED__, Evas_Object *obj, void *event_info)
517 Widget_Data *wd = data;
519 Evas_Event_Mouse_Move *ev = event_info;
521 Elm_Imageslider_Item *it;
526 if (wd->move_cnt == MOVE_STEP)
528 if (wd->on_hold == EINA_FALSE)
534 step = ev->cur.canvas.x - wd->down_pos.x;
540 wd->move_x = wd->x + ((ev->cur.canvas.x - wd->down_pos.x));
541 wd->move_y = wd->y + ((ev->cur.canvas.y - wd->down_pos.y));
545 _imageslider_update_center_pos(wd, wd->move_x, wd->move_y, wd->y, wd->w);
549 _imageslider_update_pos(wd, wd->move_x, wd->y, wd->w);
555 wd->mx = ev->cur.canvas.x;
556 wd->my = ev->cur.canvas.y;
559 sqrt((wd->mx - wd->mmx) * (wd->mx - wd->mmx) + (wd->my - wd->mmy) * (wd->my - wd->mmy));
561 eo = (Evas_Object*)elm_layout_content_get((const Evas_Object*)obj, "swl.photo");
564 it = eina_list_data_get(wd->cur);
565 if (((it->w * wd->ratio / wd->dratio) / it->ow) < MAX_ZOOM_SIZE)
567 edje_object_part_unswallow(elm_layout_edje_get(obj), eo);
568 evas_object_resize(eo, it->w * wd->ratio / wd->dratio, it->h * wd->ratio / wd->dratio);
569 evas_object_size_hint_min_set(eo, it->w * wd->ratio / wd->dratio, it->h * wd->ratio / wd->dratio);
570 elm_layout_content_set(obj, "swl.photo", eo);
580 // Whenever CLICK event occurs, Call this API
581 // But, DONOT emit CLICK event.
582 // DO NOT use this callback function. Remove later.
584 _signal_clicked(void *data, Evas_Object *obj, const char *emission, const char *source)
586 fprintf(stderr, "[[[ DEBUG ]]]: Call the callback function about Click event!, But DONOT emit CLICK event in the callback function!\n");
591 time_get(Evas_Coord x, Evas_Coord w)
595 time = (-sin(x / w) + 1) / 500;
604 _icon_to_image(void *data)
606 Widget_Data *wd = data;
609 _imageslider_update(wd);
613 ecore_idler_del(wd->queue_idler);
614 wd->queue_idler = NULL;
616 return ECORE_CALLBACK_CANCEL;
620 _check_drag(int state, void *data)
622 Widget_Data *wd = data;
624 Elm_Imageslider_Item *it;
626 Evas_Coord ix, iy, iw, ih;
630 Eina_List *l[BLOCK_MAX];
632 Evas_Object *eo = NULL;
634 l[BLOCK_LEFT] = eina_list_prev(wd->cur);
635 l[BLOCK_CENTER] = wd->cur;
636 l[BLOCK_RIGHT] = eina_list_next(wd->cur);
638 it = eina_list_data_get(l[state]);
640 eo = (Evas_Object*)elm_layout_content_get(wd->ly[state], "swl.photo");
642 evas_object_geometry_get(eo, &ix, &iy, &iw, &ih);
643 edje_object_part_drag_value_get(elm_layout_edje_get(wd->ly[state]), "swl.photo", &dx, &dy);
645 if ((iw != wd->w) || ((dx != 0) || (dy != 0)))
647 elm_layout_content_set(wd->ly[state], "swl.photo", NULL);
656 _check_zoom(void *data)
658 Widget_Data *wd = data;
660 Elm_Imageslider_Item *it;
662 Evas_Coord ix, iy, iw, ih;
666 Evas_Object *eo = NULL;
668 it = eina_list_data_get(wd->cur);
670 eo = (Evas_Object*)elm_layout_content_get(wd->ly[BLOCK_CENTER], "swl.photo");
672 evas_object_geometry_get(eo, &ix, &iy, &iw, &ih);
673 evas_object_geometry_get(eo, &ix, &iy, &iw, &ih);
674 edje_object_part_drag_value_get(elm_layout_edje_get(wd->ly[BLOCK_CENTER]), "swl.photo", &dx, &dy);
676 if ((iw != wd->w) || ((dx != 0) || (dy != 0)))
678 wd->on_zoom = EINA_TRUE;
679 edje_object_signal_emit(elm_layout_edje_get(wd->ly[BLOCK_CENTER]), "block.off", "block");
683 wd->on_zoom = EINA_FALSE;
684 edje_object_signal_emit(elm_layout_edje_get(wd->ly[BLOCK_CENTER]), "block.on", "block");
689 _timer_cb(void *data)
693 Elm_Imageslider_Item *it;
702 if (wd->ani_lock == 0)
705 gettimeofday(&tv, NULL);
707 t = (tv.tv_sec - wd->tv.tv_sec) * 1000 + (tv.tv_usec - wd->tv.tv_usec) / 1000;
708 gettimeofday(&wd->tv, NULL);
710 t = t / ANI_TIME_MSEC;
711 if (t <= STEP_WEIGHT_MIN)
713 else if (t > STEP_WEIGHT_MAX)
716 wd->move_x += (wd->step) * t;
718 if (wd->step < 0 && wd->move_x < wd->x)
720 else if (wd->step > 0 && wd->move_x > wd->x)
723 _imageslider_update_pos(wd, wd->move_x, wd->y, wd->w);
725 if (wd->move_x == wd->x)
730 it = eina_list_data_get(wd->cur);
732 it->func(it->data, wd->obj, it);
736 it = eina_list_data_get(wd->cur);
737 evas_object_smart_callback_call(wd->obj, "changed", it);
740 ret = _check_drag(BLOCK_LEFT, wd);
741 ret = _check_drag(BLOCK_RIGHT, wd);
744 if (!wd->queue_idler)
745 wd->queue_idler = ecore_idler_add(_icon_to_image, wd);
749 ecore_timer_del(wd->anim_timer);
750 wd->anim_timer = NULL;
753 return ECORE_CALLBACK_CANCEL;
756 return ECORE_CALLBACK_RENEW;
760 _anim(Widget_Data * wd)
764 if (wd->x == wd->move_x)
766 _imageslider_update_pos(wd, wd->move_x, wd->y, wd->w);
773 gettimeofday(&wd->tv, NULL);
776 wd->anim_timer = ecore_timer_add(ANI_TIME, _timer_cb, wd);
779 // Update Image Slider Items.
781 _imageslider_update(Widget_Data * wd)
785 Eina_List *l[BLOCK_MAX];
787 Elm_Imageslider_Item *it;
794 if (!wd->cur) return;
796 l[BLOCK_LEFT] = eina_list_prev(wd->cur);
797 l[BLOCK_CENTER] = wd->cur;
798 l[BLOCK_RIGHT] = eina_list_next(wd->cur);
800 for (i = 0; i < BLOCK_MAX; i++)
802 eo = (Evas_Object*)elm_layout_content_get((const Evas_Object*)wd->ly[i], "swl.photo");
805 elm_layout_content_set(wd->ly[i], "swl.photo", NULL);
809 it = eina_list_data_get(l[i]);
815 eo = elm_image_add(wd->obj);
816 elm_layout_content_set(wd->ly[i], "swl.photo", eo);
817 //elm_image_prescale_set(eo, wd->w);
818 elm_image_file_set(eo, it->photo_file, NULL);
819 elm_image_object_size_get(eo, &it->w, &it->h);
820 evas_object_geometry_get(eo, &it->ox, &it->oy, &it->ow, &it->oh);
823 elm_layout_content_set(wd->ly[i], "swl.photo", eo);
826 if (wd->moving != it->moving)
828 it->moving = wd->moving;
831 //elm_image_prescale_set(eo, MOVING_IMAGE_SIZE);
835 //elm_image_prescale_set(eo, it->w > it->h ? it->w : it->h);
845 * Add an Image Slider widget
847 * @param parent The parent object
848 * @return The new Image slider object or NULL if it cannot be created
850 * @ingroup Imageslider
853 elm_imageslider_add(Evas_Object *parent)
857 Evas_Object *obj = NULL;
859 Widget_Data *wd = NULL;
866 wd = ELM_NEW(Widget_Data);
867 e = evas_object_evas_get(parent);
868 if (e == NULL) return NULL;
870 obj = elm_widget_add(e);
871 ELM_SET_WIDTYPE(widtype, "imageslider");
872 elm_widget_type_set(obj, "imageslider");
873 elm_widget_sub_object_add(parent, obj);
874 elm_widget_data_set(obj, wd);
875 elm_widget_del_hook_set(obj, _del_hook);
876 elm_widget_theme_hook_set(obj, _theme_hook);
878 wd->clip = evas_object_rectangle_add(e);
879 elm_widget_resize_object_set(obj, wd->clip);
881 for (i = 0; i < BLOCK_MAX; i++)
883 wd->ly[i] = elm_layout_add(obj);
884 elm_layout_theme_set(wd->ly[i], "imageslider", "base", "default");
885 elm_widget_sub_object_add(obj, wd->ly[i]);
886 evas_object_smart_member_add(wd->ly[i], obj);
888 //edje_object_signal_callback_add(elm_layout_edje_get(wd->ly[i]), "elm,photo,clicked", "", _signal_clicked, obj);
889 evas_object_event_callback_add(wd->ly[i], EVAS_CALLBACK_MOUSE_DOWN, _ev_imageslider_down_cb, wd);
890 evas_object_event_callback_add(wd->ly[i], EVAS_CALLBACK_MOUSE_UP, _ev_imageslider_up_cb, wd);
891 evas_object_event_callback_add(wd->ly[i], EVAS_CALLBACK_MOUSE_MOVE, _ev_imageslider_move_cb, wd);
892 evas_object_clip_set(wd->ly[i], wd->clip);
893 evas_object_show(wd->ly[i]);
898 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _imageslider_resize, obj);
899 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE, _imageslider_move, obj);
900 evas_object_event_callback_add(obj, EVAS_CALLBACK_SHOW, _imageslider_show, obj);
901 evas_object_event_callback_add(obj, EVAS_CALLBACK_HIDE, _imageslider_hide, obj);
909 * Append an Image Slider item
911 * @param obj The Image Slider object
912 * @param photo_file photo file path
913 * @param func callback function
914 * @param data callback data
915 * @return The Image Slider item handle or NULL
917 * @ingroup Imageslider
919 EAPI Elm_Imageslider_Item *
920 elm_imageslider_item_append(Evas_Object *obj, const char *photo_file, Elm_Imageslider_Cb func, void *data)
922 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
925 Elm_Imageslider_Item *it;
927 if (!obj || !(wd = elm_widget_data_get(obj)))
930 it = (Elm_Imageslider_Item *) calloc(1, sizeof(Elm_Imageslider_Item));
933 it->photo_file = eina_stringshare_add(photo_file);
937 wd->its = eina_list_append(wd->its, it);
942 _imageslider_update(wd);
948 * Insert an Image Slider item into the Image Slider Widget by using the given index.
950 * @param obj The Image Slider object
951 * @param photo_file photo file path
952 * @param func callback function
953 * @param index required position
954 * @param data callback data
955 * @return The Image Slider item handle or NULL
957 * @ingroup Imageslider
959 EAPI Elm_Imageslider_Item *
960 elm_imageslider_item_append_relative(Evas_Object *obj, const char *photo_file, Elm_Imageslider_Cb func, unsigned int index, void *data)
962 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
965 Elm_Imageslider_Item *it;
967 fprintf(stderr, "[[[ DEBUG ]]]:: New elm_imageslider_item_append_relative()\n");
969 if (!obj || !(wd = elm_widget_data_get(obj)))
972 it = (Elm_Imageslider_Item *) calloc(1, sizeof(Elm_Imageslider_Item));
977 it->photo_file = eina_stringshare_add(photo_file);
982 eina_list_append_relative(wd->its, it, eina_list_nth(wd->its, index - 2));
987 _imageslider_update(wd);
993 * Prepend Image Slider item
995 * @param obj The Image Slider object
996 * @param photo_file photo file path
997 * @param func callback function
998 * @param data callback data
999 * @return The imageslider item handle or NULL
1001 * @ingroup Imageslider
1003 EAPI Elm_Imageslider_Item *
1004 elm_imageslider_item_prepend(Evas_Object *obj, const char *photo_file, Elm_Imageslider_Cb func, void *data)
1006 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1009 Elm_Imageslider_Item *it;
1011 if (!obj || !(wd = elm_widget_data_get(obj)))
1014 it = (Elm_Imageslider_Item *) calloc(1, sizeof(Elm_Imageslider_Item));
1015 it->photo_file = eina_stringshare_add(photo_file);
1019 wd->its = eina_list_prepend(wd->its, it);
1024 _imageslider_update(wd);
1030 * Delete the selected Image Slider item
1032 * @param it The selected Image Slider item handle
1034 * @ingroup Imageslider
1037 elm_imageslider_item_del(Elm_Imageslider_Item * it)
1041 Elm_Imageslider_Item *_it;
1045 if (!it || !(wd = elm_widget_data_get(it->obj)))
1048 EINA_LIST_FOREACH(wd->its, l, _it)
1053 wd->cur = eina_list_prev(wd->cur);
1054 wd->its = eina_list_remove(wd->its, it);
1061 _imageslider_update(wd);
1066 * Get the selected Image Slider item
1068 * @param obj The Image Slider object
1069 * @return The selected Image Slider item or NULL
1071 * @ingroup Imageslider
1073 EAPI Elm_Imageslider_Item *
1074 elm_imageslider_selected_item_get(Evas_Object *obj)
1076 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1079 if (!obj || (!(wd = elm_widget_data_get(obj))))
1085 return eina_list_data_get(wd->cur);
1089 * Get whether an Image Slider item is selected or not
1091 * @param it the selected Image Slider item
1092 * @return EINA_TRUE or EINA_FALSE
1094 * @ingroup Imageslider
1097 elm_imageslider_item_selected_get(Elm_Imageslider_Item * it)
1101 if (!it || !it->obj || (!(wd = elm_widget_data_get(it->obj))))
1107 if (eina_list_data_get(wd->cur) == it)
1115 * Set the selected Image Slider item
1117 * @param it The Imaga Slider item
1119 * @ingroup Imageslider
1122 elm_imageslider_item_selected_set(Elm_Imageslider_Item * it)
1128 Elm_Imageslider_Item *_it;
1134 if (!it || !it->obj || (!(wd = elm_widget_data_get(it->obj))))
1137 EINA_LIST_FOREACH(wd->its, l, _it)
1143 for (i = 0; i < BLOCK_MAX; i++)
1145 eo = (Evas_Object*)elm_layout_content_get(wd->ly[i], "swl.photo");
1148 elm_layout_content_set(wd->ly[i], "swl.photo", NULL);
1152 _imageslider_update(wd);
1157 * Get the photo file path of given Image Slider item
1159 * @param it The Image Slider item
1160 * @return The photo file path or NULL;
1162 * @ingroup Imageslider
1165 elm_imageslider_item_photo_file_get(Elm_Imageslider_Item * it)
1167 if (!it) return NULL;
1169 return it->photo_file;
1173 * Sets the photo file path of given Image Slider item
1175 * @param it The Image Slider item
1176 * @param photo_file The photo file path or NULL;
1178 * @ingroup Imageslider
1181 elm_imageslider_item_photo_file_set(Elm_Imageslider_Item *it, const char *photo_file)
1184 ELM_CHECK_WIDTYPE(it->obj, widtype);
1188 eina_stringshare_replace(&(it->photo_file), photo_file);
1189 elm_imageslider_item_update(it);
1194 * Get the previous Image Slider item
1196 * @param it The Image Slider item
1197 * @return The previous Image Slider item or NULL
1199 * @ingroup Imageslider
1201 EAPI Elm_Imageslider_Item *
1202 elm_imageslider_item_prev(Elm_Imageslider_Item * it)
1206 Elm_Imageslider_Item *_it;
1210 if (!it || (!(wd = elm_widget_data_get(it->obj))))
1213 EINA_LIST_FOREACH(wd->its, l, _it)
1217 l = eina_list_prev(l);
1220 return eina_list_data_get(l);
1228 * Get the next Image Slider item
1230 * @param it The Image Slider item
1231 * @return The next Image Slider item or NULL
1233 * @ingroup Imageslider
1235 EAPI Elm_Imageslider_Item *
1236 elm_imageslider_item_next(Elm_Imageslider_Item * it)
1240 Elm_Imageslider_Item *_it;
1244 if (!it || (!(wd = elm_widget_data_get(it->obj))))
1247 EINA_LIST_FOREACH(wd->its, l, _it)
1251 l = eina_list_next(l);
1254 return eina_list_data_get(l);
1262 * Move to the previous Image Slider item
1264 * @param obj The Image Slider object
1266 * @ingroup Imageslider
1269 elm_imageslider_prev(Evas_Object *obj)
1271 ELM_CHECK_WIDTYPE(obj, widtype);
1274 if (!obj || (!(wd = elm_widget_data_get(obj))))
1280 _imageslider_obj_move(wd, -1);
1284 * Move to the next Image Slider item
1286 * @param obj The Image Slider object
1288 * @ingroup Imageslider
1291 elm_imageslider_next(Evas_Object * obj)
1293 ELM_CHECK_WIDTYPE(obj, widtype);
1296 if (!obj || (!(wd = elm_widget_data_get(obj))))
1302 _imageslider_obj_move(wd, 1);
1307 * Updates an Image Slider item
1309 * @param it The Image Slider item
1311 * @ingroup Imageslider
1314 elm_imageslider_item_update(Elm_Imageslider_Item *it)
1318 if (!it || (!(wd = elm_widget_data_get(it->obj)))) return;
1319 ELM_CHECK_WIDTYPE(it->obj, widtype);
1321 if (it == eina_list_data_get(eina_list_prev(wd->cur)))
1322 elm_layout_content_set(wd->ly[BLOCK_LEFT], "swl.photo", NULL);
1323 else if (it == eina_list_data_get(wd->cur))
1324 elm_layout_content_set(wd->ly[BLOCK_CENTER], "swl.photo", NULL);
1325 else if (it == eina_list_data_get(eina_list_prev(wd->cur)))
1326 elm_layout_content_set(wd->ly[BLOCK_RIGHT], "swl.photo", NULL);
1328 _imageslider_update(wd);