Merge branch 'master' of 165.213.180.234:/git/slp/pkgs/elementary
[framework/uifw/elementary.git] / src / lib / elm_imageslider.c
1 /* 
2
3 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 
4 */
5 /**
6 * @file         elm_imageslider.c
7 * @brief                This is the implementation file for Image Slider Elementary.
8 * @version      V0.1
9 * @date                 [2010-08-12]
10 *
11 * @note
12 *               Revision History:
13 *
14 */
15 #include <stdio.h>
16 #include <math.h>
17 #include <Elementary.h>
18 #include "elm_priv.h"
19 //#include "winset_util.h"
20
21 /********************************************************* 
22         Image Slider Elementary
23 ********************************************************/ 
24 /////////////////////////////////////////////////////////////////////////////////////////////////// 
25 // Definitions of "elm_imageslider" 
26 //------------------------------------------------------------------------------------------------- 
27 #define LAYOUT_FILE PREFIX"/"
28
29 #define ANI_STEP                                (14 * elm_scale_get())
30 #define ANI_TIME                                (0.005)
31 #define ANI_TIME_MSEC           (12)
32 #define FLICK_TIME_MAX          (200)
33 #define FLICK_WIDTH_MIN (elm_finger_size_get() >> 2)
34 #define MOVE_STEP                       (3)
35 #define STEP_WEIGHT_DEF (1)
36 #define STEP_WEIGHT_MAX (2)
37 #define STEP_WEIGHT_MIN (0)
38 #define MOVING_IMAGE_SIZE       (128)
39 #define MAX_ZOOM_SIZE           (6)
40 #define INTERVAL_WIDTH          (15)
41 #define MULTITOUCHDEVICE        (11)
42
43 enum {
44         BLOCK_LEFT = 0,
45         BLOCK_CENTER,
46         BLOCK_RIGHT,
47         BLOCK_MAX
48 };
49
50 struct _Imageslider_Item 
51 {
52         Evas_Object *obj;
53         const char *photo_file;
54         void (*func)(void *data, Evas_Object *obj, void *event_info);
55         void *data;
56         Evas_Coord x, y, w, h;
57         Evas_Coord ox, oy, ow, oh;
58         int moving : 1;
59 };
60
61 typedef struct _Widget_Data Widget_Data;
62 struct _Widget_Data
63 {
64         Evas_Object *ly[BLOCK_MAX];
65         Evas_Object *clip;
66         Eina_List *its;
67         Eina_List *cur;
68         Evas_Coord x, y, w, h;
69         Evas_Object *obj;
70
71         Evas_Coord_Point down_pos;
72         Evas_Coord move_x;
73         Evas_Coord move_y;
74         Evas_Coord dest_x;
75         struct timeval tv;
76         unsigned int timestamp;
77         int step;
78         int move_cnt;
79         int ani_lock : 1;
80         int moving : 1;
81
82         Eina_Bool on_zoom : 1;
83         Eina_Bool on_hold : 1;
84         int dx, dy, mx, my;
85         int mdx, mdy, mmx, mmy;
86         int dratio;
87         int ratio;
88 };
89
90
91 /////////////////////////////////////////////////////////////////////////////////////////////////// 
92 // Declare the global variables, registers, and Internal Funntions 
93 //-------------------------------------------------------------------------------------------------
94 static const char *widtype = NULL;
95 static Evas_Smart *_imageslider_smart_get(void);
96 static Evas_Object *_imageslider_new(Evas_Object *paren);
97 //static void _imageslider_add(Evas_Object *obj);
98 static void _del_hook(Evas_Object *obj);
99 static void _theme_hook(Evas_Object *obj);
100 static void _sizing_eval(Evas_Object *obj);
101 //static void _imageslider_del(Evas_Object *obj);
102 static void _imageslider_del_all(Widget_Data *wd);
103 //static void _imageslider_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y);
104 //static void _imageslider_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h);
105 static void _imageslider_move(void *data,Evas *e, Evas_Object *obj, void *event_info);
106 static void _imageslider_resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
107
108 static void _imageslider_show(Evas_Object *obj);
109 static void _imageslider_hide(Evas_Object *obj);
110 static void _imageslider_color_set(Evas_Object *obj, int r, int g, int b, int a);
111 static void _imageslider_clip_set(Evas_Object *obj, Evas_Object *clip);
112 static void _imageslider_clip_unset(Evas_Object *obj);
113
114 static void _imageslider_update(Widget_Data *wd);
115 static void _imageslider_update_pos(Widget_Data *wd, Evas_Coord x, Evas_Coord y, Evas_Coord w);
116 static void _imageslider_update_center_pos(Widget_Data *wd, Evas_Coord x, Evas_Coord my, Evas_Coord y, Evas_Coord w);
117 static Evas_Object *_imageslider_add_obj(Widget_Data *wd);
118 static void _imageslider_obj_shift(Widget_Data *wd, Eina_Bool left);
119 static void _imageslider_obj_move(Widget_Data *wd, Evas_Coord step);
120
121 static int _icon_to_image(void *data);
122 static int _check_drag(int state, void *data);
123 static void _check_zoom(void *data);
124 static void _anim(Widget_Data *wd);
125 /////////////////////////////////////////////////////////////////////////////////////////////////// 
126 // Declare the Callback Funntions 
127 //-------------------------------------------------------------------------------------------------
128 static int _timer_cb(void *data);
129 static void ev_imageslider_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
130 static void ev_imageslider_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
131 static void ev_imageslider_move_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
132 //static void ev_imageslider_multi_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
133 //static void ev_imageslider_multi_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
134 //static void ev_imageslider_multi_move_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
135
136 /*==========================================================================
137 * Internal function definitions of Image Slider Elementary
138 *===========================================================================*/
139 /*
140 static void _imageslider_add(Evas_Object * obj)
141 {
142         int i;
143         Widget_Data *wd;
144
145         //wd = (Widget_Data *) calloc(1, sizeof(Widget_Data));
146         wd = elm_widget_data_get(obj);
147
148         if (!wd) {
149                 return;
150         } else {
151                 //evas_object_smart_data_set(obj, wd);
152                 wd->clip = evas_object_rectangle_add(evas_object_evas_get(obj));
153
154                 for (i=0; i < BLOCK_MAX; i++) {
155                         wd->ly[i] = elm_layout_add(obj);
156 //                      elm_object_style_set(obj, "elm/imageslider");
157 //                      elm_layout_file_set(wd->ly[i], get_edj_name(), "elm/imageslider");
158                         evas_object_smart_member_add(wd->ly[i], obj);
159                         evas_object_event_callback_add(wd->ly[i], EVAS_CALLBACK_MOUSE_DOWN, ev_imageslider_down_cb, wd);
160                         evas_object_event_callback_add(wd->ly[i], EVAS_CALLBACK_MOUSE_UP, ev_imageslider_up_cb, wd);
161                         evas_object_event_callback_add(wd->ly[i], EVAS_CALLBACK_MOUSE_MOVE, ev_imageslider_move_cb, wd);
162                         evas_object_clip_set(wd->ly[i], wd->clip);
163                         evas_object_show(wd->ly[i]);                    
164                 }
165
166                 wd->obj = obj;          
167         }
168         
169 }
170 */
171
172 static void _del_hook(Evas_Object * obj)
173 {
174         int i;
175         Widget_Data * wd;
176         wd = elm_widget_data_get(obj);
177
178         if (!wd) return;
179
180         for (i = 0; i < BLOCK_MAX; i++) {
181                 evas_object_del(wd->ly[i]);
182         }
183
184         if (wd->its) {
185                 eina_list_free(wd->its);
186                 wd->its = NULL;
187         }
188
189         if (wd) free(wd);
190         
191 }
192
193 static void _theme_hook(Evas_Object * obj)
194 {
195         int i;
196         Widget_Data *wd;
197         wd = elm_widget_data_get(obj);
198
199         if (!wd || !wd->ly ) {
200                 return;
201         }
202
203         for (i=0; i < BLOCK_MAX; i++) {
204                 wd->ly[i] = elm_layout_add(obj);
205                 _elm_theme_object_set(obj, wd->ly[i], "imageslider", "base", "default");
206                 elm_widget_resize_object_set(obj, wd->ly[i]);
207                 evas_object_show(wd->ly[i]);                    
208         }
209
210         _sizing_eval(obj);      
211 }
212
213
214 static void _sizing_eval(Evas_Object * obj)
215 {
216         Evas *e;
217         Widget_Data *wd = elm_widget_data_get(obj);
218
219         if (!wd) {
220                 return;
221         }
222
223         e = evas_object_evas_get(wd->obj);
224
225         _imageslider_move(obj, e, obj, NULL);
226         _imageslider_resize(obj, e, obj, NULL);
227
228 }
229
230 /*
231 static void _imageslider_del(Evas_Object * obj)
232 {
233         Widget_Data *wd;
234         wd = evas_object_smart_data_get(obj);
235         _imageslider_del_all(wd);
236 //      edje_thaw();
237
238         if (wd->its) {
239                 eina_list_free(wd->its);
240                 wd->its = NULL;
241         }
242
243         if (wd) free(wd);
244 }
245
246
247 static void _imageslider_move(Evas_Object * obj, Evas_Coord x, Evas_Coord y)
248 {
249         Widget_Data *wd;
250         //wd = evas_object_smart_data_get(obj);
251         wd = elm_widget_data_get(obj);
252
253         if (!wd) {
254                 //errno = EINVAL;
255                 return;
256         }
257
258         wd->x = x;
259         wd->y = y;
260         evas_object_move(wd->clip, x, y);
261
262         _imageslider_update_pos(wd, wd->x, wd->y, wd->w);
263         
264 }
265
266 static void _imageslider_resize(Evas_Object * obj, Evas_Coord w, Evas_Coord h)
267 {
268         int i;
269         Widget_Data *wd;
270         //wd = evas_object_smart_data_get(obj);
271         wd = elm_widget_data_get(obj);
272
273         if (!wd) {
274                 //errno = EINVAL;
275                 return;         
276         }
277
278         wd->w = w;
279         wd->h = h;
280
281         for (i = 0; i < BLOCK_MAX; i++) {
282                 evas_object_resize(wd->ly[i], w, h);
283         }
284
285         evas_object_resize(wd->clip, w, h);
286
287         _imageslider_update_pos(wd, wd->x, wd->y, wd->w);
288         
289 }
290 */
291
292 static void _imageslider_move(void * data, Evas * e, Evas_Object * obj, void * event_info)
293 {
294         Widget_Data *wd;
295         Evas_Coord x, y;
296
297         if (!data) {
298                 return;
299         }
300         
301         //wd = evas_object_smart_data_get(obj);
302         wd = elm_widget_data_get((Evas_Object *) data);
303         if (!wd) {
304                 //errno = EINVAL;
305                 return;
306         }
307
308         evas_object_geometry_get(obj, &x, &y, NULL, NULL);
309         wd->x = x;
310         wd->y = y;
311         evas_object_move(wd->clip, x, y);
312         
313         _imageslider_update_pos(wd, wd->x, wd->y, wd->w);
314         
315 }
316
317 static void _imageslider_resize(void * data, Evas * e, Evas_Object * obj, void * event_info)
318 {
319         int i;
320         Widget_Data *wd;
321         Evas_Coord w, h;
322
323         if (!data) {
324                 return;
325         }
326                 
327         //wd = evas_object_smart_data_get(obj);
328         wd = elm_widget_data_get((Evas_Object *) data);
329         if (!wd || !wd->ly) {
330                 //errno = EINVAL;
331                 return;         
332         }
333
334         evas_object_geometry_get(obj, NULL, NULL, &w, &h);
335         fprintf( stderr, "%d %d -resize\n" , w, h );
336         wd->w = w;
337         wd->h = h;
338
339         for (i = 0; i < BLOCK_MAX; i++) {
340                 evas_object_resize(wd->ly[i], w, h);
341         }
342
343         evas_object_resize(wd->clip, w, h);
344
345         _imageslider_update_pos(wd, wd->x, wd->y, wd->w);
346         
347 }
348
349
350 static void _imageslider_show(Evas_Object * obj)
351 {
352         Widget_Data *wd;
353         //wd = evas_object_smart_data_get(obj);
354         wd = elm_widget_data_get(obj);
355
356         if (!wd) {
357                 //errno = EINVAL;
358                 return;
359         }
360         evas_object_show(wd->clip);
361 }
362
363 static void _imageslider_hide(Evas_Object *obj)
364 {
365         Widget_Data *wd;
366         //wd = evas_object_smart_data_get(obj);
367         wd = elm_widget_data_get(obj);
368
369         if (!wd) {
370                 //errno = EINVAL;
371                 return;
372         }
373
374         evas_object_hide(wd->clip);
375 }
376
377 /*
378 static void _imageslider_color_set(Evas_Object * obj, int r, int g, int b, int a)
379 {
380         int i;
381         Widget_Data *wd;
382         //wd = evas_object_smart_data_get(obj);
383         wd = elm_widget_data_get(obj);
384
385         if (!wd ) {
386                 //errno = EINVAL;
387                 return;
388         }
389
390         evas_object_color_set(wd->clip, r, g, b, a);
391
392         for (i = 0; i < BLOCK_MAX; i++) {
393                 evas_object_color_set(wd->ly[i], r, g, b, a);
394         }
395 }
396
397 static void _imageslider_clip_set(Evas_Object * obj, Evas_Object * clip)
398 {
399         Widget_Data *wd;
400         //wd = evas_object_smart_data_get(obj);
401         wd = elm_widget_data_get(obj);
402
403         if (!wd) {
404                 //errno = EINVAL;
405                 return;
406         }
407
408         evas_object_clip_set(wd->clip, clip);
409 }
410
411 static void _imageslider_clip_unset(Evas_Object * obj)
412 {
413         Widget_Data *wd;
414         //wd = evas_object_smart_data_get(obj);
415         wd = elm_widget_data_get(obj);
416         
417         if (!wd) {
418                 //errno = EINVAL;
419                 return;
420         }
421
422         evas_object_clip_unset(wd->obj);
423 }
424 */
425
426 /*
427 static Evas_Smart *_imageslider_smart_get(void)
428 {
429         static Evas_Smart *s = NULL;
430         static Evas_Smart_Class sc = EVAS_SMART_CLASS_INIT_NAME_VERSION("Elm_imageslider");
431
432         if (!s) {
433                 sc.add = _imageslider_add;
434                 sc.del = _imageslider_del;
435                 sc.move = _imageslider_move;
436                 sc.resize = _imageslider_resize;
437                 sc.show = _imageslider_show;
438                 sc.hide = _imageslider_hide;
439                 sc.color_set = _imageslider_color_set;
440                 sc.clip_set = _imageslider_clip_set;
441                 sc.clip_unset = _imageslider_clip_unset;
442                 s = evas_smart_class_new(&sc);
443         }
444
445         return s;
446 }
447
448
449 static Evas_Object *_imageslider_new(Evas_Object *parent)
450 {
451         Evas_Object *obj;
452         Evas *e;
453         e = evas_object_evas_get(parent);
454
455         if (!e) {
456                 //errno = EINVAL;
457                 return NULL;
458         } else {
459                 obj = evas_object_smart_add(e, _imageslider_smart_get());
460         }
461
462         return obj;
463 }
464  */
465
466 static void _imageslider_del_all(Widget_Data * wd)
467 {
468         int i;
469         if (!wd) return;
470
471         for (i = 0; i < BLOCK_MAX; i++) {
472                 evas_object_del(wd->ly[i]);
473         }
474 }
475
476 static void _imageslider_update_pos(Widget_Data * wd, Evas_Coord x, Evas_Coord y, Evas_Coord w)
477 {
478         evas_object_move(wd->ly[BLOCK_LEFT], x - (w + INTERVAL_WIDTH), y);
479         evas_object_move(wd->ly[BLOCK_CENTER], x, y);
480         evas_object_move(wd->ly[BLOCK_RIGHT], x + (w + INTERVAL_WIDTH), y);
481         evas_render_idle_flush(evas_object_evas_get(wd->obj));
482 }
483
484 static void _imageslider_update_center_pos(Widget_Data * wd, Evas_Coord x, Evas_Coord my, Evas_Coord y, Evas_Coord w)
485 {
486         Evas_Object *eo;
487         Evas_Coord ix, iy, iw, ih;
488
489         eo = edje_object_part_swallow_get(elm_layout_edje_get(wd->ly[BLOCK_CENTER]), "swl.photo");
490         evas_object_geometry_get(eo, &ix, &iy, &iw, &ih);
491
492         if ((ix > 0) || (ix + iw < wd->w)) {
493                 edje_object_signal_emit(elm_layout_edje_get(wd->ly[BLOCK_CENTER]), "block.on", "block");
494 //              edje_freeze();
495 //              evas_event_feed_mouse_cancel(evas_object_evas_get(wd->obj), NULL, NULL);
496 //              evas_event_feed_mouse_down(evas_object_evas_get(wd->obj), 1, EVAS_BUTTON_NONE, NULL, NULL);             
497
498                 _imageslider_update_pos(wd, x, y, w);
499                 wd->on_zoom = EINA_FALSE;
500         }
501 }
502
503 static Evas_Object *_imageslider_add_obj(Widget_Data *wd)
504 {
505         Evas_Object *eo;
506         eo = elm_layout_add(wd->obj);
507         //_elm_theme_object_set(wd->obj, eo, "imageslider", "base", elm_widget_style_get(wd->obj)); 
508         elm_layout_theme_set(eo, "imageslider", "base", "default");
509         elm_widget_resize_object_set(wd->obj, eo);
510 //      elm_object_style_set(wd->obj, , "elm/imageslider");
511 //      elm_layout_file_set(eo, get_edj_name(), "elm/imageslider");
512 //      evas_object_smart_member_add(eo, wd->obj);
513         evas_object_event_callback_add(eo, EVAS_CALLBACK_MOUSE_DOWN, ev_imageslider_down_cb, wd);
514         evas_object_event_callback_add(eo, EVAS_CALLBACK_MOUSE_UP, ev_imageslider_up_cb, wd);
515         evas_object_event_callback_add(eo, EVAS_CALLBACK_MOUSE_MOVE, ev_imageslider_move_cb, wd);
516         evas_object_resize(eo, wd->w, wd->h);
517         evas_object_move(eo, wd->w + INTERVAL_WIDTH, wd->y);
518         evas_object_clip_set(eo, wd->clip);
519         evas_object_show(eo);
520
521         return eo;
522 }
523
524 static void _imageslider_obj_shift(Widget_Data *wd, Eina_Bool left)
525 {
526         if (!left) {
527                 if (wd->ly[BLOCK_LEFT]) {
528                         evas_object_del(wd->ly[BLOCK_LEFT]);
529                         wd->ly[BLOCK_LEFT] = NULL;
530                 }
531
532                 wd->ly[BLOCK_LEFT] = wd->ly[BLOCK_CENTER];
533                 wd->ly[BLOCK_CENTER]= wd->ly[BLOCK_RIGHT];
534                 wd->ly[BLOCK_RIGHT] = _imageslider_add_obj(wd);
535         } else {
536                 if (wd->ly[BLOCK_RIGHT]) {
537                         evas_object_del(wd->ly[BLOCK_RIGHT]);
538                         wd->ly[BLOCK_RIGHT] = NULL;
539                 }
540
541                 wd->ly[BLOCK_RIGHT]= wd->ly[BLOCK_CENTER];
542                 wd->ly[BLOCK_CENTER]= wd->ly[BLOCK_LEFT];
543                 wd->ly[BLOCK_LEFT]= _imageslider_add_obj(wd);
544         }
545 }
546
547
548 static void _imageslider_obj_move(Widget_Data * wd, Evas_Coord step)
549 {
550         if (step > 0) {
551                 wd->cur = eina_list_next(wd->cur);
552                 if (wd->cur == NULL) {
553                         wd->cur = eina_list_last(wd->its);
554                         wd->step = ANI_STEP;
555                 } else {
556                         wd->step = -ANI_STEP;
557                         wd->move_x += wd->w;
558                         _imageslider_obj_shift(wd, 0);
559                 }
560                 wd->moving = 1;         
561         } else if (step < 0) {
562                 wd->cur = eina_list_prev(wd->cur);
563                 if (wd->cur == NULL) {
564                         wd->cur = wd->its;
565                         wd->step = -ANI_STEP;
566                 } else {
567                         wd->step = ANI_STEP;
568                         wd->move_x -= wd->w;
569                         _imageslider_obj_shift(wd, 1);
570                 }
571                 wd->moving = 1;
572         } else {
573                 if (wd->move_x < 0) wd->step = ANI_STEP;
574                 else wd->step = -ANI_STEP;
575                 wd->moving = 0;
576         }
577
578         _imageslider_update(wd);
579 }
580
581
582 /*==========================================================================
583 * Callback function definitions of Image Slider Elementary
584 *===========================================================================*/
585 static void ev_imageslider_down_cb(void * data, Evas * e, Evas_Object * obj, void * event_info)
586 {
587         Widget_Data *wd = data;
588         Evas_Event_Mouse_Down *ev = event_info;
589         Evas_Coord ix, iy, iw, ih;
590         Evas_Object *eo = NULL;
591
592         if (wd->ani_lock) return;
593
594         wd->down_pos = ev->canvas;
595         wd->timestamp = ev->timestamp;
596         wd->move_cnt = MOVE_STEP;
597
598         wd->dx = ev->canvas.x;
599         wd->dy = ev->canvas.y;
600         wd->mx = ev->canvas.x;
601         wd->my = ev->canvas.y;
602
603         wd->dratio = 1;
604         wd->ratio = 1;
605
606         eo = edje_object_part_swallow_get(elm_layout_edje_get(obj), "swl.photo");
607         if (eo) evas_object_geometry_get(eo, &ix, &iy, &iw, &ih);
608
609         if (iw != wd->w) {
610                 wd->on_zoom = EINA_TRUE;
611                 edje_object_signal_emit(elm_layout_edje_get(obj), "block.off", "block");
612 //              edje_thaw();            
613         }
614
615         fprintf( stderr, "down!\n" );
616
617 }
618
619 static void ev_imageslider_up_cb(void * data, Evas * e, Evas_Object * obj, void * event_info)
620 {
621         Widget_Data *wd = data;
622         Evas_Event_Mouse_Up *ev = event_info;
623         Evas_Coord step;
624         int interval;
625
626         if (wd->ani_lock) return;
627
628         if (wd->on_zoom) {              
629         } else {
630                 step = wd->down_pos.x - ev->canvas.x;
631                 interval = ev->timestamp - wd->timestamp;
632                 if (step == 0 || interval == 0) return;
633
634                 if (interval < FLICK_TIME_MAX) {
635                         if (step < FLICK_WIDTH_MIN && step > FLICK_WIDTH_MIN) _imageslider_obj_move(wd, 0);
636                         else _imageslider_obj_move(wd, step);
637                 } else {
638                         step = (wd->x - wd->move_x) << 1;
639                         if (step <= wd->w && step >= -(wd->w)) _imageslider_obj_move(wd, 0);
640                         else _imageslider_obj_move(wd, step);
641                 }
642         }
643
644 }
645
646 static void ev_imageslider_move_cb(void * data, Evas * e, Evas_Object * obj, void * event_info)
647 {
648         int idx;
649         Evas_Object *eo;
650         Evas_Coord step;
651         Widget_Data *wd = data;
652         Evas_Event_Mouse_Move *ev = event_info;
653         Elm_Imageslider_Item *it;
654
655         if (wd->ani_lock) return;
656
657         if (wd->move_cnt == MOVE_STEP) {
658                 if (wd->on_hold == EINA_FALSE) {
659                         wd->move_cnt = 0;
660
661                         if (ev->buttons) {
662                                 step = ev->cur.canvas.x - wd->down_pos.x;
663                                 if (step > 0) idx = BLOCK_LEFT;
664                                 else idx = BLOCK_RIGHT;
665
666                                 wd->move_x = wd->x + ((ev->cur.canvas.x - wd->down_pos.x));
667                                 wd->move_y = wd->y + ((ev->cur.canvas.y - wd->down_pos.y));
668
669                                 if (wd->on_zoom) {
670                                         _imageslider_update_center_pos(wd, wd->move_x, wd->move_y, wd->y, wd->w);
671                                 } else {
672                                         _imageslider_update_pos(wd, wd->move_x, wd->y, wd->w);
673                                 }
674                         }
675                 } else {
676                         wd->mx = ev->cur.canvas.x;
677                         wd->my = ev->cur.canvas.y;
678
679                         wd->ratio = sqrt((wd->mx -wd->mmx)*(wd->mx -wd->mmx) + (wd->my - wd->mmy)*(wd->my - wd->mmy));
680
681                         eo = edje_object_part_swallow_get(elm_layout_edje_get(obj), "swl.photo");
682                         if (eo) {
683                                 it = eina_list_data_get(wd->cur);
684                                 if (((it->w * wd->ratio/wd->dratio)/it->ow) < MAX_ZOOM_SIZE ) {
685                                         edje_object_part_unswallow(elm_layout_edje_get(obj), eo);
686                                         evas_object_resize(eo, it->w * wd->ratio/wd->dratio, it->h * wd->ratio/wd->dratio);
687                                         evas_object_size_hint_min_set(eo, it->w * wd->ratio/wd->dratio, it->h * wd->ratio/wd->dratio);
688                                         edje_object_part_swallow(elm_layout_edje_get(obj), "swl.photo", eo);
689                                 }
690                         }                       
691                 }
692         }
693
694         wd->move_cnt++;
695
696 }
697
698
699 #if 0 // REMOVED about Multi-touch.
700 static void ev_imageslider_multi_down_cb(void * data, Evas * e, Evas_Object * obj, void * event_info)
701 {
702         Evas_Event_Multi_Down *ev = event_info;
703         Widget_Data *wd = data;
704
705         if (ev->device == MULTITOUCHDEVICE) return;
706
707         wd->on_hold = EINA_TRUE;
708         wd->mdx = ev->canvas.x;
709         wd->mdy = ev->canvas.y;
710         wd->mmx = ev->canvas.x;
711         wd->mmy = ev->canvas.y;
712
713         wd->dratio = sqrt((wd->mx - wd->mmx)*(wd->mx - wd->mmx) + (wd->my - wd->mmy)*(wd->my - wd->mmy));
714         wd->ratio = sqrt((wd->mx - wd->mmx)*(wd->mx - wd->mmx)+ (wd->my - wd->mmy)*(wd->my - wd->mmy));
715
716         if (wd->on_zoom){
717                 wd->on_zoom = EINA_FALSE;
718                 edje_object_signal_emit(elm_layout_edje_get(obj), "block.on", "block");
719 //              edje_freeze();
720         }
721 }
722
723 static void ev_imageslider_multi_up_cb(void * data, Evas * e, Evas_Object * obj, void * event_info)
724 {
725         Evas_Event_Multi_Up *ev = event_info;
726         Widget_Data *wd = data;
727         Elm_Imageslider_Item *it;
728
729         if (ev->device == MULTITOUCHDEVICE) return;
730
731         it = eina_list_data_get(wd->cur);
732         it->w = (int)it->w * wd->ratio/wd->dratio;
733         it->h = (int)it->h * wd->ratio/wd->dratio;
734
735         if (it->w != it->ow) {
736                 wd->on_zoom = EINA_TRUE;
737                 edje_object_signal_emit(elm_layout_edje_get(obj), "block.off", "block");
738 //              edje_thaw();
739         } else {
740                 wd->on_zoom = EINA_FALSE;
741         }
742
743         wd->on_hold = EINA_FALSE;
744         wd->mdx = 0;
745         wd->mdy = 0;
746         wd->mmx = 0;
747         wd->mmy = 0;
748         wd->ratio = 0;
749         wd->dratio = 0;
750         
751 }
752
753 static void ev_imageslider_multi_move_cb(void * data, Evas * e, Evas_Object * obj, void * event_info)
754 {
755         Evas_Event_Multi_Move *ev = event_info;
756         Widget_Data *wd = data;
757         Evas_Object *eo = NULL;
758         Elm_Imageslider_Item *it;
759
760         if (ev->device == MULTITOUCHDEVICE) return;
761
762         if ((wd->mdx == 0) && (wd->mdy == 0) && (wd->mmx == 0) && (wd->mmy == 0)) {
763                 wd->mdx = ev->cur.canvas.x;
764                 wd->mdy = ev->cur.canvas.y;
765                 wd->mmx = ev->cur.canvas.x;
766                 wd->mmy = ev->cur.canvas.y;
767
768                 wd->dratio = sqrt((wd->dx - wd->mdx)*(wd->dx - wd->mdx) + (wd->dy - wd->mdy)*(wd->dy - wd->mdy));
769         }
770
771         wd->mmx = ev->cur.canvas.x;
772         wd->mmy = ev->cur.canvas.y;
773         wd->ratio = sqrt((wd->mx - wd->mmx)*(wd->mx - wd->mmx) + (wd->my - wd->mmy)*(wd->my - wd->mmy));
774
775         eo = edje_object_part_swallow_get(elm_layout_edje_get(obj), "swl.photo");
776
777         if (eo) {
778                 it = eina_list_data_get(wd->cur);
779                 if (((it->w * wd->ratio/wd->dratio)/it->ow) < MAX_ZOOM_SIZE) {
780                         edje_object_part_unswallow(elm_layout_edje_get(obj), eo);
781                         evas_object_resize(eo, it->w * wd->ratio/wd->dratio, it->h * wd->ratio/wd->dratio);
782                         evas_object_size_hint_min_set(eo, it->w * wd->ratio/wd->dratio, it->h * wd->ratio/wd->dratio);
783                         edje_object_part_swallow(elm_layout_edje_get(obj), "swl.photo", eo);
784                 }
785         }       
786 }
787
788 #endif // about Multi-touch.
789
790 static inline double time_get(Evas_Coord x, Evas_Coord w)
791 {
792         double time;
793         time = (-sin(x / w) + 1) / 500;
794
795         if (time == 0) time = ANI_TIME;
796         
797         return time;
798 }
799
800 static int _icon_to_image(void *data)
801 {
802         Widget_Data *wd = data;
803         wd->moving = 0;
804         _imageslider_update(wd);
805
806         return 0;
807 }
808
809 static int _check_drag(int state, void *data)
810 {
811         Widget_Data *wd = data;
812         Elm_Imageslider_Item *it;
813         Evas_Coord ix, iy, iw, ih;
814         double dx, dy = 0;
815         Eina_List *l[BLOCK_MAX];
816         Evas_Object *eo = NULL;
817         l[BLOCK_LEFT] = eina_list_prev(wd->cur);
818         l[BLOCK_CENTER] = wd->cur;
819         l[BLOCK_RIGHT] = eina_list_next(wd->cur);
820
821         it = eina_list_data_get(l[state]);
822
823         eo = edje_object_part_swallow_get(elm_layout_edje_get(wd->ly[state]), "swl.photo");
824         if (eo) evas_object_geometry_get(eo, &ix, &iy, &iw, &ih);
825         evas_object_geometry_get(eo, &ix, &iy, &iw, &ih);
826         edje_object_part_drag_value_get(elm_layout_edje_get(wd->ly[state]), "swl.photo", &dx, &dy);
827
828         if ((iw != wd->w) || ((dx != 0 ) || (dy != 0 ))) {
829                 if (wd->ly[state]) {
830                         evas_object_del(wd->ly[state]);
831                         wd->ly[state] = NULL;
832                 }
833                 wd->ly[state] = _imageslider_add_obj(wd);
834         } else {
835                 return 1;
836         }
837
838         return 0;
839 }
840
841
842 static void _check_zoom(void *data)
843 {
844         Widget_Data *wd = data;
845         Elm_Imageslider_Item *it;
846         Evas_Coord ix, iy, iw, ih;
847         double dx, dy = 0;
848         Evas_Object *eo = NULL;
849
850         it = eina_list_data_get(wd->cur);
851
852         eo = edje_object_part_swallow_get(elm_layout_edje_get(wd->ly[BLOCK_CENTER]), "swl.photo");
853         if (eo) evas_object_geometry_get(eo, &ix, &iy, &iw, &ih);
854         evas_object_geometry_get(eo, &ix, &iy, &iw, &ih);
855         edje_object_part_drag_value_get(elm_layout_edje_get(wd->ly[BLOCK_CENTER]), "swl.photo", &dx, &dy);
856
857         if ((iw != wd->w) || ((dx != 0) || (dy != 0))) {
858                 wd->on_zoom = EINA_TRUE;
859                 edje_object_signal_emit(elm_layout_edje_get(wd->ly[BLOCK_CENTER]), "block.off", "block");
860 //              edje_thaw();
861         } else {
862                 wd->on_zoom = EINA_FALSE;
863                 edje_object_signal_emit(elm_layout_edje_get(wd->ly[BLOCK_CENTER]), "block.on", "block");
864 //              edje_freeze();
865         }
866 }
867
868
869 static int _timer_cb(void *data)
870 {
871         Widget_Data *wd;
872         Elm_Imageslider_Item *it;
873         struct timeval tv;
874         int t;
875         int ret;
876         wd = data;
877         if (wd->ani_lock == 0 ) return 0;
878
879         gettimeofday(&tv, NULL);
880
881         t = (tv.tv_sec - wd->tv.tv_sec) * 1000 + (tv.tv_usec - wd->tv.tv_usec) / 1000;
882         gettimeofday(&wd->tv, NULL);
883
884         t = t / ANI_TIME_MSEC;
885         if (t <= STEP_WEIGHT_MIN) t = STEP_WEIGHT_DEF;
886         else if (t >  STEP_WEIGHT_MAX) t = STEP_WEIGHT_MAX;
887
888         wd->move_x += (wd->step) * t;
889
890         if (wd->step < 0 && wd->move_x < wd->x) wd->move_x = wd->x;
891         else if (wd->step > 0 && wd->move_x > wd->x) wd->move_x = wd->x;
892
893         _imageslider_update_pos(wd, wd->move_x, wd->y, wd->w);
894
895         if (wd->move_x == wd->x) {
896                 wd->ani_lock = 0;
897                 if (wd->cur) {
898                         it = eina_list_data_get(wd->cur);
899                         if (it->func) it->func(it->data, wd->obj, it);
900                 }
901                 if (wd->cur) {
902                         it = eina_list_data_get(wd->cur);
903                         evas_object_smart_callback_call(wd->obj, "changed", it);
904                 }
905
906                 ret = _check_drag(BLOCK_LEFT, wd);
907                 ret = _check_drag(BLOCK_RIGHT, wd);
908                 _check_zoom(wd);
909
910                 ecore_idler_add(_icon_to_image, wd);
911
912                 return 0;
913         }
914
915         return 1;       
916 }
917
918 static void _anim(Widget_Data *wd)
919 {
920         Evas_Coord w;
921
922         if (wd->x == wd->move_x) {
923                 _imageslider_update_pos(wd, wd->move_x, wd->y, wd->w);
924                 return;
925         }
926
927         wd->ani_lock = 1;
928
929         w = wd->move_x;
930         gettimeofday(&wd->tv, NULL);
931         ecore_timer_add(ANI_TIME, _timer_cb, wd);
932 }
933
934 static void _imageslider_update(Widget_Data *wd)
935 {
936         int i;
937         Eina_List *l[BLOCK_MAX];
938         Elm_Imageslider_Item *it;
939         Evas_Object *eo;
940
941         if (!wd) {
942                 //errno = EINVAL;
943                 return;
944         }
945
946         if (!wd->cur) {
947                 _imageslider_del_all(wd);
948                 return;
949         }
950
951         l[BLOCK_LEFT] = eina_list_prev(wd->cur);
952         l[BLOCK_CENTER] = wd->cur;
953         l[BLOCK_RIGHT] = eina_list_next(wd->cur);
954
955         for (i = 0; i < BLOCK_MAX; i++) {
956                 eo = edje_object_part_swallow_get(elm_layout_edje_get(wd->ly[i]), "swl.photo");
957                 if (!l[i]) {
958                         elm_layout_content_set(wd->ly[i], "swl.photo", NULL);
959                         evas_object_del(eo);
960                 } else {
961                         it = eina_list_data_get(l[i]);
962                         if (!it) return;
963
964                         if (!eo) {
965                                 eo = elm_image_add(wd->obj);
966                                 elm_layout_content_set(wd->ly[i], "swl.photo", eo);
967                                 elm_image_prescale_set(eo, wd->w);
968                                 elm_image_file_set(eo, it->photo_file, NULL);
969                                 elm_image_object_size_get(eo, &it->w, &it->h);
970                                 evas_object_geometry_get(eo, &it->ox, &it->oy, &it->ow, &it->oh);
971                                 it->ow = it->w;
972                                 it->oh = it->h;
973                         }
974
975                         if (wd->moving != it->moving) {
976                                 it->moving = wd->moving;
977                                 if (wd->moving) {
978                                         elm_image_prescale_set(eo, MOVING_IMAGE_SIZE);
979                                 } else {
980                                         elm_image_prescale_set(eo, it->w > it->h ? it->w : it->h);
981                                 }
982                         }
983                 }
984         }
985
986         _anim(wd);
987
988 }
989
990
991 /** 
992 * add imageslider widget 
993
994 * @fn           Evas_Object *elm_imageslider_add(Evas_Object *parent); 
995 * @param        obj     The parent object 
996 * @return       The new object or NULL if it cannot be created 
997
998 * @ingroup Elm-imageslider 
999 */
1000 EAPI Evas_Object *
1001 elm_imageslider_add(Evas_Object * parent)
1002 {
1003         int i;
1004         Evas_Object *obj = NULL;
1005         Widget_Data *wd = NULL;
1006         Evas *e;
1007
1008         if (!parent) {
1009                 return NULL;
1010         }
1011
1012         wd = ELM_NEW(Widget_Data);
1013         e = evas_object_evas_get(parent);
1014         if (e == NULL ) {
1015                 return NULL;
1016         }
1017         
1018         obj = elm_widget_add(e);
1019         ELM_SET_WIDTYPE(widtype, "imageslider");
1020         elm_widget_type_set(obj, "imageslider");
1021         elm_widget_sub_object_add(parent, obj);
1022         elm_widget_data_set(obj, wd);
1023         //wd->parent = parent;
1024         elm_widget_del_hook_set(obj, _del_hook);
1025         //elm_widget_theme_hook_set(obj, _theme_hook);
1026
1027         /* Add imageslider layouts */
1028         //_imageslider_add(obj);
1029         wd->clip = evas_object_rectangle_add(e);
1030         
1031         for (i=0; i < BLOCK_MAX; i++) {
1032                 wd->ly[i] = elm_layout_add(obj);
1033         //      _elm_theme_object_set(obj, wd->ly[i], "imageslider", "base", elm_widget_style_get(obj));
1034                 elm_layout_theme_set(wd->ly[i], "imageslider", "base", "default");
1035                 elm_widget_resize_object_set(obj, wd->ly[i]);
1036                 evas_object_smart_member_add(wd->ly[i], obj);
1037                 evas_object_event_callback_add(wd->ly[i], EVAS_CALLBACK_MOUSE_DOWN, ev_imageslider_down_cb, wd);
1038                 evas_object_event_callback_add(wd->ly[i], EVAS_CALLBACK_MOUSE_UP, ev_imageslider_up_cb, wd);
1039                 evas_object_event_callback_add(wd->ly[i], EVAS_CALLBACK_MOUSE_MOVE, ev_imageslider_move_cb, wd);
1040                 evas_object_clip_set(wd->ly[i], wd->clip);
1041                 evas_object_show(wd->ly[i]);                    
1042         }
1043
1044         wd->obj = obj;
1045
1046         evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _imageslider_resize, obj);
1047         evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE, _imageslider_move, obj);
1048         evas_object_event_callback_add(obj, EVAS_CALLBACK_SHOW, _imageslider_show, obj);
1049         evas_object_event_callback_add(obj, EVAS_CALLBACK_HIDE, _imageslider_hide, obj);
1050         
1051         _sizing_eval(obj);
1052
1053    return obj;  
1054 }
1055
1056
1057 /** 
1058 * append imageslider item 
1059
1060 * @fn           Elm_Imageslider_Item *elm_imageslider_item_append(Evas_Object *obj, const char *photo_file, Elm_Imageslider_Cb func, void *data)
1061 * @param        obj          The photoslider object 
1062 * @param        photo_file   photo file path 
1063 * @param        func         callback function 
1064 * @param        data         callback data 
1065 * @return       The photoslider item handle or NULL 
1066
1067 * @ingroup ImageSlider 
1068 */
1069 EAPI Elm_Imageslider_Item *
1070 elm_imageslider_item_append(Evas_Object * obj, const char * photo_file, Elm_Imageslider_Cb func, void * data)
1071 {
1072         ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1073         Widget_Data *wd;
1074         Elm_Imageslider_Item *it;
1075
1076         if (!obj || !(wd = elm_widget_data_get(obj))) {
1077                 return NULL;
1078         }
1079
1080         it = (Elm_Imageslider_Item *)calloc(1, sizeof(Elm_Imageslider_Item));
1081         if (!it) return NULL;
1082         it->photo_file = eina_stringshare_add(photo_file);
1083         it->func = func;
1084         it->data = data;
1085         it->obj = obj;
1086         wd->its = eina_list_append(wd->its, it);
1087
1088         if (!wd->cur) wd->cur = wd->its;
1089
1090         _imageslider_update(wd);
1091
1092         return it; 
1093 }
1094
1095
1096 /** 
1097 * prepend imageslider item 
1098
1099 * @fn           Elm_Imageslider_Item *elm_imageslider_item_prepend(Evas_Object *obj, const char *photo_file, Elm_Imageslider_Cb func, void *data) 
1100 * @param        obj          The imageslider object 
1101 * @param        photo_file   photo file path 
1102 * @param        func         callback function 
1103 * @param        data         callback data 
1104 * @return       The imageslider item handle or NULL 
1105
1106 * @ingroup ImageSlider 
1107 */
1108 EAPI Elm_Imageslider_Item *
1109 elm_imageslider_item_prepend(Evas_Object * obj, const char * photo_file, Elm_Imageslider_Cb func, void * data)
1110 {
1111         ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1112         Widget_Data *wd;
1113         Elm_Imageslider_Item *it;
1114
1115         if (!obj || !(wd = elm_widget_data_get(obj))) {
1116                 return NULL;
1117         }
1118
1119         it = (Elm_Imageslider_Item *)calloc(1, sizeof(Elm_Imageslider_Item));
1120         it->photo_file = eina_stringshare_add(photo_file);
1121         it->func = func;
1122         it->data = data;
1123         it->obj = obj;
1124         wd->its = eina_list_prepend(wd->its, it );
1125
1126         if (!wd->cur) wd->cur = wd->its;
1127
1128         _imageslider_update(wd);
1129
1130         return it;
1131 }
1132
1133
1134
1135 /**
1136 * delete imageslider item
1137 *
1138 * @fn   void elm_imageslider_del(Elm_Imageslider_Item *it)
1139 * @param it imageslider item handle
1140 *
1141 * @ingroup ImageSlider
1142 */
1143 EAPI void
1144 elm_imageslider_item_del(Elm_Imageslider_Item * it)
1145 {
1146         Widget_Data *wd;
1147         Elm_Imageslider_Item *_it;
1148         Eina_List *l;
1149
1150         if (!it || !(wd = elm_widget_data_get(it->obj))) {
1151                 return ;
1152         }
1153
1154         EINA_LIST_FOREACH(wd->its, l, _it) {
1155                 if (_it == it ) {
1156                         if (l == wd->cur) wd->cur = eina_list_prev(wd->cur);
1157                         wd->its = eina_list_remove(wd->its, it);
1158                         if (!wd->cur) wd->cur = wd->its;
1159                         break;
1160                 }
1161         }
1162
1163         _imageslider_update(wd);
1164         
1165 }
1166
1167
1168 /**
1169 * get selected item
1170 *
1171 * @fn Elm_Imageslider_Item *elm_imageslider_selected_item_get(Evas_Object *obj)
1172 * @param obj The imageslider object
1173 * @return The selected item or NULL
1174 *
1175 * @ingroup ImageSlider
1176 */
1177 EAPI Elm_Imageslider_Item *
1178 elm_imageslider_selected_item_get(Evas_Object * obj)
1179 {
1180         ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1181         Widget_Data *wd;
1182
1183         if (!obj || (!(wd = elm_widget_data_get(obj)))) {
1184                 return NULL;
1185         }
1186
1187         if (!wd->cur) return NULL;
1188
1189         return eina_list_data_get(wd->cur);
1190 }
1191
1192 /**
1193 * get whether item is selected or not
1194 *
1195 * @fn Eina_Bool elm_imageslider_item_selected_get(Elm_Imageslider_Item *it)
1196 * @param it the item
1197 * @return EINA_TRUE or EINA_FALSE
1198 *
1199 * @ingroup ImageSlider
1200 */
1201 EAPI Eina_Bool
1202 elm_imageslider_item_selected_get(Elm_Imageslider_Item * it)
1203 {
1204         Widget_Data *wd;
1205         
1206         if (!it || !it->obj || (!(wd = elm_widget_data_get(it->obj)))) {
1207                 return EINA_FALSE;
1208         }
1209
1210         if (!wd->cur) return EINA_FALSE;
1211
1212         if (eina_list_data_get(wd->cur) == it ) return EINA_TRUE;
1213         else return EINA_FALSE;
1214         
1215 }
1216
1217 /**
1218 * set selected item
1219 *
1220 * @fn void elm_imageslider_item_selected_set(Elm_Imageslider_Item *it);
1221 *
1222 * @ingroup ImageSlider
1223 */
1224 EAPI void
1225 elm_imageslider_item_selected_set(Elm_Imageslider_Item * it)
1226 {
1227         int i;
1228         Widget_Data *wd;
1229         Elm_Imageslider_Item *_it;
1230         Eina_List *l;
1231         Evas_Object *eo;
1232
1233         if (!it || !it->obj || (!(wd = elm_widget_data_get(it->obj)))) {
1234                 return ;
1235         }
1236
1237         EINA_LIST_FOREACH(wd->its, l, _it) {
1238                 if (_it == it ) {
1239                         wd->cur = l;
1240                 }
1241         }
1242
1243         for (i = 0; i < BLOCK_MAX; i++) {
1244                 eo = edje_object_part_swallow_get(elm_layout_edje_get(wd->ly[i]), "swl.photo");
1245                 if (eo) {
1246                         elm_layout_content_set(wd->ly[i], "swl.photo", NULL);
1247                         evas_object_del(eo);
1248                 }
1249         }
1250
1251         _imageslider_update(wd);
1252         
1253 }
1254
1255
1256 /**
1257 * get photo file path of give item
1258 *
1259 * @fn const char *elm_imageslider_item_photo_file_get(Elm_Imageslider_Item *it)
1260 * @param it item
1261 * @return The photo file path or NULL;
1262 *
1263 * @ingroup ImageSlider
1264 */
1265 EAPI const char *
1266 elm_imageslider_item_photo_file_get(Elm_Imageslider_Item * it)
1267 {
1268         if (!it) {
1269                 return NULL;
1270         }
1271
1272         return it->photo_file;
1273 }
1274
1275
1276 /**
1277 * get previous item
1278 *
1279 * @fn Elm_Imageslider_Item *elm_imageslider_item_prev(Elm_Imageslider_Item *it)
1280 * @param it     item
1281 * @return The previous item or NULL
1282 *
1283 * @ingroup ImageSlider
1284 */
1285 EAPI Elm_Imageslider_Item *
1286 elm_imageslider_item_prev(Elm_Imageslider_Item * it)
1287 {
1288         Widget_Data *wd;
1289         Elm_Imageslider_Item *_it;
1290         Eina_List *l;
1291
1292         if (!it || (!(wd = elm_widget_data_get(it->obj)))) {
1293                 return NULL;
1294         }
1295
1296         EINA_LIST_FOREACH(wd->its, l, _it) {
1297                 if (_it == it) {
1298                         l = eina_list_prev(l);
1299                         if (!l) break;
1300                         return eina_list_data_get(l);
1301                 }
1302         }
1303
1304         return NULL;    
1305 }
1306
1307
1308 /**
1309 * get next item
1310 *
1311 * @fn Elm_Imageslider_Item *elm_imageslider_item_next(Elm_Imageslider_Item *it)
1312 * @param it     item
1313 * @return The next item or NULL
1314 *
1315 * @ingroup ImageSlider
1316 */
1317 EAPI Elm_Imageslider_Item *
1318 elm_imageslider_item_next(Elm_Imageslider_Item * it)
1319 {
1320         Widget_Data *wd;
1321         Elm_Imageslider_Item *_it;
1322         Eina_List *l;
1323
1324         if (!it || (!(wd = elm_widget_data_get(it->obj)))) {
1325                 return NULL;
1326         }
1327
1328         EINA_LIST_FOREACH(wd->its, l, _it) {
1329                 if (_it == it) {
1330                         l = eina_list_next(l);
1331                         if (!l) break;
1332                         return eina_list_data_get(l);
1333                 }
1334         }
1335
1336         return NULL;
1337 }
1338
1339
1340 /**
1341 * move to previous item
1342 *
1343 * @fn void *elm_imageslider_prev(Evas_Object *obj)
1344 * @param obj imageslider object
1345 *
1346 * @ingroup ImageSlider
1347 */
1348 EAPI void 
1349 elm_imageslider_prev(Evas_Object * obj)
1350 {
1351         ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1352         Widget_Data *wd;
1353         
1354         if (!obj || (!(wd = elm_widget_data_get(obj)))) {
1355                 return ;
1356         }
1357
1358         if (wd->ani_lock) return;
1359
1360         _imageslider_obj_move(wd, -1);
1361 }
1362
1363
1364 /**
1365 * move to next item
1366 *
1367 * @fn void *elm_imageslider_next(Evas_Object *obj)
1368 * @param obj imageslider object
1369 *
1370 * @ingroup ImageSlider
1371 */
1372 EAPI void
1373 elm_imageslider_next(Evas_Object * obj)
1374 {
1375         ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1376         Widget_Data *wd;
1377         
1378         if (!obj || (!(wd = elm_widget_data_get(obj)))) {
1379                 return ;
1380         }
1381
1382         if (wd->ani_lock) return;
1383
1384         _imageslider_obj_move(wd, 1);
1385         
1386 }
1387
1388
1389
1390
1391