aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/elementary
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2016-04-15 17:06:14 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2016-04-20 10:47:40 +0900
commitf2eff88640e9416f82e38472baf5c3bff2d29178 (patch)
tree49f68bb382490cc696f01d2fafbb90446c296c7f /src/lib/elementary
parentEfl.Ui.Grid: Fix new API behaviour (diff)
downloadefl-f2eff88640e9416f82e38472baf5c3bff2d29178.tar.gz
Efl.Ui.Box: Add pack_align property
While at first I wanted to remove the box_align / table_align properties, it ends up being a necessary value in some cases.
Diffstat (limited to 'src/lib/elementary')
-rw-r--r--src/lib/elementary/efl_ui_box.c22
-rw-r--r--src/lib/elementary/efl_ui_box.eo2
-rw-r--r--src/lib/elementary/efl_ui_box_layout.c50
-rw-r--r--src/lib/elementary/efl_ui_box_private.h4
4 files changed, 57 insertions, 21 deletions
diff --git a/src/lib/elementary/efl_ui_box.c b/src/lib/elementary/efl_ui_box.c
index d4bedf6e6f..4e1b7bc3da 100644
--- a/src/lib/elementary/efl_ui_box.c
+++ b/src/lib/elementary/efl_ui_box.c
@@ -273,6 +273,8 @@ _efl_ui_box_eo_base_constructor(Eo *obj, Efl_Ui_Box_Data *pd)
pd->orient = EFL_ORIENT_RIGHT;
pd->layout_engine = MY_CLASS;
+ pd->align.h = 0.5;
+ pd->align.v = 0.5;
return obj;
}
@@ -556,4 +558,24 @@ _efl_ui_box_efl_pack_padding_get(Eo *obj, Efl_Ui_Box_Data *pd, double *h, double
if (v) *v = pd->pad.v;
}
+EOLIAN static void
+_efl_ui_box_efl_pack_pack_align_set(Eo *obj, Efl_Ui_Box_Data *pd, double h, double v)
+{
+ if (h < 0) h = -1;
+ if (v < 0) v = -1;
+ if (h > 1) h = 1;
+ if (v > 1) v = 1;
+ pd->align.h = h;
+ pd->align.v = v;
+
+ efl_pack_layout_request(obj);
+}
+
+EOLIAN static void
+_efl_ui_box_efl_pack_pack_align_get(Eo *obj EINA_UNUSED, Efl_Ui_Box_Data *pd, double *h, double *v)
+{
+ if (h) *h = pd->align.h;
+ if (v) *v = pd->align.v;
+}
+
#include "efl_ui_box.eo.c"
diff --git a/src/lib/elementary/efl_ui_box.eo b/src/lib/elementary/efl_ui_box.eo
index 4a97db2e98..2ef5a76d1c 100644
--- a/src/lib/elementary/efl_ui_box.eo
+++ b/src/lib/elementary/efl_ui_box.eo
@@ -23,6 +23,8 @@ class Efl.Ui.Box (Elm.Widget, Efl.Pack_Engine, Efl.Pack_Linear)
Efl.Pack.pack;
Efl.Pack.padding.get;
Efl.Pack.padding.set;
+ Efl.Pack.pack_align.get;
+ Efl.Pack.pack_align.set;
Efl.Pack.layout_update;
Efl.Pack.layout_request;
Efl.Pack.layout_engine.get;
diff --git a/src/lib/elementary/efl_ui_box_layout.c b/src/lib/elementary/efl_ui_box_layout.c
index 72cdb9f6fd..2d81c17de0 100644
--- a/src/lib/elementary/efl_ui_box_layout.c
+++ b/src/lib/elementary/efl_ui_box_layout.c
@@ -31,17 +31,28 @@ _efl_ui_box_custom_layout(Efl_Ui_Box *ui_box, Evas_Object_Box_Data *bd)
Eina_Bool horiz = _horiz(pd->orient), zeroweight = EINA_FALSE;
int id = 0, count, boxl = 0, boxr = 0, boxt = 0, boxb = 0;
int length, want, deficit = 0, pad, extra = 0, rounding = 0;
- double cur_pos = 0, weight = 0, scale;
+ double cur_pos = 0, weight[2] = { 0, 0 }, scale;
double box_align[2];
+ Eina_Bool box_fill[2] = { EINA_FALSE, EINA_FALSE };
evas_object_geometry_get(ui_box, &boxx, &boxy, &boxw, &boxh);
evas_object_size_hint_padding_get(ui_box, &boxl, &boxr, &boxt, &boxb);
scale = evas_object_scale_get(ui_box);
// Box align: used if "item has max size and fill" or "no item has a weight"
- //box_align[0] = bd->align.h;
- //box_align[1] = bd->align.v;
- evas_object_size_hint_align_get(ui_box, &box_align[0], &box_align[1]);
+ // Note: cells always expand on the orthogonal direction
+ box_align[0] = pd->align.h;
+ box_align[1] = pd->align.v;
+ if (box_align[0] < 0)
+ {
+ box_fill[0] = EINA_TRUE;
+ box_align[0] = 0.5;
+ }
+ if (box_align[1] < 0)
+ {
+ box_fill[1] = EINA_TRUE;
+ box_align[1] = 0.5;
+ }
count = eina_list_count(bd->children);
if (!count)
@@ -89,16 +100,16 @@ _efl_ui_box_custom_layout(Efl_Ui_Box *ui_box, Evas_Object_Box_Data *bd)
item->want[0] = MAX(item->req[0], item->min[0]) + item->pad[0] + item->pad[1];
item->want[1] = MAX(item->req[1], item->min[1]) + item->pad[2] + item->pad[3];
+ weight[0] += item->weight[0];
+ weight[1] += item->weight[1];
if (horiz)
{
- weight += item->weight[0];
wantw += item->want[0];
if (item->want[1] > wanth)
wanth = item->want[1];
}
else
{
- weight += item->weight[1];
wanth += item->want[1];
if (item->want[0] > wantw)
wantw = item->want[0];
@@ -110,6 +121,8 @@ _efl_ui_box_custom_layout(Efl_Ui_Box *ui_box, Evas_Object_Box_Data *bd)
// box outer margin
boxw -= boxl + boxr;
boxh -= boxt + boxb;
+ boxx += boxl;
+ boxy += boxt;
// total space & available space
if (horiz)
@@ -151,10 +164,9 @@ _efl_ui_box_custom_layout(Efl_Ui_Box *ui_box, Evas_Object_Box_Data *bd)
extra = 0;
}
- if (!weight)
+ if (!weight[!horiz])
{
- double balign = box_align[!horiz];
- if (balign < 0)
+ if (box_fill[!horiz])
{
// box is filled, set all weights to be equal
zeroweight = EINA_TRUE;
@@ -162,15 +174,11 @@ _efl_ui_box_custom_layout(Efl_Ui_Box *ui_box, Evas_Object_Box_Data *bd)
else
{
// move bounding box according to box align
- cur_pos = extra * balign;
+ cur_pos = extra * box_align[!horiz];
}
- weight = count;
+ weight[!horiz] = count;
}
- // reset box_align to 0.5 if filled (only used by items with max size)
- if (box_align[0] < 0) box_align[0] = 0.5;
- if (box_align[1] < 0) box_align[1] = 0.5;
-
for (id = 0; id < count; id++)
{
double cx, cy, cw, ch, x, y, w, h;
@@ -182,18 +190,18 @@ _efl_ui_box_custom_layout(Efl_Ui_Box *ui_box, Evas_Object_Box_Data *bd)
if (horiz)
{
- cx = boxx + boxl + cur_pos;
- cy = boxy + boxt;
- cw = item->want[0] + rounding + (zeroweight ? 1.0 : item->weight[0]) * extra / weight;
+ cx = boxx + cur_pos;
+ cy = boxy;
+ cw = item->want[0] + rounding + (zeroweight ? 1.0 : item->weight[0]) * extra / weight[0];
ch = boxh;
cur_pos += cw + pad;
}
else
{
- cx = boxx + boxl;
- cy = boxy + boxt + cur_pos;
+ cx = boxx;
+ cy = boxy + cur_pos;
cw = boxw;
- ch = item->want[1] + rounding + (zeroweight ? 1.0 : item->weight[1]) * extra / weight;
+ ch = item->want[1] + rounding + (zeroweight ? 1.0 : item->weight[1]) * extra / weight[1];
cur_pos += ch + pad;
}
diff --git a/src/lib/elementary/efl_ui_box_private.h b/src/lib/elementary/efl_ui_box_private.h
index 64b009e15d..234f7b15a2 100644
--- a/src/lib/elementary/efl_ui_box_private.h
+++ b/src/lib/elementary/efl_ui_box_private.h
@@ -36,6 +36,10 @@ struct _Efl_Ui_Box_Data
double h, v;
Eina_Bool scalable: 1;
} pad;
+
+ struct {
+ double h, v;
+ } align;
};
struct _Box_Item_Iterator