summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2019-05-30 17:42:58 -0700
committerCedric BAIL <cedric.bail@free.fr>2019-07-12 09:54:06 -0700
commitb2cb77ca9cbcef71db8d583f52f1959b7eba0bd7 (patch)
tree5371239d55966b6c2c74aae7665c7a23cc4abba7
parent9fbc5dfc66af70f42c31e6c68a7a15b70f0fbbce (diff)
evas: take stretch region into account when content region is requested.
Reviewed-by: Hermet Park <hermetpark@gmail.com> Differential Revision: https://phab.enlightenment.org/D9097
-rw-r--r--src/lib/efl/interfaces/efl_gfx_image.eo8
-rw-r--r--src/lib/evas/canvas/evas_object_image.c47
2 files changed, 48 insertions, 7 deletions
diff --git a/src/lib/efl/interfaces/efl_gfx_image.eo b/src/lib/efl/interfaces/efl_gfx_image.eo
index f5ef474471..64bd6b873d 100644
--- a/src/lib/efl/interfaces/efl_gfx_image.eo
+++ b/src/lib/efl/interfaces/efl_gfx_image.eo
@@ -90,9 +90,11 @@ interface @beta Efl.Gfx.Image
90 @property content_region { 90 @property content_region {
91 [[Return the relative area enclosed inside the image where content is expected. 91 [[Return the relative area enclosed inside the image where content is expected.
92 92
93 We do expect content to be inside the limit defined by the border. If no border 93 We do expect content to be inside the limit defined by the border or inside the
94 is set, they are assumed to be zero and the full object geometry is where content 94 stretch region. If a stretch region is provided, the content region will encompass the
95 can be layout on top. The area size change with the object size. 95 non strechable area that are surrounded by stretchable area. If no border and no
96 stretch region is set, they are assumed to be zero and the full object geometry is
97 where content can be layout on top. The area size change with the object size.
96 98
97 The geometry of the area is expressed relative to the geometry of the object. 99 The geometry of the area is expressed relative to the geometry of the object.
98 ]] 100 ]]
diff --git a/src/lib/evas/canvas/evas_object_image.c b/src/lib/evas/canvas/evas_object_image.c
index 1961f59b97..ac4665e7b2 100644
--- a/src/lib/evas/canvas/evas_object_image.c
+++ b/src/lib/evas/canvas/evas_object_image.c
@@ -14,6 +14,9 @@ static Evas_Coord evas_object_image_figure_x_fill(Evas_Object *eo_obj, Evas_Ob
14static Evas_Coord evas_object_image_figure_y_fill(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, Evas_Coord start, Evas_Coord size, Evas_Coord *size_ret); 14static Evas_Coord evas_object_image_figure_y_fill(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, Evas_Coord start, Evas_Coord size, Evas_Coord *size_ret);
15 15
16static void evas_object_image_init(Evas_Object *eo_obj); 16static void evas_object_image_init(Evas_Object *eo_obj);
17
18static inline uint32_t _stretch_region_accumulate(uint8_t *stretch_region, Eina_Bool mask, uint32_t *i);
19
17static void evas_object_image_render(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, 20static void evas_object_image_render(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj,
18 void *type_private_data, 21 void *type_private_data,
19 void *engine, void *output, void *context, void *surface, 22 void *engine, void *output, void *context, void *surface,
@@ -468,10 +471,46 @@ _efl_canvas_image_internal_efl_gfx_image_content_region_get(const Eo *eo_obj, Ev
468 Evas_Object_Protected_Data *obj = efl_data_scope_get(eo_obj, EFL_CANVAS_OBJECT_CLASS); 471 Evas_Object_Protected_Data *obj = efl_data_scope_get(eo_obj, EFL_CANVAS_OBJECT_CLASS);
469 Eina_Rect r; 472 Eina_Rect r;
470 473
471 r.x = o->cur->border.l; 474 if (o->cur->stretch.horizontal.region &&
472 r.y = o->cur->border.t; 475 o->cur->stretch.vertical.region)
473 r.w = obj->cur->geometry.w - o->cur->border.l - o->cur->border.r; 476 {
474 r.h = obj->cur->geometry.h - o->cur->border.t - o->cur->border.b; 477 uint32_t acc;
478 uint32_t hi = 0;
479 uint32_t vi = 0;
480
481 r.x = _stretch_region_accumulate(o->cur->stretch.horizontal.region, 0, &hi);
482 r.w = o->cur->stretch.horizontal.stretchable + obj->cur->geometry.w - o->cur->image.w;
483
484 // Accumulate all the non stretch zone, except the first one and the last one
485 acc = 0;
486 while (o->cur->stretch.horizontal.region[hi])
487 {
488 // We are just ignoring all the stretchable zone as we know them already
489 _stretch_region_accumulate(o->cur->stretch.horizontal.region, 0x80, &hi);
490 r.w += acc;
491 acc = _stretch_region_accumulate(o->cur->stretch.horizontal.region, 0, &hi);
492 }
493
494 r.y = _stretch_region_accumulate(o->cur->stretch.vertical.region, 0, &vi);
495 r.h = o->cur->stretch.vertical.stretchable + obj->cur->geometry.h - o->cur->image.h;
496
497 // Accumulate all the stretch zone, except the last non stretching one
498 acc = 0;
499 while (o->cur->stretch.vertical.region[vi])
500 {
501 // We are just ignoring all the stretchable zone as we know them already
502 _stretch_region_accumulate(o->cur->stretch.vertical.region, 0x80, &vi);
503 r.h += acc;
504 acc = _stretch_region_accumulate(o->cur->stretch.vertical.region, 0, &vi);
505 }
506 }
507 else
508 {
509 r.x = o->cur->border.l;
510 r.y = o->cur->border.t;
511 r.w = obj->cur->geometry.w - o->cur->border.l - o->cur->border.r;
512 r.h = obj->cur->geometry.h - o->cur->border.t - o->cur->border.b;
513 }
475 514
476 return r; 515 return r;
477} 516}