Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,8 @@ public object YogaNative {
@JvmStatic
public external fun jni_YGNodeSetHasMeasureFuncJNI(nativePointer: Long, hasMeasureFunc: Boolean)

@JvmStatic public external fun jni_YGNodeSetNodeTypeJNI(nativePointer: Long, nodeType: Int)

@JvmStatic
public external fun jni_YGNodeSetHasMinContentMeasureFuncJNI(
nativePointer: Long,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,17 @@ public abstract class YogaNode : YogaProps {

abstract override fun setMeasureFunction(measureFunction: YogaMeasureFunction?)

/**
* Sets the node type, which selects how layout is rounded to the pixel grid: a
* [YogaNodeType.TEXT] node's fractional size is rounded up and its position down, so its content
* is not truncated. [setMeasureFunction] sets it ([YogaNodeType.TEXT] for a function,
* [YogaNodeType.DEFAULT] for null), so call this after it.
*
* Does nothing by default, so a subclass built against an earlier [YogaNode] keeps working, with
* the rounding [setMeasureFunction] selected.
*/
public open fun setNodeType(nodeType: YogaNodeType) {}

abstract override fun setMinContentMeasureFunction(measureFunction: YogaMeasureFunction?)

abstract override fun setMinContentWidth(minContentWidth: Float)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,10 @@ public abstract class YogaNodeJNIBase : YogaNode, Cloneable {
YogaNative.jni_YGNodeSetHasMeasureFuncJNI(nativePointer, measureFunction != null)
}

override fun setNodeType(nodeType: YogaNodeType) {
YogaNative.jni_YGNodeSetNodeTypeJNI(nativePointer, nodeType.intValue())
}

override fun setMinContentMeasureFunction(measureFunction: YogaMeasureFunction?) {
this.minContentMeasureFunction = measureFunction
YogaNative.jni_YGNodeSetHasMinContentMeasureFuncJNI(nativePointer, measureFunction != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,15 @@ static void jni_YGNodeSetHasMeasureFuncJNI(
static_cast<bool>(hasMeasureFunc) ? YGJNIMeasureFunc : nullptr);
}

static void jni_YGNodeSetNodeTypeJNI(
JNIEnv* /*env*/,
jobject /*obj*/,
jlong nativePointer,
jint nodeType) {
YGNodeSetNodeType(
_jlong2YGNodeRef(nativePointer), static_cast<YGNodeType>(nodeType));
}

static YGSize YGJNIMinContentMeasureFunc(
YGNodeConstRef node,
float width,
Expand Down Expand Up @@ -1139,6 +1148,7 @@ static JNINativeMethod methods[] = {
"(JZ)V",
(void*)jni_YGNodeSetHasMeasureFuncJNI},
// NOLINTBEGIN(cppcoreguidelines-pro-type-cstyle-cast)
{"jni_YGNodeSetNodeTypeJNI", "(JI)V", (void*)jni_YGNodeSetNodeTypeJNI},
{"jni_YGNodeSetHasMinContentMeasureFuncJNI",
"(JZ)V",
(void*)jni_YGNodeSetHasMinContentMeasureFuncJNI},
Expand Down
Loading