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);
537 // Whenever CLICK event occurs, Call this API
538 // But, DONOT emit CLICK event.
539 // DO NOT use this callback function. Remove later.
541 _signal_clicked(void *data, Evas_Object *obj, const char *emission, const char *source)
543 fprintf(stderr, "[[[ DEBUG ]]]: Call the callback function about Click event!, But DONOT emit CLICK event in the callback function!\n");
547 static inline double time_get(Evas_Coord x, Evas_Coord w)
550 time = (-sin(x / w) + 1) / 500;
552 if (time == 0) time = ANI_TIME;
557 static Eina_Bool _icon_to_image(void *data)
559 Widget_Data *wd = data;
561 _imageslider_update(wd);
563 if (wd->queue_idler) {
564 ecore_idler_del(wd->queue_idler);
565 wd->queue_idler = NULL;
567 return ECORE_CALLBACK_CANCEL;
570 static int _check_drag(int state, void *data)
572 Widget_Data *wd = data;
573 Elm_Imageslider_Item *it;
574 Evas_Coord ix, iy, iw, ih;
576 Eina_List *l[BLOCK_MAX];
577 Evas_Object *eo = NULL;
578 l[BLOCK_LEFT] = eina_list_prev(wd->cur);
579 l[BLOCK_CENTER] = wd->cur;
580 l[BLOCK_RIGHT] = eina_list_next(wd->cur);
582 it = eina_list_data_get(l[state]);
584 eo = edje_object_part_swallow_get(elm_layout_edje_get(wd->ly[state]), "swl.photo");
585 if (eo) evas_object_geometry_get(eo, &ix, &iy, &iw, &ih);
586 evas_object_geometry_get(eo, &ix, &iy, &iw, &ih);
587 edje_object_part_drag_value_get(elm_layout_edje_get(wd->ly[state]), "swl.photo", &dx, &dy);
589 if ((iw != wd->w) || ((dx != 0 ) || (dy != 0 ))) {
591 evas_object_del(wd->ly[state]);
592 wd->ly[state] = NULL;
594 wd->ly[state] = _imageslider_add_obj(wd);
603 static void _check_zoom(void *data)
605 Widget_Data *wd = data;
606 Elm_Imageslider_Item *it;
607 Evas_Coord ix, iy, iw, ih;
609 Evas_Object *eo = NULL;
611 it = eina_list_data_get(wd->cur);
613 eo = edje_object_part_swallow_get(elm_layout_edje_get(wd->ly[BLOCK_CENTER]), "swl.photo");
614 if (eo) evas_object_geometry_get(eo, &ix, &iy, &iw, &ih);
615 evas_object_geometry_get(eo, &ix, &iy, &iw, &ih);
616 edje_object_part_drag_value_get(elm_layout_edje_get(wd->ly[BLOCK_CENTER]), "swl.photo", &dx, &dy);
618 if ((iw != wd->w) || ((dx != 0) || (dy != 0))) {
619 wd->on_zoom = EINA_TRUE;
620 edje_object_signal_emit(elm_layout_edje_get(wd->ly[BLOCK_CENTER]), "block.off", "block");
623 wd->on_zoom = EINA_FALSE;
624 edje_object_signal_emit(elm_layout_edje_get(wd->ly[BLOCK_CENTER]), "block.on", "block");
629 static Eina_Bool _timer_cb(void *data)
632 Elm_Imageslider_Item *it;
637 if (wd->ani_lock == 0 ) return 0;
639 gettimeofday(&tv, NULL);
641 t = (tv.tv_sec - wd->tv.tv_sec) * 1000 + (tv.tv_usec - wd->tv.tv_usec) / 1000;
642 gettimeofday(&wd->tv, NULL);
644 t = t / ANI_TIME_MSEC;
645 if (t <= STEP_WEIGHT_MIN) t = STEP_WEIGHT_DEF;
646 else if (t > STEP_WEIGHT_MAX) t = STEP_WEIGHT_MAX;
648 wd->move_x += (wd->step) * t;
650 if (wd->step < 0 && wd->move_x < wd->x) wd->move_x = wd->x;
651 else if (wd->step > 0 && wd->move_x > wd->x) wd->move_x = wd->x;
653 _imageslider_update_pos(wd, wd->move_x, wd->y, wd->w);
655 if (wd->move_x == wd->x) {
658 it = eina_list_data_get(wd->cur);
659 if (it->func) it->func(it->data, wd->obj, it);
662 it = eina_list_data_get(wd->cur);
663 evas_object_smart_callback_call(wd->obj, "changed", it);
666 ret = _check_drag(BLOCK_LEFT, wd);
667 ret = _check_drag(BLOCK_RIGHT, wd);
670 if (!wd->queue_idler) wd->queue_idler = ecore_idler_add(_icon_to_image, wd);
673 ecore_timer_del(wd->anim_timer);
674 wd->anim_timer = NULL;
677 return ECORE_CALLBACK_CANCEL;
680 return ECORE_CALLBACK_RENEW;
684 static void _anim(Widget_Data *wd)
688 if (wd->x == wd->move_x) {
689 _imageslider_update_pos(wd, wd->move_x, wd->y, wd->w);
696 gettimeofday(&wd->tv, NULL);
698 if (!wd->anim_timer) {
699 wd->anim_timer = ecore_timer_add(ANI_TIME, _timer_cb, wd);
703 // Update Image Slider Items.
704 static void _imageslider_update(Widget_Data *wd)
707 Eina_List *l[BLOCK_MAX];
708 Elm_Imageslider_Item *it;
716 _imageslider_del_all(wd);
720 l[BLOCK_LEFT] = eina_list_prev(wd->cur);
721 l[BLOCK_CENTER] = wd->cur;
722 l[BLOCK_RIGHT] = eina_list_next(wd->cur);
724 for (i = 0; i < BLOCK_MAX; i++) {
725 eo = edje_object_part_swallow_get(elm_layout_edje_get(wd->ly[i]), "swl.photo");
727 elm_layout_content_set(wd->ly[i], "swl.photo", NULL);
730 it = eina_list_data_get(l[i]);
734 eo = elm_image_add(wd->obj);
735 elm_layout_content_set(wd->ly[i], "swl.photo", eo);
736 elm_image_prescale_set(eo, wd->w);
737 elm_image_file_set(eo, it->photo_file, NULL);
738 elm_image_object_size_get(eo, &it->w, &it->h);
739 evas_object_geometry_get(eo, &it->ox, &it->oy, &it->ow, &it->oh);
744 if (wd->moving != it->moving) {
745 it->moving = wd->moving;
747 elm_image_prescale_set(eo, MOVING_IMAGE_SIZE);
749 elm_image_prescale_set(eo, it->w > it->h ? it->w : it->h);
761 * Add an Image Slider widget
763 * @param parent The parent object
764 * @return The new Image slider object or NULL if it cannot be created
766 * @ingroup Imageslider
769 elm_imageslider_add(Evas_Object * parent)
772 Evas_Object *obj = NULL;
773 Widget_Data *wd = NULL;
780 wd = ELM_NEW(Widget_Data);
781 e = evas_object_evas_get(parent);
786 obj = elm_widget_add(e);
787 ELM_SET_WIDTYPE(widtype, "imageslider");
788 elm_widget_type_set(obj, "imageslider");
789 elm_widget_sub_object_add(parent, obj);
790 elm_widget_data_set(obj, wd);
791 //wd->parent = parent;
792 elm_widget_del_hook_set(obj, _del_hook);
793 //elm_widget_theme_hook_set(obj, _theme_hook);
795 wd->clip = evas_object_rectangle_add(e);
797 for (i=0; i < BLOCK_MAX; i++) {
798 wd->ly[i] = elm_layout_add(obj);
799 elm_layout_theme_set(wd->ly[i], "imageslider", "base", "default");
800 elm_widget_resize_object_set(obj, wd->ly[i]);
801 evas_object_smart_member_add(wd->ly[i], obj);
803 //edje_object_signal_callback_add(elm_layout_edje_get(wd->ly[i]), "elm,photo,clicked", "", _signal_clicked, obj);
804 evas_object_event_callback_add(wd->ly[i], EVAS_CALLBACK_MOUSE_DOWN, ev_imageslider_down_cb, wd);
805 evas_object_event_callback_add(wd->ly[i], EVAS_CALLBACK_MOUSE_UP, ev_imageslider_up_cb, wd);
806 evas_object_event_callback_add(wd->ly[i], EVAS_CALLBACK_MOUSE_MOVE, ev_imageslider_move_cb, wd);
807 evas_object_clip_set(wd->ly[i], wd->clip);
808 evas_object_show(wd->ly[i]);
813 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _imageslider_resize, obj);
814 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE, _imageslider_move, obj);
815 evas_object_event_callback_add(obj, EVAS_CALLBACK_SHOW, _imageslider_show, obj);
816 evas_object_event_callback_add(obj, EVAS_CALLBACK_HIDE, _imageslider_hide, obj);
825 * Append an Image Slider item
827 * @param obj The Image Slider object
828 * @param photo_file photo file path
829 * @param func callback function
830 * @param data callback data
831 * @return The Image Slider item handle or NULL
833 * @ingroup Imageslider
835 EAPI Elm_Imageslider_Item *
836 elm_imageslider_item_append(Evas_Object * obj, const char * photo_file, Elm_Imageslider_Cb func, void * data)
838 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
840 Elm_Imageslider_Item *it;
842 if (!obj || !(wd = elm_widget_data_get(obj))) {
846 it = (Elm_Imageslider_Item *)calloc(1, sizeof(Elm_Imageslider_Item));
847 if (!it) return NULL;
848 it->photo_file = eina_stringshare_add(photo_file);
852 wd->its = eina_list_append(wd->its, it);
854 if (!wd->cur) wd->cur = wd->its;
856 _imageslider_update(wd);
862 * Insert an Image Slider item into the Image Slider Widget by using the given index.
864 * @param obj The Image Slider object
865 * @param photo_file photo file path
866 * @param func callback function
867 * @param index required position
868 * @param data callback data
869 * @return The Image Slider item handle or NULL
871 * @ingroup Imageslider
873 EAPI Elm_Imageslider_Item *
874 elm_imageslider_item_append_relative(Evas_Object *obj, const char *photo_file, Elm_Imageslider_Cb func, unsigned int index, void *data)
876 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
878 Elm_Imageslider_Item *it;
880 fprintf(stderr, "[[[ DEBUG ]]]:: New elm_imageslider_item_append_relative()\n");
882 if (!obj || !(wd = elm_widget_data_get(obj))) {
886 it = (Elm_Imageslider_Item *)calloc(1, sizeof(Elm_Imageslider_Item));
887 if (!it) return NULL;
890 it->photo_file = eina_stringshare_add(photo_file);
894 wd->its = eina_list_append_relative(wd->its, it, eina_list_nth(wd->its, index-2));
896 if (!wd->cur) wd->cur = wd->its;
898 _imageslider_update(wd);
905 * Prepend Image Slider item
907 * @param obj The Image Slider object
908 * @param photo_file photo file path
909 * @param func callback function
910 * @param data callback data
911 * @return The imageslider item handle or NULL
913 * @ingroup Imageslider
915 EAPI Elm_Imageslider_Item *
916 elm_imageslider_item_prepend(Evas_Object * obj, const char * photo_file, Elm_Imageslider_Cb func, void * data)
918 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
920 Elm_Imageslider_Item *it;
922 if (!obj || !(wd = elm_widget_data_get(obj))) {
926 it = (Elm_Imageslider_Item *)calloc(1, sizeof(Elm_Imageslider_Item));
927 it->photo_file = eina_stringshare_add(photo_file);
931 wd->its = eina_list_prepend(wd->its, it );
933 if (!wd->cur) wd->cur = wd->its;
935 _imageslider_update(wd);
943 * Delete the selected Image Slider item
945 * @param it The selected Image Slider item handle
947 * @ingroup Imageslider
950 elm_imageslider_item_del(Elm_Imageslider_Item * it)
953 Elm_Imageslider_Item *_it;
956 if (!it || !(wd = elm_widget_data_get(it->obj))) {
960 EINA_LIST_FOREACH(wd->its, l, _it) {
962 if (l == wd->cur) wd->cur = eina_list_prev(wd->cur);
963 wd->its = eina_list_remove(wd->its, it);
964 if (!wd->cur) wd->cur = wd->its;
969 _imageslider_update(wd);
975 * Get the selected Image Slider item
977 * @param obj The Image Slider object
978 * @return The selected Image Slider item or NULL
980 * @ingroup Imageslider
982 EAPI Elm_Imageslider_Item *
983 elm_imageslider_selected_item_get(Evas_Object * obj)
985 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
988 if (!obj || (!(wd = elm_widget_data_get(obj)))) {
992 if (!wd->cur) return NULL;
994 return eina_list_data_get(wd->cur);
998 * Get whether an Image Slider item is selected or not
1000 * @param it the selected Image Slider item
1001 * @return EINA_TRUE or EINA_FALSE
1003 * @ingroup Imageslider
1006 elm_imageslider_item_selected_get(Elm_Imageslider_Item * it)
1010 if (!it || !it->obj || (!(wd = elm_widget_data_get(it->obj)))) {
1014 if (!wd->cur) return EINA_FALSE;
1016 if (eina_list_data_get(wd->cur) == it ) return EINA_TRUE;
1017 else return EINA_FALSE;
1022 * Set the selected Image Slider item
1024 * @param it The Imaga Slider item
1026 * @ingroup Imageslider
1029 elm_imageslider_item_selected_set(Elm_Imageslider_Item * it)
1033 Elm_Imageslider_Item *_it;
1037 if (!it || !it->obj || (!(wd = elm_widget_data_get(it->obj)))) {
1041 EINA_LIST_FOREACH(wd->its, l, _it) {
1047 for (i = 0; i < BLOCK_MAX; i++) {
1048 eo = edje_object_part_swallow_get(elm_layout_edje_get(wd->ly[i]), "swl.photo");
1050 elm_layout_content_set(wd->ly[i], "swl.photo", NULL);
1051 evas_object_del(eo);
1055 _imageslider_update(wd);
1061 * Get the photo file path of given Image Slider item
1063 * @param it The Image Slider item
1064 * @return The photo file path or NULL;
1066 * @ingroup Imageslider
1069 elm_imageslider_item_photo_file_get(Elm_Imageslider_Item * it)
1075 return it->photo_file;
1080 * Get the previous Image Slider item
1082 * @param it The Image Slider item
1083 * @return The previous Image Slider item or NULL
1085 * @ingroup Imageslider
1087 EAPI Elm_Imageslider_Item *
1088 elm_imageslider_item_prev(Elm_Imageslider_Item * it)
1091 Elm_Imageslider_Item *_it;
1094 if (!it || (!(wd = elm_widget_data_get(it->obj)))) {
1098 EINA_LIST_FOREACH(wd->its, l, _it) {
1100 l = eina_list_prev(l);
1102 return eina_list_data_get(l);
1111 * Get the next Image Slider item
1113 * @param it The Image Slider item
1114 * @return The next Image Slider item or NULL
1116 * @ingroup Imageslider
1118 EAPI Elm_Imageslider_Item *
1119 elm_imageslider_item_next(Elm_Imageslider_Item * it)
1122 Elm_Imageslider_Item *_it;
1125 if (!it || (!(wd = elm_widget_data_get(it->obj)))) {
1129 EINA_LIST_FOREACH(wd->its, l, _it) {
1131 l = eina_list_next(l);
1133 return eina_list_data_get(l);
1142 * Move to the previous Image Slider item
1144 * @param obj The Image Slider object
1146 * @ingroup Imageslider
1149 elm_imageslider_prev(Evas_Object * obj)
1151 ELM_CHECK_WIDTYPE(obj, widtype);
1154 if (!obj || (!(wd = elm_widget_data_get(obj)))) {
1158 if (wd->ani_lock) return;
1160 _imageslider_obj_move(wd, -1);
1165 * Move to the next Image Slider item
1167 * @param obj The Image Slider object
1169 * @ingroup Imageslider
1172 elm_imageslider_next(Evas_Object * obj)
1174 ELM_CHECK_WIDTYPE(obj, widtype);
1177 if (!obj || (!(wd = elm_widget_data_get(obj)))) {
1181 if (wd->ani_lock) return;
1183 _imageslider_obj_move(wd, 1);