summaryrefslogtreecommitdiff
path: root/src/lib/elementary/efl_ui_box_layout.c
diff options
context:
space:
mode:
authorYeongjong Lee <yj34.lee@samsung.com>2019-02-13 08:39:20 -0500
committerMike Blumenkrantz <zmike@samsung.com>2019-02-13 09:23:01 -0500
commit27e101da4b0134186217e27aceceb96ef2636fe5 (patch)
treed75953af1f02cc8e09948d8aa121eed55e13e75e /src/lib/elementary/efl_ui_box_layout.c
parentb1f280f0c2c307c32a5edde5b5f2f304d463dac8 (diff)
ui.box: implement homogeneous mode
Summary: On homogeneous mode, children are of the same weight and of the same min size which is determined by maximum min size of children. Depends on D7750 Reviewers: Jaehyun_Cho, zmike, jpeg Reviewed By: zmike Subscribers: segfaultxavi, cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D7889
Diffstat (limited to '')
-rw-r--r--src/lib/elementary/efl_ui_box_layout.c43
1 files changed, 35 insertions, 8 deletions
diff --git a/src/lib/elementary/efl_ui_box_layout.c b/src/lib/elementary/efl_ui_box_layout.c
index 8f8cc4d661..3b5f0a9c43 100644
--- a/src/lib/elementary/efl_ui_box_layout.c
+++ b/src/lib/elementary/efl_ui_box_layout.c
@@ -86,7 +86,7 @@ _efl_ui_box_custom_layout(Efl_Ui_Box *ui_box, Evas_Object_Box_Data *bd)
86 Eina_Bool horiz = efl_ui_dir_is_horizontal(pd->dir, EINA_FALSE); 86 Eina_Bool horiz = efl_ui_dir_is_horizontal(pd->dir, EINA_FALSE);
87 int id = 0, count, boxl = 0, boxr = 0, boxt = 0, boxb = 0; 87 int id = 0, count, boxl = 0, boxr = 0, boxt = 0, boxb = 0;
88 int length, want, pad; 88 int length, want, pad;
89 double cur_pos, weight[2] = { 0, 0 }, scale; 89 double cur_pos, weight[2] = { 0, 0 }, scale, mmin = 0;
90 double box_align[2]; 90 double box_align[2];
91 Eina_Bool box_fill[2] = { EINA_FALSE, EINA_FALSE }; 91 Eina_Bool box_fill[2] = { EINA_FALSE, EINA_FALSE };
92 92
@@ -141,9 +141,9 @@ _efl_ui_box_custom_layout(Efl_Ui_Box *ui_box, Evas_Object_Box_Data *bd)
141 item->min = efl_gfx_size_hint_combined_min_get(o); 141 item->min = efl_gfx_size_hint_combined_min_get(o);
142 efl_gfx_size_hint_aspect_get(o, &item->aspect_type, &item->aspect); 142 efl_gfx_size_hint_aspect_get(o, &item->aspect_type, &item->aspect);
143 143
144 if (horiz && box_fill[0]) item->weight[0] = 1; 144 if (horiz && (box_fill[0] || pd->homogeneous)) item->weight[0] = 1;
145 else if (item->weight[0] < 0) item->weight[0] = 0; 145 else if (item->weight[0] < 0) item->weight[0] = 0;
146 if (!horiz && box_fill[1]) item->weight[1] = 1; 146 if (!horiz && (box_fill[1] || pd->homogeneous)) item->weight[1] = 1;
147 else if (item->weight[1] < 0) item->weight[1] = 0; 147 else if (item->weight[1] < 0) item->weight[1] = 0;
148 148
149 if (EINA_DBL_EQ(item->align[0], -1)) 149 if (EINA_DBL_EQ(item->align[0], -1))
@@ -191,13 +191,29 @@ _efl_ui_box_custom_layout(Efl_Ui_Box *ui_box, Evas_Object_Box_Data *bd)
191 { 191 {
192 if (item->space[1] > wanth) 192 if (item->space[1] > wanth)
193 wanth = item->space[1]; 193 wanth = item->space[1];
194 wantw += item->space[0]; 194 if (pd->homogeneous)
195 {
196 if (item->space[0] > mmin)
197 mmin = item->space[0];
198 }
199 else
200 {
201 wantw += item->space[0];
202 }
195 } 203 }
196 else 204 else
197 { 205 {
198 if (item->space[0] > wantw) 206 if (item->space[0] > wantw)
199 wantw = item->space[0]; 207 wantw = item->space[0];
200 wanth += item->space[1]; 208 if (pd->homogeneous)
209 {
210 if (item->space[1] > mmin)
211 mmin = item->space[1];
212 }
213 else
214 {
215 wanth += item->space[1];
216 }
201 } 217 }
202 218
203 item->id = id++; 219 item->id = id++;
@@ -206,6 +222,8 @@ _efl_ui_box_custom_layout(Efl_Ui_Box *ui_box, Evas_Object_Box_Data *bd)
206 // total space & available space 222 // total space & available space
207 if (horiz) 223 if (horiz)
208 { 224 {
225 if (pd->homogeneous)
226 wantw = mmin * count;
209 want = wantw; 227 want = wantw;
210 length = boxs.w; 228 length = boxs.w;
211 pad = pd->pad.scalable ? (pd->pad.h * scale) : pd->pad.h; 229 pad = pd->pad.scalable ? (pd->pad.h * scale) : pd->pad.h;
@@ -214,6 +232,8 @@ _efl_ui_box_custom_layout(Efl_Ui_Box *ui_box, Evas_Object_Box_Data *bd)
214 } 232 }
215 else 233 else
216 { 234 {
235 if (pd->homogeneous)
236 wanth = mmin * count;
217 want = wanth; 237 want = wanth;
218 length = boxs.h; 238 length = boxs.h;
219 pad = pd->pad.scalable ? (pd->pad.v * scale) : pd->pad.v; 239 pad = pd->pad.scalable ? (pd->pad.v * scale) : pd->pad.v;
@@ -226,7 +246,7 @@ _efl_ui_box_custom_layout(Efl_Ui_Box *ui_box, Evas_Object_Box_Data *bd)
226 cur_pos = horiz ? boxs.x : boxs.y; 246 cur_pos = horiz ? boxs.x : boxs.y;
227 247
228 // calculate weight length 248 // calculate weight length
229 if ((length > want) && (weight[!horiz] > 0)) 249 if (!pd->homogeneous && (length > want) && (weight[!horiz] > 0))
230 { 250 {
231 int orig_length = length; 251 int orig_length = length;
232 double orig_weight = weight[!horiz]; 252 double orig_weight = weight[!horiz];
@@ -272,12 +292,19 @@ _efl_ui_box_custom_layout(Efl_Ui_Box *ui_box, Evas_Object_Box_Data *bd)
272 { 292 {
273 int x, y, w, h, sw, sh; 293 int x, y, w, h, sw, sh;
274 294
275 if ((length > want) && EINA_DBL_EQ(weight[!horiz], 0)) 295 if (length > want)
276 cur_pos += (length - want) * box_align[!horiz]; 296 {
297 if (pd->homogeneous)
298 mmin = (double)length / count;
299 else if (EINA_DBL_EQ(weight[!horiz], 0))
300 cur_pos += (length - want) * box_align[!horiz];
301 }
277 302
278 for (id = 0; id < count; id++) 303 for (id = 0; id < count; id++)
279 { 304 {
280 item = &items[id]; 305 item = &items[id];
306 if (pd->homogeneous)
307 item->space[!horiz] = mmin;
281 item->space[horiz] = horiz ? boxs.h : boxs.w; 308 item->space[horiz] = horiz ? boxs.h : boxs.w;
282 sw = item->space[0] - item->pad[0] - item->pad[1]; 309 sw = item->space[0] - item->pad[0] - item->pad[1];
283 sh = item->space[1] - item->pad[2] - item->pad[3]; 310 sh = item->space[1] - item->pad[2] - item->pad[3];