forked from enlightenment/efl
elementary/els_icon - added els_icon_aspect_ratio_retained_set/get since elm_image needs to provide those functionlaities.
SVN revision: 60718
This commit is contained in:
parent
321c4c8daf
commit
16e237198b
|
@ -16,6 +16,7 @@ struct _Smart_Data
|
|||
Eina_Bool show : 1;
|
||||
Eina_Bool edit : 1;
|
||||
Eina_Bool edje : 1;
|
||||
Eina_Bool aspect_ratio_retained: 1;
|
||||
Elm_Image_Orient orient;
|
||||
};
|
||||
|
||||
|
@ -418,6 +419,30 @@ _els_smart_icon_edje_get(Evas_Object *obj)
|
|||
return sd->obj;
|
||||
}
|
||||
|
||||
void
|
||||
_els_smart_icon_aspect_ratio_retained_set(Evas_Object *obj, Eina_Bool retained)
|
||||
{
|
||||
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;
|
||||
_smart_reconfigure(sd);
|
||||
}
|
||||
|
||||
Eina_Bool
|
||||
_els_smart_icon_aspect_ratio_retained_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;
|
||||
}
|
||||
|
||||
/* local subsystem globals */
|
||||
static void
|
||||
_smart_reconfigure(Smart_Data *sd)
|
||||
|
@ -425,10 +450,12 @@ _smart_reconfigure(Smart_Data *sd)
|
|||
Evas_Coord x, y, w, h;
|
||||
|
||||
if (!sd->obj) return;
|
||||
if (!strcmp(evas_object_type_get(sd->obj), "edje"))
|
||||
{
|
||||
|
||||
w = sd->w;
|
||||
h = sd->h;
|
||||
|
||||
if (!strcmp(evas_object_type_get(sd->obj), "edje"))
|
||||
{
|
||||
x = sd->x;
|
||||
y = sd->y;
|
||||
evas_object_move(sd->obj, x, y);
|
||||
|
@ -446,9 +473,9 @@ _smart_reconfigure(Smart_Data *sd)
|
|||
if (iw < 1) iw = 1;
|
||||
if (ih < 1) ih = 1;
|
||||
|
||||
w = sd->w;
|
||||
if (sd->aspect_ratio_retained)
|
||||
{
|
||||
h = ((double)ih * w) / (double)iw;
|
||||
|
||||
if (sd->fill_inside)
|
||||
{
|
||||
if (h > sd->h)
|
||||
|
@ -465,21 +492,16 @@ _smart_reconfigure(Smart_Data *sd)
|
|||
w = ((double)iw * h) / (double)ih;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!sd->scale_up)
|
||||
{
|
||||
if ((w > iw) || (h > ih))
|
||||
{
|
||||
w = iw;
|
||||
h = ih;
|
||||
}
|
||||
if (w > iw) w = iw;
|
||||
if (h > ih) h = ih;
|
||||
}
|
||||
if (!sd->scale_down)
|
||||
{
|
||||
if ((w < iw) || (h < ih))
|
||||
{
|
||||
w = iw;
|
||||
h = ih;
|
||||
}
|
||||
if (w < iw) w = iw;
|
||||
if (h < ih) h = ih;
|
||||
}
|
||||
x = sd->x + ((sd->w - w) / 2);
|
||||
y = sd->y + ((sd->h - h) / 2);
|
||||
|
@ -535,6 +557,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->size = 64;
|
||||
sd->scale = 1.0;
|
||||
evas_object_smart_member_add(sd->obj, obj);
|
||||
|
|
|
@ -21,3 +21,6 @@ Elm_Image_Orient _els_smart_icon_orient_get (const Evas_Object *obj);
|
|||
void _els_smart_icon_edit_set (Evas_Object *obj, Eina_Bool, Evas_Object *parent);
|
||||
Eina_Bool _els_smart_icon_edit_get (const Evas_Object *obj);
|
||||
Evas_Object *_els_smart_icon_edje_get(Evas_Object *obj);
|
||||
void _els_smart_icon_aspect_ratio_retained_set(Evas_Object *obj, Eina_Bool retained);
|
||||
Eina_Bool _els_smart_icon_aspect_ratio_retained_get(const Evas_Object *obj);
|
||||
|
||||
|
|
Loading…
Reference in New Issue