Add layout margin functions to the java interface
This commit is contained in:
@@ -70,6 +70,14 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
|
|||||||
@DoNotStrip
|
@DoNotStrip
|
||||||
private float mLeft = YogaConstants.UNDEFINED;
|
private float mLeft = YogaConstants.UNDEFINED;
|
||||||
@DoNotStrip
|
@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;
|
private float mPaddingLeft = 0;
|
||||||
@DoNotStrip
|
@DoNotStrip
|
||||||
private float mPaddingTop = 0;
|
private float mPaddingTop = 0;
|
||||||
@@ -573,6 +581,26 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
|
|||||||
return mHeight;
|
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
|
@Override
|
||||||
public float getLayoutPadding(YogaEdge edge) {
|
public float getLayoutPadding(YogaEdge edge) {
|
||||||
switch (edge) {
|
switch (edge) {
|
||||||
|
@@ -82,6 +82,7 @@ public interface YogaNodeAPI<YogaNodeType extends YogaNodeAPI> {
|
|||||||
float getLayoutY();
|
float getLayoutY();
|
||||||
float getLayoutWidth();
|
float getLayoutWidth();
|
||||||
float getLayoutHeight();
|
float getLayoutHeight();
|
||||||
|
float getLayoutMargin(YogaEdge edge);
|
||||||
float getLayoutPadding(YogaEdge edge);
|
float getLayoutPadding(YogaEdge edge);
|
||||||
YogaDirection getLayoutDirection();
|
YogaDirection getLayoutDirection();
|
||||||
YogaOverflow getOverflow();
|
YogaOverflow getOverflow();
|
||||||
|
@@ -30,6 +30,11 @@ static void YGTransferLayoutOutputsRecursive(YGNodeRef root) {
|
|||||||
static auto leftField = obj->getClass()->getField<jfloat>("mLeft");
|
static auto leftField = obj->getClass()->getField<jfloat>("mLeft");
|
||||||
static auto topField = obj->getClass()->getField<jfloat>("mTop");
|
static auto topField = obj->getClass()->getField<jfloat>("mTop");
|
||||||
|
|
||||||
|
static auto marginLeftField = obj->getClass()->getField<jfloat>("mMarginLeft");
|
||||||
|
static auto marginTopField = obj->getClass()->getField<jfloat>("mMarginTop");
|
||||||
|
static auto marginRightField = obj->getClass()->getField<jfloat>("mMarginRight");
|
||||||
|
static auto marginBottomField = obj->getClass()->getField<jfloat>("mMarginBottom");
|
||||||
|
|
||||||
static auto paddingLeftField = obj->getClass()->getField<jfloat>("mPaddingLeft");
|
static auto paddingLeftField = obj->getClass()->getField<jfloat>("mPaddingLeft");
|
||||||
static auto paddingTopField = obj->getClass()->getField<jfloat>("mPaddingTop");
|
static auto paddingTopField = obj->getClass()->getField<jfloat>("mPaddingTop");
|
||||||
static auto paddingRightField = obj->getClass()->getField<jfloat>("mPaddingRight");
|
static auto paddingRightField = obj->getClass()->getField<jfloat>("mPaddingRight");
|
||||||
@@ -40,6 +45,11 @@ static void YGTransferLayoutOutputsRecursive(YGNodeRef root) {
|
|||||||
obj->setFieldValue(leftField, YGNodeLayoutGetLeft(root));
|
obj->setFieldValue(leftField, YGNodeLayoutGetLeft(root));
|
||||||
obj->setFieldValue(topField, YGNodeLayoutGetTop(root));
|
obj->setFieldValue(topField, YGNodeLayoutGetTop(root));
|
||||||
|
|
||||||
|
obj->setFieldValue(marginLeftField, YGNodeLayoutGetMargin(root, YGEdgeLeft));
|
||||||
|
obj->setFieldValue(marginTopField, YGNodeLayoutGetMargin(root, YGEdgeTop));
|
||||||
|
obj->setFieldValue(marginRightField, YGNodeLayoutGetMargin(root, YGEdgeRight));
|
||||||
|
obj->setFieldValue(marginBottomField, YGNodeLayoutGetMargin(root, YGEdgeBottom));
|
||||||
|
|
||||||
obj->setFieldValue(paddingLeftField, YGNodeLayoutGetPadding(root, YGEdgeLeft));
|
obj->setFieldValue(paddingLeftField, YGNodeLayoutGetPadding(root, YGEdgeLeft));
|
||||||
obj->setFieldValue(paddingTopField, YGNodeLayoutGetPadding(root, YGEdgeTop));
|
obj->setFieldValue(paddingTopField, YGNodeLayoutGetPadding(root, YGEdgeTop));
|
||||||
obj->setFieldValue(paddingRightField, YGNodeLayoutGetPadding(root, YGEdgeRight));
|
obj->setFieldValue(paddingRightField, YGNodeLayoutGetPadding(root, YGEdgeRight));
|
||||||
|
Reference in New Issue
Block a user