forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move YGStyle to seperate file and add constructors
Reviewed By: emilsjolander Differential Revision: D7016575 fbshipit-source-id: eb28df0ffb4cc813b23edaff80d7d4ebc56ce6af
- Loading branch information
1 parent
973ef97
commit b9991d3
Showing
7 changed files
with
153 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
|
||
#pragma once | ||
#include <stdio.h> | ||
|
||
#include "YGStyle.h" | ||
#include "Yoga-internal.h" | ||
|
||
struct YGNode { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/** | ||
* Copyright (c) 2014-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
#include "YGStyle.h" | ||
|
||
YGStyle::YGStyle() | ||
: direction(YGDirectionInherit), | ||
flexDirection(YGFlexDirectionColumn), | ||
justifyContent(YGJustifyFlexStart), | ||
alignContent(YGAlignFlexStart), | ||
alignItems(YGAlignStretch), | ||
alignSelf(YGAlignAuto), | ||
positionType(YGPositionTypeRelative), | ||
flexWrap(YGWrapNoWrap), | ||
overflow(YGOverflowVisible), | ||
display(YGDisplayFlex), | ||
flex(YGUndefined), | ||
flexGrow(YGUndefined), | ||
flexShrink(YGUndefined), | ||
flexBasis(kYGValueAuto), | ||
margin(kYGDefaultEdgeValuesUnit), | ||
position(kYGDefaultEdgeValuesUnit), | ||
padding(kYGDefaultEdgeValuesUnit), | ||
border(kYGDefaultEdgeValuesUnit), | ||
dimensions(kYGDefaultDimensionValuesAutoUnit), | ||
minDimensions(kYGDefaultDimensionValuesUnit), | ||
maxDimensions(kYGDefaultDimensionValuesUnit), | ||
aspectRatio(YGUndefined) {} | ||
|
||
// Yoga specific properties, not compatible with flexbox specification | ||
bool YGStyle::operator==(const YGStyle& style) { | ||
bool areNonFloatValuesEqual = direction == style.direction && | ||
flexDirection == style.flexDirection && | ||
justifyContent == style.justifyContent && | ||
alignContent == style.alignContent && alignItems == style.alignItems && | ||
alignSelf == style.alignSelf && positionType == style.positionType && | ||
flexWrap == style.flexWrap && overflow == style.overflow && | ||
display == style.display && YGValueEqual(flexBasis, style.flexBasis) && | ||
YGValueArrayEqual(margin, style.margin) && | ||
YGValueArrayEqual(position, style.position) && | ||
YGValueArrayEqual(padding, style.padding) && | ||
YGValueArrayEqual(border, style.border) && | ||
YGValueArrayEqual(dimensions, style.dimensions) && | ||
YGValueArrayEqual(minDimensions, style.minDimensions) && | ||
YGValueArrayEqual(maxDimensions, style.maxDimensions); | ||
|
||
if (!(std::isnan(flex) && std::isnan(style.flex))) { | ||
areNonFloatValuesEqual = areNonFloatValuesEqual && flex == style.flex; | ||
} | ||
|
||
if (!(std::isnan(flexGrow) && std::isnan(style.flexGrow))) { | ||
areNonFloatValuesEqual = | ||
areNonFloatValuesEqual && flexGrow == style.flexGrow; | ||
} | ||
|
||
if (!(std::isnan(flexShrink) && std::isnan(style.flexShrink))) { | ||
areNonFloatValuesEqual = | ||
areNonFloatValuesEqual && flexShrink == style.flexShrink; | ||
} | ||
|
||
if (!(std::isnan(aspectRatio) && std::isnan(style.aspectRatio))) { | ||
areNonFloatValuesEqual = | ||
areNonFloatValuesEqual && aspectRatio == style.aspectRatio; | ||
} | ||
|
||
return areNonFloatValuesEqual; | ||
} | ||
|
||
bool YGStyle::operator!=(YGStyle style) { | ||
return !(*this == style); | ||
} | ||
|
||
YGStyle::~YGStyle() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* Copyright (c) 2014-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
#pragma once | ||
#include "Yoga-internal.h" | ||
#include "Yoga.h" | ||
|
||
struct YGStyle { | ||
YGDirection direction; | ||
YGFlexDirection flexDirection; | ||
YGJustify justifyContent; | ||
YGAlign alignContent; | ||
YGAlign alignItems; | ||
YGAlign alignSelf; | ||
YGPositionType positionType; | ||
YGWrap flexWrap; | ||
YGOverflow overflow; | ||
YGDisplay display; | ||
float flex; | ||
float flexGrow; | ||
float flexShrink; | ||
YGValue flexBasis; | ||
std::array<YGValue, YGEdgeCount> margin; | ||
std::array<YGValue, YGEdgeCount> position; | ||
std::array<YGValue, YGEdgeCount> padding; | ||
std::array<YGValue, YGEdgeCount> border; | ||
std::array<YGValue, 2> dimensions; | ||
std::array<YGValue, 2> minDimensions; | ||
std::array<YGValue, 2> maxDimensions; | ||
float aspectRatio; | ||
|
||
YGStyle(); | ||
// Yoga specific properties, not compatible with flexbox specification | ||
bool operator==(const YGStyle& style); | ||
|
||
bool operator!=(YGStyle style); | ||
~YGStyle(); | ||
}; |
Oops, something went wrong.