[YogaKit] support macOS, tvOS, Carthage; auto apply layout like AutoLayout. #1026

Closed
cntrump wants to merge 38 commits from yogakit_autoapplylayout_patch into main
81 changed files with 3629 additions and 589 deletions
Showing only changes of commit 029b877d2e - Show all commits

View File

@@ -375,9 +375,9 @@ YG_PROPERTY(CGFloat, aspectRatio, AspectRatio)
static YGSize YGMeasureView( static YGSize YGMeasureView(
YGNodeRef node, YGNodeRef node,
float width, YGFloat width,
YGMeasureMode widthMode, YGMeasureMode widthMode,
float height, YGFloat height,
YGMeasureMode heightMode) { YGMeasureMode heightMode) {
const CGFloat constrainedWidth = const CGFloat constrainedWidth =
(widthMode == YGMeasureModeUndefined) ? CGFLOAT_MAX : width; (widthMode == YGMeasureModeUndefined) ? CGFLOAT_MAX : width;
@@ -409,9 +409,9 @@ static YGSize YGMeasureView(
} }
return (YGSize){ return (YGSize){
.width = (float)YGSanitizeMeasurement( .width = (YGFloat)YGSanitizeMeasurement(
constrainedWidth, sizeThatFits.width, widthMode), constrainedWidth, sizeThatFits.width, widthMode),
.height = (float)YGSanitizeMeasurement( .height = (YGFloat)YGSanitizeMeasurement(
constrainedHeight, sizeThatFits.height, heightMode), constrainedHeight, sizeThatFits.height, heightMode),
}; };
} }
@@ -488,11 +488,6 @@ static void YGRemoveAllChildren(const YGNodeRef node) {
YGNodeRemoveAllChildren(node); YGNodeRemoveAllChildren(node);
} }
static inline CGPoint YGRoundPixelPosition(CGPoint p) {
CGFloat scale = YGScaleFactor();
return (CGPoint) { .x = round(p.x * scale) / scale, .y = round(p.y * scale) / scale };
}
static inline CGSize YGAlignPixelSize(CGSize s) { static inline CGSize YGAlignPixelSize(CGSize s) {
CGFloat scale = YGScaleFactor(); CGFloat scale = YGScaleFactor();
return (CGSize) { .width = ceil(s.width * scale) / scale, .height = ceil(s.height * scale) / scale }; return (CGSize) { .width = ceil(s.width * scale) / scale, .height = ceil(s.height * scale) / scale };
@@ -553,7 +548,7 @@ static void YGApplyLayoutToViewHierarchy(UIView* view, BOOL preserveOrigin) {
} }
view.frame = (CGRect) { view.frame = (CGRect) {
.origin = YGRoundPixelPosition(frame.origin), .origin = frame.origin,
.size = YGAlignPixelSize(frame.size) .size = YGAlignPixelSize(frame.size)
}; };
#else #else
@@ -562,10 +557,10 @@ static void YGApplyLayoutToViewHierarchy(UIView* view, BOOL preserveOrigin) {
.size = YGAlignPixelSize(frame.size) .size = YGAlignPixelSize(frame.size)
}; };
view.center = YGRoundPixelPosition((CGPoint) { view.center = (CGPoint) {
.x = CGRectGetMinX(frame) + CGRectGetWidth(frame) * 0.5, .x = CGRectGetMidX(frame),
.y = CGRectGetMinY(frame) + CGRectGetHeight(frame) * 0.5 .y = CGRectGetMidY(frame)
}); };
#endif #endif
if (!yoga.isLeaf) { if (!yoga.isLeaf) {

View File

@@ -265,16 +265,28 @@
subview1.yoga.flexGrow = 1; subview1.yoga.flexGrow = 1;
[container addSubview:subview1]; [container addSubview:subview1];
UIView *leafView = [[UIView alloc] init];
leafView.yoga.isEnabled = YES;
[subview1 addSubview:leafView];
UIView* subview2 = [[UIView alloc] initWithFrame:CGRectZero]; UIView* subview2 = [[UIView alloc] initWithFrame:CGRectZero];
subview2.yoga.isEnabled = YES; subview2.yoga.isEnabled = YES;
subview2.yoga.flexGrow = 1; subview2.yoga.flexGrow = 1;
[container addSubview:subview2]; [container addSubview:subview2];
leafView = [[UIView alloc] init];
leafView.yoga.isEnabled = YES;
[subview2 addSubview:leafView];
UIView* subview3 = [[UIView alloc] initWithFrame:CGRectZero]; UIView* subview3 = [[UIView alloc] initWithFrame:CGRectZero];
subview3.yoga.isEnabled = YES; subview3.yoga.isEnabled = YES;
subview3.yoga.flexGrow = 1; subview3.yoga.flexGrow = 1;
[container addSubview:subview3]; [container addSubview:subview3];
leafView = [[UIView alloc] init];
leafView.yoga.isEnabled = YES;
[subview3 addSubview:leafView];
[container.yoga applyLayoutPreservingOrigin:YES]; [container.yoga applyLayoutPreservingOrigin:YES];
XCTAssertEqualWithAccuracy( XCTAssertEqualWithAccuracy(

View File

@@ -18,16 +18,16 @@ YGFlexDirection YGFlexDirectionCross(
: YGFlexDirectionColumn; : YGFlexDirectionColumn;
} }
float YGFloatMax(const float a, const float b) { YGFloat YGFloatMax(const YGFloat a, const YGFloat b) {
if (!yoga::isUndefined(a) && !yoga::isUndefined(b)) { if (!yoga::isUndefined(a) && !yoga::isUndefined(b)) {
return fmaxf(a, b); return fmax(a, b);
} }
return yoga::isUndefined(a) ? b : a; return yoga::isUndefined(a) ? b : a;
} }
float YGFloatMin(const float a, const float b) { YGFloat YGFloatMin(const YGFloat a, const YGFloat b) {
if (!yoga::isUndefined(a) && !yoga::isUndefined(b)) { if (!yoga::isUndefined(a) && !yoga::isUndefined(b)) {
return fminf(a, b); return fmin(a, b);
} }
return yoga::isUndefined(a) ? b : a; return yoga::isUndefined(a) ? b : a;
@@ -46,7 +46,7 @@ bool YGValueEqual(const YGValue& a, const YGValue& b) {
return fabs(a.value - b.value) < 0.0001f; return fabs(a.value - b.value) < 0.0001f;
} }
bool YGFloatsEqual(const float a, const float b) { bool YGFloatsEqual(const YGFloat a, const YGFloat b) {
if (!yoga::isUndefined(a) && !yoga::isUndefined(b)) { if (!yoga::isUndefined(a) && !yoga::isUndefined(b)) {
return fabs(a - b) < 0.0001f; return fabs(a - b) < 0.0001f;
} }
@@ -60,7 +60,7 @@ bool YGDoubleEqual(const double a, const double b) {
return yoga::isUndefined(a) && yoga::isUndefined(b); return yoga::isUndefined(a) && yoga::isUndefined(b);
} }
float YGFloatSanitize(const float val) { YGFloat YGFloatSanitize(const YGFloat val) {
return yoga::isUndefined(val) ? 0 : val; return yoga::isUndefined(val) ? 0 : val;
} }

View File

@@ -38,19 +38,19 @@
struct YGCollectFlexItemsRowValues { struct YGCollectFlexItemsRowValues {
uint32_t itemsOnLine; uint32_t itemsOnLine;
float sizeConsumedOnCurrentLine; YGFloat sizeConsumedOnCurrentLine;
float totalFlexGrowFactors; YGFloat totalFlexGrowFactors;
float totalFlexShrinkScaledFactors; YGFloat totalFlexShrinkScaledFactors;
uint32_t endOfLineIndex; uint32_t endOfLineIndex;
std::vector<YGNodeRef> relativeChildren; std::vector<YGNodeRef> relativeChildren;
float remainingFreeSpace; YGFloat remainingFreeSpace;
// The size of the mainDim for the row after considering size, padding, margin // The size of the mainDim for the row after considering size, padding, margin
// and border of flex items. This is used to calculate maxLineDim after going // and border of flex items. This is used to calculate maxLineDim after going
// through all the rows to decide on the main axis size of owner. // through all the rows to decide on the main axis size of owner.
float mainDim; YGFloat mainDim;
// The size of the crossDim for the row after considering size, padding, // The size of the crossDim for the row after considering size, padding,
// margin and border of flex items. Used for calculating containers crossSize. // margin and border of flex items. Used for calculating containers crossSize.
float crossDim; YGFloat crossDim;
}; };
bool YGValueEqual(const YGValue& a, const YGValue& b); bool YGValueEqual(const YGValue& a, const YGValue& b);
@@ -60,27 +60,27 @@ inline bool YGValueEqual(
return YGValueEqual((YGValue) a, (YGValue) b); return YGValueEqual((YGValue) a, (YGValue) b);
} }
// This custom float equality function returns true if either absolute // This custom YGFloat equality function returns true if either absolute
// difference between two floats is less than 0.0001f or both are undefined. // difference between two floats is less than 0.0001f or both are undefined.
bool YGFloatsEqual(const float a, const float b); bool YGFloatsEqual(const YGFloat a, const YGFloat b);
bool YGDoubleEqual(const double a, const double b); bool YGDoubleEqual(const double a, const double b);
float YGFloatMax(const float a, const float b); YGFloat YGFloatMax(const YGFloat a, const YGFloat b);
YGFloatOptional YGFloatOptionalMax( YGFloatOptional YGFloatOptionalMax(
const YGFloatOptional op1, const YGFloatOptional op1,
const YGFloatOptional op2); const YGFloatOptional op2);
float YGFloatMin(const float a, const float b); YGFloat YGFloatMin(const YGFloat a, const YGFloat b);
// This custom float comparison function compares the array of float with // This custom YGFloat comparison function compares the array of YGFloat with
// YGFloatsEqual, as the default float comparison operator will not work(Look // YGFloatsEqual, as the default YGFloat comparison operator will not work(Look
// at the comments of YGFloatsEqual function). // at the comments of YGFloatsEqual function).
template <std::size_t size> template <std::size_t size>
bool YGFloatArrayEqual( bool YGFloatArrayEqual(
const std::array<float, size>& val1, const std::array<YGFloat, size>& val1,
const std::array<float, size>& val2) { const std::array<YGFloat, size>& val2) {
bool areEqual = true; bool areEqual = true;
for (std::size_t i = 0; i < size && areEqual; ++i) { for (std::size_t i = 0; i < size && areEqual; ++i) {
areEqual = YGFloatsEqual(val1[i], val2[i]); areEqual = YGFloatsEqual(val1[i], val2[i]);
@@ -89,7 +89,7 @@ bool YGFloatArrayEqual(
} }
// This function returns 0 if YGFloatIsUndefined(val) is true and val otherwise // This function returns 0 if YGFloatIsUndefined(val) is true and val otherwise
float YGFloatSanitize(const float val); YGFloat YGFloatSanitize(const YGFloat val);
YGFlexDirection YGFlexDirectionCross( YGFlexDirection YGFlexDirectionCross(
const YGFlexDirection flexDirection, const YGFlexDirection flexDirection,
@@ -102,7 +102,7 @@ inline bool YGFlexDirectionIsRow(const YGFlexDirection flexDirection) {
inline YGFloatOptional YGResolveValue( inline YGFloatOptional YGResolveValue(
const YGValue value, const YGValue value,
const float ownerSize) { const YGFloat ownerSize) {
switch (value.unit) { switch (value.unit) {
case YGUnitPoint: case YGUnitPoint:
return YGFloatOptional{value.value}; return YGFloatOptional{value.value};
@@ -115,7 +115,7 @@ inline YGFloatOptional YGResolveValue(
inline YGFloatOptional YGResolveValue( inline YGFloatOptional YGResolveValue(
yoga::detail::CompactValue value, yoga::detail::CompactValue value,
float ownerSize) { YGFloat ownerSize) {
return YGResolveValue((YGValue) value, ownerSize); return YGResolveValue((YGValue) value, ownerSize);
} }
@@ -140,7 +140,7 @@ inline YGFlexDirection YGResolveFlexDirection(
inline YGFloatOptional YGResolveValueMargin( inline YGFloatOptional YGResolveValueMargin(
yoga::detail::CompactValue value, yoga::detail::CompactValue value,
const float ownerSize) { const YGFloat ownerSize) {
return value.isAuto() ? YGFloatOptional{0} : YGResolveValue(value, ownerSize); return value.isAuto() ? YGFloatOptional{0} : YGResolveValue(value, ownerSize);
} }

View File

@@ -40,7 +40,7 @@ public:
bool useLegacyStretchBehaviour = false; bool useLegacyStretchBehaviour = false;
bool shouldDiffLayoutWithoutLegacyStretchBehaviour = false; bool shouldDiffLayoutWithoutLegacyStretchBehaviour = false;
bool printTree = false; bool printTree = false;
float pointScaleFactor = 1.0f; YGFloat pointScaleFactor = 1.0f;
std::array<bool, facebook::yoga::enums::count<YGExperimentalFeature>()> std::array<bool, facebook::yoga::enums::count<YGExperimentalFeature>()>
experimentalFeatures = {}; experimentalFeatures = {};
void* context = nullptr; void* context = nullptr;

View File

@@ -13,14 +13,14 @@
struct YGFloatOptional { struct YGFloatOptional {
private: private:
float value_ = std::numeric_limits<float>::quiet_NaN(); YGFloat value_ = std::numeric_limits<YGFloat>::quiet_NaN();
public: public:
explicit constexpr YGFloatOptional(float value) : value_(value) {} explicit constexpr YGFloatOptional(YGFloat value) : value_(value) {}
constexpr YGFloatOptional() = default; constexpr YGFloatOptional() = default;
// returns the wrapped value, or a value x with YGIsUndefined(x) == true // returns the wrapped value, or a value x with YGIsUndefined(x) == true
constexpr float unwrap() const { return value_; } constexpr YGFloat unwrap() const { return value_; }
bool isUndefined() const { return std::isnan(value_); } bool isUndefined() const { return std::isnan(value_); }
}; };
@@ -35,17 +35,17 @@ inline bool operator!=(YGFloatOptional lhs, YGFloatOptional rhs) {
return !(lhs == rhs); return !(lhs == rhs);
} }
inline bool operator==(YGFloatOptional lhs, float rhs) { inline bool operator==(YGFloatOptional lhs, YGFloat rhs) {
return lhs == YGFloatOptional{rhs}; return lhs == YGFloatOptional{rhs};
} }
inline bool operator!=(YGFloatOptional lhs, float rhs) { inline bool operator!=(YGFloatOptional lhs, YGFloat rhs) {
return !(lhs == rhs); return !(lhs == rhs);
} }
inline bool operator==(float lhs, YGFloatOptional rhs) { inline bool operator==(YGFloat lhs, YGFloatOptional rhs) {
return rhs == lhs; return rhs == lhs;
} }
inline bool operator!=(float lhs, YGFloatOptional rhs) { inline bool operator!=(YGFloat lhs, YGFloatOptional rhs) {
return !(lhs == rhs); return !(lhs == rhs);
} }

View File

@@ -13,11 +13,11 @@
using namespace facebook::yoga; using namespace facebook::yoga;
struct YGLayout { struct YGLayout {
std::array<float, 4> position = {}; std::array<YGFloat, 4> position = {};
std::array<float, 2> dimensions = {{YGUndefined, YGUndefined}}; std::array<YGFloat, 2> dimensions = {{YGUndefined, YGUndefined}};
std::array<float, 4> margin = {}; std::array<YGFloat, 4> margin = {};
std::array<float, 4> border = {}; std::array<YGFloat, 4> border = {};
std::array<float, 4> padding = {}; std::array<YGFloat, 4> padding = {};
private: private:
static constexpr size_t directionOffset = 0; static constexpr size_t directionOffset = 0;
@@ -41,7 +41,7 @@ public:
uint32_t nextCachedMeasurementsIndex = 0; uint32_t nextCachedMeasurementsIndex = 0;
std::array<YGCachedMeasurement, YG_MAX_CACHED_RESULT_COUNT> std::array<YGCachedMeasurement, YG_MAX_CACHED_RESULT_COUNT>
cachedMeasurements = {}; cachedMeasurements = {};
std::array<float, 2> measuredDimensions = {{YGUndefined, YGUndefined}}; std::array<YGFloat, 2> measuredDimensions = {{YGUndefined, YGUndefined}};
YGCachedMeasurement cachedLayout = YGCachedMeasurement(); YGCachedMeasurement cachedLayout = YGCachedMeasurement();

View File

@@ -7,6 +7,21 @@
#pragma once #pragma once
#if defined(__LP64__) && __LP64__
# define YGFLOAT_TYPE double
# define YGFLOAT_IS_DOUBLE 1
# define YGFLOAT_MIN DBL_MIN
# define YGFLOAT_MAX DBL_MAX
#else
# define YGFLOAT_TYPE float
# define YGFLOAT_IS_DOUBLE 0
# define YGFLOAT_MIN FLT_MIN
# define YGFLOAT_MAX FLT_MAX
#endif
typedef YGFLOAT_TYPE YGFloat;
#define YGFLOAT_DEFINED 1
#ifdef __cplusplus #ifdef __cplusplus
#define YG_EXTERN_CXX_BEGIN extern "C++" { #define YG_EXTERN_CXX_BEGIN extern "C++" {
#define YG_EXTERN_C_BEGIN extern "C" { #define YG_EXTERN_C_BEGIN extern "C" {

View File

@@ -52,7 +52,7 @@ void YGNode::print(void* printContext) {
YGFloatOptional YGNode::getLeadingPosition( YGFloatOptional YGNode::getLeadingPosition(
const YGFlexDirection axis, const YGFlexDirection axis,
const float axisSize) const { const YGFloat axisSize) const {
if (YGFlexDirectionIsRow(axis)) { if (YGFlexDirectionIsRow(axis)) {
auto leadingPosition = YGComputedEdgeValue( auto leadingPosition = YGComputedEdgeValue(
style_.position(), YGEdgeStart, CompactValue::ofUndefined()); style_.position(), YGEdgeStart, CompactValue::ofUndefined());
@@ -71,7 +71,7 @@ YGFloatOptional YGNode::getLeadingPosition(
YGFloatOptional YGNode::getTrailingPosition( YGFloatOptional YGNode::getTrailingPosition(
const YGFlexDirection axis, const YGFlexDirection axis,
const float axisSize) const { const YGFloat axisSize) const {
if (YGFlexDirectionIsRow(axis)) { if (YGFlexDirectionIsRow(axis)) {
auto trailingPosition = YGComputedEdgeValue( auto trailingPosition = YGComputedEdgeValue(
style_.position(), YGEdgeEnd, CompactValue::ofUndefined()); style_.position(), YGEdgeEnd, CompactValue::ofUndefined());
@@ -110,7 +110,7 @@ bool YGNode::isTrailingPosDefined(const YGFlexDirection axis) const {
YGFloatOptional YGNode::getLeadingMargin( YGFloatOptional YGNode::getLeadingMargin(
const YGFlexDirection axis, const YGFlexDirection axis,
const float widthSize) const { const YGFloat widthSize) const {
if (YGFlexDirectionIsRow(axis) && if (YGFlexDirectionIsRow(axis) &&
!style_.margin()[YGEdgeStart].isUndefined()) { !style_.margin()[YGEdgeStart].isUndefined()) {
return YGResolveValueMargin(style_.margin()[YGEdgeStart], widthSize); return YGResolveValueMargin(style_.margin()[YGEdgeStart], widthSize);
@@ -124,7 +124,7 @@ YGFloatOptional YGNode::getLeadingMargin(
YGFloatOptional YGNode::getTrailingMargin( YGFloatOptional YGNode::getTrailingMargin(
const YGFlexDirection axis, const YGFlexDirection axis,
const float widthSize) const { const YGFloat widthSize) const {
if (YGFlexDirectionIsRow(axis) && !style_.margin()[YGEdgeEnd].isUndefined()) { if (YGFlexDirectionIsRow(axis) && !style_.margin()[YGEdgeEnd].isUndefined()) {
return YGResolveValueMargin(style_.margin()[YGEdgeEnd], widthSize); return YGResolveValueMargin(style_.margin()[YGEdgeEnd], widthSize);
} }
@@ -137,14 +137,14 @@ YGFloatOptional YGNode::getTrailingMargin(
YGFloatOptional YGNode::getMarginForAxis( YGFloatOptional YGNode::getMarginForAxis(
const YGFlexDirection axis, const YGFlexDirection axis,
const float widthSize) const { const YGFloat widthSize) const {
return getLeadingMargin(axis, widthSize) + getTrailingMargin(axis, widthSize); return getLeadingMargin(axis, widthSize) + getTrailingMargin(axis, widthSize);
} }
YGSize YGNode::measure( YGSize YGNode::measure(
float width, YGFloat width,
YGMeasureMode widthMode, YGMeasureMode widthMode,
float height, YGFloat height,
YGMeasureMode heightMode, YGMeasureMode heightMode,
void* layoutContext) { void* layoutContext) {
@@ -154,7 +154,7 @@ YGSize YGNode::measure(
: measure_.noContext(this, width, widthMode, height, heightMode); : measure_.noContext(this, width, widthMode, height, heightMode);
} }
float YGNode::baseline(float width, float height, void* layoutContext) { YGFloat YGNode::baseline(YGFloat width, YGFloat height, void* layoutContext) {
return facebook::yoga::detail::getBooleanData(flags, baselineUsesContext_) return facebook::yoga::detail::getBooleanData(flags, baselineUsesContext_)
? baseline_.withContext(this, width, height, layoutContext) ? baseline_.withContext(this, width, height, layoutContext)
: baseline_.noContext(this, width, height); : baseline_.noContext(this, width, height);
@@ -235,15 +235,15 @@ void YGNode::setLayoutDirection(YGDirection direction) {
layout_.setDirection(direction); layout_.setDirection(direction);
} }
void YGNode::setLayoutMargin(float margin, int index) { void YGNode::setLayoutMargin(YGFloat margin, int index) {
layout_.margin[index] = margin; layout_.margin[index] = margin;
} }
void YGNode::setLayoutBorder(float border, int index) { void YGNode::setLayoutBorder(YGFloat border, int index) {
layout_.border[index] = border; layout_.border[index] = border;
} }
void YGNode::setLayoutPadding(float padding, int index) { void YGNode::setLayoutPadding(YGFloat padding, int index) {
layout_.padding[index] = padding; layout_.padding[index] = padding;
} }
@@ -256,7 +256,7 @@ void YGNode::setLayoutComputedFlexBasis(
layout_.computedFlexBasis = computedFlexBasis; layout_.computedFlexBasis = computedFlexBasis;
} }
void YGNode::setLayoutPosition(float position, int index) { void YGNode::setLayoutPosition(YGFloat position, int index) {
layout_.position[index] = position; layout_.position[index] = position;
} }
@@ -265,7 +265,7 @@ void YGNode::setLayoutComputedFlexBasisGeneration(
layout_.computedFlexBasisGeneration = computedFlexBasisGeneration; layout_.computedFlexBasisGeneration = computedFlexBasisGeneration;
} }
void YGNode::setLayoutMeasuredDimension(float measuredDimension, int index) { void YGNode::setLayoutMeasuredDimension(YGFloat measuredDimension, int index) {
layout_.measuredDimensions[index] = measuredDimension; layout_.measuredDimensions[index] = measuredDimension;
} }
@@ -273,7 +273,7 @@ void YGNode::setLayoutHadOverflow(bool hadOverflow) {
layout_.setHadOverflow(hadOverflow); layout_.setHadOverflow(hadOverflow);
} }
void YGNode::setLayoutDimension(float dimension, int index) { void YGNode::setLayoutDimension(YGFloat dimension, int index) {
layout_.dimensions[index] = dimension; layout_.dimensions[index] = dimension;
} }
@@ -281,7 +281,7 @@ void YGNode::setLayoutDimension(float dimension, int index) {
// -right depending on which is defined. // -right depending on which is defined.
YGFloatOptional YGNode::relativePosition( YGFloatOptional YGNode::relativePosition(
const YGFlexDirection axis, const YGFlexDirection axis,
const float axisSize) const { const YGFloat axisSize) const {
if (isLeadingPositionDefined(axis)) { if (isLeadingPositionDefined(axis)) {
return getLeadingPosition(axis, axisSize); return getLeadingPosition(axis, axisSize);
} }
@@ -295,9 +295,9 @@ YGFloatOptional YGNode::relativePosition(
void YGNode::setPosition( void YGNode::setPosition(
const YGDirection direction, const YGDirection direction,
const float mainSize, const YGFloat mainSize,
const float crossSize, const YGFloat crossSize,
const float ownerWidth) { const YGFloat ownerWidth) {
/* Root nodes should be always layouted as LTR, so we don't return negative /* Root nodes should be always layouted as LTR, so we don't return negative
* values. */ * values. */
const YGDirection directionRespectingRoot = const YGDirection directionRespectingRoot =
@@ -411,7 +411,7 @@ void YGNode::markDirtyAndPropogateDownwards() {
}); });
} }
float YGNode::resolveFlexGrow() const { YGFloat YGNode::resolveFlexGrow() const {
// Root nodes flexGrow should always be 0 // Root nodes flexGrow should always be 0
if (owner_ == nullptr) { if (owner_ == nullptr) {
return 0.0; return 0.0;
@@ -425,7 +425,7 @@ float YGNode::resolveFlexGrow() const {
return kDefaultFlexGrow; return kDefaultFlexGrow;
} }
float YGNode::resolveFlexShrink() const { YGFloat YGNode::resolveFlexShrink() const {
if (owner_ == nullptr) { if (owner_ == nullptr) {
return 0.0; return 0.0;
} }
@@ -447,7 +447,7 @@ bool YGNode::isNodeFlexible() {
(resolveFlexGrow() != 0 || resolveFlexShrink() != 0)); (resolveFlexGrow() != 0 || resolveFlexShrink() != 0));
} }
float YGNode::getLeadingBorder(const YGFlexDirection axis) const { YGFloat YGNode::getLeadingBorder(const YGFlexDirection axis) const {
YGValue leadingBorder; YGValue leadingBorder;
if (YGFlexDirectionIsRow(axis) && if (YGFlexDirectionIsRow(axis) &&
!style_.border()[YGEdgeStart].isUndefined()) { !style_.border()[YGEdgeStart].isUndefined()) {
@@ -462,7 +462,7 @@ float YGNode::getLeadingBorder(const YGFlexDirection axis) const {
return YGFloatMax(leadingBorder.value, 0.0f); return YGFloatMax(leadingBorder.value, 0.0f);
} }
float YGNode::getTrailingBorder(const YGFlexDirection flexDirection) const { YGFloat YGNode::getTrailingBorder(const YGFlexDirection flexDirection) const {
YGValue trailingBorder; YGValue trailingBorder;
if (YGFlexDirectionIsRow(flexDirection) && if (YGFlexDirectionIsRow(flexDirection) &&
!style_.border()[YGEdgeEnd].isUndefined()) { !style_.border()[YGEdgeEnd].isUndefined()) {
@@ -479,7 +479,7 @@ float YGNode::getTrailingBorder(const YGFlexDirection flexDirection) const {
YGFloatOptional YGNode::getLeadingPadding( YGFloatOptional YGNode::getLeadingPadding(
const YGFlexDirection axis, const YGFlexDirection axis,
const float widthSize) const { const YGFloat widthSize) const {
const YGFloatOptional paddingEdgeStart = const YGFloatOptional paddingEdgeStart =
YGResolveValue(style_.padding()[YGEdgeStart], widthSize); YGResolveValue(style_.padding()[YGEdgeStart], widthSize);
if (YGFlexDirectionIsRow(axis) && if (YGFlexDirectionIsRow(axis) &&
@@ -497,7 +497,7 @@ YGFloatOptional YGNode::getLeadingPadding(
YGFloatOptional YGNode::getTrailingPadding( YGFloatOptional YGNode::getTrailingPadding(
const YGFlexDirection axis, const YGFlexDirection axis,
const float widthSize) const { const YGFloat widthSize) const {
const YGFloatOptional paddingEdgeEnd = const YGFloatOptional paddingEdgeEnd =
YGResolveValue(style_.padding()[YGEdgeEnd], widthSize); YGResolveValue(style_.padding()[YGEdgeEnd], widthSize);
if (YGFlexDirectionIsRow(axis) && paddingEdgeEnd >= YGFloatOptional{0.0f}) { if (YGFlexDirectionIsRow(axis) && paddingEdgeEnd >= YGFloatOptional{0.0f}) {
@@ -514,14 +514,14 @@ YGFloatOptional YGNode::getTrailingPadding(
YGFloatOptional YGNode::getLeadingPaddingAndBorder( YGFloatOptional YGNode::getLeadingPaddingAndBorder(
const YGFlexDirection axis, const YGFlexDirection axis,
const float widthSize) const { const YGFloat widthSize) const {
return getLeadingPadding(axis, widthSize) + return getLeadingPadding(axis, widthSize) +
YGFloatOptional(getLeadingBorder(axis)); YGFloatOptional(getLeadingBorder(axis));
} }
YGFloatOptional YGNode::getTrailingPaddingAndBorder( YGFloatOptional YGNode::getTrailingPaddingAndBorder(
const YGFlexDirection axis, const YGFlexDirection axis,
const float widthSize) const { const YGFloat widthSize) const {
return getTrailingPadding(axis, widthSize) + return getTrailingPadding(axis, widthSize) +
YGFloatOptional(getTrailingBorder(axis)); YGFloatOptional(getTrailingBorder(axis));
} }

View File

@@ -23,8 +23,8 @@ YGConfigRef YGConfigGetDefault();
struct YOGA_EXPORT YGNode { struct YOGA_EXPORT YGNode {
using MeasureWithContextFn = using MeasureWithContextFn =
YGSize (*)(YGNode*, float, YGMeasureMode, float, YGMeasureMode, void*); YGSize (*)(YGNode*, YGFloat, YGMeasureMode, YGFloat, YGMeasureMode, void*);
using BaselineWithContextFn = float (*)(YGNode*, float, float, void*); using BaselineWithContextFn = YGFloat (*)(YGNode*, YGFloat, YGFloat, void*);
using PrintWithContextFn = void (*)(YGNode*, void*); using PrintWithContextFn = void (*)(YGNode*, void*);
private: private:
@@ -64,7 +64,7 @@ private:
YGFloatOptional relativePosition( YGFloatOptional relativePosition(
const YGFlexDirection axis, const YGFlexDirection axis,
const float axisSize) const; const YGFloat axisSize) const;
void setMeasureFunc(decltype(measure_)); void setMeasureFunc(decltype(measure_));
void setBaselineFunc(decltype(baseline_)); void setBaselineFunc(decltype(baseline_));
@@ -124,13 +124,13 @@ public:
bool hasMeasureFunc() const noexcept { return measure_.noContext != nullptr; } bool hasMeasureFunc() const noexcept { return measure_.noContext != nullptr; }
YGSize measure(float, YGMeasureMode, float, YGMeasureMode, void*); YGSize measure(YGFloat, YGMeasureMode, YGFloat, YGMeasureMode, void*);
bool hasBaselineFunc() const noexcept { bool hasBaselineFunc() const noexcept {
return baseline_.noContext != nullptr; return baseline_.noContext != nullptr;
} }
float baseline(float width, float height, void* layoutContext); YGFloat baseline(YGFloat width, YGFloat height, void* layoutContext);
YGDirtiedFunc getDirtied() const { return dirtied_; } YGDirtiedFunc getDirtied() const { return dirtied_; }
@@ -196,35 +196,35 @@ public:
// Methods related to positions, margin, padding and border // Methods related to positions, margin, padding and border
YGFloatOptional getLeadingPosition( YGFloatOptional getLeadingPosition(
const YGFlexDirection axis, const YGFlexDirection axis,
const float axisSize) const; const YGFloat axisSize) const;
bool isLeadingPositionDefined(const YGFlexDirection axis) const; bool isLeadingPositionDefined(const YGFlexDirection axis) const;
bool isTrailingPosDefined(const YGFlexDirection axis) const; bool isTrailingPosDefined(const YGFlexDirection axis) const;
YGFloatOptional getTrailingPosition( YGFloatOptional getTrailingPosition(
const YGFlexDirection axis, const YGFlexDirection axis,
const float axisSize) const; const YGFloat axisSize) const;
YGFloatOptional getLeadingMargin( YGFloatOptional getLeadingMargin(
const YGFlexDirection axis, const YGFlexDirection axis,
const float widthSize) const; const YGFloat widthSize) const;
YGFloatOptional getTrailingMargin( YGFloatOptional getTrailingMargin(
const YGFlexDirection axis, const YGFlexDirection axis,
const float widthSize) const; const YGFloat widthSize) const;
float getLeadingBorder(const YGFlexDirection flexDirection) const; YGFloat getLeadingBorder(const YGFlexDirection flexDirection) const;
float getTrailingBorder(const YGFlexDirection flexDirection) const; YGFloat getTrailingBorder(const YGFlexDirection flexDirection) const;
YGFloatOptional getLeadingPadding( YGFloatOptional getLeadingPadding(
const YGFlexDirection axis, const YGFlexDirection axis,
const float widthSize) const; const YGFloat widthSize) const;
YGFloatOptional getTrailingPadding( YGFloatOptional getTrailingPadding(
const YGFlexDirection axis, const YGFlexDirection axis,
const float widthSize) const; const YGFloat widthSize) const;
YGFloatOptional getLeadingPaddingAndBorder( YGFloatOptional getLeadingPaddingAndBorder(
const YGFlexDirection axis, const YGFlexDirection axis,
const float widthSize) const; const YGFloat widthSize) const;
YGFloatOptional getTrailingPaddingAndBorder( YGFloatOptional getTrailingPaddingAndBorder(
const YGFlexDirection axis, const YGFlexDirection axis,
const float widthSize) const; const YGFloat widthSize) const;
YGFloatOptional getMarginForAxis( YGFloatOptional getMarginForAxis(
const YGFlexDirection axis, const YGFlexDirection axis,
const float widthSize) const; const YGFloat widthSize) const;
// Setters // Setters
void setContext(void* context) { context_ = context; } void setContext(void* context) { context_ = context; }
@@ -292,19 +292,19 @@ public:
void setLayoutComputedFlexBasis(const YGFloatOptional computedFlexBasis); void setLayoutComputedFlexBasis(const YGFloatOptional computedFlexBasis);
void setLayoutComputedFlexBasisGeneration( void setLayoutComputedFlexBasisGeneration(
uint32_t computedFlexBasisGeneration); uint32_t computedFlexBasisGeneration);
void setLayoutMeasuredDimension(float measuredDimension, int index); void setLayoutMeasuredDimension(YGFloat measuredDimension, int index);
void setLayoutHadOverflow(bool hadOverflow); void setLayoutHadOverflow(bool hadOverflow);
void setLayoutDimension(float dimension, int index); void setLayoutDimension(YGFloat dimension, int index);
void setLayoutDirection(YGDirection direction); void setLayoutDirection(YGDirection direction);
void setLayoutMargin(float margin, int index); void setLayoutMargin(YGFloat margin, int index);
void setLayoutBorder(float border, int index); void setLayoutBorder(YGFloat border, int index);
void setLayoutPadding(float padding, int index); void setLayoutPadding(YGFloat padding, int index);
void setLayoutPosition(float position, int index); void setLayoutPosition(YGFloat position, int index);
void setPosition( void setPosition(
const YGDirection direction, const YGDirection direction,
const float mainSize, const YGFloat mainSize,
const float crossSize, const YGFloat crossSize,
const float ownerWidth); const YGFloat ownerWidth);
void setLayoutDoesLegacyFlagAffectsLayout(bool doesLegacyFlagAffectsLayout); void setLayoutDoesLegacyFlagAffectsLayout(bool doesLegacyFlagAffectsLayout);
void setLayoutDidUseLegacyFlag(bool didUseLegacyFlag); void setLayoutDidUseLegacyFlag(bool didUseLegacyFlag);
void markDirtyAndPropogateDownwards(); void markDirtyAndPropogateDownwards();
@@ -326,8 +326,8 @@ public:
void cloneChildrenIfNeeded(void*); void cloneChildrenIfNeeded(void*);
void markDirtyAndPropogate(); void markDirtyAndPropogate();
float resolveFlexGrow() const; YGFloat resolveFlexGrow() const;
float resolveFlexShrink() const; YGFloat resolveFlexShrink() const;
bool isNodeFlexible(); bool isNodeFlexible();
bool didUseLegacyFlag(); bool didUseLegacyFlag();
bool isLayoutTreeEqualToNode(const YGNode& node) const; bool isLayoutTreeEqualToNode(const YGNode& node) const;

View File

@@ -25,7 +25,7 @@ YG_EXTERN_C_BEGIN
// Not defined in MSVC++ // Not defined in MSVC++
#ifndef NAN #ifndef NAN
static const uint32_t __nan = 0x7fc00000; static const uint32_t __nan = 0x7fc00000;
#define NAN (*(const float*) __nan) #define NAN (*(const YGFloat*) __nan)
#endif #endif
#define YGUndefined NAN #define YGUndefined NAN

View File

@@ -19,8 +19,8 @@ YG_EXTERN_C_BEGIN
void YGNodeCalculateLayoutWithContext( void YGNodeCalculateLayoutWithContext(
YGNodeRef node, YGNodeRef node,
float availableWidth, YGFloat availableWidth,
float availableHeight, YGFloat availableHeight,
YGDirection ownerDirection, YGDirection ownerDirection,
void* layoutContext); void* layoutContext);
@@ -29,7 +29,7 @@ YG_EXTERN_C_END
namespace facebook { namespace facebook {
namespace yoga { namespace yoga {
inline bool isUndefined(float value) { inline bool isUndefined(YGFloat value) {
return std::isnan(value); return std::isnan(value);
} }
@@ -45,13 +45,13 @@ extern const YGValue YGValueAuto;
extern const YGValue YGValueZero; extern const YGValue YGValueZero;
struct YGCachedMeasurement { struct YGCachedMeasurement {
float availableWidth; YGFloat availableWidth;
float availableHeight; YGFloat availableHeight;
YGMeasureMode widthMeasureMode; YGMeasureMode widthMeasureMode;
YGMeasureMode heightMeasureMode; YGMeasureMode heightMeasureMode;
float computedWidth; YGFloat computedWidth;
float computedHeight; YGFloat computedHeight;
YGCachedMeasurement() YGCachedMeasurement()
: availableWidth(-1), : availableWidth(-1),
@@ -139,11 +139,11 @@ public:
} // namespace yoga } // namespace yoga
} // namespace facebook } // namespace facebook
static const float kDefaultFlexGrow = 0.0f; static const YGFloat kDefaultFlexGrow = 0.0f;
static const float kDefaultFlexShrink = 0.0f; static const YGFloat kDefaultFlexShrink = 0.0f;
static const float kWebDefaultFlexShrink = 1.0f; static const YGFloat kWebDefaultFlexShrink = 1.0f;
extern bool YGFloatsEqual(const float a, const float b); extern bool YGFloatsEqual(const YGFloat a, const YGFloat b);
extern facebook::yoga::detail::CompactValue YGComputedEdgeValue( extern facebook::yoga::detail::CompactValue YGComputedEdgeValue(
const facebook::yoga::detail::Values< const facebook::yoga::detail::Values<
facebook::yoga::enums::count<YGEdge>()>& edges, facebook::yoga::enums::count<YGEdge>()>& edges,

File diff suppressed because it is too large Load Diff

View File

@@ -25,8 +25,8 @@
YG_EXTERN_C_BEGIN YG_EXTERN_C_BEGIN
typedef struct YGSize { typedef struct YGSize {
float width; YGFloat width;
float height; YGFloat height;
} YGSize; } YGSize;
typedef struct YGConfig* YGConfigRef; typedef struct YGConfig* YGConfigRef;
@@ -36,11 +36,11 @@ typedef const struct YGNode* YGNodeConstRef;
typedef YGSize (*YGMeasureFunc)( typedef YGSize (*YGMeasureFunc)(
YGNodeRef node, YGNodeRef node,
float width, YGFloat width,
YGMeasureMode widthMode, YGMeasureMode widthMode,
float height, YGFloat height,
YGMeasureMode heightMode); YGMeasureMode heightMode);
typedef float (*YGBaselineFunc)(YGNodeRef node, float width, float height); typedef YGFloat (*YGBaselineFunc)(YGNodeRef node, YGFloat width, YGFloat height);
typedef void (*YGDirtiedFunc)(YGNodeRef node); typedef void (*YGDirtiedFunc)(YGNodeRef node);
typedef void (*YGPrintFunc)(YGNodeRef node); typedef void (*YGPrintFunc)(YGNodeRef node);
typedef void (*YGNodeCleanupFunc)(YGNodeRef node); typedef void (*YGNodeCleanupFunc)(YGNodeRef node);
@@ -93,8 +93,8 @@ WIN_EXPORT bool YGNodeIsReferenceBaseline(YGNodeRef node);
WIN_EXPORT void YGNodeCalculateLayout( WIN_EXPORT void YGNodeCalculateLayout(
YGNodeRef node, YGNodeRef node,
float availableWidth, YGFloat availableWidth,
float availableHeight, YGFloat availableHeight,
YGDirection ownerDirection); YGDirection ownerDirection);
// Mark a node as dirty. Only valid for nodes with a custom measure function // Mark a node as dirty. Only valid for nodes with a custom measure function
@@ -113,21 +113,21 @@ WIN_EXPORT void YGNodeMarkDirtyAndPropogateToDescendants(YGNodeRef node);
WIN_EXPORT void YGNodePrint(YGNodeRef node, YGPrintOptions options); WIN_EXPORT void YGNodePrint(YGNodeRef node, YGPrintOptions options);
WIN_EXPORT bool YGFloatIsUndefined(float value); WIN_EXPORT bool YGFloatIsUndefined(YGFloat value);
WIN_EXPORT bool YGNodeCanUseCachedMeasurement( WIN_EXPORT bool YGNodeCanUseCachedMeasurement(
YGMeasureMode widthMode, YGMeasureMode widthMode,
float width, YGFloat width,
YGMeasureMode heightMode, YGMeasureMode heightMode,
float height, YGFloat height,
YGMeasureMode lastWidthMode, YGMeasureMode lastWidthMode,
float lastWidth, YGFloat lastWidth,
YGMeasureMode lastHeightMode, YGMeasureMode lastHeightMode,
float lastHeight, YGFloat lastHeight,
float lastComputedWidth, YGFloat lastComputedWidth,
float lastComputedHeight, YGFloat lastComputedHeight,
float marginRow, YGFloat marginRow,
float marginColumn, YGFloat marginColumn,
YGConfigRef config); YGConfigRef config);
WIN_EXPORT void YGNodeCopyStyle(YGNodeRef dstNode, YGNodeRef srcNode); WIN_EXPORT void YGNodeCopyStyle(YGNodeRef dstNode, YGNodeRef srcNode);
@@ -187,75 +187,75 @@ WIN_EXPORT YGOverflow YGNodeStyleGetOverflow(YGNodeConstRef node);
WIN_EXPORT void YGNodeStyleSetDisplay(YGNodeRef node, YGDisplay display); WIN_EXPORT void YGNodeStyleSetDisplay(YGNodeRef node, YGDisplay display);
WIN_EXPORT YGDisplay YGNodeStyleGetDisplay(YGNodeConstRef node); WIN_EXPORT YGDisplay YGNodeStyleGetDisplay(YGNodeConstRef node);
WIN_EXPORT void YGNodeStyleSetFlex(YGNodeRef node, float flex); WIN_EXPORT void YGNodeStyleSetFlex(YGNodeRef node, YGFloat flex);
WIN_EXPORT float YGNodeStyleGetFlex(YGNodeConstRef node); WIN_EXPORT YGFloat YGNodeStyleGetFlex(YGNodeConstRef node);
WIN_EXPORT void YGNodeStyleSetFlexGrow(YGNodeRef node, float flexGrow); WIN_EXPORT void YGNodeStyleSetFlexGrow(YGNodeRef node, YGFloat flexGrow);
WIN_EXPORT float YGNodeStyleGetFlexGrow(YGNodeConstRef node); WIN_EXPORT YGFloat YGNodeStyleGetFlexGrow(YGNodeConstRef node);
WIN_EXPORT void YGNodeStyleSetFlexShrink(YGNodeRef node, float flexShrink); WIN_EXPORT void YGNodeStyleSetFlexShrink(YGNodeRef node, YGFloat flexShrink);
WIN_EXPORT float YGNodeStyleGetFlexShrink(YGNodeConstRef node); WIN_EXPORT YGFloat YGNodeStyleGetFlexShrink(YGNodeConstRef node);
WIN_EXPORT void YGNodeStyleSetFlexBasis(YGNodeRef node, float flexBasis); WIN_EXPORT void YGNodeStyleSetFlexBasis(YGNodeRef node, YGFloat flexBasis);
WIN_EXPORT void YGNodeStyleSetFlexBasisPercent(YGNodeRef node, float flexBasis); WIN_EXPORT void YGNodeStyleSetFlexBasisPercent(YGNodeRef node, YGFloat flexBasis);
WIN_EXPORT void YGNodeStyleSetFlexBasisAuto(YGNodeRef node); WIN_EXPORT void YGNodeStyleSetFlexBasisAuto(YGNodeRef node);
WIN_EXPORT YGValue YGNodeStyleGetFlexBasis(YGNodeConstRef node); WIN_EXPORT YGValue YGNodeStyleGetFlexBasis(YGNodeConstRef node);
WIN_EXPORT void YGNodeStyleSetPosition( WIN_EXPORT void YGNodeStyleSetPosition(
YGNodeRef node, YGNodeRef node,
YGEdge edge, YGEdge edge,
float position); YGFloat position);
WIN_EXPORT void YGNodeStyleSetPositionPercent( WIN_EXPORT void YGNodeStyleSetPositionPercent(
YGNodeRef node, YGNodeRef node,
YGEdge edge, YGEdge edge,
float position); YGFloat position);
WIN_EXPORT YGValue YGNodeStyleGetPosition(YGNodeConstRef node, YGEdge edge); WIN_EXPORT YGValue YGNodeStyleGetPosition(YGNodeConstRef node, YGEdge edge);
WIN_EXPORT void YGNodeStyleSetMargin(YGNodeRef node, YGEdge edge, float margin); WIN_EXPORT void YGNodeStyleSetMargin(YGNodeRef node, YGEdge edge, YGFloat margin);
WIN_EXPORT void YGNodeStyleSetMarginPercent( WIN_EXPORT void YGNodeStyleSetMarginPercent(
YGNodeRef node, YGNodeRef node,
YGEdge edge, YGEdge edge,
float margin); YGFloat margin);
WIN_EXPORT void YGNodeStyleSetMarginAuto(YGNodeRef node, YGEdge edge); WIN_EXPORT void YGNodeStyleSetMarginAuto(YGNodeRef node, YGEdge edge);
WIN_EXPORT YGValue YGNodeStyleGetMargin(YGNodeConstRef node, YGEdge edge); WIN_EXPORT YGValue YGNodeStyleGetMargin(YGNodeConstRef node, YGEdge edge);
WIN_EXPORT void YGNodeStyleSetPadding( WIN_EXPORT void YGNodeStyleSetPadding(
YGNodeRef node, YGNodeRef node,
YGEdge edge, YGEdge edge,
float padding); YGFloat padding);
WIN_EXPORT void YGNodeStyleSetPaddingPercent( WIN_EXPORT void YGNodeStyleSetPaddingPercent(
YGNodeRef node, YGNodeRef node,
YGEdge edge, YGEdge edge,
float padding); YGFloat padding);
WIN_EXPORT YGValue YGNodeStyleGetPadding(YGNodeConstRef node, YGEdge edge); WIN_EXPORT YGValue YGNodeStyleGetPadding(YGNodeConstRef node, YGEdge edge);
WIN_EXPORT void YGNodeStyleSetBorder(YGNodeRef node, YGEdge edge, float border); WIN_EXPORT void YGNodeStyleSetBorder(YGNodeRef node, YGEdge edge, YGFloat border);
WIN_EXPORT float YGNodeStyleGetBorder(YGNodeConstRef node, YGEdge edge); WIN_EXPORT YGFloat YGNodeStyleGetBorder(YGNodeConstRef node, YGEdge edge);
WIN_EXPORT void YGNodeStyleSetWidth(YGNodeRef node, float width); WIN_EXPORT void YGNodeStyleSetWidth(YGNodeRef node, YGFloat width);
WIN_EXPORT void YGNodeStyleSetWidthPercent(YGNodeRef node, float width); WIN_EXPORT void YGNodeStyleSetWidthPercent(YGNodeRef node, YGFloat width);
WIN_EXPORT void YGNodeStyleSetWidthAuto(YGNodeRef node); WIN_EXPORT void YGNodeStyleSetWidthAuto(YGNodeRef node);
WIN_EXPORT YGValue YGNodeStyleGetWidth(YGNodeConstRef node); WIN_EXPORT YGValue YGNodeStyleGetWidth(YGNodeConstRef node);
WIN_EXPORT void YGNodeStyleSetHeight(YGNodeRef node, float height); WIN_EXPORT void YGNodeStyleSetHeight(YGNodeRef node, YGFloat height);
WIN_EXPORT void YGNodeStyleSetHeightPercent(YGNodeRef node, float height); WIN_EXPORT void YGNodeStyleSetHeightPercent(YGNodeRef node, YGFloat height);
WIN_EXPORT void YGNodeStyleSetHeightAuto(YGNodeRef node); WIN_EXPORT void YGNodeStyleSetHeightAuto(YGNodeRef node);
WIN_EXPORT YGValue YGNodeStyleGetHeight(YGNodeConstRef node); WIN_EXPORT YGValue YGNodeStyleGetHeight(YGNodeConstRef node);
WIN_EXPORT void YGNodeStyleSetMinWidth(YGNodeRef node, float minWidth); WIN_EXPORT void YGNodeStyleSetMinWidth(YGNodeRef node, YGFloat minWidth);
WIN_EXPORT void YGNodeStyleSetMinWidthPercent(YGNodeRef node, float minWidth); WIN_EXPORT void YGNodeStyleSetMinWidthPercent(YGNodeRef node, YGFloat minWidth);
WIN_EXPORT YGValue YGNodeStyleGetMinWidth(YGNodeConstRef node); WIN_EXPORT YGValue YGNodeStyleGetMinWidth(YGNodeConstRef node);
WIN_EXPORT void YGNodeStyleSetMinHeight(YGNodeRef node, float minHeight); WIN_EXPORT void YGNodeStyleSetMinHeight(YGNodeRef node, YGFloat minHeight);
WIN_EXPORT void YGNodeStyleSetMinHeightPercent(YGNodeRef node, float minHeight); WIN_EXPORT void YGNodeStyleSetMinHeightPercent(YGNodeRef node, YGFloat minHeight);
WIN_EXPORT YGValue YGNodeStyleGetMinHeight(YGNodeConstRef node); WIN_EXPORT YGValue YGNodeStyleGetMinHeight(YGNodeConstRef node);
WIN_EXPORT void YGNodeStyleSetMaxWidth(YGNodeRef node, float maxWidth); WIN_EXPORT void YGNodeStyleSetMaxWidth(YGNodeRef node, YGFloat maxWidth);
WIN_EXPORT void YGNodeStyleSetMaxWidthPercent(YGNodeRef node, float maxWidth); WIN_EXPORT void YGNodeStyleSetMaxWidthPercent(YGNodeRef node, YGFloat maxWidth);
WIN_EXPORT YGValue YGNodeStyleGetMaxWidth(YGNodeConstRef node); WIN_EXPORT YGValue YGNodeStyleGetMaxWidth(YGNodeConstRef node);
WIN_EXPORT void YGNodeStyleSetMaxHeight(YGNodeRef node, float maxHeight); WIN_EXPORT void YGNodeStyleSetMaxHeight(YGNodeRef node, YGFloat maxHeight);
WIN_EXPORT void YGNodeStyleSetMaxHeightPercent(YGNodeRef node, float maxHeight); WIN_EXPORT void YGNodeStyleSetMaxHeightPercent(YGNodeRef node, YGFloat maxHeight);
WIN_EXPORT YGValue YGNodeStyleGetMaxHeight(YGNodeConstRef node); WIN_EXPORT YGValue YGNodeStyleGetMaxHeight(YGNodeConstRef node);
// Yoga specific properties, not compatible with flexbox specification Aspect // Yoga specific properties, not compatible with flexbox specification Aspect
@@ -273,15 +273,15 @@ WIN_EXPORT YGValue YGNodeStyleGetMaxHeight(YGNodeConstRef node);
// - On a node with flex grow/shrink aspect ratio controls the size of the node // - On a node with flex grow/shrink aspect ratio controls the size of the node
// in the cross axis if unset // in the cross axis if unset
// - Aspect ratio takes min/max dimensions into account // - Aspect ratio takes min/max dimensions into account
WIN_EXPORT void YGNodeStyleSetAspectRatio(YGNodeRef node, float aspectRatio); WIN_EXPORT void YGNodeStyleSetAspectRatio(YGNodeRef node, YGFloat aspectRatio);
WIN_EXPORT float YGNodeStyleGetAspectRatio(YGNodeConstRef node); WIN_EXPORT YGFloat YGNodeStyleGetAspectRatio(YGNodeConstRef node);
WIN_EXPORT float YGNodeLayoutGetLeft(YGNodeRef node); WIN_EXPORT YGFloat YGNodeLayoutGetLeft(YGNodeRef node);
WIN_EXPORT float YGNodeLayoutGetTop(YGNodeRef node); WIN_EXPORT YGFloat YGNodeLayoutGetTop(YGNodeRef node);
WIN_EXPORT float YGNodeLayoutGetRight(YGNodeRef node); WIN_EXPORT YGFloat YGNodeLayoutGetRight(YGNodeRef node);
WIN_EXPORT float YGNodeLayoutGetBottom(YGNodeRef node); WIN_EXPORT YGFloat YGNodeLayoutGetBottom(YGNodeRef node);
WIN_EXPORT float YGNodeLayoutGetWidth(YGNodeRef node); WIN_EXPORT YGFloat YGNodeLayoutGetWidth(YGNodeRef node);
WIN_EXPORT float YGNodeLayoutGetHeight(YGNodeRef node); WIN_EXPORT YGFloat YGNodeLayoutGetHeight(YGNodeRef node);
WIN_EXPORT YGDirection YGNodeLayoutGetDirection(YGNodeRef node); WIN_EXPORT YGDirection YGNodeLayoutGetDirection(YGNodeRef node);
WIN_EXPORT bool YGNodeLayoutGetHadOverflow(YGNodeRef node); WIN_EXPORT bool YGNodeLayoutGetHadOverflow(YGNodeRef node);
bool YGNodeLayoutGetDidLegacyStretchFlagAffectLayout(YGNodeRef node); bool YGNodeLayoutGetDidLegacyStretchFlagAffectLayout(YGNodeRef node);
@@ -290,9 +290,9 @@ bool YGNodeLayoutGetDidLegacyStretchFlagAffectLayout(YGNodeRef node);
// set using point values then the returned value will be the same as // set using point values then the returned value will be the same as
// YGNodeStyleGetXXX. However if they were set using a percentage value then the // YGNodeStyleGetXXX. However if they were set using a percentage value then the
// returned value is the computed value used during layout. // returned value is the computed value used during layout.
WIN_EXPORT float YGNodeLayoutGetMargin(YGNodeRef node, YGEdge edge); WIN_EXPORT YGFloat YGNodeLayoutGetMargin(YGNodeRef node, YGEdge edge);
WIN_EXPORT float YGNodeLayoutGetBorder(YGNodeRef node, YGEdge edge); WIN_EXPORT YGFloat YGNodeLayoutGetBorder(YGNodeRef node, YGEdge edge);
WIN_EXPORT float YGNodeLayoutGetPadding(YGNodeRef node, YGEdge edge); WIN_EXPORT YGFloat YGNodeLayoutGetPadding(YGNodeRef node, YGEdge edge);
WIN_EXPORT void YGConfigSetLogger(YGConfigRef config, YGLogger logger); WIN_EXPORT void YGConfigSetLogger(YGConfigRef config, YGLogger logger);
WIN_EXPORT void YGAssert(bool condition, const char* message); WIN_EXPORT void YGAssert(bool condition, const char* message);
@@ -308,7 +308,7 @@ WIN_EXPORT void YGAssertWithConfig(
// want to avoid rounding - set PointScaleFactor to 0 // want to avoid rounding - set PointScaleFactor to 0
WIN_EXPORT void YGConfigSetPointScaleFactor( WIN_EXPORT void YGConfigSetPointScaleFactor(
YGConfigRef config, YGConfigRef config,
float pixelsInPoint); YGFloat pixelsInPoint);
void YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour( void YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour(
YGConfigRef config, YGConfigRef config,
bool shouldDiffLayout); bool shouldDiffLayout);
@@ -351,7 +351,7 @@ WIN_EXPORT YGConfigRef YGConfigGetDefault(void);
WIN_EXPORT void YGConfigSetContext(YGConfigRef config, void* context); WIN_EXPORT void YGConfigSetContext(YGConfigRef config, void* context);
WIN_EXPORT void* YGConfigGetContext(YGConfigRef config); WIN_EXPORT void* YGConfigGetContext(YGConfigRef config);
WIN_EXPORT float YGRoundValueToPixelGrid( WIN_EXPORT YGFloat YGRoundValueToPixelGrid(
double value, double value,
double pointScaleFactor, double pointScaleFactor,
bool forceCeil, bool forceCeil,

View File

@@ -127,12 +127,12 @@ struct Event::TypedData<Event::LayoutPassEnd> {
template <> template <>
struct Event::TypedData<Event::MeasureCallbackEnd> { struct Event::TypedData<Event::MeasureCallbackEnd> {
void* layoutContext; void* layoutContext;
float width; YGFloat width;
YGMeasureMode widthMeasureMode; YGMeasureMode widthMeasureMode;
float height; YGFloat height;
YGMeasureMode heightMeasureMode; YGMeasureMode heightMeasureMode;
float measuredWidth; YGFloat measuredWidth;
float measuredHeight; YGFloat measuredHeight;
const LayoutPassReason reason; const LayoutPassReason reason;
}; };