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