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