C++ style enums 9/N: FlexDirection (#1394)
Summary: Pull Request resolved: https://github.com/facebook/yoga/pull/1394 X-link: https://github.com/facebook/react-native/pull/39484 Moves internal usages of YGDirection to Direction. bypass-github-export-checks Changelog: [Internal] Reviewed By: rshest Differential Revision: D49336066 fbshipit-source-id: b49e1ffcd79a427e36ea8d2c26debaa98ef3e4c9
This commit is contained in:
committed by
Facebook GitHub Bot
parent
9b99e4fc22
commit
6ec790dd1b
@@ -46,4 +46,5 @@ Pod::Spec.new do |spec|
|
|||||||
|
|
||||||
all_header_files = 'yoga/**/*.h'
|
all_header_files = 'yoga/**/*.h'
|
||||||
spec.private_header_files = Dir.glob(all_header_files) - Dir.glob(public_header_files)
|
spec.private_header_files = Dir.glob(all_header_files) - Dir.glob(public_header_files)
|
||||||
|
spec.preserve_paths = [all_header_files]
|
||||||
end
|
end
|
||||||
|
@@ -89,10 +89,10 @@ ACCESSOR_TEST(
|
|||||||
|
|
||||||
ACCESSOR_TEST(
|
ACCESSOR_TEST(
|
||||||
flexDirection,
|
flexDirection,
|
||||||
YGFlexDirectionColumn,
|
FlexDirection::Column,
|
||||||
YGFlexDirectionColumnReverse,
|
FlexDirection::ColumnReverse,
|
||||||
YGFlexDirectionRowReverse,
|
FlexDirection::RowReverse,
|
||||||
YGFlexDirectionRow)
|
FlexDirection::Row)
|
||||||
|
|
||||||
ACCESSOR_TEST(
|
ACCESSOR_TEST(
|
||||||
justifyContent,
|
justifyContent,
|
||||||
|
@@ -439,10 +439,10 @@ void YGNodeStyleSetFlexDirection(
|
|||||||
const YGNodeRef node,
|
const YGNodeRef node,
|
||||||
const YGFlexDirection flexDirection) {
|
const YGFlexDirection flexDirection) {
|
||||||
updateStyle<MSVC_HINT(flexDirection)>(
|
updateStyle<MSVC_HINT(flexDirection)>(
|
||||||
node, &Style::flexDirection, flexDirection);
|
node, &Style::flexDirection, scopedEnum(flexDirection));
|
||||||
}
|
}
|
||||||
YGFlexDirection YGNodeStyleGetFlexDirection(const YGNodeConstRef node) {
|
YGFlexDirection YGNodeStyleGetFlexDirection(const YGNodeConstRef node) {
|
||||||
return resolveRef(node)->getStyle().flexDirection();
|
return unscopedEnum(resolveRef(node)->getStyle().flexDirection());
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeStyleSetJustifyContent(
|
void YGNodeStyleSetJustifyContent(
|
||||||
|
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#include <yoga/algorithm/FlexDirection.h>
|
#include <yoga/algorithm/FlexDirection.h>
|
||||||
#include <yoga/algorithm/ResolveValue.h>
|
#include <yoga/algorithm/ResolveValue.h>
|
||||||
|
#include <yoga/enums/FlexDirection.h>
|
||||||
#include <yoga/node/Node.h>
|
#include <yoga/node/Node.h>
|
||||||
#include <yoga/numeric/Comparison.h>
|
#include <yoga/numeric/Comparison.h>
|
||||||
#include <yoga/numeric/FloatOptional.h>
|
#include <yoga/numeric/FloatOptional.h>
|
||||||
@@ -17,7 +18,7 @@ namespace facebook::yoga {
|
|||||||
|
|
||||||
inline float paddingAndBorderForAxis(
|
inline float paddingAndBorderForAxis(
|
||||||
const yoga::Node* const node,
|
const yoga::Node* const node,
|
||||||
const YGFlexDirection axis,
|
const FlexDirection axis,
|
||||||
const float widthSize) {
|
const float widthSize) {
|
||||||
return (node->getLeadingPaddingAndBorder(axis, widthSize) +
|
return (node->getLeadingPaddingAndBorder(axis, widthSize) +
|
||||||
node->getTrailingPaddingAndBorder(axis, widthSize))
|
node->getTrailingPaddingAndBorder(axis, widthSize))
|
||||||
@@ -26,7 +27,7 @@ inline float paddingAndBorderForAxis(
|
|||||||
|
|
||||||
inline FloatOptional boundAxisWithinMinAndMax(
|
inline FloatOptional boundAxisWithinMinAndMax(
|
||||||
const yoga::Node* const node,
|
const yoga::Node* const node,
|
||||||
const YGFlexDirection axis,
|
const FlexDirection axis,
|
||||||
const FloatOptional value,
|
const FloatOptional value,
|
||||||
const float axisSize) {
|
const float axisSize) {
|
||||||
FloatOptional min;
|
FloatOptional min;
|
||||||
@@ -59,7 +60,7 @@ inline FloatOptional boundAxisWithinMinAndMax(
|
|||||||
// go below the padding and border amount.
|
// go below the padding and border amount.
|
||||||
inline float boundAxis(
|
inline float boundAxis(
|
||||||
const yoga::Node* const node,
|
const yoga::Node* const node,
|
||||||
const YGFlexDirection axis,
|
const FlexDirection axis,
|
||||||
const float value,
|
const float value,
|
||||||
const float axisSize,
|
const float axisSize,
|
||||||
const float widthSize) {
|
const float widthSize) {
|
||||||
|
@@ -51,7 +51,7 @@ bool calculateLayoutInternal(
|
|||||||
|
|
||||||
static inline float dimensionWithMargin(
|
static inline float dimensionWithMargin(
|
||||||
const yoga::Node* const node,
|
const yoga::Node* const node,
|
||||||
const YGFlexDirection axis,
|
const FlexDirection axis,
|
||||||
const float widthSize) {
|
const float widthSize) {
|
||||||
return node->getLayout().measuredDimensions[dimension(axis)] +
|
return node->getLayout().measuredDimensions[dimension(axis)] +
|
||||||
(node->getLeadingMargin(axis, widthSize) +
|
(node->getLeadingMargin(axis, widthSize) +
|
||||||
@@ -61,7 +61,7 @@ static inline float dimensionWithMargin(
|
|||||||
|
|
||||||
static inline bool styleDefinesDimension(
|
static inline bool styleDefinesDimension(
|
||||||
const yoga::Node* const node,
|
const yoga::Node* const node,
|
||||||
const YGFlexDirection axis,
|
const FlexDirection axis,
|
||||||
const float ownerSize) {
|
const float ownerSize) {
|
||||||
bool isUndefined =
|
bool isUndefined =
|
||||||
yoga::isUndefined(node->getResolvedDimension(dimension(axis)).value);
|
yoga::isUndefined(node->getResolvedDimension(dimension(axis)).value);
|
||||||
@@ -78,7 +78,7 @@ static inline bool styleDefinesDimension(
|
|||||||
|
|
||||||
static inline bool isLayoutDimensionDefined(
|
static inline bool isLayoutDimensionDefined(
|
||||||
const yoga::Node* const node,
|
const yoga::Node* const node,
|
||||||
const YGFlexDirection axis) {
|
const FlexDirection axis) {
|
||||||
const float value = node->getLayout().measuredDimensions[dimension(axis)];
|
const float value = node->getLayout().measuredDimensions[dimension(axis)];
|
||||||
return !yoga::isUndefined(value) && value >= 0.0f;
|
return !yoga::isUndefined(value) && value >= 0.0f;
|
||||||
}
|
}
|
||||||
@@ -86,7 +86,7 @@ static inline bool isLayoutDimensionDefined(
|
|||||||
static void setChildTrailingPosition(
|
static void setChildTrailingPosition(
|
||||||
const yoga::Node* const node,
|
const yoga::Node* const node,
|
||||||
yoga::Node* const child,
|
yoga::Node* const child,
|
||||||
const YGFlexDirection axis) {
|
const FlexDirection axis) {
|
||||||
const float size = child->getLayout().measuredDimensions[dimension(axis)];
|
const float size = child->getLayout().measuredDimensions[dimension(axis)];
|
||||||
child->setLayoutPosition(
|
child->setLayoutPosition(
|
||||||
node->getLayout().measuredDimensions[dimension(axis)] - size -
|
node->getLayout().measuredDimensions[dimension(axis)] - size -
|
||||||
@@ -96,7 +96,7 @@ static void setChildTrailingPosition(
|
|||||||
|
|
||||||
static void constrainMaxSizeForMode(
|
static void constrainMaxSizeForMode(
|
||||||
const yoga::Node* const node,
|
const yoga::Node* const node,
|
||||||
const enum YGFlexDirection axis,
|
const enum FlexDirection axis,
|
||||||
const float ownerAxisSize,
|
const float ownerAxisSize,
|
||||||
const float ownerWidth,
|
const float ownerWidth,
|
||||||
MeasureMode* mode,
|
MeasureMode* mode,
|
||||||
@@ -134,7 +134,7 @@ static void computeFlexBasisForChild(
|
|||||||
LayoutData& layoutMarkerData,
|
LayoutData& layoutMarkerData,
|
||||||
const uint32_t depth,
|
const uint32_t depth,
|
||||||
const uint32_t generationCount) {
|
const uint32_t generationCount) {
|
||||||
const YGFlexDirection mainAxis =
|
const FlexDirection mainAxis =
|
||||||
resolveDirection(node->getStyle().flexDirection(), direction);
|
resolveDirection(node->getStyle().flexDirection(), direction);
|
||||||
const bool isMainAxisRow = isRow(mainAxis);
|
const bool isMainAxisRow = isRow(mainAxis);
|
||||||
const float mainAxisSize = isMainAxisRow ? width : height;
|
const float mainAxisSize = isMainAxisRow ? width : height;
|
||||||
@@ -148,9 +148,9 @@ static void computeFlexBasisForChild(
|
|||||||
const FloatOptional resolvedFlexBasis =
|
const FloatOptional resolvedFlexBasis =
|
||||||
yoga::resolveValue(child->resolveFlexBasisPtr(), mainAxisownerSize);
|
yoga::resolveValue(child->resolveFlexBasisPtr(), mainAxisownerSize);
|
||||||
const bool isRowStyleDimDefined =
|
const bool isRowStyleDimDefined =
|
||||||
styleDefinesDimension(child, YGFlexDirectionRow, ownerWidth);
|
styleDefinesDimension(child, FlexDirection::Row, ownerWidth);
|
||||||
const bool isColumnStyleDimDefined =
|
const bool isColumnStyleDimDefined =
|
||||||
styleDefinesDimension(child, YGFlexDirectionColumn, ownerHeight);
|
styleDefinesDimension(child, FlexDirection::Column, ownerHeight);
|
||||||
|
|
||||||
if (!resolvedFlexBasis.isUndefined() && !yoga::isUndefined(mainAxisSize)) {
|
if (!resolvedFlexBasis.isUndefined() && !yoga::isUndefined(mainAxisSize)) {
|
||||||
if (child->getLayout().computedFlexBasis.isUndefined() ||
|
if (child->getLayout().computedFlexBasis.isUndefined() ||
|
||||||
@@ -165,7 +165,7 @@ static void computeFlexBasisForChild(
|
|||||||
} else if (isMainAxisRow && isRowStyleDimDefined) {
|
} else if (isMainAxisRow && isRowStyleDimDefined) {
|
||||||
// The width is definite, so use that as the flex basis.
|
// The width is definite, so use that as the flex basis.
|
||||||
const FloatOptional paddingAndBorder = FloatOptional(
|
const FloatOptional paddingAndBorder = FloatOptional(
|
||||||
paddingAndBorderForAxis(child, YGFlexDirectionRow, ownerWidth));
|
paddingAndBorderForAxis(child, FlexDirection::Row, ownerWidth));
|
||||||
|
|
||||||
child->setLayoutComputedFlexBasis(yoga::maxOrDefined(
|
child->setLayoutComputedFlexBasis(yoga::maxOrDefined(
|
||||||
yoga::resolveValue(
|
yoga::resolveValue(
|
||||||
@@ -174,7 +174,7 @@ static void computeFlexBasisForChild(
|
|||||||
} else if (!isMainAxisRow && isColumnStyleDimDefined) {
|
} else if (!isMainAxisRow && isColumnStyleDimDefined) {
|
||||||
// The height is definite, so use that as the flex basis.
|
// The height is definite, so use that as the flex basis.
|
||||||
const FloatOptional paddingAndBorder = FloatOptional(
|
const FloatOptional paddingAndBorder = FloatOptional(
|
||||||
paddingAndBorderForAxis(child, YGFlexDirectionColumn, ownerWidth));
|
paddingAndBorderForAxis(child, FlexDirection::Column, ownerWidth));
|
||||||
child->setLayoutComputedFlexBasis(yoga::maxOrDefined(
|
child->setLayoutComputedFlexBasis(yoga::maxOrDefined(
|
||||||
yoga::resolveValue(
|
yoga::resolveValue(
|
||||||
child->getResolvedDimensions()[YGDimensionHeight], ownerHeight),
|
child->getResolvedDimensions()[YGDimensionHeight], ownerHeight),
|
||||||
@@ -188,9 +188,9 @@ static void computeFlexBasisForChild(
|
|||||||
childHeightMeasureMode = MeasureMode::Undefined;
|
childHeightMeasureMode = MeasureMode::Undefined;
|
||||||
|
|
||||||
auto marginRow =
|
auto marginRow =
|
||||||
child->getMarginForAxis(YGFlexDirectionRow, ownerWidth).unwrap();
|
child->getMarginForAxis(FlexDirection::Row, ownerWidth).unwrap();
|
||||||
auto marginColumn =
|
auto marginColumn =
|
||||||
child->getMarginForAxis(YGFlexDirectionColumn, ownerWidth).unwrap();
|
child->getMarginForAxis(FlexDirection::Column, ownerWidth).unwrap();
|
||||||
|
|
||||||
if (isRowStyleDimDefined) {
|
if (isRowStyleDimDefined) {
|
||||||
childWidth =
|
childWidth =
|
||||||
@@ -279,14 +279,14 @@ static void computeFlexBasisForChild(
|
|||||||
|
|
||||||
constrainMaxSizeForMode(
|
constrainMaxSizeForMode(
|
||||||
child,
|
child,
|
||||||
YGFlexDirectionRow,
|
FlexDirection::Row,
|
||||||
ownerWidth,
|
ownerWidth,
|
||||||
ownerWidth,
|
ownerWidth,
|
||||||
&childWidthMeasureMode,
|
&childWidthMeasureMode,
|
||||||
&childWidth);
|
&childWidth);
|
||||||
constrainMaxSizeForMode(
|
constrainMaxSizeForMode(
|
||||||
child,
|
child,
|
||||||
YGFlexDirectionColumn,
|
FlexDirection::Column,
|
||||||
ownerHeight,
|
ownerHeight,
|
||||||
ownerWidth,
|
ownerWidth,
|
||||||
&childHeightMeasureMode,
|
&childHeightMeasureMode,
|
||||||
@@ -325,9 +325,9 @@ static void layoutAbsoluteChild(
|
|||||||
LayoutData& layoutMarkerData,
|
LayoutData& layoutMarkerData,
|
||||||
const uint32_t depth,
|
const uint32_t depth,
|
||||||
const uint32_t generationCount) {
|
const uint32_t generationCount) {
|
||||||
const YGFlexDirection mainAxis =
|
const FlexDirection mainAxis =
|
||||||
resolveDirection(node->getStyle().flexDirection(), direction);
|
resolveDirection(node->getStyle().flexDirection(), direction);
|
||||||
const YGFlexDirection crossAxis = resolveCrossDirection(mainAxis, direction);
|
const FlexDirection crossAxis = resolveCrossDirection(mainAxis, direction);
|
||||||
const bool isMainAxisRow = isRow(mainAxis);
|
const bool isMainAxisRow = isRow(mainAxis);
|
||||||
|
|
||||||
float childWidth = YGUndefined;
|
float childWidth = YGUndefined;
|
||||||
@@ -335,11 +335,11 @@ static void layoutAbsoluteChild(
|
|||||||
MeasureMode childWidthMeasureMode = MeasureMode::Undefined;
|
MeasureMode childWidthMeasureMode = MeasureMode::Undefined;
|
||||||
MeasureMode childHeightMeasureMode = MeasureMode::Undefined;
|
MeasureMode childHeightMeasureMode = MeasureMode::Undefined;
|
||||||
|
|
||||||
auto marginRow = child->getMarginForAxis(YGFlexDirectionRow, width).unwrap();
|
auto marginRow = child->getMarginForAxis(FlexDirection::Row, width).unwrap();
|
||||||
auto marginColumn =
|
auto marginColumn =
|
||||||
child->getMarginForAxis(YGFlexDirectionColumn, width).unwrap();
|
child->getMarginForAxis(FlexDirection::Column, width).unwrap();
|
||||||
|
|
||||||
if (styleDefinesDimension(child, YGFlexDirectionRow, width)) {
|
if (styleDefinesDimension(child, FlexDirection::Row, width)) {
|
||||||
childWidth = yoga::resolveValue(
|
childWidth = yoga::resolveValue(
|
||||||
child->getResolvedDimensions()[YGDimensionWidth], width)
|
child->getResolvedDimensions()[YGDimensionWidth], width)
|
||||||
.unwrap() +
|
.unwrap() +
|
||||||
@@ -347,20 +347,20 @@ static void layoutAbsoluteChild(
|
|||||||
} else {
|
} else {
|
||||||
// If the child doesn't have a specified width, compute the width based on
|
// If the child doesn't have a specified width, compute the width based on
|
||||||
// the left/right offsets if they're defined.
|
// the left/right offsets if they're defined.
|
||||||
if (child->isLeadingPositionDefined(YGFlexDirectionRow) &&
|
if (child->isLeadingPositionDefined(FlexDirection::Row) &&
|
||||||
child->isTrailingPosDefined(YGFlexDirectionRow)) {
|
child->isTrailingPosDefined(FlexDirection::Row)) {
|
||||||
childWidth = node->getLayout().measuredDimensions[YGDimensionWidth] -
|
childWidth = node->getLayout().measuredDimensions[YGDimensionWidth] -
|
||||||
(node->getLeadingBorder(YGFlexDirectionRow) +
|
(node->getLeadingBorder(FlexDirection::Row) +
|
||||||
node->getTrailingBorder(YGFlexDirectionRow)) -
|
node->getTrailingBorder(FlexDirection::Row)) -
|
||||||
(child->getLeadingPosition(YGFlexDirectionRow, width) +
|
(child->getLeadingPosition(FlexDirection::Row, width) +
|
||||||
child->getTrailingPosition(YGFlexDirectionRow, width))
|
child->getTrailingPosition(FlexDirection::Row, width))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
childWidth =
|
childWidth =
|
||||||
boundAxis(child, YGFlexDirectionRow, childWidth, width, width);
|
boundAxis(child, FlexDirection::Row, childWidth, width, width);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (styleDefinesDimension(child, YGFlexDirectionColumn, height)) {
|
if (styleDefinesDimension(child, FlexDirection::Column, height)) {
|
||||||
childHeight = yoga::resolveValue(
|
childHeight = yoga::resolveValue(
|
||||||
child->getResolvedDimensions()[YGDimensionHeight], height)
|
child->getResolvedDimensions()[YGDimensionHeight], height)
|
||||||
.unwrap() +
|
.unwrap() +
|
||||||
@@ -368,16 +368,16 @@ static void layoutAbsoluteChild(
|
|||||||
} else {
|
} else {
|
||||||
// If the child doesn't have a specified height, compute the height based on
|
// If the child doesn't have a specified height, compute the height based on
|
||||||
// the top/bottom offsets if they're defined.
|
// the top/bottom offsets if they're defined.
|
||||||
if (child->isLeadingPositionDefined(YGFlexDirectionColumn) &&
|
if (child->isLeadingPositionDefined(FlexDirection::Column) &&
|
||||||
child->isTrailingPosDefined(YGFlexDirectionColumn)) {
|
child->isTrailingPosDefined(FlexDirection::Column)) {
|
||||||
childHeight = node->getLayout().measuredDimensions[YGDimensionHeight] -
|
childHeight = node->getLayout().measuredDimensions[YGDimensionHeight] -
|
||||||
(node->getLeadingBorder(YGFlexDirectionColumn) +
|
(node->getLeadingBorder(FlexDirection::Column) +
|
||||||
node->getTrailingBorder(YGFlexDirectionColumn)) -
|
node->getTrailingBorder(FlexDirection::Column)) -
|
||||||
(child->getLeadingPosition(YGFlexDirectionColumn, height) +
|
(child->getLeadingPosition(FlexDirection::Column, height) +
|
||||||
child->getTrailingPosition(YGFlexDirectionColumn, height))
|
child->getTrailingPosition(FlexDirection::Column, height))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
childHeight =
|
childHeight =
|
||||||
boundAxis(child, YGFlexDirectionColumn, childHeight, height, width);
|
boundAxis(child, FlexDirection::Column, childHeight, height, width);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -432,9 +432,9 @@ static void layoutAbsoluteChild(
|
|||||||
depth,
|
depth,
|
||||||
generationCount);
|
generationCount);
|
||||||
childWidth = child->getLayout().measuredDimensions[YGDimensionWidth] +
|
childWidth = child->getLayout().measuredDimensions[YGDimensionWidth] +
|
||||||
child->getMarginForAxis(YGFlexDirectionRow, width).unwrap();
|
child->getMarginForAxis(FlexDirection::Row, width).unwrap();
|
||||||
childHeight = child->getLayout().measuredDimensions[YGDimensionHeight] +
|
childHeight = child->getLayout().measuredDimensions[YGDimensionHeight] +
|
||||||
child->getMarginForAxis(YGFlexDirectionColumn, width).unwrap();
|
child->getMarginForAxis(FlexDirection::Column, width).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
calculateLayoutInternal(
|
calculateLayoutInternal(
|
||||||
@@ -586,12 +586,12 @@ static void measureNodeWithMeasureFunc(
|
|||||||
// Don't bother sizing the text if both dimensions are already defined.
|
// Don't bother sizing the text if both dimensions are already defined.
|
||||||
node->setLayoutMeasuredDimension(
|
node->setLayoutMeasuredDimension(
|
||||||
boundAxis(
|
boundAxis(
|
||||||
node, YGFlexDirectionRow, availableWidth, ownerWidth, ownerWidth),
|
node, FlexDirection::Row, availableWidth, ownerWidth, ownerWidth),
|
||||||
YGDimensionWidth);
|
YGDimensionWidth);
|
||||||
node->setLayoutMeasuredDimension(
|
node->setLayoutMeasuredDimension(
|
||||||
boundAxis(
|
boundAxis(
|
||||||
node,
|
node,
|
||||||
YGFlexDirectionColumn,
|
FlexDirection::Column,
|
||||||
availableHeight,
|
availableHeight,
|
||||||
ownerHeight,
|
ownerHeight,
|
||||||
ownerWidth),
|
ownerWidth),
|
||||||
@@ -620,7 +620,7 @@ static void measureNodeWithMeasureFunc(
|
|||||||
node->setLayoutMeasuredDimension(
|
node->setLayoutMeasuredDimension(
|
||||||
boundAxis(
|
boundAxis(
|
||||||
node,
|
node,
|
||||||
YGFlexDirectionRow,
|
FlexDirection::Row,
|
||||||
(widthMeasureMode == MeasureMode::Undefined ||
|
(widthMeasureMode == MeasureMode::Undefined ||
|
||||||
widthMeasureMode == MeasureMode::AtMost)
|
widthMeasureMode == MeasureMode::AtMost)
|
||||||
? measuredSize.width + paddingAndBorderAxisRow
|
? measuredSize.width + paddingAndBorderAxisRow
|
||||||
@@ -632,7 +632,7 @@ static void measureNodeWithMeasureFunc(
|
|||||||
node->setLayoutMeasuredDimension(
|
node->setLayoutMeasuredDimension(
|
||||||
boundAxis(
|
boundAxis(
|
||||||
node,
|
node,
|
||||||
YGFlexDirectionColumn,
|
FlexDirection::Column,
|
||||||
(heightMeasureMode == MeasureMode::Undefined ||
|
(heightMeasureMode == MeasureMode::Undefined ||
|
||||||
heightMeasureMode == MeasureMode::AtMost)
|
heightMeasureMode == MeasureMode::AtMost)
|
||||||
? measuredSize.height + paddingAndBorderAxisColumn
|
? measuredSize.height + paddingAndBorderAxisColumn
|
||||||
@@ -663,7 +663,7 @@ static void measureNodeWithoutChildren(
|
|||||||
border[YGEdgeRight];
|
border[YGEdgeRight];
|
||||||
}
|
}
|
||||||
node->setLayoutMeasuredDimension(
|
node->setLayoutMeasuredDimension(
|
||||||
boundAxis(node, YGFlexDirectionRow, width, ownerWidth, ownerWidth),
|
boundAxis(node, FlexDirection::Row, width, ownerWidth, ownerWidth),
|
||||||
YGDimensionWidth);
|
YGDimensionWidth);
|
||||||
|
|
||||||
float height = availableHeight;
|
float height = availableHeight;
|
||||||
@@ -673,7 +673,7 @@ static void measureNodeWithoutChildren(
|
|||||||
border[YGEdgeBottom];
|
border[YGEdgeBottom];
|
||||||
}
|
}
|
||||||
node->setLayoutMeasuredDimension(
|
node->setLayoutMeasuredDimension(
|
||||||
boundAxis(node, YGFlexDirectionColumn, height, ownerHeight, ownerWidth),
|
boundAxis(node, FlexDirection::Column, height, ownerHeight, ownerWidth),
|
||||||
YGDimensionHeight);
|
YGDimensionHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -694,7 +694,7 @@ static bool measureNodeWithFixedSize(
|
|||||||
node->setLayoutMeasuredDimension(
|
node->setLayoutMeasuredDimension(
|
||||||
boundAxis(
|
boundAxis(
|
||||||
node,
|
node,
|
||||||
YGFlexDirectionRow,
|
FlexDirection::Row,
|
||||||
yoga::isUndefined(availableWidth) ||
|
yoga::isUndefined(availableWidth) ||
|
||||||
(widthMeasureMode == MeasureMode::AtMost &&
|
(widthMeasureMode == MeasureMode::AtMost &&
|
||||||
availableWidth < 0.0f)
|
availableWidth < 0.0f)
|
||||||
@@ -707,7 +707,7 @@ static bool measureNodeWithFixedSize(
|
|||||||
node->setLayoutMeasuredDimension(
|
node->setLayoutMeasuredDimension(
|
||||||
boundAxis(
|
boundAxis(
|
||||||
node,
|
node,
|
||||||
YGFlexDirectionColumn,
|
FlexDirection::Column,
|
||||||
yoga::isUndefined(availableHeight) ||
|
yoga::isUndefined(availableHeight) ||
|
||||||
(heightMeasureMode == MeasureMode::AtMost &&
|
(heightMeasureMode == MeasureMode::AtMost &&
|
||||||
availableHeight < 0.0f)
|
availableHeight < 0.0f)
|
||||||
@@ -772,7 +772,7 @@ static float computeFlexBasisForChildren(
|
|||||||
MeasureMode widthMeasureMode,
|
MeasureMode widthMeasureMode,
|
||||||
MeasureMode heightMeasureMode,
|
MeasureMode heightMeasureMode,
|
||||||
Direction direction,
|
Direction direction,
|
||||||
YGFlexDirection mainAxis,
|
FlexDirection mainAxis,
|
||||||
bool performLayout,
|
bool performLayout,
|
||||||
LayoutData& layoutMarkerData,
|
LayoutData& layoutMarkerData,
|
||||||
const uint32_t depth,
|
const uint32_t depth,
|
||||||
@@ -859,8 +859,8 @@ static float computeFlexBasisForChildren(
|
|||||||
static float distributeFreeSpaceSecondPass(
|
static float distributeFreeSpaceSecondPass(
|
||||||
FlexLine& flexLine,
|
FlexLine& flexLine,
|
||||||
yoga::Node* const node,
|
yoga::Node* const node,
|
||||||
const YGFlexDirection mainAxis,
|
const FlexDirection mainAxis,
|
||||||
const YGFlexDirection crossAxis,
|
const FlexDirection crossAxis,
|
||||||
const float mainAxisownerSize,
|
const float mainAxisownerSize,
|
||||||
const float availableInnerMainDim,
|
const float availableInnerMainDim,
|
||||||
const float availableInnerCrossDim,
|
const float availableInnerCrossDim,
|
||||||
@@ -1047,7 +1047,7 @@ static float distributeFreeSpaceSecondPass(
|
|||||||
// is removed from the remaingfreespace.
|
// is removed from the remaingfreespace.
|
||||||
static void distributeFreeSpaceFirstPass(
|
static void distributeFreeSpaceFirstPass(
|
||||||
FlexLine& flexLine,
|
FlexLine& flexLine,
|
||||||
const YGFlexDirection mainAxis,
|
const FlexDirection mainAxis,
|
||||||
const float mainAxisownerSize,
|
const float mainAxisownerSize,
|
||||||
const float availableInnerMainDim,
|
const float availableInnerMainDim,
|
||||||
const float availableInnerWidth) {
|
const float availableInnerWidth) {
|
||||||
@@ -1153,8 +1153,8 @@ static void distributeFreeSpaceFirstPass(
|
|||||||
static void resolveFlexibleLength(
|
static void resolveFlexibleLength(
|
||||||
yoga::Node* const node,
|
yoga::Node* const node,
|
||||||
FlexLine& flexLine,
|
FlexLine& flexLine,
|
||||||
const YGFlexDirection mainAxis,
|
const FlexDirection mainAxis,
|
||||||
const YGFlexDirection crossAxis,
|
const FlexDirection crossAxis,
|
||||||
const float mainAxisownerSize,
|
const float mainAxisownerSize,
|
||||||
const float availableInnerMainDim,
|
const float availableInnerMainDim,
|
||||||
const float availableInnerCrossDim,
|
const float availableInnerCrossDim,
|
||||||
@@ -1200,8 +1200,8 @@ static void YGJustifyMainAxis(
|
|||||||
yoga::Node* const node,
|
yoga::Node* const node,
|
||||||
FlexLine& flexLine,
|
FlexLine& flexLine,
|
||||||
const size_t startOfLineIndex,
|
const size_t startOfLineIndex,
|
||||||
const YGFlexDirection mainAxis,
|
const FlexDirection mainAxis,
|
||||||
const YGFlexDirection crossAxis,
|
const FlexDirection crossAxis,
|
||||||
const MeasureMode measureModeMainDim,
|
const MeasureMode measureModeMainDim,
|
||||||
const MeasureMode measureModeCrossDim,
|
const MeasureMode measureModeCrossDim,
|
||||||
const float mainAxisownerSize,
|
const float mainAxisownerSize,
|
||||||
@@ -1370,13 +1370,13 @@ static void YGJustifyMainAxis(
|
|||||||
const float ascent = calculateBaseline(child) +
|
const float ascent = calculateBaseline(child) +
|
||||||
child
|
child
|
||||||
->getLeadingMargin(
|
->getLeadingMargin(
|
||||||
YGFlexDirectionColumn, availableInnerWidth)
|
FlexDirection::Column, availableInnerWidth)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
const float descent =
|
const float descent =
|
||||||
child->getLayout().measuredDimensions[YGDimensionHeight] +
|
child->getLayout().measuredDimensions[YGDimensionHeight] +
|
||||||
child
|
child
|
||||||
->getMarginForAxis(
|
->getMarginForAxis(
|
||||||
YGFlexDirectionColumn, availableInnerWidth)
|
FlexDirection::Column, availableInnerWidth)
|
||||||
.unwrap() -
|
.unwrap() -
|
||||||
ascent;
|
ascent;
|
||||||
|
|
||||||
@@ -1509,10 +1509,10 @@ static void calculateLayoutImpl(
|
|||||||
const Direction direction = node->resolveDirection(ownerDirection);
|
const Direction direction = node->resolveDirection(ownerDirection);
|
||||||
node->setLayoutDirection(direction);
|
node->setLayoutDirection(direction);
|
||||||
|
|
||||||
const YGFlexDirection flexRowDirection =
|
const FlexDirection flexRowDirection =
|
||||||
resolveDirection(YGFlexDirectionRow, direction);
|
resolveDirection(FlexDirection::Row, direction);
|
||||||
const YGFlexDirection flexColumnDirection =
|
const FlexDirection flexColumnDirection =
|
||||||
resolveDirection(YGFlexDirectionColumn, direction);
|
resolveDirection(FlexDirection::Column, direction);
|
||||||
|
|
||||||
const YGEdge startEdge =
|
const YGEdge startEdge =
|
||||||
direction == Direction::LTR ? YGEdgeLeft : YGEdgeRight;
|
direction == Direction::LTR ? YGEdgeLeft : YGEdgeRight;
|
||||||
@@ -1600,9 +1600,9 @@ static void calculateLayoutImpl(
|
|||||||
node->setLayoutHadOverflow(false);
|
node->setLayoutHadOverflow(false);
|
||||||
|
|
||||||
// STEP 1: CALCULATE VALUES FOR REMAINDER OF ALGORITHM
|
// STEP 1: CALCULATE VALUES FOR REMAINDER OF ALGORITHM
|
||||||
const YGFlexDirection mainAxis =
|
const FlexDirection mainAxis =
|
||||||
resolveDirection(node->getStyle().flexDirection(), direction);
|
resolveDirection(node->getStyle().flexDirection(), direction);
|
||||||
const YGFlexDirection crossAxis = resolveCrossDirection(mainAxis, direction);
|
const FlexDirection crossAxis = resolveCrossDirection(mainAxis, direction);
|
||||||
const bool isMainAxisRow = isRow(mainAxis);
|
const bool isMainAxisRow = isRow(mainAxis);
|
||||||
const bool isNodeFlexWrap = node->getStyle().flexWrap() != YGWrapNoWrap;
|
const bool isNodeFlexWrap = node->getStyle().flexWrap() != YGWrapNoWrap;
|
||||||
|
|
||||||
@@ -2087,13 +2087,13 @@ static void calculateLayoutImpl(
|
|||||||
const float ascent = calculateBaseline(child) +
|
const float ascent = calculateBaseline(child) +
|
||||||
child
|
child
|
||||||
->getLeadingMargin(
|
->getLeadingMargin(
|
||||||
YGFlexDirectionColumn, availableInnerWidth)
|
FlexDirection::Column, availableInnerWidth)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
const float descent =
|
const float descent =
|
||||||
child->getLayout().measuredDimensions[YGDimensionHeight] +
|
child->getLayout().measuredDimensions[YGDimensionHeight] +
|
||||||
child
|
child
|
||||||
->getMarginForAxis(
|
->getMarginForAxis(
|
||||||
YGFlexDirectionColumn, availableInnerWidth)
|
FlexDirection::Column, availableInnerWidth)
|
||||||
.unwrap() -
|
.unwrap() -
|
||||||
ascent;
|
ascent;
|
||||||
maxAscentForCurrentLine =
|
maxAscentForCurrentLine =
|
||||||
@@ -2201,7 +2201,7 @@ static void calculateLayoutImpl(
|
|||||||
calculateBaseline(child) +
|
calculateBaseline(child) +
|
||||||
child
|
child
|
||||||
->getLeadingPosition(
|
->getLeadingPosition(
|
||||||
YGFlexDirectionColumn, availableInnerCrossDim)
|
FlexDirection::Column, availableInnerCrossDim)
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
YGEdgeTop);
|
YGEdgeTop);
|
||||||
|
|
||||||
@@ -2224,7 +2224,7 @@ static void calculateLayoutImpl(
|
|||||||
node->setLayoutMeasuredDimension(
|
node->setLayoutMeasuredDimension(
|
||||||
boundAxis(
|
boundAxis(
|
||||||
node,
|
node,
|
||||||
YGFlexDirectionRow,
|
FlexDirection::Row,
|
||||||
availableWidth - marginAxisRow,
|
availableWidth - marginAxisRow,
|
||||||
ownerWidth,
|
ownerWidth,
|
||||||
ownerWidth),
|
ownerWidth),
|
||||||
@@ -2233,7 +2233,7 @@ static void calculateLayoutImpl(
|
|||||||
node->setLayoutMeasuredDimension(
|
node->setLayoutMeasuredDimension(
|
||||||
boundAxis(
|
boundAxis(
|
||||||
node,
|
node,
|
||||||
YGFlexDirectionColumn,
|
FlexDirection::Column,
|
||||||
availableHeight - marginAxisColumn,
|
availableHeight - marginAxisColumn,
|
||||||
ownerHeight,
|
ownerHeight,
|
||||||
ownerWidth),
|
ownerWidth),
|
||||||
@@ -2343,10 +2343,10 @@ static void calculateLayoutImpl(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// STEP 11: SETTING TRAILING POSITIONS FOR CHILDREN
|
// STEP 11: SETTING TRAILING POSITIONS FOR CHILDREN
|
||||||
const bool needsMainTrailingPos = mainAxis == YGFlexDirectionRowReverse ||
|
const bool needsMainTrailingPos = mainAxis == FlexDirection::RowReverse ||
|
||||||
mainAxis == YGFlexDirectionColumnReverse;
|
mainAxis == FlexDirection::ColumnReverse;
|
||||||
const bool needsCrossTrailingPos = crossAxis == YGFlexDirectionRowReverse ||
|
const bool needsCrossTrailingPos = crossAxis == FlexDirection::RowReverse ||
|
||||||
crossAxis == YGFlexDirectionColumnReverse;
|
crossAxis == FlexDirection::ColumnReverse;
|
||||||
|
|
||||||
// Set trailing position if necessary.
|
// Set trailing position if necessary.
|
||||||
if (needsMainTrailingPos || needsCrossTrailingPos) {
|
if (needsMainTrailingPos || needsCrossTrailingPos) {
|
||||||
@@ -2449,9 +2449,9 @@ bool calculateLayoutInternal(
|
|||||||
// measurements if at all possible.
|
// measurements if at all possible.
|
||||||
if (node->hasMeasureFunc()) {
|
if (node->hasMeasureFunc()) {
|
||||||
const float marginAxisRow =
|
const float marginAxisRow =
|
||||||
node->getMarginForAxis(YGFlexDirectionRow, ownerWidth).unwrap();
|
node->getMarginForAxis(FlexDirection::Row, ownerWidth).unwrap();
|
||||||
const float marginAxisColumn =
|
const float marginAxisColumn =
|
||||||
node->getMarginForAxis(YGFlexDirectionColumn, ownerWidth).unwrap();
|
node->getMarginForAxis(FlexDirection::Column, ownerWidth).unwrap();
|
||||||
|
|
||||||
// First, try to use the layout cache.
|
// First, try to use the layout cache.
|
||||||
if (canUseCachedMeasurement(
|
if (canUseCachedMeasurement(
|
||||||
@@ -2680,11 +2680,11 @@ void calculateLayout(
|
|||||||
float width = YGUndefined;
|
float width = YGUndefined;
|
||||||
MeasureMode widthMeasureMode = MeasureMode::Undefined;
|
MeasureMode widthMeasureMode = MeasureMode::Undefined;
|
||||||
const auto& maxDimensions = node->getStyle().maxDimensions();
|
const auto& maxDimensions = node->getStyle().maxDimensions();
|
||||||
if (styleDefinesDimension(node, YGFlexDirectionRow, ownerWidth)) {
|
if (styleDefinesDimension(node, FlexDirection::Row, ownerWidth)) {
|
||||||
width = (yoga::resolveValue(
|
width = (yoga::resolveValue(
|
||||||
node->getResolvedDimension(dimension(YGFlexDirectionRow)),
|
node->getResolvedDimension(dimension(FlexDirection::Row)),
|
||||||
ownerWidth) +
|
ownerWidth) +
|
||||||
node->getMarginForAxis(YGFlexDirectionRow, ownerWidth))
|
node->getMarginForAxis(FlexDirection::Row, ownerWidth))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
widthMeasureMode = MeasureMode::Exactly;
|
widthMeasureMode = MeasureMode::Exactly;
|
||||||
} else if (!yoga::resolveValue(maxDimensions[YGDimensionWidth], ownerWidth)
|
} else if (!yoga::resolveValue(maxDimensions[YGDimensionWidth], ownerWidth)
|
||||||
@@ -2700,11 +2700,11 @@ void calculateLayout(
|
|||||||
|
|
||||||
float height = YGUndefined;
|
float height = YGUndefined;
|
||||||
MeasureMode heightMeasureMode = MeasureMode::Undefined;
|
MeasureMode heightMeasureMode = MeasureMode::Undefined;
|
||||||
if (styleDefinesDimension(node, YGFlexDirectionColumn, ownerHeight)) {
|
if (styleDefinesDimension(node, FlexDirection::Column, ownerHeight)) {
|
||||||
height = (yoga::resolveValue(
|
height = (yoga::resolveValue(
|
||||||
node->getResolvedDimension(dimension(YGFlexDirectionColumn)),
|
node->getResolvedDimension(dimension(FlexDirection::Column)),
|
||||||
ownerHeight) +
|
ownerHeight) +
|
||||||
node->getMarginForAxis(YGFlexDirectionColumn, ownerWidth))
|
node->getMarginForAxis(FlexDirection::Column, ownerWidth))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
heightMeasureMode = MeasureMode::Exactly;
|
heightMeasureMode = MeasureMode::Exactly;
|
||||||
} else if (!yoga::resolveValue(maxDimensions[YGDimensionHeight], ownerHeight)
|
} else if (!yoga::resolveValue(maxDimensions[YGDimensionHeight], ownerHeight)
|
||||||
|
@@ -10,84 +10,85 @@
|
|||||||
#include <yoga/Yoga.h>
|
#include <yoga/Yoga.h>
|
||||||
|
|
||||||
#include <yoga/debug/AssertFatal.h>
|
#include <yoga/debug/AssertFatal.h>
|
||||||
|
#include <yoga/enums/FlexDirection.h>
|
||||||
|
|
||||||
namespace facebook::yoga {
|
namespace facebook::yoga {
|
||||||
|
|
||||||
inline bool isRow(const YGFlexDirection flexDirection) {
|
inline bool isRow(const FlexDirection flexDirection) {
|
||||||
return flexDirection == YGFlexDirectionRow ||
|
return flexDirection == FlexDirection::Row ||
|
||||||
flexDirection == YGFlexDirectionRowReverse;
|
flexDirection == FlexDirection::RowReverse;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool isColumn(const YGFlexDirection flexDirection) {
|
inline bool isColumn(const FlexDirection flexDirection) {
|
||||||
return flexDirection == YGFlexDirectionColumn ||
|
return flexDirection == FlexDirection::Column ||
|
||||||
flexDirection == YGFlexDirectionColumnReverse;
|
flexDirection == FlexDirection::ColumnReverse;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline YGFlexDirection resolveDirection(
|
inline FlexDirection resolveDirection(
|
||||||
const YGFlexDirection flexDirection,
|
const FlexDirection flexDirection,
|
||||||
const Direction direction) {
|
const Direction direction) {
|
||||||
if (direction == Direction::RTL) {
|
if (direction == Direction::RTL) {
|
||||||
if (flexDirection == YGFlexDirectionRow) {
|
if (flexDirection == FlexDirection::Row) {
|
||||||
return YGFlexDirectionRowReverse;
|
return FlexDirection::RowReverse;
|
||||||
} else if (flexDirection == YGFlexDirectionRowReverse) {
|
} else if (flexDirection == FlexDirection::RowReverse) {
|
||||||
return YGFlexDirectionRow;
|
return FlexDirection::Row;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return flexDirection;
|
return flexDirection;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline YGFlexDirection resolveCrossDirection(
|
inline FlexDirection resolveCrossDirection(
|
||||||
const YGFlexDirection flexDirection,
|
const FlexDirection flexDirection,
|
||||||
const Direction direction) {
|
const Direction direction) {
|
||||||
return isColumn(flexDirection)
|
return isColumn(flexDirection)
|
||||||
? resolveDirection(YGFlexDirectionRow, direction)
|
? resolveDirection(FlexDirection::Row, direction)
|
||||||
: YGFlexDirectionColumn;
|
: FlexDirection::Column;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline YGEdge leadingEdge(const YGFlexDirection flexDirection) {
|
inline YGEdge leadingEdge(const FlexDirection flexDirection) {
|
||||||
switch (flexDirection) {
|
switch (flexDirection) {
|
||||||
case YGFlexDirectionColumn:
|
case FlexDirection::Column:
|
||||||
return YGEdgeTop;
|
return YGEdgeTop;
|
||||||
case YGFlexDirectionColumnReverse:
|
case FlexDirection::ColumnReverse:
|
||||||
return YGEdgeBottom;
|
return YGEdgeBottom;
|
||||||
case YGFlexDirectionRow:
|
case FlexDirection::Row:
|
||||||
return YGEdgeLeft;
|
return YGEdgeLeft;
|
||||||
case YGFlexDirectionRowReverse:
|
case FlexDirection::RowReverse:
|
||||||
return YGEdgeRight;
|
return YGEdgeRight;
|
||||||
}
|
}
|
||||||
|
|
||||||
fatalWithMessage("Invalid YGFlexDirection");
|
fatalWithMessage("Invalid FlexDirection");
|
||||||
}
|
}
|
||||||
|
|
||||||
inline YGEdge trailingEdge(const YGFlexDirection flexDirection) {
|
inline YGEdge trailingEdge(const FlexDirection flexDirection) {
|
||||||
switch (flexDirection) {
|
switch (flexDirection) {
|
||||||
case YGFlexDirectionColumn:
|
case FlexDirection::Column:
|
||||||
return YGEdgeBottom;
|
return YGEdgeBottom;
|
||||||
case YGFlexDirectionColumnReverse:
|
case FlexDirection::ColumnReverse:
|
||||||
return YGEdgeTop;
|
return YGEdgeTop;
|
||||||
case YGFlexDirectionRow:
|
case FlexDirection::Row:
|
||||||
return YGEdgeRight;
|
return YGEdgeRight;
|
||||||
case YGFlexDirectionRowReverse:
|
case FlexDirection::RowReverse:
|
||||||
return YGEdgeLeft;
|
return YGEdgeLeft;
|
||||||
}
|
}
|
||||||
|
|
||||||
fatalWithMessage("Invalid YGFlexDirection");
|
fatalWithMessage("Invalid FlexDirection");
|
||||||
}
|
}
|
||||||
|
|
||||||
inline YGDimension dimension(const YGFlexDirection flexDirection) {
|
inline YGDimension dimension(const FlexDirection flexDirection) {
|
||||||
switch (flexDirection) {
|
switch (flexDirection) {
|
||||||
case YGFlexDirectionColumn:
|
case FlexDirection::Column:
|
||||||
return YGDimensionHeight;
|
return YGDimensionHeight;
|
||||||
case YGFlexDirectionColumnReverse:
|
case FlexDirection::ColumnReverse:
|
||||||
return YGDimensionHeight;
|
return YGDimensionHeight;
|
||||||
case YGFlexDirectionRow:
|
case FlexDirection::Row:
|
||||||
return YGDimensionWidth;
|
return YGDimensionWidth;
|
||||||
case YGFlexDirectionRowReverse:
|
case FlexDirection::RowReverse:
|
||||||
return YGDimensionWidth;
|
return YGDimensionWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
fatalWithMessage("Invalid YGFlexDirection");
|
fatalWithMessage("Invalid FlexDirection");
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace facebook::yoga
|
} // namespace facebook::yoga
|
||||||
|
@@ -30,7 +30,7 @@ FlexLine calculateFlexLine(
|
|||||||
size_t endOfLineIndex = startOfLineIndex;
|
size_t endOfLineIndex = startOfLineIndex;
|
||||||
|
|
||||||
float sizeConsumedIncludingMinConstraint = 0;
|
float sizeConsumedIncludingMinConstraint = 0;
|
||||||
const YGFlexDirection mainAxis = resolveDirection(
|
const FlexDirection mainAxis = resolveDirection(
|
||||||
node->getStyle().flexDirection(), node->resolveDirection(ownerDirection));
|
node->getStyle().flexDirection(), node->resolveDirection(ownerDirection));
|
||||||
const bool isNodeFlexWrap = node->getStyle().flexWrap() != YGWrapNoWrap;
|
const bool isNodeFlexWrap = node->getStyle().flexWrap() != YGWrapNoWrap;
|
||||||
const float gap = node->getGapForAxis(mainAxis, availableInnerWidth).unwrap();
|
const float gap = node->getGapForAxis(mainAxis, availableInnerWidth).unwrap();
|
||||||
|
@@ -142,9 +142,7 @@ void nodeToString(
|
|||||||
const auto& style = node->getStyle();
|
const auto& style = node->getStyle();
|
||||||
if (style.flexDirection() != yoga::Node{}.getStyle().flexDirection()) {
|
if (style.flexDirection() != yoga::Node{}.getStyle().flexDirection()) {
|
||||||
appendFormattedString(
|
appendFormattedString(
|
||||||
str,
|
str, "flex-direction: %s; ", toString(style.flexDirection()));
|
||||||
"flex-direction: %s; ",
|
|
||||||
YGFlexDirectionToString(style.flexDirection()));
|
|
||||||
}
|
}
|
||||||
if (style.justifyContent() != yoga::Node{}.getStyle().justifyContent()) {
|
if (style.justifyContent() != yoga::Node{}.getStyle().justifyContent()) {
|
||||||
appendFormattedString(
|
appendFormattedString(
|
||||||
|
@@ -114,7 +114,7 @@ CompactValue Node::computeColumnGap(
|
|||||||
}
|
}
|
||||||
|
|
||||||
FloatOptional Node::getLeadingPosition(
|
FloatOptional Node::getLeadingPosition(
|
||||||
const YGFlexDirection axis,
|
const FlexDirection axis,
|
||||||
const float axisSize) const {
|
const float axisSize) const {
|
||||||
auto leadingPosition = isRow(axis)
|
auto leadingPosition = isRow(axis)
|
||||||
? computeEdgeValueForRow(
|
? computeEdgeValueForRow(
|
||||||
@@ -128,7 +128,7 @@ FloatOptional Node::getLeadingPosition(
|
|||||||
}
|
}
|
||||||
|
|
||||||
FloatOptional Node::getTrailingPosition(
|
FloatOptional Node::getTrailingPosition(
|
||||||
const YGFlexDirection axis,
|
const FlexDirection axis,
|
||||||
const float axisSize) const {
|
const float axisSize) const {
|
||||||
auto trailingPosition = isRow(axis)
|
auto trailingPosition = isRow(axis)
|
||||||
? computeEdgeValueForRow(
|
? computeEdgeValueForRow(
|
||||||
@@ -141,7 +141,7 @@ FloatOptional Node::getTrailingPosition(
|
|||||||
return yoga::resolveValue(trailingPosition, axisSize);
|
return yoga::resolveValue(trailingPosition, axisSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Node::isLeadingPositionDefined(const YGFlexDirection axis) const {
|
bool Node::isLeadingPositionDefined(const FlexDirection axis) const {
|
||||||
auto leadingPosition = isRow(axis)
|
auto leadingPosition = isRow(axis)
|
||||||
? computeEdgeValueForRow(
|
? computeEdgeValueForRow(
|
||||||
style_.position(),
|
style_.position(),
|
||||||
@@ -153,7 +153,7 @@ bool Node::isLeadingPositionDefined(const YGFlexDirection axis) const {
|
|||||||
return !leadingPosition.isUndefined();
|
return !leadingPosition.isUndefined();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Node::isTrailingPosDefined(const YGFlexDirection axis) const {
|
bool Node::isTrailingPosDefined(const FlexDirection axis) const {
|
||||||
auto trailingPosition = isRow(axis)
|
auto trailingPosition = isRow(axis)
|
||||||
? computeEdgeValueForRow(
|
? computeEdgeValueForRow(
|
||||||
style_.position(),
|
style_.position(),
|
||||||
@@ -166,7 +166,7 @@ bool Node::isTrailingPosDefined(const YGFlexDirection axis) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
FloatOptional Node::getLeadingMargin(
|
FloatOptional Node::getLeadingMargin(
|
||||||
const YGFlexDirection axis,
|
const FlexDirection axis,
|
||||||
const float widthSize) const {
|
const float widthSize) const {
|
||||||
auto leadingMargin = isRow(axis)
|
auto leadingMargin = isRow(axis)
|
||||||
? computeEdgeValueForRow(
|
? computeEdgeValueForRow(
|
||||||
@@ -181,7 +181,7 @@ FloatOptional Node::getLeadingMargin(
|
|||||||
}
|
}
|
||||||
|
|
||||||
FloatOptional Node::getTrailingMargin(
|
FloatOptional Node::getTrailingMargin(
|
||||||
const YGFlexDirection axis,
|
const FlexDirection axis,
|
||||||
const float widthSize) const {
|
const float widthSize) const {
|
||||||
auto trailingMargin = isRow(axis)
|
auto trailingMargin = isRow(axis)
|
||||||
? computeEdgeValueForRow(
|
? computeEdgeValueForRow(
|
||||||
@@ -197,13 +197,13 @@ FloatOptional Node::getTrailingMargin(
|
|||||||
}
|
}
|
||||||
|
|
||||||
FloatOptional Node::getMarginForAxis(
|
FloatOptional Node::getMarginForAxis(
|
||||||
const YGFlexDirection axis,
|
const FlexDirection axis,
|
||||||
const float widthSize) const {
|
const float widthSize) const {
|
||||||
return getLeadingMargin(axis, widthSize) + getTrailingMargin(axis, widthSize);
|
return getLeadingMargin(axis, widthSize) + getTrailingMargin(axis, widthSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
FloatOptional Node::getGapForAxis(
|
FloatOptional Node::getGapForAxis(
|
||||||
const YGFlexDirection axis,
|
const FlexDirection axis,
|
||||||
const float widthSize) const {
|
const float widthSize) const {
|
||||||
auto gap = isRow(axis)
|
auto gap = isRow(axis)
|
||||||
? computeColumnGap(style_.gap(), CompactValue::ofZero())
|
? computeColumnGap(style_.gap(), CompactValue::ofZero())
|
||||||
@@ -355,7 +355,7 @@ void Node::setLayoutDimension(float dimensionValue, YGDimension dimension) {
|
|||||||
// If both left and right are defined, then use left. Otherwise return +left or
|
// If both left and right are defined, then use left. Otherwise return +left or
|
||||||
// -right depending on which is defined.
|
// -right depending on which is defined.
|
||||||
FloatOptional Node::relativePosition(
|
FloatOptional Node::relativePosition(
|
||||||
const YGFlexDirection axis,
|
const FlexDirection axis,
|
||||||
const float axisSize) const {
|
const float axisSize) const {
|
||||||
if (isLeadingPositionDefined(axis)) {
|
if (isLeadingPositionDefined(axis)) {
|
||||||
return getLeadingPosition(axis, axisSize);
|
return getLeadingPosition(axis, axisSize);
|
||||||
@@ -377,9 +377,9 @@ void Node::setPosition(
|
|||||||
* values. */
|
* values. */
|
||||||
const Direction directionRespectingRoot =
|
const Direction directionRespectingRoot =
|
||||||
owner_ != nullptr ? direction : Direction::LTR;
|
owner_ != nullptr ? direction : Direction::LTR;
|
||||||
const YGFlexDirection mainAxis =
|
const FlexDirection mainAxis =
|
||||||
yoga::resolveDirection(style_.flexDirection(), directionRespectingRoot);
|
yoga::resolveDirection(style_.flexDirection(), directionRespectingRoot);
|
||||||
const YGFlexDirection crossAxis =
|
const FlexDirection crossAxis =
|
||||||
yoga::resolveCrossDirection(mainAxis, directionRespectingRoot);
|
yoga::resolveCrossDirection(mainAxis, directionRespectingRoot);
|
||||||
|
|
||||||
// Here we should check for `YGPositionTypeStatic` and in this case zero inset
|
// Here we should check for `YGPositionTypeStatic` and in this case zero inset
|
||||||
@@ -406,7 +406,7 @@ void Node::setPosition(
|
|||||||
trailingEdge(crossAxis));
|
trailingEdge(crossAxis));
|
||||||
}
|
}
|
||||||
|
|
||||||
YGValue Node::marginLeadingValue(const YGFlexDirection axis) const {
|
YGValue Node::marginLeadingValue(const FlexDirection axis) const {
|
||||||
if (isRow(axis) && !style_.margin()[YGEdgeStart].isUndefined()) {
|
if (isRow(axis) && !style_.margin()[YGEdgeStart].isUndefined()) {
|
||||||
return style_.margin()[YGEdgeStart];
|
return style_.margin()[YGEdgeStart];
|
||||||
} else {
|
} else {
|
||||||
@@ -414,7 +414,7 @@ YGValue Node::marginLeadingValue(const YGFlexDirection axis) const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
YGValue Node::marginTrailingValue(const YGFlexDirection axis) const {
|
YGValue Node::marginTrailingValue(const FlexDirection axis) const {
|
||||||
if (isRow(axis) && !style_.margin()[YGEdgeEnd].isUndefined()) {
|
if (isRow(axis) && !style_.margin()[YGEdgeEnd].isUndefined()) {
|
||||||
return style_.margin()[YGEdgeEnd];
|
return style_.margin()[YGEdgeEnd];
|
||||||
} else {
|
} else {
|
||||||
@@ -526,7 +526,7 @@ bool Node::isNodeFlexible() {
|
|||||||
(resolveFlexGrow() != 0 || resolveFlexShrink() != 0));
|
(resolveFlexGrow() != 0 || resolveFlexShrink() != 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
float Node::getLeadingBorder(const YGFlexDirection axis) const {
|
float Node::getLeadingBorder(const FlexDirection axis) const {
|
||||||
YGValue leadingBorder = isRow(axis)
|
YGValue leadingBorder = isRow(axis)
|
||||||
? computeEdgeValueForRow(
|
? computeEdgeValueForRow(
|
||||||
style_.border(),
|
style_.border(),
|
||||||
@@ -538,7 +538,7 @@ float Node::getLeadingBorder(const YGFlexDirection axis) const {
|
|||||||
return fmaxf(leadingBorder.value, 0.0f);
|
return fmaxf(leadingBorder.value, 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
float Node::getTrailingBorder(const YGFlexDirection axis) const {
|
float Node::getTrailingBorder(const FlexDirection axis) const {
|
||||||
YGValue trailingBorder = isRow(axis)
|
YGValue trailingBorder = isRow(axis)
|
||||||
? computeEdgeValueForRow(
|
? computeEdgeValueForRow(
|
||||||
style_.border(),
|
style_.border(),
|
||||||
@@ -551,7 +551,7 @@ float Node::getTrailingBorder(const YGFlexDirection axis) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
FloatOptional Node::getLeadingPadding(
|
FloatOptional Node::getLeadingPadding(
|
||||||
const YGFlexDirection axis,
|
const FlexDirection axis,
|
||||||
const float widthSize) const {
|
const float widthSize) const {
|
||||||
auto leadingPadding = isRow(axis)
|
auto leadingPadding = isRow(axis)
|
||||||
? computeEdgeValueForRow(
|
? computeEdgeValueForRow(
|
||||||
@@ -566,7 +566,7 @@ FloatOptional Node::getLeadingPadding(
|
|||||||
}
|
}
|
||||||
|
|
||||||
FloatOptional Node::getTrailingPadding(
|
FloatOptional Node::getTrailingPadding(
|
||||||
const YGFlexDirection axis,
|
const FlexDirection axis,
|
||||||
const float widthSize) const {
|
const float widthSize) const {
|
||||||
auto trailingPadding = isRow(axis)
|
auto trailingPadding = isRow(axis)
|
||||||
? computeEdgeValueForRow(
|
? computeEdgeValueForRow(
|
||||||
@@ -581,14 +581,14 @@ FloatOptional Node::getTrailingPadding(
|
|||||||
}
|
}
|
||||||
|
|
||||||
FloatOptional Node::getLeadingPaddingAndBorder(
|
FloatOptional Node::getLeadingPaddingAndBorder(
|
||||||
const YGFlexDirection axis,
|
const FlexDirection axis,
|
||||||
const float widthSize) const {
|
const float widthSize) const {
|
||||||
return getLeadingPadding(axis, widthSize) +
|
return getLeadingPadding(axis, widthSize) +
|
||||||
FloatOptional(getLeadingBorder(axis));
|
FloatOptional(getLeadingBorder(axis));
|
||||||
}
|
}
|
||||||
|
|
||||||
FloatOptional Node::getTrailingPaddingAndBorder(
|
FloatOptional Node::getTrailingPaddingAndBorder(
|
||||||
const YGFlexDirection axis,
|
const FlexDirection axis,
|
||||||
const float widthSize) const {
|
const float widthSize) const {
|
||||||
return getTrailingPadding(axis, widthSize) +
|
return getTrailingPadding(axis, widthSize) +
|
||||||
FloatOptional(getTrailingBorder(axis));
|
FloatOptional(getTrailingBorder(axis));
|
||||||
|
@@ -47,12 +47,11 @@ class YG_EXPORT Node : public ::YGNode {
|
|||||||
std::array<YGValue, 2> resolvedDimensions_ = {
|
std::array<YGValue, 2> resolvedDimensions_ = {
|
||||||
{YGValueUndefined, YGValueUndefined}};
|
{YGValueUndefined, YGValueUndefined}};
|
||||||
|
|
||||||
FloatOptional relativePosition(
|
FloatOptional relativePosition(const FlexDirection axis, const float axisSize)
|
||||||
const YGFlexDirection axis,
|
const;
|
||||||
const float axisSize) const;
|
|
||||||
|
|
||||||
void useWebDefaults() {
|
void useWebDefaults() {
|
||||||
style_.flexDirection() = YGFlexDirectionRow;
|
style_.flexDirection() = FlexDirection::Row;
|
||||||
style_.alignContent() = YGAlignStretch;
|
style_.alignContent() = YGAlignStretch;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,37 +200,37 @@ class YG_EXPORT Node : public ::YGNode {
|
|||||||
|
|
||||||
// Methods related to positions, margin, padding and border
|
// Methods related to positions, margin, padding and border
|
||||||
FloatOptional getLeadingPosition(
|
FloatOptional getLeadingPosition(
|
||||||
const YGFlexDirection axis,
|
const FlexDirection axis,
|
||||||
const float axisSize) const;
|
const float axisSize) const;
|
||||||
bool isLeadingPositionDefined(const YGFlexDirection axis) const;
|
bool isLeadingPositionDefined(const FlexDirection axis) const;
|
||||||
bool isTrailingPosDefined(const YGFlexDirection axis) const;
|
bool isTrailingPosDefined(const FlexDirection axis) const;
|
||||||
FloatOptional getTrailingPosition(
|
FloatOptional getTrailingPosition(
|
||||||
const YGFlexDirection axis,
|
const FlexDirection axis,
|
||||||
const float axisSize) const;
|
const float axisSize) const;
|
||||||
FloatOptional getLeadingMargin(
|
FloatOptional getLeadingMargin(
|
||||||
const YGFlexDirection axis,
|
const FlexDirection axis,
|
||||||
const float widthSize) const;
|
const float widthSize) const;
|
||||||
FloatOptional getTrailingMargin(
|
FloatOptional getTrailingMargin(
|
||||||
const YGFlexDirection axis,
|
const FlexDirection axis,
|
||||||
const float widthSize) const;
|
const float widthSize) const;
|
||||||
float getLeadingBorder(const YGFlexDirection flexDirection) const;
|
float getLeadingBorder(const FlexDirection flexDirection) const;
|
||||||
float getTrailingBorder(const YGFlexDirection flexDirection) const;
|
float getTrailingBorder(const FlexDirection flexDirection) const;
|
||||||
FloatOptional getLeadingPadding(
|
FloatOptional getLeadingPadding(
|
||||||
const YGFlexDirection axis,
|
const FlexDirection axis,
|
||||||
const float widthSize) const;
|
const float widthSize) const;
|
||||||
FloatOptional getTrailingPadding(
|
FloatOptional getTrailingPadding(
|
||||||
const YGFlexDirection axis,
|
const FlexDirection axis,
|
||||||
const float widthSize) const;
|
const float widthSize) const;
|
||||||
FloatOptional getLeadingPaddingAndBorder(
|
FloatOptional getLeadingPaddingAndBorder(
|
||||||
const YGFlexDirection axis,
|
const FlexDirection axis,
|
||||||
const float widthSize) const;
|
const float widthSize) const;
|
||||||
FloatOptional getTrailingPaddingAndBorder(
|
FloatOptional getTrailingPaddingAndBorder(
|
||||||
const YGFlexDirection axis,
|
const FlexDirection axis,
|
||||||
const float widthSize) const;
|
const float widthSize) const;
|
||||||
FloatOptional getMarginForAxis(
|
FloatOptional getMarginForAxis(
|
||||||
const YGFlexDirection axis,
|
const FlexDirection axis,
|
||||||
const float widthSize) const;
|
const float widthSize) const;
|
||||||
FloatOptional getGapForAxis(const YGFlexDirection axis, const float widthSize)
|
FloatOptional getGapForAxis(const FlexDirection axis, const float widthSize)
|
||||||
const;
|
const;
|
||||||
// Setters
|
// Setters
|
||||||
|
|
||||||
@@ -312,8 +311,8 @@ class YG_EXPORT Node : public ::YGNode {
|
|||||||
void markDirtyAndPropagateDownwards();
|
void markDirtyAndPropagateDownwards();
|
||||||
|
|
||||||
// Other methods
|
// Other methods
|
||||||
YGValue marginLeadingValue(const YGFlexDirection axis) const;
|
YGValue marginLeadingValue(const FlexDirection axis) const;
|
||||||
YGValue marginTrailingValue(const YGFlexDirection axis) const;
|
YGValue marginTrailingValue(const FlexDirection axis) const;
|
||||||
YGValue resolveFlexBasisPtr() const;
|
YGValue resolveFlexBasisPtr() const;
|
||||||
void resolveDimension();
|
void resolveDimension();
|
||||||
Direction resolveDirection(const Direction ownerDirection);
|
Direction resolveDirection(const Direction ownerDirection);
|
||||||
|
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
#include <yoga/bits/NumericBitfield.h>
|
#include <yoga/bits/NumericBitfield.h>
|
||||||
#include <yoga/enums/Direction.h>
|
#include <yoga/enums/Direction.h>
|
||||||
|
#include <yoga/enums/FlexDirection.h>
|
||||||
#include <yoga/numeric/FloatOptional.h>
|
#include <yoga/numeric/FloatOptional.h>
|
||||||
#include <yoga/style/CompactValue.h>
|
#include <yoga/style/CompactValue.h>
|
||||||
|
|
||||||
@@ -103,7 +104,7 @@ class YG_EXPORT Style {
|
|||||||
static constexpr uint8_t flexdirectionOffset =
|
static constexpr uint8_t flexdirectionOffset =
|
||||||
directionOffset + minimumBitCount<Direction>();
|
directionOffset + minimumBitCount<Direction>();
|
||||||
static constexpr uint8_t justifyContentOffset =
|
static constexpr uint8_t justifyContentOffset =
|
||||||
flexdirectionOffset + minimumBitCount<YGFlexDirection>();
|
flexdirectionOffset + minimumBitCount<FlexDirection>();
|
||||||
static constexpr uint8_t alignContentOffset =
|
static constexpr uint8_t alignContentOffset =
|
||||||
justifyContentOffset + minimumBitCount<YGJustify>();
|
justifyContentOffset + minimumBitCount<YGJustify>();
|
||||||
static constexpr uint8_t alignItemsOffset =
|
static constexpr uint8_t alignItemsOffset =
|
||||||
@@ -147,10 +148,10 @@ class YG_EXPORT Style {
|
|||||||
return {*this, directionOffset};
|
return {*this, directionOffset};
|
||||||
}
|
}
|
||||||
|
|
||||||
YGFlexDirection flexDirection() const {
|
FlexDirection flexDirection() const {
|
||||||
return getEnumData<YGFlexDirection>(flags, flexdirectionOffset);
|
return getEnumData<FlexDirection>(flags, flexdirectionOffset);
|
||||||
}
|
}
|
||||||
BitfieldRef<YGFlexDirection> flexDirection() {
|
BitfieldRef<FlexDirection> flexDirection() {
|
||||||
return {*this, flexdirectionOffset};
|
return {*this, flexdirectionOffset};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user