Skip to content

Commit 803a297

Browse files
NickGerlemanfacebook-github-bot
authored andcommitted
Implement method bindings for gap/row-gap/column-gap
Summary: This adds method bindings for `YGNodeStyleSetGap` and `YGNodeStyleGetGap`. Changelog: [Genral][Added] - Implement method bindings for yoga gap/row-gap/column-gap Reviewed By: yungsters Differential Revision: D39922411 fbshipit-source-id: 6cbb4d352203d2ec92df162c3f2f2efd02bd9568
1 parent 1373a70 commit 803a297

File tree

4 files changed

+40
-1
lines changed

4 files changed

+40
-1
lines changed

ReactAndroid/src/main/java/com/facebook/yoga/YogaNative.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class YogaNative {
1515
static {
1616
SoLoader.loadLibrary("yoga");
1717
}
18-
18+
1919
// JNI methods that use Vanilla JNI
2020
// YGConfig related
2121
static native long jni_YGConfigNewJNI();
@@ -108,6 +108,8 @@ public class YogaNative {
108108
static native void jni_YGNodeStyleSetMaxHeightPercentJNI(long nativePointer, float percent);
109109
static native float jni_YGNodeStyleGetAspectRatioJNI(long nativePointer);
110110
static native void jni_YGNodeStyleSetAspectRatioJNI(long nativePointer, float aspectRatio);
111+
static native float jni_YGNodeStyleGetGapJNI(long nativePointer, int gutter);
112+
static native void jni_YGNodeStyleSetGapJNI(long nativePointer, int gutter, float gapLength);
111113
static native void jni_YGNodeSetHasMeasureFuncJNI(long nativePointer, boolean hasMeasureFunc);
112114
static native void jni_YGNodeSetHasBaselineFuncJNI(long nativePointer, boolean hasMeasureFunc);
113115
static native void jni_YGNodePrintJNI(long nativePointer);

ReactAndroid/src/main/java/com/facebook/yoga/YogaNode.java

+4
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,10 @@ public interface Inputs {
188188

189189
public abstract void setAspectRatio(float aspectRatio);
190190

191+
public abstract float getGap(YogaGutter gutter);
192+
193+
public abstract void setGap(YogaGutter gutter, float gapLength);
194+
191195
public abstract float getLayoutX();
192196

193197
public abstract float getLayoutY();

ReactAndroid/src/main/java/com/facebook/yoga/YogaNodeJNIBase.java

+10
Original file line numberDiff line numberDiff line change
@@ -725,4 +725,14 @@ public void markLayoutSeen() {
725725
}
726726
mHasNewLayout = false;
727727
}
728+
729+
@Override
730+
public float getGap(YogaGutter gutter) {
731+
return YogaNative.jni_YGNodeStyleGetGapJNI(mNativePointer, gutter.intValue());
732+
}
733+
734+
@Override
735+
public void setGap(YogaGutter gutter, float gapLength) {
736+
YogaNative.jni_YGNodeStyleSetGapJNI(mNativePointer, gutter.intValue(), gapLength);
737+
}
728738
}

ReactAndroid/src/main/jni/first-party/yogajni/jni/YGJNIVanilla.cpp

+23
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,27 @@ static jlong jni_YGNodeCloneJNI(JNIEnv* env, jobject obj, jlong nativePointer) {
734734
return reinterpret_cast<jlong>(clonedYogaNode);
735735
}
736736

737+
static jfloat jni_YGNodeStyleGetGapJNI(
738+
JNIEnv* env,
739+
jobject obj,
740+
jlong nativePointer,
741+
jint gutter) {
742+
return (jfloat) YGNodeStyleGetGap(
743+
_jlong2YGNodeRef(nativePointer), static_cast<YGGutter>(gutter));
744+
}
745+
746+
static void jni_YGNodeStyleSetGapJNI(
747+
JNIEnv* env,
748+
jobject obj,
749+
jlong nativePointer,
750+
jint gutter,
751+
jfloat gapLength) {
752+
YGNodeStyleSetGap(
753+
_jlong2YGNodeRef(nativePointer),
754+
static_cast<YGGutter>(gutter),
755+
static_cast<float>(gapLength));
756+
}
757+
737758
// Yoga specific properties, not compatible with flexbox specification
738759
YG_NODE_JNI_STYLE_PROP(jfloat, float, AspectRatio);
739760

@@ -971,6 +992,8 @@ static JNINativeMethod methods[] = {
971992
{"jni_YGNodeSetHasMeasureFuncJNI",
972993
"(JZ)V",
973994
(void*) jni_YGNodeSetHasMeasureFuncJNI},
995+
{"jni_YGNodeStyleGetGapJNI", "(JI)F", (void*) jni_YGNodeStyleGetGapJNI},
996+
{"jni_YGNodeStyleSetGapJNI", "(JIF)V", (void*) jni_YGNodeStyleSetGapJNI},
974997
{"jni_YGNodeSetHasBaselineFuncJNI",
975998
"(JZ)V",
976999
(void*) jni_YGNodeSetHasBaselineFuncJNI},

0 commit comments

Comments
 (0)