Expose layout paddding in java api

Summary: Expose layout padding api from D4376572

Reviewed By: passy

Differential Revision: D4377069

fbshipit-source-id: 2e0c04104560e1be586562b27b3457576590dc18
This commit is contained in:
Emil Sjolander
2017-01-05 12:48:10 -08:00
committed by Facebook Github Bot
parent bf5eeaf61e
commit e539ecc9aa
4 changed files with 57 additions and 0 deletions

View File

@@ -69,6 +69,14 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
@DoNotStrip
private float mLeft = YogaConstants.UNDEFINED;
@DoNotStrip
private float mPaddingLeft = 0;
@DoNotStrip
private float mPaddingTop = 0;
@DoNotStrip
private float mPaddingRight = 0;
@DoNotStrip
private float mPaddingBottom = 0;
@DoNotStrip
private int mLayoutDirection = 0;
private native long jni_YGNodeNew();
@@ -564,6 +572,26 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
return mHeight;
}
@Override
public float getLayoutPadding(YogaEdge edge) {
switch (edge) {
case LEFT:
return mPaddingLeft;
case TOP:
return mPaddingTop;
case RIGHT:
return mPaddingRight;
case BOTTOM:
return mPaddingBottom;
case START:
return getLayoutDirection() == YogaDirection.RTL ? mPaddingRight : mPaddingLeft;
case END:
return getLayoutDirection() == YogaDirection.RTL ? mPaddingLeft : mPaddingRight;
default:
throw new IllegalArgumentException("Cannot get layout paddings of multi-edge shorthands");
}
}
@Override
public YogaDirection getLayoutDirection() {
return YogaDirection.values()[mLayoutDirection];

View File

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