Add YGLayoutGetMargin

Summary:
Fix #326. I'll open another PR once this one gets accepted to add support for `YGLayoutGetBorder` 👌
Closes https://github.com/facebook/yoga/pull/335

Reviewed By: gkassabli

Differential Revision: D4409399

Pulled By: emilsjolander

fbshipit-source-id: 8153f6701cab60b55a485f6d2e0b9f7767481090
This commit is contained in:
Maël Nison
2017-01-15 15:16:10 -08:00
committed by Facebook Github Bot
parent 498a5980e8
commit d70f289e73
16 changed files with 288 additions and 29 deletions

View File

@@ -70,6 +70,14 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
@DoNotStrip
private float mLeft = YogaConstants.UNDEFINED;
@DoNotStrip
private float mMarginLeft = 0;
@DoNotStrip
private float mMarginTop = 0;
@DoNotStrip
private float mMarginRight = 0;
@DoNotStrip
private float mMarginBottom = 0;
@DoNotStrip
private float mPaddingLeft = 0;
@DoNotStrip
private float mPaddingTop = 0;
@@ -573,6 +581,26 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
return mHeight;
}
@Override
public float getLayoutMargin(YogaEdge edge) {
switch (edge) {
case LEFT:
return mMarginLeft;
case TOP:
return mMarginTop;
case RIGHT:
return mMarginRight;
case BOTTOM:
return mMarginBottom;
case START:
return getLayoutDirection() == YogaDirection.RTL ? mMarginRight : mMarginLeft;
case END:
return getLayoutDirection() == YogaDirection.RTL ? mMarginLeft : mMarginRight;
default:
throw new IllegalArgumentException("Cannot get layout margins of multi-edge shorthands");
}
}
@Override
public float getLayoutPadding(YogaEdge edge) {
switch (edge) {

View File

@@ -82,6 +82,7 @@ public interface YogaNodeAPI<YogaNodeType extends YogaNodeAPI> {
float getLayoutY();
float getLayoutWidth();
float getLayoutHeight();
float getLayoutMargin(YogaEdge edge);
float getLayoutPadding(YogaEdge edge);
YogaDirection getLayoutDirection();
YogaOverflow getOverflow();