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