summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib/elementary/efl_ui_box.c12
-rw-r--r--src/lib/elementary/efl_ui_box.eo12
-rw-r--r--src/lib/elementary/efl_ui_box_layout.c43
3 files changed, 59 insertions, 8 deletions
diff --git a/src/lib/elementary/efl_ui_box.c b/src/lib/elementary/efl_ui_box.c
index aa6b2d85aa..dbf4584503 100644
--- a/src/lib/elementary/efl_ui_box.c
+++ b/src/lib/elementary/efl_ui_box.c
@@ -81,6 +81,18 @@ _evas_box_custom_layout(Evas_Object *evas_box EINA_UNUSED,
81} 81}
82 82
83EOLIAN static void 83EOLIAN static void
84_efl_ui_box_homogeneous_set(Eo *obj EINA_UNUSED, Efl_Ui_Box_Data *pd, Eina_Bool homogeneous)
85{
86 pd->homogeneous = !!homogeneous;
87}
88
89EOLIAN static Eina_Bool
90_efl_ui_box_homogeneous_get(const Eo *obj EINA_UNUSED, Efl_Ui_Box_Data *pd)
91{
92 return pd->homogeneous;
93}
94
95EOLIAN static void
84_efl_ui_box_efl_pack_layout_layout_update(Eo *obj, Efl_Ui_Box_Data *pd EINA_UNUSED) 96_efl_ui_box_efl_pack_layout_layout_update(Eo *obj, Efl_Ui_Box_Data *pd EINA_UNUSED)
85{ 97{
86 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); 98 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
diff --git a/src/lib/elementary/efl_ui_box.eo b/src/lib/elementary/efl_ui_box.eo
index 3b595096ef..fddf253d90 100644
--- a/src/lib/elementary/efl_ui_box.eo
+++ b/src/lib/elementary/efl_ui_box.eo
@@ -15,6 +15,18 @@ class Efl.Ui.Box extends Efl.Ui.Widget implements Efl.Pack_Linear, Efl.Pack_Layo
15 THIS CLASS NEEDS GOOD UP TO DATE DOCUMENTATION. LEGACY BOX AND UI BOX 15 THIS CLASS NEEDS GOOD UP TO DATE DOCUMENTATION. LEGACY BOX AND UI BOX
16 BEHAVE SLIGHTLY DIFFERENTLY AND USE VASTLY DIFFERENT APIS. 16 BEHAVE SLIGHTLY DIFFERENTLY AND USE VASTLY DIFFERENT APIS.
17 ]] 17 ]]
18 methods {
19 @property homogeneous {
20 [[Control homogeneous mode.
21
22 This will enable the homogeneous mode where children are of the same
23 weight and of the same min size which is determined by maximum min
24 size of children.]]
25 values {
26 homogeneous: bool; [[$true if the box is homogeneous, $false otherwise]]
27 }
28 }
29 }
18 implements { 30 implements {
19 Efl.Object.constructor; 31 Efl.Object.constructor;
20 Efl.Canvas.Group.group_calculate; 32 Efl.Canvas.Group.group_calculate;
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];