EAPI Elm_Image_Orient elm_image_orient_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
EAPI void elm_image_editable_set(Evas_Object *obj, Eina_Bool set) EINA_ARG_NONNULL(1);
EAPI Eina_Bool elm_image_editable_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
+ EAPI void elm_image_aspect_ratio_retained_set(Evas_Object *obj, Eina_Bool retained) EINA_ARG_NONNULL(1);
+ EAPI Eina_Bool elm_image_aspect_ratio_retained_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
+
/* smart callbacks called:
* "clicked" - the user clicked the image
*/
}
-/* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/
+/**
+ * Enable/disable retaining up the aspect ratio of the image.
+ *
+ * @param obj The image object.
+ * @param retained Retaining or Non retaining.
+ *
+ * @ingroup Image
+ */
+EAPI void
+elm_image_aspect_ratio_retained_set(Evas_Object *obj, Eina_Bool retained)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype);
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return;
+ return _els_smart_icon_aspect_ratio_retained_set(wd->img, retained);
+}
+
+/**
+ * Get if the object retains the aspect ratio.
+ *
+ * @param obj The image object.
+ * @return If the object retains the aspect ratio.
+ *
+ * @ingroup Image
+ */
+EAPI Eina_Bool
+elm_image_aspect_ratio_retained_get(const Evas_Object *obj)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return EINA_FALSE;
+ return _els_smart_icon_aspect_ratio_retained_get(wd->img);
+}
+
+/* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-3f0^-2{2(0W1st0 :*/
Eina_Bool show : 1;
Eina_Bool edit : 1;
Eina_Bool edje : 1;
+ Eina_Bool aspect_ratio_retained: 1;
Elm_Image_Orient orient;
};
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)
Evas_Coord x, y, w, h;
if (!sd->obj) return;
+
+ w = sd->w;
+ h = sd->h;
+
if (!strcmp(evas_object_type_get(sd->obj), "edje"))
{
- w = sd->w;
- h = sd->h;
x = sd->x;
y = sd->y;
evas_object_move(sd->obj, x, y);
if (iw < 1) iw = 1;
if (ih < 1) ih = 1;
- if (sd->fill_inside)
+ if (sd->aspect_ratio_retained)
{
- w = sd->w;
h = ((double)ih * w) / (double)iw;
- if (h > sd->h)
+ if (sd->fill_inside)
{
- h = sd->h;
- w = ((double)iw * h) / (double)ih;
+ if (h > sd->h)
+ {
+ h = sd->h;
+ w = ((double)iw * h) / (double)ih;
+ }
}
- }
- else
- {
- w = sd->w;
- h = ((double)ih * w) / (double)iw;
- if (h < sd->h)
+ else
{
- h = sd->h;
- w = ((double)iw * h) / (double)ih;
+ if (h < sd->h)
+ {
+ h = sd->h;
+ 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);
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);
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);
+