1 #include <Elementary.h>
3 #include "elm_widget_image.h"
6 # define FMT_SIZE_T "%Iu"
8 # define FMT_SIZE_T "%zu"
11 EAPI const char ELM_IMAGE_SMART_NAME[] = "elm_image";
13 static const char SIG_DND[] = "drop";
14 static const char SIG_CLICKED[] = "clicked";
15 static const Evas_Smart_Cb_Description _smart_callbacks[] = {
21 EVAS_SMART_SUBCLASS_NEW
22 (ELM_IMAGE_SMART_NAME, _elm_image, Elm_Image_Smart_Class,
23 Elm_Widget_Smart_Class, elm_widget_smart_class_get, _smart_callbacks);
26 _on_image_preloaded(void *data,
29 void *event __UNUSED__)
31 Elm_Image_Smart_Data *sd = data;
33 sd->preloading = EINA_FALSE;
35 if (sd->show) evas_object_show(obj);
36 if (sd->prev_img) evas_object_del(sd->prev_img);
42 _on_mouse_up(void *data,
44 Evas_Object *obj __UNUSED__,
45 void *event_info __UNUSED__)
47 evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
51 _elm_image_animate_cb(void *data)
53 Elm_Image_Smart_Data *sd = data;
55 if (!sd->anim) return ECORE_CALLBACK_CANCEL;
58 if (sd->cur_frame > sd->frame_count)
59 sd->cur_frame = sd->cur_frame % sd->frame_count;
61 evas_object_image_animated_frame_set(sd->img, sd->cur_frame);
63 sd->frame_duration = evas_object_image_animated_frame_duration_get
64 (sd->img, sd->cur_frame, 0);
66 if (sd->frame_duration > 0)
67 ecore_timer_interval_set(sd->anim_timer, sd->frame_duration);
69 return ECORE_CALLBACK_RENEW;
73 _img_new(Evas_Object *obj)
77 ELM_IMAGE_DATA_GET(obj, sd);
79 img = evas_object_image_add(evas_object_evas_get(obj));
80 evas_object_image_scale_hint_set(img, EVAS_IMAGE_SCALE_HINT_STATIC);
81 evas_object_repeat_events_set(img, EINA_TRUE);
82 evas_object_event_callback_add
83 (img, EVAS_CALLBACK_IMAGE_PRELOADED, _on_image_preloaded, sd);
85 evas_object_smart_member_add(img, obj);
86 elm_widget_sub_object_add(obj, img);
91 /* fixme: testar drag and drop depois! */
94 _elm_image_internal_sizing_eval(Elm_Image_Smart_Data *sd)
96 Evas_Coord x, y, w, h;
104 type = evas_object_type_get(sd->img);
107 if (!strcmp(type, "edje"))
111 evas_object_move(sd->img, x, y);
112 evas_object_resize(sd->img, w, h);
116 double alignh = 0.5, alignv = 0.5;
119 evas_object_image_size_get(sd->img, &iw, &ih);
121 iw = ((double)iw) * sd->scale;
122 ih = ((double)ih) * sd->scale;
127 if (sd->aspect_fixed)
129 h = ((double)ih * w) / (double)iw;
135 w = ((double)iw * h) / (double)ih;
143 w = ((double)iw * h) / (double)ih;
152 if (!sd->resize_down)
158 evas_object_size_hint_align_get
159 (ELM_WIDGET_DATA(sd)->obj, &alignh, &alignv);
161 if (alignh == EVAS_HINT_FILL) alignh = 0.5;
162 if (alignv == EVAS_HINT_FILL) alignv = 0.5;
164 x = sd->img_x + ((sd->img_w - w) * alignh);
165 y = sd->img_y + ((sd->img_h - h) * alignv);
167 evas_object_move(sd->img, x, y);
168 evas_object_image_fill_set(sd->img, 0, 0, w, h);
169 evas_object_resize(sd->img, w, h);
171 evas_object_move(sd->hit_rect, x, y);
172 evas_object_resize(sd->hit_rect, w, h);
176 _elm_image_file_set_do(Evas_Object *obj)
178 Evas_Object *pclip = NULL;
180 ELM_IMAGE_DATA_GET(obj, sd);
182 if (sd->prev_img) evas_object_del(sd->prev_img);
185 pclip = evas_object_clip_get(sd->img);
186 sd->prev_img = sd->img;
189 sd->img = _img_new(obj);
191 evas_object_image_load_orientation_set(sd->img, EINA_TRUE);
193 evas_object_clip_set(sd->img, pclip);
195 sd->edje = EINA_FALSE;
198 evas_object_image_load_size_set(sd->img, sd->load_size, sd->load_size);
201 /* WARNING: whenever you patch this function, remember to do the same
202 * on elm_icon.c:_elm_icon_smart_file_set()'s 2nd half.
205 _elm_image_edje_file_set(Evas_Object *obj,
211 ELM_IMAGE_DATA_GET(obj, sd);
213 if (sd->prev_img) evas_object_del(sd->prev_img);
218 pclip = evas_object_clip_get(sd->img);
219 if (sd->img) evas_object_del(sd->img);
221 /* Edje object instead */
222 sd->img = edje_object_add(evas_object_evas_get(obj));
223 evas_object_smart_member_add(sd->img, obj);
224 if (sd->show) evas_object_show(sd->img);
225 evas_object_clip_set(sd->img, pclip);
228 sd->edje = EINA_TRUE;
229 if (!edje_object_file_set(sd->img, file, group))
231 ERR("failed to set edje file '%s', group '%s': %s", file, group,
232 edje_load_error_str(edje_object_load_error_get(sd->img)));
236 /* FIXME: do i want to update icon on file change ? */
237 _elm_image_internal_sizing_eval(sd);
243 _elm_image_smart_size_get(const Evas_Object *obj,
251 ELM_IMAGE_DATA_GET(obj, sd);
253 type = evas_object_type_get(sd->img);
256 if (!strcmp(type, "edje"))
257 edje_object_size_min_get(sd->img, &tw, &th);
259 evas_object_image_size_get(sd->img, &tw, &th);
261 if ((sd->resize_up) || (sd->resize_down))
262 evas_object_geometry_get(sd->img, NULL, NULL, &cw, &ch);
264 tw = tw > cw ? tw : cw;
265 th = th > ch ? th : ch;
266 tw = ((double)tw) * sd->scale;
267 th = ((double)th) * sd->scale;
273 _elm_image_smart_smooth_scale_set(Evas_Object *obj,
276 ELM_IMAGE_DATA_GET(obj, sd);
278 if (sd->edje) return;
280 evas_object_image_smooth_scale_set(sd->img, smooth);
284 _elm_image_smart_smooth_scale_get(const Evas_Object *obj)
286 ELM_IMAGE_DATA_GET(obj, sd);
288 if (sd->edje) return EINA_FALSE;
290 return evas_object_image_smooth_scale_get(sd->img);
294 _elm_image_smart_object_get(const Evas_Object *obj)
296 ELM_IMAGE_DATA_GET(obj, sd);
302 _elm_image_smart_fill_inside_set(Evas_Object *obj,
303 Eina_Bool fill_inside)
305 ELM_IMAGE_DATA_GET(obj, sd);
307 fill_inside = !!fill_inside;
309 if (sd->fill_inside == fill_inside) return;
311 sd->fill_inside = fill_inside;
313 _elm_image_internal_sizing_eval(sd);
317 _elm_image_smart_fill_inside_get(const Evas_Object *obj)
319 ELM_IMAGE_DATA_GET(obj, sd);
321 return sd->fill_inside;
325 _elm_image_smart_resize_up_set(Evas_Object *obj,
328 ELM_IMAGE_DATA_GET(obj, sd);
330 resize_up = !!resize_up;
332 if (sd->resize_up == resize_up) return;
334 sd->resize_up = resize_up;
336 _elm_image_internal_sizing_eval(sd);
340 _elm_image_smart_resize_up_get(const Evas_Object *obj)
342 ELM_IMAGE_DATA_GET(obj, sd);
344 return sd->resize_up;
348 _elm_image_smart_resize_down_set(Evas_Object *obj,
349 Eina_Bool resize_down)
351 ELM_IMAGE_DATA_GET(obj, sd);
353 resize_down = !!resize_down;
355 if (sd->resize_down == resize_down) return;
357 sd->resize_down = resize_down;
359 _elm_image_internal_sizing_eval(sd);
363 _elm_image_smart_resize_down_get(const Evas_Object *obj)
365 ELM_IMAGE_DATA_GET(obj, sd);
367 return sd->resize_up;
371 _elm_image_flip_horizontal(Elm_Image_Smart_Data *sd)
373 unsigned int *p1, *p2, tmp;
377 evas_object_image_size_get(sd->img, &iw, &ih);
378 data = evas_object_image_data_get(sd->img, EINA_TRUE);
380 for (y = 0; y < ih; y++)
382 p1 = data + (y * iw);
383 p2 = data + ((y + 1) * iw) - 1;
384 for (x = 0; x < (iw >> 1); x++)
394 evas_object_image_data_set(sd->img, data);
395 evas_object_image_data_update_add(sd->img, 0, 0, iw, ih);
397 _elm_image_internal_sizing_eval(sd);
401 _elm_image_flip_vertical(Elm_Image_Smart_Data *sd)
403 unsigned int *p1, *p2, tmp;
407 evas_object_image_size_get(sd->img, &iw, &ih);
408 data = evas_object_image_data_get(sd->img, EINA_TRUE);
410 for (y = 0; y < (ih >> 1); y++)
412 p1 = data + (y * iw);
413 p2 = data + ((ih - 1 - y) * iw);
414 for (x = 0; x < iw; x++)
424 evas_object_image_data_set(sd->img, data);
425 evas_object_image_data_update_add(sd->img, 0, 0, iw, ih);
427 _elm_image_internal_sizing_eval(sd);
431 _elm_image_smart_rotate_180(Elm_Image_Smart_Data *sd)
433 unsigned int *p1, *p2, tmp;
437 evas_object_image_size_get(sd->img, &iw, &ih);
438 data = evas_object_image_data_get(sd->img, 1);
454 evas_object_image_data_set(sd->img, data);
455 evas_object_image_data_update_add(sd->img, 0, 0, iw, ih);
457 _elm_image_internal_sizing_eval(sd);
461 _elm_image_smart_orient_set(Evas_Object *obj,
462 Elm_Image_Orient orient)
464 unsigned int *data, *data2 = NULL, *to, *from;
465 int x, y, w, hw, iw, ih;
467 ELM_IMAGE_DATA_GET(obj, sd);
474 case ELM_IMAGE_FLIP_HORIZONTAL:
475 _elm_image_flip_horizontal(sd);
479 case ELM_IMAGE_FLIP_VERTICAL:
480 _elm_image_flip_vertical(sd);
484 case ELM_IMAGE_ROTATE_180:
485 _elm_image_smart_rotate_180(sd);
489 case ELM_IMAGE_ORIENT_NONE:
497 evas_object_image_size_get(sd->img, &iw, &ih);
499 /* we need separate destination memory if we want to rotate 90 or
501 data = evas_object_image_data_get(sd->img, EINA_FALSE);
503 data2 = malloc(sizeof(unsigned char) * (iw * ih * 4));
505 memcpy(data2, data, sizeof (unsigned char) * (iw * ih * 4));
512 evas_object_image_size_set(sd->img, iw, ih);
513 data = evas_object_image_data_get(sd->img, EINA_TRUE);
517 case ELM_IMAGE_FLIP_TRANSPOSE:
523 case ELM_IMAGE_FLIP_TRANSVERSE:
530 case ELM_IMAGE_ROTATE_90:
536 case ELM_IMAGE_ROTATE_270:
544 ERR("unknown orient %d", orient);
545 evas_object_image_data_set(sd->img, data); // give it back
546 if (data2) free(data2);
552 for (x = iw; --x >= 0; )
554 for (y = ih; --y >= 0; )
562 if (data2) free(data2);
564 evas_object_image_data_set(sd->img, data);
565 evas_object_image_data_update_add(sd->img, 0, 0, iw, ih);
567 _elm_image_internal_sizing_eval(sd);
570 static Elm_Image_Orient
571 _elm_image_smart_orient_get(const Evas_Object *obj)
573 ELM_IMAGE_DATA_GET(obj, sd);
579 _elm_image_drag_n_drop_cb(void *elm_obj,
581 Elm_Selection_Data *drop)
583 ELM_IMAGE_DATA_GET(obj, sd);
585 if (ELM_IMAGE_CLASS(ELM_WIDGET_DATA(sd)->api)->file_set
586 (obj, drop->data, NULL))
588 printf("dnd: %s, %s, %s", elm_widget_type_get(elm_obj),
589 SIG_DND, (char *)drop->data);
591 evas_object_smart_callback_call(elm_obj, SIG_DND, drop->data);
599 _elm_image_smart_add(Evas_Object *obj)
601 EVAS_SMART_DATA_ALLOC(obj, Elm_Image_Smart_Data);
603 ELM_WIDGET_CLASS(_elm_image_parent_sc)->base.add(obj);
605 priv->hit_rect = evas_object_rectangle_add(evas_object_evas_get(obj));
606 evas_object_smart_member_add(priv->hit_rect, obj);
607 elm_widget_sub_object_add(obj, priv->hit_rect);
609 evas_object_color_set(priv->hit_rect, 0, 0, 0, 0);
610 evas_object_show(priv->hit_rect);
611 evas_object_repeat_events_set(priv->hit_rect, EINA_TRUE);
613 evas_object_event_callback_add
614 (priv->hit_rect, EVAS_CALLBACK_MOUSE_UP, _on_mouse_up, obj);
616 /* starts as an Evas image. may switch to an Edje object */
617 priv->img = _img_new(obj);
618 priv->prev_img = NULL;
620 priv->smooth = EINA_TRUE;
621 priv->fill_inside = EINA_TRUE;
622 priv->resize_up = EINA_TRUE;
623 priv->resize_down = EINA_TRUE;
624 priv->aspect_fixed = EINA_TRUE;
626 priv->load_size = 64;
629 ELM_IMAGE_CLASS(ELM_WIDGET_DATA(priv)->api)->load_size_set(obj, 0);
631 elm_widget_can_focus_set(obj, EINA_FALSE);
633 ELM_IMAGE_CLASS(ELM_WIDGET_DATA(priv)->api)->sizing_eval(obj);
637 _elm_image_smart_del(Evas_Object *obj)
639 ELM_IMAGE_DATA_GET(obj, sd);
642 ecore_timer_del(sd->anim_timer);
644 evas_object_del(sd->img);
645 if (sd->prev_img) evas_object_del(sd->prev_img);
647 ELM_WIDGET_CLASS(_elm_image_parent_sc)->base.del(obj);
651 _elm_image_smart_move(Evas_Object *obj,
655 ELM_IMAGE_DATA_GET(obj, sd);
657 ELM_WIDGET_CLASS(_elm_image_parent_sc)->base.move(obj, x, y);
659 if ((sd->img_x == x) && (sd->img_y == y)) return;
663 /* takes care of moving */
664 _elm_image_internal_sizing_eval(sd);
668 _elm_image_smart_resize(Evas_Object *obj,
672 ELM_IMAGE_DATA_GET(obj, sd);
674 ELM_WIDGET_CLASS(_elm_image_parent_sc)->base.resize(obj, w, h);
676 if ((sd->img_w == w) && (sd->img_h == h)) return;
681 /* takes care of resizing */
682 _elm_image_internal_sizing_eval(sd);
686 _elm_image_smart_show(Evas_Object *obj)
688 ELM_IMAGE_DATA_GET(obj, sd);
690 sd->show = EINA_TRUE;
694 ELM_WIDGET_CLASS(_elm_image_parent_sc)->base.show(obj);
696 evas_object_show(sd->img);
698 if (sd->prev_img) evas_object_del(sd->prev_img);
703 _elm_image_smart_hide(Evas_Object *obj)
705 ELM_IMAGE_DATA_GET(obj, sd);
707 ELM_WIDGET_CLASS(_elm_image_parent_sc)->base.hide(obj);
709 sd->show = EINA_FALSE;
710 evas_object_hide(sd->img);
712 if (sd->prev_img) evas_object_del(sd->prev_img);
717 _elm_image_smart_member_add(Evas_Object *obj,
720 ELM_IMAGE_DATA_GET(obj, sd);
722 ELM_WIDGET_CLASS(_elm_image_parent_sc)->base.member_add(obj, member);
725 evas_object_raise(sd->hit_rect);
729 _elm_image_smart_color_set(Evas_Object *obj,
735 ELM_IMAGE_DATA_GET(obj, sd);
737 ELM_WIDGET_CLASS(_elm_image_parent_sc)->base.color_set(obj, r, g, b, a);
739 evas_object_color_set(sd->hit_rect, 0, 0, 0, 0);
740 evas_object_color_set(sd->img, r, g, b, a);
741 if (sd->prev_img) evas_object_color_set(sd->prev_img, r, g, b, a);
745 _elm_image_smart_clip_set(Evas_Object *obj,
748 ELM_IMAGE_DATA_GET(obj, sd);
750 ELM_WIDGET_CLASS(_elm_image_parent_sc)->base.clip_set(obj, clip);
752 evas_object_clip_set(sd->img, clip);
753 if (sd->prev_img) evas_object_clip_set(sd->prev_img, clip);
757 _elm_image_smart_clip_unset(Evas_Object *obj)
759 ELM_IMAGE_DATA_GET(obj, sd);
761 ELM_WIDGET_CLASS(_elm_image_parent_sc)->base.clip_unset(obj);
763 evas_object_clip_unset(sd->img);
764 if (sd->prev_img) evas_object_clip_unset(sd->prev_img);
768 _elm_image_smart_theme(Evas_Object *obj)
770 ELM_IMAGE_DATA_GET(obj, sd);
772 if (!ELM_WIDGET_CLASS(_elm_image_parent_sc)->theme(obj))
775 ELM_IMAGE_CLASS(ELM_WIDGET_DATA(sd)->api)->sizing_eval(obj);
781 _elm_image_smart_sizing_eval(Evas_Object *obj)
783 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
787 ELM_IMAGE_DATA_GET(obj, sd);
789 _elm_image_internal_sizing_eval(sd);
791 ELM_IMAGE_CLASS(ELM_WIDGET_DATA(sd)->api)->smooth_scale_set
795 ELM_IMAGE_CLASS(ELM_WIDGET_DATA(sd)->api)->scale_set(obj, 1.0);
797 ELM_IMAGE_CLASS(ELM_WIDGET_DATA(sd)->api)->scale_set
798 (obj, elm_widget_scale_get(obj) * elm_config_scale_get());
802 ELM_IMAGE_CLASS(ELM_WIDGET_DATA(sd)->api)->size_get(obj, &w, &h);
804 evas_object_size_hint_min_get(obj, &minw, &minh);
810 if ((sd->scale > 1.0) && (sd->resize_up))
812 maxw = minw = w * sd->scale;
813 maxh = minh = h * sd->scale;
815 else if ((sd->scale < 1.0) && (sd->resize_down))
817 maxw = minw = w * sd->scale;
818 maxh = minh = h * sd->scale;
823 if (!sd->resize_down)
825 minw = w * sd->scale;
826 minh = h * sd->scale;
830 maxw = w * sd->scale;
831 maxh = h * sd->scale;
835 evas_object_size_hint_min_set(obj, minw, minh);
836 evas_object_size_hint_max_set(obj, maxw, maxh);
840 _elm_image_smart_memfile_set(Evas_Object *obj,
846 ELM_IMAGE_DATA_GET(obj, sd);
848 _elm_image_file_set_do(obj);
850 evas_object_image_memfile_set
851 (sd->img, (void *)img, size, (char *)format, (char *)key);
853 sd->preloading = EINA_TRUE;
854 sd->show = EINA_TRUE;
856 evas_object_hide(sd->img);
857 evas_object_image_preload(sd->img, EINA_FALSE);
858 if (evas_object_image_load_error_get(sd->img) != EVAS_LOAD_ERROR_NONE)
860 ERR("Things are going bad for some random " FMT_SIZE_T
861 " byte chunk of memory (%p)", size, sd->img);
865 _elm_image_internal_sizing_eval(sd);
871 _elm_image_smart_file_set(Evas_Object *obj,
877 ELM_IMAGE_DATA_GET(obj, sd);
879 if (eina_str_has_extension(file, ".edj"))
880 return _elm_image_edje_file_set(obj, file, key);
882 _elm_image_file_set_do(obj);
884 evas_object_image_file_set(sd->img, file, key);
886 sd->preloading = EINA_TRUE;
887 sd->show = EINA_TRUE;
889 evas_object_hide(sd->img);
891 ELM_IMAGE_CLASS(ELM_WIDGET_DATA(sd)->api)->size_get(obj, &w, &h);
893 evas_object_image_load_size_set(sd->img, w, h);
895 evas_object_image_preload(sd->img, EINA_FALSE);
896 if (evas_object_image_load_error_get(sd->img) != EVAS_LOAD_ERROR_NONE)
898 ERR("Things are going bad for '%s' (%p)", file, sd->img);
902 _elm_image_internal_sizing_eval(sd);
908 _elm_image_smart_file_get(const Evas_Object *obj,
912 ELM_IMAGE_DATA_GET(obj, sd);
915 edje_object_file_get(sd->img, file, key);
917 evas_object_image_file_get(sd->img, file, key);
921 _elm_image_smart_preload_set(Evas_Object *obj,
924 ELM_IMAGE_DATA_GET(obj, sd);
926 if (sd->edje || !sd->preloading) return;
928 evas_object_image_preload(sd->img, disable);
929 sd->preloading = !disable;
933 if (sd->show && sd->img) evas_object_show(sd->img);
936 evas_object_del(sd->prev_img);
943 _elm_image_smart_load_size_set(Evas_Object *obj,
946 ELM_IMAGE_DATA_GET(obj, sd);
948 sd->load_size = size;
949 if (!sd->img || sd->edje) return;
951 evas_object_image_load_size_set(sd->img, sd->load_size, sd->load_size);
955 _elm_image_smart_load_size_get(const Evas_Object *obj)
957 ELM_IMAGE_DATA_GET(obj, sd);
959 return sd->load_size;
963 _elm_image_smart_scale_set(Evas_Object *obj,
966 ELM_IMAGE_DATA_GET(obj, sd);
970 _elm_image_internal_sizing_eval(sd);
974 _elm_image_smart_scale_get(const Evas_Object *obj)
976 ELM_IMAGE_DATA_GET(obj, sd);
982 * Turns on editing through drag and drop and copy and paste.
985 _elm_image_smart_edit_set(Evas_Object *obj,
989 ELM_IMAGE_DATA_GET(obj, sd);
993 printf("No editing edje objects yet (ever)\n");
999 if (edit == sd->edit) return;
1005 (obj, ELM_SEL_FORMAT_IMAGE, _elm_image_drag_n_drop_cb, parent);
1007 elm_drop_target_del(obj);
1011 _elm_image_smart_edit_get(const Evas_Object *obj)
1013 ELM_IMAGE_DATA_GET(obj, sd);
1019 _elm_image_smart_aspect_fixed_set(Evas_Object *obj,
1022 ELM_IMAGE_DATA_GET(obj, sd);
1025 if (sd->aspect_fixed == fixed) return;
1027 sd->aspect_fixed = fixed;
1029 _elm_image_internal_sizing_eval(sd);
1033 _elm_image_smart_aspect_fixed_get(const Evas_Object *obj)
1035 ELM_IMAGE_DATA_GET(obj, sd);
1037 return sd->aspect_fixed;
1041 _elm_image_smart_set_user(Elm_Image_Smart_Class *sc)
1043 ELM_WIDGET_CLASS(sc)->base.add = _elm_image_smart_add;
1044 ELM_WIDGET_CLASS(sc)->base.del = _elm_image_smart_del,
1045 ELM_WIDGET_CLASS(sc)->base.move = _elm_image_smart_move,
1046 ELM_WIDGET_CLASS(sc)->base.resize = _elm_image_smart_resize,
1047 ELM_WIDGET_CLASS(sc)->base.show = _elm_image_smart_show,
1048 ELM_WIDGET_CLASS(sc)->base.hide = _elm_image_smart_hide,
1049 ELM_WIDGET_CLASS(sc)->base.member_add = _elm_image_smart_member_add,
1050 ELM_WIDGET_CLASS(sc)->base.color_set = _elm_image_smart_color_set,
1051 ELM_WIDGET_CLASS(sc)->base.clip_set = _elm_image_smart_clip_set,
1052 ELM_WIDGET_CLASS(sc)->base.clip_unset = _elm_image_smart_clip_unset,
1054 ELM_WIDGET_CLASS(sc)->theme = _elm_image_smart_theme;
1056 sc->aspect_fixed_get = _elm_image_smart_aspect_fixed_get;
1057 sc->aspect_fixed_set = _elm_image_smart_aspect_fixed_set;
1058 sc->edit_get = _elm_image_smart_edit_get;
1059 sc->edit_set = _elm_image_smart_edit_set;
1060 sc->file_get = _elm_image_smart_file_get;
1061 sc->file_set = _elm_image_smart_file_set;
1062 sc->fill_inside_get = _elm_image_smart_fill_inside_get;
1063 sc->fill_inside_set = _elm_image_smart_fill_inside_set;
1064 sc->image_object_get = _elm_image_smart_object_get;
1065 sc->load_size_get = _elm_image_smart_load_size_get;
1066 sc->load_size_set = _elm_image_smart_load_size_set;
1067 sc->memfile_set = _elm_image_smart_memfile_set;
1068 sc->orient_get = _elm_image_smart_orient_get;
1069 sc->orient_set = _elm_image_smart_orient_set;
1070 sc->preload_set = _elm_image_smart_preload_set;
1071 sc->resize_down_get = _elm_image_smart_resize_down_get;
1072 sc->resize_down_set = _elm_image_smart_resize_down_set;
1073 sc->scale_get = _elm_image_smart_scale_get;
1074 sc->scale_set = _elm_image_smart_scale_set;
1075 sc->resize_up_get = _elm_image_smart_resize_up_get;
1076 sc->resize_up_set = _elm_image_smart_resize_up_set;
1077 sc->size_get = _elm_image_smart_size_get;
1078 sc->sizing_eval = _elm_image_smart_sizing_eval;
1079 sc->smooth_scale_get = _elm_image_smart_smooth_scale_get;
1080 sc->smooth_scale_set = _elm_image_smart_smooth_scale_set;
1083 EAPI const Elm_Image_Smart_Class *
1084 elm_image_smart_class_get(void)
1086 static Elm_Image_Smart_Class _sc =
1087 ELM_IMAGE_SMART_CLASS_INIT_NAME_VERSION(ELM_IMAGE_SMART_NAME);
1088 static const Elm_Image_Smart_Class *class = NULL;
1089 Evas_Smart_Class *esc = (Evas_Smart_Class *)&_sc;
1094 _elm_image_smart_set(&_sc);
1095 esc->callbacks = _smart_callbacks;
1102 elm_image_add(Evas_Object *parent)
1106 EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
1108 obj = elm_widget_add(_elm_image_smart_class_new(), parent);
1109 if (!obj) return NULL;
1111 if (!elm_widget_sub_object_add(parent, obj))
1112 ERR("could not add %p as sub object of %p", obj, parent);
1118 elm_image_memfile_set(Evas_Object *obj,
1124 ELM_IMAGE_CHECK(obj) EINA_FALSE;
1125 ELM_IMAGE_DATA_GET(obj, sd);
1127 EINA_SAFETY_ON_NULL_RETURN_VAL(img, EINA_FALSE);
1128 EINA_SAFETY_ON_TRUE_RETURN_VAL(!size, EINA_FALSE);
1130 return ELM_IMAGE_CLASS(ELM_WIDGET_DATA(sd)->api)->memfile_set
1131 (obj, img, size, format, key);
1135 elm_image_file_set(Evas_Object *obj,
1141 ELM_IMAGE_CHECK(obj) EINA_FALSE;
1142 ELM_IMAGE_DATA_GET(obj, sd);
1144 EINA_SAFETY_ON_NULL_RETURN_VAL(file, EINA_FALSE);
1146 ret = ELM_IMAGE_CLASS(ELM_WIDGET_DATA(sd)->api)->file_set(obj, file, group);
1148 ELM_IMAGE_CLASS(ELM_WIDGET_DATA(sd)->api)->sizing_eval(obj);
1154 elm_image_file_get(const Evas_Object *obj,
1158 ELM_IMAGE_CHECK(obj);
1159 ELM_IMAGE_DATA_GET(obj, sd);
1161 ELM_IMAGE_CLASS(ELM_WIDGET_DATA(sd)->api)->file_get(obj, file, group);
1165 elm_image_smooth_set(Evas_Object *obj,
1168 ELM_IMAGE_CHECK(obj);
1169 ELM_IMAGE_DATA_GET(obj, sd);
1171 sd->smooth = smooth;
1173 ELM_IMAGE_CLASS(ELM_WIDGET_DATA(sd)->api)->sizing_eval(obj);
1177 elm_image_smooth_get(const Evas_Object *obj)
1179 ELM_IMAGE_CHECK(obj) EINA_FALSE;
1180 ELM_IMAGE_DATA_GET(obj, sd);
1186 elm_image_object_size_get(const Evas_Object *obj,
1193 ELM_IMAGE_CHECK(obj);
1194 ELM_IMAGE_DATA_GET(obj, sd);
1196 ELM_IMAGE_CLASS(ELM_WIDGET_DATA(sd)->api)->size_get(obj, w, h);
1200 elm_image_no_scale_set(Evas_Object *obj,
1203 ELM_IMAGE_CHECK(obj);
1204 ELM_IMAGE_DATA_GET(obj, sd);
1206 sd->no_scale = no_scale;
1208 ELM_IMAGE_CLASS(ELM_WIDGET_DATA(sd)->api)->sizing_eval(obj);
1212 elm_image_no_scale_get(const Evas_Object *obj)
1214 ELM_IMAGE_CHECK(obj) EINA_FALSE;
1215 ELM_IMAGE_DATA_GET(obj, sd);
1217 return sd->no_scale;
1221 elm_image_resizable_set(Evas_Object *obj,
1225 ELM_IMAGE_CHECK(obj);
1226 ELM_IMAGE_DATA_GET(obj, sd);
1228 sd->resize_up = !!up;
1229 sd->resize_down = !!down;
1231 ELM_IMAGE_CLASS(ELM_WIDGET_DATA(sd)->api)->sizing_eval(obj);
1235 elm_image_resizable_get(const Evas_Object *obj,
1237 Eina_Bool *size_down)
1239 ELM_IMAGE_CHECK(obj);
1240 ELM_IMAGE_DATA_GET(obj, sd);
1242 if (size_up) *size_up = sd->resize_up;
1243 if (size_down) *size_down = sd->resize_down;
1247 elm_image_fill_outside_set(Evas_Object *obj,
1248 Eina_Bool fill_outside)
1250 ELM_IMAGE_CHECK(obj);
1251 ELM_IMAGE_DATA_GET(obj, sd);
1253 sd->fill_inside = !fill_outside;
1255 ELM_IMAGE_CLASS(ELM_WIDGET_DATA(sd)->api)->sizing_eval(obj);
1259 elm_image_fill_outside_get(const Evas_Object *obj)
1261 ELM_IMAGE_CHECK(obj) EINA_FALSE;
1262 ELM_IMAGE_DATA_GET(obj, sd);
1264 return !sd->fill_inside;
1268 elm_image_preload_disabled_set(Evas_Object *obj,
1271 ELM_IMAGE_CHECK(obj);
1272 ELM_IMAGE_DATA_GET(obj, sd);
1274 ELM_IMAGE_CLASS(ELM_WIDGET_DATA(sd)->api)->preload_set(obj, !!disabled);
1278 elm_image_prescale_set(Evas_Object *obj,
1281 ELM_IMAGE_CHECK(obj);
1282 ELM_IMAGE_DATA_GET(obj, sd);
1284 ELM_IMAGE_CLASS(ELM_WIDGET_DATA(sd)->api)->load_size_set(obj, size);
1288 elm_image_prescale_get(const Evas_Object *obj)
1290 ELM_IMAGE_CHECK(obj) 0;
1291 ELM_IMAGE_DATA_GET(obj, sd);
1293 return ELM_IMAGE_CLASS(ELM_WIDGET_DATA(sd)->api)->load_size_get(obj);
1297 elm_image_orient_set(Evas_Object *obj,
1298 Elm_Image_Orient orient)
1300 ELM_IMAGE_CHECK(obj);
1301 ELM_IMAGE_DATA_GET(obj, sd);
1303 ELM_IMAGE_CLASS(ELM_WIDGET_DATA(sd)->api)->orient_set(obj, orient);
1306 EAPI Elm_Image_Orient
1307 elm_image_orient_get(const Evas_Object *obj)
1309 ELM_IMAGE_CHECK(obj) ELM_IMAGE_ORIENT_NONE;
1310 ELM_IMAGE_DATA_GET(obj, sd);
1312 return ELM_IMAGE_CLASS(ELM_WIDGET_DATA(sd)->api)->orient_get(obj);
1316 elm_image_editable_set(Evas_Object *obj,
1319 ELM_IMAGE_CHECK(obj);
1320 ELM_IMAGE_DATA_GET(obj, sd);
1322 ELM_IMAGE_CLASS(ELM_WIDGET_DATA(sd)->api)->edit_set(obj, set, obj);
1326 elm_image_editable_get(const Evas_Object *obj)
1328 ELM_IMAGE_CHECK(obj) EINA_FALSE;
1329 ELM_IMAGE_DATA_GET(obj, sd);
1331 return ELM_IMAGE_CLASS(ELM_WIDGET_DATA(sd)->api)->edit_get(obj);
1335 elm_image_object_get(const Evas_Object *obj)
1337 ELM_IMAGE_CHECK(obj) NULL;
1338 ELM_IMAGE_DATA_GET(obj, sd);
1340 return ELM_IMAGE_CLASS(ELM_WIDGET_DATA(sd)->api)->image_object_get(obj);
1344 elm_image_aspect_fixed_set(Evas_Object *obj,
1347 ELM_IMAGE_CHECK(obj);
1348 ELM_IMAGE_DATA_GET(obj, sd);
1350 ELM_IMAGE_CLASS(ELM_WIDGET_DATA(sd)->api)->aspect_fixed_set(obj, fixed);
1354 elm_image_aspect_fixed_get(const Evas_Object *obj)
1356 ELM_IMAGE_CHECK(obj) EINA_FALSE;
1357 ELM_IMAGE_DATA_GET(obj, sd);
1359 return ELM_IMAGE_CLASS(ELM_WIDGET_DATA(sd)->api)->aspect_fixed_get(obj);
1363 elm_image_animated_available_get(const Evas_Object *obj)
1365 ELM_IMAGE_CHECK(obj) EINA_FALSE;
1366 ELM_IMAGE_DATA_GET(obj, sd);
1368 if (sd->edje) return EINA_FALSE;
1370 return evas_object_image_animated_get(elm_image_object_get(obj));
1374 elm_image_animated_set(Evas_Object *obj,
1377 ELM_IMAGE_CHECK(obj);
1378 ELM_IMAGE_DATA_GET(obj, sd);
1381 if (sd->anim == anim) return;
1383 if (sd->edje) return;
1385 sd->img = elm_image_object_get(obj);
1386 if (!evas_object_image_animated_get(sd->img)) return;
1390 sd->frame_count = evas_object_image_animated_frame_count_get(sd->img);
1392 sd->frame_duration =
1393 evas_object_image_animated_frame_duration_get
1394 (sd->img, sd->cur_frame, 0);
1395 evas_object_image_animated_frame_set(sd->img, sd->cur_frame);
1399 sd->frame_count = -1;
1401 sd->frame_duration = -1;
1409 elm_image_animated_get(const Evas_Object *obj)
1411 ELM_IMAGE_CHECK(obj) EINA_FALSE;
1412 ELM_IMAGE_DATA_GET(obj, sd);
1418 elm_image_animated_play_set(Evas_Object *obj,
1421 ELM_IMAGE_CHECK(obj);
1422 ELM_IMAGE_DATA_GET(obj, sd);
1424 if (!sd->anim) return;
1425 if (sd->play == play) return;
1427 if (sd->edje) return;
1431 sd->anim_timer = ecore_timer_add
1432 (sd->frame_duration, _elm_image_animate_cb, sd);
1438 ecore_timer_del(sd->anim_timer);
1439 sd->anim_timer = NULL;
1446 elm_image_animated_play_get(const Evas_Object *obj)
1448 ELM_IMAGE_CHECK(obj) EINA_FALSE;
1449 ELM_IMAGE_DATA_GET(obj, sd);