evas: add an API to know where inside an object content can be layout over.

The first step with this API is to use the information provided when setting
the border on an image to define the content area inside it. Improvement will
be to use more flexible stretch region area to make it more customizable and
finally read the information from a 9patch file (.9.png).

Reviewed-by: Hermet Park <hermetpark@gmail.com>
Differential Revision: https://phab.enlightenment.org/D9093
This commit is contained in:
Cedric BAIL 2019-05-30 11:22:42 -07:00
parent 2854702f8e
commit 23a2820121
3 changed files with 29 additions and 0 deletions

View File

@ -76,6 +76,20 @@ interface @beta Efl.Gfx.Image
ratio: double; [[The image's ratio.]]
}
}
@property content_region {
[[Return the relative area enclosed inside the image where content is expected.
We do expect content to be inside the limit defined by the border. If no border
is set, they are assumed to be zero and the full object geometry is where content
can be layout on top. The area size change with the object size.
The geometry of the area is expressed relative to the geometry of the object.
]]
get { }
values {
region: Eina.Rect; [[A rectangle inside the object boundary that where content is expected.]]
}
}
@property border {
[[Dimensions of this image's border, a region that does not scale
with the center area.

View File

@ -14,6 +14,7 @@ abstract @beta Efl.Canvas.Image_Internal extends Efl.Canvas.Object implements Ef
Efl.Gfx.Image_Orientable.image_orientation { get; set; }
Efl.Gfx.Image.smooth_scale { get; set; }
Efl.Gfx.Image.ratio { get; }
Efl.Gfx.Image.content_region { get; }
Efl.Gfx.Image.border { get; set; }
Efl.Gfx.Image.border_scale { get; set; }
Efl.Gfx.Image.border_center_fill { get; set; }

View File

@ -461,6 +461,20 @@ _efl_canvas_image_internal_efl_object_dbg_info_get(Eo *eo_obj, Evas_Image_Data *
(uint64_t)(uintptr_t)evas_object_image_source_get(eo_obj));
}
static Eina_Rect
_efl_canvas_image_internal_efl_gfx_image_content_region_get(const Eo *eo_obj, Evas_Image_Data *o)
{
Evas_Object_Protected_Data *obj = efl_data_scope_get(eo_obj, EFL_CANVAS_OBJECT_CLASS);
Eina_Rect r;
r.x = o->cur->border.l;
r.y = o->cur->border.t;
r.w = obj->cur->geometry.w - o->cur->border.l - o->cur->border.r;
r.h = obj->cur->geometry.h - o->cur->border.t - o->cur->border.b;
return r;
}
EOLIAN static void
_efl_canvas_image_internal_efl_gfx_image_border_set(Eo *eo_obj, Evas_Image_Data *o, int l, int r, int t, int b)
{