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_del_all(Widget_Data * wd);
102 static void _imageslider_move(void *data, Evas * e, Evas_Object *obj, void *event_info);
103 static void _imageslider_resize(void *data, Evas * e, Evas_Object *obj, void *event_info);
104 static void _imageslider_show(void *data, Evas * e, Evas_Object *obj, void *event_info);
105 static void _imageslider_hide(void *data, Evas * e, Evas_Object *obj, void *event_info);
106 static void _imageslider_update(Widget_Data * wd);
108 static void _imageslider_update_pos(Widget_Data * wd, Evas_Coord x, Evas_Coord y, Evas_Coord w);
109 static void _imageslider_update_center_pos(Widget_Data * wd, Evas_Coord x, Evas_Coord my, Evas_Coord y, Evas_Coord w);
110 static Evas_Object *_imageslider_add_obj(Widget_Data * wd);
112 static void _imageslider_obj_shift(Widget_Data * wd, Eina_Bool left);
114 static void _imageslider_obj_move(Widget_Data * wd, Evas_Coord step);
116 static Eina_Bool _icon_to_image(void *data);
118 static int _check_drag(int state, void *data);
120 static void _check_zoom(void *data);
122 static void _anim(Widget_Data * wd);
124 static Eina_Bool _timer_cb(void *data);
126 //static void _signal_clicked(void *data, Evas_Object *obj, const char *emission, const char *source);
127 static void ev_imageslider_down_cb(void *data, Evas * e, Evas_Object *obj, void *event_info);
128 static void ev_imageslider_up_cb(void *data, Evas * e, Evas_Object *obj, void *event_info);
129 static void ev_imageslider_move_cb(void *data, Evas * e, Evas_Object *obj, void *event_info);
131 // Whenever the Image Slider item is deleted, Call this funtion.
133 _del_hook(Evas_Object *obj)
139 wd = elm_widget_data_get(obj);
144 for (i = 0; i < BLOCK_MAX; i++)
146 evas_object_del(wd->ly[i]);
151 eina_list_free(wd->its);
157 ecore_idler_del(wd->queue_idler);
158 wd->queue_idler = NULL;
163 ecore_timer_del(wd->anim_timer);
164 wd->anim_timer = NULL;
172 // Whenever require processing theme, Call this function
174 _theme_hook(Evas_Object *obj)
180 wd = elm_widget_data_get(obj);
185 for (i = 0; i < BLOCK_MAX; i++)
187 wd->ly[i] = elm_layout_add(obj);
188 _elm_theme_object_set(obj, wd->ly[i], "imageslider", "base", "default");
189 elm_widget_resize_object_set(obj, wd->ly[i]);
190 evas_object_show(wd->ly[i]);
196 // Resize Image Slider item.
198 _sizing_eval(Evas_Object *obj)
202 Widget_Data *wd = elm_widget_data_get(obj);
207 e = evas_object_evas_get(wd->obj);
209 _imageslider_move(obj, e, obj, NULL);
210 _imageslider_resize(obj, e, obj, NULL);
214 // Whenever MOVE event occurs, Call this function.
216 _imageslider_move(void *data, Evas * e, Evas_Object *obj, void *event_info)
225 wd = elm_widget_data_get((Evas_Object *) data);
229 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
232 evas_object_move(wd->clip, x, y);
234 _imageslider_update_pos(wd, wd->x, wd->y, wd->w);
238 // Whenever RESIZE event occurs, Call this fucntion.
240 _imageslider_resize(void *data, Evas * e, Evas_Object *obj, void *event_info)
251 wd = elm_widget_data_get((Evas_Object *) data);
255 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
256 fprintf(stderr, "%d %d -resize\n", w, h);
260 for (i = 0; i < BLOCK_MAX; i++)
262 evas_object_resize(wd->ly[i], w, h);
265 evas_object_resize(wd->clip, w, h);
267 _imageslider_update_pos(wd, wd->x, wd->y, wd->w);
271 // Whenever SHOW event occurs, Call this function.
273 _imageslider_show(void *data, Evas * e, Evas_Object *obj, void *event_info)
282 wd = elm_widget_data_get((Evas_Object *) data);
285 evas_object_show(wd->clip);
288 // Whenever HIDE event occurs, Call this function.
290 _imageslider_hide(void *data, Evas * e, Evas_Object *obj, void *event_info)
296 wd = elm_widget_data_get((Evas_Object *) data);
298 evas_object_hide(wd->clip);
301 // Delete all Image Slider items.
303 _imageslider_del_all(Widget_Data * wd)
310 for (i = 0; i < BLOCK_MAX; i++)
312 evas_object_del(wd->ly[i]);
316 // Update Image Slider item position.
318 _imageslider_update_pos(Widget_Data * wd, Evas_Coord x, Evas_Coord y, Evas_Coord w)
320 evas_object_move(wd->ly[BLOCK_LEFT], x - (w + INTERVAL_WIDTH), y);
321 evas_object_move(wd->ly[BLOCK_CENTER], x, y);
322 evas_object_move(wd->ly[BLOCK_RIGHT], x + (w + INTERVAL_WIDTH), y);
323 evas_render_idle_flush(evas_object_evas_get(wd->obj));
326 // Update the center position of Image Slider item.
328 _imageslider_update_center_pos(Widget_Data * wd, Evas_Coord x, Evas_Coord my, Evas_Coord y, Evas_Coord w)
332 Evas_Coord ix, iy, iw, ih;
334 eo = edje_object_part_swallow_get(elm_layout_edje_get(wd->ly[BLOCK_CENTER]), "swl.photo");
335 evas_object_geometry_get(eo, &ix, &iy, &iw, &ih);
337 if ((ix > 0) || (ix + iw < wd->w))
339 edje_object_signal_emit(elm_layout_edje_get(wd->ly[BLOCK_CENTER]), "block.on", "block");
340 _imageslider_update_pos(wd, x, y, w);
341 wd->on_zoom = EINA_FALSE;
345 // Add previous/next Image Slider item.
347 _imageslider_add_obj(Widget_Data * wd)
351 eo = elm_layout_add(wd->obj);
352 elm_layout_theme_set(eo, "imageslider", "base", "default");
353 elm_widget_resize_object_set(wd->obj, eo);
354 //evas_object_smart_member_add(eo, wd->obj);
356 //edje_object_signal_callback_add(elm_layout_edje_get(eo), "elm,photo,clicked", "", _signal_clicked, wd->obj);
357 evas_object_event_callback_add(eo, EVAS_CALLBACK_MOUSE_DOWN, ev_imageslider_down_cb, wd);
358 evas_object_event_callback_add(eo, EVAS_CALLBACK_MOUSE_UP, ev_imageslider_up_cb, wd);
359 evas_object_event_callback_add(eo, EVAS_CALLBACK_MOUSE_MOVE, ev_imageslider_move_cb, wd);
360 evas_object_resize(eo, wd->w, wd->h);
361 evas_object_move(eo, wd->w + INTERVAL_WIDTH, wd->y);
362 evas_object_clip_set(eo, wd->clip);
363 evas_object_show(eo);
368 // Shift next/previous Image Slider item in layouts.
370 _imageslider_obj_shift(Widget_Data * wd, Eina_Bool left)
374 if (wd->ly[BLOCK_LEFT])
376 evas_object_del(wd->ly[BLOCK_LEFT]);
377 wd->ly[BLOCK_LEFT] = NULL;
380 wd->ly[BLOCK_LEFT] = wd->ly[BLOCK_CENTER];
381 wd->ly[BLOCK_CENTER] = wd->ly[BLOCK_RIGHT];
382 wd->ly[BLOCK_RIGHT] = _imageslider_add_obj(wd);
386 if (wd->ly[BLOCK_RIGHT])
388 evas_object_del(wd->ly[BLOCK_RIGHT]);
389 wd->ly[BLOCK_RIGHT] = NULL;
392 wd->ly[BLOCK_RIGHT] = wd->ly[BLOCK_CENTER];
393 wd->ly[BLOCK_CENTER] = wd->ly[BLOCK_LEFT];
394 wd->ly[BLOCK_LEFT] = _imageslider_add_obj(wd);
398 // Move the current Image Slider item and update.
400 _imageslider_obj_move(Widget_Data * wd, Evas_Coord step)
404 wd->cur = eina_list_next(wd->cur);
407 wd->cur = eina_list_last(wd->its);
412 wd->step = -ANI_STEP;
414 _imageslider_obj_shift(wd, 0);
420 wd->cur = eina_list_prev(wd->cur);
424 wd->step = -ANI_STEP;
430 _imageslider_obj_shift(wd, 1);
439 wd->step = -ANI_STEP;
443 _imageslider_update(wd);
446 // Whenever MOUSE DOWN event occurs, Call this function.
448 ev_imageslider_down_cb(void *data, Evas * e, Evas_Object *obj, void *event_info)
450 Widget_Data *wd = data;
452 Evas_Event_Mouse_Down *ev = event_info;
454 Evas_Coord ix, iy, iw, ih;
456 Evas_Object *eo = NULL;
461 wd->down_pos = ev->canvas;
462 wd->timestamp = ev->timestamp;
463 wd->move_cnt = MOVE_STEP;
465 wd->dx = ev->canvas.x;
466 wd->dy = ev->canvas.y;
467 wd->mx = ev->canvas.x;
468 wd->my = ev->canvas.y;
473 eo = edje_object_part_swallow_get(elm_layout_edje_get(obj), "swl.photo");
475 evas_object_geometry_get(eo, &ix, &iy, &iw, &ih);
479 wd->on_zoom = EINA_TRUE;
480 edje_object_signal_emit(elm_layout_edje_get(obj), "block.off", "block");
485 // Whenever MOUSE UP event occurs, Call this function.
486 // And make Click Event also.
488 ev_imageslider_up_cb(void *data, Evas * e, Evas_Object *obj, void *event_info)
490 Widget_Data *wd = data;
492 Evas_Event_Mouse_Up *ev = event_info;
506 step = wd->down_pos.x - ev->canvas.x;
507 interval = ev->timestamp - wd->timestamp;
508 if (step == 0 || interval == 0)
510 fprintf(stderr, "[[[ DEBUG ]]]: case1: emit CLICK event\n");
511 evas_object_smart_callback_call(wd->obj, SIG_CLICKED, NULL);
514 if (interval < CLICK_TIME_MAX)
516 if (step < CLICK_WIDTH_MIN && step > CLICK_WIDTH_MIN)
518 fprintf(stderr, "[[[ DEBUG ]]]: case2: emit CLICK event\n");
519 evas_object_smart_callback_call(wd->obj, SIG_CLICKED, NULL);
524 if (interval < FLICK_TIME_MAX)
526 if (step < FLICK_WIDTH_MIN && step > FLICK_WIDTH_MIN)
528 fprintf(stderr, "[[[ DEBUG ]]]:ev_imageslider_up_cb-black zone (1)\n");
530 _imageslider_obj_move(wd, 0);
534 fprintf(stderr, "[[[ DEBUG ]]]:ev_imageslider_up_cb-black zone (2)\n");
536 _imageslider_obj_move(wd, step);
542 step = (wd->x - wd->move_x) << 1;
543 if (step <= wd->w && step >= -(wd->w))
545 fprintf(stderr, "[[[ DEBUG ]]]:ev_imageslider_up_cb-white zone (1)\n");
547 _imageslider_obj_move(wd, 0);
551 fprintf(stderr, "[[[ DEBUG ]]]:ev_imageslider_up_cb-white zone (2)\n");
553 _imageslider_obj_move(wd, step);
560 // Whenever MOUSE MOVE event occurs, Call this API.
562 ev_imageslider_move_cb(void *data, Evas * e, Evas_Object *obj, void *event_info)
570 Widget_Data *wd = data;
572 Evas_Event_Mouse_Move *ev = event_info;
574 Elm_Imageslider_Item *it;
579 if (wd->move_cnt == MOVE_STEP)
581 if (wd->on_hold == EINA_FALSE)
587 step = ev->cur.canvas.x - wd->down_pos.x;
593 wd->move_x = wd->x + ((ev->cur.canvas.x - wd->down_pos.x));
594 wd->move_y = wd->y + ((ev->cur.canvas.y - wd->down_pos.y));
598 _imageslider_update_center_pos(wd, wd->move_x, wd->move_y, wd->y, wd->w);
602 _imageslider_update_pos(wd, wd->move_x, wd->y, wd->w);
608 wd->mx = ev->cur.canvas.x;
609 wd->my = ev->cur.canvas.y;
612 sqrt((wd->mx - wd->mmx) * (wd->mx - wd->mmx) + (wd->my - wd->mmy) * (wd->my - wd->mmy));
614 eo = edje_object_part_swallow_get(elm_layout_edje_get(obj), "swl.photo");
617 it = eina_list_data_get(wd->cur);
618 if (((it->w * wd->ratio / wd->dratio) / it->ow) < MAX_ZOOM_SIZE)
620 edje_object_part_unswallow(elm_layout_edje_get(obj), eo);
621 evas_object_resize(eo, it->w * wd->ratio / wd->dratio, it->h * wd->ratio / wd->dratio);
622 evas_object_size_hint_min_set(eo, it->w * wd->ratio / wd->dratio, it->h * wd->ratio / wd->dratio);
623 edje_object_part_swallow(elm_layout_edje_get(obj), "swl.photo", eo);
633 // Whenever CLICK event occurs, Call this API
634 // But, DONOT emit CLICK event.
635 // DO NOT use this callback function. Remove later.
637 _signal_clicked(void *data, Evas_Object *obj, const char *emission, const char *source)
639 fprintf(stderr, "[[[ DEBUG ]]]: Call the callback function about Click event!, But DONOT emit CLICK event in the callback function!\n");
644 time_get(Evas_Coord x, Evas_Coord w)
648 time = (-sin(x / w) + 1) / 500;
657 _icon_to_image(void *data)
659 Widget_Data *wd = data;
662 _imageslider_update(wd);
666 ecore_idler_del(wd->queue_idler);
667 wd->queue_idler = NULL;
669 return ECORE_CALLBACK_CANCEL;
673 _check_drag(int state, void *data)
675 Widget_Data *wd = data;
677 Elm_Imageslider_Item *it;
679 Evas_Coord ix, iy, iw, ih;
683 Eina_List *l[BLOCK_MAX];
685 Evas_Object *eo = NULL;
687 l[BLOCK_LEFT] = eina_list_prev(wd->cur);
688 l[BLOCK_CENTER] = wd->cur;
689 l[BLOCK_RIGHT] = eina_list_next(wd->cur);
691 it = eina_list_data_get(l[state]);
693 eo = edje_object_part_swallow_get(elm_layout_edje_get(wd->ly[state]), "swl.photo");
695 evas_object_geometry_get(eo, &ix, &iy, &iw, &ih);
696 edje_object_part_drag_value_get(elm_layout_edje_get(wd->ly[state]), "swl.photo", &dx, &dy);
698 if ((iw != wd->w) || ((dx != 0) || (dy != 0)))
702 evas_object_del(wd->ly[state]);
703 wd->ly[state] = NULL;
705 wd->ly[state] = _imageslider_add_obj(wd);
714 _check_zoom(void *data)
716 Widget_Data *wd = data;
718 Elm_Imageslider_Item *it;
720 Evas_Coord ix, iy, iw, ih;
724 Evas_Object *eo = NULL;
726 it = eina_list_data_get(wd->cur);
729 edje_object_part_swallow_get(elm_layout_edje_get(wd->ly[BLOCK_CENTER]), "swl.photo");
731 evas_object_geometry_get(eo, &ix, &iy, &iw, &ih);
732 evas_object_geometry_get(eo, &ix, &iy, &iw, &ih);
733 edje_object_part_drag_value_get(elm_layout_edje_get(wd->ly[BLOCK_CENTER]), "swl.photo", &dx, &dy);
735 if ((iw != wd->w) || ((dx != 0) || (dy != 0)))
737 wd->on_zoom = EINA_TRUE;
738 edje_object_signal_emit(elm_layout_edje_get(wd->ly[BLOCK_CENTER]), "block.off", "block");
742 wd->on_zoom = EINA_FALSE;
743 edje_object_signal_emit(elm_layout_edje_get(wd->ly[BLOCK_CENTER]), "block.on", "block");
748 _timer_cb(void *data)
752 Elm_Imageslider_Item *it;
761 if (wd->ani_lock == 0)
764 gettimeofday(&tv, NULL);
766 t = (tv.tv_sec - wd->tv.tv_sec) * 1000 + (tv.tv_usec - wd->tv.tv_usec) / 1000;
767 gettimeofday(&wd->tv, NULL);
769 t = t / ANI_TIME_MSEC;
770 if (t <= STEP_WEIGHT_MIN)
772 else if (t > STEP_WEIGHT_MAX)
775 wd->move_x += (wd->step) * t;
777 if (wd->step < 0 && wd->move_x < wd->x)
779 else if (wd->step > 0 && wd->move_x > wd->x)
782 _imageslider_update_pos(wd, wd->move_x, wd->y, wd->w);
784 if (wd->move_x == wd->x)
789 it = eina_list_data_get(wd->cur);
791 it->func(it->data, wd->obj, it);
795 it = eina_list_data_get(wd->cur);
796 evas_object_smart_callback_call(wd->obj, "changed", it);
799 ret = _check_drag(BLOCK_LEFT, wd);
800 ret = _check_drag(BLOCK_RIGHT, wd);
803 if (!wd->queue_idler)
804 wd->queue_idler = ecore_idler_add(_icon_to_image, wd);
808 ecore_timer_del(wd->anim_timer);
809 wd->anim_timer = NULL;
812 return ECORE_CALLBACK_CANCEL;
815 return ECORE_CALLBACK_RENEW;
819 _anim(Widget_Data * wd)
823 if (wd->x == wd->move_x)
825 _imageslider_update_pos(wd, wd->move_x, wd->y, wd->w);
832 gettimeofday(&wd->tv, NULL);
835 wd->anim_timer = ecore_timer_add(ANI_TIME, _timer_cb, wd);
838 // Update Image Slider Items.
840 _imageslider_update(Widget_Data * wd)
844 Eina_List *l[BLOCK_MAX];
846 Elm_Imageslider_Item *it;
855 _imageslider_del_all(wd);
859 l[BLOCK_LEFT] = eina_list_prev(wd->cur);
860 l[BLOCK_CENTER] = wd->cur;
861 l[BLOCK_RIGHT] = eina_list_next(wd->cur);
863 for (i = 0; i < BLOCK_MAX; i++)
866 edje_object_part_swallow_get(elm_layout_edje_get(wd->ly[i]), "swl.photo");
869 elm_layout_content_set(wd->ly[i], "swl.photo", NULL);
874 it = eina_list_data_get(l[i]);
880 eo = elm_image_add(wd->obj);
881 elm_layout_content_set(wd->ly[i], "swl.photo", eo);
882 //elm_image_prescale_set(eo, wd->w);
883 elm_image_file_set(eo, it->photo_file, NULL);
884 elm_image_object_size_get(eo, &it->w, &it->h);
885 evas_object_geometry_get(eo, &it->ox, &it->oy, &it->ow, &it->oh);
890 if (wd->moving != it->moving)
892 it->moving = wd->moving;
895 //elm_image_prescale_set(eo, MOVING_IMAGE_SIZE);
899 //elm_image_prescale_set(eo, it->w > it->h ? it->w : it->h);
909 * Add an Image Slider widget
911 * @param parent The parent object
912 * @return The new Image slider object or NULL if it cannot be created
914 * @ingroup Imageslider
917 elm_imageslider_add(Evas_Object *parent)
921 Evas_Object *obj = NULL;
923 Widget_Data *wd = NULL;
930 wd = ELM_NEW(Widget_Data);
931 e = evas_object_evas_get(parent);
935 obj = elm_widget_add(e);
936 ELM_SET_WIDTYPE(widtype, "imageslider");
937 elm_widget_type_set(obj, "imageslider");
938 elm_widget_sub_object_add(parent, obj);
939 elm_widget_data_set(obj, wd);
940 elm_widget_del_hook_set(obj, _del_hook);
941 elm_widget_theme_hook_set(obj, _theme_hook);
943 wd->clip = evas_object_rectangle_add(e);
945 for (i = 0; i < BLOCK_MAX; i++)
947 wd->ly[i] = elm_layout_add(obj);
948 elm_layout_theme_set(wd->ly[i], "imageslider", "base", "default");
949 elm_widget_resize_object_set(obj, wd->ly[i]);
950 evas_object_smart_member_add(wd->ly[i], obj);
952 //edje_object_signal_callback_add(elm_layout_edje_get(wd->ly[i]), "elm,photo,clicked", "", _signal_clicked, obj);
953 evas_object_event_callback_add(wd->ly[i], EVAS_CALLBACK_MOUSE_DOWN, ev_imageslider_down_cb, wd);
954 evas_object_event_callback_add(wd->ly[i], EVAS_CALLBACK_MOUSE_UP, ev_imageslider_up_cb, wd);
955 evas_object_event_callback_add(wd->ly[i], EVAS_CALLBACK_MOUSE_MOVE, ev_imageslider_move_cb, wd);
956 evas_object_clip_set(wd->ly[i], wd->clip);
957 evas_object_show(wd->ly[i]);
962 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _imageslider_resize, obj);
963 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE, _imageslider_move, obj);
964 evas_object_event_callback_add(obj, EVAS_CALLBACK_SHOW, _imageslider_show, obj);
965 evas_object_event_callback_add(obj, EVAS_CALLBACK_HIDE, _imageslider_hide, obj);
973 * Append an Image Slider item
975 * @param obj The Image Slider object
976 * @param photo_file photo file path
977 * @param func callback function
978 * @param data callback data
979 * @return The Image Slider item handle or NULL
981 * @ingroup Imageslider
983 EAPI Elm_Imageslider_Item *
984 elm_imageslider_item_append(Evas_Object *obj, const char *photo_file, Elm_Imageslider_Cb func, void *data)
986 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
989 Elm_Imageslider_Item *it;
991 if (!obj || !(wd = elm_widget_data_get(obj)))
994 it = (Elm_Imageslider_Item *) calloc(1, sizeof(Elm_Imageslider_Item));
997 it->photo_file = eina_stringshare_add(photo_file);
1001 wd->its = eina_list_append(wd->its, it);
1006 _imageslider_update(wd);
1012 * Insert an Image Slider item into the Image Slider Widget by using the given index.
1014 * @param obj The Image Slider object
1015 * @param photo_file photo file path
1016 * @param func callback function
1017 * @param index required position
1018 * @param data callback data
1019 * @return The Image Slider item handle or NULL
1021 * @ingroup Imageslider
1023 EAPI Elm_Imageslider_Item *
1024 elm_imageslider_item_append_relative(Evas_Object *obj, const char *photo_file, Elm_Imageslider_Cb func, unsigned int index, void *data)
1026 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1029 Elm_Imageslider_Item *it;
1031 fprintf(stderr, "[[[ DEBUG ]]]:: New elm_imageslider_item_append_relative()\n");
1033 if (!obj || !(wd = elm_widget_data_get(obj)))
1036 it = (Elm_Imageslider_Item *) calloc(1, sizeof(Elm_Imageslider_Item));
1041 it->photo_file = eina_stringshare_add(photo_file);
1046 eina_list_append_relative(wd->its, it, eina_list_nth(wd->its, index - 2));
1051 _imageslider_update(wd);
1057 * Prepend Image Slider item
1059 * @param obj The Image Slider object
1060 * @param photo_file photo file path
1061 * @param func callback function
1062 * @param data callback data
1063 * @return The imageslider item handle or NULL
1065 * @ingroup Imageslider
1067 EAPI Elm_Imageslider_Item *
1068 elm_imageslider_item_prepend(Evas_Object *obj, const char *photo_file, Elm_Imageslider_Cb func, void *data)
1070 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1073 Elm_Imageslider_Item *it;
1075 if (!obj || !(wd = elm_widget_data_get(obj)))
1078 it = (Elm_Imageslider_Item *) calloc(1, sizeof(Elm_Imageslider_Item));
1079 it->photo_file = eina_stringshare_add(photo_file);
1083 wd->its = eina_list_prepend(wd->its, it);
1088 _imageslider_update(wd);
1094 * Delete the selected Image Slider item
1096 * @param it The selected Image Slider item handle
1098 * @ingroup Imageslider
1101 elm_imageslider_item_del(Elm_Imageslider_Item * it)
1105 Elm_Imageslider_Item *_it;
1109 if (!it || !(wd = elm_widget_data_get(it->obj)))
1112 EINA_LIST_FOREACH(wd->its, l, _it)
1117 wd->cur = eina_list_prev(wd->cur);
1118 wd->its = eina_list_remove(wd->its, it);
1125 _imageslider_update(wd);
1130 * Get the selected Image Slider item
1132 * @param obj The Image Slider object
1133 * @return The selected Image Slider item or NULL
1135 * @ingroup Imageslider
1137 EAPI Elm_Imageslider_Item *
1138 elm_imageslider_selected_item_get(Evas_Object *obj)
1140 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1143 if (!obj || (!(wd = elm_widget_data_get(obj))))
1149 return eina_list_data_get(wd->cur);
1153 * Get whether an Image Slider item is selected or not
1155 * @param it the selected Image Slider item
1156 * @return EINA_TRUE or EINA_FALSE
1158 * @ingroup Imageslider
1161 elm_imageslider_item_selected_get(Elm_Imageslider_Item * it)
1165 if (!it || !it->obj || (!(wd = elm_widget_data_get(it->obj))))
1171 if (eina_list_data_get(wd->cur) == it)
1179 * Set the selected Image Slider item
1181 * @param it The Imaga Slider item
1183 * @ingroup Imageslider
1186 elm_imageslider_item_selected_set(Elm_Imageslider_Item * it)
1192 Elm_Imageslider_Item *_it;
1198 if (!it || !it->obj || (!(wd = elm_widget_data_get(it->obj))))
1201 EINA_LIST_FOREACH(wd->its, l, _it)
1207 for (i = 0; i < BLOCK_MAX; i++)
1210 edje_object_part_swallow_get(elm_layout_edje_get(wd->ly[i]), "swl.photo");
1213 elm_layout_content_set(wd->ly[i], "swl.photo", NULL);
1214 evas_object_del(eo);
1218 _imageslider_update(wd);
1223 * Get the photo file path of given Image Slider item
1225 * @param it The Image Slider item
1226 * @return The photo file path or NULL;
1228 * @ingroup Imageslider
1231 elm_imageslider_item_photo_file_get(Elm_Imageslider_Item * it)
1236 return it->photo_file;
1240 * Get the previous Image Slider item
1242 * @param it The Image Slider item
1243 * @return The previous Image Slider item or NULL
1245 * @ingroup Imageslider
1247 EAPI Elm_Imageslider_Item *
1248 elm_imageslider_item_prev(Elm_Imageslider_Item * it)
1252 Elm_Imageslider_Item *_it;
1256 if (!it || (!(wd = elm_widget_data_get(it->obj))))
1259 EINA_LIST_FOREACH(wd->its, l, _it)
1263 l = eina_list_prev(l);
1266 return eina_list_data_get(l);
1274 * Get the next Image Slider item
1276 * @param it The Image Slider item
1277 * @return The next Image Slider item or NULL
1279 * @ingroup Imageslider
1281 EAPI Elm_Imageslider_Item *
1282 elm_imageslider_item_next(Elm_Imageslider_Item * it)
1286 Elm_Imageslider_Item *_it;
1290 if (!it || (!(wd = elm_widget_data_get(it->obj))))
1293 EINA_LIST_FOREACH(wd->its, l, _it)
1297 l = eina_list_next(l);
1300 return eina_list_data_get(l);
1308 * Move to the previous Image Slider item
1310 * @param obj The Image Slider object
1312 * @ingroup Imageslider
1315 elm_imageslider_prev(Evas_Object *obj)
1317 ELM_CHECK_WIDTYPE(obj, widtype);
1320 if (!obj || (!(wd = elm_widget_data_get(obj))))
1326 _imageslider_obj_move(wd, -1);
1330 * Move to the next Image Slider item
1332 * @param obj The Image Slider object
1334 * @ingroup Imageslider
1337 elm_imageslider_next(Evas_Object * obj)
1339 ELM_CHECK_WIDTYPE(obj, widtype);
1342 if (!obj || (!(wd = elm_widget_data_get(obj))))
1348 _imageslider_obj_move(wd, 1);