YGEdge -> yoga::Edge (#1461)
Summary: X-link: https://github.com/facebook/react-native/pull/41391 Pull Request resolved: https://github.com/facebook/yoga/pull/1461 Converts usages of `YGEdge` within internal APIs to `yoga::Edge` scoped enum. With the exception of YGUnit which is in its own state of transition, this is the last public yoga enum to need to be moved to scoped enum form for usages internal to the Yoga public API. Changelog: [internal] Reviewed By: rshest Differential Revision: D51152779 fbshipit-source-id: 06554f67bfd7709cbc24fdd9a5474e897e9e95d8
This commit is contained in:
committed by
Facebook GitHub Bot
parent
a121483e81
commit
325ccea068
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include <yoga/Yoga.h>
|
#include <yoga/Yoga.h>
|
||||||
#include <yoga/debug/AssertFatal.h>
|
#include <yoga/debug/AssertFatal.h>
|
||||||
|
#include <yoga/enums/Edge.h>
|
||||||
#include <yoga/node/Node.h>
|
#include <yoga/node/Node.h>
|
||||||
|
|
||||||
using namespace facebook;
|
using namespace facebook;
|
||||||
@@ -15,50 +16,48 @@ using namespace facebook::yoga;
|
|||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
template <auto LayoutMember>
|
template <auto LayoutMember>
|
||||||
float getResolvedLayoutProperty(
|
float getResolvedLayoutProperty(const YGNodeConstRef nodeRef, const Edge edge) {
|
||||||
const YGNodeConstRef nodeRef,
|
|
||||||
const YGEdge edge) {
|
|
||||||
const auto node = resolveRef(nodeRef);
|
const auto node = resolveRef(nodeRef);
|
||||||
yoga::assertFatalWithNode(
|
yoga::assertFatalWithNode(
|
||||||
node,
|
node,
|
||||||
edge <= YGEdgeEnd,
|
edge <= Edge::End,
|
||||||
"Cannot get layout properties of multi-edge shorthands");
|
"Cannot get layout properties of multi-edge shorthands");
|
||||||
|
|
||||||
if (edge == YGEdgeStart) {
|
if (edge == Edge::Start) {
|
||||||
if (node->getLayout().direction() == Direction::RTL) {
|
if (node->getLayout().direction() == Direction::RTL) {
|
||||||
return (node->getLayout().*LayoutMember)[YGEdgeRight];
|
return (node->getLayout().*LayoutMember)(Edge::Right);
|
||||||
} else {
|
} else {
|
||||||
return (node->getLayout().*LayoutMember)[YGEdgeLeft];
|
return (node->getLayout().*LayoutMember)(Edge::Left);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (edge == YGEdgeEnd) {
|
if (edge == Edge::End) {
|
||||||
if (node->getLayout().direction() == Direction::RTL) {
|
if (node->getLayout().direction() == Direction::RTL) {
|
||||||
return (node->getLayout().*LayoutMember)[YGEdgeLeft];
|
return (node->getLayout().*LayoutMember)(Edge::Left);
|
||||||
} else {
|
} else {
|
||||||
return (node->getLayout().*LayoutMember)[YGEdgeRight];
|
return (node->getLayout().*LayoutMember)(Edge::Right);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (node->getLayout().*LayoutMember)[edge];
|
return (node->getLayout().*LayoutMember)(edge);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
float YGNodeLayoutGetLeft(const YGNodeConstRef node) {
|
float YGNodeLayoutGetLeft(const YGNodeConstRef node) {
|
||||||
return resolveRef(node)->getLayout().position[YGEdgeLeft];
|
return resolveRef(node)->getLayout().position(Edge::Left);
|
||||||
}
|
}
|
||||||
|
|
||||||
float YGNodeLayoutGetTop(const YGNodeConstRef node) {
|
float YGNodeLayoutGetTop(const YGNodeConstRef node) {
|
||||||
return resolveRef(node)->getLayout().position[YGEdgeTop];
|
return resolveRef(node)->getLayout().position(Edge::Top);
|
||||||
}
|
}
|
||||||
|
|
||||||
float YGNodeLayoutGetRight(const YGNodeConstRef node) {
|
float YGNodeLayoutGetRight(const YGNodeConstRef node) {
|
||||||
return resolveRef(node)->getLayout().position[YGEdgeRight];
|
return resolveRef(node)->getLayout().position(Edge::Right);
|
||||||
}
|
}
|
||||||
|
|
||||||
float YGNodeLayoutGetBottom(const YGNodeConstRef node) {
|
float YGNodeLayoutGetBottom(const YGNodeConstRef node) {
|
||||||
return resolveRef(node)->getLayout().position[YGEdgeBottom];
|
return resolveRef(node)->getLayout().position(Edge::Bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
float YGNodeLayoutGetWidth(const YGNodeConstRef node) {
|
float YGNodeLayoutGetWidth(const YGNodeConstRef node) {
|
||||||
@@ -78,13 +77,16 @@ bool YGNodeLayoutGetHadOverflow(const YGNodeConstRef node) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
float YGNodeLayoutGetMargin(YGNodeConstRef node, YGEdge edge) {
|
float YGNodeLayoutGetMargin(YGNodeConstRef node, YGEdge edge) {
|
||||||
return getResolvedLayoutProperty<&LayoutResults::margin>(node, edge);
|
return getResolvedLayoutProperty<&LayoutResults::margin>(
|
||||||
|
node, scopedEnum(edge));
|
||||||
}
|
}
|
||||||
|
|
||||||
float YGNodeLayoutGetBorder(YGNodeConstRef node, YGEdge edge) {
|
float YGNodeLayoutGetBorder(YGNodeConstRef node, YGEdge edge) {
|
||||||
return getResolvedLayoutProperty<&LayoutResults::border>(node, edge);
|
return getResolvedLayoutProperty<&LayoutResults::border>(
|
||||||
|
node, scopedEnum(edge));
|
||||||
}
|
}
|
||||||
|
|
||||||
float YGNodeLayoutGetPadding(YGNodeConstRef node, YGEdge edge) {
|
float YGNodeLayoutGetPadding(YGNodeConstRef node, YGEdge edge) {
|
||||||
return getResolvedLayoutProperty<&LayoutResults::padding>(node, edge);
|
return getResolvedLayoutProperty<&LayoutResults::padding>(
|
||||||
|
node, scopedEnum(edge));
|
||||||
}
|
}
|
||||||
|
@@ -223,49 +223,49 @@ YGValue YGNodeStyleGetFlexBasis(const YGNodeConstRef node) {
|
|||||||
|
|
||||||
void YGNodeStyleSetPosition(YGNodeRef node, YGEdge edge, float points) {
|
void YGNodeStyleSetPosition(YGNodeRef node, YGEdge edge, float points) {
|
||||||
updateIndexedStyleProp<&Style::position, &Style::setPosition>(
|
updateIndexedStyleProp<&Style::position, &Style::setPosition>(
|
||||||
node, edge, value::points(points));
|
node, scopedEnum(edge), value::points(points));
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeStyleSetPositionPercent(YGNodeRef node, YGEdge edge, float percent) {
|
void YGNodeStyleSetPositionPercent(YGNodeRef node, YGEdge edge, float percent) {
|
||||||
updateIndexedStyleProp<&Style::position, &Style::setPosition>(
|
updateIndexedStyleProp<&Style::position, &Style::setPosition>(
|
||||||
node, edge, value::percent(percent));
|
node, scopedEnum(edge), value::percent(percent));
|
||||||
}
|
}
|
||||||
|
|
||||||
YGValue YGNodeStyleGetPosition(YGNodeConstRef node, YGEdge edge) {
|
YGValue YGNodeStyleGetPosition(YGNodeConstRef node, YGEdge edge) {
|
||||||
return resolveRef(node)->getStyle().position(edge);
|
return resolveRef(node)->getStyle().position(scopedEnum(edge));
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeStyleSetMargin(YGNodeRef node, YGEdge edge, float points) {
|
void YGNodeStyleSetMargin(YGNodeRef node, YGEdge edge, float points) {
|
||||||
updateIndexedStyleProp<&Style::margin, &Style::setMargin>(
|
updateIndexedStyleProp<&Style::margin, &Style::setMargin>(
|
||||||
node, edge, value::points(points));
|
node, scopedEnum(edge), value::points(points));
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeStyleSetMarginPercent(YGNodeRef node, YGEdge edge, float percent) {
|
void YGNodeStyleSetMarginPercent(YGNodeRef node, YGEdge edge, float percent) {
|
||||||
updateIndexedStyleProp<&Style::margin, &Style::setMargin>(
|
updateIndexedStyleProp<&Style::margin, &Style::setMargin>(
|
||||||
node, edge, value::percent(percent));
|
node, scopedEnum(edge), value::percent(percent));
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeStyleSetMarginAuto(YGNodeRef node, YGEdge edge) {
|
void YGNodeStyleSetMarginAuto(YGNodeRef node, YGEdge edge) {
|
||||||
updateIndexedStyleProp<&Style::margin, &Style::setMargin>(
|
updateIndexedStyleProp<&Style::margin, &Style::setMargin>(
|
||||||
node, edge, value::ofAuto());
|
node, scopedEnum(edge), value::ofAuto());
|
||||||
}
|
}
|
||||||
|
|
||||||
YGValue YGNodeStyleGetMargin(YGNodeConstRef node, YGEdge edge) {
|
YGValue YGNodeStyleGetMargin(YGNodeConstRef node, YGEdge edge) {
|
||||||
return resolveRef(node)->getStyle().margin(edge);
|
return resolveRef(node)->getStyle().margin(scopedEnum(edge));
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeStyleSetPadding(YGNodeRef node, YGEdge edge, float points) {
|
void YGNodeStyleSetPadding(YGNodeRef node, YGEdge edge, float points) {
|
||||||
updateIndexedStyleProp<&Style::padding, &Style::setPadding>(
|
updateIndexedStyleProp<&Style::padding, &Style::setPadding>(
|
||||||
node, edge, value::points(points));
|
node, scopedEnum(edge), value::points(points));
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeStyleSetPaddingPercent(YGNodeRef node, YGEdge edge, float percent) {
|
void YGNodeStyleSetPaddingPercent(YGNodeRef node, YGEdge edge, float percent) {
|
||||||
updateIndexedStyleProp<&Style::padding, &Style::setPadding>(
|
updateIndexedStyleProp<&Style::padding, &Style::setPadding>(
|
||||||
node, edge, value::percent(percent));
|
node, scopedEnum(edge), value::percent(percent));
|
||||||
}
|
}
|
||||||
|
|
||||||
YGValue YGNodeStyleGetPadding(YGNodeConstRef node, YGEdge edge) {
|
YGValue YGNodeStyleGetPadding(YGNodeConstRef node, YGEdge edge) {
|
||||||
return resolveRef(node)->getStyle().padding(edge);
|
return resolveRef(node)->getStyle().padding(scopedEnum(edge));
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeStyleSetBorder(
|
void YGNodeStyleSetBorder(
|
||||||
@@ -273,11 +273,11 @@ void YGNodeStyleSetBorder(
|
|||||||
const YGEdge edge,
|
const YGEdge edge,
|
||||||
const float border) {
|
const float border) {
|
||||||
updateIndexedStyleProp<&Style::border, &Style::setBorder>(
|
updateIndexedStyleProp<&Style::border, &Style::setBorder>(
|
||||||
node, edge, value::points(border));
|
node, scopedEnum(edge), value::points(border));
|
||||||
}
|
}
|
||||||
|
|
||||||
float YGNodeStyleGetBorder(const YGNodeConstRef node, const YGEdge edge) {
|
float YGNodeStyleGetBorder(const YGNodeConstRef node, const YGEdge edge) {
|
||||||
auto border = resolveRef(node)->getStyle().border(edge);
|
auto border = resolveRef(node)->getStyle().border(scopedEnum(edge));
|
||||||
if (border.isUndefined() || border.isAuto()) {
|
if (border.isUndefined() || border.isAuto()) {
|
||||||
return YGUndefined;
|
return YGUndefined;
|
||||||
}
|
}
|
||||||
|
@@ -57,7 +57,7 @@ float calculateBaseline(const yoga::Node* node) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const float baseline = calculateBaseline(baselineChild);
|
const float baseline = calculateBaseline(baselineChild);
|
||||||
return baseline + baselineChild->getLayout().position[YGEdgeTop];
|
return baseline + baselineChild->getLayout().position(Edge::Top);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isBaselineLayout(const yoga::Node* node) {
|
bool isBaselineLayout(const yoga::Node* node) {
|
||||||
|
@@ -89,7 +89,7 @@ static void setChildTrailingPosition(
|
|||||||
const float size = child->getLayout().measuredDimension(dimension(axis));
|
const float size = child->getLayout().measuredDimension(dimension(axis));
|
||||||
child->setLayoutPosition(
|
child->setLayoutPosition(
|
||||||
node->getLayout().measuredDimension(dimension(axis)) - size -
|
node->getLayout().measuredDimension(dimension(axis)) - size -
|
||||||
child->getLayout().position[flexStartEdge(axis)],
|
child->getLayout().position(flexStartEdge(axis)),
|
||||||
flexEndEdge(axis));
|
flexEndEdge(axis));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -553,12 +553,13 @@ static void measureNodeWithMeasureFunc(
|
|||||||
availableHeight = YGUndefined;
|
availableHeight = YGUndefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto& padding = node->getLayout().padding;
|
const auto& layout = node->getLayout();
|
||||||
const auto& border = node->getLayout().border;
|
const float paddingAndBorderAxisRow = layout.padding(Edge::Left) +
|
||||||
const float paddingAndBorderAxisRow = padding[YGEdgeLeft] +
|
layout.padding(Edge::Right) + layout.border(Edge::Left) +
|
||||||
padding[YGEdgeRight] + border[YGEdgeLeft] + border[YGEdgeRight];
|
layout.border(Edge::Right);
|
||||||
const float paddingAndBorderAxisColumn = padding[YGEdgeTop] +
|
const float paddingAndBorderAxisColumn = layout.padding(Edge::Top) +
|
||||||
padding[YGEdgeBottom] + border[YGEdgeTop] + border[YGEdgeBottom];
|
layout.padding(Edge::Bottom) + layout.border(Edge::Top) +
|
||||||
|
layout.border(Edge::Bottom);
|
||||||
|
|
||||||
// We want to make sure we don't call measure with negative size
|
// We want to make sure we don't call measure with negative size
|
||||||
const float innerWidth = yoga::isUndefined(availableWidth)
|
const float innerWidth = yoga::isUndefined(availableWidth)
|
||||||
@@ -643,14 +644,13 @@ static void measureNodeWithoutChildren(
|
|||||||
const SizingMode heightSizingMode,
|
const SizingMode heightSizingMode,
|
||||||
const float ownerWidth,
|
const float ownerWidth,
|
||||||
const float ownerHeight) {
|
const float ownerHeight) {
|
||||||
const auto& padding = node->getLayout().padding;
|
const auto& layout = node->getLayout();
|
||||||
const auto& border = node->getLayout().border;
|
|
||||||
|
|
||||||
float width = availableWidth;
|
float width = availableWidth;
|
||||||
if (widthSizingMode == SizingMode::MaxContent ||
|
if (widthSizingMode == SizingMode::MaxContent ||
|
||||||
widthSizingMode == SizingMode::FitContent) {
|
widthSizingMode == SizingMode::FitContent) {
|
||||||
width = padding[YGEdgeLeft] + padding[YGEdgeRight] + border[YGEdgeLeft] +
|
width = layout.padding(Edge::Left) + layout.padding(Edge::Right) +
|
||||||
border[YGEdgeRight];
|
layout.border(Edge::Left) + layout.border(Edge::Right);
|
||||||
}
|
}
|
||||||
node->setLayoutMeasuredDimension(
|
node->setLayoutMeasuredDimension(
|
||||||
boundAxis(node, FlexDirection::Row, width, ownerWidth, ownerWidth),
|
boundAxis(node, FlexDirection::Row, width, ownerWidth, ownerWidth),
|
||||||
@@ -659,8 +659,8 @@ static void measureNodeWithoutChildren(
|
|||||||
float height = availableHeight;
|
float height = availableHeight;
|
||||||
if (heightSizingMode == SizingMode::MaxContent ||
|
if (heightSizingMode == SizingMode::MaxContent ||
|
||||||
heightSizingMode == SizingMode::FitContent) {
|
heightSizingMode == SizingMode::FitContent) {
|
||||||
height = padding[YGEdgeTop] + padding[YGEdgeBottom] + border[YGEdgeTop] +
|
height = layout.padding(Edge::Top) + layout.padding(Edge::Bottom) +
|
||||||
border[YGEdgeBottom];
|
layout.border(Edge::Top) + layout.border(Edge::Bottom);
|
||||||
}
|
}
|
||||||
node->setLayoutMeasuredDimension(
|
node->setLayoutMeasuredDimension(
|
||||||
boundAxis(node, FlexDirection::Column, height, ownerHeight, ownerWidth),
|
boundAxis(node, FlexDirection::Column, height, ownerHeight, ownerWidth),
|
||||||
@@ -1330,7 +1330,7 @@ static void justifyMainAxis(
|
|||||||
|
|
||||||
if (performLayout) {
|
if (performLayout) {
|
||||||
child->setLayoutPosition(
|
child->setLayoutPosition(
|
||||||
childLayout.position[flexStartEdge(mainAxis)] +
|
childLayout.position(flexStartEdge(mainAxis)) +
|
||||||
flexLine.layout.mainDim,
|
flexLine.layout.mainDim,
|
||||||
flexStartEdge(mainAxis));
|
flexStartEdge(mainAxis));
|
||||||
}
|
}
|
||||||
@@ -1386,7 +1386,7 @@ static void justifyMainAxis(
|
|||||||
}
|
}
|
||||||
} else if (performLayout) {
|
} else if (performLayout) {
|
||||||
child->setLayoutPosition(
|
child->setLayoutPosition(
|
||||||
childLayout.position[flexStartEdge(mainAxis)] +
|
childLayout.position(flexStartEdge(mainAxis)) +
|
||||||
node->getInlineStartBorder(mainAxis, direction) +
|
node->getInlineStartBorder(mainAxis, direction) +
|
||||||
leadingMainDim,
|
leadingMainDim,
|
||||||
flexStartEdge(mainAxis));
|
flexStartEdge(mainAxis));
|
||||||
@@ -1497,9 +1497,8 @@ static void calculateLayoutImpl(
|
|||||||
const FlexDirection flexColumnDirection =
|
const FlexDirection flexColumnDirection =
|
||||||
resolveDirection(FlexDirection::Column, direction);
|
resolveDirection(FlexDirection::Column, direction);
|
||||||
|
|
||||||
const YGEdge startEdge =
|
const Edge startEdge = direction == Direction::LTR ? Edge::Left : Edge::Right;
|
||||||
direction == Direction::LTR ? YGEdgeLeft : YGEdgeRight;
|
const Edge endEdge = direction == Direction::LTR ? Edge::Right : Edge::Left;
|
||||||
const YGEdge endEdge = direction == Direction::LTR ? YGEdgeRight : YGEdgeLeft;
|
|
||||||
|
|
||||||
const float marginRowLeading =
|
const float marginRowLeading =
|
||||||
node->getInlineStartMargin(flexRowDirection, direction, ownerWidth);
|
node->getInlineStartMargin(flexRowDirection, direction, ownerWidth);
|
||||||
@@ -1509,10 +1508,10 @@ static void calculateLayoutImpl(
|
|||||||
node->setLayoutMargin(marginRowTrailing, endEdge);
|
node->setLayoutMargin(marginRowTrailing, endEdge);
|
||||||
const float marginColumnLeading =
|
const float marginColumnLeading =
|
||||||
node->getInlineStartMargin(flexColumnDirection, direction, ownerWidth);
|
node->getInlineStartMargin(flexColumnDirection, direction, ownerWidth);
|
||||||
node->setLayoutMargin(marginColumnLeading, YGEdgeTop);
|
node->setLayoutMargin(marginColumnLeading, Edge::Top);
|
||||||
const float marginColumnTrailing =
|
const float marginColumnTrailing =
|
||||||
node->getInlineEndMargin(flexColumnDirection, direction, ownerWidth);
|
node->getInlineEndMargin(flexColumnDirection, direction, ownerWidth);
|
||||||
node->setLayoutMargin(marginColumnTrailing, YGEdgeBottom);
|
node->setLayoutMargin(marginColumnTrailing, Edge::Bottom);
|
||||||
|
|
||||||
const float marginAxisRow = marginRowLeading + marginRowTrailing;
|
const float marginAxisRow = marginRowLeading + marginRowTrailing;
|
||||||
const float marginAxisColumn = marginColumnLeading + marginColumnTrailing;
|
const float marginAxisColumn = marginColumnLeading + marginColumnTrailing;
|
||||||
@@ -1522,9 +1521,9 @@ static void calculateLayoutImpl(
|
|||||||
node->setLayoutBorder(
|
node->setLayoutBorder(
|
||||||
node->getInlineEndBorder(flexRowDirection, direction), endEdge);
|
node->getInlineEndBorder(flexRowDirection, direction), endEdge);
|
||||||
node->setLayoutBorder(
|
node->setLayoutBorder(
|
||||||
node->getInlineStartBorder(flexColumnDirection, direction), YGEdgeTop);
|
node->getInlineStartBorder(flexColumnDirection, direction), Edge::Top);
|
||||||
node->setLayoutBorder(
|
node->setLayoutBorder(
|
||||||
node->getInlineEndBorder(flexColumnDirection, direction), YGEdgeBottom);
|
node->getInlineEndBorder(flexColumnDirection, direction), Edge::Bottom);
|
||||||
|
|
||||||
node->setLayoutPadding(
|
node->setLayoutPadding(
|
||||||
node->getInlineStartPadding(flexRowDirection, direction, ownerWidth),
|
node->getInlineStartPadding(flexRowDirection, direction, ownerWidth),
|
||||||
@@ -1534,10 +1533,10 @@ static void calculateLayoutImpl(
|
|||||||
endEdge);
|
endEdge);
|
||||||
node->setLayoutPadding(
|
node->setLayoutPadding(
|
||||||
node->getInlineStartPadding(flexColumnDirection, direction, ownerWidth),
|
node->getInlineStartPadding(flexColumnDirection, direction, ownerWidth),
|
||||||
YGEdgeTop);
|
Edge::Top);
|
||||||
node->setLayoutPadding(
|
node->setLayoutPadding(
|
||||||
node->getInlineEndPadding(flexColumnDirection, direction, ownerWidth),
|
node->getInlineEndPadding(flexColumnDirection, direction, ownerWidth),
|
||||||
YGEdgeBottom);
|
Edge::Bottom);
|
||||||
|
|
||||||
if (node->hasMeasureFunc()) {
|
if (node->hasMeasureFunc()) {
|
||||||
measureNodeWithMeasureFunc(
|
measureNodeWithMeasureFunc(
|
||||||
@@ -1868,7 +1867,7 @@ static void calculateLayoutImpl(
|
|||||||
// default to border + margin
|
// default to border + margin
|
||||||
if (!isChildLeadingPosDefined ||
|
if (!isChildLeadingPosDefined ||
|
||||||
yoga::isUndefined(
|
yoga::isUndefined(
|
||||||
child->getLayout().position[flexStartEdge(crossAxis)])) {
|
child->getLayout().position(flexStartEdge(crossAxis)))) {
|
||||||
child->setLayoutPosition(
|
child->setLayoutPosition(
|
||||||
node->getInlineStartBorder(crossAxis, direction) +
|
node->getInlineStartBorder(crossAxis, direction) +
|
||||||
child->getInlineStartMargin(
|
child->getInlineStartMargin(
|
||||||
@@ -1981,7 +1980,7 @@ static void calculateLayoutImpl(
|
|||||||
}
|
}
|
||||||
// And we apply the position
|
// And we apply the position
|
||||||
child->setLayoutPosition(
|
child->setLayoutPosition(
|
||||||
child->getLayout().position[flexStartEdge(crossAxis)] +
|
child->getLayout().position(flexStartEdge(crossAxis)) +
|
||||||
totalLineCrossDim + leadingCrossDim,
|
totalLineCrossDim + leadingCrossDim,
|
||||||
flexStartEdge(crossAxis));
|
flexStartEdge(crossAxis));
|
||||||
}
|
}
|
||||||
@@ -2190,7 +2189,7 @@ static void calculateLayoutImpl(
|
|||||||
FlexDirection::Column,
|
FlexDirection::Column,
|
||||||
direction,
|
direction,
|
||||||
availableInnerCrossDim),
|
availableInnerCrossDim),
|
||||||
YGEdgeTop);
|
Edge::Top);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -2296,7 +2295,7 @@ static void calculateLayoutImpl(
|
|||||||
if (child->getStyle().positionType() != PositionType::Absolute) {
|
if (child->getStyle().positionType() != PositionType::Absolute) {
|
||||||
child->setLayoutPosition(
|
child->setLayoutPosition(
|
||||||
node->getLayout().measuredDimension(dimension(crossAxis)) -
|
node->getLayout().measuredDimension(dimension(crossAxis)) -
|
||||||
child->getLayout().position[flexStartEdge(crossAxis)] -
|
child->getLayout().position(flexStartEdge(crossAxis)) -
|
||||||
child->getLayout().measuredDimension(dimension(crossAxis)),
|
child->getLayout().measuredDimension(dimension(crossAxis)),
|
||||||
flexStartEdge(crossAxis));
|
flexStartEdge(crossAxis));
|
||||||
}
|
}
|
||||||
|
@@ -12,6 +12,7 @@
|
|||||||
#include <yoga/debug/AssertFatal.h>
|
#include <yoga/debug/AssertFatal.h>
|
||||||
#include <yoga/enums/Dimension.h>
|
#include <yoga/enums/Dimension.h>
|
||||||
#include <yoga/enums/Direction.h>
|
#include <yoga/enums/Direction.h>
|
||||||
|
#include <yoga/enums/Edge.h>
|
||||||
#include <yoga/enums/FlexDirection.h>
|
#include <yoga/enums/FlexDirection.h>
|
||||||
|
|
||||||
namespace facebook::yoga {
|
namespace facebook::yoga {
|
||||||
@@ -48,80 +49,80 @@ inline FlexDirection resolveCrossDirection(
|
|||||||
: FlexDirection::Column;
|
: FlexDirection::Column;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline YGEdge flexStartEdge(const FlexDirection flexDirection) {
|
inline Edge flexStartEdge(const FlexDirection flexDirection) {
|
||||||
switch (flexDirection) {
|
switch (flexDirection) {
|
||||||
case FlexDirection::Column:
|
case FlexDirection::Column:
|
||||||
return YGEdgeTop;
|
return Edge::Top;
|
||||||
case FlexDirection::ColumnReverse:
|
case FlexDirection::ColumnReverse:
|
||||||
return YGEdgeBottom;
|
return Edge::Bottom;
|
||||||
case FlexDirection::Row:
|
case FlexDirection::Row:
|
||||||
return YGEdgeLeft;
|
return Edge::Left;
|
||||||
case FlexDirection::RowReverse:
|
case FlexDirection::RowReverse:
|
||||||
return YGEdgeRight;
|
return Edge::Right;
|
||||||
}
|
}
|
||||||
|
|
||||||
fatalWithMessage("Invalid FlexDirection");
|
fatalWithMessage("Invalid FlexDirection");
|
||||||
}
|
}
|
||||||
|
|
||||||
inline YGEdge flexEndEdge(const FlexDirection flexDirection) {
|
inline Edge flexEndEdge(const FlexDirection flexDirection) {
|
||||||
switch (flexDirection) {
|
switch (flexDirection) {
|
||||||
case FlexDirection::Column:
|
case FlexDirection::Column:
|
||||||
return YGEdgeBottom;
|
return Edge::Bottom;
|
||||||
case FlexDirection::ColumnReverse:
|
case FlexDirection::ColumnReverse:
|
||||||
return YGEdgeTop;
|
return Edge::Top;
|
||||||
case FlexDirection::Row:
|
case FlexDirection::Row:
|
||||||
return YGEdgeRight;
|
return Edge::Right;
|
||||||
case FlexDirection::RowReverse:
|
case FlexDirection::RowReverse:
|
||||||
return YGEdgeLeft;
|
return Edge::Left;
|
||||||
}
|
}
|
||||||
|
|
||||||
fatalWithMessage("Invalid FlexDirection");
|
fatalWithMessage("Invalid FlexDirection");
|
||||||
}
|
}
|
||||||
|
|
||||||
inline YGEdge inlineStartEdge(
|
inline Edge inlineStartEdge(
|
||||||
const FlexDirection flexDirection,
|
const FlexDirection flexDirection,
|
||||||
const Direction direction) {
|
const Direction direction) {
|
||||||
if (isRow(flexDirection)) {
|
if (isRow(flexDirection)) {
|
||||||
return direction == Direction::RTL ? YGEdgeRight : YGEdgeLeft;
|
return direction == Direction::RTL ? Edge::Right : Edge::Left;
|
||||||
}
|
}
|
||||||
|
|
||||||
return YGEdgeTop;
|
return Edge::Top;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline YGEdge inlineEndEdge(
|
inline Edge inlineEndEdge(
|
||||||
const FlexDirection flexDirection,
|
const FlexDirection flexDirection,
|
||||||
const Direction direction) {
|
const Direction direction) {
|
||||||
if (isRow(flexDirection)) {
|
if (isRow(flexDirection)) {
|
||||||
return direction == Direction::RTL ? YGEdgeLeft : YGEdgeRight;
|
return direction == Direction::RTL ? Edge::Left : Edge::Right;
|
||||||
}
|
}
|
||||||
|
|
||||||
return YGEdgeBottom;
|
return Edge::Bottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The physical edges that YGEdgeStart and YGEdgeEnd correspond to (e.g.
|
* The physical edges that Edge::Start and Edge::End correspond to (e.g.
|
||||||
* left/right) are soley dependent on the direction. However, there are cases
|
* left/right) are soley dependent on the direction. However, there are cases
|
||||||
* where we want the flex start/end edge (i.e. which edge is the start/end
|
* where we want the flex start/end edge (i.e. which edge is the start/end
|
||||||
* for laying out flex items), which can be distinct from the corresponding
|
* for laying out flex items), which can be distinct from the corresponding
|
||||||
* inline edge. In these cases we need to know which "relative edge"
|
* inline edge. In these cases we need to know which "relative edge"
|
||||||
* (YGEdgeStart/YGEdgeEnd) corresponds to the said flex start/end edge as these
|
* (Edge::Start/Edge::End) corresponds to the said flex start/end edge as these
|
||||||
* relative edges can be used instead of physical ones when defining certain
|
* relative edges can be used instead of physical ones when defining certain
|
||||||
* attributes like border or padding.
|
* attributes like border or padding.
|
||||||
*/
|
*/
|
||||||
inline YGEdge flexStartRelativeEdge(
|
inline Edge flexStartRelativeEdge(
|
||||||
FlexDirection flexDirection,
|
FlexDirection flexDirection,
|
||||||
Direction direction) {
|
Direction direction) {
|
||||||
const YGEdge leadLayoutEdge = inlineStartEdge(flexDirection, direction);
|
const Edge leadLayoutEdge = inlineStartEdge(flexDirection, direction);
|
||||||
const YGEdge leadFlexItemEdge = flexStartEdge(flexDirection);
|
const Edge leadFlexItemEdge = flexStartEdge(flexDirection);
|
||||||
return leadLayoutEdge == leadFlexItemEdge ? YGEdgeStart : YGEdgeEnd;
|
return leadLayoutEdge == leadFlexItemEdge ? Edge::Start : Edge::End;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline YGEdge flexEndRelativeEdge(
|
inline Edge flexEndRelativeEdge(
|
||||||
FlexDirection flexDirection,
|
FlexDirection flexDirection,
|
||||||
Direction direction) {
|
Direction direction) {
|
||||||
const YGEdge trailLayoutEdge = inlineEndEdge(flexDirection, direction);
|
const Edge trailLayoutEdge = inlineEndEdge(flexDirection, direction);
|
||||||
const YGEdge trailFlexItemEdge = flexEndEdge(flexDirection);
|
const Edge trailFlexItemEdge = flexEndEdge(flexDirection);
|
||||||
return trailLayoutEdge == trailFlexItemEdge ? YGEdgeEnd : YGEdgeStart;
|
return trailLayoutEdge == trailFlexItemEdge ? Edge::End : Edge::Start;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Dimension dimension(const FlexDirection flexDirection) {
|
inline Dimension dimension(const FlexDirection flexDirection) {
|
||||||
|
@@ -68,8 +68,8 @@ void roundLayoutResultsToPixelGrid(
|
|||||||
const double absoluteTop) {
|
const double absoluteTop) {
|
||||||
const auto pointScaleFactor = node->getConfig()->getPointScaleFactor();
|
const auto pointScaleFactor = node->getConfig()->getPointScaleFactor();
|
||||||
|
|
||||||
const double nodeLeft = node->getLayout().position[YGEdgeLeft];
|
const double nodeLeft = node->getLayout().position(Edge::Left);
|
||||||
const double nodeTop = node->getLayout().position[YGEdgeTop];
|
const double nodeTop = node->getLayout().position(Edge::Top);
|
||||||
|
|
||||||
const double nodeWidth = node->getLayout().dimension(Dimension::Width);
|
const double nodeWidth = node->getLayout().dimension(Dimension::Width);
|
||||||
const double nodeHeight = node->getLayout().dimension(Dimension::Height);
|
const double nodeHeight = node->getLayout().dimension(Dimension::Height);
|
||||||
@@ -87,11 +87,11 @@ void roundLayoutResultsToPixelGrid(
|
|||||||
|
|
||||||
node->setLayoutPosition(
|
node->setLayoutPosition(
|
||||||
roundValueToPixelGrid(nodeLeft, pointScaleFactor, false, textRounding),
|
roundValueToPixelGrid(nodeLeft, pointScaleFactor, false, textRounding),
|
||||||
YGEdgeLeft);
|
Edge::Left);
|
||||||
|
|
||||||
node->setLayoutPosition(
|
node->setLayoutPosition(
|
||||||
roundValueToPixelGrid(nodeTop, pointScaleFactor, false, textRounding),
|
roundValueToPixelGrid(nodeTop, pointScaleFactor, false, textRounding),
|
||||||
YGEdgeTop);
|
Edge::Top);
|
||||||
|
|
||||||
// We multiply dimension by scale factor and if the result is close to the
|
// We multiply dimension by scale factor and if the result is close to the
|
||||||
// whole number, we don't have any fraction To verify if the result is close
|
// whole number, we don't have any fraction To verify if the result is close
|
||||||
|
@@ -9,8 +9,6 @@
|
|||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
#include <yoga/YGEnums.h>
|
|
||||||
|
|
||||||
#include <yoga/debug/Log.h>
|
#include <yoga/debug/Log.h>
|
||||||
#include <yoga/debug/NodeToString.h>
|
#include <yoga/debug/NodeToString.h>
|
||||||
#include <yoga/numeric/Comparison.h>
|
#include <yoga/numeric/Comparison.h>
|
||||||
@@ -85,7 +83,7 @@ static void
|
|||||||
appendEdges(std::string& base, const std::string& key, const Style& style) {
|
appendEdges(std::string& base, const std::string& key, const Style& style) {
|
||||||
for (auto edge : ordinals<Edge>()) {
|
for (auto edge : ordinals<Edge>()) {
|
||||||
std::string str = key + "-" + toString(edge);
|
std::string str = key + "-" + toString(edge);
|
||||||
appendNumberIfNotZero(base, str, (style.*Field)(unscopedEnum(edge)));
|
appendNumberIfNotZero(base, str, (style.*Field)(edge));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,9 +102,9 @@ void nodeToString(
|
|||||||
appendFormattedString(
|
appendFormattedString(
|
||||||
str, "height: %g; ", node->getLayout().dimension(Dimension::Height));
|
str, "height: %g; ", node->getLayout().dimension(Dimension::Height));
|
||||||
appendFormattedString(
|
appendFormattedString(
|
||||||
str, "top: %g; ", node->getLayout().position[YGEdgeTop]);
|
str, "top: %g; ", node->getLayout().position(Edge::Top));
|
||||||
appendFormattedString(
|
appendFormattedString(
|
||||||
str, "left: %g;", node->getLayout().position[YGEdgeLeft]);
|
str, "left: %g;", node->getLayout().position(Edge::Left));
|
||||||
appendFormattedString(str, "\" ");
|
appendFormattedString(str, "\" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -13,11 +13,11 @@
|
|||||||
namespace facebook::yoga {
|
namespace facebook::yoga {
|
||||||
|
|
||||||
bool LayoutResults::operator==(LayoutResults layout) const {
|
bool LayoutResults::operator==(LayoutResults layout) const {
|
||||||
bool isEqual = yoga::inexactEquals(position, layout.position) &&
|
bool isEqual = yoga::inexactEquals(position_, layout.position_) &&
|
||||||
yoga::inexactEquals(dimensions_, layout.dimensions_) &&
|
yoga::inexactEquals(dimensions_, layout.dimensions_) &&
|
||||||
yoga::inexactEquals(margin, layout.margin) &&
|
yoga::inexactEquals(margin_, layout.margin_) &&
|
||||||
yoga::inexactEquals(border, layout.border) &&
|
yoga::inexactEquals(border_, layout.border_) &&
|
||||||
yoga::inexactEquals(padding, layout.padding) &&
|
yoga::inexactEquals(padding_, layout.padding_) &&
|
||||||
direction() == layout.direction() &&
|
direction() == layout.direction() &&
|
||||||
hadOverflow() == layout.hadOverflow() &&
|
hadOverflow() == layout.hadOverflow() &&
|
||||||
lastOwnerDirection == layout.lastOwnerDirection &&
|
lastOwnerDirection == layout.lastOwnerDirection &&
|
||||||
|
@@ -10,8 +10,10 @@
|
|||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
#include <yoga/bits/NumericBitfield.h>
|
#include <yoga/bits/NumericBitfield.h>
|
||||||
|
#include <yoga/debug/AssertFatal.h>
|
||||||
#include <yoga/enums/Dimension.h>
|
#include <yoga/enums/Dimension.h>
|
||||||
#include <yoga/enums/Direction.h>
|
#include <yoga/enums/Direction.h>
|
||||||
|
#include <yoga/enums/Edge.h>
|
||||||
#include <yoga/node/CachedMeasurement.h>
|
#include <yoga/node/CachedMeasurement.h>
|
||||||
#include <yoga/numeric/FloatOptional.h>
|
#include <yoga/numeric/FloatOptional.h>
|
||||||
|
|
||||||
@@ -22,19 +24,6 @@ struct LayoutResults {
|
|||||||
// 98% of analyzed layouts require less than 8 entries.
|
// 98% of analyzed layouts require less than 8 entries.
|
||||||
static constexpr int32_t MaxCachedMeasurements = 8;
|
static constexpr int32_t MaxCachedMeasurements = 8;
|
||||||
|
|
||||||
std::array<float, 4> position = {};
|
|
||||||
std::array<float, 4> margin = {};
|
|
||||||
std::array<float, 4> border = {};
|
|
||||||
std::array<float, 4> padding = {};
|
|
||||||
|
|
||||||
private:
|
|
||||||
Direction direction_ : bitCount<Direction>() = Direction::Inherit;
|
|
||||||
bool hadOverflow_ : 1 = false;
|
|
||||||
|
|
||||||
std::array<float, 2> dimensions_ = {{YGUndefined, YGUndefined}};
|
|
||||||
std::array<float, 2> measuredDimensions_ = {{YGUndefined, YGUndefined}};
|
|
||||||
|
|
||||||
public:
|
|
||||||
uint32_t computedFlexBasisGeneration = 0;
|
uint32_t computedFlexBasisGeneration = 0;
|
||||||
FloatOptional computedFlexBasis = {};
|
FloatOptional computedFlexBasis = {};
|
||||||
|
|
||||||
@@ -80,10 +69,66 @@ struct LayoutResults {
|
|||||||
measuredDimensions_[yoga::to_underlying(axis)] = dimension;
|
measuredDimensions_[yoga::to_underlying(axis)] = dimension;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float position(Edge cardinalEdge) const {
|
||||||
|
assertCardinalEdge(cardinalEdge);
|
||||||
|
return position_[yoga::to_underlying(cardinalEdge)];
|
||||||
|
}
|
||||||
|
|
||||||
|
void setPosition(Edge cardinalEdge, float dimension) {
|
||||||
|
assertCardinalEdge(cardinalEdge);
|
||||||
|
position_[yoga::to_underlying(cardinalEdge)] = dimension;
|
||||||
|
}
|
||||||
|
|
||||||
|
float margin(Edge cardinalEdge) const {
|
||||||
|
assertCardinalEdge(cardinalEdge);
|
||||||
|
return margin_[yoga::to_underlying(cardinalEdge)];
|
||||||
|
}
|
||||||
|
|
||||||
|
void setMargin(Edge cardinalEdge, float dimension) {
|
||||||
|
assertCardinalEdge(cardinalEdge);
|
||||||
|
margin_[yoga::to_underlying(cardinalEdge)] = dimension;
|
||||||
|
}
|
||||||
|
|
||||||
|
float border(Edge cardinalEdge) const {
|
||||||
|
assertCardinalEdge(cardinalEdge);
|
||||||
|
return border_[yoga::to_underlying(cardinalEdge)];
|
||||||
|
}
|
||||||
|
|
||||||
|
void setBorder(Edge cardinalEdge, float dimension) {
|
||||||
|
assertCardinalEdge(cardinalEdge);
|
||||||
|
border_[yoga::to_underlying(cardinalEdge)] = dimension;
|
||||||
|
}
|
||||||
|
|
||||||
|
float padding(Edge cardinalEdge) const {
|
||||||
|
assertCardinalEdge(cardinalEdge);
|
||||||
|
return padding_[yoga::to_underlying(cardinalEdge)];
|
||||||
|
}
|
||||||
|
|
||||||
|
void setPadding(Edge cardinalEdge, float dimension) {
|
||||||
|
assertCardinalEdge(cardinalEdge);
|
||||||
|
padding_[yoga::to_underlying(cardinalEdge)] = dimension;
|
||||||
|
}
|
||||||
|
|
||||||
bool operator==(LayoutResults layout) const;
|
bool operator==(LayoutResults layout) const;
|
||||||
bool operator!=(LayoutResults layout) const {
|
bool operator!=(LayoutResults layout) const {
|
||||||
return !(*this == layout);
|
return !(*this == layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
static inline void assertCardinalEdge(Edge edge) {
|
||||||
|
assertFatal(
|
||||||
|
static_cast<int>(edge) <= 3, "Edge must be top/left/bottom/right");
|
||||||
|
}
|
||||||
|
|
||||||
|
Direction direction_ : bitCount<Direction>() = Direction::Inherit;
|
||||||
|
bool hadOverflow_ : 1 = false;
|
||||||
|
|
||||||
|
std::array<float, 2> dimensions_ = {{YGUndefined, YGUndefined}};
|
||||||
|
std::array<float, 2> measuredDimensions_ = {{YGUndefined, YGUndefined}};
|
||||||
|
std::array<float, 4> position_ = {};
|
||||||
|
std::array<float, 4> margin_ = {};
|
||||||
|
std::array<float, 4> border_ = {};
|
||||||
|
std::array<float, 4> padding_ = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace facebook::yoga
|
} // namespace facebook::yoga
|
||||||
|
@@ -58,31 +58,31 @@ void Node::print() {
|
|||||||
|
|
||||||
// TODO: Edge value resolution should be moved to `yoga::Style`
|
// TODO: Edge value resolution should be moved to `yoga::Style`
|
||||||
template <auto Field>
|
template <auto Field>
|
||||||
Style::Length Node::computeEdgeValueForRow(YGEdge rowEdge, YGEdge edge) const {
|
Style::Length Node::computeEdgeValueForRow(Edge rowEdge, Edge edge) const {
|
||||||
if ((style_.*Field)(rowEdge).isDefined()) {
|
if ((style_.*Field)(rowEdge).isDefined()) {
|
||||||
return (style_.*Field)(rowEdge);
|
return (style_.*Field)(rowEdge);
|
||||||
} else if ((style_.*Field)(edge).isDefined()) {
|
} else if ((style_.*Field)(edge).isDefined()) {
|
||||||
return (style_.*Field)(edge);
|
return (style_.*Field)(edge);
|
||||||
} else if ((style_.*Field)(YGEdgeHorizontal).isDefined()) {
|
} else if ((style_.*Field)(Edge::Horizontal).isDefined()) {
|
||||||
return (style_.*Field)(YGEdgeHorizontal);
|
return (style_.*Field)(Edge::Horizontal);
|
||||||
} else {
|
} else {
|
||||||
return (style_.*Field)(YGEdgeAll);
|
return (style_.*Field)(Edge::All);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Edge value resolution should be moved to `yoga::Style`
|
// TODO: Edge value resolution should be moved to `yoga::Style`
|
||||||
template <auto Field>
|
template <auto Field>
|
||||||
Style::Length Node::computeEdgeValueForColumn(YGEdge edge) const {
|
Style::Length Node::computeEdgeValueForColumn(Edge edge) const {
|
||||||
if ((style_.*Field)(edge).isDefined()) {
|
if ((style_.*Field)(edge).isDefined()) {
|
||||||
return (style_.*Field)(edge);
|
return (style_.*Field)(edge);
|
||||||
} else if ((style_.*Field)(YGEdgeVertical).isDefined()) {
|
} else if ((style_.*Field)(Edge::Vertical).isDefined()) {
|
||||||
return (style_.*Field)(YGEdgeVertical);
|
return (style_.*Field)(Edge::Vertical);
|
||||||
} else {
|
} else {
|
||||||
return (style_.*Field)(YGEdgeAll);
|
return (style_.*Field)(Edge::All);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
YGEdge Node::getInlineStartEdgeUsingErrata(
|
Edge Node::getInlineStartEdgeUsingErrata(
|
||||||
FlexDirection flexDirection,
|
FlexDirection flexDirection,
|
||||||
Direction direction) const {
|
Direction direction) const {
|
||||||
return hasErrata(Errata::StartingEndingEdgeFromFlexDirection)
|
return hasErrata(Errata::StartingEndingEdgeFromFlexDirection)
|
||||||
@@ -90,7 +90,7 @@ YGEdge Node::getInlineStartEdgeUsingErrata(
|
|||||||
: inlineStartEdge(flexDirection, direction);
|
: inlineStartEdge(flexDirection, direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
YGEdge Node::getInlineEndEdgeUsingErrata(
|
Edge Node::getInlineEndEdgeUsingErrata(
|
||||||
FlexDirection flexDirection,
|
FlexDirection flexDirection,
|
||||||
Direction direction) const {
|
Direction direction) const {
|
||||||
return hasErrata(Errata::StartingEndingEdgeFromFlexDirection)
|
return hasErrata(Errata::StartingEndingEdgeFromFlexDirection)
|
||||||
@@ -99,9 +99,9 @@ YGEdge Node::getInlineEndEdgeUsingErrata(
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Node::isFlexStartPositionDefined(FlexDirection axis) const {
|
bool Node::isFlexStartPositionDefined(FlexDirection axis) const {
|
||||||
const YGEdge startEdge = flexStartEdge(axis);
|
const Edge startEdge = flexStartEdge(axis);
|
||||||
auto leadingPosition = isRow(axis)
|
auto leadingPosition = isRow(axis)
|
||||||
? computeEdgeValueForRow<&Style::position>(YGEdgeStart, startEdge)
|
? computeEdgeValueForRow<&Style::position>(Edge::Start, startEdge)
|
||||||
: computeEdgeValueForColumn<&Style::position>(startEdge);
|
: computeEdgeValueForColumn<&Style::position>(startEdge);
|
||||||
|
|
||||||
return leadingPosition.isDefined();
|
return leadingPosition.isDefined();
|
||||||
@@ -109,18 +109,18 @@ bool Node::isFlexStartPositionDefined(FlexDirection axis) const {
|
|||||||
|
|
||||||
bool Node::isInlineStartPositionDefined(FlexDirection axis, Direction direction)
|
bool Node::isInlineStartPositionDefined(FlexDirection axis, Direction direction)
|
||||||
const {
|
const {
|
||||||
const YGEdge startEdge = getInlineStartEdgeUsingErrata(axis, direction);
|
const Edge startEdge = getInlineStartEdgeUsingErrata(axis, direction);
|
||||||
auto leadingPosition = isRow(axis)
|
auto leadingPosition = isRow(axis)
|
||||||
? computeEdgeValueForRow<&Style::position>(YGEdgeStart, startEdge)
|
? computeEdgeValueForRow<&Style::position>(Edge::Start, startEdge)
|
||||||
: computeEdgeValueForColumn<&Style::position>(startEdge);
|
: computeEdgeValueForColumn<&Style::position>(startEdge);
|
||||||
|
|
||||||
return leadingPosition.isDefined();
|
return leadingPosition.isDefined();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Node::isFlexEndPositionDefined(FlexDirection axis) const {
|
bool Node::isFlexEndPositionDefined(FlexDirection axis) const {
|
||||||
const YGEdge endEdge = flexEndEdge(axis);
|
const Edge endEdge = flexEndEdge(axis);
|
||||||
auto trailingPosition = isRow(axis)
|
auto trailingPosition = isRow(axis)
|
||||||
? computeEdgeValueForRow<&Style::position>(YGEdgeEnd, endEdge)
|
? computeEdgeValueForRow<&Style::position>(Edge::End, endEdge)
|
||||||
: computeEdgeValueForColumn<&Style::position>(endEdge);
|
: computeEdgeValueForColumn<&Style::position>(endEdge);
|
||||||
|
|
||||||
return !trailingPosition.isUndefined();
|
return !trailingPosition.isUndefined();
|
||||||
@@ -128,18 +128,18 @@ bool Node::isFlexEndPositionDefined(FlexDirection axis) const {
|
|||||||
|
|
||||||
bool Node::isInlineEndPositionDefined(FlexDirection axis, Direction direction)
|
bool Node::isInlineEndPositionDefined(FlexDirection axis, Direction direction)
|
||||||
const {
|
const {
|
||||||
const YGEdge endEdge = getInlineEndEdgeUsingErrata(axis, direction);
|
const Edge endEdge = getInlineEndEdgeUsingErrata(axis, direction);
|
||||||
auto trailingPosition = isRow(axis)
|
auto trailingPosition = isRow(axis)
|
||||||
? computeEdgeValueForRow<&Style::position>(YGEdgeEnd, endEdge)
|
? computeEdgeValueForRow<&Style::position>(Edge::End, endEdge)
|
||||||
: computeEdgeValueForColumn<&Style::position>(endEdge);
|
: computeEdgeValueForColumn<&Style::position>(endEdge);
|
||||||
|
|
||||||
return trailingPosition.isDefined();
|
return trailingPosition.isDefined();
|
||||||
}
|
}
|
||||||
|
|
||||||
float Node::getFlexStartPosition(FlexDirection axis, float axisSize) const {
|
float Node::getFlexStartPosition(FlexDirection axis, float axisSize) const {
|
||||||
const YGEdge startEdge = flexStartEdge(axis);
|
const Edge startEdge = flexStartEdge(axis);
|
||||||
auto leadingPosition = isRow(axis)
|
auto leadingPosition = isRow(axis)
|
||||||
? computeEdgeValueForRow<&Style::position>(YGEdgeStart, startEdge)
|
? computeEdgeValueForRow<&Style::position>(Edge::Start, startEdge)
|
||||||
: computeEdgeValueForColumn<&Style::position>(startEdge);
|
: computeEdgeValueForColumn<&Style::position>(startEdge);
|
||||||
|
|
||||||
return resolveValue(leadingPosition, axisSize).unwrapOrDefault(0.0f);
|
return resolveValue(leadingPosition, axisSize).unwrapOrDefault(0.0f);
|
||||||
@@ -149,18 +149,18 @@ float Node::getInlineStartPosition(
|
|||||||
FlexDirection axis,
|
FlexDirection axis,
|
||||||
Direction direction,
|
Direction direction,
|
||||||
float axisSize) const {
|
float axisSize) const {
|
||||||
const YGEdge startEdge = getInlineStartEdgeUsingErrata(axis, direction);
|
const Edge startEdge = getInlineStartEdgeUsingErrata(axis, direction);
|
||||||
auto leadingPosition = isRow(axis)
|
auto leadingPosition = isRow(axis)
|
||||||
? computeEdgeValueForRow<&Style::position>(YGEdgeStart, startEdge)
|
? computeEdgeValueForRow<&Style::position>(Edge::Start, startEdge)
|
||||||
: computeEdgeValueForColumn<&Style::position>(startEdge);
|
: computeEdgeValueForColumn<&Style::position>(startEdge);
|
||||||
|
|
||||||
return resolveValue(leadingPosition, axisSize).unwrapOrDefault(0.0f);
|
return resolveValue(leadingPosition, axisSize).unwrapOrDefault(0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
float Node::getFlexEndPosition(FlexDirection axis, float axisSize) const {
|
float Node::getFlexEndPosition(FlexDirection axis, float axisSize) const {
|
||||||
const YGEdge endEdge = flexEndEdge(axis);
|
const Edge endEdge = flexEndEdge(axis);
|
||||||
auto trailingPosition = isRow(axis)
|
auto trailingPosition = isRow(axis)
|
||||||
? computeEdgeValueForRow<&Style::position>(YGEdgeEnd, endEdge)
|
? computeEdgeValueForRow<&Style::position>(Edge::End, endEdge)
|
||||||
: computeEdgeValueForColumn<&Style::position>(endEdge);
|
: computeEdgeValueForColumn<&Style::position>(endEdge);
|
||||||
|
|
||||||
return resolveValue(trailingPosition, axisSize).unwrapOrDefault(0.0f);
|
return resolveValue(trailingPosition, axisSize).unwrapOrDefault(0.0f);
|
||||||
@@ -170,18 +170,18 @@ float Node::getInlineEndPosition(
|
|||||||
FlexDirection axis,
|
FlexDirection axis,
|
||||||
Direction direction,
|
Direction direction,
|
||||||
float axisSize) const {
|
float axisSize) const {
|
||||||
const YGEdge endEdge = getInlineEndEdgeUsingErrata(axis, direction);
|
const Edge endEdge = getInlineEndEdgeUsingErrata(axis, direction);
|
||||||
auto trailingPosition = isRow(axis)
|
auto trailingPosition = isRow(axis)
|
||||||
? computeEdgeValueForRow<&Style::position>(YGEdgeEnd, endEdge)
|
? computeEdgeValueForRow<&Style::position>(Edge::End, endEdge)
|
||||||
: computeEdgeValueForColumn<&Style::position>(endEdge);
|
: computeEdgeValueForColumn<&Style::position>(endEdge);
|
||||||
|
|
||||||
return resolveValue(trailingPosition, axisSize).unwrapOrDefault(0.0f);
|
return resolveValue(trailingPosition, axisSize).unwrapOrDefault(0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
float Node::getFlexStartMargin(FlexDirection axis, float widthSize) const {
|
float Node::getFlexStartMargin(FlexDirection axis, float widthSize) const {
|
||||||
const YGEdge startEdge = flexStartEdge(axis);
|
const Edge startEdge = flexStartEdge(axis);
|
||||||
auto leadingMargin = isRow(axis)
|
auto leadingMargin = isRow(axis)
|
||||||
? computeEdgeValueForRow<&Style::margin>(YGEdgeStart, startEdge)
|
? computeEdgeValueForRow<&Style::margin>(Edge::Start, startEdge)
|
||||||
: computeEdgeValueForColumn<&Style::margin>(startEdge);
|
: computeEdgeValueForColumn<&Style::margin>(startEdge);
|
||||||
|
|
||||||
return resolveValue(leadingMargin, widthSize).unwrapOrDefault(0.0f);
|
return resolveValue(leadingMargin, widthSize).unwrapOrDefault(0.0f);
|
||||||
@@ -191,18 +191,18 @@ float Node::getInlineStartMargin(
|
|||||||
FlexDirection axis,
|
FlexDirection axis,
|
||||||
Direction direction,
|
Direction direction,
|
||||||
float widthSize) const {
|
float widthSize) const {
|
||||||
const YGEdge startEdge = getInlineStartEdgeUsingErrata(axis, direction);
|
const Edge startEdge = getInlineStartEdgeUsingErrata(axis, direction);
|
||||||
auto leadingMargin = isRow(axis)
|
auto leadingMargin = isRow(axis)
|
||||||
? computeEdgeValueForRow<&Style::margin>(YGEdgeStart, startEdge)
|
? computeEdgeValueForRow<&Style::margin>(Edge::Start, startEdge)
|
||||||
: computeEdgeValueForColumn<&Style::margin>(startEdge);
|
: computeEdgeValueForColumn<&Style::margin>(startEdge);
|
||||||
|
|
||||||
return resolveValue(leadingMargin, widthSize).unwrapOrDefault(0.0f);
|
return resolveValue(leadingMargin, widthSize).unwrapOrDefault(0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
float Node::getFlexEndMargin(FlexDirection axis, float widthSize) const {
|
float Node::getFlexEndMargin(FlexDirection axis, float widthSize) const {
|
||||||
const YGEdge endEdge = flexEndEdge(axis);
|
const Edge endEdge = flexEndEdge(axis);
|
||||||
auto trailingMargin = isRow(axis)
|
auto trailingMargin = isRow(axis)
|
||||||
? computeEdgeValueForRow<&Style::margin>(YGEdgeEnd, endEdge)
|
? computeEdgeValueForRow<&Style::margin>(Edge::End, endEdge)
|
||||||
: computeEdgeValueForColumn<&Style::margin>(endEdge);
|
: computeEdgeValueForColumn<&Style::margin>(endEdge);
|
||||||
|
|
||||||
return resolveValue(trailingMargin, widthSize).unwrapOrDefault(0.0f);
|
return resolveValue(trailingMargin, widthSize).unwrapOrDefault(0.0f);
|
||||||
@@ -212,9 +212,9 @@ float Node::getInlineEndMargin(
|
|||||||
FlexDirection axis,
|
FlexDirection axis,
|
||||||
Direction direction,
|
Direction direction,
|
||||||
float widthSize) const {
|
float widthSize) const {
|
||||||
const YGEdge endEdge = getInlineEndEdgeUsingErrata(axis, direction);
|
const Edge endEdge = getInlineEndEdgeUsingErrata(axis, direction);
|
||||||
auto trailingMargin = isRow(axis)
|
auto trailingMargin = isRow(axis)
|
||||||
? computeEdgeValueForRow<&Style::margin>(YGEdgeEnd, endEdge)
|
? computeEdgeValueForRow<&Style::margin>(Edge::End, endEdge)
|
||||||
: computeEdgeValueForColumn<&Style::margin>(endEdge);
|
: computeEdgeValueForColumn<&Style::margin>(endEdge);
|
||||||
|
|
||||||
return resolveValue(trailingMargin, widthSize).unwrapOrDefault(0.0f);
|
return resolveValue(trailingMargin, widthSize).unwrapOrDefault(0.0f);
|
||||||
@@ -222,17 +222,16 @@ float Node::getInlineEndMargin(
|
|||||||
|
|
||||||
float Node::getInlineStartBorder(FlexDirection axis, Direction direction)
|
float Node::getInlineStartBorder(FlexDirection axis, Direction direction)
|
||||||
const {
|
const {
|
||||||
const YGEdge startEdge = getInlineStartEdgeUsingErrata(axis, direction);
|
const Edge startEdge = getInlineStartEdgeUsingErrata(axis, direction);
|
||||||
YGValue leadingBorder = isRow(axis)
|
YGValue leadingBorder = isRow(axis)
|
||||||
? computeEdgeValueForRow<&Style::border>(YGEdgeStart, startEdge)
|
? computeEdgeValueForRow<&Style::border>(Edge::Start, startEdge)
|
||||||
: computeEdgeValueForColumn<&Style::border>(startEdge);
|
: computeEdgeValueForColumn<&Style::border>(startEdge);
|
||||||
|
|
||||||
return maxOrDefined(leadingBorder.value, 0.0f);
|
return maxOrDefined(leadingBorder.value, 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
float Node::getFlexStartBorder(FlexDirection axis, Direction direction) const {
|
float Node::getFlexStartBorder(FlexDirection axis, Direction direction) const {
|
||||||
const YGEdge leadRelativeFlexItemEdge =
|
const Edge leadRelativeFlexItemEdge = flexStartRelativeEdge(axis, direction);
|
||||||
flexStartRelativeEdge(axis, direction);
|
|
||||||
YGValue leadingBorder = isRow(axis)
|
YGValue leadingBorder = isRow(axis)
|
||||||
? computeEdgeValueForRow<&Style::border>(
|
? computeEdgeValueForRow<&Style::border>(
|
||||||
leadRelativeFlexItemEdge, flexStartEdge(axis))
|
leadRelativeFlexItemEdge, flexStartEdge(axis))
|
||||||
@@ -242,16 +241,16 @@ float Node::getFlexStartBorder(FlexDirection axis, Direction direction) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
float Node::getInlineEndBorder(FlexDirection axis, Direction direction) const {
|
float Node::getInlineEndBorder(FlexDirection axis, Direction direction) const {
|
||||||
const YGEdge endEdge = getInlineEndEdgeUsingErrata(axis, direction);
|
const Edge endEdge = getInlineEndEdgeUsingErrata(axis, direction);
|
||||||
YGValue trailingBorder = isRow(axis)
|
YGValue trailingBorder = isRow(axis)
|
||||||
? computeEdgeValueForRow<&Style::border>(YGEdgeEnd, endEdge)
|
? computeEdgeValueForRow<&Style::border>(Edge::End, endEdge)
|
||||||
: computeEdgeValueForColumn<&Style::border>(endEdge);
|
: computeEdgeValueForColumn<&Style::border>(endEdge);
|
||||||
|
|
||||||
return maxOrDefined(trailingBorder.value, 0.0f);
|
return maxOrDefined(trailingBorder.value, 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
float Node::getFlexEndBorder(FlexDirection axis, Direction direction) const {
|
float Node::getFlexEndBorder(FlexDirection axis, Direction direction) const {
|
||||||
const YGEdge trailRelativeFlexItemEdge = flexEndRelativeEdge(axis, direction);
|
const Edge trailRelativeFlexItemEdge = flexEndRelativeEdge(axis, direction);
|
||||||
YGValue trailingBorder = isRow(axis)
|
YGValue trailingBorder = isRow(axis)
|
||||||
? computeEdgeValueForRow<&Style::border>(
|
? computeEdgeValueForRow<&Style::border>(
|
||||||
trailRelativeFlexItemEdge, flexEndEdge(axis))
|
trailRelativeFlexItemEdge, flexEndEdge(axis))
|
||||||
@@ -264,9 +263,9 @@ float Node::getInlineStartPadding(
|
|||||||
FlexDirection axis,
|
FlexDirection axis,
|
||||||
Direction direction,
|
Direction direction,
|
||||||
float widthSize) const {
|
float widthSize) const {
|
||||||
const YGEdge startEdge = getInlineStartEdgeUsingErrata(axis, direction);
|
const Edge startEdge = getInlineStartEdgeUsingErrata(axis, direction);
|
||||||
auto leadingPadding = isRow(axis)
|
auto leadingPadding = isRow(axis)
|
||||||
? computeEdgeValueForRow<&Style::padding>(YGEdgeStart, startEdge)
|
? computeEdgeValueForRow<&Style::padding>(Edge::Start, startEdge)
|
||||||
: computeEdgeValueForColumn<&Style::padding>(startEdge);
|
: computeEdgeValueForColumn<&Style::padding>(startEdge);
|
||||||
|
|
||||||
return maxOrDefined(resolveValue(leadingPadding, widthSize).unwrap(), 0.0f);
|
return maxOrDefined(resolveValue(leadingPadding, widthSize).unwrap(), 0.0f);
|
||||||
@@ -276,8 +275,7 @@ float Node::getFlexStartPadding(
|
|||||||
FlexDirection axis,
|
FlexDirection axis,
|
||||||
Direction direction,
|
Direction direction,
|
||||||
float widthSize) const {
|
float widthSize) const {
|
||||||
const YGEdge leadRelativeFlexItemEdge =
|
const Edge leadRelativeFlexItemEdge = flexStartRelativeEdge(axis, direction);
|
||||||
flexStartRelativeEdge(axis, direction);
|
|
||||||
auto leadingPadding = isRow(axis)
|
auto leadingPadding = isRow(axis)
|
||||||
? computeEdgeValueForRow<&Style::padding>(
|
? computeEdgeValueForRow<&Style::padding>(
|
||||||
leadRelativeFlexItemEdge, flexStartEdge(axis))
|
leadRelativeFlexItemEdge, flexStartEdge(axis))
|
||||||
@@ -290,9 +288,9 @@ float Node::getInlineEndPadding(
|
|||||||
FlexDirection axis,
|
FlexDirection axis,
|
||||||
Direction direction,
|
Direction direction,
|
||||||
float widthSize) const {
|
float widthSize) const {
|
||||||
const YGEdge endEdge = getInlineEndEdgeUsingErrata(axis, direction);
|
const Edge endEdge = getInlineEndEdgeUsingErrata(axis, direction);
|
||||||
auto trailingPadding = isRow(axis)
|
auto trailingPadding = isRow(axis)
|
||||||
? computeEdgeValueForRow<&Style::padding>(YGEdgeEnd, endEdge)
|
? computeEdgeValueForRow<&Style::padding>(Edge::End, endEdge)
|
||||||
: computeEdgeValueForColumn<&Style::padding>(endEdge);
|
: computeEdgeValueForColumn<&Style::padding>(endEdge);
|
||||||
|
|
||||||
return maxOrDefined(resolveValue(trailingPadding, widthSize).unwrap(), 0.0f);
|
return maxOrDefined(resolveValue(trailingPadding, widthSize).unwrap(), 0.0f);
|
||||||
@@ -302,7 +300,7 @@ float Node::getFlexEndPadding(
|
|||||||
FlexDirection axis,
|
FlexDirection axis,
|
||||||
Direction direction,
|
Direction direction,
|
||||||
float widthSize) const {
|
float widthSize) const {
|
||||||
const YGEdge trailRelativeFlexItemEdge = flexEndRelativeEdge(axis, direction);
|
const Edge trailRelativeFlexItemEdge = flexEndRelativeEdge(axis, direction);
|
||||||
auto trailingPadding = isRow(axis)
|
auto trailingPadding = isRow(axis)
|
||||||
? computeEdgeValueForRow<&Style::padding>(
|
? computeEdgeValueForRow<&Style::padding>(
|
||||||
trailRelativeFlexItemEdge, flexEndEdge(axis))
|
trailRelativeFlexItemEdge, flexEndEdge(axis))
|
||||||
@@ -446,25 +444,16 @@ void Node::setLayoutDirection(Direction direction) {
|
|||||||
layout_.setDirection(direction);
|
layout_.setDirection(direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Node::setLayoutMargin(float margin, YGEdge edge) {
|
void Node::setLayoutMargin(float margin, Edge edge) {
|
||||||
assertFatal(
|
layout_.setMargin(edge, margin);
|
||||||
edge < static_cast<int>(layout_.margin.size()),
|
|
||||||
"Edge must be top/left/bottom/right");
|
|
||||||
layout_.margin[edge] = margin;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Node::setLayoutBorder(float border, YGEdge edge) {
|
void Node::setLayoutBorder(float border, Edge edge) {
|
||||||
assertFatal(
|
layout_.setBorder(edge, border);
|
||||||
edge < static_cast<int>(layout_.border.size()),
|
|
||||||
"Edge must be top/left/bottom/right");
|
|
||||||
layout_.border[edge] = border;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Node::setLayoutPadding(float padding, YGEdge edge) {
|
void Node::setLayoutPadding(float padding, Edge edge) {
|
||||||
assertFatal(
|
layout_.setPadding(edge, padding);
|
||||||
edge < static_cast<int>(layout_.padding.size()),
|
|
||||||
"Edge must be top/left/bottom/right");
|
|
||||||
layout_.padding[edge] = padding;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Node::setLayoutLastOwnerDirection(Direction direction) {
|
void Node::setLayoutLastOwnerDirection(Direction direction) {
|
||||||
@@ -475,11 +464,8 @@ void Node::setLayoutComputedFlexBasis(const FloatOptional computedFlexBasis) {
|
|||||||
layout_.computedFlexBasis = computedFlexBasis;
|
layout_.computedFlexBasis = computedFlexBasis;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Node::setLayoutPosition(float position, YGEdge edge) {
|
void Node::setLayoutPosition(float position, Edge edge) {
|
||||||
assertFatal(
|
layout_.setPosition(edge, position);
|
||||||
edge < static_cast<int>(layout_.position.size()),
|
|
||||||
"Edge must be top/left/bottom/right");
|
|
||||||
layout_.position[edge] = position;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Node::setLayoutComputedFlexBasisGeneration(
|
void Node::setLayoutComputedFlexBasisGeneration(
|
||||||
@@ -536,13 +522,13 @@ void Node::setPosition(
|
|||||||
const float relativePositionCross =
|
const float relativePositionCross =
|
||||||
relativePosition(crossAxis, directionRespectingRoot, crossSize);
|
relativePosition(crossAxis, directionRespectingRoot, crossSize);
|
||||||
|
|
||||||
const YGEdge mainAxisLeadingEdge =
|
const Edge mainAxisLeadingEdge =
|
||||||
getInlineStartEdgeUsingErrata(mainAxis, direction);
|
getInlineStartEdgeUsingErrata(mainAxis, direction);
|
||||||
const YGEdge mainAxisTrailingEdge =
|
const Edge mainAxisTrailingEdge =
|
||||||
getInlineEndEdgeUsingErrata(mainAxis, direction);
|
getInlineEndEdgeUsingErrata(mainAxis, direction);
|
||||||
const YGEdge crossAxisLeadingEdge =
|
const Edge crossAxisLeadingEdge =
|
||||||
getInlineStartEdgeUsingErrata(crossAxis, direction);
|
getInlineStartEdgeUsingErrata(crossAxis, direction);
|
||||||
const YGEdge crossAxisTrailingEdge =
|
const Edge crossAxisTrailingEdge =
|
||||||
getInlineEndEdgeUsingErrata(crossAxis, direction);
|
getInlineEndEdgeUsingErrata(crossAxis, direction);
|
||||||
|
|
||||||
setLayoutPosition(
|
setLayoutPosition(
|
||||||
@@ -564,16 +550,16 @@ void Node::setPosition(
|
|||||||
}
|
}
|
||||||
|
|
||||||
YGValue Node::getFlexStartMarginValue(FlexDirection axis) const {
|
YGValue Node::getFlexStartMarginValue(FlexDirection axis) const {
|
||||||
if (isRow(axis) && style_.margin(YGEdgeStart).isDefined()) {
|
if (isRow(axis) && style_.margin(Edge::Start).isDefined()) {
|
||||||
return style_.margin(YGEdgeStart);
|
return style_.margin(Edge::Start);
|
||||||
} else {
|
} else {
|
||||||
return style_.margin(flexStartEdge(axis));
|
return style_.margin(flexStartEdge(axis));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
YGValue Node::marginTrailingValue(FlexDirection axis) const {
|
YGValue Node::marginTrailingValue(FlexDirection axis) const {
|
||||||
if (isRow(axis) && style_.margin(YGEdgeEnd).isDefined()) {
|
if (isRow(axis) && style_.margin(Edge::End).isDefined()) {
|
||||||
return style_.margin(YGEdgeEnd);
|
return style_.margin(Edge::End);
|
||||||
} else {
|
} else {
|
||||||
return style_.margin(flexEndEdge(axis));
|
return style_.margin(flexEndEdge(axis));
|
||||||
}
|
}
|
||||||
|
@@ -16,6 +16,7 @@
|
|||||||
#include <yoga/config/Config.h>
|
#include <yoga/config/Config.h>
|
||||||
#include <yoga/enums/Dimension.h>
|
#include <yoga/enums/Dimension.h>
|
||||||
#include <yoga/enums/Direction.h>
|
#include <yoga/enums/Direction.h>
|
||||||
|
#include <yoga/enums/Edge.h>
|
||||||
#include <yoga/enums/Errata.h>
|
#include <yoga/enums/Errata.h>
|
||||||
#include <yoga/enums/MeasureMode.h>
|
#include <yoga/enums/MeasureMode.h>
|
||||||
#include <yoga/enums/NodeType.h>
|
#include <yoga/enums/NodeType.h>
|
||||||
@@ -52,10 +53,10 @@ class YG_EXPORT Node : public ::YGNode {
|
|||||||
Direction direction,
|
Direction direction,
|
||||||
const float axisSize) const;
|
const float axisSize) const;
|
||||||
|
|
||||||
YGEdge getInlineStartEdgeUsingErrata(
|
Edge getInlineStartEdgeUsingErrata(
|
||||||
FlexDirection flexDirection,
|
FlexDirection flexDirection,
|
||||||
Direction direction) const;
|
Direction direction) const;
|
||||||
YGEdge getInlineEndEdgeUsingErrata(
|
Edge getInlineEndEdgeUsingErrata(
|
||||||
FlexDirection flexDirection,
|
FlexDirection flexDirection,
|
||||||
Direction direction) const;
|
Direction direction) const;
|
||||||
|
|
||||||
@@ -65,10 +66,10 @@ class YG_EXPORT Node : public ::YGNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <auto Field>
|
template <auto Field>
|
||||||
Style::Length computeEdgeValueForColumn(YGEdge edge) const;
|
Style::Length computeEdgeValueForColumn(Edge edge) const;
|
||||||
|
|
||||||
template <auto Field>
|
template <auto Field>
|
||||||
Style::Length computeEdgeValueForRow(YGEdge rowEdge, YGEdge edge) const;
|
Style::Length computeEdgeValueForRow(Edge rowEdge, Edge edge) const;
|
||||||
|
|
||||||
// DANGER DANGER DANGER!
|
// DANGER DANGER DANGER!
|
||||||
// If the node assigned to has children, we'd either have to deallocate
|
// If the node assigned to has children, we'd either have to deallocate
|
||||||
@@ -328,10 +329,10 @@ class YG_EXPORT Node : public ::YGNode {
|
|||||||
void setLayoutHadOverflow(bool hadOverflow);
|
void setLayoutHadOverflow(bool hadOverflow);
|
||||||
void setLayoutDimension(float LengthValue, Dimension dimension);
|
void setLayoutDimension(float LengthValue, Dimension dimension);
|
||||||
void setLayoutDirection(Direction direction);
|
void setLayoutDirection(Direction direction);
|
||||||
void setLayoutMargin(float margin, YGEdge edge);
|
void setLayoutMargin(float margin, Edge edge);
|
||||||
void setLayoutBorder(float border, YGEdge edge);
|
void setLayoutBorder(float border, Edge edge);
|
||||||
void setLayoutPadding(float padding, YGEdge edge);
|
void setLayoutPadding(float padding, Edge edge);
|
||||||
void setLayoutPosition(float position, YGEdge edge);
|
void setLayoutPosition(float position, Edge edge);
|
||||||
void setPosition(
|
void setPosition(
|
||||||
const Direction direction,
|
const Direction direction,
|
||||||
const float mainSize,
|
const float mainSize,
|
||||||
|
@@ -227,32 +227,32 @@ class YG_EXPORT Style {
|
|||||||
return {*this};
|
return {*this};
|
||||||
}
|
}
|
||||||
|
|
||||||
Style::Length margin(YGEdge edge) const {
|
Style::Length margin(Edge edge) const {
|
||||||
return margin_[edge];
|
return margin_[yoga::to_underlying(edge)];
|
||||||
}
|
}
|
||||||
void setMargin(YGEdge edge, Style::Length value) {
|
void setMargin(Edge edge, Style::Length value) {
|
||||||
margin_[edge] = value;
|
margin_[yoga::to_underlying(edge)] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
Style::Length position(YGEdge edge) const {
|
Style::Length position(Edge edge) const {
|
||||||
return position_[edge];
|
return position_[yoga::to_underlying(edge)];
|
||||||
}
|
}
|
||||||
void setPosition(YGEdge edge, Style::Length value) {
|
void setPosition(Edge edge, Style::Length value) {
|
||||||
position_[edge] = value;
|
position_[yoga::to_underlying(edge)] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
Style::Length padding(YGEdge edge) const {
|
Style::Length padding(Edge edge) const {
|
||||||
return padding_[edge];
|
return padding_[yoga::to_underlying(edge)];
|
||||||
}
|
}
|
||||||
void setPadding(YGEdge edge, Style::Length value) {
|
void setPadding(Edge edge, Style::Length value) {
|
||||||
padding_[edge] = value;
|
padding_[yoga::to_underlying(edge)] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
Style::Length border(YGEdge edge) const {
|
Style::Length border(Edge edge) const {
|
||||||
return border_[edge];
|
return border_[yoga::to_underlying(edge)];
|
||||||
}
|
}
|
||||||
void setBorder(YGEdge edge, Style::Length value) {
|
void setBorder(Edge edge, Style::Length value) {
|
||||||
border_[edge] = value;
|
border_[yoga::to_underlying(edge)] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
Style::Length gap(Gutter gutter) const {
|
Style::Length gap(Gutter gutter) const {
|
||||||
|
Reference in New Issue
Block a user