Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/tests/scene/test_flow_container.cpp
59209 views
1
/**************************************************************************/
2
/* test_flow_container.cpp */
3
/**************************************************************************/
4
/* This file is part of: */
5
/* GODOT ENGINE */
6
/* https://godotengine.org */
7
/**************************************************************************/
8
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10
/* */
11
/* Permission is hereby granted, free of charge, to any person obtaining */
12
/* a copy of this software and associated documentation files (the */
13
/* "Software"), to deal in the Software without restriction, including */
14
/* without limitation the rights to use, copy, modify, merge, publish, */
15
/* distribute, sublicense, and/or sell copies of the Software, and to */
16
/* permit persons to whom the Software is furnished to do so, subject to */
17
/* the following conditions: */
18
/* */
19
/* The above copyright notice and this permission notice shall be */
20
/* included in all copies or substantial portions of the Software. */
21
/* */
22
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29
/**************************************************************************/
30
31
#include "tests/test_macros.h"
32
33
TEST_FORCE_LINK(test_flow_container)
34
35
#include "scene/gui/control.h"
36
#include "scene/gui/flow_container.h"
37
#include "scene/main/scene_tree.h"
38
#include "scene/main/window.h"
39
40
namespace TestFlowContainer {
41
42
TEST_CASE("[SceneTree][FlowContainer] HFlowContainer") {
43
HFlowContainer *hflow_container = memnew(HFlowContainer);
44
Window *root = SceneTree::get_singleton()->get_root();
45
root->add_child(hflow_container);
46
47
hflow_container->add_theme_constant_override("h_separation", 0);
48
hflow_container->add_theme_constant_override("v_separation", 0);
49
hflow_container->set_size(Size2(100, 100));
50
SceneTree::get_singleton()->process(0);
51
52
SUBCASE("Default behavior") {
53
Control *child_control_1 = memnew(Control);
54
Control *child_control_2 = memnew(Control);
55
Control *child_control_3 = memnew(Control);
56
child_control_1->set_custom_minimum_size(Size2(20, 10));
57
child_control_2->set_custom_minimum_size(Size2(20, 10));
58
child_control_3->set_custom_minimum_size(Size2(20, 10));
59
hflow_container->add_child(child_control_1);
60
hflow_container->add_child(child_control_2);
61
hflow_container->add_child(child_control_3);
62
SceneTree::get_singleton()->process(0);
63
64
CHECK_MESSAGE(
65
hflow_container->get_alignment() == FlowContainer::ALIGNMENT_BEGIN,
66
"HFlowContainer alignment is set to ALIGNMENT_BEGIN by default.");
67
68
CHECK_MESSAGE(
69
hflow_container->get_last_wrap_alignment() == FlowContainer::LAST_WRAP_ALIGNMENT_INHERIT,
70
"HFlowContainer last wrap alignment is set to LAST_WRAP_ALIGNMENT_INHERIT by default.");
71
72
CHECK_MESSAGE(
73
!hflow_container->is_vertical(),
74
"HFlowContainer is horizontal.");
75
76
CHECK_MESSAGE(
77
!hflow_container->is_reverse_fill(),
78
"HFlowContainer reverse fill is disabled by default.");
79
80
CHECK_MESSAGE(
81
hflow_container->get_line_count() == 1,
82
"HFlowContainer keeps all children in one line when there is enough horizontal space.");
83
84
CHECK_MESSAGE(
85
hflow_container->get_line_max_child_count() == 3,
86
"HFlowContainer reports the child count of the first line.");
87
88
CHECK_MESSAGE(
89
child_control_1->get_position().is_equal_approx(Point2(0, 0)),
90
"First child control is positioned at the beginning of the line.");
91
92
CHECK_MESSAGE(
93
child_control_2->get_position().is_equal_approx(Point2(20, 0)),
94
"Second child control is placed after the first child control.");
95
96
CHECK_MESSAGE(
97
child_control_3->get_position().is_equal_approx(Point2(40, 0)),
98
"Third child control is placed after the second child control.");
99
100
memdelete(child_control_3);
101
memdelete(child_control_2);
102
memdelete(child_control_1);
103
}
104
105
SUBCASE("Wrapping and last wrap alignment") {
106
Control *child_control_1 = memnew(Control);
107
Control *child_control_2 = memnew(Control);
108
Control *child_control_3 = memnew(Control);
109
child_control_1->set_custom_minimum_size(Size2(20, 10));
110
child_control_2->set_custom_minimum_size(Size2(20, 10));
111
child_control_3->set_custom_minimum_size(Size2(20, 10));
112
hflow_container->set_size(Size2(50, 100));
113
hflow_container->add_child(child_control_1);
114
hflow_container->add_child(child_control_2);
115
hflow_container->add_child(child_control_3);
116
SceneTree::get_singleton()->process(0);
117
118
CHECK_MESSAGE(
119
hflow_container->get_line_count() == 2,
120
"HFlowContainer wraps children to a second line when they no longer fit.");
121
122
CHECK_MESSAGE(
123
hflow_container->get_line_max_child_count() == 2,
124
"HFlowContainer reports the first line child count as the line max child count.");
125
126
CHECK_MESSAGE(
127
child_control_1->get_position().is_equal_approx(Point2(0, 0)),
128
"First child control starts at the first line origin.");
129
130
CHECK_MESSAGE(
131
child_control_2->get_position().is_equal_approx(Point2(20, 0)),
132
"Second child control remains on the first line.");
133
134
CHECK_MESSAGE(
135
child_control_3->get_position().is_equal_approx(Point2(0, 10)),
136
"Third child control wraps to the second line.");
137
138
hflow_container->set_last_wrap_alignment(FlowContainer::LAST_WRAP_ALIGNMENT_CENTER);
139
SceneTree::get_singleton()->process(0);
140
141
CHECK_MESSAGE(
142
child_control_3->get_position().is_equal_approx(Point2(10, 10)),
143
"Last wrapped line is centered relative to the previous line when LAST_WRAP_ALIGNMENT_CENTER is used.");
144
145
hflow_container->set_last_wrap_alignment(FlowContainer::LAST_WRAP_ALIGNMENT_END);
146
SceneTree::get_singleton()->process(0);
147
148
CHECK_MESSAGE(
149
child_control_3->get_position().is_equal_approx(Point2(20, 10)),
150
"Last wrapped line is aligned to the end relative to the previous line when LAST_WRAP_ALIGNMENT_END is used.");
151
152
memdelete(child_control_3);
153
memdelete(child_control_2);
154
memdelete(child_control_1);
155
}
156
157
SUBCASE("Alignment and RTL") {
158
Control *child_control_1 = memnew(Control);
159
Control *child_control_2 = memnew(Control);
160
child_control_1->set_custom_minimum_size(Size2(20, 10));
161
child_control_2->set_custom_minimum_size(Size2(20, 10));
162
hflow_container->set_size(Size2(100, 100));
163
hflow_container->add_child(child_control_1);
164
hflow_container->add_child(child_control_2);
165
SceneTree::get_singleton()->process(0);
166
167
hflow_container->set_alignment(FlowContainer::ALIGNMENT_CENTER);
168
SceneTree::get_singleton()->process(0);
169
170
CHECK_MESSAGE(
171
child_control_1->get_position().is_equal_approx(Point2(30, 0)),
172
"First child control is centered when ALIGNMENT_CENTER is used.");
173
174
CHECK_MESSAGE(
175
child_control_2->get_position().is_equal_approx(Point2(50, 0)),
176
"Second child control follows centered alignment when ALIGNMENT_CENTER is used.");
177
178
hflow_container->set_alignment(FlowContainer::ALIGNMENT_END);
179
SceneTree::get_singleton()->process(0);
180
181
CHECK_MESSAGE(
182
child_control_1->get_position().is_equal_approx(Point2(60, 0)),
183
"First child control is aligned to the end when ALIGNMENT_END is used.");
184
185
CHECK_MESSAGE(
186
child_control_2->get_position().is_equal_approx(Point2(80, 0)),
187
"Second child control is aligned to the end when ALIGNMENT_END is used.");
188
189
hflow_container->set_alignment(FlowContainer::ALIGNMENT_BEGIN);
190
hflow_container->set_layout_direction(Control::LAYOUT_DIRECTION_RTL);
191
SceneTree::get_singleton()->process(0);
192
193
CHECK_MESSAGE(
194
child_control_1->get_position().is_equal_approx(Point2(80, 0)),
195
"First child control starts at the right edge in RTL mode with ALIGNMENT_BEGIN.");
196
197
CHECK_MESSAGE(
198
child_control_2->get_position().is_equal_approx(Point2(60, 0)),
199
"Second child control follows right-to-left ordering in RTL mode with ALIGNMENT_BEGIN.");
200
201
memdelete(child_control_2);
202
memdelete(child_control_1);
203
}
204
205
SUBCASE("Expanding children and stretch ratio") {
206
Control *child_control_1 = memnew(Control);
207
Control *child_control_2 = memnew(Control);
208
child_control_1->set_custom_minimum_size(Size2(20, 10));
209
child_control_2->set_custom_minimum_size(Size2(20, 10));
210
child_control_1->set_h_size_flags(Control::SIZE_EXPAND_FILL);
211
child_control_2->set_h_size_flags(Control::SIZE_EXPAND_FILL);
212
hflow_container->set_size(Size2(100, 100));
213
hflow_container->add_child(child_control_1);
214
hflow_container->add_child(child_control_2);
215
SceneTree::get_singleton()->process(0);
216
217
CHECK_MESSAGE(
218
child_control_1->get_size().is_equal_approx(Size2(50, 10)),
219
"First child control expands to half of the available width when both children have equal stretch ratio.");
220
221
CHECK_MESSAGE(
222
child_control_2->get_size().is_equal_approx(Size2(50, 10)),
223
"Second child control expands to half of the available width when both children have equal stretch ratio.");
224
225
CHECK_MESSAGE(
226
child_control_2->get_position().is_equal_approx(Point2(50, 0)),
227
"Second child control is placed immediately after the first expanded child control.");
228
229
child_control_2->set_stretch_ratio(3.0f);
230
SceneTree::get_singleton()->process(0);
231
232
CHECK_MESSAGE(
233
child_control_1->get_size().is_equal_approx(Size2(35, 10)),
234
"First child control receives less width when its stretch ratio is lower.");
235
236
CHECK_MESSAGE(
237
child_control_2->get_size().is_equal_approx(Size2(65, 10)),
238
"Second child control receives more width when its stretch ratio is higher.");
239
240
CHECK_MESSAGE(
241
child_control_2->get_position().is_equal_approx(Point2(35, 0)),
242
"Second child control starts after the first child control's stretched width.");
243
244
memdelete(child_control_2);
245
memdelete(child_control_1);
246
}
247
248
SUBCASE("Reverse fill") {
249
Control *child_control_1 = memnew(Control);
250
Control *child_control_2 = memnew(Control);
251
Control *child_control_3 = memnew(Control);
252
child_control_1->set_custom_minimum_size(Size2(20, 10));
253
child_control_2->set_custom_minimum_size(Size2(20, 10));
254
child_control_3->set_custom_minimum_size(Size2(20, 10));
255
hflow_container->set_size(Size2(50, 100));
256
hflow_container->add_child(child_control_1);
257
hflow_container->add_child(child_control_2);
258
hflow_container->add_child(child_control_3);
259
SceneTree::get_singleton()->process(0);
260
261
CHECK_MESSAGE(
262
child_control_1->get_position().is_equal_approx(Point2(0, 0)),
263
"First child control starts at the top row by default.");
264
265
CHECK_MESSAGE(
266
child_control_3->get_position().is_equal_approx(Point2(0, 10)),
267
"Third child control wraps to the next row by default.");
268
269
hflow_container->set_reverse_fill(true);
270
SceneTree::get_singleton()->process(0);
271
272
CHECK_MESSAGE(
273
child_control_1->get_position().is_equal_approx(Point2(0, 90)),
274
"First child control moves to the bottom row when reverse fill is enabled.");
275
276
CHECK_MESSAGE(
277
child_control_2->get_position().is_equal_approx(Point2(20, 90)),
278
"Second child control remains in the same row as the first child control when reverse fill is enabled.");
279
280
CHECK_MESSAGE(
281
child_control_3->get_position().is_equal_approx(Point2(0, 80)),
282
"Wrapped row order is inverted from bottom to top when reverse fill is enabled.");
283
284
hflow_container->set_layout_direction(Control::LAYOUT_DIRECTION_RTL);
285
SceneTree::get_singleton()->process(0);
286
287
CHECK_MESSAGE(
288
child_control_1->get_position().is_equal_approx(Point2(30, 90)),
289
"RTL mirrors horizontal placement while reverse fill keeps rows bottom to top.");
290
291
CHECK_MESSAGE(
292
child_control_2->get_position().is_equal_approx(Point2(10, 90)),
293
"Second child control follows mirrored RTL order while reverse fill remains enabled.");
294
295
CHECK_MESSAGE(
296
child_control_3->get_position().is_equal_approx(Point2(30, 80)),
297
"Wrapped child control is mirrored in RTL while keeping reverse-filled row order.");
298
299
memdelete(child_control_3);
300
memdelete(child_control_2);
301
memdelete(child_control_1);
302
}
303
304
memdelete(hflow_container);
305
}
306
307
TEST_CASE("[SceneTree][FlowContainer] VFlowContainer") {
308
VFlowContainer *vflow_container = memnew(VFlowContainer);
309
Window *root = SceneTree::get_singleton()->get_root();
310
root->add_child(vflow_container);
311
312
vflow_container->add_theme_constant_override("h_separation", 0);
313
vflow_container->add_theme_constant_override("v_separation", 0);
314
vflow_container->set_size(Size2(100, 100));
315
SceneTree::get_singleton()->process(0);
316
317
SUBCASE("Default behavior") {
318
Control *child_control_1 = memnew(Control);
319
Control *child_control_2 = memnew(Control);
320
Control *child_control_3 = memnew(Control);
321
child_control_1->set_custom_minimum_size(Size2(20, 10));
322
child_control_2->set_custom_minimum_size(Size2(20, 10));
323
child_control_3->set_custom_minimum_size(Size2(20, 10));
324
vflow_container->add_child(child_control_1);
325
vflow_container->add_child(child_control_2);
326
vflow_container->add_child(child_control_3);
327
SceneTree::get_singleton()->process(0);
328
329
CHECK_MESSAGE(
330
vflow_container->get_alignment() == FlowContainer::ALIGNMENT_BEGIN,
331
"VFlowContainer alignment is set to ALIGNMENT_BEGIN by default.");
332
333
CHECK_MESSAGE(
334
vflow_container->get_last_wrap_alignment() == FlowContainer::LAST_WRAP_ALIGNMENT_INHERIT,
335
"VFlowContainer last wrap alignment is set to LAST_WRAP_ALIGNMENT_INHERIT by default.");
336
337
CHECK_MESSAGE(
338
vflow_container->is_vertical(),
339
"VFlowContainer is vertical.");
340
341
CHECK_MESSAGE(
342
!vflow_container->is_reverse_fill(),
343
"VFlowContainer reverse fill is disabled by default.");
344
345
CHECK_MESSAGE(
346
vflow_container->get_line_count() == 1,
347
"VFlowContainer keeps all children in one column when there is enough vertical space.");
348
349
CHECK_MESSAGE(
350
vflow_container->get_line_max_child_count() == 3,
351
"VFlowContainer reports the child count of the first column.");
352
353
CHECK_MESSAGE(
354
child_control_1->get_position().is_equal_approx(Point2(0, 0)),
355
"First child control is positioned at the top of the first column.");
356
357
CHECK_MESSAGE(
358
child_control_2->get_position().is_equal_approx(Point2(0, 10)),
359
"Second child control is placed below the first child control.");
360
361
CHECK_MESSAGE(
362
child_control_3->get_position().is_equal_approx(Point2(0, 20)),
363
"Third child control is placed below the second child control.");
364
365
memdelete(child_control_3);
366
memdelete(child_control_2);
367
memdelete(child_control_1);
368
}
369
370
SUBCASE("Wrapping and last wrap alignment") {
371
Control *child_control_1 = memnew(Control);
372
Control *child_control_2 = memnew(Control);
373
Control *child_control_3 = memnew(Control);
374
child_control_1->set_custom_minimum_size(Size2(20, 20));
375
child_control_2->set_custom_minimum_size(Size2(20, 20));
376
child_control_3->set_custom_minimum_size(Size2(20, 20));
377
vflow_container->set_size(Size2(100, 50));
378
vflow_container->add_child(child_control_1);
379
vflow_container->add_child(child_control_2);
380
vflow_container->add_child(child_control_3);
381
SceneTree::get_singleton()->process(0);
382
383
CHECK_MESSAGE(
384
vflow_container->get_line_count() == 2,
385
"VFlowContainer wraps children to a second column when they no longer fit vertically.");
386
387
CHECK_MESSAGE(
388
vflow_container->get_line_max_child_count() == 2,
389
"VFlowContainer reports the first column child count as the line max child count.");
390
391
CHECK_MESSAGE(
392
child_control_1->get_position().is_equal_approx(Point2(0, 0)),
393
"First child control starts at the first column origin.");
394
395
CHECK_MESSAGE(
396
child_control_2->get_position().is_equal_approx(Point2(0, 20)),
397
"Second child control remains in the first column.");
398
399
CHECK_MESSAGE(
400
child_control_3->get_position().is_equal_approx(Point2(20, 0)),
401
"Third child control wraps to the second column.");
402
403
vflow_container->set_last_wrap_alignment(FlowContainer::LAST_WRAP_ALIGNMENT_CENTER);
404
SceneTree::get_singleton()->process(0);
405
406
CHECK_MESSAGE(
407
child_control_3->get_position().is_equal_approx(Point2(20, 10)),
408
"Last wrapped column is centered relative to the previous column when LAST_WRAP_ALIGNMENT_CENTER is used.");
409
410
vflow_container->set_last_wrap_alignment(FlowContainer::LAST_WRAP_ALIGNMENT_END);
411
SceneTree::get_singleton()->process(0);
412
413
CHECK_MESSAGE(
414
child_control_3->get_position().is_equal_approx(Point2(20, 20)),
415
"Last wrapped column is aligned to the end relative to the previous column when LAST_WRAP_ALIGNMENT_END is used.");
416
417
memdelete(child_control_3);
418
memdelete(child_control_2);
419
memdelete(child_control_1);
420
}
421
422
SUBCASE("Alignment and RTL") {
423
Control *child_control_1 = memnew(Control);
424
Control *child_control_2 = memnew(Control);
425
child_control_1->set_custom_minimum_size(Size2(20, 20));
426
child_control_2->set_custom_minimum_size(Size2(20, 20));
427
vflow_container->set_size(Size2(100, 100));
428
vflow_container->add_child(child_control_1);
429
vflow_container->add_child(child_control_2);
430
SceneTree::get_singleton()->process(0);
431
432
vflow_container->set_alignment(FlowContainer::ALIGNMENT_CENTER);
433
SceneTree::get_singleton()->process(0);
434
435
CHECK_MESSAGE(
436
child_control_1->get_position().is_equal_approx(Point2(0, 30)),
437
"First child control is vertically centered when ALIGNMENT_CENTER is used.");
438
439
CHECK_MESSAGE(
440
child_control_2->get_position().is_equal_approx(Point2(0, 50)),
441
"Second child control follows centered vertical alignment when ALIGNMENT_CENTER is used.");
442
443
vflow_container->set_alignment(FlowContainer::ALIGNMENT_END);
444
SceneTree::get_singleton()->process(0);
445
446
CHECK_MESSAGE(
447
child_control_1->get_position().is_equal_approx(Point2(0, 60)),
448
"First child control is aligned to the bottom when ALIGNMENT_END is used.");
449
450
CHECK_MESSAGE(
451
child_control_2->get_position().is_equal_approx(Point2(0, 80)),
452
"Second child control is aligned to the bottom when ALIGNMENT_END is used.");
453
454
vflow_container->set_alignment(FlowContainer::ALIGNMENT_BEGIN);
455
vflow_container->set_layout_direction(Control::LAYOUT_DIRECTION_RTL);
456
SceneTree::get_singleton()->process(0);
457
458
CHECK_MESSAGE(
459
child_control_1->get_position().is_equal_approx(Point2(80, 0)),
460
"First child control moves to the right edge in RTL mode with vertical flow.");
461
462
CHECK_MESSAGE(
463
child_control_2->get_position().is_equal_approx(Point2(80, 20)),
464
"Second child control follows RTL horizontal mirroring in vertical flow.");
465
466
memdelete(child_control_2);
467
memdelete(child_control_1);
468
}
469
470
SUBCASE("Expanding children and stretch ratio") {
471
Control *child_control_1 = memnew(Control);
472
Control *child_control_2 = memnew(Control);
473
child_control_1->set_custom_minimum_size(Size2(20, 20));
474
child_control_2->set_custom_minimum_size(Size2(20, 20));
475
child_control_1->set_v_size_flags(Control::SIZE_EXPAND_FILL);
476
child_control_2->set_v_size_flags(Control::SIZE_EXPAND_FILL);
477
vflow_container->set_size(Size2(100, 100));
478
vflow_container->add_child(child_control_1);
479
vflow_container->add_child(child_control_2);
480
SceneTree::get_singleton()->process(0);
481
482
CHECK_MESSAGE(
483
child_control_1->get_size().is_equal_approx(Size2(20, 50)),
484
"First child control expands to half of the available height when both children have equal stretch ratio.");
485
486
CHECK_MESSAGE(
487
child_control_2->get_size().is_equal_approx(Size2(20, 50)),
488
"Second child control expands to half of the available height when both children have equal stretch ratio.");
489
490
CHECK_MESSAGE(
491
child_control_2->get_position().is_equal_approx(Point2(0, 50)),
492
"Second child control is placed immediately after the first expanded child control.");
493
494
child_control_2->set_stretch_ratio(3.0f);
495
SceneTree::get_singleton()->process(0);
496
497
CHECK_MESSAGE(
498
child_control_1->get_size().is_equal_approx(Size2(20, 35)),
499
"First child control receives less height when its stretch ratio is lower.");
500
501
CHECK_MESSAGE(
502
child_control_2->get_size().is_equal_approx(Size2(20, 65)),
503
"Second child control receives more height when its stretch ratio is higher.");
504
505
CHECK_MESSAGE(
506
child_control_2->get_position().is_equal_approx(Point2(0, 35)),
507
"Second child control starts after the first child control's stretched height.");
508
509
memdelete(child_control_2);
510
memdelete(child_control_1);
511
}
512
513
SUBCASE("Reverse fill") {
514
Control *child_control_1 = memnew(Control);
515
Control *child_control_2 = memnew(Control);
516
Control *child_control_3 = memnew(Control);
517
child_control_1->set_custom_minimum_size(Size2(20, 20));
518
child_control_2->set_custom_minimum_size(Size2(20, 20));
519
child_control_3->set_custom_minimum_size(Size2(20, 20));
520
vflow_container->set_size(Size2(100, 30));
521
vflow_container->add_child(child_control_1);
522
vflow_container->add_child(child_control_2);
523
vflow_container->add_child(child_control_3);
524
SceneTree::get_singleton()->process(0);
525
526
CHECK_MESSAGE(
527
child_control_1->get_position().is_equal_approx(Point2(0, 0)),
528
"First child control starts in the first column by default.");
529
530
CHECK_MESSAGE(
531
child_control_2->get_position().is_equal_approx(Point2(20, 0)),
532
"Second child control starts in the second column by default.");
533
534
CHECK_MESSAGE(
535
child_control_3->get_position().is_equal_approx(Point2(40, 0)),
536
"Third child control starts in the third column by default.");
537
538
vflow_container->set_reverse_fill(true);
539
SceneTree::get_singleton()->process(0);
540
541
CHECK_MESSAGE(
542
child_control_1->get_position().is_equal_approx(Point2(80, 0)),
543
"First child control starts from the right when reverse fill is enabled in vertical mode.");
544
545
CHECK_MESSAGE(
546
child_control_2->get_position().is_equal_approx(Point2(60, 0)),
547
"Second child control follows right-to-left column filling when reverse fill is enabled.");
548
549
CHECK_MESSAGE(
550
child_control_3->get_position().is_equal_approx(Point2(40, 0)),
551
"Third child control continues right-to-left column filling when reverse fill is enabled.");
552
553
vflow_container->set_layout_direction(Control::LAYOUT_DIRECTION_RTL);
554
SceneTree::get_singleton()->process(0);
555
556
CHECK_MESSAGE(
557
child_control_1->get_position().is_equal_approx(Point2(0, 0)),
558
"Vertical flow with RTL and reverse fill fills columns from left to right.");
559
560
CHECK_MESSAGE(
561
child_control_2->get_position().is_equal_approx(Point2(20, 0)),
562
"Second child control follows left-to-right order in vertical mode with RTL and reverse fill.");
563
564
CHECK_MESSAGE(
565
child_control_3->get_position().is_equal_approx(Point2(40, 0)),
566
"Third child control follows left-to-right order in vertical mode with RTL and reverse fill.");
567
568
memdelete(child_control_3);
569
memdelete(child_control_2);
570
memdelete(child_control_1);
571
}
572
573
memdelete(vflow_container);
574
}
575
576
} // namespace TestFlowContainer
577
578