diff --git a/tests/YGStyleAccessorsTest.cpp b/tests/YGStyleAccessorsTest.cpp index 4f6a187c..8f9967d8 100644 --- a/tests/YGStyleAccessorsTest.cpp +++ b/tests/YGStyleAccessorsTest.cpp @@ -96,11 +96,11 @@ ACCESSOR_TEST( ACCESSOR_TEST( justifyContent, - YGJustifyFlexStart, - YGJustifyFlexEnd, - YGJustifySpaceAround, - YGJustifyFlexStart, - YGJustifySpaceEvenly) + Justify::FlexStart, + Justify::FlexEnd, + Justify::SpaceAround, + Justify::FlexStart, + Justify::SpaceEvenly) ACCESSOR_TEST( alignContent, diff --git a/yoga/Yoga.cpp b/yoga/Yoga.cpp index 59bb80da..e1b980c2 100644 --- a/yoga/Yoga.cpp +++ b/yoga/Yoga.cpp @@ -449,10 +449,10 @@ void YGNodeStyleSetJustifyContent( const YGNodeRef node, const YGJustify justifyContent) { updateStyle( - node, &Style::justifyContent, justifyContent); + node, &Style::justifyContent, scopedEnum(justifyContent)); } YGJustify YGNodeStyleGetJustifyContent(const YGNodeConstRef node) { - return resolveRef(node)->getStyle().justifyContent(); + return unscopedEnum(resolveRef(node)->getStyle().justifyContent()); } void YGNodeStyleSetAlignContent( diff --git a/yoga/algorithm/CalculateLayout.cpp b/yoga/algorithm/CalculateLayout.cpp index 57afda80..8b8311a7 100644 --- a/yoga/algorithm/CalculateLayout.cpp +++ b/yoga/algorithm/CalculateLayout.cpp @@ -465,7 +465,7 @@ static void layoutAbsoluteChild( leadingEdge(mainAxis)); } else if ( !child->isLeadingPositionDefined(mainAxis) && - node->getStyle().justifyContent() == YGJustifyCenter) { + node->getStyle().justifyContent() == Justify::Center) { child->setLayoutPosition( (node->getLayout().measuredDimensions[dimension(mainAxis)] - child->getLayout().measuredDimensions[dimension(mainAxis)]) / @@ -473,7 +473,7 @@ static void layoutAbsoluteChild( leadingEdge(mainAxis)); } else if ( !child->isLeadingPositionDefined(mainAxis) && - node->getStyle().justifyContent() == YGJustifyFlexEnd) { + node->getStyle().justifyContent() == Justify::FlexEnd) { child->setLayoutPosition( (node->getLayout().measuredDimensions[dimension(mainAxis)] - child->getLayout().measuredDimensions[dimension(mainAxis)]), @@ -1196,7 +1196,7 @@ static void resolveFlexibleLength( flexLine.layout.remainingFreeSpace = originalFreeSpace - distributedFreeSpace; } -static void YGJustifyMainAxis( +static void justifyMainAxis( yoga::Node* const node, FlexLine& flexLine, const size_t startOfLineIndex, @@ -1263,36 +1263,36 @@ static void YGJustifyMainAxis( // each two elements. float leadingMainDim = 0; float betweenMainDim = gap; - const YGJustify justifyContent = node->getStyle().justifyContent(); + const Justify justifyContent = node->getStyle().justifyContent(); if (numberOfAutoMarginsOnCurrentLine == 0) { switch (justifyContent) { - case YGJustifyCenter: + case Justify::Center: leadingMainDim = flexLine.layout.remainingFreeSpace / 2; break; - case YGJustifyFlexEnd: + case Justify::FlexEnd: leadingMainDim = flexLine.layout.remainingFreeSpace; break; - case YGJustifySpaceBetween: + case Justify::SpaceBetween: if (flexLine.itemsInFlow.size() > 1) { betweenMainDim += yoga::maxOrDefined(flexLine.layout.remainingFreeSpace, 0) / static_cast(flexLine.itemsInFlow.size() - 1); } break; - case YGJustifySpaceEvenly: + case Justify::SpaceEvenly: // Space is distributed evenly across all elements leadingMainDim = flexLine.layout.remainingFreeSpace / static_cast(flexLine.itemsInFlow.size() + 1); betweenMainDim += leadingMainDim; break; - case YGJustifySpaceAround: + case Justify::SpaceAround: // Space on the edges is half of the space between elements leadingMainDim = 0.5f * flexLine.layout.remainingFreeSpace / static_cast(flexLine.itemsInFlow.size()); betweenMainDim += leadingMainDim * 2; break; - case YGJustifyFlexStart: + case Justify::FlexStart: break; } } @@ -1814,7 +1814,7 @@ static void calculateLayoutImpl( // of items that are aligned "stretch". We need to compute these stretch // values and set the final positions. - YGJustifyMainAxis( + justifyMainAxis( node, flexLine, startOfLineIndex, diff --git a/yoga/debug/NodeToString.cpp b/yoga/debug/NodeToString.cpp index 35f4628c..92f2c0d4 100644 --- a/yoga/debug/NodeToString.cpp +++ b/yoga/debug/NodeToString.cpp @@ -146,9 +146,7 @@ void nodeToString( } if (style.justifyContent() != yoga::Node{}.getStyle().justifyContent()) { appendFormattedString( - str, - "justify-content: %s; ", - YGJustifyToString(style.justifyContent())); + str, "justify-content: %s; ", toString(style.justifyContent())); } if (style.alignItems() != yoga::Node{}.getStyle().alignItems()) { appendFormattedString( diff --git a/yoga/style/Style.h b/yoga/style/Style.h index e0072f6b..c6f99c40 100644 --- a/yoga/style/Style.h +++ b/yoga/style/Style.h @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -106,7 +107,7 @@ class YG_EXPORT Style { static constexpr uint8_t justifyContentOffset = flexdirectionOffset + minimumBitCount(); static constexpr uint8_t alignContentOffset = - justifyContentOffset + minimumBitCount(); + justifyContentOffset + minimumBitCount(); static constexpr uint8_t alignItemsOffset = alignContentOffset + minimumBitCount(); static constexpr uint8_t alignSelfOffset = @@ -155,10 +156,10 @@ class YG_EXPORT Style { return {*this, flexdirectionOffset}; } - YGJustify justifyContent() const { - return getEnumData(flags, justifyContentOffset); + Justify justifyContent() const { + return getEnumData(flags, justifyContentOffset); } - BitfieldRef justifyContent() { + BitfieldRef justifyContent() { return {*this, justifyContentOffset}; }