[SLP Merge] 2011/07/12 11:00 34a691da729cee2e39c71ad73eff4337c4a5402b
[framework/uifw/elementary.git] / src / lib / els_icon.c
1 #include <Elementary.h>
2 #include "elm_priv.h"
3
4 typedef struct _Smart_Data Smart_Data;
5
6 struct _Smart_Data
7 {
8    Evas_Coord   x, y, w, h;
9    Evas_Object *obj;
10    Evas_Object *prev;
11    int          size;
12    double       scale;
13    Eina_Bool fill_inside : 1;
14    Eina_Bool scale_up : 1;
15    Eina_Bool scale_down : 1;
16    Eina_Bool preloading : 1;
17    Eina_Bool show : 1;
18    Eina_Bool edit : 1;
19    Eina_Bool edje : 1;
20    Eina_Bool aspect_ratio_retained: 1;
21    Elm_Image_Orient orient;
22 };
23
24 /* local subsystem functions */
25 static void _smart_reconfigure(Smart_Data *sd);
26 static void _smart_init(void);
27 static void _smart_add(Evas_Object *obj);
28 static void _smart_del(Evas_Object *obj);
29 static void _smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y);
30 static void _smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h);
31 static void _smart_show(Evas_Object *obj);
32 static void _smart_hide(Evas_Object *obj);
33 static void _smart_color_set(Evas_Object *obj, int r, int g, int b, int a);
34 static void _smart_clip_set(Evas_Object *obj, Evas_Object * clip);
35 static void _smart_clip_unset(Evas_Object *obj);
36
37 static void _els_smart_icon_flip_horizontal(Smart_Data *sd);
38 static void _els_smart_icon_flip_vertical(Smart_Data *sd);
39 static void _els_smart_icon_rotate_180(Smart_Data *sd);
40 static Eina_Bool _els_smart_icon_dropcb(void *,Evas_Object *, Elm_Selection_Data *);
41
42 /* local subsystem globals */
43 static Evas_Smart *_e_smart = NULL;
44
45 /* externally accessible functions */
46 Evas_Object *
47 _els_smart_icon_add(Evas *evas)
48 {
49    _smart_init();
50    return evas_object_smart_add(evas, _e_smart);
51 }
52
53 static void
54 _preloaded(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event __UNUSED__)
55 {
56    Smart_Data *sd = data;
57
58    sd->preloading = EINA_FALSE;
59    if (obj == sd->obj)
60      {
61         if (sd->show)
62           evas_object_show(sd->obj);
63      }
64    if (sd->prev) evas_object_del(sd->prev);
65    sd->prev = NULL;
66 }
67
68 Eina_Bool
69 _els_smart_icon_file_key_set(Evas_Object *obj, const char *file, const char *key)
70 {
71    Smart_Data *sd;
72    Evas_Object *pclip;
73
74    sd = evas_object_smart_data_get(obj);
75    if (!sd) return EINA_FALSE;
76    /* smart code here */
77    if (sd->prev) evas_object_del(sd->prev);
78    pclip = evas_object_clip_get(sd->obj);
79    if (sd->obj) sd->prev = sd->obj;
80    sd->obj = evas_object_image_add(evas_object_evas_get(obj));
81    evas_object_event_callback_add(sd->obj, EVAS_CALLBACK_IMAGE_PRELOADED,
82                                   _preloaded, sd);
83    evas_object_smart_member_add(sd->obj, obj);
84    if (sd->prev) evas_object_smart_member_add(sd->prev, obj);
85    evas_object_image_scale_hint_set(sd->obj, EVAS_IMAGE_SCALE_HINT_STATIC);
86    evas_object_clip_set(sd->obj, pclip);
87
88    sd->edje = EINA_FALSE;
89
90    if (!sd->size)
91      evas_object_image_load_size_set(sd->obj, sd->size, sd->size);
92    evas_object_image_file_set(sd->obj, file, key);
93    // NOTE: Do not merge upstream for sd->preloading.
94    sd->preloading = EINA_FALSE; // by default preload off by seok.j.jeong
95    sd->show = EINA_TRUE;
96    // NOTE: Do not merge upstream for sd->preloading.
97    if (sd->preloading)
98      evas_object_image_preload(sd->obj, EINA_FALSE);
99    // NOTE: Do not merge upstream for sd->preloading.
100    if (sd->preloading) // sd->preloading can be changed by above function. so add "if (sd->preloading)" as below
101      evas_object_hide(sd->obj);
102    if (evas_object_image_load_error_get(sd->obj) != EVAS_LOAD_ERROR_NONE)
103      {
104         ERR("Things are going bad for '%s' (%p)", file, sd->obj);
105         return EINA_FALSE;
106      }
107    _smart_reconfigure(sd);
108    return EINA_TRUE;
109 }
110
111 Eina_Bool
112 _els_smart_icon_file_edje_set(Evas_Object *obj, const char *file, const char *part)
113 {
114    Smart_Data *sd;
115    Evas_Object *pclip;
116
117    sd = evas_object_smart_data_get(obj);
118    if (!sd) return EINA_FALSE;
119    /* smart code here */
120    if (sd->prev) evas_object_del(sd->prev);
121    sd->prev = NULL;
122
123    if (!sd->edje)
124      {
125         pclip = evas_object_clip_get(sd->obj);
126         if (sd->obj) evas_object_del(sd->obj);
127         sd->obj = edje_object_add(evas_object_evas_get(obj));
128         evas_object_smart_member_add(sd->obj, obj);
129         if (sd->show) evas_object_show(sd->obj);
130         evas_object_clip_set(sd->obj, pclip);
131      }
132    sd->edje = EINA_TRUE;
133    if (!edje_object_file_set(sd->obj, file, part))
134      return EINA_FALSE;
135    _smart_reconfigure(sd);
136    return EINA_TRUE;
137 }
138
139 void
140 _els_smart_icon_file_get(const Evas_Object *obj, const char **file, const char **key)
141 {
142    Smart_Data *sd = evas_object_smart_data_get(obj);
143    if (!sd) return;
144    if (sd->edje)
145      edje_object_file_get(sd->obj, file, key);
146    else
147      evas_object_image_file_get(sd->obj, file, key);
148 }
149
150 void
151 _els_smart_icon_smooth_scale_set(Evas_Object *obj, Eina_Bool smooth)
152 {
153    Smart_Data *sd = evas_object_smart_data_get(obj);
154    if (!sd) return;
155    if (sd->edje)
156      return;
157    evas_object_image_smooth_scale_set(sd->obj, smooth);
158 }
159
160 Eina_Bool
161 _els_smart_icon_smooth_scale_get(const Evas_Object *obj)
162 {
163    Smart_Data *sd = evas_object_smart_data_get(obj);
164    if (!sd) return EINA_FALSE;
165    if (sd->edje)
166      return EINA_FALSE;
167    return evas_object_image_smooth_scale_get(sd->obj);
168 }
169
170 Evas_Object *
171 _els_smart_icon_object_get(const Evas_Object *obj)
172 {
173    Smart_Data *sd = evas_object_smart_data_get(obj);
174    if (!sd) return NULL;
175    return sd->obj;
176 }
177
178 void
179 _els_smart_icon_size_get(const Evas_Object *obj, int *w, int *h)
180 {
181    Smart_Data *sd;
182    int tw, th;
183    int cw, ch;
184
185    sd = evas_object_smart_data_get(obj);
186    if (!sd) return;
187    if (!strcmp(evas_object_type_get(sd->obj), "edje"))
188      edje_object_size_min_get(sd->obj, &tw, &th);
189    else
190      evas_object_image_size_get(sd->obj, &tw, &th);
191    evas_object_geometry_get(sd->obj, NULL, NULL, &cw, &ch);
192    tw = tw > cw ? tw : cw;
193    th = th > ch ? th : ch;
194    tw = ((double)tw) * sd->scale;
195    th = ((double)th) * sd->scale;
196    if (w) *w = tw;
197    if (h) *h = th;
198 }
199
200 void
201 _els_smart_icon_fill_inside_set(Evas_Object *obj, Eina_Bool fill_inside)
202 {
203    Smart_Data *sd;
204
205    sd = evas_object_smart_data_get(obj);
206    if (!sd) return;
207    if (((sd->fill_inside) && (fill_inside)) ||
208        ((!sd->fill_inside) && (!fill_inside))) return;
209    sd->fill_inside = fill_inside;
210    _smart_reconfigure(sd);
211 }
212
213 Eina_Bool
214 _els_smart_icon_fill_inside_get(const Evas_Object *obj)
215 {
216    Smart_Data *sd = evas_object_smart_data_get(obj);
217    if (!sd) return EINA_FALSE;
218    return sd->fill_inside;
219 }
220
221 void
222 _els_smart_icon_scale_up_set(Evas_Object *obj, Eina_Bool scale_up)
223 {
224    Smart_Data *sd;
225
226    sd = evas_object_smart_data_get(obj);
227    if (!sd) return;
228    if (((sd->scale_up) && (scale_up)) ||
229        ((!sd->scale_up) && (!scale_up))) return;
230    sd->scale_up = scale_up;
231    _smart_reconfigure(sd);
232 }
233
234 Eina_Bool
235 _els_smart_icon_scale_up_get(const Evas_Object *obj)
236 {
237    Smart_Data *sd; sd = evas_object_smart_data_get(obj);
238    if (!sd) return EINA_FALSE;
239    return sd->scale_up;
240 }
241
242 void
243 _els_smart_icon_scale_down_set(Evas_Object *obj, Eina_Bool scale_down)
244 {
245    Smart_Data *sd;
246
247    sd = evas_object_smart_data_get(obj);
248    if (!sd) return;
249    if (((sd->scale_down) && (scale_down)) ||
250        ((!sd->scale_down) && (!scale_down))) return;
251    sd->scale_down = scale_down;
252    _smart_reconfigure(sd);
253 }
254
255 Eina_Bool
256 _els_smart_icon_scale_down_get(const Evas_Object *obj)
257 {
258    Smart_Data *sd; sd = evas_object_smart_data_get(obj);
259    if (!sd) return EINA_FALSE;
260    return sd->scale_up;
261 }
262
263 void
264 _els_smart_icon_scale_size_set(Evas_Object *obj, int size)
265 {
266    Smart_Data *sd;
267
268    sd = evas_object_smart_data_get(obj);
269    if (!sd) return;
270    sd->size = size;
271    if (!sd->obj) return;
272    if (sd->edje)
273      return;
274    evas_object_image_load_size_set(sd->obj, sd->size, sd->size);
275 }
276
277 int
278 _els_smart_icon_scale_size_get(const Evas_Object *obj)
279 {
280    Smart_Data *sd; sd = evas_object_smart_data_get(obj);
281    if (!sd) return 0;
282    return sd->size;
283 }
284
285 void
286 _els_smart_icon_scale_set(Evas_Object *obj, double scale)
287 {
288    Smart_Data *sd = evas_object_smart_data_get(obj);
289    if (!sd) return;
290    sd->scale = scale;
291    _smart_reconfigure(sd);
292 }
293
294 double
295 _els_smart_icon_scale_get(const Evas_Object *obj)
296 {
297    Smart_Data *sd; sd = evas_object_smart_data_get(obj);
298    if (!sd) return 0.0;
299    return sd->scale;
300 }
301
302 void
303 _els_smart_icon_orient_set(Evas_Object *obj, Elm_Image_Orient orient)
304 {
305    Smart_Data   *sd;
306    Evas_Object  *tmp;
307    unsigned int *data, *data2, *to, *from;
308    int           x, y, w, hw, iw, ih;
309    const char   *file, *key;
310
311    sd = evas_object_smart_data_get(obj);
312    if (!sd) return;
313    if (sd->edje)
314      return;
315
316    switch (orient)
317      {
318       case ELM_IMAGE_FLIP_HORIZONTAL:
319          _els_smart_icon_flip_horizontal(sd);
320          return;
321       case ELM_IMAGE_FLIP_VERTICAL:
322          _els_smart_icon_flip_vertical(sd);
323          return;
324       case ELM_IMAGE_ROTATE_180_CW:
325          _els_smart_icon_rotate_180(sd);
326          return;
327       default:
328          break;
329      }
330
331    evas_object_image_size_get(sd->obj, &iw, &ih);
332    evas_object_image_file_get(sd->obj, &file, &key);
333    tmp = evas_object_image_add(evas_object_evas_get(sd->obj));
334    evas_object_image_file_set(tmp, file, key);
335    data2 = evas_object_image_data_get(tmp, EINA_FALSE);
336
337    w = ih;
338    ih = iw;
339    iw = w;
340    hw = w * ih;
341
342    evas_object_image_size_set(sd->obj, iw, ih);
343    data = evas_object_image_data_get(sd->obj, EINA_TRUE);
344    switch (orient)
345      {
346       case ELM_IMAGE_FLIP_TRANSPOSE:
347          to = data;
348          hw = -hw + 1;
349          break;
350       case ELM_IMAGE_FLIP_TRANSVERSE:
351          to = data + hw - 1;
352          w = -w;
353          hw = hw - 1;
354          break;
355       case ELM_IMAGE_ROTATE_90_CW:
356          to = data + w - 1;
357          hw = -hw - 1;
358          break;
359       case ELM_IMAGE_ROTATE_90_CCW:
360          to = data + hw - w;
361          w = -w;
362          hw = hw + 1;
363          break;
364       default:
365          ERR("unknown orient %d", orient);
366          evas_object_del(tmp);
367          evas_object_image_data_set(sd->obj, data); // give it back
368          return;
369      }
370    from = data2;
371    for (x = iw; --x >= 0;)
372      {
373         for (y = ih; --y >= 0;)
374           {
375              *to = *from;
376              from++;
377              to += w;
378           }
379         to += hw;
380      }
381    sd->orient = orient;
382    evas_object_del(tmp);
383    evas_object_image_data_set(sd->obj, data);
384    evas_object_image_data_update_add(sd->obj, 0, 0, iw, ih);
385    _smart_reconfigure(sd);
386 }
387
388 Elm_Image_Orient
389 _els_smart_icon_orient_get(const Evas_Object *obj)
390 {
391    Smart_Data *sd; sd = evas_object_smart_data_get(obj);
392    if (!sd) return 0;
393    return sd->orient;
394 }
395
396 /**
397  * Turns on editing through drag and drop and copy and paste.
398  */
399 void
400 _els_smart_icon_edit_set(Evas_Object *obj, Eina_Bool edit, Evas_Object *parent)
401 {
402    Smart_Data   *sd = evas_object_smart_data_get(obj);
403    if (!sd) return;
404
405    if (sd->edje)
406      {
407         printf("No editing edje objects yet (ever)\n");
408         return;
409      }
410
411    /* Unfortunately eina bool is not a bool, but a char */
412    if (edit == sd->edit) return;
413
414    sd->edit = edit;
415
416    if (sd->edit)
417      elm_drop_target_add(obj, ELM_SEL_FORMAT_IMAGE, _els_smart_icon_dropcb,
418                          parent);
419    else
420      elm_drop_target_del(obj);
421 }
422
423 Eina_Bool
424 _els_smart_icon_edit_get(const Evas_Object *obj)
425 {
426    Smart_Data *sd; sd = evas_object_smart_data_get(obj);
427    if (!sd) return EINA_FALSE;
428    return sd->edit;
429 }
430
431 Evas_Object *
432 _els_smart_icon_edje_get(Evas_Object *obj)
433 {
434    Smart_Data *sd = evas_object_smart_data_get(obj);
435    if (!sd) return NULL;
436    if (!sd->edje) return NULL;
437    return sd->obj;
438 }
439
440 void
441 _els_smart_icon_aspect_ratio_retained_set(Evas_Object *obj, Eina_Bool retained)
442 {
443    Smart_Data *sd;
444
445    sd = evas_object_smart_data_get(obj);
446    if (!sd) return;
447
448    retained = !!retained;
449    if (sd->aspect_ratio_retained == retained) return;
450    sd->aspect_ratio_retained = retained;
451    _smart_reconfigure(sd);
452 }
453
454 Eina_Bool
455 _els_smart_icon_aspect_ratio_retained_get(const Evas_Object *obj)
456 {
457    Smart_Data *sd;
458
459    sd = evas_object_smart_data_get(obj);
460    if (!sd) return EINA_FALSE;
461    return sd->aspect_ratio_retained;
462 }
463
464 /* local subsystem globals */
465 static void
466 _smart_reconfigure(Smart_Data *sd)
467 {
468    Evas_Coord x, y, w, h;
469
470    if (!sd->obj) return;
471
472    w = sd->w;
473    h = sd->h;
474
475    if (!strcmp(evas_object_type_get(sd->obj), "edje"))
476      {
477         x = sd->x;
478         y = sd->y;
479         evas_object_move(sd->obj, x, y);
480         evas_object_resize(sd->obj, w, h);
481      }
482    else
483      {
484         int iw = 0, ih = 0;
485
486         evas_object_image_size_get(sd->obj, &iw, &ih);
487
488         iw = ((double)iw) * sd->scale;
489         ih = ((double)ih) * sd->scale;
490
491         if (iw < 1) iw = 1;
492         if (ih < 1) ih = 1;
493
494         if (sd->aspect_ratio_retained)
495           {
496              h = ((double)ih * w) / (double)iw;
497              if (sd->fill_inside)
498                {
499                   if (h > sd->h)
500                     {
501                        h = sd->h;
502                        w = ((double)iw * h) / (double)ih;
503                     }
504                }
505              else
506                {
507                   if (h < sd->h)
508                     {
509                        h = sd->h;
510                        w = ((double)iw * h) / (double)ih;
511                     }
512                }
513           }
514         if (!sd->scale_up)
515           {
516              if (w > iw) w = iw;
517              if (h > ih) h = ih;
518           }
519         if (!sd->scale_down)
520           {
521              if (w < iw) w = iw;
522              if (h < ih) h = ih;
523           }
524         x = sd->x + ((sd->w - w) / 2);
525         y = sd->y + ((sd->h - h) / 2);
526         evas_object_move(sd->obj, x, y);
527         evas_object_image_fill_set(sd->obj, 0, 0, w, h);
528         evas_object_resize(sd->obj, w, h);
529      }
530 }
531
532 static void
533 _smart_init(void)
534 {
535    if (_e_smart) return;
536      {
537         static const Evas_Smart_Class sc =
538           {
539              "e_icon",
540              EVAS_SMART_CLASS_VERSION,
541              _smart_add,
542              _smart_del,
543              _smart_move,
544              _smart_resize,
545              _smart_show,
546              _smart_hide,
547              _smart_color_set,
548              _smart_clip_set,
549              _smart_clip_unset,
550              NULL,
551              NULL,
552              NULL,
553              NULL,
554              NULL,
555              NULL,
556              NULL
557           };
558         _e_smart = evas_smart_class_new(&sc);
559      }
560 }
561
562 static void
563 _smart_add(Evas_Object *obj)
564 {
565    Smart_Data *sd;
566
567    sd = calloc(1, sizeof(Smart_Data));
568    if (!sd) return;
569    sd->obj = evas_object_image_add(evas_object_evas_get(obj));
570    sd->prev = NULL;
571    evas_object_image_scale_hint_set(sd->obj, EVAS_IMAGE_SCALE_HINT_STATIC);
572    sd->x = 0;
573    sd->y = 0;
574    sd->w = 0;
575    sd->h = 0;
576    sd->fill_inside = EINA_TRUE;
577    sd->scale_up = EINA_TRUE;
578    sd->scale_down = EINA_TRUE;
579    sd->aspect_ratio_retained = EINA_TRUE;
580    sd->size = 64;
581    sd->scale = 1.0;
582    evas_object_smart_member_add(sd->obj, obj);
583    evas_object_smart_data_set(obj, sd);
584    evas_object_event_callback_add(sd->obj, EVAS_CALLBACK_IMAGE_PRELOADED,
585                                   _preloaded, sd);
586 }
587
588 static void
589 _smart_del(Evas_Object *obj)
590 {
591    Smart_Data *sd;
592
593    sd = evas_object_smart_data_get(obj);
594    if (!sd) return;
595    evas_object_del(sd->obj);
596    if (sd->prev) evas_object_del(sd->prev);
597    free(sd);
598 }
599
600 static void
601 _smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
602 {
603    Smart_Data *sd;
604
605    sd = evas_object_smart_data_get(obj);
606    if (!sd) return;
607    if ((sd->x == x) && (sd->y == y)) return;
608    sd->x = x;
609    sd->y = y;
610    _smart_reconfigure(sd);
611 }
612
613 static void
614 _smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
615 {
616    Smart_Data *sd;
617
618    sd = evas_object_smart_data_get(obj);
619    if (!sd) return;
620    if ((sd->w == w) && (sd->h == h)) return;
621    sd->w = w;
622    sd->h = h;
623    _smart_reconfigure(sd);
624 }
625
626 static void
627 _smart_show(Evas_Object *obj)
628 {
629    Smart_Data *sd;
630
631    sd = evas_object_smart_data_get(obj);
632    if (!sd) return;
633    sd->show = EINA_TRUE;
634    if (!sd->preloading)
635      {
636         evas_object_show(sd->obj);
637         if (sd->prev) evas_object_del(sd->prev);
638         sd->prev = NULL;
639      }
640 }
641
642 static void
643 _smart_hide(Evas_Object *obj)
644 {
645    Smart_Data *sd;
646
647    sd = evas_object_smart_data_get(obj);
648    if (!sd) return;
649    sd->show = EINA_FALSE;
650    evas_object_hide(sd->obj);
651    if (sd->prev) evas_object_del(sd->prev);
652    sd->prev = NULL;
653 }
654
655 static void
656 _smart_color_set(Evas_Object *obj, int r, int g, int b, int a)
657 {
658    Smart_Data *sd;
659
660    sd = evas_object_smart_data_get(obj);
661    if (!sd) return;
662    evas_object_color_set(sd->obj, r, g, b, a);
663    if (sd->prev) evas_object_color_set(sd->prev, r, g, b, a);
664 }
665
666 static void
667 _smart_clip_set(Evas_Object *obj, Evas_Object * clip)
668 {
669    Smart_Data *sd;
670
671    sd = evas_object_smart_data_get(obj);
672    if (!sd) return;
673    evas_object_clip_set(sd->obj, clip);
674    if (sd->prev) evas_object_clip_set(sd->prev, clip);
675 }
676
677 static void
678 _smart_clip_unset(Evas_Object *obj)
679 {
680    Smart_Data *sd;
681
682    sd = evas_object_smart_data_get(obj);
683    if (!sd) return;
684    evas_object_clip_unset(sd->obj);
685    if (sd->prev) evas_object_clip_unset(sd->prev);
686 }
687
688 static void
689 _els_smart_icon_flip_horizontal(Smart_Data *sd)
690 {
691    unsigned int   *data;
692    unsigned int   *p1, *p2, tmp;
693    int             x, y, iw, ih;
694
695    evas_object_image_size_get(sd->obj, &iw, &ih);
696    data = evas_object_image_data_get(sd->obj, EINA_TRUE);
697
698    for (y = 0; y < ih; y++)
699      {
700         p1 = data + (y * iw);
701         p2 = data + ((y + 1) * iw) - 1;
702         for (x = 0; x < (iw >> 1); x++)
703           {
704              tmp = *p1;
705              *p1 = *p2;
706              *p2 = tmp;
707              p1++;
708              p2--;
709           }
710      }
711
712    evas_object_image_data_set(sd->obj, data);
713    evas_object_image_data_update_add(sd->obj, 0, 0, iw, ih);
714    _smart_reconfigure(sd);
715 }
716
717 static void
718 _els_smart_icon_flip_vertical(Smart_Data *sd)
719 {
720    unsigned int   *data;
721    unsigned int   *p1, *p2, tmp;
722    int             x, y, iw, ih;
723
724    evas_object_image_size_get(sd->obj, &iw, &ih);
725    data = evas_object_image_data_get(sd->obj, EINA_TRUE);
726
727    for (y = 0; y < (ih >> 1); y++)
728      {
729         p1 = data + (y * iw);
730         p2 = data + ((ih - 1 - y) * iw);
731         for (x = 0; x < iw; x++)
732           {
733              tmp = *p1;
734              *p1 = *p2;
735              *p2 = tmp;
736              p1++;
737              p2++;
738           }
739      }
740
741    evas_object_image_data_set(sd->obj, data);
742    evas_object_image_data_update_add(sd->obj, 0, 0, iw, ih);
743    _smart_reconfigure(sd);
744 }
745
746 static void
747 _els_smart_icon_rotate_180(Smart_Data *sd)
748 {
749    unsigned int   *data;
750    unsigned int   *p1, *p2, tmp;
751    int             x, hw, iw, ih;
752
753    evas_object_image_size_get(sd->obj, &iw, &ih);
754    data = evas_object_image_data_get(sd->obj, 1);
755
756    hw = iw * ih;
757    x = (hw / 2);
758    p1 = data;
759    p2 = data + hw - 1;
760    for (; --x > 0;)
761      {
762         tmp = *p1;
763         *p1 = *p2;
764         *p2 = tmp;
765         p1++;
766         p2--;
767      }
768    evas_object_image_data_set(sd->obj, data);
769    evas_object_image_data_update_add(sd->obj, 0, 0, iw, ih);
770    _smart_reconfigure(sd);
771 }
772
773 static Eina_Bool
774 _els_smart_icon_dropcb(void *elmobj,Evas_Object *obj, Elm_Selection_Data *drop)
775 {
776    _els_smart_icon_file_key_set(obj, drop->data, NULL);
777    evas_object_smart_callback_call(elmobj, "drop", drop->data);
778
779    return EINA_TRUE;
780 }
781 /* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-3f0^-2{2(0W1st0 :*/