Rename YGUnitPixel to YGPoint... #375
@@ -25,7 +25,7 @@
|
||||
- (CGFloat)lowercased_name \
|
||||
{ \
|
||||
YGValue value = YGNodeStyleGet##capitalized_name(self.node); \
|
||||
if (value.unit == YGUnitPixel) { \
|
||||
if (value.unit == YGUnitPoint) { \
|
||||
return value.value; \
|
||||
} else { \
|
||||
return YGUndefined; \
|
||||
@@ -67,7 +67,7 @@ YG_EDGE_PROPERTY_SETTER(lowercased_name, capitalized_name, property, edge)
|
||||
- (CGFloat)objc_lowercased_name \
|
||||
{ \
|
||||
YGValue value = YGNodeStyleGet##c_name(self.node, edge); \
|
||||
if (value.unit == YGUnitPixel) { \
|
||||
if (value.unit == YGUnitPoint) { \
|
||||
return value.value; \
|
||||
} else { \
|
||||
return YGUndefined; \
|
||||
@@ -353,7 +353,7 @@ static void YGRemoveAllChildren(const YGNodeRef node)
|
||||
}
|
||||
}
|
||||
|
||||
static CGFloat YGRoundPixelValue(CGFloat value)
|
||||
static CGFloat YGRoundPointValue(CGFloat value)
|
||||
{
|
||||
static CGFloat scale;
|
||||
static dispatch_once_t onceToken;
|
||||
@@ -387,12 +387,12 @@ static void YGApplyLayoutToViewHierarchy(UIView *view)
|
||||
|
||||
view.frame = (CGRect) {
|
||||
.origin = {
|
||||
.x = YGRoundPixelValue(topLeft.x),
|
||||
.y = YGRoundPixelValue(topLeft.y),
|
||||
.x = YGRoundPointValue(topLeft.x),
|
||||
.y = YGRoundPointValue(topLeft.y),
|
||||
},
|
||||
.size = {
|
||||
.width = YGRoundPixelValue(bottomRight.x) - YGRoundPixelValue(topLeft.x),
|
||||
.height = YGRoundPixelValue(bottomRight.y) - YGRoundPixelValue(topLeft.y),
|
||||
.width = YGRoundPointValue(bottomRight.x) - YGRoundPointValue(topLeft.x),
|
||||
.height = YGRoundPointValue(bottomRight.y) - YGRoundPointValue(topLeft.y),
|
||||
},
|
||||
};
|
||||
|
||||
|
@@ -417,32 +417,32 @@
|
||||
|
||||
view.yoga.left = 1;
|
||||
XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeLeft).value, 1);
|
||||
XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeLeft).unit, YGUnitPixel);
|
||||
XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeLeft).unit, YGUnitPoint);
|
||||
XCTAssertEqual(view.yoga.left, 1);
|
||||
|
||||
view.yoga.right = 2;
|
||||
XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeRight).value, 2);
|
||||
XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeRight).unit, YGUnitPixel);
|
||||
XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeRight).unit, YGUnitPoint);
|
||||
XCTAssertEqual(view.yoga.right, 2);
|
||||
|
||||
view.yoga.top = 3;
|
||||
XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeTop).value, 3);
|
||||
XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeTop).unit, YGUnitPixel);
|
||||
XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeTop).unit, YGUnitPoint);
|
||||
XCTAssertEqual(view.yoga.top, 3);
|
||||
|
||||
view.yoga.bottom = 4;
|
||||
XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeBottom).value, 4);
|
||||
XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeBottom).unit, YGUnitPixel);
|
||||
XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeBottom).unit, YGUnitPoint);
|
||||
XCTAssertEqual(view.yoga.bottom, 4);
|
||||
|
||||
view.yoga.start = 5;
|
||||
XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeStart).value, 5);
|
||||
XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeStart).unit, YGUnitPixel);
|
||||
XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeStart).unit, YGUnitPoint);
|
||||
XCTAssertEqual(view.yoga.start, 5);
|
||||
|
||||
view.yoga.end = 6;
|
||||
XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeEnd).value, 6);
|
||||
XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeEnd).unit, YGUnitPixel);
|
||||
XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeEnd).unit, YGUnitPoint);
|
||||
XCTAssertEqual(view.yoga.end, 6);
|
||||
}
|
||||
|
||||
@@ -452,67 +452,67 @@
|
||||
|
||||
view.yoga.margin = 1;
|
||||
XCTAssertEqual(view.yoga.marginLeft, 1);
|
||||
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeLeft).unit, YGUnitPixel);
|
||||
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeLeft).unit, YGUnitPoint);
|
||||
XCTAssertEqual(view.yoga.marginRight, 1);
|
||||
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeRight).unit, YGUnitPixel);
|
||||
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeRight).unit, YGUnitPoint);
|
||||
XCTAssertEqual(view.yoga.marginStart, 1);
|
||||
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeStart).unit, YGUnitPixel);
|
||||
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeStart).unit, YGUnitPoint);
|
||||
XCTAssertEqual(view.yoga.marginEnd, 1);
|
||||
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeEnd).unit, YGUnitPixel);
|
||||
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeEnd).unit, YGUnitPoint);
|
||||
XCTAssertEqual(view.yoga.marginTop, 1);
|
||||
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeTop).unit, YGUnitPixel);
|
||||
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeTop).unit, YGUnitPoint);
|
||||
XCTAssertEqual(view.yoga.marginBottom, 1);
|
||||
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeBottom).unit, YGUnitPixel);
|
||||
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeBottom).unit, YGUnitPoint);
|
||||
XCTAssertTrue(isnan(view.yoga.marginHorizontal));
|
||||
XCTAssertTrue(isnan(view.yoga.marginVertical));
|
||||
XCTAssertTrue(isnan(view.yoga.margin));
|
||||
|
||||
view.yoga.marginHorizontal = 2;
|
||||
XCTAssertEqual(view.yoga.marginLeft, 2);
|
||||
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeLeft).unit, YGUnitPixel);
|
||||
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeLeft).unit, YGUnitPoint);
|
||||
XCTAssertEqual(view.yoga.marginRight, 2);
|
||||
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeRight).unit, YGUnitPixel);
|
||||
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeRight).unit, YGUnitPoint);
|
||||
XCTAssertEqual(view.yoga.marginStart, 2);
|
||||
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeStart).unit, YGUnitPixel);
|
||||
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeStart).unit, YGUnitPoint);
|
||||
XCTAssertEqual(view.yoga.marginEnd, 2);
|
||||
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeEnd).unit, YGUnitPixel);
|
||||
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeEnd).unit, YGUnitPoint);
|
||||
XCTAssertTrue(isnan(view.yoga.marginHorizontal));
|
||||
|
||||
view.yoga.marginVertical = 3;
|
||||
XCTAssertEqual(view.yoga.marginTop, 3);
|
||||
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeTop).unit, YGUnitPixel);
|
||||
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeTop).unit, YGUnitPoint);
|
||||
XCTAssertEqual(view.yoga.marginBottom, 3);
|
||||
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeBottom).unit, YGUnitPixel);
|
||||
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeBottom).unit, YGUnitPoint);
|
||||
XCTAssertTrue(isnan(view.yoga.marginVertical));
|
||||
|
||||
view.yoga.marginLeft = 4;
|
||||
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeLeft).value, 4);
|
||||
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeLeft).unit, YGUnitPixel);
|
||||
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeLeft).unit, YGUnitPoint);
|
||||
XCTAssertEqual(view.yoga.marginLeft, 4);
|
||||
|
||||
view.yoga.marginRight = 5;
|
||||
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeRight).value, 5);
|
||||
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeRight).unit, YGUnitPixel);
|
||||
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeRight).unit, YGUnitPoint);
|
||||
XCTAssertEqual(view.yoga.marginRight, 5);
|
||||
|
||||
view.yoga.marginTop = 6;
|
||||
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeTop).value, 6);
|
||||
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeTop).unit, YGUnitPixel);
|
||||
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeTop).unit, YGUnitPoint);
|
||||
XCTAssertEqual(view.yoga.marginTop, 6);
|
||||
|
||||
view.yoga.marginBottom = 7;
|
||||
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeBottom).value, 7);
|
||||
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeBottom).unit, YGUnitPixel);
|
||||
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeBottom).unit, YGUnitPoint);
|
||||
XCTAssertEqual(view.yoga.marginBottom, 7);
|
||||
|
||||
view.yoga.marginStart = 8;
|
||||
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeStart).value, 8);
|
||||
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeStart).unit, YGUnitPixel);
|
||||
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeStart).unit, YGUnitPoint);
|
||||
XCTAssertEqual(view.yoga.marginStart, 8);
|
||||
|
||||
view.yoga.marginEnd = 9;
|
||||
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeEnd).value, 9);
|
||||
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeEnd).unit, YGUnitPixel);
|
||||
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeEnd).unit, YGUnitPoint);
|
||||
XCTAssertEqual(view.yoga.marginEnd, 9);
|
||||
}
|
||||
|
||||
@@ -522,67 +522,67 @@
|
||||
|
||||
view.yoga.padding = 1;
|
||||
XCTAssertEqual(view.yoga.paddingLeft, 1);
|
||||
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeLeft).unit, YGUnitPixel);
|
||||
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeLeft).unit, YGUnitPoint);
|
||||
XCTAssertEqual(view.yoga.paddingRight, 1);
|
||||
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeRight).unit, YGUnitPixel);
|
||||
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeRight).unit, YGUnitPoint);
|
||||
XCTAssertEqual(view.yoga.paddingStart, 1);
|
||||
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeStart).unit, YGUnitPixel);
|
||||
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeStart).unit, YGUnitPoint);
|
||||
XCTAssertEqual(view.yoga.paddingEnd, 1);
|
||||
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeEnd).unit, YGUnitPixel);
|
||||
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeEnd).unit, YGUnitPoint);
|
||||
XCTAssertEqual(view.yoga.paddingTop, 1);
|
||||
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeTop).unit, YGUnitPixel);
|
||||
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeTop).unit, YGUnitPoint);
|
||||
XCTAssertEqual(view.yoga.paddingBottom, 1);
|
||||
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeBottom).unit, YGUnitPixel);
|
||||
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeBottom).unit, YGUnitPoint);
|
||||
XCTAssertTrue(isnan(view.yoga.paddingHorizontal));
|
||||
XCTAssertTrue(isnan(view.yoga.paddingVertical));
|
||||
XCTAssertTrue(isnan(view.yoga.padding));
|
||||
|
||||
view.yoga.paddingHorizontal = 2;
|
||||
XCTAssertEqual(view.yoga.paddingLeft, 2);
|
||||
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeLeft).unit, YGUnitPixel);
|
||||
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeLeft).unit, YGUnitPoint);
|
||||
XCTAssertEqual(view.yoga.paddingRight, 2);
|
||||
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeRight).unit, YGUnitPixel);
|
||||
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeRight).unit, YGUnitPoint);
|
||||
XCTAssertEqual(view.yoga.paddingStart, 2);
|
||||
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeStart).unit, YGUnitPixel);
|
||||
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeStart).unit, YGUnitPoint);
|
||||
XCTAssertEqual(view.yoga.paddingEnd, 2);
|
||||
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeEnd).unit, YGUnitPixel);
|
||||
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeEnd).unit, YGUnitPoint);
|
||||
XCTAssertTrue(isnan(view.yoga.paddingHorizontal));
|
||||
|
||||
view.yoga.paddingVertical = 3;
|
||||
XCTAssertEqual(view.yoga.paddingTop, 3);
|
||||
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeTop).unit, YGUnitPixel);
|
||||
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeTop).unit, YGUnitPoint);
|
||||
XCTAssertEqual(view.yoga.paddingBottom, 3);
|
||||
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeBottom).unit, YGUnitPixel);
|
||||
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeBottom).unit, YGUnitPoint);
|
||||
XCTAssertTrue(isnan(view.yoga.paddingVertical));
|
||||
|
||||
view.yoga.paddingLeft = 4;
|
||||
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeLeft).value, 4);
|
||||
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeLeft).unit, YGUnitPixel);
|
||||
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeLeft).unit, YGUnitPoint);
|
||||
XCTAssertEqual(view.yoga.paddingLeft, 4);
|
||||
|
||||
view.yoga.paddingRight = 5;
|
||||
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeRight).value, 5);
|
||||
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeRight).unit, YGUnitPixel);
|
||||
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeRight).unit, YGUnitPoint);
|
||||
XCTAssertEqual(view.yoga.paddingRight, 5);
|
||||
|
||||
view.yoga.paddingTop = 6;
|
||||
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeTop).value, 6);
|
||||
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeTop).unit, YGUnitPixel);
|
||||
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeTop).unit, YGUnitPoint);
|
||||
XCTAssertEqual(view.yoga.paddingTop, 6);
|
||||
|
||||
view.yoga.paddingBottom = 7;
|
||||
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeBottom).value, 7);
|
||||
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeBottom).unit, YGUnitPixel);
|
||||
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeBottom).unit, YGUnitPoint);
|
||||
XCTAssertEqual(view.yoga.paddingBottom, 7);
|
||||
|
||||
view.yoga.paddingStart = 8;
|
||||
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeStart).value, 8);
|
||||
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeStart).unit, YGUnitPixel);
|
||||
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeStart).unit, YGUnitPoint);
|
||||
XCTAssertEqual(view.yoga.paddingStart, 8);
|
||||
|
||||
view.yoga.paddingEnd = 9;
|
||||
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeEnd).value, 9);
|
||||
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeEnd).unit, YGUnitPixel);
|
||||
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeEnd).unit, YGUnitPoint);
|
||||
XCTAssertEqual(view.yoga.paddingEnd, 9);
|
||||
}
|
||||
|
||||
|
@@ -12,7 +12,7 @@ namespace Facebook.Yoga
|
||||
public enum YogaUnit
|
||||
{
|
||||
Undefined,
|
||||
Pixel,
|
||||
Point,
|
||||
Percent,
|
||||
}
|
||||
}
|
||||
|
@@ -33,12 +33,12 @@ namespace Facebook.Yoga
|
||||
}
|
||||
}
|
||||
|
||||
public static YogaValue Pixel(float value)
|
||||
public static YogaValue Point(float value)
|
||||
{
|
||||
return new YogaValue
|
||||
{
|
||||
value = value,
|
||||
unit = YogaConstants.IsUndefined(value) ? YogaUnit.Undefined : YogaUnit.Pixel
|
||||
unit = YogaConstants.IsUndefined(value) ? YogaUnit.Undefined : YogaUnit.Point
|
||||
};
|
||||
}
|
||||
|
||||
@@ -79,9 +79,9 @@ namespace Facebook.Yoga
|
||||
};
|
||||
}
|
||||
|
||||
public static implicit operator YogaValue(float pixelValue)
|
||||
public static implicit operator YogaValue(float pointValue)
|
||||
{
|
||||
return Pixel(pixelValue);
|
||||
return Point(pointValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -16,9 +16,9 @@ namespace Facebook.Yoga
|
||||
return YogaValue.Percent(value);
|
||||
}
|
||||
|
||||
public static YogaValue Px(this float value)
|
||||
public static YogaValue Pt(this float value)
|
||||
{
|
||||
return YogaValue.Pixel(value);
|
||||
return YogaValue.Point(value);
|
||||
}
|
||||
|
||||
public static YogaValue Percent(this int value)
|
||||
@@ -26,9 +26,9 @@ namespace Facebook.Yoga
|
||||
return YogaValue.Percent(value);
|
||||
}
|
||||
|
||||
public static YogaValue Px(this int value)
|
||||
public static YogaValue Pt(this int value)
|
||||
{
|
||||
return YogaValue.Pixel(value);
|
||||
return YogaValue.Point(value);
|
||||
}
|
||||
}
|
||||
}
|
@@ -854,9 +854,9 @@ namespace Facebook.YogaKit
|
||||
}
|
||||
}
|
||||
|
||||
static double RoundPixelValue(float value)
|
||||
static double RoundPointValue(float value)
|
||||
{
|
||||
float scale = NativePixelScale;
|
||||
float scale = NativePointScale;
|
||||
|
||||
return Math.Round(value * scale) / scale;
|
||||
}
|
||||
|
@@ -30,7 +30,7 @@ namespace Facebook.YogaKit
|
||||
{
|
||||
var topLeft = new CGPoint(node.LayoutX, node.LayoutY);
|
||||
var bottomRight = new CGPoint(topLeft.X + node.LayoutWidth, topLeft.Y + node.LayoutHeight);
|
||||
view.Frame = new CGRect(RoundPixelValue((float)topLeft.X), RoundPixelValue((float)topLeft.Y), RoundPixelValue((float)bottomRight.X) - RoundPixelValue((float)topLeft.X), RoundPixelValue((float)bottomRight.Y) - RoundPixelValue((float)topLeft.Y));
|
||||
view.Frame = new CGRect(RoundPointValue((float)topLeft.X), RoundPointValue((float)topLeft.Y), RoundPointValue((float)bottomRight.X) - RoundPointValue((float)topLeft.X), RoundPointValue((float)bottomRight.Y) - RoundPointValue((float)topLeft.Y));
|
||||
}
|
||||
|
||||
bool _disposed;
|
||||
|
2
enums.py
2
enums.py
@@ -19,7 +19,7 @@ ENUMS = {
|
||||
],
|
||||
'Unit': [
|
||||
'Undefined',
|
||||
'Pixel',
|
||||
'Point',
|
||||
'Percent',
|
||||
],
|
||||
'FlexDirection': [
|
||||
|
@@ -201,105 +201,105 @@ function setupTestTree(e, parent, node, genericNode, nodeName, parentName, index
|
||||
e.YGNodeStyleSetFlexShrink(nodeName, node.style[style]);
|
||||
break;
|
||||
case 'flex-basis':
|
||||
e.YGNodeStyleSetFlexBasis(nodeName, pixelValue(e, node.style[style]));
|
||||
e.YGNodeStyleSetFlexBasis(nodeName, pointValue(e, node.style[style]));
|
||||
break;
|
||||
case 'left':
|
||||
if (genericNode.rawStyle.indexOf('start:') >= 0) {
|
||||
e.YGNodeStyleSetPosition(nodeName, e.YGEdgeStart, pixelValue(e, node.style[style]));
|
||||
e.YGNodeStyleSetPosition(nodeName, e.YGEdgeStart, pointValue(e, node.style[style]));
|
||||
} else {
|
||||
e.YGNodeStyleSetPosition(nodeName, e.YGEdgeLeft, pixelValue(e, node.style[style]));
|
||||
e.YGNodeStyleSetPosition(nodeName, e.YGEdgeLeft, pointValue(e, node.style[style]));
|
||||
}
|
||||
break;
|
||||
case 'top':
|
||||
e.YGNodeStyleSetPosition(nodeName, e.YGEdgeTop, pixelValue(e, node.style[style]));
|
||||
e.YGNodeStyleSetPosition(nodeName, e.YGEdgeTop, pointValue(e, node.style[style]));
|
||||
break;
|
||||
case 'right':
|
||||
if (genericNode.rawStyle.indexOf('end:') >= 0) {
|
||||
e.YGNodeStyleSetPosition(nodeName, e.YGEdgeEnd, pixelValue(e, node.style[style]));
|
||||
e.YGNodeStyleSetPosition(nodeName, e.YGEdgeEnd, pointValue(e, node.style[style]));
|
||||
} else {
|
||||
e.YGNodeStyleSetPosition(nodeName, e.YGEdgeRight, pixelValue(e, node.style[style]));
|
||||
e.YGNodeStyleSetPosition(nodeName, e.YGEdgeRight, pointValue(e, node.style[style]));
|
||||
}
|
||||
break;
|
||||
case 'bottom':
|
||||
e.YGNodeStyleSetPosition(nodeName, e.YGEdgeBottom, pixelValue(e, node.style[style]));
|
||||
e.YGNodeStyleSetPosition(nodeName, e.YGEdgeBottom, pointValue(e, node.style[style]));
|
||||
break;
|
||||
case 'margin-left':
|
||||
if (genericNode.rawStyle.indexOf('margin-start:') >= 0) {
|
||||
e.YGNodeStyleSetMargin(nodeName, e.YGEdgeStart, pixelValue(e, node.style[style]));
|
||||
e.YGNodeStyleSetMargin(nodeName, e.YGEdgeStart, pointValue(e, node.style[style]));
|
||||
} else {
|
||||
e.YGNodeStyleSetMargin(nodeName, e.YGEdgeLeft, pixelValue(e, node.style[style]));
|
||||
e.YGNodeStyleSetMargin(nodeName, e.YGEdgeLeft, pointValue(e, node.style[style]));
|
||||
}
|
||||
break;
|
||||
case 'margin-top':
|
||||
e.YGNodeStyleSetMargin(nodeName, e.YGEdgeTop, pixelValue(e, node.style[style]));
|
||||
e.YGNodeStyleSetMargin(nodeName, e.YGEdgeTop, pointValue(e, node.style[style]));
|
||||
break;
|
||||
case 'margin-right':
|
||||
if (genericNode.rawStyle.indexOf('margin-end:') >= 0) {
|
||||
e.YGNodeStyleSetMargin(nodeName, e.YGEdgeEnd, pixelValue(e, node.style[style]));
|
||||
e.YGNodeStyleSetMargin(nodeName, e.YGEdgeEnd, pointValue(e, node.style[style]));
|
||||
} else {
|
||||
e.YGNodeStyleSetMargin(nodeName, e.YGEdgeRight, pixelValue(e, node.style[style]));
|
||||
e.YGNodeStyleSetMargin(nodeName, e.YGEdgeRight, pointValue(e, node.style[style]));
|
||||
}
|
||||
break;
|
||||
case 'margin-bottom':
|
||||
e.YGNodeStyleSetMargin(nodeName, e.YGEdgeBottom, pixelValue(e, node.style[style]));
|
||||
e.YGNodeStyleSetMargin(nodeName, e.YGEdgeBottom, pointValue(e, node.style[style]));
|
||||
break;
|
||||
case 'padding-left':
|
||||
if (genericNode.rawStyle.indexOf('padding-start:') >= 0) {
|
||||
e.YGNodeStyleSetPadding(nodeName, e.YGEdgeStart, pixelValue(e, node.style[style]));
|
||||
e.YGNodeStyleSetPadding(nodeName, e.YGEdgeStart, pointValue(e, node.style[style]));
|
||||
} else {
|
||||
e.YGNodeStyleSetPadding(nodeName, e.YGEdgeLeft, pixelValue(e, node.style[style]));
|
||||
e.YGNodeStyleSetPadding(nodeName, e.YGEdgeLeft, pointValue(e, node.style[style]));
|
||||
}
|
||||
break;
|
||||
case 'padding-top':
|
||||
e.YGNodeStyleSetPadding(nodeName, e.YGEdgeTop, pixelValue(e, node.style[style]));
|
||||
e.YGNodeStyleSetPadding(nodeName, e.YGEdgeTop, pointValue(e, node.style[style]));
|
||||
break;
|
||||
case 'padding-right':
|
||||
if (genericNode.rawStyle.indexOf('padding-end:') >= 0) {
|
||||
e.YGNodeStyleSetPadding(nodeName, e.YGEdgeEnd, pixelValue(e, node.style[style]));
|
||||
e.YGNodeStyleSetPadding(nodeName, e.YGEdgeEnd, pointValue(e, node.style[style]));
|
||||
} else {
|
||||
e.YGNodeStyleSetPadding(nodeName, e.YGEdgeRight, pixelValue(e, node.style[style]));
|
||||
e.YGNodeStyleSetPadding(nodeName, e.YGEdgeRight, pointValue(e, node.style[style]));
|
||||
}
|
||||
break;
|
||||
case 'padding-bottom':
|
||||
e.YGNodeStyleSetPadding(nodeName, e.YGEdgeBottom, pixelValue(e, node.style[style]));
|
||||
e.YGNodeStyleSetPadding(nodeName, e.YGEdgeBottom, pointValue(e, node.style[style]));
|
||||
break;
|
||||
case 'border-left-width':
|
||||
if (genericNode.rawStyle.indexOf('border-start-width:') >= 0) {
|
||||
e.YGNodeStyleSetBorder(nodeName, e.YGEdgeStart, pixelValue(e, node.style[style]));
|
||||
e.YGNodeStyleSetBorder(nodeName, e.YGEdgeStart, pointValue(e, node.style[style]));
|
||||
} else {
|
||||
e.YGNodeStyleSetBorder(nodeName, e.YGEdgeLeft, pixelValue(e, node.style[style]));
|
||||
e.YGNodeStyleSetBorder(nodeName, e.YGEdgeLeft, pointValue(e, node.style[style]));
|
||||
}
|
||||
break;
|
||||
case 'border-top-width':
|
||||
e.YGNodeStyleSetBorder(nodeName, e.YGEdgeTop, pixelValue(e, node.style[style]));
|
||||
e.YGNodeStyleSetBorder(nodeName, e.YGEdgeTop, pointValue(e, node.style[style]));
|
||||
break;
|
||||
case 'border-right-width':
|
||||
if (genericNode.rawStyle.indexOf('border-end-width:') >= 0) {
|
||||
e.YGNodeStyleSetBorder(nodeName, e.YGEdgeEnd, pixelValue(e, node.style[style]));
|
||||
e.YGNodeStyleSetBorder(nodeName, e.YGEdgeEnd, pointValue(e, node.style[style]));
|
||||
} else {
|
||||
e.YGNodeStyleSetBorder(nodeName, e.YGEdgeRight, pixelValue(e, node.style[style]));
|
||||
e.YGNodeStyleSetBorder(nodeName, e.YGEdgeRight, pointValue(e, node.style[style]));
|
||||
}
|
||||
break;
|
||||
case 'border-bottom-width':
|
||||
e.YGNodeStyleSetBorder(nodeName, e.YGEdgeBottom, pixelValue(e, node.style[style]));
|
||||
e.YGNodeStyleSetBorder(nodeName, e.YGEdgeBottom, pointValue(e, node.style[style]));
|
||||
break;
|
||||
case 'width':
|
||||
e.YGNodeStyleSetWidth(nodeName, pixelValue(e, node.style[style]));
|
||||
e.YGNodeStyleSetWidth(nodeName, pointValue(e, node.style[style]));
|
||||
break;
|
||||
case 'min-width':
|
||||
e.YGNodeStyleSetMinWidth(nodeName, pixelValue(e, node.style[style]));
|
||||
e.YGNodeStyleSetMinWidth(nodeName, pointValue(e, node.style[style]));
|
||||
break;
|
||||
case 'max-width':
|
||||
e.YGNodeStyleSetMaxWidth(nodeName, pixelValue(e, node.style[style]));
|
||||
e.YGNodeStyleSetMaxWidth(nodeName, pointValue(e, node.style[style]));
|
||||
break;
|
||||
case 'height':
|
||||
e.YGNodeStyleSetHeight(nodeName, pixelValue(e, node.style[style]));
|
||||
e.YGNodeStyleSetHeight(nodeName, pointValue(e, node.style[style]));
|
||||
break;
|
||||
case 'min-height':
|
||||
e.YGNodeStyleSetMinHeight(nodeName, pixelValue(e, node.style[style]));
|
||||
e.YGNodeStyleSetMinHeight(nodeName, pointValue(e, node.style[style]));
|
||||
break;
|
||||
case 'max-height':
|
||||
e.YGNodeStyleSetMaxHeight(nodeName, pixelValue(e, node.style[style]));
|
||||
e.YGNodeStyleSetMaxHeight(nodeName, pointValue(e, node.style[style]));
|
||||
break;
|
||||
case 'display':
|
||||
e.YGNodeStyleSetDisplay(nodeName, displayValue(e, node.style[style]))
|
||||
@@ -385,7 +385,7 @@ function alignValue(e, value) {
|
||||
}
|
||||
}
|
||||
|
||||
function pixelValue(e, value) {
|
||||
function pointValue(e, value) {
|
||||
switch (value) {
|
||||
case 'auto': return e.YGUndefined;
|
||||
case 'undefined': return e.YGUndefined;
|
||||
|
@@ -14,7 +14,7 @@ import com.facebook.proguard.annotations.DoNotStrip;
|
||||
@DoNotStrip
|
||||
public interface YogaBaselineFunction {
|
||||
/**
|
||||
* Return the baseline of the node in pixels. When no baseline function is set the baseline
|
||||
* Return the baseline of the node in points. When no baseline function is set the baseline
|
||||
* default to the computed height of the node.
|
||||
*/
|
||||
@DoNotStrip
|
||||
|
@@ -14,7 +14,7 @@ import com.facebook.proguard.annotations.DoNotStrip;
|
||||
@DoNotStrip
|
||||
public enum YogaUnit {
|
||||
UNDEFINED(0),
|
||||
PIXEL(1),
|
||||
POINT(1),
|
||||
PERCENT(2);
|
||||
|
||||
private int mIntValue;
|
||||
@@ -30,7 +30,7 @@ public enum YogaUnit {
|
||||
public static YogaUnit fromInt(int value) {
|
||||
switch (value) {
|
||||
case 0: return UNDEFINED;
|
||||
case 1: return PIXEL;
|
||||
case 1: return POINT;
|
||||
case 2: return PERCENT;
|
||||
default: throw new IllegalArgumentException("Unknown enum value: " + value);
|
||||
}
|
||||
|
@@ -14,7 +14,7 @@ import com.facebook.proguard.annotations.DoNotStrip;
|
||||
@DoNotStrip
|
||||
public class YogaValue {
|
||||
static final YogaValue UNDEFINED = new YogaValue(YogaConstants.UNDEFINED, YogaUnit.UNDEFINED);
|
||||
static final YogaValue ZERO = new YogaValue(0, YogaUnit.PIXEL);
|
||||
static final YogaValue ZERO = new YogaValue(0, YogaUnit.POINT);
|
||||
|
||||
public final float value;
|
||||
public final YogaUnit unit;
|
||||
|
@@ -86,7 +86,7 @@ module.exports = {
|
||||
|
||||
UNIT_COUNT: 3,
|
||||
UNIT_UNDEFINED: 0,
|
||||
UNIT_PIXEL: 1,
|
||||
UNIT_POINT: 1,
|
||||
UNIT_PERCENT: 2,
|
||||
|
||||
WRAP_COUNT: 2,
|
||||
|
@@ -102,7 +102,7 @@ module.exports = function (bind, lib) {
|
||||
|
||||
switch (this.unit) {
|
||||
|
||||
case constants.UNIT_PIXEL:
|
||||
case constants.UNIT_POINT:
|
||||
return `${this.value}`;
|
||||
|
||||
case constants.UNIT_PERCENT:
|
||||
@@ -126,7 +126,7 @@ module.exports = function (bind, lib) {
|
||||
|
||||
for (let fnName of [ `setPosition`, `setMargin`, `setFlexBasis`, `setWidth`, `setHeight`, `setMinWidth`, `setMinHeight`, `setMaxWidth`, `setMaxHeight`, `setPadding` ]) {
|
||||
|
||||
let methods = { [constants.UNIT_PIXEL]: lib.Node.prototype[fnName], [constants.UNIT_PERCENT]: lib.Node.prototype[`${fnName}Percent`] };
|
||||
let methods = { [constants.UNIT_POINT]: lib.Node.prototype[fnName], [constants.UNIT_PERCENT]: lib.Node.prototype[`${fnName}Percent`] };
|
||||
|
||||
if (Object.keys(methods).some(method => methods[method] == null))
|
||||
throw new Error(`Assertion failed; some unit derivates of ${fnName} seem missing`);
|
||||
@@ -146,7 +146,7 @@ module.exports = function (bind, lib) {
|
||||
|
||||
} else {
|
||||
|
||||
unit = typeof value === `string` && value.endsWith(`%`) ? constants.UNIT_PERCENT : constants.UNIT_PIXEL;
|
||||
unit = typeof value === `string` && value.endsWith(`%`) ? constants.UNIT_PERCENT : constants.UNIT_POINT;
|
||||
asNumber = parseFloat(value);
|
||||
|
||||
}
|
||||
|
111
yoga/YGEnums.h
111
yoga/YGEnums.h
@@ -15,21 +15,26 @@ YG_EXTERN_C_BEGIN
|
||||
|
||||
#define YGAlignCount 6
|
||||
typedef YG_ENUM_BEGIN(YGAlign) {
|
||||
YGAlignAuto, YGAlignFlexStart, YGAlignCenter, YGAlignFlexEnd, YGAlignStretch, YGAlignBaseline,
|
||||
}
|
||||
YG_ENUM_END(YGAlign);
|
||||
YGAlignAuto,
|
||||
YGAlignFlexStart,
|
||||
YGAlignCenter,
|
||||
YGAlignFlexEnd,
|
||||
YGAlignStretch,
|
||||
YGAlignBaseline,
|
||||
} YG_ENUM_END(YGAlign);
|
||||
|
||||
#define YGDimensionCount 2
|
||||
typedef YG_ENUM_BEGIN(YGDimension) {
|
||||
YGDimensionWidth, YGDimensionHeight,
|
||||
}
|
||||
YG_ENUM_END(YGDimension);
|
||||
YGDimensionWidth,
|
||||
YGDimensionHeight,
|
||||
} YG_ENUM_END(YGDimension);
|
||||
|
||||
#define YGDirectionCount 3
|
||||
typedef YG_ENUM_BEGIN(YGDirection) {
|
||||
YGDirectionInherit, YGDirectionLTR, YGDirectionRTL,
|
||||
}
|
||||
YG_ENUM_END(YGDirection);
|
||||
YGDirectionInherit,
|
||||
YGDirectionLTR,
|
||||
YGDirectionRTL,
|
||||
} YG_ENUM_END(YGDirection);
|
||||
|
||||
#define YGDisplayCount 2
|
||||
typedef YG_ENUM_BEGIN(YGDisplay) {
|
||||
@@ -39,71 +44,87 @@ typedef YG_ENUM_BEGIN(YGDisplay) {
|
||||
|
||||
#define YGEdgeCount 9
|
||||
typedef YG_ENUM_BEGIN(YGEdge) {
|
||||
YGEdgeLeft, YGEdgeTop, YGEdgeRight, YGEdgeBottom, YGEdgeStart, YGEdgeEnd, YGEdgeHorizontal,
|
||||
YGEdgeVertical, YGEdgeAll,
|
||||
}
|
||||
YG_ENUM_END(YGEdge);
|
||||
YGEdgeLeft,
|
||||
YGEdgeTop,
|
||||
YGEdgeRight,
|
||||
YGEdgeBottom,
|
||||
YGEdgeStart,
|
||||
YGEdgeEnd,
|
||||
YGEdgeHorizontal,
|
||||
YGEdgeVertical,
|
||||
YGEdgeAll,
|
||||
} YG_ENUM_END(YGEdge);
|
||||
|
||||
#define YGExperimentalFeatureCount 2
|
||||
typedef YG_ENUM_BEGIN(YGExperimentalFeature) {
|
||||
YGExperimentalFeatureRounding, YGExperimentalFeatureWebFlexBasis,
|
||||
}
|
||||
YG_ENUM_END(YGExperimentalFeature);
|
||||
YGExperimentalFeatureRounding,
|
||||
YGExperimentalFeatureWebFlexBasis,
|
||||
} YG_ENUM_END(YGExperimentalFeature);
|
||||
|
||||
#define YGFlexDirectionCount 4
|
||||
typedef YG_ENUM_BEGIN(YGFlexDirection) {
|
||||
YGFlexDirectionColumn, YGFlexDirectionColumnReverse, YGFlexDirectionRow,
|
||||
YGFlexDirectionRowReverse,
|
||||
}
|
||||
YG_ENUM_END(YGFlexDirection);
|
||||
YGFlexDirectionColumn,
|
||||
YGFlexDirectionColumnReverse,
|
||||
YGFlexDirectionRow,
|
||||
YGFlexDirectionRowReverse,
|
||||
} YG_ENUM_END(YGFlexDirection);
|
||||
|
||||
#define YGJustifyCount 5
|
||||
typedef YG_ENUM_BEGIN(YGJustify) {
|
||||
YGJustifyFlexStart, YGJustifyCenter, YGJustifyFlexEnd, YGJustifySpaceBetween,
|
||||
YGJustifySpaceAround,
|
||||
}
|
||||
YG_ENUM_END(YGJustify);
|
||||
YGJustifyFlexStart,
|
||||
YGJustifyCenter,
|
||||
YGJustifyFlexEnd,
|
||||
YGJustifySpaceBetween,
|
||||
YGJustifySpaceAround,
|
||||
} YG_ENUM_END(YGJustify);
|
||||
|
||||
#define YGLogLevelCount 5
|
||||
typedef YG_ENUM_BEGIN(YGLogLevel) {
|
||||
YGLogLevelError, YGLogLevelWarn, YGLogLevelInfo, YGLogLevelDebug, YGLogLevelVerbose,
|
||||
}
|
||||
YG_ENUM_END(YGLogLevel);
|
||||
YGLogLevelError,
|
||||
YGLogLevelWarn,
|
||||
YGLogLevelInfo,
|
||||
YGLogLevelDebug,
|
||||
YGLogLevelVerbose,
|
||||
} YG_ENUM_END(YGLogLevel);
|
||||
|
||||
#define YGMeasureModeCount 3
|
||||
typedef YG_ENUM_BEGIN(YGMeasureMode) {
|
||||
YGMeasureModeUndefined, YGMeasureModeExactly, YGMeasureModeAtMost,
|
||||
}
|
||||
YG_ENUM_END(YGMeasureMode);
|
||||
YGMeasureModeUndefined,
|
||||
YGMeasureModeExactly,
|
||||
YGMeasureModeAtMost,
|
||||
} YG_ENUM_END(YGMeasureMode);
|
||||
|
||||
#define YGOverflowCount 3
|
||||
typedef YG_ENUM_BEGIN(YGOverflow) {
|
||||
YGOverflowVisible, YGOverflowHidden, YGOverflowScroll,
|
||||
}
|
||||
YG_ENUM_END(YGOverflow);
|
||||
YGOverflowVisible,
|
||||
YGOverflowHidden,
|
||||
YGOverflowScroll,
|
||||
} YG_ENUM_END(YGOverflow);
|
||||
|
||||
#define YGPositionTypeCount 2
|
||||
typedef YG_ENUM_BEGIN(YGPositionType) {
|
||||
YGPositionTypeRelative, YGPositionTypeAbsolute,
|
||||
}
|
||||
YG_ENUM_END(YGPositionType);
|
||||
YGPositionTypeRelative,
|
||||
YGPositionTypeAbsolute,
|
||||
} YG_ENUM_END(YGPositionType);
|
||||
|
||||
#define YGPrintOptionsCount 3
|
||||
typedef YG_ENUM_BEGIN(YGPrintOptions) {
|
||||
YGPrintOptionsLayout = 1, YGPrintOptionsStyle = 2, YGPrintOptionsChildren = 4,
|
||||
}
|
||||
YG_ENUM_END(YGPrintOptions);
|
||||
YGPrintOptionsLayout = 1,
|
||||
YGPrintOptionsStyle = 2,
|
||||
YGPrintOptionsChildren = 4,
|
||||
} YG_ENUM_END(YGPrintOptions);
|
||||
|
||||
#define YGUnitCount 3
|
||||
typedef YG_ENUM_BEGIN(YGUnit) {
|
||||
YGUnitUndefined, YGUnitPixel, YGUnitPercent,
|
||||
}
|
||||
YG_ENUM_END(YGUnit);
|
||||
YGUnitUndefined,
|
||||
YGUnitPoint,
|
||||
YGUnitPercent,
|
||||
} YG_ENUM_END(YGUnit);
|
||||
|
||||
#define YGWrapCount 2
|
||||
typedef YG_ENUM_BEGIN(YGWrap) {
|
||||
YGWrapNoWrap, YGWrapWrap,
|
||||
}
|
||||
YG_ENUM_END(YGWrap);
|
||||
YGWrapNoWrap,
|
||||
YGWrapWrap,
|
||||
} YG_ENUM_END(YGWrap);
|
||||
|
||||
YG_EXTERN_C_END
|
||||
|
34
yoga/Yoga.c
34
yoga/Yoga.c
@@ -188,7 +188,7 @@ YGCalloc gYGCalloc = &calloc;
|
||||
YGRealloc gYGRealloc = &realloc;
|
||||
YGFree gYGFree = &free;
|
||||
|
||||
static YGValue YGValueZero = {.value = 0, .unit = YGUnitPixel};
|
||||
static YGValue YGValueZero = {.value = 0, .unit = YGUnitPoint};
|
||||
|
||||
#ifdef ANDROID
|
||||
#include <android/log.h>
|
||||
@@ -265,7 +265,7 @@ static inline float YGValueResolve(const YGValue *const value, const float paren
|
||||
switch (value->unit) {
|
||||
case YGUnitUndefined:
|
||||
return YGUndefined;
|
||||
case YGUnitPixel:
|
||||
case YGUnitPoint:
|
||||
return value->value;
|
||||
case YGUnitPercent:
|
||||
return value->value * parentSize / 100.0f;
|
||||
@@ -462,10 +462,10 @@ void YGNodeStyleSetFlex(const YGNodeRef node, const float flex) {
|
||||
#define YG_NODE_STYLE_PROPERTY_SETTER_UNIT_IMPL(type, name, paramName, instanceName) \
|
||||
void YGNodeStyleSet##name(const YGNodeRef node, const type paramName) { \
|
||||
if (node->style.instanceName.value != paramName || \
|
||||
node->style.instanceName.unit != YGUnitPixel) { \
|
||||
node->style.instanceName.unit != YGUnitPoint) { \
|
||||
node->style.instanceName.value = paramName; \
|
||||
node->style.instanceName.unit = \
|
||||
YGFloatIsUndefined(paramName) ? YGUnitUndefined : YGUnitPixel; \
|
||||
YGFloatIsUndefined(paramName) ? YGUnitUndefined : YGUnitPoint; \
|
||||
YGNodeMarkDirtyInternal(node); \
|
||||
} \
|
||||
} \
|
||||
@@ -497,10 +497,10 @@ void YGNodeStyleSetFlex(const YGNodeRef node, const float flex) {
|
||||
#define YG_NODE_STYLE_EDGE_PROPERTY_UNIT_IMPL(type, name, paramName, instanceName) \
|
||||
void YGNodeStyleSet##name(const YGNodeRef node, const YGEdge edge, const float paramName) { \
|
||||
if (node->style.instanceName[edge].value != paramName || \
|
||||
node->style.instanceName[edge].unit != YGUnitPixel) { \
|
||||
node->style.instanceName[edge].unit != YGUnitPoint) { \
|
||||
node->style.instanceName[edge].value = paramName; \
|
||||
node->style.instanceName[edge].unit = \
|
||||
YGFloatIsUndefined(paramName) ? YGUnitUndefined : YGUnitPixel; \
|
||||
YGFloatIsUndefined(paramName) ? YGUnitUndefined : YGUnitPoint; \
|
||||
YGNodeMarkDirtyInternal(node); \
|
||||
} \
|
||||
} \
|
||||
@@ -524,10 +524,10 @@ void YGNodeStyleSetFlex(const YGNodeRef node, const float flex) {
|
||||
#define YG_NODE_STYLE_EDGE_PROPERTY_IMPL(type, name, paramName, instanceName) \
|
||||
void YGNodeStyleSet##name(const YGNodeRef node, const YGEdge edge, const float paramName) { \
|
||||
if (node->style.instanceName[edge].value != paramName || \
|
||||
node->style.instanceName[edge].unit != YGUnitPixel) { \
|
||||
node->style.instanceName[edge].unit != YGUnitPoint) { \
|
||||
node->style.instanceName[edge].value = paramName; \
|
||||
node->style.instanceName[edge].unit = \
|
||||
YGFloatIsUndefined(paramName) ? YGUnitUndefined : YGUnitPixel; \
|
||||
YGFloatIsUndefined(paramName) ? YGUnitUndefined : YGUnitPoint; \
|
||||
YGNodeMarkDirtyInternal(node); \
|
||||
} \
|
||||
} \
|
||||
@@ -671,7 +671,7 @@ static void YGPrintNumberIfNotZero(const char *str, const YGValue *const number)
|
||||
"%s: %g%s, ",
|
||||
str,
|
||||
number->value,
|
||||
number->unit == YGUnitPixel ? "px" : "%");
|
||||
number->unit == YGUnitPoint ? "pt" : "%");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -687,7 +687,7 @@ static void YGPrintNumberIfNotUndefined(const char *str, const YGValue *const nu
|
||||
"%s: %g%s, ",
|
||||
str,
|
||||
number->value,
|
||||
number->unit == YGUnitPixel ? "px" : "%");
|
||||
number->unit == YGUnitPoint ? "pt" : "%");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1098,7 +1098,7 @@ static inline bool YGNodeIsStyleDimDefined(const YGNodeRef node,
|
||||
const YGFlexDirection axis,
|
||||
const float parentSize) {
|
||||
return !(node->resolvedDimensions[dim[axis]].unit == YGUnitUndefined ||
|
||||
(node->resolvedDimensions[dim[axis]].unit == YGUnitPixel &&
|
||||
(node->resolvedDimensions[dim[axis]].unit == YGUnitPoint &&
|
||||
node->resolvedDimensions[dim[axis]].value < 0.0f) ||
|
||||
(node->resolvedDimensions[dim[axis]].unit == YGUnitPercent &&
|
||||
YGFloatIsUndefined(parentSize)));
|
||||
@@ -1723,11 +1723,11 @@ static void YGZeroOutLayoutRecursivly(const YGNodeRef node) {
|
||||
// the width/height attributes.
|
||||
// flex: -1 (or any negative value) is equivalent to flex: 0 1 auto
|
||||
// * Margins cannot be specified as 'auto'. They must be specified in terms of
|
||||
// pixel
|
||||
// points
|
||||
// values, and the default value is 0.
|
||||
// * Values of width, maxWidth, minWidth, height, maxHeight and minHeight must
|
||||
// be
|
||||
// specified as pixel values, not as percentages.
|
||||
// specified as point values, not as percentages.
|
||||
// * There is no support for calculation of dimensions based on intrinsic
|
||||
// aspect ratios
|
||||
// (e.g. images).
|
||||
@@ -2122,7 +2122,7 @@ static void YGNodelayoutImpl(const YGNodeRef node,
|
||||
// based on its
|
||||
// content.
|
||||
// sizeConsumedOnCurrentLine is negative which means the node will
|
||||
// allocate 0 pixels for
|
||||
// allocate 0 points for
|
||||
// its content. Consequently, remainingFreeSpace is 0 -
|
||||
// sizeConsumedOnCurrentLine.
|
||||
remainingFreeSpace = -sizeConsumedOnCurrentLine;
|
||||
@@ -3144,7 +3144,7 @@ bool YGLayoutNodeInternal(const YGNodeRef node,
|
||||
return (needToVisitNode || cachedResults == NULL);
|
||||
}
|
||||
|
||||
static void roundToPixelGrid(const YGNodeRef node) {
|
||||
static void roundToPointGrid(const YGNodeRef node) {
|
||||
const float fractialLeft =
|
||||
node->layout.position[YGEdgeLeft] - floorf(node->layout.position[YGEdgeLeft]);
|
||||
const float fractialTop =
|
||||
@@ -3159,7 +3159,7 @@ static void roundToPixelGrid(const YGNodeRef node) {
|
||||
|
||||
const uint32_t childCount = YGNodeListCount(node->children);
|
||||
for (uint32_t i = 0; i < childCount; i++) {
|
||||
roundToPixelGrid(YGNodeGetChild(node, i));
|
||||
roundToPointGrid(YGNodeGetChild(node, i));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3219,7 +3219,7 @@ void YGNodeCalculateLayout(const YGNodeRef node,
|
||||
YGNodeSetPosition(node, node->layout.direction, availableWidth, availableHeight, availableWidth);
|
||||
|
||||
if (YGIsExperimentalFeatureEnabled(YGExperimentalFeatureRounding)) {
|
||||
roundToPixelGrid(node);
|
||||
roundToPointGrid(node);
|
||||
}
|
||||
|
||||
if (gPrintTree) {
|
||||
|
@@ -200,7 +200,7 @@ YG_NODE_LAYOUT_PROPERTY(float, Height);
|
||||
YG_NODE_LAYOUT_PROPERTY(YGDirection, Direction);
|
||||
|
||||
// Get the computed values for these nodes after performing layout. If they were set using
|
||||
// pixel values then the returned value will be the same as YGNodeStyleGetXXX. However if
|
||||
// point values then the returned value will be the same as YGNodeStyleGetXXX. However if
|
||||
// they were set using a percentage value then the returned value is the computed value used
|
||||
// during layout.
|
||||
YG_NODE_LAYOUT_EDGE_PROPERTY(float, Margin);
|
||||
|
Reference in New Issue
Block a user