summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYeongjong Lee <yj34.lee@samsung.com>2019-03-08 08:22:08 -0500
committerMike Blumenkrantz <zmike@samsung.com>2019-03-08 08:22:08 -0500
commitfbc7c31b33270a4d617bead2cf3baec61cc64b62 (patch)
tree24b1afe569ca33e78d6611c2da2a6624b6c21cff
parent8118330d2a34a26078d3642ebbebf188146a5415 (diff)
ui.box_flow: refactor layout_update
Summary: This patch remove evas_box function from Efl.Ui.Box_Flow and add unit test. Depends on D8214 Test Plan: 1. make check 2. `elementary_test -to 'efl.ui.box'` with 'flow' checkbox. Reviewers: zmike, Jaehyun_Cho Reviewed By: zmike Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D8219
-rw-r--r--src/Makefile_Elementary.am1
-rw-r--r--src/bin/elementary/test_ui_box.c18
-rw-r--r--src/lib/elementary/efl_ui_box_flow.c358
-rw-r--r--src/lib/elementary/efl_ui_box_flow.eo18
-rw-r--r--src/tests/elementary/efl_ui_suite.c1
-rw-r--r--src/tests/elementary/efl_ui_suite.h1
-rw-r--r--src/tests/elementary/efl_ui_test_box_flow.c416
-rw-r--r--src/tests/elementary/meson.build1
8 files changed, 741 insertions, 73 deletions
diff --git a/src/Makefile_Elementary.am b/src/Makefile_Elementary.am
index 002d3f27ba..e29471912b 100644
--- a/src/Makefile_Elementary.am
+++ b/src/Makefile_Elementary.am
@@ -1922,6 +1922,7 @@ tests_elementary_efl_ui_suite_SOURCES = \
1922 tests/elementary/efl_ui_test_focus.c \ 1922 tests/elementary/efl_ui_test_focus.c \
1923 tests/elementary/efl_ui_test_focus_sub.c \ 1923 tests/elementary/efl_ui_test_focus_sub.c \
1924 tests/elementary/efl_ui_test_box.c \ 1924 tests/elementary/efl_ui_test_box.c \
1925 tests/elementary/efl_ui_test_box_flow.c \
1925 tests/elementary/efl_ui_test_table.c \ 1926 tests/elementary/efl_ui_test_table.c \
1926 tests/elementary/efl_ui_test_relative_layout.c \ 1927 tests/elementary/efl_ui_test_relative_layout.c \
1927 tests/elementary/efl_ui_test_grid.c \ 1928 tests/elementary/efl_ui_test_grid.c \
diff --git a/src/bin/elementary/test_ui_box.c b/src/bin/elementary/test_ui_box.c
index c5b9db8d56..0021be5603 100644
--- a/src/bin/elementary/test_ui_box.c
+++ b/src/bin/elementary/test_ui_box.c
@@ -179,15 +179,7 @@ homo_check_cb(void *data, const Efl_Event *event)
179{ 179{
180 Eina_Bool chk = elm_check_selected_get(event->object); 180 Eina_Bool chk = elm_check_selected_get(event->object);
181 Eo *box = efl_key_wref_get(data, "box"); 181 Eo *box = efl_key_wref_get(data, "box");
182 efl_ui_box_flow_homogenous_set(box, chk); 182 efl_ui_box_homogeneous_set(box, chk);
183}
184
185static void
186max_size_check_cb(void *data, const Efl_Event *event)
187{
188 Eina_Bool chk = elm_check_selected_get(event->object);
189 Eo *box = efl_key_wref_get(data, "box");
190 efl_ui_box_flow_max_size_set(box, chk);
191} 183}
192 184
193static void 185static void
@@ -360,14 +352,6 @@ test_ui_box(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in
360 352
361 o = elm_check_add(win); 353 o = elm_check_add(win);
362 elm_check_selected_set(o, 0); 354 elm_check_selected_set(o, 0);
363 elm_object_text_set(o, "Homogenous + Max");
364 efl_event_callback_add(o, EFL_UI_CHECK_EVENT_CHANGED, max_size_check_cb, win);
365 efl_gfx_hint_align_set(o, 0, 0);
366 efl_pack(bx, o);
367 efl_gfx_entity_visible_set(o, 1);
368
369 o = elm_check_add(win);
370 elm_check_selected_set(o, 0);
371 elm_object_text_set(o, "Custom layout"); 355 elm_object_text_set(o, "Custom layout");
372 efl_event_callback_add(o, EFL_UI_CHECK_EVENT_CHANGED, custom_check_cb, win); 356 efl_event_callback_add(o, EFL_UI_CHECK_EVENT_CHANGED, custom_check_cb, win);
373 efl_gfx_hint_align_set(o, 0, 0); 357 efl_gfx_hint_align_set(o, 0, 0);
diff --git a/src/lib/elementary/efl_ui_box_flow.c b/src/lib/elementary/efl_ui_box_flow.c
index a93ccc9e49..38bcb7d626 100644
--- a/src/lib/elementary/efl_ui_box_flow.c
+++ b/src/lib/elementary/efl_ui_box_flow.c
@@ -1,4 +1,5 @@
1#include "efl_ui_box_private.h" 1#include "efl_ui_box_private.h"
2#include "efl_ui_container_layout.h"
2 3
3#define MY_CLASS EFL_UI_BOX_FLOW_CLASS 4#define MY_CLASS EFL_UI_BOX_FLOW_CLASS
4 5
@@ -6,75 +7,356 @@ typedef struct _Efl_Ui_Box_Flow_Data Efl_Ui_Box_Flow_Data;
6 7
7struct _Efl_Ui_Box_Flow_Data 8struct _Efl_Ui_Box_Flow_Data
8{ 9{
9 Eina_Bool homogenous;
10 Eina_Bool max_size;
11}; 10};
12 11
13EOLIAN static void 12typedef struct _Item_Calc Item_Calc;
14_efl_ui_box_flow_box_flow_homogenous_set(Eo *obj EINA_UNUSED, Efl_Ui_Box_Flow_Data *pd, Eina_Bool val) 13typedef struct _Row_Calc Row_Calc;
14
15struct _Item_Calc
15{ 16{
16 pd->homogenous = val; 17 EINA_INLIST;
17}
18 18
19EOLIAN static Eina_Bool 19 Evas_Object *obj;
20_efl_ui_box_flow_box_flow_homogenous_get(const Eo *obj EINA_UNUSED, Efl_Ui_Box_Flow_Data *pd) 20 Row_Calc *row;
21 double weight_factor;
22 Efl_Ui_Container_Item_Hints hints[2]; /* 0 is x-axis, 1 is y-axis */
23};
24
25struct _Row_Calc
21{ 26{
22 return pd->homogenous; 27 EINA_INLIST;
23}
24 28
25EOLIAN static void 29 Evas_Object *obj;
26_efl_ui_box_flow_box_flow_max_size_set(Eo *obj EINA_UNUSED, Efl_Ui_Box_Flow_Data *pd, Eina_Bool val) 30 int item_count;
31 int min_sum;
32 int hgsize;
33 double weight_sum;
34 double cross_weight;
35 double cross_space;
36 double cur_pos;
37 double weight_factor;
38 Efl_Ui_Container_Item_Hints hint;
39};
40
41static int
42_item_weight_sort_cb(const void *l1, const void *l2)
27{ 43{
28 pd->max_size = val; 44 Item_Calc *it1, *it2;
45
46 it1 = EINA_INLIST_CONTAINER_GET(l1, Item_Calc);
47 it2 = EINA_INLIST_CONTAINER_GET(l2, Item_Calc);
48
49 return it2->weight_factor <= it1->weight_factor ? -1 : 1;
29} 50}
30 51
31EOLIAN static Eina_Bool 52static int
32_efl_ui_box_flow_box_flow_max_size_get(const Eo *obj EINA_UNUSED, Efl_Ui_Box_Flow_Data *pd) 53_row_weight_sort_cb(const void *l1, const void *l2)
33{ 54{
34 return pd->max_size; 55 Row_Calc *it1, *it2;
56
57 it1 = EINA_INLIST_CONTAINER_GET(l1, Row_Calc);
58 it2 = EINA_INLIST_CONTAINER_GET(l2, Row_Calc);
59
60 return it2->weight_factor <= it1->weight_factor ? -1 : 1;
35} 61}
36 62
37EOLIAN static void 63EOLIAN static void
38_efl_ui_box_flow_efl_pack_layout_layout_update(Eo *obj, Efl_Ui_Box_Flow_Data *pd) 64_efl_ui_box_flow_efl_pack_layout_layout_update(Eo *obj, Efl_Ui_Box_Flow_Data *pd EINA_UNUSED)
39{ 65{
40 void (*func)(Evas_Box *obj, Evas_Object_Box_Data *priv, void *data);
41 Evas_Object_Box_Data *bd; 66 Evas_Object_Box_Data *bd;
42 Eina_Bool homo = EINA_FALSE, maxsize = EINA_FALSE;
43 67
44 EINA_SAFETY_ON_FALSE_RETURN(efl_isa(obj, EFL_UI_BOX_CLASS));
45 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); 68 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
46 bd = efl_data_scope_get(wd->resize_obj, EVAS_BOX_CLASS); 69 bd = efl_data_scope_get(wd->resize_obj, EVAS_BOX_CLASS);
70 Efl_Ui_Box_Data *bcd = efl_data_scope_get(obj, EFL_UI_BOX_CLASS);
71 Evas_Object_Box_Option *opt;
72 Eina_List *li;
73 Eina_Inlist *inlist = NULL;
74 Item_Calc *items, *item;
75 Row_Calc *rows, *row;
76 Efl_Ui_Container_Item_Hints *hints, *hint;
77 Eina_Bool axis = !efl_ui_dir_is_horizontal(bcd->dir, EINA_FALSE);
78 Eina_Bool c_axis = !axis;
79 int want[2] = { 0, 0 };
80 int rc = 0, count, i = 0, id, item_last = 0;
81 double cur_pos, cross_weight_sum = 0, cross_min_sum = 0, min_sum = 0;
82 Efl_Ui_Container_Layout_Calc box_calc[2]; /* 0 is x-axis, 1 is y-axis */
83
84 count = eina_list_count(bd->children);
85 if (!count)
86 {
87 efl_gfx_hint_size_min_set(obj, EINA_SIZE2D(0, 0));
88 return;
89 }
47 90
48 homo = pd->homogenous; 91 _efl_ui_container_layout_init(obj, box_calc);
49 maxsize = pd->max_size;
50 92
51 // This makes it horizontal by default, as opposed to the standard box. 93 items = alloca(count * sizeof(*items));
52 if (efl_ui_dir_is_horizontal(efl_ui_direction_get(obj), EINA_TRUE)) 94 rows = alloca(count * sizeof(*rows));
95 memset(rows, 0, count * sizeof(*rows));
96
97#ifdef DEBUG
98 memset(items, 0, count * sizeof(*items));
99#endif
100
101 // scan all items, get their properties, calculate total weight & min size
102 EINA_LIST_FOREACH(bd->children, li, opt)
53 { 103 {
54 if (homo) 104 item = &items[i++];
105 item->obj = opt->obj;
106 hints = item->hints;
107
108 _efl_ui_container_layout_item_init(item->obj, hints);
109
110 if ((bcd->homogeneous && !axis) || box_calc[0].fill)
111 hints[0].weight = 1;
112 else if (hints[0].weight < 0)
113 hints[0].weight = 0;
114
115 if ((bcd->homogeneous && axis) || box_calc[1].fill)
116 hints[1].weight = 1;
117 else if (hints[1].weight < 0)
118 hints[1].weight = 0;
119
120 if (want[axis] < hints[axis].space)
121 want[axis] = hints[axis].space;
122
123 if (bcd->homogeneous)
124 continue;
125
126 if (i == 1)
55 { 127 {
56 if (maxsize) 128 min_sum = hints[axis].space;
57 func = evas_object_box_layout_homogeneous_max_size_horizontal; 129 }
58 else 130 else if (box_calc[axis].size < (min_sum + hints[axis].space + box_calc[axis].pad))
59 func = evas_object_box_layout_homogeneous_horizontal; 131 {
132 min_sum = hints[axis].space;
133 rc++;
60 } 134 }
61 else 135 else
62 func = evas_object_box_layout_flow_horizontal; 136 {
137 min_sum += (hints[axis].space + box_calc[axis].pad);
138 }
139
140 row = &rows[rc];
141 item->row = row;
142
143 if (row->cross_weight < hints[c_axis].weight)
144 row->cross_weight = hints[c_axis].weight;
145 if (row->cross_space < hints[c_axis].space)
146 row->cross_space = hints[c_axis].space;
147 row->weight_sum += hints[axis].weight;
148 row->min_sum += hints[axis].space;
149 row->item_count++;
63 } 150 }
64 else 151
152 // initialize homogeneous properties
153 if (bcd->homogeneous)
65 { 154 {
66 if (homo) 155 min_sum = 0;
156 for (i = 0; i < count; i++)
67 { 157 {
68 if (maxsize) 158 item = &items[i];
69 func = evas_object_box_layout_homogeneous_max_size_vertical; 159 hints = items[i].hints;
160
161 if (i == 0)
162 {
163 min_sum = want[axis];
164 }
165 else if (box_calc[axis].size < (min_sum + want[axis] + box_calc[axis].pad))
166 {
167 min_sum = want[axis];
168 rc++;
169 }
70 else 170 else
71 func = evas_object_box_layout_homogeneous_vertical; 171 {
172 min_sum += (want[axis] + box_calc[axis].pad);
173 }
174
175 row = &rows[rc];
176 item->row = row;
177
178 if (row->cross_weight < hints[c_axis].weight)
179 row->cross_weight = hints[c_axis].weight;
180 if (row->cross_space < hints[c_axis].space)
181 row->cross_space = hints[c_axis].space;
182 row->item_count++;
183 }
184 }
185
186 // calculate item space of each row
187 for (id = 0, i = 0; id <= rc; id++)
188 {
189 int box_size;
190
191 row = &rows[id];
192 row->cur_pos = box_calc[axis].pos;
193
194 box_size = box_calc[axis].size -
195 (box_calc[axis].pad * (row->item_count - 1));
196 row->hgsize = box_size / row->item_count;
197
198 cross_min_sum += row->cross_space;
199 cross_weight_sum += row->cross_weight;
200
201 if (bcd->homogeneous)
202 continue;
203
204 if (row->weight_sum > 0)
205 {
206 int calc_size;
207 double orig_weight = row->weight_sum;
208
209 calc_size = box_size;
210 inlist = NULL;
211
212 item_last += row->item_count;
213 for (; i < item_last; i++)
214 {
215 double denom;
216 hint = &items[i].hints[axis];
217
218 denom = (hint->weight * box_size) - (orig_weight * hint->space);
219 if (denom > 0)
220 {
221 items[i].weight_factor = (hint->weight * box_size) / denom;
222 inlist = eina_inlist_sorted_insert(inlist, EINA_INLIST_GET(&items[i]),
223 _item_weight_sort_cb);
224
225 }
226 else
227 {
228 calc_size -= hint->space;
229 row->weight_sum -= hint->weight;
230 }
231 }
232
233 EINA_INLIST_FOREACH(inlist, item)
234 {
235 double weight_len;
236 hint = &item->hints[axis];
237
238 weight_len = (calc_size * hint->weight) / row->weight_sum;
239 if (hint->space < weight_len)
240 {
241 hint->space = weight_len;
242 }
243 else
244 {
245 row->weight_sum -= hint->weight;
246 calc_size -= hint->space;
247 }
248 }
249 }
250 else if (EINA_DBL_EQ(row->weight_sum, 0))
251 {
252 row->cur_pos += (box_size - row->min_sum) * box_calc[axis].align;
72 } 253 }
73 else
74 func = evas_object_box_layout_flow_vertical;
75 } 254 }
76 255
77 func(wd->resize_obj, bd, NULL); 256 // calculate row space
257 box_calc[c_axis].size -= (box_calc[c_axis].pad * rc);
258 cur_pos = box_calc[c_axis].pos;
259 if ((box_calc[c_axis].size > cross_min_sum))
260 {
261 if (cross_weight_sum > 0)
262 {
263 int orig_size, calc_size;
264 double orig_weight = cross_weight_sum;
265
266 calc_size = orig_size = box_calc[c_axis].size;
267 inlist = NULL;
268
269 for (i = 0; i <= rc; i++)
270 {
271 double denom;
272 row = &rows[i];
273
274 denom = (row->cross_weight * orig_size) -
275 (orig_weight * row->cross_space);
276 if (denom > 0)
277 {
278 row->weight_factor = (row->cross_weight * orig_size) / denom;
279 inlist = eina_inlist_sorted_insert(inlist, EINA_INLIST_GET(row),
280 _row_weight_sort_cb);
281
282 }
283 else
284 {
285 calc_size -= row->cross_space;
286 cross_weight_sum -= row->cross_weight;
287 }
288 }
289
290 EINA_INLIST_FOREACH(inlist, row)
291 {
292 double weight_len;
293
294 weight_len = (calc_size * row->cross_weight) / cross_weight_sum;
295 if (row->cross_space < weight_len)
296 {
297 row->cross_space = weight_len;
298 }
299 else
300 {
301 cross_weight_sum -= row->cross_weight;
302 calc_size -= row->cross_space;
303 }
304 }
305 }
306 else if (EINA_DBL_EQ(cross_weight_sum, 0))
307 {
308 cur_pos += (box_calc[c_axis].size - cross_min_sum) * box_calc[c_axis].align;
309 }
310 }
311
312 // calculate item geometry
313 int item_size[2], item_pos[2], sw, sh;
314
315 row = NULL;
316 for (i = 0; i < count; i++)
317 {
318 item = &items[i];
319 hints = items[i].hints;
320
321 if (row && (row != item->row))
322 cur_pos += row->cross_space + box_calc[c_axis].pad;
323
324 row = item->row;
325
326 if (bcd->homogeneous)
327 hints[axis].space = row->hgsize;
328 hints[c_axis].space = row->cross_space;
329 sw = hints[0].space - (hints[0].margin[0] + hints[0].margin[1]);
330 sh = hints[1].space - (hints[1].margin[0] + hints[1].margin[1]);
331
332 item_size[0] = ((hints[0].weight > 0) && hints[0].fill) ? sw : 0;
333 item_size[1] = ((hints[1].weight > 0) && hints[1].fill) ? sh : 0;
334
335 _efl_ui_container_layout_min_max_calc(hints, &item_size[0], &item_size[1],
336 (hints[0].aspect > 0) && (hints[1].aspect > 0));
337
338 item_pos[axis] = row->cur_pos + 0.5;
339 item_pos[c_axis] = cur_pos + 0.5;
340
341 item_pos[0] += (hints[0].margin[0] +
342 ((sw - item_size[0]) * hints[0].align));
343 item_pos[1] += (hints[1].margin[0] +
344 ((sh - item_size[1]) * hints[1].align));
345
346 row->cur_pos += hints[axis].space + box_calc[axis].pad;
347
348 efl_gfx_entity_geometry_set(items[i].obj,
349 EINA_RECT(item_pos[0], item_pos[1],
350 item_size[0], item_size[1]));
351 }
352
353 want[axis] += (box_calc[axis].margin[0] + box_calc[axis].margin[1]);
354 want[c_axis] = (box_calc[c_axis].margin[0] + box_calc[c_axis].margin[1]) +
355 (box_calc[c_axis].pad * rc) + cross_min_sum;
356
357 efl_gfx_hint_size_restricted_min_set(obj, EINA_SIZE2D(want[0], want[1]));
358
359 efl_event_callback_call(obj, EFL_PACK_EVENT_LAYOUT_UPDATED, NULL);
78} 360}
79 361
80#include "efl_ui_box_flow.eo.c" 362#include "efl_ui_box_flow.eo.c"
diff --git a/src/lib/elementary/efl_ui_box_flow.eo b/src/lib/elementary/efl_ui_box_flow.eo
index 3ba120b6fb..91336525dc 100644
--- a/src/lib/elementary/efl_ui_box_flow.eo
+++ b/src/lib/elementary/efl_ui_box_flow.eo
@@ -1,24 +1,6 @@
1class @beta Efl.Ui.Box_Flow extends Efl.Ui.Box 1class @beta Efl.Ui.Box_Flow extends Efl.Ui.Box
2{ 2{
3 [[A custom layout engine for @Efl.Ui.Box.]] 3 [[A custom layout engine for @Efl.Ui.Box.]]
4 methods {
5 @property box_flow_homogenous {
6 [[Box flow homogenous property]]
7 set {}
8 get {}
9 values {
10 val: bool; [[$true if the box flow layout is homogenous, $false otherwise]]
11 }
12 }
13 @property box_flow_max_size {
14 [[Box flow maximum size property]]
15 set {}
16 get {}
17 values {
18 val: bool; [[$true if the box flow layout has the maximal size, $false otherwise]]
19 }
20 }
21 }
22 implements { 4 implements {
23 Efl.Pack_Layout.layout_update; 5 Efl.Pack_Layout.layout_update;
24 } 6 }
diff --git a/src/tests/elementary/efl_ui_suite.c b/src/tests/elementary/efl_ui_suite.c
index aa5de44f60..5783c203ce 100644
--- a/src/tests/elementary/efl_ui_suite.c
+++ b/src/tests/elementary/efl_ui_suite.c
@@ -13,6 +13,7 @@ static const Efl_Test_Case etc[] = {
13 { "efl_ui_focus", efl_ui_test_focus}, 13 { "efl_ui_focus", efl_ui_test_focus},
14 { "efl_ui_focus_sub", efl_ui_test_focus_sub}, 14 { "efl_ui_focus_sub", efl_ui_test_focus_sub},
15 { "efl_ui_box", efl_ui_test_box}, 15 { "efl_ui_box", efl_ui_test_box},
16 { "efl_ui_box_flow", efl_ui_test_box_flow},
16 { "efl_ui_table", efl_ui_test_table}, 17 { "efl_ui_table", efl_ui_test_table},
17 { "efl_ui_grid", efl_ui_test_grid}, 18 { "efl_ui_grid", efl_ui_test_grid},
18 { "efl_ui_relative_layout", efl_ui_test_relative_layout}, 19 { "efl_ui_relative_layout", efl_ui_test_relative_layout},
diff --git a/src/tests/elementary/efl_ui_suite.h b/src/tests/elementary/efl_ui_suite.h
index 4f5e529af0..1f393828f4 100644
--- a/src/tests/elementary/efl_ui_suite.h
+++ b/src/tests/elementary/efl_ui_suite.h
@@ -20,6 +20,7 @@
20 } 20 }
21 21
22void efl_ui_test_box(TCase *tc); 22void efl_ui_test_box(TCase *tc);
23void efl_ui_test_box_flow(TCase *tc);
23void efl_ui_test_table(TCase *tc); 24void efl_ui_test_table(TCase *tc);
24void efl_ui_test_grid(TCase *tc); 25void efl_ui_test_grid(TCase *tc);
25void efl_ui_test_relative_layout(TCase *tc); 26void efl_ui_test_relative_layout(TCase *tc);
diff --git a/src/tests/elementary/efl_ui_test_box_flow.c b/src/tests/elementary/efl_ui_test_box_flow.c
new file mode 100644
index 0000000000..52af8f0c15
--- /dev/null
+++ b/src/tests/elementary/efl_ui_test_box_flow.c
@@ -0,0 +1,416 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4
5#include <Elementary.h>
6#include "elm_suite.h"
7
8#define COORD_EQ(a, b) (!!(abs(a - b) < 2))
9#define GEOMETRY_EQ(a, b) (COORD_EQ(a.x, b.x) && COORD_EQ(a.y, b.y) && \
10 COORD_EQ(a.w, b.w) && COORD_EQ(a.h, b.h))
11
12typedef struct {
13 Eina_Size2D max;
14 Eina_Size2D min;
15 double weightx;
16 double weighty;
17 double alignx;
18 double aligny;
19 int marginl;
20 int marginr;
21 int margint;
22 int marginb;
23 Efl_Gfx_Hint_Aspect mode;
24 Eina_Size2D aspect;
25 Eina_Bool fillx;
26 Eina_Bool filly;
27 Eina_Size2D layout_size;
28 Eina_Size2D layout_expected;
29 Eina_Rect expected;
30 char testname[1024];
31} Hint;
32
33static Hint hints[] = {
34 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(0, 0), 1, 1, 0.5, 0.5, 0, 0, 0, 0,
35 EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_TRUE, EINA_TRUE,
36 EINA_SIZE2D(200, 200), EINA_SIZE2D(200, 200),
37 EINA_RECT(0, 0, 200, 200), "[0]" },
38 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 1, 1, 0.3, 0.5, 0, 0, 0, 0,
39 EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_TRUE, EINA_TRUE,
40 EINA_SIZE2D(200, 200), EINA_SIZE2D(200, 200),
41 EINA_RECT(0, 0, 200, 200), "[1]" },
42 { EINA_SIZE2D(50, 150), EINA_SIZE2D(70, 70), 1, 1, 0.3, 0.7, 0, 0, 0, 0,
43 EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_TRUE, EINA_TRUE,
44 EINA_SIZE2D(200, 200), EINA_SIZE2D(200, 200),
45 EINA_RECT((200 - 70) * 0.3, (200 - 150) * 0.7, 70, 150), "[2]" },
46 { EINA_SIZE2D(150, -1), EINA_SIZE2D(70, 70), 0, 0, 0.3, 0.7, 0, 0, 0, 0,
47 EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_FALSE, EINA_FALSE,
48 EINA_SIZE2D(200, 200), EINA_SIZE2D(200, 200),
49 EINA_RECT((200 - 70) * 0.8, (200 - 70) * 0.2, 70, 70), "[3]" },
50 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 1, 0, 0.3, 0.7, 0, 0, 0, 0,
51 EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_FALSE, EINA_TRUE,
52 EINA_SIZE2D(200, 200), EINA_SIZE2D(200, 200),
53 EINA_RECT((200 - 70) * 0.3, (200 - 70) * 0.2, 70, 70), "[4]" },
54 { EINA_SIZE2D(150, 150), EINA_SIZE2D(70, 70), 1, 0, 0.3, 0.7, 0, 0, 0, 0,
55 EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_FALSE, EINA_TRUE,
56 EINA_SIZE2D(200, 200), EINA_SIZE2D(200, 200),
57 EINA_RECT((200 - 70) * 0.3, (200 - 70) * 0.2, 70, 70), "[5]" },
58 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 0, 1, 0.3, 0.7, 0, 0, 0, 0,
59 EFL_GFX_HINT_ASPECT_BOTH, EINA_SIZE2D(1, 3), EINA_TRUE, EINA_FALSE,
60 EINA_SIZE2D(200, 200), EINA_SIZE2D(200, 210),
61 EINA_RECT((200 - 70) * 0.8, 0, 70, 70 * 3), "[6]" },
62 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 0, 1, 0.3, 0.7, 0, 0, 0, 0,
63 EFL_GFX_HINT_ASPECT_BOTH, EINA_SIZE2D(1, 3), EINA_TRUE, EINA_FALSE,
64 EINA_SIZE2D(300, 300), EINA_SIZE2D(300, 300),
65 EINA_RECT((300 - 70) * 0.8, (300 - 70 * 3) * 0.7, 70, 70 * 3), "[7]" },
66 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 1, 0, 0.3, 0.7, 0, 0, 0, 0,
67 EFL_GFX_HINT_ASPECT_BOTH, EINA_SIZE2D(1, 3), EINA_TRUE, EINA_FALSE,
68 EINA_SIZE2D(200, 200), EINA_SIZE2D(200, 210),
69 EINA_RECT((200 - 70) * 0.3, 0, 70, 70 * 3), "[8]" },
70 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 1, 0, 0.3, 0.7, 0, 0, 0, 0,
71 EFL_GFX_HINT_ASPECT_BOTH, EINA_SIZE2D(1, 3), EINA_TRUE, EINA_FALSE,
72 EINA_SIZE2D(300, 300), EINA_SIZE2D(300, 300),
73 EINA_RECT((300 - 70) * 0.3, (300 - 70 * 3) * 0.2, 70, 70 * 3), "[9]" },
74 { EINA_SIZE2D(-1, 150), EINA_SIZE2D(70, 70), 0, 1, 0.3, 0.7, 0, 0, 0, 0,
75 EFL_GFX_HINT_ASPECT_BOTH, EINA_SIZE2D(1, 3), EINA_TRUE, EINA_FALSE,
76 EINA_SIZE2D(200, 200), EINA_SIZE2D(200, 210),
77 EINA_RECT((200 - 70) * 0.8, 0, 70, 70 * 3), "[10]" },
78 { EINA_SIZE2D(-1, 150), EINA_SIZE2D(70, 70), 0, 1, 0.3, 0.7, 0, 0, 0, 0,
79 EFL_GFX_HINT_ASPECT_BOTH, EINA_SIZE2D(1, 3), EINA_TRUE, EINA_FALSE,
80 EINA_SIZE2D(300, 300), EINA_SIZE2D(300, 300),
81 EINA_RECT((300 - 70) * 0.8, (300 - 70 * 3) * 0.7, 70, 70 * 3), "[11]" },
82 { EINA_SIZE2D(-1, 150), EINA_SIZE2D(70, 70), 1, 0, 0.3, 0.7, 0, 0, 0, 0,
83 EFL_GFX_HINT_ASPECT_BOTH, EINA_SIZE2D(1, 3), EINA_TRUE, EINA_FALSE,
84 EINA_SIZE2D(200, 200), EINA_SIZE2D(200, 210),
85 EINA_RECT((200 - 70) * 0.3, 0, 70, 70 * 3), "[12]" },
86 { EINA_SIZE2D(-1, 150), EINA_SIZE2D(70, 70), 1, 0, 0.3, 0.7, 0, 0, 0, 0,
87 EFL_GFX_HINT_ASPECT_BOTH, EINA_SIZE2D(1, 3), EINA_TRUE, EINA_FALSE,
88 EINA_SIZE2D(300, 300), EINA_SIZE2D(300, 300),
89 EINA_RECT((300 - 70) * 0.3, (300 - 70 * 3) * 0.2, 70, 70 * 3), "[13]" },
90};
91
92static Hint hints2[][2] = {
93 {
94 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 1, 1, 0.3, 0.7, 0, 0, 0, 0,
95 EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_FALSE, EINA_FALSE,
96 EINA_SIZE2D(150, 300), EINA_SIZE2D(150, 300),
97 EINA_RECT((150 - 70) * 0.3, (150 - 70) * 0.7, 70, 70), "[1/1 weight btn]" },
98 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 1, 1, 0.8, 0.2, 0, 0, 0, 0,
99 EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_FALSE, EINA_FALSE,
100 EINA_SIZE2D(150, 300), EINA_SIZE2D(150, 300),
101 EINA_RECT((150 - 70) * 0.8, (150 - 70) * 0.2 + 150, 70, 70), "[1/1 weight btn2]" }
102 },
103 {
104 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 1, 0, 0.3, 0.7, 0, 0, 0, 0,
105 EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_FALSE, EINA_FALSE,
106 EINA_SIZE2D(150, 300), EINA_SIZE2D(150, 300),
107 EINA_RECT((150 - 70) * 0.3, 0, 70, 70), "[0/1 weight btn]" },
108 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 1, 1, 0.8, 0.2, 0, 0, 0, 0,
109 EFL_GFX_HINT_ASPECT_VERTICAL, EINA_SIZE2D(1, 3), EINA_TRUE, EINA_TRUE,
110 EINA_SIZE2D(150, 300), EINA_SIZE2D(150, 300),
111 EINA_RECT((150 - ((300 - 70) / 3)) * 0.8, 70, (300 - 70) / 3, (300 - 70)), "[0/1 weight btn2]" }
112 },
113 {
114 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 1, 0, 0.3, 0.7, 0, 0, 0, 0,
115 EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_FALSE, EINA_FALSE,
116 EINA_SIZE2D(150, 300), EINA_SIZE2D(150, 300),
117 EINA_RECT((150 - 70) * 0.3, (300 - 280) * 0.2, 70, 70), "[0/0 weight btn]" },
118 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 1, 0, 0.8, 0.2, 0, 0, 0, 0,
119 EFL_GFX_HINT_ASPECT_HORIZONTAL, EINA_SIZE2D(1, 3), EINA_TRUE, EINA_FALSE,
120 EINA_SIZE2D(150, 300), EINA_SIZE2D(150, 300),
121 EINA_RECT((150 - 70) * 0.8, (300 - 280) * 0.2 + 70, 70, 70 * 3), "[0/0 weight btn2]" }
122 },
123};
124
125static Hint hints3[][3] = {
126 {
127 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 1, 1, 0.3, 0.7, 0, 0, 0, 0,
128 EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_TRUE, EINA_TRUE,
129 EINA_SIZE2D(150, 300), EINA_SIZE2D(150, 300),
130 EINA_RECT(0, 0, 150, 100), "[1/1/1 weight_l btn]" },
131 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 100), 1, 1, 0.8, 0.2, 0, 0, 0, 0,
132 EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_TRUE, EINA_TRUE,
133 EINA_SIZE2D(150, 300), EINA_SIZE2D(150, 300),
134 EINA_RECT(0, 100, 150, 100), "[1/1/1 weight_l btn2]" },
135 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 1, 1, 0.8, 0.2, 0, 0, 0, 0,
136 EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_TRUE, EINA_TRUE,
137 EINA_SIZE2D(150, 300), EINA_SIZE2D(150, 300),
138 EINA_RECT(0, 100 + 100, 150, 100), "[1/1/1 weight_l btn3]" }
139 },
140 {
141 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 1, 1, 0.3, 0.7, 0, 0, 0, 0,
142 EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_TRUE, EINA_TRUE,
143 EINA_SIZE2D(150, 270), EINA_SIZE2D(150, 270),
144 EINA_RECT(0, 0, 150, 85), "[1/1/1 weight_m btn]" },
145 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 100), 1, 1, 0.8, 0.2, 0, 0, 0, 0,
146 EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_TRUE, EINA_TRUE,
147 EINA_SIZE2D(150, 270), EINA_SIZE2D(150, 270),
148 EINA_RECT(0, 85, 150, 100), "[1/1/1 weight_m btn2]" },
149 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 1, 1, 0.8, 0.2, 0, 0, 0, 0,
150 EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_TRUE, EINA_TRUE,
151 EINA_SIZE2D(150, 270), EINA_SIZE2D(150, 270),
152 EINA_RECT(0, 100 + 85, 150, 85), "[1/1/1 weight_m btn3]" }
153 },
154 {
155 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 1, 1, 0.3, 0.7, 0, 0, 0, 0,
156 EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_TRUE, EINA_TRUE,
157 EINA_SIZE2D(150, 200), EINA_SIZE2D(150, 200),
158 EINA_RECT(0, 0, 75, 100), "[1/1/1 weight_s btn]" },
159 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 100), 1, 1, 0.8, 0.2, 0, 0, 0, 0,
160 EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_TRUE, EINA_TRUE,
161 EINA_SIZE2D(150, 200), EINA_SIZE2D(150, 200),
162 EINA_RECT(0, 100, 75, 100), "[1/1/1 weight_s btn2]" },
163 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 1, 1, 0.8, 0.2, 0, 0, 0, 0,
164 EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_TRUE, EINA_TRUE,
165 EINA_SIZE2D(150, 200), EINA_SIZE2D(150, 200),
166 EINA_RECT(75, 0, 75, 200), "[1/1/1 weight_s btn3]" }
167 },
168 {
169 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(0, 0), 1, 1, 0.5, 0.5, 0, 0, 0, 0,
170 EFL_GFX_HINT_ASPECT_BOTH, EINA_SIZE2D(1, 3), EINA_TRUE, EINA_TRUE,
171 EINA_SIZE2D(300, 900), EINA_SIZE2D(300, 900),
172 EINA_RECT(100, 0, 100, 300), "[aspect resize btn]" },
173 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(0, 0), 1, 1, 0.5, 0.5, 0, 0, 0, 0,
174 EFL_GFX_HINT_ASPECT_BOTH, EINA_SIZE2D(1, 3), EINA_TRUE, EINA_TRUE,
175 EINA_SIZE2D(300, 900), EINA_SIZE2D(300, 900),
176 EINA_RECT(100, 300, 100, 300), "[aspect resize btn2]" },
177 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(0, 0), 1, 1, 0.5, 0.5, 0, 0, 0, 0,
178 EFL_GFX_HINT_ASPECT_BOTH, EINA_SIZE2D(1, 3), EINA_TRUE, EINA_TRUE,
179 EINA_SIZE2D(300, 900), EINA_SIZE2D(300, 900),
180 EINA_RECT(100, 300 + 300, 100, 300), "[aspect resize btn3]" }
181 },
182};
183
184static Eo *win, *layout;
185
186static void
187btn_hint_set(Eo *btn, Hint *hint)
188{
189 efl_gfx_entity_size_set(layout, hint->layout_size);
190 efl_gfx_hint_size_min_set(layout, hint->layout_size);
191 efl_gfx_hint_size_max_set(btn, hint->max);
192 efl_gfx_hint_size_min_set(btn, hint->min);
193 efl_gfx_hint_weight_set(btn, hint->weightx, hint->weighty);
194 efl_gfx_hint_align_set(btn, hint->alignx, hint->aligny);
195 efl_gfx_hint_fill_set(btn, hint->fillx, hint->filly);
196 efl_gfx_hint_aspect_set(btn, hint->mode, hint->aspect);
197 efl_canvas_group_calculate(layout);
198}
199
200static void
201btn_geom_assert(Hint *hint, Eina_Rect btn_geom)
202{
203 Eina_Size2D layout_size, layout_min;
204
205 layout_size = efl_gfx_entity_size_get(layout);
206 layout_min = efl_gfx_hint_size_combined_min_get(layout);
207 layout_size.w = layout_size.w > layout_min.w ? layout_size.w : layout_min.w;
208 layout_size.h = layout_size.h > layout_min.h ? layout_size.h : layout_min.h;
209
210 ck_assert_msg(GEOMETRY_EQ(btn_geom, hint->expected),
211 "Case %s failed... button geometry: (%d, %d, %d, %d) expected geometry: (%d, %d, %d, %d)",
212 hint->testname, btn_geom.x, btn_geom.y, btn_geom.w, btn_geom.h,
213 hint->expected.x, hint->expected.y, hint->expected.w, hint->expected.h);
214 ck_assert_msg(COORD_EQ(layout_size.w, hint->layout_expected.w) &&
215 COORD_EQ(layout_size.h, hint->layout_expected.h),
216 "Case %s failed... layout size: (%d, %d) expected size: (%d, %d)",
217 hint->testname, layout_size.w, layout_size.h,
218 hint->layout_expected.w, hint->layout_expected.h);
219}
220
221static void
222layout_setup()
223{
224 win = win_add();
225
226 layout = efl_add(EFL_UI_BOX_FLOW_CLASS, win,
227 efl_pack_align_set(efl_added, 0.8, 0.2),
228 efl_ui_direction_set(efl_added, EFL_UI_DIR_VERTICAL));
229}
230
231static void
232layout_teardown()
233{
234 if (win)
235 {
236 efl_del(win);
237 win = NULL;
238 }
239}
240
241EFL_START_TEST (efl_ui_box_flow_class_check)
242{
243 const char *class;
244
245 class = efl_class_name_get(layout);
246
247 ck_assert(class != NULL);
248 ck_assert(!strcmp(class, "Efl.Ui.Box_Flow"));
249}
250EFL_END_TEST
251
252EFL_START_TEST (efl_ui_box_flow_layout_update)
253{
254 int i, max_index = (sizeof(hints) / sizeof(Hint));
255
256 Eo *btn = efl_add(EFL_UI_BUTTON_CLASS, layout,
257 efl_pack_end(layout, efl_added));
258
259 for (i = 0; i < max_index; i++)
260 {
261 btn_hint_set(btn, &hints[i]);
262 btn_geom_assert(&hints[i], efl_gfx_entity_geometry_get(btn));
263 }
264}
265EFL_END_TEST
266
267EFL_START_TEST (efl_ui_box_flow_layout_update_pack)
268{
269 int i, max_index2, max_index3;
270 Eo *btn, *btn2, *btn3;
271
272 max_index2 = ((sizeof(hints2) / sizeof(Hint)) / 2);
273 max_index3 = ((sizeof(hints3) / sizeof(Hint)) / 3);
274
275 btn = efl_add(EFL_UI_BUTTON_CLASS, layout,
276 efl_pack_end(layout, efl_added));
277 btn2 = efl_add(EFL_UI_BUTTON_CLASS, layout,
278 efl_pack_end(layout, efl_added));
279
280 for (i = 0; i < max_index2; i++)
281 {
282 btn_hint_set(btn, &hints2[i][0]);
283 btn_hint_set(btn2, &hints2[i][1]);
284 btn_geom_assert(&hints2[i][0], efl_gfx_entity_geometry_get(btn));
285 btn_geom_assert(&hints2[i][1], efl_gfx_entity_geometry_get(btn2));
286 }
287
288 btn3 = efl_add(EFL_UI_BUTTON_CLASS, layout,
289 efl_pack_end(layout, efl_added));
290
291 for (i = 0; i < max_index3; i++)
292 {
293 btn_hint_set(btn, &hints3[i][0]);
294 btn_hint_set(btn2, &hints3[i][1]);
295 btn_hint_set(btn3, &hints3[i][2]);
296 btn_geom_assert(&hints3[i][0], efl_gfx_entity_geometry_get(btn));
297 btn_geom_assert(&hints3[i][1], efl_gfx_entity_geometry_get(btn2));
298 btn_geom_assert(&hints3[i][2], efl_gfx_entity_geometry_get(btn3));
299 }
300
301 // aspect resize test
302 hints3[3][0].layout_expected = hints3[3][0].layout_size = EINA_SIZE2D(150, 450);
303 hints3[3][1].layout_expected = hints3[3][1].layout_size = EINA_SIZE2D(150, 450);
304 hints3[3][2].layout_expected = hints3[3][2].layout_size = EINA_SIZE2D(150, 450);
305 hints3[3][0].expected = EINA_RECT(50, 0, 50, 150);
306 hints3[3][1].expected = EINA_RECT(50, 150, 50, 150);
307 hints3[3][2].expected = EINA_RECT(50, 300, 50, 150);
308
309 btn_hint_set(btn, &hints3[3][0]);
310 btn_hint_set(btn2, &hints3[3][1]);
311 btn_hint_set(btn3, &hints3[3][2]);
312 btn_geom_assert(&hints3[3][0], efl_gfx_entity_geometry_get(btn));
313 btn_geom_assert(&hints3[3][1], efl_gfx_entity_geometry_get(btn2));
314 btn_geom_assert(&hints3[3][2], efl_gfx_entity_geometry_get(btn3));
315
316 efl_ui_direction_set(layout, EFL_UI_DIR_HORIZONTAL);
317 hints3[3][0].layout_expected = hints3[3][0].layout_size = EINA_SIZE2D(300, 900);
318 hints3[3][1].layout_expected = hints3[3][1].layout_size = EINA_SIZE2D(300, 900);
319 hints3[3][2].layout_expected = hints3[3][2].layout_size = EINA_SIZE2D(300, 900);
320 hints3[3][0].expected = EINA_RECT(0, 300, 100, 300);
321 hints3[3][1].expected = EINA_RECT(100, 300, 100, 300);
322 hints3[3][2].expected = EINA_RECT(200, 300, 100, 300);
323
324 btn_hint_set(btn, &hints3[3][0]);
325 btn_hint_set(btn2, &hints3[3][1]);
326 btn_hint_set(btn3, &hints3[3][2]);
327 btn_geom_assert(&hints3[3][0], efl_gfx_entity_geometry_get(btn));
328 btn_geom_assert(&hints3[3][1], efl_gfx_entity_geometry_get(btn2));
329 btn_geom_assert(&hints3[3][2], efl_gfx_entity_geometry_get(btn3));
330
331 hints3[3][0].layout_expected = hints3[3][0].layout_size = EINA_SIZE2D(150, 450);
332 hints3[3][1].layout_expected = hints3[3][1].layout_size = EINA_SIZE2D(150, 450);
333 hints3[3][2].layout_expected = hints3[3][2].layout_size = EINA_SIZE2D(150, 450);
334 hints3[3][0].expected = EINA_RECT(0, 150, 50, 150);
335 hints3[3][1].expected = EINA_RECT(50, 150, 50, 150);
336 hints3[3][2].expected = EINA_RECT(100, 150, 50, 150);
337
338 btn_hint_set(btn, &hints3[3][0]);
339 btn_hint_set(btn2, &hints3[3][1]);
340 btn_hint_set(btn3, &hints3[3][2]);
341 btn_geom_assert(&hints3[3][0], efl_gfx_entity_geometry_get(btn));
342 btn_geom_assert(&hints3[3][1], efl_gfx_entity_geometry_get(btn2));
343 btn_geom_assert(&hints3[3][2], efl_gfx_entity_geometry_get(btn3));
344}
345EFL_END_TEST
346
347EFL_START_TEST (efl_ui_box_flow_size)
348{
349#define USERMIN_CHECK(a, b) \
350 efl_canvas_group_calculate(layout); \
351 user_min = efl_gfx_hint_size_min_get(layout); \
352 ck_assert_msg(COORD_EQ(user_min.w, (a)) && COORD_EQ(user_min.h, (b)), \
353 "Case box_size failed... user_min: (%d, %d) expected user_min: (%d, %d)", \
354 user_min.w, user_min.h, (a), (b));
355
356#define MIN_CHECK(a, b) \
357 efl_canvas_group_calculate(layout); \
358 min = efl_gfx_hint_size_combined_min_get(layout); \
359 ck_assert_msg(COORD_EQ(min.w, (a)) && COORD_EQ(min.h, (b)), \
360 "Case box_size failed... min: (%d, %d) expected min: (%d, %d)", \
361 min.w, min.h, (a), (b));
362
363 Eo *btn, *btn2, *btn3;
364 Eina_Size2D min, user_min;
365
366 btn = efl_add(EFL_UI_BUTTON_CLASS, layout,
367 efl_gfx_hint_size_min_set(efl_added, EINA_SIZE2D(100, 100)),
368 efl_pack_end(layout, efl_added));
369
370 USERMIN_CHECK(0, 0);
371 MIN_CHECK(100, 100);
372
373 btn2 = efl_add(EFL_UI_BUTTON_CLASS, layout,
374 efl_gfx_hint_size_min_set(efl_added, EINA_SIZE2D(100, 100)),
375 efl_pack_end(layout, efl_added));
376 btn3 = efl_add(EFL_UI_BUTTON_CLASS, layout,
377 efl_gfx_hint_size_min_set(efl_added, EINA_SIZE2D(100, 100)),
378 efl_pack_end(layout, efl_added));
379 USERMIN_CHECK(0, 0);
380 MIN_CHECK(300, 100);
381
382 efl_pack_unpack(layout, btn2);
383 USERMIN_CHECK(0, 0);
384 MIN_CHECK(200, 100);
385
386 efl_pack_unpack(layout, btn3);
387 USERMIN_CHECK(0, 0);
388 MIN_CHECK(100, 100);
389
390 efl_pack_unpack(layout, btn);
391 USERMIN_CHECK(0, 0);
392 MIN_CHECK(0, 0);
393
394 efl_pack_end(layout, btn);
395 efl_gfx_hint_size_min_set(layout, EINA_SIZE2D(200, 200));
396 USERMIN_CHECK(200, 200);
397 MIN_CHECK(200, 200);
398
399 efl_pack_end(layout, btn2);
400 efl_pack_end(layout, btn3);
401 USERMIN_CHECK(200, 200);
402 MIN_CHECK(300, 200);
403
404#undef USERMIN_ASSERT
405#undef MIN_ASSERT
406}
407EFL_END_TEST
408
409void efl_ui_test_box_flow(TCase *tc)
410{
411 tcase_add_checked_fixture(tc, layout_setup, layout_teardown);
412 tcase_add_test(tc, efl_ui_box_flow_class_check);
413 tcase_add_test(tc, efl_ui_box_flow_layout_update);
414 tcase_add_test(tc, efl_ui_box_flow_layout_update_pack);
415 tcase_add_test(tc, efl_ui_box_flow_size);
416}
diff --git a/src/tests/elementary/meson.build b/src/tests/elementary/meson.build
index eaffab6d6b..8ff6298917 100644
--- a/src/tests/elementary/meson.build
+++ b/src/tests/elementary/meson.build
@@ -123,6 +123,7 @@ efl_ui_suite_src = [
123 'efl_ui_test_focus.c', 123 'efl_ui_test_focus.c',
124 'efl_ui_test_focus_sub.c', 124 'efl_ui_test_focus_sub.c',
125 'efl_ui_test_box.c', 125 'efl_ui_test_box.c',
126 'efl_ui_test_box_flow.c',
126 'efl_ui_test_table.c', 127 'efl_ui_test_table.c',
127 'efl_ui_test_grid.c', 128 'efl_ui_test_grid.c',
128 'efl_ui_test_relative_layout.c', 129 'efl_ui_test_relative_layout.c',