@@ -920,6 +920,89 @@ LTEST_DECLARE(anchor_right_margin2)
920
920
LTEST_VEC4EQ (lay_get_rect (ctx , child ), 40 , 40 , 50 , 50 );
921
921
}
922
922
923
+ // issue #15
924
+ LTEST_DECLARE (child_expands_container1 )
925
+ {
926
+ lay_id root = lay_item (ctx );
927
+ lay_set_size_xy (ctx , root , 1 , 100 );
928
+
929
+ lay_id row = lay_item (ctx );
930
+ lay_set_contain (ctx , row , LAY_ROW );
931
+ lay_insert (ctx , root , row );
932
+
933
+ lay_id child = lay_item (ctx );
934
+ lay_set_size_xy (ctx , child , 1 , 50 );
935
+ lay_set_margins_ltrb (ctx , child , 0 , 0 , 0 , 10 );
936
+ lay_insert (ctx , row , child );
937
+
938
+ lay_run_context (ctx );
939
+ lay_vec4 root_rect = lay_get_rect (ctx , root );
940
+ lay_vec4 row_rect = lay_get_rect (ctx , row );
941
+ lay_vec4 child_rect = lay_get_rect (ctx , child );
942
+
943
+ LTEST_VEC4EQ (root_rect , 0 , 0 , 1 , 100 );
944
+ LTEST_VEC4EQ (row_rect , 0 , 20 , 1 , 60 );
945
+ LTEST_VEC4EQ (child_rect , 0 , 20 , 1 , 50 );
946
+ }
947
+
948
+ // issue #15
949
+ LTEST_DECLARE (child_expands_container2 )
950
+ {
951
+ lay_id root = lay_item (ctx );
952
+ lay_set_size_xy (ctx , root , 400 , 400 );
953
+ lay_set_margins_ltrb (ctx , root , 50 , 50 , 50 , 50 );
954
+ lay_set_contain (ctx , root , LAY_COLUMN | LAY_WRAP );
955
+
956
+ lay_id child1 = lay_item (ctx );
957
+ lay_set_size_xy (ctx , child1 , 50 , 50 );
958
+ lay_set_margins_ltrb (ctx , child1 , 5 , 5 , 5 , 5 );
959
+ lay_insert (ctx , root , child1 );
960
+
961
+ lay_id child2 = lay_item (ctx );
962
+ lay_set_size_xy (ctx , child2 , 50 , 50 );
963
+ lay_set_margins_ltrb (ctx , child2 , 5 , 5 , 5 , 5 );
964
+ lay_insert (ctx , root , child2 );
965
+
966
+ lay_run_context (ctx );
967
+
968
+ lay_vec4 root_rect = lay_get_rect (ctx , root );
969
+ lay_vec4 child1_rect = lay_get_rect (ctx , child1 );
970
+ lay_vec4 child2_rect = lay_get_rect (ctx , child2 );
971
+
972
+ LTEST_VEC4EQ (root_rect , 50 , 50 , 60 , 400 );
973
+ LTEST_VEC4EQ (child1_rect , 55 , 195 , 50 , 50 );
974
+ LTEST_VEC4EQ (child2_rect , 55 , 255 , 50 , 50 );
975
+ }
976
+
977
+ // issue #20
978
+ LTEST_DECLARE (column_wrap_grandson )
979
+ {
980
+ lay_id root = lay_item (ctx );
981
+ lay_set_size_xy (ctx , root , 200 , 200 );
982
+ lay_set_margins_ltrb (ctx , root , 50 , 50 , 50 , 50 );
983
+ lay_set_contain (ctx , root , LAY_WRAP | LAY_COLUMN );
984
+
985
+ lay_id child1 = lay_item (ctx );
986
+ lay_set_size_xy (ctx , child1 , 50 , 50 );
987
+ lay_set_margins_ltrb (ctx , child1 , 5 , 5 , 5 , 5 );
988
+ lay_insert (ctx , root , child1 );
989
+
990
+ lay_id child2 = lay_item (ctx );
991
+ lay_set_size_xy (ctx , child2 , 50 , 50 );
992
+ lay_set_margins_ltrb (ctx , child2 , 5 , 5 , 5 , 5 );
993
+ lay_insert (ctx , child1 , child2 );
994
+
995
+ lay_run_context (ctx );
996
+
997
+ lay_vec4 root_rect = lay_get_rect (ctx , root );
998
+ lay_vec4 child1_rect = lay_get_rect (ctx , child1 );
999
+ lay_vec4 child2_rect = lay_get_rect (ctx , child2 );
1000
+
1001
+ LTEST_VEC4EQ (root_rect , 50 , 50 , 60 , 200 );
1002
+ LTEST_VEC4EQ (child1_rect , 55 , 125 , 50 , 50 );
1003
+ LTEST_VEC4EQ (child2_rect , 60 , 130 , 50 , 50 );
1004
+ }
1005
+
923
1006
// Call in main to run a test by name
924
1007
//
925
1008
// Resets string buffer and lay context before running test
@@ -966,6 +1049,9 @@ int main(int argc, char** argv)
966
1049
LTEST_RUN (wrap_column_4 );
967
1050
LTEST_RUN (anchor_right_margin1 );
968
1051
LTEST_RUN (anchor_right_margin2 );
1052
+ LTEST_RUN (child_expands_container1 );
1053
+ LTEST_RUN (child_expands_container2 );
1054
+ LTEST_RUN (column_wrap_grandson );
969
1055
970
1056
printf ("Finished tests\n" );
971
1057
0 commit comments