C++ style enums 11/N: Align (#1395)
Summary: X-link: https://github.com/facebook/react-native/pull/39497 Pull Request resolved: https://github.com/facebook/yoga/pull/1395 Moves internal usages of YGAlign to Align bypass-github-export-checks Changelog: [Internal] Reviewed By: rshest Differential Revision: D49337511 fbshipit-source-id: bb9906fcd22780d2cfd8d1360ef69f66b9701bb6
This commit is contained in:
committed by
Facebook GitHub Bot
parent
61763e7d0a
commit
5bf81b1ef8
@@ -104,30 +104,30 @@ ACCESSOR_TEST(
|
|||||||
|
|
||||||
ACCESSOR_TEST(
|
ACCESSOR_TEST(
|
||||||
alignContent,
|
alignContent,
|
||||||
YGAlignFlexStart,
|
Align::FlexStart,
|
||||||
YGAlignAuto,
|
Align::Auto,
|
||||||
YGAlignFlexStart,
|
Align::FlexStart,
|
||||||
YGAlignCenter,
|
Align::Center,
|
||||||
YGAlignFlexEnd,
|
Align::FlexEnd,
|
||||||
YGAlignStretch)
|
Align::Stretch)
|
||||||
|
|
||||||
ACCESSOR_TEST(
|
ACCESSOR_TEST(
|
||||||
alignItems,
|
alignItems,
|
||||||
YGAlignStretch,
|
Align::Stretch,
|
||||||
YGAlignFlexStart,
|
Align::FlexStart,
|
||||||
YGAlignFlexEnd,
|
Align::FlexEnd,
|
||||||
YGAlignBaseline,
|
Align::Baseline,
|
||||||
YGAlignSpaceBetween,
|
Align::SpaceBetween,
|
||||||
YGAlignSpaceAround)
|
Align::SpaceAround)
|
||||||
|
|
||||||
ACCESSOR_TEST(
|
ACCESSOR_TEST(
|
||||||
alignSelf,
|
alignSelf,
|
||||||
YGAlignAuto,
|
Align::Auto,
|
||||||
YGAlignFlexStart,
|
Align::FlexStart,
|
||||||
YGAlignCenter,
|
Align::Center,
|
||||||
YGAlignAuto,
|
Align::Auto,
|
||||||
YGAlignFlexEnd,
|
Align::FlexEnd,
|
||||||
YGAlignStretch)
|
Align::Stretch)
|
||||||
|
|
||||||
ACCESSOR_TEST(
|
ACCESSOR_TEST(
|
||||||
positionType,
|
positionType,
|
||||||
|
@@ -459,24 +459,26 @@ void YGNodeStyleSetAlignContent(
|
|||||||
const YGNodeRef node,
|
const YGNodeRef node,
|
||||||
const YGAlign alignContent) {
|
const YGAlign alignContent) {
|
||||||
updateStyle<MSVC_HINT(alignContent)>(
|
updateStyle<MSVC_HINT(alignContent)>(
|
||||||
node, &Style::alignContent, alignContent);
|
node, &Style::alignContent, scopedEnum(alignContent));
|
||||||
}
|
}
|
||||||
YGAlign YGNodeStyleGetAlignContent(const YGNodeConstRef node) {
|
YGAlign YGNodeStyleGetAlignContent(const YGNodeConstRef node) {
|
||||||
return resolveRef(node)->getStyle().alignContent();
|
return unscopedEnum(resolveRef(node)->getStyle().alignContent());
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeStyleSetAlignItems(const YGNodeRef node, const YGAlign alignItems) {
|
void YGNodeStyleSetAlignItems(const YGNodeRef node, const YGAlign alignItems) {
|
||||||
updateStyle<MSVC_HINT(alignItems)>(node, &Style::alignItems, alignItems);
|
updateStyle<MSVC_HINT(alignItems)>(
|
||||||
|
node, &Style::alignItems, scopedEnum(alignItems));
|
||||||
}
|
}
|
||||||
YGAlign YGNodeStyleGetAlignItems(const YGNodeConstRef node) {
|
YGAlign YGNodeStyleGetAlignItems(const YGNodeConstRef node) {
|
||||||
return resolveRef(node)->getStyle().alignItems();
|
return unscopedEnum(resolveRef(node)->getStyle().alignItems());
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeStyleSetAlignSelf(const YGNodeRef node, const YGAlign alignSelf) {
|
void YGNodeStyleSetAlignSelf(const YGNodeRef node, const YGAlign alignSelf) {
|
||||||
updateStyle<MSVC_HINT(alignSelf)>(node, &Style::alignSelf, alignSelf);
|
updateStyle<MSVC_HINT(alignSelf)>(
|
||||||
|
node, &Style::alignSelf, scopedEnum(alignSelf));
|
||||||
}
|
}
|
||||||
YGAlign YGNodeStyleGetAlignSelf(const YGNodeConstRef node) {
|
YGAlign YGNodeStyleGetAlignSelf(const YGNodeConstRef node) {
|
||||||
return resolveRef(node)->getStyle().alignSelf();
|
return unscopedEnum(resolveRef(node)->getStyle().alignSelf());
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeStyleSetPositionType(
|
void YGNodeStyleSetPositionType(
|
||||||
|
@@ -14,14 +14,14 @@
|
|||||||
|
|
||||||
namespace facebook::yoga {
|
namespace facebook::yoga {
|
||||||
|
|
||||||
inline YGAlign resolveChildAlignment(
|
inline Align resolveChildAlignment(
|
||||||
const yoga::Node* node,
|
const yoga::Node* node,
|
||||||
const yoga::Node* child) {
|
const yoga::Node* child) {
|
||||||
const YGAlign align = child->getStyle().alignSelf() == YGAlignAuto
|
const Align align = child->getStyle().alignSelf() == Align::Auto
|
||||||
? node->getStyle().alignItems()
|
? node->getStyle().alignItems()
|
||||||
: child->getStyle().alignSelf();
|
: child->getStyle().alignSelf();
|
||||||
if (align == YGAlignBaseline && isColumn(node->getStyle().flexDirection())) {
|
if (align == Align::Baseline && isColumn(node->getStyle().flexDirection())) {
|
||||||
return YGAlignFlexStart;
|
return Align::FlexStart;
|
||||||
}
|
}
|
||||||
return align;
|
return align;
|
||||||
}
|
}
|
||||||
|
@@ -41,7 +41,7 @@ float calculateBaseline(const yoga::Node* node) {
|
|||||||
if (child->getStyle().positionType() == YGPositionTypeAbsolute) {
|
if (child->getStyle().positionType() == YGPositionTypeAbsolute) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (resolveChildAlignment(node, child) == YGAlignBaseline ||
|
if (resolveChildAlignment(node, child) == Align::Baseline ||
|
||||||
child->isReferenceBaseline()) {
|
child->isReferenceBaseline()) {
|
||||||
baselineChild = child;
|
baselineChild = child;
|
||||||
break;
|
break;
|
||||||
@@ -64,14 +64,14 @@ bool isBaselineLayout(const yoga::Node* node) {
|
|||||||
if (isColumn(node->getStyle().flexDirection())) {
|
if (isColumn(node->getStyle().flexDirection())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (node->getStyle().alignItems() == YGAlignBaseline) {
|
if (node->getStyle().alignItems() == Align::Baseline) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
const auto childCount = node->getChildCount();
|
const auto childCount = node->getChildCount();
|
||||||
for (size_t i = 0; i < childCount; i++) {
|
for (size_t i = 0; i < childCount; i++) {
|
||||||
auto child = node->getChild(i);
|
auto child = node->getChild(i);
|
||||||
if (child->getStyle().positionType() != YGPositionTypeAbsolute &&
|
if (child->getStyle().positionType() != YGPositionTypeAbsolute &&
|
||||||
child->getStyle().alignSelf() == YGAlignBaseline) {
|
child->getStyle().alignSelf() == Align::Baseline) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -247,7 +247,7 @@ static void computeFlexBasisForChild(
|
|||||||
const bool hasExactWidth =
|
const bool hasExactWidth =
|
||||||
!yoga::isUndefined(width) && widthMode == MeasureMode::Exactly;
|
!yoga::isUndefined(width) && widthMode == MeasureMode::Exactly;
|
||||||
const bool childWidthStretch =
|
const bool childWidthStretch =
|
||||||
resolveChildAlignment(node, child) == YGAlignStretch &&
|
resolveChildAlignment(node, child) == Align::Stretch &&
|
||||||
childWidthMeasureMode != MeasureMode::Exactly;
|
childWidthMeasureMode != MeasureMode::Exactly;
|
||||||
if (!isMainAxisRow && !isRowStyleDimDefined && hasExactWidth &&
|
if (!isMainAxisRow && !isRowStyleDimDefined && hasExactWidth &&
|
||||||
childWidthStretch) {
|
childWidthStretch) {
|
||||||
@@ -263,7 +263,7 @@ static void computeFlexBasisForChild(
|
|||||||
const bool hasExactHeight =
|
const bool hasExactHeight =
|
||||||
!yoga::isUndefined(height) && heightMode == MeasureMode::Exactly;
|
!yoga::isUndefined(height) && heightMode == MeasureMode::Exactly;
|
||||||
const bool childHeightStretch =
|
const bool childHeightStretch =
|
||||||
resolveChildAlignment(node, child) == YGAlignStretch &&
|
resolveChildAlignment(node, child) == Align::Stretch &&
|
||||||
childHeightMeasureMode != MeasureMode::Exactly;
|
childHeightMeasureMode != MeasureMode::Exactly;
|
||||||
if (isMainAxisRow && !isColumnStyleDimDefined && hasExactHeight &&
|
if (isMainAxisRow && !isColumnStyleDimDefined && hasExactHeight &&
|
||||||
childHeightStretch) {
|
childHeightStretch) {
|
||||||
@@ -511,7 +511,7 @@ static void layoutAbsoluteChild(
|
|||||||
|
|
||||||
} else if (
|
} else if (
|
||||||
!child->isLeadingPositionDefined(crossAxis) &&
|
!child->isLeadingPositionDefined(crossAxis) &&
|
||||||
resolveChildAlignment(node, child) == YGAlignCenter) {
|
resolveChildAlignment(node, child) == Align::Center) {
|
||||||
child->setLayoutPosition(
|
child->setLayoutPosition(
|
||||||
(node->getLayout().measuredDimensions[dimension(crossAxis)] -
|
(node->getLayout().measuredDimensions[dimension(crossAxis)] -
|
||||||
child->getLayout().measuredDimensions[dimension(crossAxis)]) /
|
child->getLayout().measuredDimensions[dimension(crossAxis)]) /
|
||||||
@@ -519,7 +519,7 @@ static void layoutAbsoluteChild(
|
|||||||
leadingEdge(crossAxis));
|
leadingEdge(crossAxis));
|
||||||
} else if (
|
} else if (
|
||||||
!child->isLeadingPositionDefined(crossAxis) &&
|
!child->isLeadingPositionDefined(crossAxis) &&
|
||||||
((resolveChildAlignment(node, child) == YGAlignFlexEnd) ^
|
((resolveChildAlignment(node, child) == Align::FlexEnd) ^
|
||||||
(node->getStyle().flexWrap() == YGWrapWrapReverse))) {
|
(node->getStyle().flexWrap() == YGWrapWrapReverse))) {
|
||||||
child->setLayoutPosition(
|
child->setLayoutPosition(
|
||||||
(node->getLayout().measuredDimensions[dimension(crossAxis)] -
|
(node->getLayout().measuredDimensions[dimension(crossAxis)] -
|
||||||
@@ -959,7 +959,7 @@ static float distributeFreeSpaceSecondPass(
|
|||||||
currentLineChild, crossAxis, availableInnerCrossDim) &&
|
currentLineChild, crossAxis, availableInnerCrossDim) &&
|
||||||
measureModeCrossDim == MeasureMode::Exactly &&
|
measureModeCrossDim == MeasureMode::Exactly &&
|
||||||
!(isNodeFlexWrap && mainAxisOverflows) &&
|
!(isNodeFlexWrap && mainAxisOverflows) &&
|
||||||
resolveChildAlignment(node, currentLineChild) == YGAlignStretch &&
|
resolveChildAlignment(node, currentLineChild) == Align::Stretch &&
|
||||||
currentLineChild->marginLeadingValue(crossAxis).unit != YGUnitAuto &&
|
currentLineChild->marginLeadingValue(crossAxis).unit != YGUnitAuto &&
|
||||||
currentLineChild->marginTrailingValue(crossAxis).unit != YGUnitAuto) {
|
currentLineChild->marginTrailingValue(crossAxis).unit != YGUnitAuto) {
|
||||||
childCrossSize = availableInnerCrossDim;
|
childCrossSize = availableInnerCrossDim;
|
||||||
@@ -1005,7 +1005,7 @@ static float distributeFreeSpaceSecondPass(
|
|||||||
const bool requiresStretchLayout =
|
const bool requiresStretchLayout =
|
||||||
!styleDefinesDimension(
|
!styleDefinesDimension(
|
||||||
currentLineChild, crossAxis, availableInnerCrossDim) &&
|
currentLineChild, crossAxis, availableInnerCrossDim) &&
|
||||||
resolveChildAlignment(node, currentLineChild) == YGAlignStretch &&
|
resolveChildAlignment(node, currentLineChild) == Align::Stretch &&
|
||||||
currentLineChild->marginLeadingValue(crossAxis).unit != YGUnitAuto &&
|
currentLineChild->marginLeadingValue(crossAxis).unit != YGUnitAuto &&
|
||||||
currentLineChild->marginTrailingValue(crossAxis).unit != YGUnitAuto;
|
currentLineChild->marginTrailingValue(crossAxis).unit != YGUnitAuto;
|
||||||
|
|
||||||
@@ -1898,12 +1898,12 @@ static void calculateLayoutImpl(
|
|||||||
// For a relative children, we're either using alignItems (owner) or
|
// For a relative children, we're either using alignItems (owner) or
|
||||||
// alignSelf (child) in order to determine the position in the cross
|
// alignSelf (child) in order to determine the position in the cross
|
||||||
// axis
|
// axis
|
||||||
const YGAlign alignItem = resolveChildAlignment(node, child);
|
const Align alignItem = resolveChildAlignment(node, child);
|
||||||
|
|
||||||
// If the child uses align stretch, we need to lay it out one more
|
// If the child uses align stretch, we need to lay it out one more
|
||||||
// time, this time forcing the cross-axis size to be the computed
|
// time, this time forcing the cross-axis size to be the computed
|
||||||
// cross size for the current line.
|
// cross size for the current line.
|
||||||
if (alignItem == YGAlignStretch &&
|
if (alignItem == Align::Stretch &&
|
||||||
child->marginLeadingValue(crossAxis).unit != YGUnitAuto &&
|
child->marginLeadingValue(crossAxis).unit != YGUnitAuto &&
|
||||||
child->marginTrailingValue(crossAxis).unit != YGUnitAuto) {
|
child->marginTrailingValue(crossAxis).unit != YGUnitAuto) {
|
||||||
// If the child defines a definite size for its cross axis, there's
|
// If the child defines a definite size for its cross axis, there's
|
||||||
@@ -1949,7 +1949,7 @@ static void calculateLayoutImpl(
|
|||||||
|
|
||||||
auto alignContent = node->getStyle().alignContent();
|
auto alignContent = node->getStyle().alignContent();
|
||||||
auto crossAxisDoesNotGrow =
|
auto crossAxisDoesNotGrow =
|
||||||
alignContent != YGAlignStretch && isNodeFlexWrap;
|
alignContent != Align::Stretch && isNodeFlexWrap;
|
||||||
const MeasureMode childWidthMeasureMode =
|
const MeasureMode childWidthMeasureMode =
|
||||||
yoga::isUndefined(childWidth) ||
|
yoga::isUndefined(childWidth) ||
|
||||||
(!isMainAxisRow && crossAxisDoesNotGrow)
|
(!isMainAxisRow && crossAxisDoesNotGrow)
|
||||||
@@ -1990,9 +1990,9 @@ static void calculateLayoutImpl(
|
|||||||
} else if (
|
} else if (
|
||||||
child->marginLeadingValue(crossAxis).unit == YGUnitAuto) {
|
child->marginLeadingValue(crossAxis).unit == YGUnitAuto) {
|
||||||
leadingCrossDim += yoga::maxOrDefined(0.0f, remainingCrossDim);
|
leadingCrossDim += yoga::maxOrDefined(0.0f, remainingCrossDim);
|
||||||
} else if (alignItem == YGAlignFlexStart) {
|
} else if (alignItem == Align::FlexStart) {
|
||||||
// No-Op
|
// No-Op
|
||||||
} else if (alignItem == YGAlignCenter) {
|
} else if (alignItem == Align::Center) {
|
||||||
leadingCrossDim += remainingCrossDim / 2;
|
leadingCrossDim += remainingCrossDim / 2;
|
||||||
} else {
|
} else {
|
||||||
leadingCrossDim += remainingCrossDim;
|
leadingCrossDim += remainingCrossDim;
|
||||||
@@ -2022,19 +2022,19 @@ static void calculateLayoutImpl(
|
|||||||
const float remainingAlignContentDim =
|
const float remainingAlignContentDim =
|
||||||
availableInnerCrossDim - totalLineCrossDim;
|
availableInnerCrossDim - totalLineCrossDim;
|
||||||
switch (node->getStyle().alignContent()) {
|
switch (node->getStyle().alignContent()) {
|
||||||
case YGAlignFlexEnd:
|
case Align::FlexEnd:
|
||||||
currentLead += remainingAlignContentDim;
|
currentLead += remainingAlignContentDim;
|
||||||
break;
|
break;
|
||||||
case YGAlignCenter:
|
case Align::Center:
|
||||||
currentLead += remainingAlignContentDim / 2;
|
currentLead += remainingAlignContentDim / 2;
|
||||||
break;
|
break;
|
||||||
case YGAlignStretch:
|
case Align::Stretch:
|
||||||
if (availableInnerCrossDim > totalLineCrossDim) {
|
if (availableInnerCrossDim > totalLineCrossDim) {
|
||||||
crossDimLead =
|
crossDimLead =
|
||||||
remainingAlignContentDim / static_cast<float>(lineCount);
|
remainingAlignContentDim / static_cast<float>(lineCount);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case YGAlignSpaceAround:
|
case Align::SpaceAround:
|
||||||
if (availableInnerCrossDim > totalLineCrossDim) {
|
if (availableInnerCrossDim > totalLineCrossDim) {
|
||||||
currentLead +=
|
currentLead +=
|
||||||
remainingAlignContentDim / (2 * static_cast<float>(lineCount));
|
remainingAlignContentDim / (2 * static_cast<float>(lineCount));
|
||||||
@@ -2046,15 +2046,15 @@ static void calculateLayoutImpl(
|
|||||||
currentLead += remainingAlignContentDim / 2;
|
currentLead += remainingAlignContentDim / 2;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case YGAlignSpaceBetween:
|
case Align::SpaceBetween:
|
||||||
if (availableInnerCrossDim > totalLineCrossDim && lineCount > 1) {
|
if (availableInnerCrossDim > totalLineCrossDim && lineCount > 1) {
|
||||||
crossDimLead =
|
crossDimLead =
|
||||||
remainingAlignContentDim / static_cast<float>(lineCount - 1);
|
remainingAlignContentDim / static_cast<float>(lineCount - 1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case YGAlignAuto:
|
case Align::Auto:
|
||||||
case YGAlignFlexStart:
|
case Align::FlexStart:
|
||||||
case YGAlignBaseline:
|
case Align::Baseline:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2083,7 +2083,7 @@ static void calculateLayoutImpl(
|
|||||||
child->getMarginForAxis(crossAxis, availableInnerWidth)
|
child->getMarginForAxis(crossAxis, availableInnerWidth)
|
||||||
.unwrap());
|
.unwrap());
|
||||||
}
|
}
|
||||||
if (resolveChildAlignment(node, child) == YGAlignBaseline) {
|
if (resolveChildAlignment(node, child) == Align::Baseline) {
|
||||||
const float ascent = calculateBaseline(child) +
|
const float ascent = calculateBaseline(child) +
|
||||||
child
|
child
|
||||||
->getLeadingMargin(
|
->getLeadingMargin(
|
||||||
@@ -2117,7 +2117,7 @@ static void calculateLayoutImpl(
|
|||||||
}
|
}
|
||||||
if (child->getStyle().positionType() != YGPositionTypeAbsolute) {
|
if (child->getStyle().positionType() != YGPositionTypeAbsolute) {
|
||||||
switch (resolveChildAlignment(node, child)) {
|
switch (resolveChildAlignment(node, child)) {
|
||||||
case YGAlignFlexStart: {
|
case Align::FlexStart: {
|
||||||
child->setLayoutPosition(
|
child->setLayoutPosition(
|
||||||
currentLead +
|
currentLead +
|
||||||
child->getLeadingMargin(crossAxis, availableInnerWidth)
|
child->getLeadingMargin(crossAxis, availableInnerWidth)
|
||||||
@@ -2125,7 +2125,7 @@ static void calculateLayoutImpl(
|
|||||||
leadingEdge(crossAxis));
|
leadingEdge(crossAxis));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case YGAlignFlexEnd: {
|
case Align::FlexEnd: {
|
||||||
child->setLayoutPosition(
|
child->setLayoutPosition(
|
||||||
currentLead + lineHeight -
|
currentLead + lineHeight -
|
||||||
child->getTrailingMargin(crossAxis, availableInnerWidth)
|
child->getTrailingMargin(crossAxis, availableInnerWidth)
|
||||||
@@ -2135,7 +2135,7 @@ static void calculateLayoutImpl(
|
|||||||
leadingEdge(crossAxis));
|
leadingEdge(crossAxis));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case YGAlignCenter: {
|
case Align::Center: {
|
||||||
float childHeight =
|
float childHeight =
|
||||||
child->getLayout().measuredDimensions[dimension(crossAxis)];
|
child->getLayout().measuredDimensions[dimension(crossAxis)];
|
||||||
|
|
||||||
@@ -2144,7 +2144,7 @@ static void calculateLayoutImpl(
|
|||||||
leadingEdge(crossAxis));
|
leadingEdge(crossAxis));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case YGAlignStretch: {
|
case Align::Stretch: {
|
||||||
child->setLayoutPosition(
|
child->setLayoutPosition(
|
||||||
currentLead +
|
currentLead +
|
||||||
child->getLeadingMargin(crossAxis, availableInnerWidth)
|
child->getLeadingMargin(crossAxis, availableInnerWidth)
|
||||||
@@ -2195,7 +2195,7 @@ static void calculateLayoutImpl(
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case YGAlignBaseline: {
|
case Align::Baseline: {
|
||||||
child->setLayoutPosition(
|
child->setLayoutPosition(
|
||||||
currentLead + maxAscentForCurrentLine -
|
currentLead + maxAscentForCurrentLine -
|
||||||
calculateBaseline(child) +
|
calculateBaseline(child) +
|
||||||
@@ -2207,9 +2207,9 @@ static void calculateLayoutImpl(
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case YGAlignAuto:
|
case Align::Auto:
|
||||||
case YGAlignSpaceBetween:
|
case Align::SpaceBetween:
|
||||||
case YGAlignSpaceAround:
|
case Align::SpaceAround:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -150,15 +150,15 @@ void nodeToString(
|
|||||||
}
|
}
|
||||||
if (style.alignItems() != yoga::Node{}.getStyle().alignItems()) {
|
if (style.alignItems() != yoga::Node{}.getStyle().alignItems()) {
|
||||||
appendFormattedString(
|
appendFormattedString(
|
||||||
str, "align-items: %s; ", YGAlignToString(style.alignItems()));
|
str, "align-items: %s; ", toString(style.alignItems()));
|
||||||
}
|
}
|
||||||
if (style.alignContent() != yoga::Node{}.getStyle().alignContent()) {
|
if (style.alignContent() != yoga::Node{}.getStyle().alignContent()) {
|
||||||
appendFormattedString(
|
appendFormattedString(
|
||||||
str, "align-content: %s; ", YGAlignToString(style.alignContent()));
|
str, "align-content: %s; ", toString(style.alignContent()));
|
||||||
}
|
}
|
||||||
if (style.alignSelf() != yoga::Node{}.getStyle().alignSelf()) {
|
if (style.alignSelf() != yoga::Node{}.getStyle().alignSelf()) {
|
||||||
appendFormattedString(
|
appendFormattedString(
|
||||||
str, "align-self: %s; ", YGAlignToString(style.alignSelf()));
|
str, "align-self: %s; ", toString(style.alignSelf()));
|
||||||
}
|
}
|
||||||
appendFloatOptionalIfDefined(str, "flex-grow", style.flexGrow());
|
appendFloatOptionalIfDefined(str, "flex-grow", style.flexGrow());
|
||||||
appendFloatOptionalIfDefined(str, "flex-shrink", style.flexShrink());
|
appendFloatOptionalIfDefined(str, "flex-shrink", style.flexShrink());
|
||||||
|
@@ -52,7 +52,7 @@ class YG_EXPORT Node : public ::YGNode {
|
|||||||
|
|
||||||
void useWebDefaults() {
|
void useWebDefaults() {
|
||||||
style_.flexDirection() = FlexDirection::Row;
|
style_.flexDirection() = FlexDirection::Row;
|
||||||
style_.alignContent() = YGAlignStretch;
|
style_.alignContent() = Align::Stretch;
|
||||||
}
|
}
|
||||||
|
|
||||||
// DANGER DANGER DANGER!
|
// DANGER DANGER DANGER!
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
#include <yoga/Yoga.h>
|
#include <yoga/Yoga.h>
|
||||||
|
|
||||||
#include <yoga/bits/NumericBitfield.h>
|
#include <yoga/bits/NumericBitfield.h>
|
||||||
|
#include <yoga/enums/Align.h>
|
||||||
#include <yoga/enums/Direction.h>
|
#include <yoga/enums/Direction.h>
|
||||||
#include <yoga/enums/FlexDirection.h>
|
#include <yoga/enums/FlexDirection.h>
|
||||||
#include <yoga/enums/Justify.h>
|
#include <yoga/enums/Justify.h>
|
||||||
@@ -95,8 +96,8 @@ class YG_EXPORT Style {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Style() {
|
Style() {
|
||||||
alignContent() = YGAlignFlexStart;
|
alignContent() = Align::FlexStart;
|
||||||
alignItems() = YGAlignStretch;
|
alignItems() = Align::Stretch;
|
||||||
}
|
}
|
||||||
~Style() = default;
|
~Style() = default;
|
||||||
|
|
||||||
@@ -109,11 +110,11 @@ class YG_EXPORT Style {
|
|||||||
static constexpr uint8_t alignContentOffset =
|
static constexpr uint8_t alignContentOffset =
|
||||||
justifyContentOffset + minimumBitCount<Justify>();
|
justifyContentOffset + minimumBitCount<Justify>();
|
||||||
static constexpr uint8_t alignItemsOffset =
|
static constexpr uint8_t alignItemsOffset =
|
||||||
alignContentOffset + minimumBitCount<YGAlign>();
|
alignContentOffset + minimumBitCount<Align>();
|
||||||
static constexpr uint8_t alignSelfOffset =
|
static constexpr uint8_t alignSelfOffset =
|
||||||
alignItemsOffset + minimumBitCount<YGAlign>();
|
alignItemsOffset + minimumBitCount<Align>();
|
||||||
static constexpr uint8_t positionTypeOffset =
|
static constexpr uint8_t positionTypeOffset =
|
||||||
alignSelfOffset + minimumBitCount<YGAlign>();
|
alignSelfOffset + minimumBitCount<Align>();
|
||||||
static constexpr uint8_t flexWrapOffset =
|
static constexpr uint8_t flexWrapOffset =
|
||||||
positionTypeOffset + minimumBitCount<YGPositionType>();
|
positionTypeOffset + minimumBitCount<YGPositionType>();
|
||||||
static constexpr uint8_t overflowOffset =
|
static constexpr uint8_t overflowOffset =
|
||||||
@@ -163,24 +164,24 @@ class YG_EXPORT Style {
|
|||||||
return {*this, justifyContentOffset};
|
return {*this, justifyContentOffset};
|
||||||
}
|
}
|
||||||
|
|
||||||
YGAlign alignContent() const {
|
Align alignContent() const {
|
||||||
return getEnumData<YGAlign>(flags, alignContentOffset);
|
return getEnumData<Align>(flags, alignContentOffset);
|
||||||
}
|
}
|
||||||
BitfieldRef<YGAlign> alignContent() {
|
BitfieldRef<Align> alignContent() {
|
||||||
return {*this, alignContentOffset};
|
return {*this, alignContentOffset};
|
||||||
}
|
}
|
||||||
|
|
||||||
YGAlign alignItems() const {
|
Align alignItems() const {
|
||||||
return getEnumData<YGAlign>(flags, alignItemsOffset);
|
return getEnumData<Align>(flags, alignItemsOffset);
|
||||||
}
|
}
|
||||||
BitfieldRef<YGAlign> alignItems() {
|
BitfieldRef<Align> alignItems() {
|
||||||
return {*this, alignItemsOffset};
|
return {*this, alignItemsOffset};
|
||||||
}
|
}
|
||||||
|
|
||||||
YGAlign alignSelf() const {
|
Align alignSelf() const {
|
||||||
return getEnumData<YGAlign>(flags, alignSelfOffset);
|
return getEnumData<Align>(flags, alignSelfOffset);
|
||||||
}
|
}
|
||||||
BitfieldRef<YGAlign> alignSelf() {
|
BitfieldRef<Align> alignSelf() {
|
||||||
return {*this, alignSelfOffset};
|
return {*this, alignSelfOffset};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user