summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@osg.samsung.com>2017-09-12 13:21:09 -0400
committerMike Blumenkrantz <zmike@osg.samsung.com>2017-09-12 13:21:04 -0400
commit721eeb994e8d33dd285c1c3f4cd11e71a71e01c5 (patch)
tree3d27576a87924a2f376634811fb90d9c3d17ec93
parent24591631eedc84551233a6722076fc98abca2878 (diff)
downloadenlightenment-721eeb994e8d33dd285c1c3f4cd11e71a71e01c5.tar.gz
make spacer gadgets smarter when multiple spacers exist
* ignore consecutive spacers * attempt to size/fill consistently based on occupied space fix T5973
-rw-r--r--src/bin/e_gadget.c91
1 files changed, 85 insertions, 6 deletions
diff --git a/src/bin/e_gadget.c b/src/bin/e_gadget.c
index d6204ed75a..2fdaf5a965 100644
--- a/src/bin/e_gadget.c
+++ b/src/bin/e_gadget.c
@@ -675,15 +675,18 @@ _site_layout_orient(Evas_Object *o, E_Gadget_Site *zgs)
Eina_List *l;
double ax, ay;
E_Gadget_Config *zgc;
- int mw, mh, sw, sh, rw, rh, bw, bh;
- int expand_count;
+ int mw, mh, sw, sh, rw, rh, bw, bh, prev_w = 0, prev_h = 0;
+ int groups = 0, avg;
+ Eina_Bool prev_ex = 0, after = 0;
struct Size
{
Evas_Coord_Size size;
Evas_Coord_Size clipped;
+ Evas_Coord_Size before;
+ Evas_Coord_Size after;
Eina_Bool expand;
Evas_Object *obj;
- } *size;
+ } *size, *psize = NULL;
Eina_List *expand = NULL, *gadgets = NULL;
evas_object_geometry_get(o, &x, &y, &w, &h);
@@ -706,13 +709,34 @@ _site_layout_orient(Evas_Object *o, E_Gadget_Site *zgs)
if (!zgc->display) continue;
ex = _site_gadget_resize(zgc->gadget, w, h, &ww, &hh, &ow, &oh);
+ if (ex && prev_ex)
+ {
+ /* multiple spacers */
+ evas_object_resize(zgc->display, 0, 0);
+ continue;
+ }
size = E_NEW(struct Size, 1);
size->size.w = ww;
size->size.h = hh;
size->clipped.w = ow;
size->clipped.h = oh;
size->expand = ex;
+ if (ex)
+ {
+ if (psize)
+ {
+ psize->after.w = prev_w, psize->after.h = prev_h;
+ groups++;
+ }
+ psize = size;
+ size->before.w = prev_w;
+ size->before.h = prev_h;
+ prev_w = prev_h = 0;
+ }
size->obj = zgc->display;
+ prev_w += ow;
+ prev_h += oh;
+ prev_ex = ex;
gadgets = eina_list_append(gadgets, size);
if (ex)
{
@@ -724,21 +748,76 @@ _site_layout_orient(Evas_Object *o, E_Gadget_Site *zgs)
else if (IS_VERT(zgs->orient))
rh = MAX(rh - oh, 0);
}
+ if (expand)
+ {
+ size = eina_list_last_data_get(expand);
+ psize = eina_list_last_data_get(gadgets);
+ if (size != psize)
+ {
+ if ((!size->after.w) && (!size->after.h))
+ {
+ size->after.w = prev_w, size->after.h = prev_h;
+ groups++;
+ }
+ }
- expand_count = eina_list_count(expand);
+ size = eina_list_data_get(expand);
+ if (IS_HORIZ(zgs->orient))
+ {
+ after = !size->before.w;
+ avg = (bw - rw) / groups;
+ }
+ else
+ {
+ after = !size->before.h;
+ avg = (bh - rh) / groups;
+ }
+ }
EINA_LIST_FREE(expand, size)
{
if (IS_HORIZ(zgs->orient))
{
if (rw)
- size->size.w = size->clipped.w = rw / expand_count;
+ {
+ size->size.w = size->clipped.w = rw / eina_list_count(expand);
+ if (eina_list_count(expand) > 1)
+ {
+ int gw;
+ if (after)
+ gw = size->after.w;
+ else
+ gw = size->before.w;
+ if (gw > avg)
+ size->size.w = size->clipped.w -= (gw - avg);
+ else
+ size->size.w = size->clipped.w += abs(gw - avg);
+ size->size.w = size->clipped.w -= size->after.w / 2;
+ rw -= size->size.w;
+ }
+ }
else
size->size.w = size->clipped.w = 0;
}
else if (IS_VERT(zgs->orient))
{
if (rh)
- size->size.h = size->clipped.h = rh / expand_count;
+ {
+ size->size.h = size->clipped.h = rh / eina_list_count(expand);
+ if (eina_list_count(expand) > 1)
+ {
+ int gh;
+ if (after)
+ gh = size->after.h;
+ else
+ gh = size->before.h;
+ if (gh > avg)
+ size->size.h = size->clipped.h -= (gh - avg);
+ else
+ size->size.h = size->clipped.h += abs(gh - avg);
+ size->size.h = size->clipped.h -= size->after.h / 2;
+ rh -= size->size.h;
+ }
+ }
else
size->size.h = size->clipped.h = 0;
}