Move files around

This commit is contained in:
Rui Marinho
2016-12-16 14:09:39 +00:00
parent 57b042feb1
commit cb44a9f5a2
291 changed files with 25201 additions and 1724 deletions

View File

@@ -16,4 +16,8 @@ public class YogaConstants {
public static boolean isUndefined(float value) {
return Float.compare(value, UNDEFINED) == 0;
}
public static boolean isUndefined(YogaValue value) {
return value.unit == YogaUnit.UNDEFINED;
}
}

View File

@@ -15,18 +15,20 @@ package com.facebook.yoga;
public class YogaMeasureOutput {
public static long make(float width, float height) {
return make((int) width, (int) height);
final int wBits = Float.floatToRawIntBits(width);
final int hBits = Float.floatToRawIntBits(height);
return ((long) wBits) << 32 | ((long) hBits);
}
public static long make(int width, int height) {
return ((long) width) << 32 | ((long) height);
return make((float) width, (float) height);
}
public static int getWidth(long measureOutput) {
return (int) (0xFFFFFFFF & (measureOutput >> 32));
public static float getWidth(long measureOutput) {
return Float.intBitsToFloat((int) (0xFFFFFFFF & (measureOutput >> 32)));
}
public static int getHeight(long measureOutput) {
return (int) (0xFFFFFFFF & measureOutput);
public static float getHeight(long measureOutput) {
return Float.intBitsToFloat((int) (0xFFFFFFFF & measureOutput));
}
}

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();
@@ -323,10 +331,10 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
jni_YGNodeStyleSetFlexShrink(mNativePointer, flexShrink);
}
private native float jni_YGNodeStyleGetFlexBasis(long nativePointer);
private native Object jni_YGNodeStyleGetFlexBasis(long nativePointer);
@Override
public float getFlexBasis() {
return jni_YGNodeStyleGetFlexBasis(mNativePointer);
public YogaValue getFlexBasis() {
return (YogaValue) jni_YGNodeStyleGetFlexBasis(mNativePointer);
}
private native void jni_YGNodeStyleSetFlexBasis(long nativePointer, float flexBasis);
@@ -335,13 +343,19 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
jni_YGNodeStyleSetFlexBasis(mNativePointer, flexBasis);
}
private native float jni_YGNodeStyleGetMargin(long nativePointer, int edge);
private native void jni_YGNodeStyleSetFlexBasisPercent(long nativePointer, float percent);
@Override
public float getMargin(YogaEdge edge) {
public void setFlexBasisPercent(float percent) {
jni_YGNodeStyleSetFlexBasisPercent(mNativePointer, percent);
}
private native Object jni_YGNodeStyleGetMargin(long nativePointer, int edge);
@Override
public YogaValue getMargin(YogaEdge edge) {
if (!mHasSetMargin) {
return edge.intValue() < YogaEdge.START.intValue() ? 0 : YogaConstants.UNDEFINED;
return edge.intValue() < YogaEdge.START.intValue() ? YogaValue.ZERO : YogaValue.UNDEFINED;
}
return jni_YGNodeStyleGetMargin(mNativePointer, edge.intValue());
return (YogaValue) jni_YGNodeStyleGetMargin(mNativePointer, edge.intValue());
}
private native void jni_YGNodeStyleSetMargin(long nativePointer, int edge, float margin);
@@ -351,13 +365,20 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
jni_YGNodeStyleSetMargin(mNativePointer, edge.intValue(), margin);
}
private native float jni_YGNodeStyleGetPadding(long nativePointer, int edge);
private native void jni_YGNodeStyleSetMarginPercent(long nativePointer, int edge, float percent);
@Override
public float getPadding(YogaEdge edge) {
public void setMarginPercent(YogaEdge edge, float percent) {
mHasSetMargin = true;
jni_YGNodeStyleSetMarginPercent(mNativePointer, edge.intValue(), percent);
}
private native Object jni_YGNodeStyleGetPadding(long nativePointer, int edge);
@Override
public YogaValue getPadding(YogaEdge edge) {
if (!mHasSetPadding) {
return edge.intValue() < YogaEdge.START.intValue() ? 0 : YogaConstants.UNDEFINED;
return edge.intValue() < YogaEdge.START.intValue() ? YogaValue.ZERO : YogaValue.UNDEFINED;
}
return jni_YGNodeStyleGetPadding(mNativePointer, edge.intValue());
return (YogaValue) jni_YGNodeStyleGetPadding(mNativePointer, edge.intValue());
}
private native void jni_YGNodeStyleSetPadding(long nativePointer, int edge, float padding);
@@ -367,6 +388,13 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
jni_YGNodeStyleSetPadding(mNativePointer, edge.intValue(), padding);
}
private native void jni_YGNodeStyleSetPaddingPercent(long nativePointer, int edge, float percent);
@Override
public void setPaddingPercent(YogaEdge edge, float percent) {
mHasSetPadding = true;
jni_YGNodeStyleSetPaddingPercent(mNativePointer, edge.intValue(), percent);
}
private native float jni_YGNodeStyleGetBorder(long nativePointer, int edge);
@Override
public float getBorder(YogaEdge edge) {
@@ -383,13 +411,13 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
jni_YGNodeStyleSetBorder(mNativePointer, edge.intValue(), border);
}
private native float jni_YGNodeStyleGetPosition(long nativePointer, int edge);
private native Object jni_YGNodeStyleGetPosition(long nativePointer, int edge);
@Override
public float getPosition(YogaEdge edge) {
public YogaValue getPosition(YogaEdge edge) {
if (!mHasSetPosition) {
return YogaConstants.UNDEFINED;
return YogaValue.UNDEFINED;
}
return jni_YGNodeStyleGetPosition(mNativePointer, edge.intValue());
return (YogaValue) jni_YGNodeStyleGetPosition(mNativePointer, edge.intValue());
}
private native void jni_YGNodeStyleSetPosition(long nativePointer, int edge, float position);
@@ -399,10 +427,17 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
jni_YGNodeStyleSetPosition(mNativePointer, edge.intValue(), position);
}
private native float jni_YGNodeStyleGetWidth(long nativePointer);
private native void jni_YGNodeStyleSetPositionPercent(long nativePointer, int edge, float percent);
@Override
public float getWidth() {
return jni_YGNodeStyleGetWidth(mNativePointer);
public void setPositionPercent(YogaEdge edge, float percent) {
mHasSetPosition = true;
jni_YGNodeStyleSetPositionPercent(mNativePointer, edge.intValue(), percent);
}
private native Object jni_YGNodeStyleGetWidth(long nativePointer);
@Override
public YogaValue getWidth() {
return (YogaValue) jni_YGNodeStyleGetWidth(mNativePointer);
}
private native void jni_YGNodeStyleSetWidth(long nativePointer, float width);
@@ -411,10 +446,16 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
jni_YGNodeStyleSetWidth(mNativePointer, width);
}
private native float jni_YGNodeStyleGetHeight(long nativePointer);
private native void jni_YGNodeStyleSetWidthPercent(long nativePointer, float percent);
@Override
public float getHeight() {
return jni_YGNodeStyleGetHeight(mNativePointer);
public void setWidthPercent(float percent) {
jni_YGNodeStyleSetWidthPercent(mNativePointer, percent);
}
private native Object jni_YGNodeStyleGetHeight(long nativePointer);
@Override
public YogaValue getHeight() {
return (YogaValue) jni_YGNodeStyleGetHeight(mNativePointer);
}
private native void jni_YGNodeStyleSetHeight(long nativePointer, float height);
@@ -423,10 +464,16 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
jni_YGNodeStyleSetHeight(mNativePointer, height);
}
private native float jni_YGNodeStyleGetMinWidth(long nativePointer);
private native void jni_YGNodeStyleSetHeightPercent(long nativePointer, float percent);
@Override
public float getMinWidth() {
return jni_YGNodeStyleGetMinWidth(mNativePointer);
public void setHeightPercent(float percent) {
jni_YGNodeStyleSetHeightPercent(mNativePointer, percent);
}
private native Object jni_YGNodeStyleGetMinWidth(long nativePointer);
@Override
public YogaValue getMinWidth() {
return (YogaValue) jni_YGNodeStyleGetMinWidth(mNativePointer);
}
private native void jni_YGNodeStyleSetMinWidth(long nativePointer, float minWidth);
@@ -435,10 +482,16 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
jni_YGNodeStyleSetMinWidth(mNativePointer, minWidth);
}
private native float jni_YGNodeStyleGetMinHeight(long nativePointer);
private native void jni_YGNodeStyleSetMinWidthPercent(long nativePointer, float percent);
@Override
public float getMinHeight() {
return jni_YGNodeStyleGetMinHeight(mNativePointer);
public void setMinWidthPercent(float percent) {
jni_YGNodeStyleSetMinWidthPercent(mNativePointer, percent);
}
private native Object jni_YGNodeStyleGetMinHeight(long nativePointer);
@Override
public YogaValue getMinHeight() {
return (YogaValue) jni_YGNodeStyleGetMinHeight(mNativePointer);
}
private native void jni_YGNodeStyleSetMinHeight(long nativePointer, float minHeight);
@@ -447,10 +500,16 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
jni_YGNodeStyleSetMinHeight(mNativePointer, minHeight);
}
private native float jni_YGNodeStyleGetMaxWidth(long nativePointer);
private native void jni_YGNodeStyleSetMinHeightPercent(long nativePointer, float percent);
@Override
public float getMaxWidth() {
return jni_YGNodeStyleGetMaxWidth(mNativePointer);
public void setMinHeightPercent(float percent) {
jni_YGNodeStyleSetMinHeightPercent(mNativePointer, percent);
}
private native Object jni_YGNodeStyleGetMaxWidth(long nativePointer);
@Override
public YogaValue getMaxWidth() {
return (YogaValue) jni_YGNodeStyleGetMaxWidth(mNativePointer);
}
private native void jni_YGNodeStyleSetMaxWidth(long nativePointer, float maxWidth);
@@ -459,10 +518,16 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
jni_YGNodeStyleSetMaxWidth(mNativePointer, maxWidth);
}
private native float jni_YGNodeStyleGetMaxHeight(long nativePointer);
private native void jni_YGNodeStyleSetMaxWidthPercent(long nativePointer, float percent);
@Override
public float getMaxHeight() {
return jni_YGNodeStyleGetMaxHeight(mNativePointer);
public void setMaxWidthPercent(float percent) {
jni_YGNodeStyleSetMaxWidthPercent(mNativePointer, percent);
}
private native Object jni_YGNodeStyleGetMaxHeight(long nativePointer);
@Override
public YogaValue getMaxHeight() {
return (YogaValue) jni_YGNodeStyleGetMaxHeight(mNativePointer);
}
private native void jni_YGNodeStyleSetMaxHeight(long nativePointer, float maxheight);
@@ -471,6 +536,12 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
jni_YGNodeStyleSetMaxHeight(mNativePointer, maxheight);
}
private native void jni_YGNodeStyleSetMaxHeightPercent(long nativePointer, float percent);
@Override
public void setMaxHeightPercent(float percent) {
jni_YGNodeStyleSetMaxHeightPercent(mNativePointer, percent);
}
private native float jni_YGNodeStyleGetAspectRatio(long nativePointer);
public float getAspectRatio() {
return jni_YGNodeStyleGetAspectRatio(mNativePointer);
@@ -501,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

@@ -45,32 +45,43 @@ public interface YogaNodeAPI<YogaNodeType extends YogaNodeAPI> {
void setFlexGrow(float flexGrow);
float getFlexShrink();
void setFlexShrink(float flexShrink);
float getFlexBasis();
YogaValue getFlexBasis();
void setFlexBasis(float flexBasis);
float getMargin(YogaEdge edge);
void setFlexBasisPercent(float percent);
YogaValue getMargin(YogaEdge edge);
void setMargin(YogaEdge edge, float margin);
float getPadding(YogaEdge edge);
void setMarginPercent(YogaEdge edge, float percent);
YogaValue getPadding(YogaEdge edge);
void setPadding(YogaEdge edge, float padding);
void setPaddingPercent(YogaEdge edge, float percent);
float getBorder(YogaEdge edge);
void setBorder(YogaEdge edge, float border);
float getPosition(YogaEdge edge);
YogaValue getPosition(YogaEdge edge);
void setPosition(YogaEdge edge, float position);
float getWidth();
void setPositionPercent(YogaEdge edge, float percent);
YogaValue getWidth();
void setWidth(float width);
float getHeight();
void setWidthPercent(float percent);
YogaValue getHeight();
void setHeight(float height);
float getMaxWidth();
void setHeightPercent(float percent);
YogaValue getMaxWidth();
void setMaxWidth(float maxWidth);
float getMinWidth();
void setMaxWidthPercent(float percent);
YogaValue getMinWidth();
void setMinWidth(float minWidth);
float getMaxHeight();
void setMinWidthPercent(float percent);
YogaValue getMaxHeight();
void setMaxHeight(float maxHeight);
float getMinHeight();
void setMaxHeightPercent(float percent);
YogaValue getMinHeight();
void setMinHeight(float minHeight);
void setMinHeightPercent(float percent);
float getLayoutX();
float getLayoutY();
float getLayoutWidth();
float getLayoutHeight();
float getLayoutPadding(YogaEdge edge);
YogaDirection getLayoutDirection();
YogaOverflow getOverflow();
void setOverflow(YogaOverflow overflow);

View File

@@ -0,0 +1,38 @@
/**
* 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.
*/
package com.facebook.yoga;
import com.facebook.proguard.annotations.DoNotStrip;
@DoNotStrip
public enum YogaUnit {
UNDEFINED(0),
PIXEL(1),
PERCENT(2);
private int mIntValue;
YogaUnit(int intValue) {
mIntValue = intValue;
}
public int intValue() {
return mIntValue;
}
public static YogaUnit fromInt(int value) {
switch (value) {
case 0: return UNDEFINED;
case 1: return PIXEL;
case 2: return PERCENT;
default: throw new IllegalArgumentException("Unkown enum value: " + value);
}
}
}

View File

@@ -0,0 +1,45 @@
/**
* 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.
*/
package com.facebook.yoga;
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);
public final float value;
public final YogaUnit unit;
YogaValue(float value, YogaUnit unit) {
this.value = value;
this.unit = unit;
}
@DoNotStrip
YogaValue(float value, int unit) {
this(value, YogaUnit.fromInt(unit));
}
@Override
public boolean equals(Object other) {
if (other instanceof YogaValue) {
final YogaValue otherValue = (YogaValue) other;
return value == otherValue.value && unit == otherValue.unit;
}
return false;
}
@Override
public int hashCode() {
return Float.floatToIntBits(value) + unit.intValue();
}
}