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 FLICK_TIME_MAX (200)
24 #define FLICK_WIDTH_MIN (elm_finger_size_get() >> 2)
26 #define STEP_WEIGHT_DEF (1)
27 #define STEP_WEIGHT_MAX (2)
28 #define STEP_WEIGHT_MIN (0)
29 #define MOVING_IMAGE_SIZE (128)
30 #define MAX_ZOOM_SIZE (6)
31 #define INTERVAL_WIDTH (15)
32 #define MULTITOUCHDEVICE (11)
41 struct _Imageslider_Item
44 const char *photo_file;
45 void (*func)(void *data, Evas_Object *obj, void *event_info);
47 Evas_Coord x, y, w, h;
48 Evas_Coord ox, oy, ow, oh;
54 Evas_Object *ly[BLOCK_MAX];
58 Evas_Coord x, y, w, h;
60 Ecore_Idler *queue_idler;
61 Ecore_Timer *anim_timer;
63 Evas_Coord_Point down_pos;
68 unsigned int timestamp;
74 Eina_Bool on_zoom : 1;
75 Eina_Bool on_hold : 1;
77 int mdx, mdy, mmx, mmy;
83 static const char *widtype = NULL;
84 static void _del_hook(Evas_Object *obj);
85 static void _theme_hook(Evas_Object *obj);
86 static void _sizing_eval(Evas_Object *obj);
87 static void _imageslider_del_all(Widget_Data *wd);
88 static void _imageslider_move(void *data,Evas *e, Evas_Object *obj, void *event_info);
89 static void _imageslider_resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
90 //static void _imageslider_show(Evas_Object *obj);
91 //static void _imageslider_hide(Evas_Object *obj);
92 static void _imageslider_show(void * data, Evas * e, Evas_Object * obj, void * event_info);
93 static void _imageslider_hide(void * data, Evas * e, Evas_Object * obj, void * event_info);
94 static void _imageslider_update(Widget_Data *wd);
95 static void _imageslider_update_pos(Widget_Data *wd, Evas_Coord x, Evas_Coord y, Evas_Coord w);
96 static void _imageslider_update_center_pos(Widget_Data *wd, Evas_Coord x, Evas_Coord my, Evas_Coord y, Evas_Coord w);
97 static Evas_Object *_imageslider_add_obj(Widget_Data *wd);
98 static void _imageslider_obj_shift(Widget_Data *wd, Eina_Bool left);
99 static void _imageslider_obj_move(Widget_Data *wd, Evas_Coord step);
100 static int _icon_to_image(void *data);
101 static int _check_drag(int state, void *data);
102 static void _check_zoom(void *data);
103 static void _anim(Widget_Data *wd);
104 static int _timer_cb(void *data);
105 static void ev_imageslider_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
106 static void ev_imageslider_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
107 static void ev_imageslider_move_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
109 static void _del_hook(Evas_Object * obj)
113 wd = elm_widget_data_get(obj);
115 fprintf( stderr, "Call imageslider del hook!\n" );
119 for (i = 0; i < BLOCK_MAX; i++) {
120 evas_object_del(wd->ly[i]);
124 eina_list_free(wd->its);
128 if (wd->queue_idler) {
129 ecore_idler_del(wd->queue_idler);
130 wd->queue_idler = NULL;
133 if (wd->anim_timer) {
134 ecore_timer_del(wd->anim_timer);
135 wd->anim_timer = NULL;
142 static void _theme_hook(Evas_Object * obj)
146 wd = elm_widget_data_get(obj);
148 if (!wd || !wd->ly ) {
152 for (i=0; i < BLOCK_MAX; i++) {
153 wd->ly[i] = elm_layout_add(obj);
154 _elm_theme_object_set(obj, wd->ly[i], "imageslider", "base", "default");
155 elm_widget_resize_object_set(obj, wd->ly[i]);
156 evas_object_show(wd->ly[i]);
163 static void _sizing_eval(Evas_Object * obj)
166 Widget_Data *wd = elm_widget_data_get(obj);
172 e = evas_object_evas_get(wd->obj);
174 _imageslider_move(obj, e, obj, NULL);
175 _imageslider_resize(obj, e, obj, NULL);
179 static void _imageslider_move(void * data, Evas * e, Evas_Object * obj, void * event_info)
188 wd = elm_widget_data_get((Evas_Object *) data);
193 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
196 evas_object_move(wd->clip, x, y);
198 _imageslider_update_pos(wd, wd->x, wd->y, wd->w);
202 static void _imageslider_resize(void * data, Evas * e, Evas_Object * obj, void * event_info)
212 wd = elm_widget_data_get((Evas_Object *) data);
213 if (!wd || !wd->ly) {
217 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
218 fprintf( stderr, "%d %d -resize\n" , w, h );
222 for (i = 0; i < BLOCK_MAX; i++) {
223 evas_object_resize(wd->ly[i], w, h);
226 evas_object_resize(wd->clip, w, h);
228 _imageslider_update_pos(wd, wd->x, wd->y, wd->w);
233 //static void _imageslider_show(Evas_Object * obj)
234 static void _imageslider_show(void *data, Evas *e, Evas_Object * obj, void *event_info)
242 wd = elm_widget_data_get((Evas_Object *) data);
247 evas_object_show(wd->clip);
250 //static void _imageslider_hide(Evas_Object *obj)
251 static void _imageslider_hide(void *data, Evas *e, Evas_Object *obj, void *event_info)
259 wd = elm_widget_data_get((Evas_Object *) data);
263 evas_object_hide(wd->clip);
266 static void _imageslider_del_all(Widget_Data * wd)
275 for (i = 0; i < BLOCK_MAX; i++) {
276 evas_object_del(wd->ly[i]);
280 static void _imageslider_update_pos(Widget_Data * wd, Evas_Coord x, Evas_Coord y, Evas_Coord w)
282 evas_object_move(wd->ly[BLOCK_LEFT], x - (w + INTERVAL_WIDTH), y);
283 evas_object_move(wd->ly[BLOCK_CENTER], x, y);
284 evas_object_move(wd->ly[BLOCK_RIGHT], x + (w + INTERVAL_WIDTH), y);
285 evas_render_idle_flush(evas_object_evas_get(wd->obj));
288 static void _imageslider_update_center_pos(Widget_Data * wd, Evas_Coord x, Evas_Coord my, Evas_Coord y, Evas_Coord w)
291 Evas_Coord ix, iy, iw, ih;
293 eo = edje_object_part_swallow_get(elm_layout_edje_get(wd->ly[BLOCK_CENTER]), "swl.photo");
294 evas_object_geometry_get(eo, &ix, &iy, &iw, &ih);
296 if ((ix > 0) || (ix + iw < wd->w)) {
297 edje_object_signal_emit(elm_layout_edje_get(wd->ly[BLOCK_CENTER]), "block.on", "block");
299 // evas_event_feed_mouse_cancel(evas_object_evas_get(wd->obj), NULL, NULL);
300 // evas_event_feed_mouse_down(evas_object_evas_get(wd->obj), 1, EVAS_BUTTON_NONE, NULL, NULL);
302 _imageslider_update_pos(wd, x, y, w);
303 wd->on_zoom = EINA_FALSE;
307 static Evas_Object *_imageslider_add_obj(Widget_Data *wd)
310 eo = elm_layout_add(wd->obj);
311 elm_layout_theme_set(eo, "imageslider", "base", "default");
312 elm_widget_resize_object_set(wd->obj, eo);
313 // evas_object_smart_member_add(eo, wd->obj);
314 evas_object_event_callback_add(eo, EVAS_CALLBACK_MOUSE_DOWN, ev_imageslider_down_cb, wd);
315 evas_object_event_callback_add(eo, EVAS_CALLBACK_MOUSE_UP, ev_imageslider_up_cb, wd);
316 evas_object_event_callback_add(eo, EVAS_CALLBACK_MOUSE_MOVE, ev_imageslider_move_cb, wd);
317 evas_object_resize(eo, wd->w, wd->h);
318 evas_object_move(eo, wd->w + INTERVAL_WIDTH, wd->y);
319 evas_object_clip_set(eo, wd->clip);
320 evas_object_show(eo);
325 static void _imageslider_obj_shift(Widget_Data *wd, Eina_Bool left)
328 if (wd->ly[BLOCK_LEFT]) {
329 evas_object_del(wd->ly[BLOCK_LEFT]);
330 wd->ly[BLOCK_LEFT] = NULL;
333 wd->ly[BLOCK_LEFT] = wd->ly[BLOCK_CENTER];
334 wd->ly[BLOCK_CENTER]= wd->ly[BLOCK_RIGHT];
335 wd->ly[BLOCK_RIGHT] = _imageslider_add_obj(wd);
337 if (wd->ly[BLOCK_RIGHT]) {
338 evas_object_del(wd->ly[BLOCK_RIGHT]);
339 wd->ly[BLOCK_RIGHT] = NULL;
342 wd->ly[BLOCK_RIGHT]= wd->ly[BLOCK_CENTER];
343 wd->ly[BLOCK_CENTER]= wd->ly[BLOCK_LEFT];
344 wd->ly[BLOCK_LEFT]= _imageslider_add_obj(wd);
349 static void _imageslider_obj_move(Widget_Data * wd, Evas_Coord step)
352 wd->cur = eina_list_next(wd->cur);
353 if (wd->cur == NULL) {
354 wd->cur = eina_list_last(wd->its);
357 wd->step = -ANI_STEP;
359 _imageslider_obj_shift(wd, 0);
362 } else if (step < 0) {
363 wd->cur = eina_list_prev(wd->cur);
364 if (wd->cur == NULL) {
366 wd->step = -ANI_STEP;
370 _imageslider_obj_shift(wd, 1);
374 if (wd->move_x < 0) wd->step = ANI_STEP;
375 else wd->step = -ANI_STEP;
379 _imageslider_update(wd);
382 static void ev_imageslider_down_cb(void * data, Evas * e, Evas_Object * obj, void * event_info)
384 Widget_Data *wd = data;
385 Evas_Event_Mouse_Down *ev = event_info;
386 Evas_Coord ix, iy, iw, ih;
387 Evas_Object *eo = NULL;
389 if (wd->ani_lock) return;
391 wd->down_pos = ev->canvas;
392 wd->timestamp = ev->timestamp;
393 wd->move_cnt = MOVE_STEP;
395 wd->dx = ev->canvas.x;
396 wd->dy = ev->canvas.y;
397 wd->mx = ev->canvas.x;
398 wd->my = ev->canvas.y;
403 eo = edje_object_part_swallow_get(elm_layout_edje_get(obj), "swl.photo");
404 if (eo) evas_object_geometry_get(eo, &ix, &iy, &iw, &ih);
407 wd->on_zoom = EINA_TRUE;
408 edje_object_signal_emit(elm_layout_edje_get(obj), "block.off", "block");
412 fprintf( stderr, "down!\n" );
416 static void ev_imageslider_up_cb(void * data, Evas * e, Evas_Object * obj, void * event_info)
418 Widget_Data *wd = data;
419 Evas_Event_Mouse_Up *ev = event_info;
423 if (wd->ani_lock) return;
427 step = wd->down_pos.x - ev->canvas.x;
428 interval = ev->timestamp - wd->timestamp;
429 if (step == 0 || interval == 0) return;
431 if (interval < FLICK_TIME_MAX) {
432 if (step < FLICK_WIDTH_MIN && step > FLICK_WIDTH_MIN) _imageslider_obj_move(wd, 0);
433 else _imageslider_obj_move(wd, step);
435 step = (wd->x - wd->move_x) << 1;
436 if (step <= wd->w && step >= -(wd->w)) _imageslider_obj_move(wd, 0);
437 else _imageslider_obj_move(wd, step);
443 static void ev_imageslider_move_cb(void * data, Evas * e, Evas_Object * obj, void * event_info)
448 Widget_Data *wd = data;
449 Evas_Event_Mouse_Move *ev = event_info;
450 Elm_Imageslider_Item *it;
452 if (wd->ani_lock) return;
454 if (wd->move_cnt == MOVE_STEP) {
455 if (wd->on_hold == EINA_FALSE) {
459 step = ev->cur.canvas.x - wd->down_pos.x;
460 if (step > 0) idx = BLOCK_LEFT;
461 else idx = BLOCK_RIGHT;
463 wd->move_x = wd->x + ((ev->cur.canvas.x - wd->down_pos.x));
464 wd->move_y = wd->y + ((ev->cur.canvas.y - wd->down_pos.y));
467 _imageslider_update_center_pos(wd, wd->move_x, wd->move_y, wd->y, wd->w);
469 _imageslider_update_pos(wd, wd->move_x, wd->y, wd->w);
473 wd->mx = ev->cur.canvas.x;
474 wd->my = ev->cur.canvas.y;
476 wd->ratio = sqrt((wd->mx -wd->mmx)*(wd->mx -wd->mmx) + (wd->my - wd->mmy)*(wd->my - wd->mmy));
478 eo = edje_object_part_swallow_get(elm_layout_edje_get(obj), "swl.photo");
480 it = eina_list_data_get(wd->cur);
481 if (((it->w * wd->ratio/wd->dratio)/it->ow) < MAX_ZOOM_SIZE ) {
482 edje_object_part_unswallow(elm_layout_edje_get(obj), eo);
483 evas_object_resize(eo, it->w * wd->ratio/wd->dratio, it->h * wd->ratio/wd->dratio);
484 evas_object_size_hint_min_set(eo, it->w * wd->ratio/wd->dratio, it->h * wd->ratio/wd->dratio);
485 edje_object_part_swallow(elm_layout_edje_get(obj), "swl.photo", eo);
496 #if 0 // REMOVED about Multi-touch.
497 static void ev_imageslider_multi_down_cb(void * data, Evas * e, Evas_Object * obj, void * event_info)
499 Evas_Event_Multi_Down *ev = event_info;
500 Widget_Data *wd = data;
502 if (ev->device == MULTITOUCHDEVICE) return;
504 wd->on_hold = EINA_TRUE;
505 wd->mdx = ev->canvas.x;
506 wd->mdy = ev->canvas.y;
507 wd->mmx = ev->canvas.x;
508 wd->mmy = ev->canvas.y;
510 wd->dratio = sqrt((wd->mx - wd->mmx)*(wd->mx - wd->mmx) + (wd->my - wd->mmy)*(wd->my - wd->mmy));
511 wd->ratio = sqrt((wd->mx - wd->mmx)*(wd->mx - wd->mmx)+ (wd->my - wd->mmy)*(wd->my - wd->mmy));
514 wd->on_zoom = EINA_FALSE;
515 edje_object_signal_emit(elm_layout_edje_get(obj), "block.on", "block");
520 static void ev_imageslider_multi_up_cb(void * data, Evas * e, Evas_Object * obj, void * event_info)
522 Evas_Event_Multi_Up *ev = event_info;
523 Widget_Data *wd = data;
524 Elm_Imageslider_Item *it;
526 if (ev->device == MULTITOUCHDEVICE) return;
528 it = eina_list_data_get(wd->cur);
529 it->w = (int)it->w * wd->ratio/wd->dratio;
530 it->h = (int)it->h * wd->ratio/wd->dratio;
532 if (it->w != it->ow) {
533 wd->on_zoom = EINA_TRUE;
534 edje_object_signal_emit(elm_layout_edje_get(obj), "block.off", "block");
537 wd->on_zoom = EINA_FALSE;
540 wd->on_hold = EINA_FALSE;
550 static void ev_imageslider_multi_move_cb(void * data, Evas * e, Evas_Object * obj, void * event_info)
552 Evas_Event_Multi_Move *ev = event_info;
553 Widget_Data *wd = data;
554 Evas_Object *eo = NULL;
555 Elm_Imageslider_Item *it;
557 if (ev->device == MULTITOUCHDEVICE) return;
559 if ((wd->mdx == 0) && (wd->mdy == 0) && (wd->mmx == 0) && (wd->mmy == 0)) {
560 wd->mdx = ev->cur.canvas.x;
561 wd->mdy = ev->cur.canvas.y;
562 wd->mmx = ev->cur.canvas.x;
563 wd->mmy = ev->cur.canvas.y;
565 wd->dratio = sqrt((wd->dx - wd->mdx)*(wd->dx - wd->mdx) + (wd->dy - wd->mdy)*(wd->dy - wd->mdy));
568 wd->mmx = ev->cur.canvas.x;
569 wd->mmy = ev->cur.canvas.y;
570 wd->ratio = sqrt((wd->mx - wd->mmx)*(wd->mx - wd->mmx) + (wd->my - wd->mmy)*(wd->my - wd->mmy));
572 eo = edje_object_part_swallow_get(elm_layout_edje_get(obj), "swl.photo");
575 it = eina_list_data_get(wd->cur);
576 if (((it->w * wd->ratio/wd->dratio)/it->ow) < MAX_ZOOM_SIZE) {
577 edje_object_part_unswallow(elm_layout_edje_get(obj), eo);
578 evas_object_resize(eo, it->w * wd->ratio/wd->dratio, it->h * wd->ratio/wd->dratio);
579 evas_object_size_hint_min_set(eo, it->w * wd->ratio/wd->dratio, it->h * wd->ratio/wd->dratio);
580 edje_object_part_swallow(elm_layout_edje_get(obj), "swl.photo", eo);
585 #endif // about Multi-touch.
587 static inline double time_get(Evas_Coord x, Evas_Coord w)
590 time = (-sin(x / w) + 1) / 500;
592 if (time == 0) time = ANI_TIME;
597 static int _icon_to_image(void *data)
599 Widget_Data *wd = data;
601 _imageslider_update(wd);
603 if (wd->queue_idler) {
604 ecore_idler_del(wd->queue_idler);
605 wd->queue_idler = NULL;
607 return ECORE_CALLBACK_CANCEL;
610 static int _check_drag(int state, void *data)
612 Widget_Data *wd = data;
613 Elm_Imageslider_Item *it;
614 Evas_Coord ix, iy, iw, ih;
616 Eina_List *l[BLOCK_MAX];
617 Evas_Object *eo = NULL;
618 l[BLOCK_LEFT] = eina_list_prev(wd->cur);
619 l[BLOCK_CENTER] = wd->cur;
620 l[BLOCK_RIGHT] = eina_list_next(wd->cur);
622 it = eina_list_data_get(l[state]);
624 eo = edje_object_part_swallow_get(elm_layout_edje_get(wd->ly[state]), "swl.photo");
625 if (eo) evas_object_geometry_get(eo, &ix, &iy, &iw, &ih);
626 evas_object_geometry_get(eo, &ix, &iy, &iw, &ih);
627 edje_object_part_drag_value_get(elm_layout_edje_get(wd->ly[state]), "swl.photo", &dx, &dy);
629 if ((iw != wd->w) || ((dx != 0 ) || (dy != 0 ))) {
631 evas_object_del(wd->ly[state]);
632 wd->ly[state] = NULL;
634 wd->ly[state] = _imageslider_add_obj(wd);
643 static void _check_zoom(void *data)
645 Widget_Data *wd = data;
646 Elm_Imageslider_Item *it;
647 Evas_Coord ix, iy, iw, ih;
649 Evas_Object *eo = NULL;
651 it = eina_list_data_get(wd->cur);
653 eo = edje_object_part_swallow_get(elm_layout_edje_get(wd->ly[BLOCK_CENTER]), "swl.photo");
654 if (eo) evas_object_geometry_get(eo, &ix, &iy, &iw, &ih);
655 evas_object_geometry_get(eo, &ix, &iy, &iw, &ih);
656 edje_object_part_drag_value_get(elm_layout_edje_get(wd->ly[BLOCK_CENTER]), "swl.photo", &dx, &dy);
658 if ((iw != wd->w) || ((dx != 0) || (dy != 0))) {
659 wd->on_zoom = EINA_TRUE;
660 edje_object_signal_emit(elm_layout_edje_get(wd->ly[BLOCK_CENTER]), "block.off", "block");
663 wd->on_zoom = EINA_FALSE;
664 edje_object_signal_emit(elm_layout_edje_get(wd->ly[BLOCK_CENTER]), "block.on", "block");
670 static int _timer_cb(void *data)
673 Elm_Imageslider_Item *it;
678 if (wd->ani_lock == 0 ) return 0;
680 gettimeofday(&tv, NULL);
682 t = (tv.tv_sec - wd->tv.tv_sec) * 1000 + (tv.tv_usec - wd->tv.tv_usec) / 1000;
683 gettimeofday(&wd->tv, NULL);
685 t = t / ANI_TIME_MSEC;
686 if (t <= STEP_WEIGHT_MIN) t = STEP_WEIGHT_DEF;
687 else if (t > STEP_WEIGHT_MAX) t = STEP_WEIGHT_MAX;
689 wd->move_x += (wd->step) * t;
691 if (wd->step < 0 && wd->move_x < wd->x) wd->move_x = wd->x;
692 else if (wd->step > 0 && wd->move_x > wd->x) wd->move_x = wd->x;
694 _imageslider_update_pos(wd, wd->move_x, wd->y, wd->w);
696 if (wd->move_x == wd->x) {
699 it = eina_list_data_get(wd->cur);
700 if (it->func) it->func(it->data, wd->obj, it);
703 it = eina_list_data_get(wd->cur);
704 evas_object_smart_callback_call(wd->obj, "changed", it);
707 ret = _check_drag(BLOCK_LEFT, wd);
708 ret = _check_drag(BLOCK_RIGHT, wd);
711 if (!wd->queue_idler) wd->queue_idler = ecore_idler_add(_icon_to_image, wd);
714 ecore_timer_del(wd->anim_timer);
715 wd->anim_timer = NULL;
718 return ECORE_CALLBACK_CANCEL;
721 return ECORE_CALLBACK_RENEW;
725 static void _anim(Widget_Data *wd)
729 if (wd->x == wd->move_x) {
730 _imageslider_update_pos(wd, wd->move_x, wd->y, wd->w);
737 gettimeofday(&wd->tv, NULL);
739 if (!wd->anim_timer) {
740 wd->anim_timer = ecore_timer_add(ANI_TIME, _timer_cb, wd);
744 static void _imageslider_update(Widget_Data *wd)
747 Eina_List *l[BLOCK_MAX];
748 Elm_Imageslider_Item *it;
756 _imageslider_del_all(wd);
760 l[BLOCK_LEFT] = eina_list_prev(wd->cur);
761 l[BLOCK_CENTER] = wd->cur;
762 l[BLOCK_RIGHT] = eina_list_next(wd->cur);
764 for (i = 0; i < BLOCK_MAX; i++) {
765 eo = edje_object_part_swallow_get(elm_layout_edje_get(wd->ly[i]), "swl.photo");
767 elm_layout_content_set(wd->ly[i], "swl.photo", NULL);
770 it = eina_list_data_get(l[i]);
774 eo = elm_image_add(wd->obj);
775 elm_layout_content_set(wd->ly[i], "swl.photo", eo);
776 elm_image_prescale_set(eo, wd->w);
777 elm_image_file_set(eo, it->photo_file, NULL);
778 elm_image_object_size_get(eo, &it->w, &it->h);
779 evas_object_geometry_get(eo, &it->ox, &it->oy, &it->ow, &it->oh);
784 if (wd->moving != it->moving) {
785 it->moving = wd->moving;
787 elm_image_prescale_set(eo, MOVING_IMAGE_SIZE);
789 elm_image_prescale_set(eo, it->w > it->h ? it->w : it->h);
801 * Add an Image Slider widget
803 * @param parent The parent object
804 * @return The new Image slider object or NULL if it cannot be created
806 * @ingroup Imageslider
809 elm_imageslider_add(Evas_Object * parent)
812 Evas_Object *obj = NULL;
813 Widget_Data *wd = NULL;
820 wd = ELM_NEW(Widget_Data);
821 e = evas_object_evas_get(parent);
826 obj = elm_widget_add(e);
827 ELM_SET_WIDTYPE(widtype, "imageslider");
828 elm_widget_type_set(obj, "imageslider");
829 elm_widget_sub_object_add(parent, obj);
830 elm_widget_data_set(obj, wd);
831 //wd->parent = parent;
832 elm_widget_del_hook_set(obj, _del_hook);
833 //elm_widget_theme_hook_set(obj, _theme_hook);
835 wd->clip = evas_object_rectangle_add(e);
837 for (i=0; i < BLOCK_MAX; i++) {
838 wd->ly[i] = elm_layout_add(obj);
839 elm_layout_theme_set(wd->ly[i], "imageslider", "base", "default");
840 elm_widget_resize_object_set(obj, wd->ly[i]);
841 evas_object_smart_member_add(wd->ly[i], obj);
842 evas_object_event_callback_add(wd->ly[i], EVAS_CALLBACK_MOUSE_DOWN, ev_imageslider_down_cb, wd);
843 evas_object_event_callback_add(wd->ly[i], EVAS_CALLBACK_MOUSE_UP, ev_imageslider_up_cb, wd);
844 evas_object_event_callback_add(wd->ly[i], EVAS_CALLBACK_MOUSE_MOVE, ev_imageslider_move_cb, wd);
845 evas_object_clip_set(wd->ly[i], wd->clip);
846 evas_object_show(wd->ly[i]);
851 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _imageslider_resize, obj);
852 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE, _imageslider_move, obj);
853 evas_object_event_callback_add(obj, EVAS_CALLBACK_SHOW, _imageslider_show, obj);
854 evas_object_event_callback_add(obj, EVAS_CALLBACK_HIDE, _imageslider_hide, obj);
863 * Append an Image Slider item
865 * @param obj The Image Slider object
866 * @param photo_file photo file path
867 * @param func callback function
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(Evas_Object * obj, const char * photo_file, Elm_Imageslider_Cb func, void * data)
876 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
878 Elm_Imageslider_Item *it;
880 if (!obj || !(wd = elm_widget_data_get(obj))) {
884 it = (Elm_Imageslider_Item *)calloc(1, sizeof(Elm_Imageslider_Item));
885 if (!it) return NULL;
886 it->photo_file = eina_stringshare_add(photo_file);
890 wd->its = eina_list_append(wd->its, it);
892 if (!wd->cur) wd->cur = wd->its;
894 _imageslider_update(wd);
901 * Prepend Image Slider item
903 * @param obj The Image Slider object
904 * @param photo_file photo file path
905 * @param func callback function
906 * @param data callback data
907 * @return The imageslider item handle or NULL
909 * @ingroup Imageslider
911 EAPI Elm_Imageslider_Item *
912 elm_imageslider_item_prepend(Evas_Object * obj, const char * photo_file, Elm_Imageslider_Cb func, void * data)
914 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
916 Elm_Imageslider_Item *it;
918 if (!obj || !(wd = elm_widget_data_get(obj))) {
922 it = (Elm_Imageslider_Item *)calloc(1, sizeof(Elm_Imageslider_Item));
923 it->photo_file = eina_stringshare_add(photo_file);
927 wd->its = eina_list_prepend(wd->its, it );
929 if (!wd->cur) wd->cur = wd->its;
931 _imageslider_update(wd);
939 * Delete the selected Image Slider item
941 * @param it The selected Image Slider item handle
943 * @ingroup Imageslider
946 elm_imageslider_item_del(Elm_Imageslider_Item * it)
949 Elm_Imageslider_Item *_it;
952 if (!it || !(wd = elm_widget_data_get(it->obj))) {
956 EINA_LIST_FOREACH(wd->its, l, _it) {
958 if (l == wd->cur) wd->cur = eina_list_prev(wd->cur);
959 wd->its = eina_list_remove(wd->its, it);
960 if (!wd->cur) wd->cur = wd->its;
965 _imageslider_update(wd);
971 * Get the selected Image Slider item
973 * @param obj The Image Slider object
974 * @return The selected Image Slider item or NULL
976 * @ingroup Imageslider
978 EAPI Elm_Imageslider_Item *
979 elm_imageslider_selected_item_get(Evas_Object * obj)
981 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
984 if (!obj || (!(wd = elm_widget_data_get(obj)))) {
988 if (!wd->cur) return NULL;
990 return eina_list_data_get(wd->cur);
994 * Get whether an Image Slider item is selected or not
996 * @param it the selected Image Slider item
997 * @return EINA_TRUE or EINA_FALSE
999 * @ingroup Imageslider
1002 elm_imageslider_item_selected_get(Elm_Imageslider_Item * it)
1006 if (!it || !it->obj || (!(wd = elm_widget_data_get(it->obj)))) {
1010 if (!wd->cur) return EINA_FALSE;
1012 if (eina_list_data_get(wd->cur) == it ) return EINA_TRUE;
1013 else return EINA_FALSE;
1018 * Set the selected Image Slider item
1020 * @param it The Imaga Slider item
1022 * @ingroup Imageslider
1025 elm_imageslider_item_selected_set(Elm_Imageslider_Item * it)
1029 Elm_Imageslider_Item *_it;
1033 if (!it || !it->obj || (!(wd = elm_widget_data_get(it->obj)))) {
1037 EINA_LIST_FOREACH(wd->its, l, _it) {
1043 for (i = 0; i < BLOCK_MAX; i++) {
1044 eo = edje_object_part_swallow_get(elm_layout_edje_get(wd->ly[i]), "swl.photo");
1046 elm_layout_content_set(wd->ly[i], "swl.photo", NULL);
1047 evas_object_del(eo);
1051 _imageslider_update(wd);
1057 * Get the photo file path of given Image Slider item
1059 * @param it The Image Slider item
1060 * @return The photo file path or NULL;
1062 * @ingroup Imageslider
1065 elm_imageslider_item_photo_file_get(Elm_Imageslider_Item * it)
1071 return it->photo_file;
1076 * Get the previous Image Slider item
1078 * @param it The Image Slider item
1079 * @return The previous Image Slider item or NULL
1081 * @ingroup Imageslider
1083 EAPI Elm_Imageslider_Item *
1084 elm_imageslider_item_prev(Elm_Imageslider_Item * it)
1087 Elm_Imageslider_Item *_it;
1090 if (!it || (!(wd = elm_widget_data_get(it->obj)))) {
1094 EINA_LIST_FOREACH(wd->its, l, _it) {
1096 l = eina_list_prev(l);
1098 return eina_list_data_get(l);
1107 * Get the next Image Slider item
1109 * @param it The Image Slider item
1110 * @return The next Image Slider item or NULL
1112 * @ingroup Imageslider
1114 EAPI Elm_Imageslider_Item *
1115 elm_imageslider_item_next(Elm_Imageslider_Item * it)
1118 Elm_Imageslider_Item *_it;
1121 if (!it || (!(wd = elm_widget_data_get(it->obj)))) {
1125 EINA_LIST_FOREACH(wd->its, l, _it) {
1127 l = eina_list_next(l);
1129 return eina_list_data_get(l);
1138 * Move to the previous Image Slider item
1140 * @param obj The Image Slider object
1142 * @ingroup Imageslider
1145 elm_imageslider_prev(Evas_Object * obj)
1147 ELM_CHECK_WIDTYPE(obj, widtype);
1150 if (!obj || (!(wd = elm_widget_data_get(obj)))) {
1154 if (wd->ani_lock) return;
1156 _imageslider_obj_move(wd, -1);
1161 * Move to the next Image Slider item
1163 * @param obj The Image Slider object
1165 * @ingroup Imageslider
1168 elm_imageslider_next(Evas_Object * obj)
1170 ELM_CHECK_WIDTYPE(obj, widtype);
1173 if (!obj || (!(wd = elm_widget_data_get(obj)))) {
1177 if (wd->ani_lock) return;
1179 _imageslider_obj_move(wd, 1);