Skip to content

Commit

Permalink
fix percentage padding
Browse files Browse the repository at this point in the history
  • Loading branch information
woehrl01 committed Oct 9, 2017
1 parent 08295a0 commit 40f4578
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
11 changes: 6 additions & 5 deletions tests/YGMeasureTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ TEST(YogaTest, percent_with_text_node) {
YGNodeStyleSetJustifyContent(root, YGJustifySpaceBetween);
YGNodeStyleSetAlignItems(root, YGAlignCenter);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 20);
YGNodeStyleSetHeight(root, 80);

const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeInsertChild(root, root_child0, 0);
Expand All @@ -643,24 +643,25 @@ TEST(YogaTest, percent_with_text_node) {

YGNodeSetMeasureFunc(root_child1, _measure_90_10);
YGNodeStyleSetMaxWidthPercent(root_child1, 50);
YGNodeStyleSetPaddingPercent(root_child1, YGEdgeTop, 50);
YGNodeInsertChild(root, root_child1, 1);

YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);

ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root));

ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0));

ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(5, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(15, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1));

YGNodeFreeRecursive(root);

Expand Down
4 changes: 2 additions & 2 deletions yoga/Yoga.c
Original file line number Diff line number Diff line change
Expand Up @@ -1776,7 +1776,7 @@ static void YGNodeWithMeasureFuncSetMeasuredDimensions(const YGNodeRef node,
? measuredSize.width + paddingAndBorderAxisRow
: availableWidth - marginAxisRow,
parentWidth,
availableWidth);
parentWidth);
node->layout.measuredDimensions[YGDimensionHeight] =
YGNodeBoundAxis(node,
YGFlexDirectionColumn,
Expand All @@ -1785,7 +1785,7 @@ static void YGNodeWithMeasureFuncSetMeasuredDimensions(const YGNodeRef node,
? measuredSize.height + paddingAndBorderAxisColumn
: availableHeight - marginAxisColumn,
parentHeight,
availableWidth);
parentWidth);
}
}

Expand Down

0 comments on commit 40f4578

Please sign in to comment.