summaryrefslogtreecommitdiff
path: root/src/lib/elementary/efl_ui_box_layout.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/elementary/efl_ui_box_layout.c')
-rw-r--r--src/lib/elementary/efl_ui_box_layout.c67
1 files changed, 33 insertions, 34 deletions
diff --git a/src/lib/elementary/efl_ui_box_layout.c b/src/lib/elementary/efl_ui_box_layout.c
index 40f6be6..70cf4ca 100644
--- a/src/lib/elementary/efl_ui_box_layout.c
+++ b/src/lib/elementary/efl_ui_box_layout.c
@@ -12,9 +12,8 @@ struct _Item_Calc
12 Evas_Object *obj; 12 Evas_Object *obj;
13 double weight[2]; 13 double weight[2];
14 double align[2]; 14 double align[2];
15 Eina_Size2D max; 15 Eina_Size2D max, want;
16 int pad[4]; 16 int pad[4];
17 int want[2];
18 Efl_Gfx_Size_Hint_Aspect aspect_type; 17 Efl_Gfx_Size_Hint_Aspect aspect_type;
19 int aspect[2]; 18 int aspect[2];
20 int id; 19 int id;
@@ -79,7 +78,7 @@ _efl_ui_box_custom_layout(Efl_Ui_Box *ui_box, Evas_Object_Box_Data *bd)
79 efl_gfx_size_hint_align_get(o, &item->align[0], &item->align[1]); 78 efl_gfx_size_hint_align_get(o, &item->align[0], &item->align[1]);
80 efl_gfx_size_hint_margin_get(o, &item->pad[0], &item->pad[1], &item->pad[2], &item->pad[3]); 79 efl_gfx_size_hint_margin_get(o, &item->pad[0], &item->pad[1], &item->pad[2], &item->pad[3]);
81 item->max = efl_gfx_size_hint_max_get(o); 80 item->max = efl_gfx_size_hint_max_get(o);
82 efl_gfx_size_hint_combined_min_get(o, &item->want[0], &item->want[1]); 81 item->want = efl_gfx_size_hint_combined_min_get(o);
83 efl_gfx_size_hint_aspect_get(o, &item->aspect_type, &item->aspect[0], &item->aspect[1]); 82 efl_gfx_size_hint_aspect_get(o, &item->aspect_type, &item->aspect[0], &item->aspect[1]);
84 83
85 if (item->aspect[0] <= 0 || item->aspect[1] <= 0) 84 if (item->aspect[0] <= 0 || item->aspect[1] <= 0)
@@ -94,11 +93,11 @@ _efl_ui_box_custom_layout(Efl_Ui_Box *ui_box, Evas_Object_Box_Data *bd)
94 { 93 {
95 double w, h; 94 double w, h;
96 95
97 w = item->want[0]; 96 w = item->want.w;
98 h = w * item->aspect[1] / item->aspect[0]; 97 h = w * item->aspect[1] / item->aspect[0];
99 if (h < item->want[1]) 98 if (h < item->want.h)
100 { 99 {
101 h = item->want[1]; 100 h = item->want.h;
102 w = h * item->aspect[0] / item->aspect[1]; 101 w = h * item->aspect[0] / item->aspect[1];
103 } 102 }
104 103
@@ -124,8 +123,8 @@ _efl_ui_box_custom_layout(Efl_Ui_Box *ui_box, Evas_Object_Box_Data *bd)
124 h = item->max.h > 0 ? MIN(h1, item->max.h) : h1; 123 h = item->max.h > 0 ? MIN(h1, item->max.h) : h1;
125 } 124 }
126 } 125 }
127 item->want[0] = w; 126 item->want.w = w;
128 item->want[1] = h; 127 item->want.h = h;
129 } 128 }
130 129
131 if (item->weight[0] < 0) item->weight[0] = 0; 130 if (item->weight[0] < 0) item->weight[0] = 0;
@@ -136,30 +135,30 @@ _efl_ui_box_custom_layout(Efl_Ui_Box *ui_box, Evas_Object_Box_Data *bd)
136 if (item->align[0] > 1) item->align[0] = 1; 135 if (item->align[0] > 1) item->align[0] = 1;
137 if (item->align[1] > 1) item->align[1] = 1; 136 if (item->align[1] > 1) item->align[1] = 1;
138 137
139 if (item->want[0] < 0) item->want[0] = 0; 138 if (item->want.w < 0) item->want.w = 0;
140 if (item->want[1] < 0) item->want[1] = 0; 139 if (item->want.h < 0) item->want.h = 0;
141 140
142 if (item->max.w < 0) item->max.w = INT_MAX; 141 if (item->max.w < 0) item->max.w = INT_MAX;
143 if (item->max.h < 0) item->max.h = INT_MAX; 142 if (item->max.h < 0) item->max.h = INT_MAX;
144 if (item->max.w < item->want[0]) item->max.w = item->want[0]; 143 if (item->max.w < item->want.w) item->max.w = item->want.w;
145 if (item->max.h < item->want[1]) item->max.h = item->want[1]; 144 if (item->max.h < item->want.h) item->max.h = item->want.h;
146 145
147 item->want[0] += item->pad[0] + item->pad[1]; 146 item->want.w += item->pad[0] + item->pad[1];
148 item->want[1] += item->pad[2] + item->pad[3]; 147 item->want.h += item->pad[2] + item->pad[3];
149 148
150 weight[0] += item->weight[0]; 149 weight[0] += item->weight[0];
151 weight[1] += item->weight[1]; 150 weight[1] += item->weight[1];
152 if (horiz) 151 if (horiz)
153 { 152 {
154 wantw += item->want[0]; 153 wantw += item->want.w;
155 if (item->want[1] > wanth) 154 if (item->want.h > wanth)
156 wanth = item->want[1]; 155 wanth = item->want.h;
157 } 156 }
158 else 157 else
159 { 158 {
160 wanth += item->want[1]; 159 wanth += item->want.h;
161 if (item->want[0] > wantw) 160 if (item->want.w > wantw)
162 wantw = item->want[0]; 161 wantw = item->want.w;
163 } 162 }
164 163
165 item->id = id++; 164 item->id = id++;
@@ -234,7 +233,7 @@ _efl_ui_box_custom_layout(Efl_Ui_Box *ui_box, Evas_Object_Box_Data *bd)
234 { 233 {
235 cx = boxx + cur_pos; 234 cx = boxx + cur_pos;
236 cy = boxy; 235 cy = boxy;
237 cw = item->want[0] + rounding + (zeroweight ? 1.0 : item->weight[0]) * extra / weight[0]; 236 cw = item->want.w + rounding + (zeroweight ? 1.0 : item->weight[0]) * extra / weight[0];
238 ch = boxh; 237 ch = boxh;
239 cur_pos += cw + pad; 238 cur_pos += cw + pad;
240 } 239 }
@@ -243,7 +242,7 @@ _efl_ui_box_custom_layout(Efl_Ui_Box *ui_box, Evas_Object_Box_Data *bd)
243 cx = boxx; 242 cx = boxx;
244 cy = boxy + cur_pos; 243 cy = boxy + cur_pos;
245 cw = boxw; 244 cw = boxw;
246 ch = item->want[1] + rounding + (zeroweight ? 1.0 : item->weight[1]) * extra / weight[1]; 245 ch = item->want.h + rounding + (zeroweight ? 1.0 : item->weight[1]) * extra / weight[1];
247 cur_pos += ch + pad; 246 cur_pos += ch + pad;
248 } 247 }
249 248
@@ -251,10 +250,10 @@ _efl_ui_box_custom_layout(Efl_Ui_Box *ui_box, Evas_Object_Box_Data *bd)
251 { 250 {
252 if (horiz) 251 if (horiz)
253 { 252 {
254 w = item->want[0]; 253 w = item->want.w;
255 h = item->want[1]; 254 h = item->want.h;
256 if (weight[0] > 0) 255 if (weight[0] > 0)
257 w = item->want[0] + extra * item->weight[0] / weight[0]; 256 w = item->want.w + extra * item->weight[0] / weight[0];
258 h = w * item->aspect[1] / item->aspect[0]; 257 h = w * item->aspect[1] / item->aspect[0];
259 258
260 if (item->aspect_type == EFL_GFX_SIZE_HINT_ASPECT_BOTH || 259 if (item->aspect_type == EFL_GFX_SIZE_HINT_ASPECT_BOTH ||
@@ -269,10 +268,10 @@ _efl_ui_box_custom_layout(Efl_Ui_Box *ui_box, Evas_Object_Box_Data *bd)
269 } 268 }
270 else 269 else
271 { 270 {
272 w = item->want[0]; 271 w = item->want.w;
273 h = item->want[1]; 272 h = item->want.h;
274 if (weight[1] > 0) 273 if (weight[1] > 0)
275 h = item->want[1] + extra * item->weight[1] / weight[1]; 274 h = item->want.h + extra * item->weight[1] / weight[1];
276 w = h * item->aspect[0] / item->aspect[1]; 275 w = h * item->aspect[0] / item->aspect[1];
277 276
278 if (item->aspect_type == EFL_GFX_SIZE_HINT_ASPECT_BOTH || 277 if (item->aspect_type == EFL_GFX_SIZE_HINT_ASPECT_BOTH ||
@@ -310,12 +309,12 @@ _efl_ui_box_custom_layout(Efl_Ui_Box *ui_box, Evas_Object_Box_Data *bd)
310 } 309 }
311 else if (item->max.w != INT_MAX) 310 else if (item->max.w != INT_MAX)
312 { 311 {
313 w = MIN(w, MAX(item->want[0], item->max.w)); 312 w = MIN(w, MAX(item->want.w, item->max.w));
314 h = w * item->aspect[1] / item->aspect[0]; 313 h = w * item->aspect[1] / item->aspect[0];
315 } 314 }
316 else 315 else
317 { 316 {
318 h = MIN(h, MAX(item->want[1], item->max.h)); 317 h = MIN(h, MAX(item->want.h, item->max.h));
319 w = h * item->aspect[0] / item->aspect[1]; 318 w = h * item->aspect[0] / item->aspect[1];
320 } 319 }
321 w = w - item->pad[0] - item->pad[1]; 320 w = w - item->pad[0] - item->pad[1];
@@ -336,7 +335,7 @@ _efl_ui_box_custom_layout(Efl_Ui_Box *ui_box, Evas_Object_Box_Data *bd)
336 // horizontally 335 // horizontally
337 if (item->max.w < INT_MAX) 336 if (item->max.w < INT_MAX)
338 { 337 {
339 w = MIN(MAX(item->want[0] - item->pad[0] - item->pad[1], item->max.w), cw); 338 w = MIN(MAX(item->want.w - item->pad[0] - item->pad[1], item->max.w), cw);
340 if (item->align[0] < 0) 339 if (item->align[0] < 0)
341 { 340 {
342 // bad case: fill+max are not good together 341 // bad case: fill+max are not good together
@@ -356,14 +355,14 @@ _efl_ui_box_custom_layout(Efl_Ui_Box *ui_box, Evas_Object_Box_Data *bd)
356 if (horiz && item->weight[0] > 0) 355 if (horiz && item->weight[0] > 0)
357 w = cw - item->pad[0] - item->pad[1]; 356 w = cw - item->pad[0] - item->pad[1];
358 else 357 else
359 w = item->want[0] - item->pad[0] - item->pad[1]; 358 w = item->want.w - item->pad[0] - item->pad[1];
360 x = cx + ((cw - w) * item->align[0]) + item->pad[0]; 359 x = cx + ((cw - w) * item->align[0]) + item->pad[0];
361 } 360 }
362 361
363 // vertically 362 // vertically
364 if (item->max.h < INT_MAX) 363 if (item->max.h < INT_MAX)
365 { 364 {
366 h = MIN(MAX(item->want[1] - item->pad[2] - item->pad[3], item->max.h), ch); 365 h = MIN(MAX(item->want.h - item->pad[2] - item->pad[3], item->max.h), ch);
367 if (item->align[1] < 0) 366 if (item->align[1] < 0)
368 { 367 {
369 // bad case: fill+max are not good together 368 // bad case: fill+max are not good together
@@ -383,7 +382,7 @@ _efl_ui_box_custom_layout(Efl_Ui_Box *ui_box, Evas_Object_Box_Data *bd)
383 if (!horiz && item->weight[1] > 0) 382 if (!horiz && item->weight[1] > 0)
384 h = ch - item->pad[2] - item->pad[3]; 383 h = ch - item->pad[2] - item->pad[3];
385 else 384 else
386 h = item->want[1] - item->pad[2] - item->pad[3]; 385 h = item->want.h - item->pad[2] - item->pad[3];
387 y = cy + ((ch - h) * item->align[1]) + item->pad[2]; 386 y = cy + ((ch - h) * item->align[1]) + item->pad[2];
388 } 387 }
389 } 388 }