X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Flib%2Fels_icon.c;h=f32ab4dd39e08fd7806c089310fa2a84cbd0ed59;hb=946051a5db20eca4d492bb1de4fb032a21772138;hp=e4893ab66aec422e88f833ceace4523e5c1d4b0a;hpb=508d93869c7601d0258094b50ade511451e7a2b3;p=framework%2Fuifw%2Felementary.git diff --git a/src/lib/els_icon.c b/src/lib/els_icon.c old mode 100755 new mode 100644 index e4893ab..f32ab4d --- a/src/lib/els_icon.c +++ b/src/lib/els_icon.c @@ -24,7 +24,7 @@ struct _Smart_Data Eina_Bool show : 1; Eina_Bool edit : 1; Eina_Bool edje : 1; - Eina_Bool aspect_ratio_retained: 1; + Eina_Bool aspect_fixed: 1; Elm_Image_Orient orient; }; @@ -88,6 +88,7 @@ _els_smart_icon_file_helper(Evas_Object *obj) pclip = evas_object_clip_get(sd->obj); if (sd->obj) sd->prev = sd->obj; sd->obj = evas_object_image_add(evas_object_evas_get(obj)); + evas_object_image_load_orientation_set(sd->obj, EINA_TRUE); evas_object_event_callback_add(sd->obj, EVAS_CALLBACK_IMAGE_PRELOADED, _preloaded, sd); evas_object_smart_member_add(sd->obj, obj); @@ -362,10 +363,8 @@ void _els_smart_icon_orient_set(Evas_Object *obj, Elm_Image_Orient orient) { Smart_Data *sd; - Evas_Object *tmp; - unsigned int *data, *data2, *to, *from; + unsigned int *data, *data2 = NULL, *to, *from; int x, y, w, hw, iw, ih; - const char *file, *key; sd = evas_object_smart_data_get(obj); if (!sd) return; @@ -388,10 +387,9 @@ _els_smart_icon_orient_set(Evas_Object *obj, Elm_Image_Orient orient) } evas_object_image_size_get(sd->obj, &iw, &ih); - evas_object_image_file_get(sd->obj, &file, &key); - tmp = evas_object_image_add(evas_object_evas_get(sd->obj)); - evas_object_image_file_set(tmp, file, key); - data2 = evas_object_image_data_get(tmp, EINA_FALSE); + /* we need separate destination memory if we want to rotate 90 or 270 degree */ + evas_object_image_data_copy_set(sd->obj, data2); + if (!data2) return; w = ih; ih = iw; @@ -400,6 +398,7 @@ _els_smart_icon_orient_set(Evas_Object *obj, Elm_Image_Orient orient) evas_object_image_size_set(sd->obj, iw, ih); data = evas_object_image_data_get(sd->obj, EINA_TRUE); + switch (orient) { case ELM_IMAGE_FLIP_TRANSPOSE: @@ -422,8 +421,8 @@ _els_smart_icon_orient_set(Evas_Object *obj, Elm_Image_Orient orient) break; default: ERR("unknown orient %d", orient); - evas_object_del(tmp); evas_object_image_data_set(sd->obj, data); // give it back + if (data2) free(data2); return; } from = data2; @@ -438,7 +437,7 @@ _els_smart_icon_orient_set(Evas_Object *obj, Elm_Image_Orient orient) to += hw; } sd->orient = orient; - evas_object_del(tmp); + if (data2) free(data2); evas_object_image_data_set(sd->obj, data); evas_object_image_data_update_add(sd->obj, 0, 0, iw, ih); _smart_reconfigure(sd); @@ -497,27 +496,27 @@ _els_smart_icon_edje_get(Evas_Object *obj) } void -_els_smart_icon_aspect_ratio_retained_set(Evas_Object *obj, Eina_Bool retained) +_els_smart_icon_aspect_fixed_set(Evas_Object *obj, Eina_Bool fixed) { Smart_Data *sd; sd = evas_object_smart_data_get(obj); if (!sd) return; - retained = !!retained; - if (sd->aspect_ratio_retained == retained) return; - sd->aspect_ratio_retained = retained; + fixed = !!fixed; + if (sd->aspect_fixed == fixed) return; + sd->aspect_fixed = fixed; _smart_reconfigure(sd); } Eina_Bool -_els_smart_icon_aspect_ratio_retained_get(const Evas_Object *obj) +_els_smart_icon_aspect_fixed_get(const Evas_Object *obj) { Smart_Data *sd; sd = evas_object_smart_data_get(obj); if (!sd) return EINA_FALSE; - return sd->aspect_ratio_retained; + return sd->aspect_fixed; } /* local subsystem globals */ @@ -544,6 +543,8 @@ _smart_reconfigure(Smart_Data *sd) else { int iw = 0, ih = 0; + double alignh = 0.5, alignv = 0.5; + Evas_Object *parent; evas_object_image_size_get(sd->obj, &iw, &ih); @@ -553,7 +554,7 @@ _smart_reconfigure(Smart_Data *sd) if (iw < 1) iw = 1; if (ih < 1) ih = 1; - if (sd->aspect_ratio_retained) + if (sd->aspect_fixed) { h = ((double)ih * w) / (double)iw; if (sd->fill_inside) @@ -583,8 +584,13 @@ _smart_reconfigure(Smart_Data *sd) if (w < iw) w = iw; if (h < ih) h = ih; } - x = sd->x + ((sd->w - w) / 2); - y = sd->y + ((sd->h - h) / 2); + parent = elm_widget_parent_widget_get(sd->obj); + if (parent) + evas_object_size_hint_align_get(parent, &alignh, &alignv); + if (alignh == EVAS_HINT_FILL) alignh = 0.5; + if (alignv == EVAS_HINT_FILL) alignv = 0.5; + x = sd->x + ((sd->w - w) * alignh); + y = sd->y + ((sd->h - h) * alignv); evas_object_move(sd->obj, x, y); evas_object_image_fill_set(sd->obj, 0, 0, w, h); evas_object_resize(sd->obj, w, h); @@ -638,7 +644,7 @@ _smart_add(Evas_Object *obj) sd->fill_inside = EINA_TRUE; sd->scale_up = EINA_TRUE; sd->scale_down = EINA_TRUE; - sd->aspect_ratio_retained = EINA_TRUE; + sd->aspect_fixed = EINA_TRUE; sd->size = 64; sd->scale = 1.0; evas_object_smart_member_add(sd->obj, obj);