diff --git a/.gitignore b/.gitignore index fca97a4b..65f01a65 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,12 @@ # Visual studio code .vscode +*.pdb +*.tlog +*.obj +*.pch +*.log +*.orig # Xcode ## Build generated diff --git a/benchmark/YGBenchmark.c b/benchmark/YGBenchmark.c index d824239e..2e816359 100644 --- a/benchmark/YGBenchmark.c +++ b/benchmark/YGBenchmark.c @@ -26,8 +26,8 @@ YGBENCHMARKS({ YGBENCHMARK("Stack with flex", { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); for (uint32_t i = 0; i < 10; i++) { const YGNodeRef child = YGNodeNew(); @@ -45,7 +45,7 @@ YGBENCHMARKS({ for (uint32_t i = 0; i < 10; i++) { const YGNodeRef child = YGNodeNew(); - YGNodeStyleSetHeight(child, YGPx(20)); + YGNodeStyleSetHeight(child, 20); YGNodeSetMeasureFunc(child, _measure); YGNodeInsertChild(root, child, 0); } @@ -80,31 +80,31 @@ YGBENCHMARKS({ for (uint32_t i = 0; i < 10; i++) { const YGNodeRef child = YGNodeNew(); YGNodeStyleSetFlexGrow(child, 1); - YGNodeStyleSetWidth(child, YGPx(10)); - YGNodeStyleSetHeight(child, YGPx(10)); + YGNodeStyleSetWidth(child, 10); + YGNodeStyleSetHeight(child, 10); YGNodeInsertChild(root, child, 0); for (uint32_t ii = 0; ii < 10; ii++) { const YGNodeRef grandChild = YGNodeNew(); YGNodeStyleSetFlexDirection(grandChild, YGFlexDirectionRow); YGNodeStyleSetFlexGrow(grandChild, 1); - YGNodeStyleSetWidth(grandChild, YGPx(10)); - YGNodeStyleSetHeight(grandChild, YGPx(10)); + YGNodeStyleSetWidth(grandChild, 10); + YGNodeStyleSetHeight(grandChild, 10); YGNodeInsertChild(child, grandChild, 0); for (uint32_t iii = 0; iii < 10; iii++) { const YGNodeRef grandGrandChild = YGNodeNew(); YGNodeStyleSetFlexGrow(grandGrandChild, 1); - YGNodeStyleSetWidth(grandGrandChild, YGPx(10)); - YGNodeStyleSetHeight(grandGrandChild, YGPx(10)); + YGNodeStyleSetWidth(grandGrandChild, 10); + YGNodeStyleSetHeight(grandGrandChild, 10); YGNodeInsertChild(grandChild, grandGrandChild, 0); for (uint32_t iii = 0; iii < 10; iii++) { const YGNodeRef grandGrandGrandChild = YGNodeNew(); YGNodeStyleSetFlexDirection(grandGrandGrandChild, YGFlexDirectionRow); YGNodeStyleSetFlexGrow(grandGrandGrandChild, 1); - YGNodeStyleSetWidth(grandGrandGrandChild, YGPx(10)); - YGNodeStyleSetHeight(grandGrandGrandChild, YGPx(10)); + YGNodeStyleSetWidth(grandGrandGrandChild, 10); + YGNodeStyleSetHeight(grandGrandGrandChild, 10); YGNodeInsertChild(grandGrandChild, grandGrandGrandChild, 0); } } diff --git a/enums.py b/enums.py index c8caf95b..0eaca23d 100644 --- a/enums.py +++ b/enums.py @@ -18,6 +18,7 @@ ENUMS = { 'RTL', ], 'Unit': [ + 'Undefined', 'Pixel', 'Percent', ], diff --git a/gentest/gentest-cpp.js b/gentest/gentest-cpp.js index b66eb10a..008a5b32 100644 --- a/gentest/gentest-cpp.js +++ b/gentest/gentest-cpp.js @@ -12,14 +12,11 @@ function toValueCpp(value) { return n + (Number(n) == n && n % 1 !== 0 ? 'f' : ''); } -function toValueCppCpp(value) { - var methodName = ''; - if(value.indexOf('px') >= 0){ - methodName = 'YGPx'; - }else if (value.indexOf('%') >= 0){ - methodName = 'YGPercent'; +function toFunctionName(value) { + if (value.indexOf('%') >= 0){ + return 'Percent'; } - return methodName + '(' + toValueCpp(value) + ')'; + return ''; } var CPPEmitter = function() { @@ -164,7 +161,7 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, { }}, YGNodeStyleSetFlexBasis:{value:function(nodeName, value) { - this.push('YGNodeStyleSetFlexBasis(' + nodeName + ', ' + toValueCppCpp(value) + ');'); + this.push('YGNodeStyleSetFlexBasis' + toFunctionName(value) + '(' + nodeName + ', ' + toValueCpp(value) + ');'); }}, YGNodeStyleSetFlexDirection:{value:function(nodeName, value) { @@ -184,7 +181,7 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, { }}, YGNodeStyleSetHeight:{value:function(nodeName, value) { - this.push('YGNodeStyleSetHeight(' + nodeName + ', ' + toValueCppCpp(value) + ');'); + this.push('YGNodeStyleSetHeight' + toFunctionName(value) + '(' + nodeName + ', ' + toValueCpp(value) + ');'); }}, YGNodeStyleSetJustifyContent:{value:function(nodeName, value) { @@ -192,23 +189,23 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, { }}, YGNodeStyleSetMargin:{value:function(nodeName, edge, value) { - this.push('YGNodeStyleSetMargin(' + nodeName + ', ' + edge + ', ' + toValueCppCpp(value) + ');'); + this.push('YGNodeStyleSetMargin' + toFunctionName(value) + '(' + nodeName + ', ' + edge + ', ' + toValueCpp(value) + ');'); }}, YGNodeStyleSetMaxHeight:{value:function(nodeName, value) { - this.push('YGNodeStyleSetMaxHeight(' + nodeName + ', ' + toValueCppCpp(value) + ');'); + this.push('YGNodeStyleSetMaxHeight' + toFunctionName(value) + '(' + nodeName + ', ' + toValueCpp(value) + ');'); }}, YGNodeStyleSetMaxWidth:{value:function(nodeName, value) { - this.push('YGNodeStyleSetMaxWidth(' + nodeName + ', ' + toValueCppCpp(value) + ');'); + this.push('YGNodeStyleSetMaxWidth' + toFunctionName(value) + '(' + nodeName + ', ' + toValueCpp(value) + ');'); }}, YGNodeStyleSetMinHeight:{value:function(nodeName, value) { - this.push('YGNodeStyleSetMinHeight(' + nodeName + ', ' + toValueCppCpp(value) + ');'); + this.push('YGNodeStyleSetMinHeight' + toFunctionName(value) + '(' + nodeName + ', ' + toValueCpp(value) + ');'); }}, YGNodeStyleSetMinWidth:{value:function(nodeName, value) { - this.push('YGNodeStyleSetMinWidth(' + nodeName + ', ' + toValueCppCpp(value) + ');'); + this.push('YGNodeStyleSetMinWidth' + toFunctionName(value) + '(' + nodeName + ', ' + toValueCpp(value) + ');'); }}, YGNodeStyleSetOverflow:{value:function(nodeName, value) { @@ -216,11 +213,11 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, { }}, YGNodeStyleSetPadding:{value:function(nodeName, edge, value) { - this.push('YGNodeStyleSetPadding(' + nodeName + ', ' + edge + ', ' + toValueCppCpp(value) + ');'); + this.push('YGNodeStyleSetPadding' + toFunctionName(value) + '(' + nodeName + ', ' + edge + ', ' + toValueCpp(value) + ');'); }}, YGNodeStyleSetPosition:{value:function(nodeName, edge, value) { - this.push('YGNodeStyleSetPosition(' + nodeName + ', ' + edge + ', ' + toValueCppCpp(value) + ');'); + this.push('YGNodeStyleSetPosition' + toFunctionName(value) + '(' + nodeName + ', ' + edge + ', ' + toValueCpp(value) + ');'); }}, YGNodeStyleSetPositionType:{value:function(nodeName, value) { @@ -228,6 +225,6 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, { }}, YGNodeStyleSetWidth:{value:function(nodeName, value) { - this.push('YGNodeStyleSetWidth(' + nodeName + ', ' + toValueCppCpp(value) + ');'); + this.push('YGNodeStyleSetWidth' + toFunctionName(value) + '(' + nodeName + ', ' + toValueCpp(value) + ');'); }}, }); diff --git a/tests/YGAbsolutePositionTest.cpp b/tests/YGAbsolutePositionTest.cpp index 9187c37b..c5a3891b 100644 --- a/tests/YGAbsolutePositionTest.cpp +++ b/tests/YGAbsolutePositionTest.cpp @@ -14,15 +14,15 @@ TEST(YogaTest, absolute_layout_width_height_start_top) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); - YGNodeStyleSetPosition(root_child0, YGEdgeStart, YGPx(10)); - YGNodeStyleSetPosition(root_child0, YGEdgeTop, YGPx(10)); - YGNodeStyleSetWidth(root_child0, YGPx(10)); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetPosition(root_child0, YGEdgeStart, 10); + YGNodeStyleSetPosition(root_child0, YGEdgeTop, 10); + YGNodeStyleSetWidth(root_child0, 10); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -53,15 +53,15 @@ TEST(YogaTest, absolute_layout_width_height_start_top) { TEST(YogaTest, absolute_layout_width_height_end_bottom) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); - YGNodeStyleSetPosition(root_child0, YGEdgeEnd, YGPx(10)); - YGNodeStyleSetPosition(root_child0, YGEdgeBottom, YGPx(10)); - YGNodeStyleSetWidth(root_child0, YGPx(10)); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetPosition(root_child0, YGEdgeEnd, 10); + YGNodeStyleSetPosition(root_child0, YGEdgeBottom, 10); + YGNodeStyleSetWidth(root_child0, 10); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -92,15 +92,15 @@ TEST(YogaTest, absolute_layout_width_height_end_bottom) { TEST(YogaTest, absolute_layout_start_top_end_bottom) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); - YGNodeStyleSetPosition(root_child0, YGEdgeStart, YGPx(10)); - YGNodeStyleSetPosition(root_child0, YGEdgeTop, YGPx(10)); - YGNodeStyleSetPosition(root_child0, YGEdgeEnd, YGPx(10)); - YGNodeStyleSetPosition(root_child0, YGEdgeBottom, YGPx(10)); + YGNodeStyleSetPosition(root_child0, YGEdgeStart, 10); + YGNodeStyleSetPosition(root_child0, YGEdgeTop, 10); + YGNodeStyleSetPosition(root_child0, YGEdgeEnd, 10); + YGNodeStyleSetPosition(root_child0, YGEdgeBottom, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -131,17 +131,17 @@ TEST(YogaTest, absolute_layout_start_top_end_bottom) { TEST(YogaTest, absolute_layout_width_height_start_top_end_bottom) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); - YGNodeStyleSetPosition(root_child0, YGEdgeStart, YGPx(10)); - YGNodeStyleSetPosition(root_child0, YGEdgeTop, YGPx(10)); - YGNodeStyleSetPosition(root_child0, YGEdgeEnd, YGPx(10)); - YGNodeStyleSetPosition(root_child0, YGEdgeBottom, YGPx(10)); - YGNodeStyleSetWidth(root_child0, YGPx(10)); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetPosition(root_child0, YGEdgeStart, 10); + YGNodeStyleSetPosition(root_child0, YGEdgeTop, 10); + YGNodeStyleSetPosition(root_child0, YGEdgeEnd, 10); + YGNodeStyleSetPosition(root_child0, YGEdgeBottom, 10); + YGNodeStyleSetWidth(root_child0, 10); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -174,18 +174,18 @@ TEST(YogaTest, do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hi const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetOverflow(root, YGOverflowHidden); - YGNodeStyleSetWidth(root, YGPx(50)); - YGNodeStyleSetHeight(root, YGPx(50)); + YGNodeStyleSetWidth(root, 50); + YGNodeStyleSetHeight(root, 50); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); - YGNodeStyleSetPosition(root_child0, YGEdgeStart, YGPx(0)); - YGNodeStyleSetPosition(root_child0, YGEdgeTop, YGPx(0)); + YGNodeStyleSetPosition(root_child0, YGEdgeStart, 0); + YGNodeStyleSetPosition(root_child0, YGEdgeTop, 0); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child0_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0_child0, YGPx(100)); - YGNodeStyleSetHeight(root_child0_child0, YGPx(100)); + YGNodeStyleSetWidth(root_child0_child0, 100); + YGNodeStyleSetHeight(root_child0_child0, 100); YGNodeInsertChild(root_child0, root_child0_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -226,35 +226,35 @@ TEST(YogaTest, do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hi TEST(YogaTest, absolute_layout_within_border) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetMargin(root, YGEdgeLeft, YGPx(10)); - YGNodeStyleSetMargin(root, YGEdgeTop, YGPx(10)); - YGNodeStyleSetMargin(root, YGEdgeRight, YGPx(10)); - YGNodeStyleSetMargin(root, YGEdgeBottom, YGPx(10)); - YGNodeStyleSetPadding(root, YGEdgeLeft, YGPx(10)); - YGNodeStyleSetPadding(root, YGEdgeTop, YGPx(10)); - YGNodeStyleSetPadding(root, YGEdgeRight, YGPx(10)); - YGNodeStyleSetPadding(root, YGEdgeBottom, YGPx(10)); + YGNodeStyleSetMargin(root, YGEdgeLeft, 10); + YGNodeStyleSetMargin(root, YGEdgeTop, 10); + YGNodeStyleSetMargin(root, YGEdgeRight, 10); + YGNodeStyleSetMargin(root, YGEdgeBottom, 10); + YGNodeStyleSetPadding(root, YGEdgeLeft, 10); + YGNodeStyleSetPadding(root, YGEdgeTop, 10); + YGNodeStyleSetPadding(root, YGEdgeRight, 10); + YGNodeStyleSetPadding(root, YGEdgeBottom, 10); YGNodeStyleSetBorder(root, YGEdgeLeft, 10); YGNodeStyleSetBorder(root, YGEdgeTop, 10); YGNodeStyleSetBorder(root, YGEdgeRight, 10); YGNodeStyleSetBorder(root, YGEdgeBottom, 10); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); - YGNodeStyleSetPosition(root_child0, YGEdgeLeft, YGPx(0)); - YGNodeStyleSetPosition(root_child0, YGEdgeTop, YGPx(0)); - YGNodeStyleSetWidth(root_child0, YGPx(50)); - YGNodeStyleSetHeight(root_child0, YGPx(50)); + YGNodeStyleSetPosition(root_child0, YGEdgeLeft, 0); + YGNodeStyleSetPosition(root_child0, YGEdgeTop, 0); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetPositionType(root_child1, YGPositionTypeAbsolute); - YGNodeStyleSetPosition(root_child1, YGEdgeRight, YGPx(0)); - YGNodeStyleSetPosition(root_child1, YGEdgeBottom, YGPx(0)); - YGNodeStyleSetWidth(root_child1, YGPx(50)); - YGNodeStyleSetHeight(root_child1, YGPx(50)); + YGNodeStyleSetPosition(root_child1, YGEdgeRight, 0); + YGNodeStyleSetPosition(root_child1, YGEdgeBottom, 0); + YGNodeStyleSetWidth(root_child1, 50); + YGNodeStyleSetHeight(root_child1, 50); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); diff --git a/tests/YGAlignContentTest.cpp b/tests/YGAlignContentTest.cpp index d5e09f93..6c2aaa40 100644 --- a/tests/YGAlignContentTest.cpp +++ b/tests/YGAlignContentTest.cpp @@ -15,32 +15,32 @@ TEST(YogaTest, align_content_flex_start) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexWrap(root, YGWrapWrap); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(50)); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, YGPx(50)); - YGNodeStyleSetHeight(root_child1, YGPx(10)); + YGNodeStyleSetWidth(root_child1, 50); + YGNodeStyleSetHeight(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidth(root_child2, YGPx(50)); - YGNodeStyleSetHeight(root_child2, YGPx(10)); + YGNodeStyleSetWidth(root_child2, 50); + YGNodeStyleSetHeight(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); const YGNodeRef root_child3 = YGNodeNew(); - YGNodeStyleSetWidth(root_child3, YGPx(50)); - YGNodeStyleSetHeight(root_child3, YGPx(10)); + YGNodeStyleSetWidth(root_child3, 50); + YGNodeStyleSetHeight(root_child3, 10); YGNodeInsertChild(root, root_child3, 3); const YGNodeRef root_child4 = YGNodeNew(); - YGNodeStyleSetWidth(root_child4, YGPx(50)); - YGNodeStyleSetHeight(root_child4, YGPx(10)); + YGNodeStyleSetWidth(root_child4, 50); + YGNodeStyleSetHeight(root_child4, 10); YGNodeInsertChild(root, root_child4, 4); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -113,32 +113,32 @@ TEST(YogaTest, align_content_flex_end) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignContent(root, YGAlignFlexEnd); YGNodeStyleSetFlexWrap(root, YGWrapWrap); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(50)); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, YGPx(50)); - YGNodeStyleSetHeight(root_child1, YGPx(10)); + YGNodeStyleSetWidth(root_child1, 50); + YGNodeStyleSetHeight(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidth(root_child2, YGPx(50)); - YGNodeStyleSetHeight(root_child2, YGPx(10)); + YGNodeStyleSetWidth(root_child2, 50); + YGNodeStyleSetHeight(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); const YGNodeRef root_child3 = YGNodeNew(); - YGNodeStyleSetWidth(root_child3, YGPx(50)); - YGNodeStyleSetHeight(root_child3, YGPx(10)); + YGNodeStyleSetWidth(root_child3, 50); + YGNodeStyleSetHeight(root_child3, 10); YGNodeInsertChild(root, root_child3, 3); const YGNodeRef root_child4 = YGNodeNew(); - YGNodeStyleSetWidth(root_child4, YGPx(50)); - YGNodeStyleSetHeight(root_child4, YGPx(10)); + YGNodeStyleSetWidth(root_child4, 50); + YGNodeStyleSetHeight(root_child4, 10); YGNodeInsertChild(root, root_child4, 4); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -211,32 +211,32 @@ TEST(YogaTest, align_content_center) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignContent(root, YGAlignCenter); YGNodeStyleSetFlexWrap(root, YGWrapWrap); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(50)); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, YGPx(50)); - YGNodeStyleSetHeight(root_child1, YGPx(10)); + YGNodeStyleSetWidth(root_child1, 50); + YGNodeStyleSetHeight(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidth(root_child2, YGPx(50)); - YGNodeStyleSetHeight(root_child2, YGPx(10)); + YGNodeStyleSetWidth(root_child2, 50); + YGNodeStyleSetHeight(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); const YGNodeRef root_child3 = YGNodeNew(); - YGNodeStyleSetWidth(root_child3, YGPx(50)); - YGNodeStyleSetHeight(root_child3, YGPx(10)); + YGNodeStyleSetWidth(root_child3, 50); + YGNodeStyleSetHeight(root_child3, 10); YGNodeInsertChild(root, root_child3, 3); const YGNodeRef root_child4 = YGNodeNew(); - YGNodeStyleSetWidth(root_child4, YGPx(50)); - YGNodeStyleSetHeight(root_child4, YGPx(10)); + YGNodeStyleSetWidth(root_child4, 50); + YGNodeStyleSetHeight(root_child4, 10); YGNodeInsertChild(root, root_child4, 4); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -309,27 +309,27 @@ TEST(YogaTest, align_content_stretch) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignContent(root, YGAlignStretch); YGNodeStyleSetFlexWrap(root, YGWrapWrap); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(50)); + YGNodeStyleSetWidth(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, YGPx(50)); + YGNodeStyleSetWidth(root_child1, 50); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidth(root_child2, YGPx(50)); + YGNodeStyleSetWidth(root_child2, 50); YGNodeInsertChild(root, root_child2, 2); const YGNodeRef root_child3 = YGNodeNew(); - YGNodeStyleSetWidth(root_child3, YGPx(50)); + YGNodeStyleSetWidth(root_child3, 50); YGNodeInsertChild(root, root_child3, 3); const YGNodeRef root_child4 = YGNodeNew(); - YGNodeStyleSetWidth(root_child4, YGPx(50)); + YGNodeStyleSetWidth(root_child4, 50); YGNodeInsertChild(root, root_child4, 4); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); diff --git a/tests/YGAlignItemsTest.cpp b/tests/YGAlignItemsTest.cpp index 90a7cee6..e80ae1d4 100644 --- a/tests/YGAlignItemsTest.cpp +++ b/tests/YGAlignItemsTest.cpp @@ -14,11 +14,11 @@ TEST(YogaTest, align_items_stretch) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -50,12 +50,12 @@ TEST(YogaTest, align_items_stretch) { TEST(YogaTest, align_items_center) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignCenter); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(10)); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, 10); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -87,12 +87,12 @@ TEST(YogaTest, align_items_center) { TEST(YogaTest, align_items_flex_start) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(10)); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, 10); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -124,12 +124,12 @@ TEST(YogaTest, align_items_flex_start) { TEST(YogaTest, align_items_flex_end) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignFlexEnd); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(10)); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, 10); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); diff --git a/tests/YGAlignSelfTest.cpp b/tests/YGAlignSelfTest.cpp index 6293c725..436d78b4 100644 --- a/tests/YGAlignSelfTest.cpp +++ b/tests/YGAlignSelfTest.cpp @@ -14,13 +14,13 @@ TEST(YogaTest, align_self_center) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetAlignSelf(root_child0, YGAlignCenter); - YGNodeStyleSetWidth(root_child0, YGPx(10)); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, 10); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -51,13 +51,13 @@ TEST(YogaTest, align_self_center) { TEST(YogaTest, align_self_flex_end) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetAlignSelf(root_child0, YGAlignFlexEnd); - YGNodeStyleSetWidth(root_child0, YGPx(10)); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, 10); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -88,13 +88,13 @@ TEST(YogaTest, align_self_flex_end) { TEST(YogaTest, align_self_flex_start) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetAlignSelf(root_child0, YGAlignFlexStart); - YGNodeStyleSetWidth(root_child0, YGPx(10)); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, 10); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -126,13 +126,13 @@ TEST(YogaTest, align_self_flex_start) { TEST(YogaTest, align_self_flex_end_override_flex_start) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetAlignSelf(root_child0, YGAlignFlexEnd); - YGNodeStyleSetWidth(root_child0, YGPx(10)); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, 10); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); diff --git a/tests/YGBorderTest.cpp b/tests/YGBorderTest.cpp index 3b8743e1..41673414 100644 --- a/tests/YGBorderTest.cpp +++ b/tests/YGBorderTest.cpp @@ -43,8 +43,8 @@ TEST(YogaTest, border_container_match_child) { YGNodeStyleSetBorder(root, YGEdgeBottom, 10); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(10)); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, 10); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -79,12 +79,12 @@ TEST(YogaTest, border_flex_child) { YGNodeStyleSetBorder(root, YGEdgeTop, 10); YGNodeStyleSetBorder(root, YGEdgeRight, 10); YGNodeStyleSetBorder(root, YGEdgeBottom, 10); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetWidth(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -119,11 +119,11 @@ TEST(YogaTest, border_stretch_child) { YGNodeStyleSetBorder(root, YGEdgeTop, 10); YGNodeStyleSetBorder(root, YGEdgeRight, 10); YGNodeStyleSetBorder(root, YGEdgeBottom, 10); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -159,12 +159,12 @@ TEST(YogaTest, border_center_child) { YGNodeStyleSetBorder(root, YGEdgeStart, 10); YGNodeStyleSetBorder(root, YGEdgeEnd, 20); YGNodeStyleSetBorder(root, YGEdgeBottom, 20); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(10)); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, 10); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); diff --git a/tests/YGDirtyMarkingTest.cpp b/tests/YGDirtyMarkingTest.cpp index e5035835..3888966e 100644 --- a/tests/YGDirtyMarkingTest.cpp +++ b/tests/YGDirtyMarkingTest.cpp @@ -13,22 +13,22 @@ TEST(YogaTest, dirty_propagation) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(50)); - YGNodeStyleSetHeight(root_child0, YGPx(20)); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 20); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, YGPx(50)); - YGNodeStyleSetHeight(root_child1, YGPx(20)); + YGNodeStyleSetWidth(root_child1, 50); + YGNodeStyleSetHeight(root_child1, 20); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - YGNodeStyleSetWidth(root_child0, YGPx(20)); + YGNodeStyleSetWidth(root_child0, 20); EXPECT_TRUE(YGNodeIsDirty(root_child0)); EXPECT_FALSE(YGNodeIsDirty(root_child1)); @@ -46,22 +46,22 @@ TEST(YogaTest, dirty_propagation) { TEST(YogaTest, dirty_propagation_only_if_prop_changed) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(50)); - YGNodeStyleSetHeight(root_child0, YGPx(20)); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 20); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, YGPx(50)); - YGNodeStyleSetHeight(root_child1, YGPx(20)); + YGNodeStyleSetWidth(root_child1, 50); + YGNodeStyleSetHeight(root_child1, 20); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - YGNodeStyleSetWidth(root_child0, YGPx(50)); + YGNodeStyleSetWidth(root_child0, 50); EXPECT_FALSE(YGNodeIsDirty(root_child0)); EXPECT_FALSE(YGNodeIsDirty(root_child1)); @@ -73,12 +73,12 @@ TEST(YogaTest, dirty_propagation_only_if_prop_changed) { TEST(YogaTest, dirty_node_only_if_children_are_actually_removed) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - YGNodeStyleSetWidth(root, YGPx(50)); - YGNodeStyleSetHeight(root, YGPx(50)); + YGNodeStyleSetWidth(root, 50); + YGNodeStyleSetHeight(root, 50); const YGNodeRef child0 = YGNodeNew(); - YGNodeStyleSetWidth(child0, YGPx(50)); - YGNodeStyleSetHeight(child0, YGPx(25)); + YGNodeStyleSetWidth(child0, 50); + YGNodeStyleSetHeight(child0, 25); YGNodeInsertChild(root, child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); diff --git a/tests/YGEdgeTest.cpp b/tests/YGEdgeTest.cpp index df6a0a55..4122b11b 100644 --- a/tests/YGEdgeTest.cpp +++ b/tests/YGEdgeTest.cpp @@ -13,14 +13,14 @@ TEST(YogaTest, start_overrides) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetMargin(root_child0, YGEdgeStart, YGPx(10)); - YGNodeStyleSetMargin(root_child0, YGEdgeLeft, YGPx(20)); - YGNodeStyleSetMargin(root_child0, YGEdgeRight, YGPx(20)); + YGNodeStyleSetMargin(root_child0, YGEdgeStart, 10); + YGNodeStyleSetMargin(root_child0, YGEdgeLeft, 20); + YGNodeStyleSetMargin(root_child0, YGEdgeRight, 20); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -37,14 +37,14 @@ TEST(YogaTest, start_overrides) { TEST(YogaTest, end_overrides) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetMargin(root_child0, YGEdgeEnd, YGPx(10)); - YGNodeStyleSetMargin(root_child0, YGEdgeLeft, YGPx(20)); - YGNodeStyleSetMargin(root_child0, YGEdgeRight, YGPx(20)); + YGNodeStyleSetMargin(root_child0, YGEdgeEnd, 10); + YGNodeStyleSetMargin(root_child0, YGEdgeLeft, 20); + YGNodeStyleSetMargin(root_child0, YGEdgeRight, 20); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -61,13 +61,13 @@ TEST(YogaTest, end_overrides) { TEST(YogaTest, horizontal_overridden) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetMargin(root_child0, YGEdgeHorizontal, YGPx(10)); - YGNodeStyleSetMargin(root_child0, YGEdgeLeft, YGPx(20)); + YGNodeStyleSetMargin(root_child0, YGEdgeHorizontal, 10); + YGNodeStyleSetMargin(root_child0, YGEdgeLeft, 20); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -80,13 +80,13 @@ TEST(YogaTest, horizontal_overridden) { TEST(YogaTest, vertical_overridden) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionColumn); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetMargin(root_child0, YGEdgeVertical, YGPx(10)); - YGNodeStyleSetMargin(root_child0, YGEdgeTop, YGPx(20)); + YGNodeStyleSetMargin(root_child0, YGEdgeVertical, 10); + YGNodeStyleSetMargin(root_child0, YGEdgeTop, 20); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -99,13 +99,13 @@ TEST(YogaTest, vertical_overridden) { TEST(YogaTest, horizontal_overrides_all) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionColumn); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetMargin(root_child0, YGEdgeHorizontal, YGPx(10)); - YGNodeStyleSetMargin(root_child0, YGEdgeAll, YGPx(20)); + YGNodeStyleSetMargin(root_child0, YGEdgeHorizontal, 10); + YGNodeStyleSetMargin(root_child0, YGEdgeAll, 20); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -120,13 +120,13 @@ TEST(YogaTest, horizontal_overrides_all) { TEST(YogaTest, vertical_overrides_all) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionColumn); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetMargin(root_child0, YGEdgeVertical, YGPx(10)); - YGNodeStyleSetMargin(root_child0, YGEdgeAll, YGPx(20)); + YGNodeStyleSetMargin(root_child0, YGEdgeVertical, 10); + YGNodeStyleSetMargin(root_child0, YGEdgeAll, 20); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -141,16 +141,16 @@ TEST(YogaTest, vertical_overrides_all) { TEST(YogaTest, all_overridden) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionColumn); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetMargin(root_child0, YGEdgeLeft, YGPx(10)); - YGNodeStyleSetMargin(root_child0, YGEdgeTop, YGPx(10)); - YGNodeStyleSetMargin(root_child0, YGEdgeRight, YGPx(10)); - YGNodeStyleSetMargin(root_child0, YGEdgeBottom, YGPx(10)); - YGNodeStyleSetMargin(root_child0, YGEdgeAll, YGPx(20)); + YGNodeStyleSetMargin(root_child0, YGEdgeLeft, 10); + YGNodeStyleSetMargin(root_child0, YGEdgeTop, 10); + YGNodeStyleSetMargin(root_child0, YGEdgeRight, 10); + YGNodeStyleSetMargin(root_child0, YGEdgeBottom, 10); + YGNodeStyleSetMargin(root_child0, YGEdgeAll, 20); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); diff --git a/tests/YGFlexDirectionTest.cpp b/tests/YGFlexDirectionTest.cpp index 30cb2a4b..b6016428 100644 --- a/tests/YGFlexDirectionTest.cpp +++ b/tests/YGFlexDirectionTest.cpp @@ -14,18 +14,18 @@ TEST(YogaTest, flex_direction_column_no_height) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetHeight(root_child1, YGPx(10)); + YGNodeStyleSetHeight(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetHeight(root_child2, YGPx(10)); + YGNodeStyleSetHeight(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -77,18 +77,18 @@ TEST(YogaTest, flex_direction_column_no_height) { TEST(YogaTest, flex_direction_row_no_width) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, YGPx(10)); + YGNodeStyleSetWidth(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidth(root_child2, YGPx(10)); + YGNodeStyleSetWidth(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -139,19 +139,19 @@ TEST(YogaTest, flex_direction_row_no_width) { TEST(YogaTest, flex_direction_column) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetHeight(root_child1, YGPx(10)); + YGNodeStyleSetHeight(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetHeight(root_child2, YGPx(10)); + YGNodeStyleSetHeight(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -203,19 +203,19 @@ TEST(YogaTest, flex_direction_column) { TEST(YogaTest, flex_direction_row) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, YGPx(10)); + YGNodeStyleSetWidth(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidth(root_child2, YGPx(10)); + YGNodeStyleSetWidth(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -267,19 +267,19 @@ TEST(YogaTest, flex_direction_row) { TEST(YogaTest, flex_direction_column_reverse) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionColumnReverse); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetHeight(root_child1, YGPx(10)); + YGNodeStyleSetHeight(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetHeight(root_child2, YGPx(10)); + YGNodeStyleSetHeight(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -331,19 +331,19 @@ TEST(YogaTest, flex_direction_column_reverse) { TEST(YogaTest, flex_direction_row_reverse) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRowReverse); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, YGPx(10)); + YGNodeStyleSetWidth(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidth(root_child2, YGPx(10)); + YGNodeStyleSetWidth(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); diff --git a/tests/YGFlexTest.cpp b/tests/YGFlexTest.cpp index 69cf569a..559025f7 100644 --- a/tests/YGFlexTest.cpp +++ b/tests/YGFlexTest.cpp @@ -14,12 +14,12 @@ TEST(YogaTest, flex_basis_flex_grow_column) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasis(root_child0, YGPx(50)); + YGNodeStyleSetFlexBasis(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); @@ -65,12 +65,12 @@ TEST(YogaTest, flex_basis_flex_grow_column) { TEST(YogaTest, flex_basis_flex_grow_row) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasis(root_child0, YGPx(50)); + YGNodeStyleSetFlexBasis(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); @@ -115,16 +115,16 @@ TEST(YogaTest, flex_basis_flex_grow_row) { TEST(YogaTest, flex_basis_flex_shrink_column) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexShrink(root_child0, 1); - YGNodeStyleSetFlexBasis(root_child0, YGPx(100)); + YGNodeStyleSetFlexBasis(root_child0, 100); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetFlexBasis(root_child1, YGPx(50)); + YGNodeStyleSetFlexBasis(root_child1, 50); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -166,16 +166,16 @@ TEST(YogaTest, flex_basis_flex_shrink_column) { TEST(YogaTest, flex_basis_flex_shrink_row) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexShrink(root_child0, 1); - YGNodeStyleSetFlexBasis(root_child0, YGPx(100)); + YGNodeStyleSetFlexBasis(root_child0, 100); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetFlexBasis(root_child1, YGPx(50)); + YGNodeStyleSetFlexBasis(root_child1, 50); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -216,22 +216,22 @@ TEST(YogaTest, flex_basis_flex_shrink_row) { TEST(YogaTest, flex_shrink_to_zero) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetHeight(root, YGPx(75)); + YGNodeStyleSetHeight(root, 75); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(50)); - YGNodeStyleSetHeight(root_child0, YGPx(50)); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexShrink(root_child1, 1); - YGNodeStyleSetWidth(root_child1, YGPx(50)); - YGNodeStyleSetHeight(root_child1, YGPx(50)); + YGNodeStyleSetWidth(root_child1, 50); + YGNodeStyleSetHeight(root_child1, 50); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidth(root_child2, YGPx(50)); - YGNodeStyleSetHeight(root_child2, YGPx(50)); + YGNodeStyleSetWidth(root_child2, 50); + YGNodeStyleSetHeight(root_child2, 50); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -282,23 +282,23 @@ TEST(YogaTest, flex_shrink_to_zero) { TEST(YogaTest, flex_basis_overrides_main_size) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasis(root_child0, YGPx(50)); - YGNodeStyleSetHeight(root_child0, YGPx(20)); + YGNodeStyleSetFlexBasis(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 20); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 1); - YGNodeStyleSetHeight(root_child1, YGPx(10)); + YGNodeStyleSetHeight(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child2, 1); - YGNodeStyleSetHeight(root_child2, YGPx(10)); + YGNodeStyleSetHeight(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -349,8 +349,8 @@ TEST(YogaTest, flex_basis_overrides_main_size) { TEST(YogaTest, flex_grow_shrink_at_most) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeInsertChild(root, root_child0, 0); diff --git a/tests/YGFlexWrapTest.cpp b/tests/YGFlexWrapTest.cpp index 32e86a6e..03d07a82 100644 --- a/tests/YGFlexWrapTest.cpp +++ b/tests/YGFlexWrapTest.cpp @@ -15,26 +15,26 @@ TEST(YogaTest, wrap_column) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexWrap(root, YGWrapWrap); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(30)); - YGNodeStyleSetHeight(root_child0, YGPx(30)); + YGNodeStyleSetWidth(root_child0, 30); + YGNodeStyleSetHeight(root_child0, 30); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, YGPx(30)); - YGNodeStyleSetHeight(root_child1, YGPx(30)); + YGNodeStyleSetWidth(root_child1, 30); + YGNodeStyleSetHeight(root_child1, 30); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidth(root_child2, YGPx(30)); - YGNodeStyleSetHeight(root_child2, YGPx(30)); + YGNodeStyleSetWidth(root_child2, 30); + YGNodeStyleSetHeight(root_child2, 30); YGNodeInsertChild(root, root_child2, 2); const YGNodeRef root_child3 = YGNodeNew(); - YGNodeStyleSetWidth(root_child3, YGPx(30)); - YGNodeStyleSetHeight(root_child3, YGPx(30)); + YGNodeStyleSetWidth(root_child3, 30); + YGNodeStyleSetHeight(root_child3, 30); YGNodeInsertChild(root, root_child3, 3); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -97,26 +97,26 @@ TEST(YogaTest, wrap_row) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetFlexWrap(root, YGWrapWrap); - YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(30)); - YGNodeStyleSetHeight(root_child0, YGPx(30)); + YGNodeStyleSetWidth(root_child0, 30); + YGNodeStyleSetHeight(root_child0, 30); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, YGPx(30)); - YGNodeStyleSetHeight(root_child1, YGPx(30)); + YGNodeStyleSetWidth(root_child1, 30); + YGNodeStyleSetHeight(root_child1, 30); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidth(root_child2, YGPx(30)); - YGNodeStyleSetHeight(root_child2, YGPx(30)); + YGNodeStyleSetWidth(root_child2, 30); + YGNodeStyleSetHeight(root_child2, 30); YGNodeInsertChild(root, root_child2, 2); const YGNodeRef root_child3 = YGNodeNew(); - YGNodeStyleSetWidth(root_child3, YGPx(30)); - YGNodeStyleSetHeight(root_child3, YGPx(30)); + YGNodeStyleSetWidth(root_child3, 30); + YGNodeStyleSetHeight(root_child3, 30); YGNodeInsertChild(root, root_child3, 3); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -180,26 +180,26 @@ TEST(YogaTest, wrap_row_align_items_flex_end) { YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetAlignItems(root, YGAlignFlexEnd); YGNodeStyleSetFlexWrap(root, YGWrapWrap); - YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(30)); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, 30); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, YGPx(30)); - YGNodeStyleSetHeight(root_child1, YGPx(20)); + YGNodeStyleSetWidth(root_child1, 30); + YGNodeStyleSetHeight(root_child1, 20); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidth(root_child2, YGPx(30)); - YGNodeStyleSetHeight(root_child2, YGPx(30)); + YGNodeStyleSetWidth(root_child2, 30); + YGNodeStyleSetHeight(root_child2, 30); YGNodeInsertChild(root, root_child2, 2); const YGNodeRef root_child3 = YGNodeNew(); - YGNodeStyleSetWidth(root_child3, YGPx(30)); - YGNodeStyleSetHeight(root_child3, YGPx(30)); + YGNodeStyleSetWidth(root_child3, 30); + YGNodeStyleSetHeight(root_child3, 30); YGNodeInsertChild(root, root_child3, 3); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -263,26 +263,26 @@ TEST(YogaTest, wrap_row_align_items_center) { YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetAlignItems(root, YGAlignCenter); YGNodeStyleSetFlexWrap(root, YGWrapWrap); - YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(30)); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, 30); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, YGPx(30)); - YGNodeStyleSetHeight(root_child1, YGPx(20)); + YGNodeStyleSetWidth(root_child1, 30); + YGNodeStyleSetHeight(root_child1, 20); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidth(root_child2, YGPx(30)); - YGNodeStyleSetHeight(root_child2, YGPx(30)); + YGNodeStyleSetWidth(root_child2, 30); + YGNodeStyleSetHeight(root_child2, 30); YGNodeInsertChild(root, root_child2, 2); const YGNodeRef root_child3 = YGNodeNew(); - YGNodeStyleSetWidth(root_child3, YGPx(30)); - YGNodeStyleSetHeight(root_child3, YGPx(30)); + YGNodeStyleSetWidth(root_child3, 30); + YGNodeStyleSetHeight(root_child3, 30); YGNodeInsertChild(root, root_child3, 3); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); diff --git a/tests/YGJustifyContentTest.cpp b/tests/YGJustifyContentTest.cpp index 260d3914..b7afe1b6 100644 --- a/tests/YGJustifyContentTest.cpp +++ b/tests/YGJustifyContentTest.cpp @@ -15,19 +15,19 @@ TEST(YogaTest, justify_content_row_flex_start) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, YGPx(102)); - YGNodeStyleSetHeight(root, YGPx(102)); + YGNodeStyleSetWidth(root, 102); + YGNodeStyleSetHeight(root, 102); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, YGPx(10)); + YGNodeStyleSetWidth(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidth(root_child2, YGPx(10)); + YGNodeStyleSetWidth(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -80,19 +80,19 @@ TEST(YogaTest, justify_content_row_flex_end) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetJustifyContent(root, YGJustifyFlexEnd); - YGNodeStyleSetWidth(root, YGPx(102)); - YGNodeStyleSetHeight(root, YGPx(102)); + YGNodeStyleSetWidth(root, 102); + YGNodeStyleSetHeight(root, 102); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, YGPx(10)); + YGNodeStyleSetWidth(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidth(root_child2, YGPx(10)); + YGNodeStyleSetWidth(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -145,19 +145,19 @@ TEST(YogaTest, justify_content_row_center) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetJustifyContent(root, YGJustifyCenter); - YGNodeStyleSetWidth(root, YGPx(102)); - YGNodeStyleSetHeight(root, YGPx(102)); + YGNodeStyleSetWidth(root, 102); + YGNodeStyleSetHeight(root, 102); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, YGPx(10)); + YGNodeStyleSetWidth(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidth(root_child2, YGPx(10)); + YGNodeStyleSetWidth(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -210,19 +210,19 @@ TEST(YogaTest, justify_content_row_space_between) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetJustifyContent(root, YGJustifySpaceBetween); - YGNodeStyleSetWidth(root, YGPx(102)); - YGNodeStyleSetHeight(root, YGPx(102)); + YGNodeStyleSetWidth(root, 102); + YGNodeStyleSetHeight(root, 102); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, YGPx(10)); + YGNodeStyleSetWidth(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidth(root_child2, YGPx(10)); + YGNodeStyleSetWidth(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -275,19 +275,19 @@ TEST(YogaTest, justify_content_row_space_around) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetJustifyContent(root, YGJustifySpaceAround); - YGNodeStyleSetWidth(root, YGPx(102)); - YGNodeStyleSetHeight(root, YGPx(102)); + YGNodeStyleSetWidth(root, 102); + YGNodeStyleSetHeight(root, 102); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, YGPx(10)); + YGNodeStyleSetWidth(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidth(root_child2, YGPx(10)); + YGNodeStyleSetWidth(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -338,18 +338,18 @@ TEST(YogaTest, justify_content_row_space_around) { TEST(YogaTest, justify_content_column_flex_start) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(102)); - YGNodeStyleSetHeight(root, YGPx(102)); + YGNodeStyleSetWidth(root, 102); + YGNodeStyleSetHeight(root, 102); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetHeight(root_child2, YGPx(10)); + YGNodeStyleSetHeight(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -401,19 +401,19 @@ TEST(YogaTest, justify_content_column_flex_start) { TEST(YogaTest, justify_content_column_flex_end) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetJustifyContent(root, YGJustifyFlexEnd); - YGNodeStyleSetWidth(root, YGPx(102)); - YGNodeStyleSetHeight(root, YGPx(102)); + YGNodeStyleSetWidth(root, 102); + YGNodeStyleSetHeight(root, 102); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetHeight(root_child1, YGPx(10)); + YGNodeStyleSetHeight(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetHeight(root_child2, YGPx(10)); + YGNodeStyleSetHeight(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -465,19 +465,19 @@ TEST(YogaTest, justify_content_column_flex_end) { TEST(YogaTest, justify_content_column_center) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetJustifyContent(root, YGJustifyCenter); - YGNodeStyleSetWidth(root, YGPx(102)); - YGNodeStyleSetHeight(root, YGPx(102)); + YGNodeStyleSetWidth(root, 102); + YGNodeStyleSetHeight(root, 102); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetHeight(root_child1, YGPx(10)); + YGNodeStyleSetHeight(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetHeight(root_child2, YGPx(10)); + YGNodeStyleSetHeight(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -529,19 +529,19 @@ TEST(YogaTest, justify_content_column_center) { TEST(YogaTest, justify_content_column_space_between) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetJustifyContent(root, YGJustifySpaceBetween); - YGNodeStyleSetWidth(root, YGPx(102)); - YGNodeStyleSetHeight(root, YGPx(102)); + YGNodeStyleSetWidth(root, 102); + YGNodeStyleSetHeight(root, 102); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetHeight(root_child1, YGPx(10)); + YGNodeStyleSetHeight(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetHeight(root_child2, YGPx(10)); + YGNodeStyleSetHeight(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -593,19 +593,19 @@ TEST(YogaTest, justify_content_column_space_between) { TEST(YogaTest, justify_content_column_space_around) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetJustifyContent(root, YGJustifySpaceAround); - YGNodeStyleSetWidth(root, YGPx(102)); - YGNodeStyleSetHeight(root, YGPx(102)); + YGNodeStyleSetWidth(root, 102); + YGNodeStyleSetHeight(root, 102); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetHeight(root_child1, YGPx(10)); + YGNodeStyleSetHeight(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetHeight(root_child2, YGPx(10)); + YGNodeStyleSetHeight(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); diff --git a/tests/YGMarginTest.cpp b/tests/YGMarginTest.cpp index 17de3e78..724b2eef 100644 --- a/tests/YGMarginTest.cpp +++ b/tests/YGMarginTest.cpp @@ -15,12 +15,12 @@ TEST(YogaTest, margin_start) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetMargin(root_child0, YGEdgeStart, YGPx(10)); - YGNodeStyleSetWidth(root_child0, YGPx(10)); + YGNodeStyleSetMargin(root_child0, YGEdgeStart, 10); + YGNodeStyleSetWidth(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -51,12 +51,12 @@ TEST(YogaTest, margin_start) { TEST(YogaTest, margin_top) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetMargin(root_child0, YGEdgeTop, YGPx(10)); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetMargin(root_child0, YGEdgeTop, 10); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -89,12 +89,12 @@ TEST(YogaTest, margin_end) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetJustifyContent(root, YGJustifyFlexEnd); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetMargin(root_child0, YGEdgeEnd, YGPx(10)); - YGNodeStyleSetWidth(root_child0, YGPx(10)); + YGNodeStyleSetMargin(root_child0, YGEdgeEnd, 10); + YGNodeStyleSetWidth(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -126,12 +126,12 @@ TEST(YogaTest, margin_end) { TEST(YogaTest, margin_bottom) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetJustifyContent(root, YGJustifyFlexEnd); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetMargin(root_child0, YGEdgeBottom, YGPx(10)); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetMargin(root_child0, YGEdgeBottom, 10); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -163,12 +163,12 @@ TEST(YogaTest, margin_bottom) { TEST(YogaTest, margin_and_flex_row) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetMargin(root_child0, YGEdgeStart, YGPx(10)); + YGNodeStyleSetMargin(root_child0, YGEdgeStart, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -199,12 +199,12 @@ TEST(YogaTest, margin_and_flex_row) { TEST(YogaTest, margin_and_flex_column) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetMargin(root_child0, YGEdgeTop, YGPx(10)); + YGNodeStyleSetMargin(root_child0, YGEdgeTop, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -236,12 +236,12 @@ TEST(YogaTest, margin_and_flex_column) { TEST(YogaTest, margin_and_stretch_row) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetMargin(root_child0, YGEdgeTop, YGPx(10)); + YGNodeStyleSetMargin(root_child0, YGEdgeTop, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -272,12 +272,12 @@ TEST(YogaTest, margin_and_stretch_row) { TEST(YogaTest, margin_and_stretch_column) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetMargin(root_child0, YGEdgeStart, YGPx(10)); + YGNodeStyleSetMargin(root_child0, YGEdgeStart, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -309,8 +309,8 @@ TEST(YogaTest, margin_and_stretch_column) { TEST(YogaTest, margin_with_sibling_row) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); @@ -358,8 +358,8 @@ TEST(YogaTest, margin_with_sibling_row) { TEST(YogaTest, margin_with_sibling_column) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); diff --git a/tests/YGMinMaxDimensionTest.cpp b/tests/YGMinMaxDimensionTest.cpp index 00df60e3..b1463e52 100644 --- a/tests/YGMinMaxDimensionTest.cpp +++ b/tests/YGMinMaxDimensionTest.cpp @@ -14,12 +14,12 @@ TEST(YogaTest, max_width) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetMaxWidth(root_child0, YGPx(50)); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetMaxWidth(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -51,12 +51,12 @@ TEST(YogaTest, max_width) { TEST(YogaTest, max_height) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(10)); - YGNodeStyleSetMaxHeight(root_child0, YGPx(50)); + YGNodeStyleSetWidth(root_child0, 10); + YGNodeStyleSetMaxHeight(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -87,12 +87,12 @@ TEST(YogaTest, max_height) { TEST(YogaTest, min_height) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetMinHeight(root_child0, YGPx(60)); + YGNodeStyleSetMinHeight(root_child0, 60); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); @@ -138,12 +138,12 @@ TEST(YogaTest, min_height) { TEST(YogaTest, min_width) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetMinWidth(root_child0, YGPx(60)); + YGNodeStyleSetMinWidth(root_child0, 60); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); @@ -189,13 +189,13 @@ TEST(YogaTest, min_width) { TEST(YogaTest, justify_content_min_max) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetJustifyContent(root, YGJustifyCenter); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetMinHeight(root, YGPx(100)); - YGNodeStyleSetMaxHeight(root, YGPx(200)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetMinHeight(root, 100); + YGNodeStyleSetMaxHeight(root, 200); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(60)); - YGNodeStyleSetHeight(root_child0, YGPx(60)); + YGNodeStyleSetWidth(root_child0, 60); + YGNodeStyleSetHeight(root_child0, 60); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -227,13 +227,13 @@ TEST(YogaTest, justify_content_min_max) { TEST(YogaTest, align_items_min_max) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignCenter); - YGNodeStyleSetMinWidth(root, YGPx(100)); - YGNodeStyleSetMaxWidth(root, YGPx(200)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetMinWidth(root, 100); + YGNodeStyleSetMaxWidth(root, 200); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(60)); - YGNodeStyleSetHeight(root_child0, YGPx(60)); + YGNodeStyleSetWidth(root_child0, 60); + YGNodeStyleSetHeight(root_child0, 60); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -265,22 +265,22 @@ TEST(YogaTest, align_items_min_max) { TEST(YogaTest, justify_content_overflow_min_max) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetJustifyContent(root, YGJustifyCenter); - YGNodeStyleSetMinHeight(root, YGPx(100)); - YGNodeStyleSetMaxHeight(root, YGPx(110)); + YGNodeStyleSetMinHeight(root, 100); + YGNodeStyleSetMaxHeight(root, 110); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(50)); - YGNodeStyleSetHeight(root_child0, YGPx(50)); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, YGPx(50)); - YGNodeStyleSetHeight(root_child1, YGPx(50)); + YGNodeStyleSetWidth(root_child1, 50); + YGNodeStyleSetHeight(root_child1, 50); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidth(root_child2, YGPx(50)); - YGNodeStyleSetHeight(root_child2, YGPx(50)); + YGNodeStyleSetWidth(root_child2, 50); + YGNodeStyleSetHeight(root_child2, 50); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -331,17 +331,17 @@ TEST(YogaTest, justify_content_overflow_min_max) { TEST(YogaTest, flex_grow_within_max_width) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(200)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow); - YGNodeStyleSetMaxWidth(root_child0, YGPx(100)); + YGNodeStyleSetMaxWidth(root_child0, 100); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child0_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0_child0, 1); - YGNodeStyleSetHeight(root_child0_child0, YGPx(20)); + YGNodeStyleSetHeight(root_child0_child0, 20); YGNodeInsertChild(root_child0, root_child0_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -382,17 +382,17 @@ TEST(YogaTest, flex_grow_within_max_width) { TEST(YogaTest, flex_grow_within_constrained_max_width) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(200)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow); - YGNodeStyleSetMaxWidth(root_child0, YGPx(300)); + YGNodeStyleSetMaxWidth(root_child0, 300); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child0_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0_child0, 1); - YGNodeStyleSetHeight(root_child0_child0, YGPx(20)); + YGNodeStyleSetHeight(root_child0_child0, 20); YGNodeInsertChild(root_child0, root_child0_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -434,15 +434,15 @@ TEST(YogaTest, flex_grow_within_constrained_max_width) { TEST(YogaTest, flex_grow_within_constrained_min_row) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetMinWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetMinWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, YGPx(50)); + YGNodeStyleSetWidth(root_child1, 50); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -483,14 +483,14 @@ TEST(YogaTest, flex_grow_within_constrained_min_row) { TEST(YogaTest, flex_grow_within_constrained_min_column) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetMinHeight(root, YGPx(100)); + YGNodeStyleSetMinHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetHeight(root_child1, YGPx(50)); + YGNodeStyleSetHeight(root_child1, 50); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -531,21 +531,21 @@ TEST(YogaTest, flex_grow_within_constrained_min_column) { TEST(YogaTest, flex_grow_within_constrained_max_row) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(200)); + YGNodeStyleSetWidth(root, 200); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow); - YGNodeStyleSetMaxWidth(root_child0, YGPx(100)); - YGNodeStyleSetHeight(root_child0, YGPx(100)); + YGNodeStyleSetMaxWidth(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 100); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child0_child0 = YGNodeNew(); YGNodeStyleSetFlexShrink(root_child0_child0, 1); - YGNodeStyleSetFlexBasis(root_child0_child0, YGPx(100)); + YGNodeStyleSetFlexBasis(root_child0_child0, 100); YGNodeInsertChild(root_child0, root_child0_child0, 0); const YGNodeRef root_child0_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0_child1, YGPx(50)); + YGNodeStyleSetWidth(root_child0_child1, 50); YGNodeInsertChild(root_child0, root_child0_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -596,16 +596,16 @@ TEST(YogaTest, flex_grow_within_constrained_max_row) { TEST(YogaTest, flex_grow_within_constrained_max_column) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetMaxHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetMaxHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexShrink(root_child0, 1); - YGNodeStyleSetFlexBasis(root_child0, YGPx(100)); + YGNodeStyleSetFlexBasis(root_child0, 100); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetHeight(root_child1, YGPx(50)); + YGNodeStyleSetHeight(root_child1, 50); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); diff --git a/tests/YGPaddingTest.cpp b/tests/YGPaddingTest.cpp index 9fe33ac0..aab6726b 100644 --- a/tests/YGPaddingTest.cpp +++ b/tests/YGPaddingTest.cpp @@ -14,10 +14,10 @@ TEST(YogaTest, padding_no_size) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetPadding(root, YGEdgeLeft, YGPx(10)); - YGNodeStyleSetPadding(root, YGEdgeTop, YGPx(10)); - YGNodeStyleSetPadding(root, YGEdgeRight, YGPx(10)); - YGNodeStyleSetPadding(root, YGEdgeBottom, YGPx(10)); + YGNodeStyleSetPadding(root, YGEdgeLeft, 10); + YGNodeStyleSetPadding(root, YGEdgeTop, 10); + YGNodeStyleSetPadding(root, YGEdgeRight, 10); + YGNodeStyleSetPadding(root, YGEdgeBottom, 10); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); @@ -37,14 +37,14 @@ TEST(YogaTest, padding_no_size) { TEST(YogaTest, padding_container_match_child) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetPadding(root, YGEdgeLeft, YGPx(10)); - YGNodeStyleSetPadding(root, YGEdgeTop, YGPx(10)); - YGNodeStyleSetPadding(root, YGEdgeRight, YGPx(10)); - YGNodeStyleSetPadding(root, YGEdgeBottom, YGPx(10)); + YGNodeStyleSetPadding(root, YGEdgeLeft, 10); + YGNodeStyleSetPadding(root, YGEdgeTop, 10); + YGNodeStyleSetPadding(root, YGEdgeRight, 10); + YGNodeStyleSetPadding(root, YGEdgeBottom, 10); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(10)); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, 10); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -75,16 +75,16 @@ TEST(YogaTest, padding_container_match_child) { TEST(YogaTest, padding_flex_child) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetPadding(root, YGEdgeLeft, YGPx(10)); - YGNodeStyleSetPadding(root, YGEdgeTop, YGPx(10)); - YGNodeStyleSetPadding(root, YGEdgeRight, YGPx(10)); - YGNodeStyleSetPadding(root, YGEdgeBottom, YGPx(10)); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetPadding(root, YGEdgeLeft, 10); + YGNodeStyleSetPadding(root, YGEdgeTop, 10); + YGNodeStyleSetPadding(root, YGEdgeRight, 10); + YGNodeStyleSetPadding(root, YGEdgeBottom, 10); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetWidth(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -115,15 +115,15 @@ TEST(YogaTest, padding_flex_child) { TEST(YogaTest, padding_stretch_child) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetPadding(root, YGEdgeLeft, YGPx(10)); - YGNodeStyleSetPadding(root, YGEdgeTop, YGPx(10)); - YGNodeStyleSetPadding(root, YGEdgeRight, YGPx(10)); - YGNodeStyleSetPadding(root, YGEdgeBottom, YGPx(10)); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetPadding(root, YGEdgeLeft, 10); + YGNodeStyleSetPadding(root, YGEdgeTop, 10); + YGNodeStyleSetPadding(root, YGEdgeRight, 10); + YGNodeStyleSetPadding(root, YGEdgeBottom, 10); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -156,15 +156,15 @@ TEST(YogaTest, padding_center_child) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetJustifyContent(root, YGJustifyCenter); YGNodeStyleSetAlignItems(root, YGAlignCenter); - YGNodeStyleSetPadding(root, YGEdgeStart, YGPx(10)); - YGNodeStyleSetPadding(root, YGEdgeEnd, YGPx(20)); - YGNodeStyleSetPadding(root, YGEdgeBottom, YGPx(20)); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetPadding(root, YGEdgeStart, 10); + YGNodeStyleSetPadding(root, YGEdgeEnd, 20); + YGNodeStyleSetPadding(root, YGEdgeBottom, 20); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(10)); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, 10); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -197,16 +197,16 @@ TEST(YogaTest, child_with_padding_align_end) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetJustifyContent(root, YGJustifyFlexEnd); YGNodeStyleSetAlignItems(root, YGAlignFlexEnd); - YGNodeStyleSetWidth(root, YGPx(200)); - YGNodeStyleSetHeight(root, YGPx(200)); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 200); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetPadding(root_child0, YGEdgeLeft, YGPx(20)); - YGNodeStyleSetPadding(root_child0, YGEdgeTop, YGPx(20)); - YGNodeStyleSetPadding(root_child0, YGEdgeRight, YGPx(20)); - YGNodeStyleSetPadding(root_child0, YGEdgeBottom, YGPx(20)); - YGNodeStyleSetWidth(root_child0, YGPx(100)); - YGNodeStyleSetHeight(root_child0, YGPx(100)); + YGNodeStyleSetPadding(root_child0, YGEdgeLeft, 20); + YGNodeStyleSetPadding(root_child0, YGEdgeTop, 20); + YGNodeStyleSetPadding(root_child0, YGEdgeRight, 20); + YGNodeStyleSetPadding(root_child0, YGEdgeBottom, 20); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 100); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); diff --git a/tests/YGPercentageTest.cpp b/tests/YGPercentageTest.cpp index 9d16db6f..80d2f4f7 100644 --- a/tests/YGPercentageTest.cpp +++ b/tests/YGPercentageTest.cpp @@ -17,12 +17,12 @@ TEST(YogaTest, percentage_width_height) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, YGPx(200)); - YGNodeStyleSetHeight(root, YGPx(200)); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 200); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPercent(30)); - YGNodeStyleSetHeight(root_child0, YGPercent(30)); + YGNodeStyleSetWidthPercent(root_child0, 30); + YGNodeStyleSetHeightPercent(root_child0, 30); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -58,14 +58,14 @@ TEST(YogaTest, percentage_position_left_top) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, YGPx(400)); - YGNodeStyleSetHeight(root, YGPx(400)); + YGNodeStyleSetWidth(root, 400); + YGNodeStyleSetHeight(root, 400); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetPosition(root_child0, YGEdgeLeft, YGPercent(10)); - YGNodeStyleSetPosition(root_child0, YGEdgeTop, YGPercent(20)); - YGNodeStyleSetWidth(root_child0, YGPercent(45)); - YGNodeStyleSetHeight(root_child0, YGPercent(55)); + YGNodeStyleSetPositionPercent(root_child0, YGEdgeLeft, 10); + YGNodeStyleSetPositionPercent(root_child0, YGEdgeTop, 20); + YGNodeStyleSetWidthPercent(root_child0, 45); + YGNodeStyleSetHeightPercent(root_child0, 55); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -101,14 +101,14 @@ TEST(YogaTest, percentage_position_bottom_right) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, YGPx(500)); - YGNodeStyleSetHeight(root, YGPx(500)); + YGNodeStyleSetWidth(root, 500); + YGNodeStyleSetHeight(root, 500); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetPosition(root_child0, YGEdgeRight, YGPercent(20)); - YGNodeStyleSetPosition(root_child0, YGEdgeBottom, YGPercent(10)); - YGNodeStyleSetWidth(root_child0, YGPercent(55)); - YGNodeStyleSetHeight(root_child0, YGPercent(15)); + YGNodeStyleSetPositionPercent(root_child0, YGEdgeRight, 20); + YGNodeStyleSetPositionPercent(root_child0, YGEdgeBottom, 10); + YGNodeStyleSetWidthPercent(root_child0, 55); + YGNodeStyleSetHeightPercent(root_child0, 15); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -144,17 +144,17 @@ TEST(YogaTest, percentage_flex_basis) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, YGPx(200)); - YGNodeStyleSetHeight(root, YGPx(200)); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 200); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasis(root_child0, YGPercent(50)); + YGNodeStyleSetFlexBasisPercent(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 1); - YGNodeStyleSetFlexBasis(root_child1, YGPercent(25)); + YGNodeStyleSetFlexBasisPercent(root_child1, 25); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -199,17 +199,17 @@ TEST(YogaTest, percentage_flex_basis_cross) { YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(200)); - YGNodeStyleSetHeight(root, YGPx(200)); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 200); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasis(root_child0, YGPercent(50)); + YGNodeStyleSetFlexBasisPercent(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 1); - YGNodeStyleSetFlexBasis(root_child1, YGPercent(25)); + YGNodeStyleSetFlexBasisPercent(root_child1, 25); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -254,17 +254,17 @@ TEST(YogaTest, percentage_flex_basis_cross_min_height) { YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(200)); - YGNodeStyleSetHeight(root, YGPx(200)); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 200); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetMinHeight(root_child0, YGPercent(60)); + YGNodeStyleSetMinHeightPercent(root_child0, 60); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 2); - YGNodeStyleSetMinHeight(root_child1, YGPercent(10)); + YGNodeStyleSetMinHeightPercent(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -310,19 +310,19 @@ TEST(YogaTest, percentage_flex_basis_main_max_height) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, YGPx(200)); - YGNodeStyleSetHeight(root, YGPx(200)); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 200); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasis(root_child0, YGPercent(10)); - YGNodeStyleSetMaxHeight(root_child0, YGPercent(60)); + YGNodeStyleSetFlexBasisPercent(root_child0, 10); + YGNodeStyleSetMaxHeightPercent(root_child0, 60); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 4); - YGNodeStyleSetFlexBasis(root_child1, YGPercent(10)); - YGNodeStyleSetMaxHeight(root_child1, YGPercent(20)); + YGNodeStyleSetFlexBasisPercent(root_child1, 10); + YGNodeStyleSetMaxHeightPercent(root_child1, 20); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -367,19 +367,19 @@ TEST(YogaTest, percentage_flex_basis_cross_max_height) { YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(200)); - YGNodeStyleSetHeight(root, YGPx(200)); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 200); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasis(root_child0, YGPercent(10)); - YGNodeStyleSetMaxHeight(root_child0, YGPercent(60)); + YGNodeStyleSetFlexBasisPercent(root_child0, 10); + YGNodeStyleSetMaxHeightPercent(root_child0, 60); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 4); - YGNodeStyleSetFlexBasis(root_child1, YGPercent(10)); - YGNodeStyleSetMaxHeight(root_child1, YGPercent(20)); + YGNodeStyleSetFlexBasisPercent(root_child1, 10); + YGNodeStyleSetMaxHeightPercent(root_child1, 20); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -425,19 +425,19 @@ TEST(YogaTest, percentage_flex_basis_main_max_width) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, YGPx(200)); - YGNodeStyleSetHeight(root, YGPx(200)); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 200); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasis(root_child0, YGPercent(15)); - YGNodeStyleSetMaxWidth(root_child0, YGPercent(60)); + YGNodeStyleSetFlexBasisPercent(root_child0, 15); + YGNodeStyleSetMaxWidthPercent(root_child0, 60); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 4); - YGNodeStyleSetFlexBasis(root_child1, YGPercent(10)); - YGNodeStyleSetMaxWidth(root_child1, YGPercent(20)); + YGNodeStyleSetFlexBasisPercent(root_child1, 10); + YGNodeStyleSetMaxWidthPercent(root_child1, 20); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -482,19 +482,19 @@ TEST(YogaTest, percentage_flex_basis_cross_max_width) { YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(200)); - YGNodeStyleSetHeight(root, YGPx(200)); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 200); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasis(root_child0, YGPercent(10)); - YGNodeStyleSetMaxWidth(root_child0, YGPercent(60)); + YGNodeStyleSetFlexBasisPercent(root_child0, 10); + YGNodeStyleSetMaxWidthPercent(root_child0, 60); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 4); - YGNodeStyleSetFlexBasis(root_child1, YGPercent(15)); - YGNodeStyleSetMaxWidth(root_child1, YGPercent(20)); + YGNodeStyleSetFlexBasisPercent(root_child1, 15); + YGNodeStyleSetMaxWidthPercent(root_child1, 20); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -540,19 +540,19 @@ TEST(YogaTest, percentage_flex_basis_main_min_width) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, YGPx(200)); - YGNodeStyleSetHeight(root, YGPx(200)); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 200); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasis(root_child0, YGPercent(15)); - YGNodeStyleSetMinWidth(root_child0, YGPercent(60)); + YGNodeStyleSetFlexBasisPercent(root_child0, 15); + YGNodeStyleSetMinWidthPercent(root_child0, 60); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 4); - YGNodeStyleSetFlexBasis(root_child1, YGPercent(10)); - YGNodeStyleSetMinWidth(root_child1, YGPercent(20)); + YGNodeStyleSetFlexBasisPercent(root_child1, 10); + YGNodeStyleSetMinWidthPercent(root_child1, 20); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -597,19 +597,19 @@ TEST(YogaTest, percentage_flex_basis_cross_min_width) { YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(200)); - YGNodeStyleSetHeight(root, YGPx(200)); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 200); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasis(root_child0, YGPercent(10)); - YGNodeStyleSetMinWidth(root_child0, YGPercent(60)); + YGNodeStyleSetFlexBasisPercent(root_child0, 10); + YGNodeStyleSetMinWidthPercent(root_child0, 60); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 4); - YGNodeStyleSetFlexBasis(root_child1, YGPercent(15)); - YGNodeStyleSetMinWidth(root_child1, YGPercent(20)); + YGNodeStyleSetFlexBasisPercent(root_child1, 15); + YGNodeStyleSetMinWidthPercent(root_child1, 20); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -654,51 +654,51 @@ TEST(YogaTest, percentage_multiple_nested_with_padding_margin_and_percentage_val YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(200)); - YGNodeStyleSetHeight(root, YGPx(200)); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 200); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasis(root_child0, YGPercent(10)); - YGNodeStyleSetMargin(root_child0, YGEdgeLeft, YGPx(5)); - YGNodeStyleSetMargin(root_child0, YGEdgeTop, YGPx(5)); - YGNodeStyleSetMargin(root_child0, YGEdgeRight, YGPx(5)); - YGNodeStyleSetMargin(root_child0, YGEdgeBottom, YGPx(5)); - YGNodeStyleSetPadding(root_child0, YGEdgeLeft, YGPx(3)); - YGNodeStyleSetPadding(root_child0, YGEdgeTop, YGPx(3)); - YGNodeStyleSetPadding(root_child0, YGEdgeRight, YGPx(3)); - YGNodeStyleSetPadding(root_child0, YGEdgeBottom, YGPx(3)); - YGNodeStyleSetMinWidth(root_child0, YGPercent(60)); + YGNodeStyleSetFlexBasisPercent(root_child0, 10); + YGNodeStyleSetMargin(root_child0, YGEdgeLeft, 5); + YGNodeStyleSetMargin(root_child0, YGEdgeTop, 5); + YGNodeStyleSetMargin(root_child0, YGEdgeRight, 5); + YGNodeStyleSetMargin(root_child0, YGEdgeBottom, 5); + YGNodeStyleSetPadding(root_child0, YGEdgeLeft, 3); + YGNodeStyleSetPadding(root_child0, YGEdgeTop, 3); + YGNodeStyleSetPadding(root_child0, YGEdgeRight, 3); + YGNodeStyleSetPadding(root_child0, YGEdgeBottom, 3); + YGNodeStyleSetMinWidthPercent(root_child0, 60); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child0_child0 = YGNodeNew(); - YGNodeStyleSetMargin(root_child0_child0, YGEdgeLeft, YGPx(5)); - YGNodeStyleSetMargin(root_child0_child0, YGEdgeTop, YGPx(5)); - YGNodeStyleSetMargin(root_child0_child0, YGEdgeRight, YGPx(5)); - YGNodeStyleSetMargin(root_child0_child0, YGEdgeBottom, YGPx(5)); - YGNodeStyleSetPadding(root_child0_child0, YGEdgeLeft, YGPercent(3)); - YGNodeStyleSetPadding(root_child0_child0, YGEdgeTop, YGPercent(3)); - YGNodeStyleSetPadding(root_child0_child0, YGEdgeRight, YGPercent(3)); - YGNodeStyleSetPadding(root_child0_child0, YGEdgeBottom, YGPercent(3)); - YGNodeStyleSetWidth(root_child0_child0, YGPercent(50)); + YGNodeStyleSetMargin(root_child0_child0, YGEdgeLeft, 5); + YGNodeStyleSetMargin(root_child0_child0, YGEdgeTop, 5); + YGNodeStyleSetMargin(root_child0_child0, YGEdgeRight, 5); + YGNodeStyleSetMargin(root_child0_child0, YGEdgeBottom, 5); + YGNodeStyleSetPaddingPercent(root_child0_child0, YGEdgeLeft, 3); + YGNodeStyleSetPaddingPercent(root_child0_child0, YGEdgeTop, 3); + YGNodeStyleSetPaddingPercent(root_child0_child0, YGEdgeRight, 3); + YGNodeStyleSetPaddingPercent(root_child0_child0, YGEdgeBottom, 3); + YGNodeStyleSetWidthPercent(root_child0_child0, 50); YGNodeInsertChild(root_child0, root_child0_child0, 0); const YGNodeRef root_child0_child0_child0 = YGNodeNew(); - YGNodeStyleSetMargin(root_child0_child0_child0, YGEdgeLeft, YGPercent(5)); - YGNodeStyleSetMargin(root_child0_child0_child0, YGEdgeTop, YGPercent(5)); - YGNodeStyleSetMargin(root_child0_child0_child0, YGEdgeRight, YGPercent(5)); - YGNodeStyleSetMargin(root_child0_child0_child0, YGEdgeBottom, YGPercent(5)); - YGNodeStyleSetPadding(root_child0_child0_child0, YGEdgeLeft, YGPx(3)); - YGNodeStyleSetPadding(root_child0_child0_child0, YGEdgeTop, YGPx(3)); - YGNodeStyleSetPadding(root_child0_child0_child0, YGEdgeRight, YGPx(3)); - YGNodeStyleSetPadding(root_child0_child0_child0, YGEdgeBottom, YGPx(3)); - YGNodeStyleSetWidth(root_child0_child0_child0, YGPercent(45)); + YGNodeStyleSetMarginPercent(root_child0_child0_child0, YGEdgeLeft, 5); + YGNodeStyleSetMarginPercent(root_child0_child0_child0, YGEdgeTop, 5); + YGNodeStyleSetMarginPercent(root_child0_child0_child0, YGEdgeRight, 5); + YGNodeStyleSetMarginPercent(root_child0_child0_child0, YGEdgeBottom, 5); + YGNodeStyleSetPadding(root_child0_child0_child0, YGEdgeLeft, 3); + YGNodeStyleSetPadding(root_child0_child0_child0, YGEdgeTop, 3); + YGNodeStyleSetPadding(root_child0_child0_child0, YGEdgeRight, 3); + YGNodeStyleSetPadding(root_child0_child0_child0, YGEdgeBottom, 3); + YGNodeStyleSetWidthPercent(root_child0_child0_child0, 45); YGNodeInsertChild(root_child0_child0, root_child0_child0_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 4); - YGNodeStyleSetFlexBasis(root_child1, YGPercent(15)); - YGNodeStyleSetMinWidth(root_child1, YGPercent(20)); + YGNodeStyleSetFlexBasisPercent(root_child1, 15); + YGNodeStyleSetMinWidthPercent(root_child1, 20); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -763,20 +763,20 @@ TEST(YogaTest, percentage_margin_should_calculate_based_only_on_width) { YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(200)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetMargin(root_child0, YGEdgeLeft, YGPercent(10)); - YGNodeStyleSetMargin(root_child0, YGEdgeTop, YGPercent(10)); - YGNodeStyleSetMargin(root_child0, YGEdgeRight, YGPercent(10)); - YGNodeStyleSetMargin(root_child0, YGEdgeBottom, YGPercent(10)); + YGNodeStyleSetMarginPercent(root_child0, YGEdgeLeft, 10); + YGNodeStyleSetMarginPercent(root_child0, YGEdgeTop, 10); + YGNodeStyleSetMarginPercent(root_child0, YGEdgeRight, 10); + YGNodeStyleSetMarginPercent(root_child0, YGEdgeBottom, 10); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child0_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0_child0, YGPx(10)); - YGNodeStyleSetHeight(root_child0_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0_child0, 10); + YGNodeStyleSetHeight(root_child0_child0, 10); YGNodeInsertChild(root_child0, root_child0_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -821,20 +821,20 @@ TEST(YogaTest, percentage_padding_should_calculate_based_only_on_width) { YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(200)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetPadding(root_child0, YGEdgeLeft, YGPercent(10)); - YGNodeStyleSetPadding(root_child0, YGEdgeTop, YGPercent(10)); - YGNodeStyleSetPadding(root_child0, YGEdgeRight, YGPercent(10)); - YGNodeStyleSetPadding(root_child0, YGEdgeBottom, YGPercent(10)); + YGNodeStyleSetPaddingPercent(root_child0, YGEdgeLeft, 10); + YGNodeStyleSetPaddingPercent(root_child0, YGEdgeTop, 10); + YGNodeStyleSetPaddingPercent(root_child0, YGEdgeRight, 10); + YGNodeStyleSetPaddingPercent(root_child0, YGEdgeBottom, 10); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child0_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0_child0, YGPx(10)); - YGNodeStyleSetHeight(root_child0_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0_child0, 10); + YGNodeStyleSetHeight(root_child0_child0, 10); YGNodeInsertChild(root_child0, root_child0_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -879,15 +879,15 @@ TEST(YogaTest, percentage_absolute_position) { YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(200)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); - YGNodeStyleSetPosition(root_child0, YGEdgeLeft, YGPercent(30)); - YGNodeStyleSetPosition(root_child0, YGEdgeTop, YGPercent(10)); - YGNodeStyleSetWidth(root_child0, YGPx(10)); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetPositionPercent(root_child0, YGEdgeLeft, 30); + YGNodeStyleSetPositionPercent(root_child0, YGEdgeTop, 10); + YGNodeStyleSetWidth(root_child0, 10); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); diff --git a/tests/YGRelayoutTest.cpp b/tests/YGRelayoutTest.cpp index b637d17c..de298325 100644 --- a/tests/YGRelayoutTest.cpp +++ b/tests/YGRelayoutTest.cpp @@ -16,8 +16,8 @@ TEST(YogaTest, dont_cache_computed_flex_basis_between_layouts) { const YGNodeRef root = YGNodeNew(); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeight(root_child0, YGPx(10)); - YGNodeStyleSetFlexBasis(root_child0, YGPx(20)); + YGNodeStyleSetHeight(root_child0, 10); + YGNodeStyleSetFlexBasis(root_child0, 20); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, 100, YGUndefined, YGDirectionLTR); diff --git a/tests/YGRoundingTest.cpp b/tests/YGRoundingTest.cpp index aaad141c..0ce9f5c0 100644 --- a/tests/YGRoundingTest.cpp +++ b/tests/YGRoundingTest.cpp @@ -17,8 +17,8 @@ TEST(YogaTest, rounding_flex_basis_flex_grow_row_width_of_100) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); @@ -85,8 +85,8 @@ TEST(YogaTest, rounding_flex_basis_flex_grow_row_prime_number_width) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, YGPx(113)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 113); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); @@ -181,20 +181,20 @@ TEST(YogaTest, rounding_flex_basis_flex_shrink_row) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, YGPx(101)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 101); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexShrink(root_child0, 1); - YGNodeStyleSetFlexBasis(root_child0, YGPx(100)); + YGNodeStyleSetFlexBasis(root_child0, 100); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetFlexBasis(root_child1, YGPx(25)); + YGNodeStyleSetFlexBasis(root_child1, 25); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetFlexBasis(root_child2, YGPx(25)); + YGNodeStyleSetFlexBasis(root_child2, 25); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -249,23 +249,23 @@ TEST(YogaTest, rounding_flex_basis_overrides_main_size) { YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(113)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 113); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasis(root_child0, YGPx(50)); - YGNodeStyleSetHeight(root_child0, YGPx(20)); + YGNodeStyleSetFlexBasis(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 20); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 1); - YGNodeStyleSetHeight(root_child1, YGPx(10)); + YGNodeStyleSetHeight(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child2, 1); - YGNodeStyleSetHeight(root_child2, YGPx(10)); + YGNodeStyleSetHeight(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -320,23 +320,23 @@ TEST(YogaTest, rounding_total_fractial) { YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(87.4f)); - YGNodeStyleSetHeight(root, YGPx(113.4f)); + YGNodeStyleSetWidth(root, 87.4f); + YGNodeStyleSetHeight(root, 113.4f); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 0.7f); - YGNodeStyleSetFlexBasis(root_child0, YGPx(50.3f)); - YGNodeStyleSetHeight(root_child0, YGPx(20.3f)); + YGNodeStyleSetFlexBasis(root_child0, 50.3f); + YGNodeStyleSetHeight(root_child0, 20.3f); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 1.6f); - YGNodeStyleSetHeight(root_child1, YGPx(10)); + YGNodeStyleSetHeight(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child2, 1.1f); - YGNodeStyleSetHeight(root_child2, YGPx(10.7f)); + YGNodeStyleSetHeight(root_child2, 10.7f); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -391,37 +391,37 @@ TEST(YogaTest, rounding_total_fractial_nested) { YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(87.4f)); - YGNodeStyleSetHeight(root, YGPx(113.4f)); + YGNodeStyleSetWidth(root, 87.4f); + YGNodeStyleSetHeight(root, 113.4f); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 0.7f); - YGNodeStyleSetFlexBasis(root_child0, YGPx(50.3f)); - YGNodeStyleSetHeight(root_child0, YGPx(20.3f)); + YGNodeStyleSetFlexBasis(root_child0, 50.3f); + YGNodeStyleSetHeight(root_child0, 20.3f); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child0_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0_child0, 1); - YGNodeStyleSetFlexBasis(root_child0_child0, YGPx(0.3f)); - YGNodeStyleSetPosition(root_child0_child0, YGEdgeBottom, YGPx(13.3f)); - YGNodeStyleSetHeight(root_child0_child0, YGPx(9.9f)); + YGNodeStyleSetFlexBasis(root_child0_child0, 0.3f); + YGNodeStyleSetPosition(root_child0_child0, YGEdgeBottom, 13.3f); + YGNodeStyleSetHeight(root_child0_child0, 9.9f); YGNodeInsertChild(root_child0, root_child0_child0, 0); const YGNodeRef root_child0_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0_child1, 4); - YGNodeStyleSetFlexBasis(root_child0_child1, YGPx(0.3f)); - YGNodeStyleSetPosition(root_child0_child1, YGEdgeTop, YGPx(13.3f)); - YGNodeStyleSetHeight(root_child0_child1, YGPx(1.1f)); + YGNodeStyleSetFlexBasis(root_child0_child1, 0.3f); + YGNodeStyleSetPosition(root_child0_child1, YGEdgeTop, 13.3f); + YGNodeStyleSetHeight(root_child0_child1, 1.1f); YGNodeInsertChild(root_child0, root_child0_child1, 1); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 1.6f); - YGNodeStyleSetHeight(root_child1, YGPx(10)); + YGNodeStyleSetHeight(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child2, 1.1f); - YGNodeStyleSetHeight(root_child2, YGPx(10.7f)); + YGNodeStyleSetHeight(root_child2, 10.7f); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -496,23 +496,23 @@ TEST(YogaTest, rounding_fractial_input_1) { YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(113.4f)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 113.4f); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasis(root_child0, YGPx(50)); - YGNodeStyleSetHeight(root_child0, YGPx(20)); + YGNodeStyleSetFlexBasis(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 20); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 1); - YGNodeStyleSetHeight(root_child1, YGPx(10)); + YGNodeStyleSetHeight(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child2, 1); - YGNodeStyleSetHeight(root_child2, YGPx(10)); + YGNodeStyleSetHeight(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -567,23 +567,23 @@ TEST(YogaTest, rounding_fractial_input_2) { YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(113.6f)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 113.6f); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasis(root_child0, YGPx(50)); - YGNodeStyleSetHeight(root_child0, YGPx(20)); + YGNodeStyleSetFlexBasis(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 20); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 1); - YGNodeStyleSetHeight(root_child1, YGPx(10)); + YGNodeStyleSetHeight(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child2, 1); - YGNodeStyleSetHeight(root_child2, YGPx(10)); + YGNodeStyleSetHeight(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -638,24 +638,24 @@ TEST(YogaTest, rounding_fractial_input_3) { YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetPosition(root, YGEdgeTop, YGPx(0.3f)); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(113.4f)); + YGNodeStyleSetPosition(root, YGEdgeTop, 0.3f); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 113.4f); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasis(root_child0, YGPx(50)); - YGNodeStyleSetHeight(root_child0, YGPx(20)); + YGNodeStyleSetFlexBasis(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 20); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 1); - YGNodeStyleSetHeight(root_child1, YGPx(10)); + YGNodeStyleSetHeight(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child2, 1); - YGNodeStyleSetHeight(root_child2, YGPx(10)); + YGNodeStyleSetHeight(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -710,24 +710,24 @@ TEST(YogaTest, rounding_fractial_input_4) { YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetPosition(root, YGEdgeTop, YGPx(0.7f)); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(113.4f)); + YGNodeStyleSetPosition(root, YGEdgeTop, 0.7f); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 113.4f); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasis(root_child0, YGPx(50)); - YGNodeStyleSetHeight(root_child0, YGPx(20)); + YGNodeStyleSetFlexBasis(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 20); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 1); - YGNodeStyleSetHeight(root_child1, YGPx(10)); + YGNodeStyleSetHeight(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child2, 1); - YGNodeStyleSetHeight(root_child2, YGPx(10)); + YGNodeStyleSetHeight(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); diff --git a/yoga/YGEnums.h b/yoga/YGEnums.h index 7f3af522..c1428afc 100644 --- a/yoga/YGEnums.h +++ b/yoga/YGEnums.h @@ -21,8 +21,9 @@ typedef enum YGFlexDirection { YGFlexDirectionRowReverse, } YGFlexDirection; -#define YGUnitCount 2 +#define YGUnitCount 3 typedef enum YGUnit { + YGUnitUndefined, YGUnitPixel, YGUnitPercent, } YGUnit; diff --git a/yoga/Yoga.c b/yoga/Yoga.c index 64cf4ebb..90d1a5d9 100644 --- a/yoga/Yoga.c +++ b/yoga/Yoga.c @@ -106,6 +106,11 @@ typedef struct YGNode { void *context; } YGNode; +#define YG_UNDEFINED_VALUES { \ + .value = YGUndefined, \ + .unit = YGUnitUndefined \ +} + #define YG_DEFAULT_EDGE_VALUES { \ [YGEdgeLeft] = YGUndefined, \ [YGEdgeTop] = YGUndefined, \ @@ -118,11 +123,28 @@ typedef struct YGNode { [YGEdgeAll] = YGUndefined, \ } +#define YG_DEFAULT_EDGE_VALUES_UNIT { \ + [YGEdgeLeft] = YG_UNDEFINED_VALUES, \ + [YGEdgeTop] = YG_UNDEFINED_VALUES, \ + [YGEdgeRight] = YG_UNDEFINED_VALUES, \ + [YGEdgeBottom] = YG_UNDEFINED_VALUES, \ + [YGEdgeStart] = YG_UNDEFINED_VALUES, \ + [YGEdgeEnd] = YG_UNDEFINED_VALUES, \ + [YGEdgeHorizontal] = YG_UNDEFINED_VALUES, \ + [YGEdgeVertical] = YG_UNDEFINED_VALUES, \ + [YGEdgeAll] = YG_UNDEFINED_VALUES, \ +} + #define YG_DEFAULT_DIMENSION_VALUES { \ [YGDimensionWidth] = YGUndefined, \ [YGDimensionHeight] = YGUndefined, \ } +#define YG_DEFAULT_DIMENSION_VALUES_UNIT { \ + [YGDimensionWidth] = YG_UNDEFINED_VALUES, \ + [YGDimensionHeight] = YG_UNDEFINED_VALUES, \ +} + YGNode gYGNodeDefaults = { .parent = NULL, .children = NULL, @@ -133,19 +155,19 @@ YGNode gYGNodeDefaults = { .flex = YGUndefined, .flexGrow = YGUndefined, .flexShrink = YGUndefined, - .flexBasis = YGUndefined, + .flexBasis = YG_UNDEFINED_VALUES, .justifyContent = YGJustifyFlexStart, .alignItems = YGAlignStretch, .alignContent = YGAlignFlexStart, .direction = YGDirectionInherit, .flexDirection = YGFlexDirectionColumn, .overflow = YGOverflowVisible, - .dimensions = YG_DEFAULT_DIMENSION_VALUES, - .minDimensions = YG_DEFAULT_DIMENSION_VALUES, - .maxDimensions = YG_DEFAULT_DIMENSION_VALUES, - .position = YG_DEFAULT_EDGE_VALUES, - .margin = YG_DEFAULT_EDGE_VALUES, - .padding = YG_DEFAULT_EDGE_VALUES, + .dimensions = YG_DEFAULT_DIMENSION_VALUES_UNIT, + .minDimensions = YG_DEFAULT_DIMENSION_VALUES_UNIT, + .maxDimensions = YG_DEFAULT_DIMENSION_VALUES_UNIT, + .position = YG_DEFAULT_EDGE_VALUES_UNIT, + .margin = YG_DEFAULT_EDGE_VALUES_UNIT, + .padding = YG_DEFAULT_EDGE_VALUES_UNIT, .border = YG_DEFAULT_EDGE_VALUES, .aspectRatio = YGUndefined, }, @@ -175,13 +197,11 @@ YGFree gYGFree = &free; static YGValue YGValueUndefined = { .value = YGUndefined, - .isDefined = false, - .unit = YGUnitPixel + .unit = YGUnitUndefined }; static YGValue YGValueZero = { .value = 0, - .isDefined = true, .unit = YGUnitPixel }; @@ -231,20 +251,20 @@ static inline const YGValue * YGComputedEdgeValue(const YGValue edges[YGEdgeCoun const YGValue * const defaultValue) { YG_ASSERT(edge <= YGEdgeEnd, "Cannot get computed value of multi-edge shorthands"); - if (edges[edge].isDefined) { + if (edges[edge].unit != YGUnitUndefined) { return &edges[edge]; } - if ((edge == YGEdgeTop || edge == YGEdgeBottom) && edges[YGEdgeVertical].isDefined) { + if ((edge == YGEdgeTop || edge == YGEdgeBottom) && edges[YGEdgeVertical].unit != YGUnitUndefined) { return &edges[YGEdgeVertical]; } if ((edge == YGEdgeLeft || edge == YGEdgeRight || edge == YGEdgeStart || edge == YGEdgeEnd) && - edges[YGEdgeHorizontal].isDefined) { + edges[YGEdgeHorizontal].unit != YGUnitUndefined) { return &edges[YGEdgeHorizontal]; } - if (edges[YGEdgeAll].isDefined) { + if (edges[YGEdgeAll].unit != YGUnitUndefined) { return &edges[YGEdgeAll]; } @@ -265,24 +285,6 @@ static inline float YGValueResolve(const YGValue * const unit, const float paren int32_t gNodeInstanceCount = 0; -YGValue YGPx(const float value){ - YGValue result = { - .value = value, - .isDefined = !YGFloatIsUndefined(value), - .unit = YGUnitPixel, - }; - return result; -} - -YGValue YGPercent(const float value){ - YGValue result = { - .value = value, - .isDefined = !YGFloatIsUndefined(value), - .unit = YGUnitPercent, - }; - return result; -} - YGNodeRef YGNodeNew(void) { const YGNodeRef node = gYGMalloc(sizeof(YGNode)); YG_ASSERT(node, "Could not allocate memory for node"); @@ -421,7 +423,7 @@ inline float YGNodeStyleGetFlexShrink(const YGNodeRef node) { } static inline const YGValue * YGNodeStyleGetFlexBasisPtr(const YGNodeRef node) { - if (node->style.flexBasis.isDefined) { + if (node->style.flexBasis.unit != YGUnitUndefined) { return &node->style.flexBasis; } if (!YGFloatIsUndefined(node->style.flex) && node->style.flex > 0.0f) { @@ -460,10 +462,17 @@ void YGNodeStyleSetFlex(const YGNodeRef node, const float flex) { #define YG_NODE_STYLE_PROPERTY_SETTER_UNIT_IMPL(type, name, paramName, instanceName) \ void YGNodeStyleSet##name(const YGNodeRef node, const type paramName) { \ - if (node->style.instanceName.value != paramName.value || node->style.instanceName.unit != paramName.unit) { \ - node->style.instanceName.value = paramName.value; \ - node->style.instanceName.isDefined = !YGFloatIsUndefined(paramName.value); \ - node->style.instanceName.unit = paramName.unit; \ + if (node->style.instanceName.value != paramName || node->style.instanceName.unit != YGUnitPixel) { \ + node->style.instanceName.value = paramName; \ + node->style.instanceName.unit = YGFloatIsUndefined(paramName) ? YGUnitUndefined : YGUnitPixel; \ + YGNodeMarkDirtyInternal(node); \ + } \ + } \ + \ + void YGNodeStyleSet##name##Percent(const YGNodeRef node, const type paramName) { \ + if (node->style.instanceName.value != paramName || node->style.instanceName.unit != YGUnitPercent) { \ + node->style.instanceName.value = paramName; \ + node->style.instanceName.unit = YGFloatIsUndefined(paramName) ? YGUnitUndefined : YGUnitPercent; \ YGNodeMarkDirtyInternal(node); \ } \ } @@ -476,18 +485,25 @@ void YGNodeStyleSetFlex(const YGNodeRef node, const float flex) { } #define YG_NODE_STYLE_PROPERTY_UNIT_IMPL(type, name, paramName, instanceName) \ - YG_NODE_STYLE_PROPERTY_SETTER_UNIT_IMPL(type, name, paramName, instanceName) \ + YG_NODE_STYLE_PROPERTY_SETTER_UNIT_IMPL(float, name, paramName, instanceName) \ \ type YGNodeStyleGet##name(const YGNodeRef node) { \ return node->style.instanceName; \ } #define YG_NODE_STYLE_EDGE_PROPERTY_UNIT_IMPL(type, name, paramName, instanceName, defaultValue) \ - void YGNodeStyleSet##name(const YGNodeRef node, const YGEdge edge, const type paramName) { \ - if (node->style.instanceName[edge].value != paramName.value || node->style.instanceName[edge].unit != paramName.unit ) { \ - node->style.instanceName[edge].value = paramName.value; \ - node->style.instanceName[edge].isDefined = !YGFloatIsUndefined(paramName.value); \ - node->style.instanceName[edge].unit = paramName.unit; \ + void YGNodeStyleSet##name(const YGNodeRef node, const YGEdge edge, const float paramName) { \ + if (node->style.instanceName[edge].value != paramName || node->style.instanceName[edge].unit != YGUnitPixel ) { \ + node->style.instanceName[edge].value = paramName; \ + node->style.instanceName[edge].unit = YGFloatIsUndefined(paramName) ? YGUnitUndefined : YGUnitPixel; \ + YGNodeMarkDirtyInternal(node); \ + } \ + } \ + \ + void YGNodeStyleSet##name##Percent(const YGNodeRef node, const YGEdge edge, const float paramName) { \ + if (node->style.instanceName[edge].value != paramName || node->style.instanceName[edge].unit != YGUnitPercent ) { \ + node->style.instanceName[edge].value = paramName; \ + node->style.instanceName[edge].unit = YGFloatIsUndefined(paramName) ? YGUnitUndefined : YGUnitPercent; \ YGNodeMarkDirtyInternal(node); \ } \ } \ @@ -501,8 +517,15 @@ void YGNodeStyleSetFlex(const YGNodeRef node, const float flex) { void YGNodeStyleSet##name(const YGNodeRef node, const YGEdge edge, const float paramName) { \ if (node->style.instanceName[edge].value != paramName || node->style.instanceName[edge].unit != YGUnitPixel ) { \ node->style.instanceName[edge].value = paramName; \ - node->style.instanceName[edge].isDefined = !YGFloatIsUndefined(paramName); \ - node->style.instanceName[edge].unit = YGUnitPixel; \ + node->style.instanceName[edge].unit = YGFloatIsUndefined(paramName) ? YGUnitUndefined : YGUnitPixel; \ + YGNodeMarkDirtyInternal(node); \ + } \ + } \ + \ + void YGNodeStyleSet##name##Percent(const YGNodeRef node, const YGEdge edge, const float paramName) { \ + if (node->style.instanceName[edge].value != paramName || node->style.instanceName[edge].unit != YGUnitPercent ) { \ + node->style.instanceName[edge].value = paramName; \ + node->style.instanceName[edge].unit = YGFloatIsUndefined(paramName) ? YGUnitUndefined : YGUnitPercent; \ YGNodeMarkDirtyInternal(node); \ } \ } \ @@ -532,7 +555,7 @@ YG_NODE_STYLE_PROPERTY_IMPL(YGOverflow, Overflow, overflow, overflow); YG_NODE_STYLE_PROPERTY_SETTER_IMPL(float, FlexGrow, flexGrow, flexGrow); YG_NODE_STYLE_PROPERTY_SETTER_IMPL(float, FlexShrink, flexShrink, flexShrink); -YG_NODE_STYLE_PROPERTY_SETTER_UNIT_IMPL(YGValue, FlexBasis, flexBasis, flexBasis); +YG_NODE_STYLE_PROPERTY_SETTER_UNIT_IMPL(float, FlexBasis, flexBasis, flexBasis); YG_NODE_STYLE_EDGE_PROPERTY_UNIT_IMPL(YGValue, Position, position, position, YGValueUndefined); YG_NODE_STYLE_EDGE_PROPERTY_UNIT_IMPL(YGValue, Margin, margin, margin, YGValueZero); @@ -575,7 +598,7 @@ inline bool YGFloatIsUndefined(const float value) { } static inline bool YGValueEqual(const YGValue a, const YGValue b) { - if (a.isDefined != b.isDefined || a.unit != b.unit) { + if (a.unit != YGUnitUndefined != b.unit != YGUnitUndefined || a.unit != b.unit) { return false; } @@ -608,7 +631,7 @@ static void YGPrintNumberIfNotUndefinedf(const char *str, const float number) { } static void YGPrintNumberIfNotUndefined(const char *str, const YGValue * const number) { - if (number->isDefined) { + if (number->unit != YGUnitUndefined) { YGLog(YGLogLevelDebug, "%s: %g%s, ", str, number->value, number->unit == YGUnitPixel ? "px" : "%"); } } @@ -797,7 +820,7 @@ static inline bool YGFlexDirectionIsColumn(const YGFlexDirection flexDirection) } static inline float YGNodeLeadingMargin(const YGNodeRef node, const YGFlexDirection axis, const float widthSize) { - if (YGFlexDirectionIsRow(axis) && node->style.margin[YGEdgeStart].isDefined) { + if (YGFlexDirectionIsRow(axis) && node->style.margin[YGEdgeStart].unit != YGUnitUndefined) { return YGValueResolve(&node->style.margin[YGEdgeStart], widthSize); } @@ -805,7 +828,7 @@ static inline float YGNodeLeadingMargin(const YGNodeRef node, const YGFlexDirect } static float YGNodeTrailingMargin(const YGNodeRef node, const YGFlexDirection axis, const float widthSize) { - if (YGFlexDirectionIsRow(axis) && node->style.margin[YGEdgeEnd].isDefined) { + if (YGFlexDirectionIsRow(axis) && node->style.margin[YGEdgeEnd].unit != YGUnitUndefined) { return YGValueResolve(&node->style.margin[YGEdgeEnd], widthSize); } @@ -813,7 +836,7 @@ static float YGNodeTrailingMargin(const YGNodeRef node, const YGFlexDirection ax } static float YGNodeLeadingPadding(const YGNodeRef node, const YGFlexDirection axis, const float widthSize) { - if (YGFlexDirectionIsRow(axis) && node->style.padding[YGEdgeStart].isDefined && + if (YGFlexDirectionIsRow(axis) && node->style.padding[YGEdgeStart].unit != YGUnitUndefined && YGValueResolve(&node->style.padding[YGEdgeStart], widthSize) >= 0.0f) { return YGValueResolve(&node->style.padding[YGEdgeStart], widthSize); } @@ -822,7 +845,7 @@ static float YGNodeLeadingPadding(const YGNodeRef node, const YGFlexDirection ax } static float YGNodeTrailingPadding(const YGNodeRef node, const YGFlexDirection axis, const float widthSize) { - if (YGFlexDirectionIsRow(axis) && node->style.padding[YGEdgeEnd].isDefined && + if (YGFlexDirectionIsRow(axis) && node->style.padding[YGEdgeEnd].unit != YGUnitUndefined && YGValueResolve(&node->style.padding[YGEdgeEnd], widthSize) >= 0.0f) { return YGValueResolve(&node->style.padding[YGEdgeEnd], widthSize); } @@ -831,7 +854,7 @@ static float YGNodeTrailingPadding(const YGNodeRef node, const YGFlexDirection a } static float YGNodeLeadingBorder(const YGNodeRef node, const YGFlexDirection axis) { - if (YGFlexDirectionIsRow(axis) && node->style.border[YGEdgeStart].isDefined && + if (YGFlexDirectionIsRow(axis) && node->style.border[YGEdgeStart].unit != YGUnitUndefined && node->style.border[YGEdgeStart].value >= 0.0f) { return node->style.border[YGEdgeStart].value; } @@ -840,7 +863,7 @@ static float YGNodeLeadingBorder(const YGNodeRef node, const YGFlexDirection axi } static float YGNodeTrailingBorder(const YGNodeRef node, const YGFlexDirection axis) { - if (YGFlexDirectionIsRow(axis) && node->style.border[YGEdgeEnd].isDefined && + if (YGFlexDirectionIsRow(axis) && node->style.border[YGEdgeEnd].unit != YGUnitUndefined && node->style.border[YGEdgeEnd].value >= 0.0f) { return node->style.border[YGEdgeEnd].value; } @@ -911,7 +934,7 @@ static inline float YGNodeDimWithMargin(const YGNodeRef node, const YGFlexDirect } static inline bool YGNodeIsStyleDimDefined(const YGNodeRef node, const YGFlexDirection axis) { - return node->style.dimensions[dim[axis]].isDefined && node->style.dimensions[dim[axis]].value >= 0.0f; + return node->style.dimensions[dim[axis]].unit != YGUnitUndefined && node->style.dimensions[dim[axis]].value >= 0.0f; } static inline bool YGNodeIsLayoutDimDefined(const YGNodeRef node, const YGFlexDirection axis) { @@ -921,21 +944,21 @@ static inline bool YGNodeIsLayoutDimDefined(const YGNodeRef node, const YGFlexDi static inline bool YGNodeIsLeadingPosDefined(const YGNodeRef node, const YGFlexDirection axis) { return (YGFlexDirectionIsRow(axis) && - YGComputedEdgeValue(node->style.position, YGEdgeStart, &YGValueUndefined)->isDefined) || - YGComputedEdgeValue(node->style.position, leading[axis], &YGValueUndefined)->isDefined; + YGComputedEdgeValue(node->style.position, YGEdgeStart, &YGValueUndefined)->unit != YGUnitUndefined) || + YGComputedEdgeValue(node->style.position, leading[axis], &YGValueUndefined)->unit != YGUnitUndefined; } static inline bool YGNodeIsTrailingPosDefined(const YGNodeRef node, const YGFlexDirection axis) { return (YGFlexDirectionIsRow(axis) && - YGComputedEdgeValue(node->style.position, YGEdgeEnd, &YGValueUndefined)->isDefined) || - YGComputedEdgeValue(node->style.position, trailing[axis], &YGValueUndefined)->isDefined; + YGComputedEdgeValue(node->style.position, YGEdgeEnd, &YGValueUndefined)->unit != YGUnitUndefined) || + YGComputedEdgeValue(node->style.position, trailing[axis], &YGValueUndefined)->unit != YGUnitUndefined; } static float YGNodeLeadingPosition(const YGNodeRef node, const YGFlexDirection axis, const float axisSize) { if (YGFlexDirectionIsRow(axis)) { const YGValue * leadingPosition = YGComputedEdgeValue(node->style.position, YGEdgeStart, &YGValueUndefined); - if (leadingPosition->isDefined) { + if (leadingPosition->unit != YGUnitUndefined) { return YGValueResolve(leadingPosition, axisSize); } } @@ -943,14 +966,14 @@ static float YGNodeLeadingPosition(const YGNodeRef node, const YGFlexDirection a const YGValue * leadingPosition = YGComputedEdgeValue(node->style.position, leading[axis], &YGValueUndefined); - return !leadingPosition->isDefined ? 0.0f : YGValueResolve(leadingPosition, axisSize); + return !leadingPosition->unit != YGUnitUndefined ? 0.0f : YGValueResolve(leadingPosition, axisSize); } static float YGNodeTrailingPosition(const YGNodeRef node, const YGFlexDirection axis, const float axisSize) { if (YGFlexDirectionIsRow(axis)) { const YGValue * trailingPosition = YGComputedEdgeValue(node->style.position, YGEdgeEnd, &YGValueUndefined); - if (trailingPosition->isDefined) { + if (trailingPosition->unit != YGUnitUndefined) { return YGValueResolve(trailingPosition, axisSize); } } @@ -958,7 +981,7 @@ static float YGNodeTrailingPosition(const YGNodeRef node, const YGFlexDirection const YGValue * trailingPosition = YGComputedEdgeValue(node->style.position, trailing[axis], &YGValueUndefined); - return !trailingPosition->isDefined ? 0.0f : YGValueResolve(trailingPosition, axisSize); + return !trailingPosition->unit != YGUnitUndefined ? 0.0f : YGValueResolve(trailingPosition, axisSize); } static float YGNodeBoundAxisWithinMinAndMax(const YGNodeRef node, @@ -1066,7 +1089,7 @@ static void YGNodeComputeFlexBasisForChild(const YGNodeRef node, const bool isRowStyleDimDefined = YGNodeIsStyleDimDefined(child, YGFlexDirectionRow); const bool isColumnStyleDimDefined = YGNodeIsStyleDimDefined(child, YGFlexDirectionColumn); - if (YGNodeStyleGetFlexBasisPtr(child)->isDefined && + if (YGNodeStyleGetFlexBasisPtr(child)->unit != YGUnitUndefined && !YGFloatIsUndefined(mainAxisSize)) { if (YGFloatIsUndefined(child->layout.computedFlexBasis) || (YGIsExperimentalFeatureEnabled(YGExperimentalFeatureWebFlexBasis) && @@ -2026,7 +2049,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, // constraint by the min size defined for the main axis. if (measureModeMainDim == YGMeasureModeAtMost && remainingFreeSpace > 0) { - if (node->style.minDimensions[dim[mainAxis]].isDefined && + if (node->style.minDimensions[dim[mainAxis]].unit != YGUnitUndefined && YGValueResolve(&node->style.minDimensions[dim[mainAxis]], mainAxisParentSize) >= 0) { remainingFreeSpace = fmaxf(0, YGValueResolve(&node->style.minDimensions[dim[mainAxis]], mainAxisParentSize) - diff --git a/yoga/Yoga.h b/yoga/Yoga.h index 7172f9ea..095cece1 100644 --- a/yoga/Yoga.h +++ b/yoga/Yoga.h @@ -41,12 +41,8 @@ typedef struct YGSize { typedef struct YGValue { float value; YGUnit unit; - bool isDefined; } YGValue; -WIN_EXPORT YGValue YGPx(const float value); -WIN_EXPORT YGValue YGPercent(const float value); - typedef struct YGNode *YGNodeRef; typedef YGSize (*YGMeasureFunc)(YGNodeRef node, float width, @@ -118,7 +114,8 @@ WIN_EXPORT void YGNodeCopyStyle(const YGNodeRef dstNode, const YGNodeRef srcNode WIN_EXPORT type YGNodeStyleGet##name(const YGNodeRef node); #define YG_NODE_STYLE_PROPERTY_UNIT(type, name, paramName) \ - WIN_EXPORT void YGNodeStyleSet##name(const YGNodeRef node, const type paramName); \ + WIN_EXPORT void YGNodeStyleSet##name(const YGNodeRef node, const float paramName); \ + WIN_EXPORT void YGNodeStyleSet##name##Percent(const YGNodeRef node, const float paramName); \ WIN_EXPORT type YGNodeStyleGet##name(const YGNodeRef node); #define YG_NODE_STYLE_EDGE_PROPERTY(type, name, paramName) \ @@ -130,7 +127,10 @@ WIN_EXPORT void YGNodeCopyStyle(const YGNodeRef dstNode, const YGNodeRef srcNode #define YG_NODE_STYLE_EDGE_PROPERTY_UNIT(type, name, paramName) \ WIN_EXPORT void YGNodeStyleSet##name(const YGNodeRef node, \ const YGEdge edge, \ - const type paramName); \ + const float paramName); \ + WIN_EXPORT void YGNodeStyleSet##name##Percent(const YGNodeRef node, \ + const YGEdge edge, \ + const float paramName); \ WIN_EXPORT type YGNodeStyleGet##name(const YGNodeRef node, const YGEdge edge); #define YG_NODE_LAYOUT_PROPERTY(type, name) \