summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2019-05-30 11:22:42 -0700
committerCedric BAIL <cedric.bail@free.fr>2019-07-12 09:53:59 -0700
commit23a2820121920ecfbfa0ad7a4f04cbcc51e87477 (patch)
tree11d8d1ab880c98056b09fc3fde86ed14fa829ae4
parent2854702f8ec4c7899473f737c31420de429e9359 (diff)
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
-rw-r--r--src/lib/efl/interfaces/efl_gfx_image.eo14
-rw-r--r--src/lib/evas/canvas/efl_canvas_image_internal.eo1
-rw-r--r--src/lib/evas/canvas/evas_object_image.c14
3 files changed, 29 insertions, 0 deletions
diff --git a/src/lib/efl/interfaces/efl_gfx_image.eo b/src/lib/efl/interfaces/efl_gfx_image.eo
index 1ef54efe8c..e1853feb99 100644
--- a/src/lib/efl/interfaces/efl_gfx_image.eo
+++ b/src/lib/efl/interfaces/efl_gfx_image.eo
@@ -76,6 +76,20 @@ interface @beta Efl.Gfx.Image
76 ratio: double; [[The image's ratio.]] 76 ratio: double; [[The image's ratio.]]
77 } 77 }
78 } 78 }
79 @property content_region {
80 [[Return the relative area enclosed inside the image where content is expected.
81
82 We do expect content to be inside the limit defined by the border. If no border
83 is set, they are assumed to be zero and the full object geometry is where content
84 can be layout on top. The area size change with the object size.
85
86 The geometry of the area is expressed relative to the geometry of the object.
87 ]]
88 get { }
89 values {
90 region: Eina.Rect; [[A rectangle inside the object boundary that where content is expected.]]
91 }
92 }
79 @property border { 93 @property border {
80 [[Dimensions of this image's border, a region that does not scale 94 [[Dimensions of this image's border, a region that does not scale
81 with the center area. 95 with the center area.
diff --git a/src/lib/evas/canvas/efl_canvas_image_internal.eo b/src/lib/evas/canvas/efl_canvas_image_internal.eo
index 0e42c1c0f9..ae210621c2 100644
--- a/src/lib/evas/canvas/efl_canvas_image_internal.eo
+++ b/src/lib/evas/canvas/efl_canvas_image_internal.eo
@@ -14,6 +14,7 @@ abstract @beta Efl.Canvas.Image_Internal extends Efl.Canvas.Object implements Ef
14 Efl.Gfx.Image_Orientable.image_orientation { get; set; } 14 Efl.Gfx.Image_Orientable.image_orientation { get; set; }
15 Efl.Gfx.Image.smooth_scale { get; set; } 15 Efl.Gfx.Image.smooth_scale { get; set; }
16 Efl.Gfx.Image.ratio { get; } 16 Efl.Gfx.Image.ratio { get; }
17 Efl.Gfx.Image.content_region { get; }
17 Efl.Gfx.Image.border { get; set; } 18 Efl.Gfx.Image.border { get; set; }
18 Efl.Gfx.Image.border_scale { get; set; } 19 Efl.Gfx.Image.border_scale { get; set; }
19 Efl.Gfx.Image.border_center_fill { get; set; } 20 Efl.Gfx.Image.border_center_fill { get; set; }
diff --git a/src/lib/evas/canvas/evas_object_image.c b/src/lib/evas/canvas/evas_object_image.c
index f0795fcbc1..998eec0484 100644
--- a/src/lib/evas/canvas/evas_object_image.c
+++ b/src/lib/evas/canvas/evas_object_image.c
@@ -461,6 +461,20 @@ _efl_canvas_image_internal_efl_object_dbg_info_get(Eo *eo_obj, Evas_Image_Data *
461 (uint64_t)(uintptr_t)evas_object_image_source_get(eo_obj)); 461 (uint64_t)(uintptr_t)evas_object_image_source_get(eo_obj));
462} 462}
463 463
464static Eina_Rect
465_efl_canvas_image_internal_efl_gfx_image_content_region_get(const Eo *eo_obj, Evas_Image_Data *o)
466{
467 Evas_Object_Protected_Data *obj = efl_data_scope_get(eo_obj, EFL_CANVAS_OBJECT_CLASS);
468 Eina_Rect r;
469
470 r.x = o->cur->border.l;
471 r.y = o->cur->border.t;
472 r.w = obj->cur->geometry.w - o->cur->border.l - o->cur->border.r;
473 r.h = obj->cur->geometry.h - o->cur->border.t - o->cur->border.b;
474
475 return r;
476}
477
464EOLIAN static void 478EOLIAN static void
465_efl_canvas_image_internal_efl_gfx_image_border_set(Eo *eo_obj, Evas_Image_Data *o, int l, int r, int t, int b) 479_efl_canvas_image_internal_efl_gfx_image_border_set(Eo *eo_obj, Evas_Image_Data *o, int l, int r, int t, int b)
466{ 480{