feat: introduce binding generator

A squash of hundreds of commits with a binding API generator.

The API generator works with a hybrid model:
1. We define methods and fields in the code.
2. Mark them with API annotations.
3. For specific use cases, we use the old approach with JNI generation comments.

There is also an API to generate an AST tree, which is saved to JSON.
This JSON can be used for full API generation by declaring only field/method names.
Currently, it is used to generate constants.

By eyeballing, 95% of the API has been converted to the new approach.
This is sufficient for the current moment. Only edge cases with specific API calls are left.

fix: ambiguous call for ImGui::GetColorU32

build: disable checkstyle for imgui-binding module

Since the module is heavily generated, checkstyle for it doesn't make sense.

build: make buildSrc to use JDK 11

build: make generateApi optional when compiling project

Initially generated module was not included to the project VCS.
Since it's now in the separate src folder, we don't need to call generator every time.
Only when a new generation result is required.
This commit is contained in:
SpaiR committed 2024-08-08 14:46:23 +03:00
1 parent e64df5a433
commit 8a8cd22ed6
323 files changed
+113518 -15318

No files matched your search

+20
View File
@@ -1,3 +1,5 @@
import tool.generator.ast.task.GenerateAst
import java.text.SimpleDateFormat
ext {
@@ -45,3 +47,21 @@ tasks.register('buildAll') { t ->
}
}
}
tasks.register('generateAst', GenerateAst) {
headerFiles = [
(file('include/imgui/imgui.h')): [],
(file('include/imgui/imgui_internal.h')): [
"#define IMGUI_HAS_TABLE",
"#define IMGUI_HAS_VIEWPORT",
"#define IMGUI_HAS_DOCK",
],
(file('include/ImGuiFileDialog/ImGuiFileDialog.h')): [],
(file('include/imgui-knobs/imgui-knobs.h')): [],
(file('include/imguizmo/ImGuizmo.h')): [],
(file('include/imnodes/imnodes.h')): [],
(file('include/implot/implot.h')): [],
(file('include/imgui-node-editor/imgui_node_editor.h')): [],
(file('include/ImGuiColorTextEdit/TextEditor.h')): [],
]
}
-18
View File
@@ -1,18 +0,0 @@
plugins {
id 'groovy'
}
repositories {
mavenCentral()
}
ext {
jnigenVersion = '2.4.0'
}
dependencies {
implementation gradleApi()
implementation localGroovy()
implementation "com.badlogicgames.gdx:gdx-jnigen:$jnigenVersion"
}
+31
View File
@@ -0,0 +1,31 @@
plugins {
groovy
`kotlin-dsl`
}
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(11))
}
}
kotlinDslPluginOptions {
jvmTarget.set("11") // TODO: remove when migrating to Gradle 8
}
repositories {
mavenCentral()
}
dependencies {
implementation(gradleApi())
implementation(localGroovy())
implementation("com.badlogicgames.gdx:gdx-jnigen:2.4.0")
implementation("org.reflections:reflections:0.10.2")
implementation("com.lordcodes.turtle:turtle:0.6.0")
implementation("fr.inria.gforge.spoon:spoon-core:10.3.0")
implementation("com.fasterxml.jackson.core:jackson-core:2.14.2")
implementation("com.fasterxml.jackson.core:jackson-databind:2.14.2")
}
@@ -36,7 +36,7 @@ class GenerateLibs extends DefaultTask {
private final boolean isLocal = System.properties.containsKey('local')
private final boolean withFreeType = Boolean.valueOf(System.properties.getProperty('freetype', 'false'))
private final String sourceDir = project.file('src/main/java')
private final String sourceDir = project.file('src/generated/java')
private final String classpath = project.file('build/classes/java/main')
private final String rootDir = (isLocal ? project.buildDir.path : '/tmp/imgui')
private final String jniDir = "$rootDir/jni"
@@ -0,0 +1,155 @@
package tool.generator.api
import spoon.reflect.code.CtJavaDoc
import spoon.reflect.declaration.CtElement
import spoon.reflect.declaration.CtField
import spoon.reflect.declaration.CtMethod
import spoon.reflect.declaration.CtType
class BindingSourceProcessor(
private val type: CtType<*>
) {
companion object {
private const val BLANK_SPACE = " "
private val CLEANUP_ANNOTATIONS_REGEX = Regex(
"@" + CLEANUP_ANNOTATIONS_LIST.joinToString(separator = "|", prefix = "(", postfix = ")") + ".*"
)
private val CLEANUP_IMPORTS_REGEX = Regex(
"import.+" + CLEANUP_ANNOTATIONS_LIST.joinToString(separator = "|", prefix = "(", postfix = ")")
)
fun isProcessable(type: CtType<*>): Boolean {
return type.hasAnnotation(A_NAME_BINDING_SOURCE)
}
}
private val originalContent: String = type.position.file.readText()
fun process() {
val contentToReplace = mutableMapOf<ReplacePos, String>()
contentToReplace += collectBindingFields()
contentToReplace += collectBindingMethods()
contentToReplace += collectBindingAstEnums()
val contentBuilder = StringBuilder(originalContent)
contentToReplace.keys.sortedDescending().forEach { replacePos ->
contentBuilder.replace(replacePos.startIdx, replacePos.endIdx, contentToReplace[replacePos])
}
cleanupBindingAnnotations(contentBuilder)
type.position.file.writeText(contentBuilder.toString())
}
private fun collectBindingFields(): Map<ReplacePos, String> {
val result = mutableMapOf<ReplacePos, String>()
for (field in type.fields) {
if (field.hasAnnotation(A_NAME_BINDING_FIELD)) {
result += processBindingField(field)
}
}
return result
}
private fun collectBindingMethods(): Map<ReplacePos, String> {
val result = mutableMapOf<ReplacePos, String>()
for (method in type.methods) {
if (method.hasAnnotation(A_NAME_BINDING_METHOD)) {
result += processBindingMethod(method)
}
}
return result
}
private fun collectBindingAstEnums(): Map<ReplacePos, String> {
val result = mutableMapOf<ReplacePos, String>()
for (field in type.fields) {
if (field.hasAnnotation(A_NAME_BINDING_AST_ENUM)) {
result += processBindingAstEnum(field)
}
}
return result
}
private fun cleanupBindingAnnotations(contentBuilder: StringBuilder) {
val linesToRemove = mutableListOf<String>()
contentBuilder.lineSequence().forEach { line ->
if (line.contains(CLEANUP_IMPORTS_REGEX)) {
linesToRemove += line
}
if (line.contains(CLEANUP_ANNOTATIONS_REGEX)) {
linesToRemove += line
}
}
linesToRemove.reversed().forEach { line ->
val idx = contentBuilder.indexOf(line)
contentBuilder.delete(idx, idx + line.length + 1)
}
}
private fun processBindingMethod(method: CtMethod<*>): Map<ReplacePos, String> {
val contentToReplace = mutableMapOf<ReplacePos, String>()
// Remove the original javadoc comment from the generated content.
method.comments.find { it is CtJavaDoc }?.let {
// sourceEnd has an additional offset of 6.
// 1 - '/'
// 2 - '\n'
// 3-6 - ' '
contentToReplace[ReplacePos(it.position.sourceStart, it.position.sourceEnd + 6)] = ""
}
val content = jvmMethodContent(method) + jniMethodContent(method)
contentToReplace[method.findReplacePos()] = content.joinWithIndention()
return contentToReplace
}
private fun processBindingField(field: CtField<*>): Map<ReplacePos, String> {
val contentToReplace = mutableMapOf<ReplacePos, String>()
// Remove the original javadoc comment from the generated content.
field.comments.find { it is CtJavaDoc }?.let {
// sourceEnd has an additional offset of 6.
// 1 - '/'
// 2 - '\n'
// 3-6 - ' '
contentToReplace[ReplacePos(it.position.sourceStart, it.position.sourceEnd + 6)] = ""
}
val content = jvmFieldContent(field) + jniFieldContent(field)
contentToReplace[field.findReplacePos()] = content.joinWithIndention()
return contentToReplace
}
private fun processBindingAstEnum(field: CtField<*>): Map<ReplacePos, String> {
val content = astEnumContent(field.getAnnotation(A_NAME_BINDING_AST_ENUM)!!)
val contentStr = content.joinWithIndention()
return mapOf(field.findReplacePos() to contentStr)
}
private fun List<String>.joinWithIndention(): String {
return joinToString("\n\n") { str ->
str.lines().joinToString("\n") {
it.takeIf(String::isNotBlank)?.prependIndent(BLANK_SPACE) ?: it
}
}
}
private fun CtElement.findReplacePos(): ReplacePos {
var startIdx = annotations[0].position.sourceStart
while (originalContent[startIdx] != '\n') {
startIdx--
}
startIdx++
val endIdx = position.sourceEnd + 1
return ReplacePos(startIdx, endIdx)
}
private data class ReplacePos(val startIdx: Int, val endIdx: Int) : Comparable<ReplacePos> {
override fun compareTo(other: ReplacePos): Int {
return startIdx.compareTo(other.startIdx)
}
}
}
@@ -0,0 +1,23 @@
package tool.generator.api
import org.apache.commons.io.FileUtils
import spoon.reflect.declaration.CtType
class ExcludedSourceProcessor(
private val type: CtType<*>
) {
companion object {
fun isProcessable(type: CtType<*>): Boolean {
return type.hasAnnotation(A_NAME_EXCLUDED_SOURCE)
}
}
fun process() {
val sourceFile = type.position.file
val parentDir = sourceFile.parentFile
sourceFile.delete()
if (FileUtils.isEmptyDirectory(parentDir)) {
parentDir.delete()
}
}
}
@@ -0,0 +1,60 @@
package tool.generator.api
import spoon.reflect.declaration.CtAnnotation
import spoon.reflect.declaration.ModifierKind
import tool.generator.ast.AstEnumConstantDecl
import tool.generator.ast.AstParser
fun astEnumContent(markerAnnotation: CtAnnotation<*>): List<String> {
val result = mutableListOf<String>()
val file = markerAnnotation.getValueAsString(A_VALUE_FILE)!!
val qualType = markerAnnotation.getValueAsString(A_VALUE_QUAL_TYPE)!!
val sanitizeName = markerAnnotation.getValueAsString(A_VALUE_SANITIZE_NAME)?.takeIf(String::isNotEmpty) ?: qualType
val astRoot = AstParser.readFromResource(file)
val enums = astRoot.decls.filterDecls0 {
it is AstEnumConstantDecl && it.qualType == qualType
}.map { it as AstEnumConstantDecl }
val factory = markerAnnotation.factory
enums.forEach { e ->
val f = factory.createField<Nothing>()
f.setModifiers<Nothing>(setOf(ModifierKind.PUBLIC, ModifierKind.STATIC, ModifierKind.FINAL))
f.setType<Nothing>(factory.createTypeParam("int"))
f.setSimpleName<Nothing>(e.name.replace(sanitizeName, ""))
buildString {
if (e.docComment != null) {
appendLine(e.docComment)
if (e.value != null) {
appendLine()
append("<p>")
}
}
if (e.value != null) {
append("Definition: {@code ${e.value}}")
}
}.let {
if (it.isNotEmpty()) {
f.setDocComment<Nothing>(sanitizeDocComment(it))
}
}
f.setAssignment<Nothing>(factory.createCodeSnippetExpression((e.evaluatedValue ?: e.order).toString()))
result += f.prettyprint()
}
return result
}
private fun sanitizeDocComment(doc: String): String {
return doc
.replace("*/", "* /")
.replace(" > ", "{@code >}")
.replace("< <", "{@code <<}")
.replace(" < ", "{@code <}")
.replace("->", "{@code ->}")
.replace("&", "{@code &}")
}
@@ -0,0 +1,688 @@
package tool.generator.api
import spoon.reflect.code.CtStatement
import spoon.reflect.declaration.CtField
import spoon.reflect.declaration.CtMethod
import spoon.reflect.declaration.CtParameter
import spoon.reflect.declaration.ModifierKind
import spoon.reflect.factory.Factory
import spoon.reflect.reference.CtTypeReference
private fun convertParams2jni(f: Factory, params: List<CtParameter<*>>, defaults: IntArray): List<CtParameter<*>> {
val result = mutableListOf<CtParameter<*>>()
for ((index, p) in params.withIndex()) {
if (defaults.isNotEmpty() && !defaults.contains(index)) {
continue
}
if (p.isType("Void")) {
continue
}
if (p.isType("ImVec2") || p.isType("ImVec4")) { // vec param always accepted as primitive values
result += f.createParameter<Nothing>().apply {
setType<Nothing>(f.createTypeParam("float"))
setSimpleName<Nothing>("${p.simpleName}X")
}
result += f.createParameter<Nothing>().apply {
setType<Nothing>(f.createTypeParam("float"))
setSimpleName<Nothing>("${p.simpleName}Y")
}
if (p.isType("ImVec4")) {
result += f.createParameter<Nothing>().apply {
setType<Nothing>(f.createTypeParam("float"))
setSimpleName<Nothing>("${p.simpleName}Z")
}
result += f.createParameter<Nothing>().apply {
setType<Nothing>(f.createTypeParam("float"))
setSimpleName<Nothing>("${p.simpleName}W")
}
}
} else if (p.isType("ImRect")) {
result += f.createParameter<Nothing>().apply {
setType<Nothing>(f.createTypeParam("float"))
setSimpleName<Nothing>("${p.simpleName}MinX")
}
result += f.createParameter<Nothing>().apply {
setType<Nothing>(f.createTypeParam("float"))
setSimpleName<Nothing>("${p.simpleName}MinY")
}
result += f.createParameter<Nothing>().apply {
setType<Nothing>(f.createTypeParam("float"))
setSimpleName<Nothing>("${p.simpleName}MaxX")
}
result += f.createParameter<Nothing>().apply {
setType<Nothing>(f.createTypeParam("float"))
setSimpleName<Nothing>("${p.simpleName}MaxY")
}
} else if (p.isType("ImPlotPoint")) {
result += f.createParameter<Nothing>().apply {
setType<Nothing>(f.createTypeParam("double"))
setSimpleName<Nothing>("${p.simpleName}X")
}
result += f.createParameter<Nothing>().apply {
setType<Nothing>(f.createTypeParam("double"))
setSimpleName<Nothing>("${p.simpleName}Y")
}
} else if (p.isType("ImPlotRange")) {
result += f.createParameter<Nothing>().apply {
setType<Nothing>(f.createTypeParam("double"))
setSimpleName<Nothing>("${p.simpleName}Min")
}
result += f.createParameter<Nothing>().apply {
setType<Nothing>(f.createTypeParam("double"))
setSimpleName<Nothing>("${p.simpleName}Max")
}
} else if (p.isType("ImPlotLimits")) {
result += f.createParameter<Nothing>().apply {
setType<Nothing>(f.createTypeParam("double"))
setSimpleName<Nothing>("${p.simpleName}MinX")
}
result += f.createParameter<Nothing>().apply {
setType<Nothing>(f.createTypeParam("double"))
setSimpleName<Nothing>("${p.simpleName}MinY")
}
result += f.createParameter<Nothing>().apply {
setType<Nothing>(f.createTypeParam("double"))
setSimpleName<Nothing>("${p.simpleName}MaxX")
}
result += f.createParameter<Nothing>().apply {
setType<Nothing>(f.createTypeParam("double"))
setSimpleName<Nothing>("${p.simpleName}MaxY")
}
} else if (p.isType("TextEditorCoordinates")) {
result += f.createParameter<Nothing>().apply {
setType<Nothing>(f.createTypeParam("int"))
setSimpleName<Nothing>("${p.simpleName}Line")
}
result += f.createParameter<Nothing>().apply {
setType<Nothing>(f.createTypeParam("int"))
setSimpleName<Nothing>("${p.simpleName}Column")
}
} else if (p.isType("String[]")) {
result += f.createParameter<Nothing>().apply {
setType<Nothing>(f.createTypeParam("String[]"))
setSimpleName<Nothing>(p.simpleName)
}
result += f.createParameter<Nothing>().apply {
setType<Nothing>(f.createTypeParam("int"))
setSimpleName<Nothing>("${p.simpleName}$PARAM_ARR_LEN_POSTFIX")
}
} else {
result += f.createParameter<Nothing>().apply {
val type = if (p.type.isPtrClass()) {
f.createTypeParam("long")
} else if (p.type.isClass) {
when (p.type.simpleName) {
"ImBoolean" -> f.createTypeParam("boolean[]")
"ImInt" -> f.createTypeParam("int[]")
"ImFloat" -> f.createTypeParam("float[]")
"ImLong" -> f.createTypeParam("long[]")
"ImDouble" -> f.createTypeParam("double[]")
else -> p.type
}
} else {
p.type
}
setType<Nothing>(type)
setSimpleName<Nothing>(p.simpleName)
}
}
}
return result
}
private fun joinInBodyParams(params: List<CtParameter<*>>, defaults: IntArray): String {
fun param2str(p: CtParameter<*>): String {
return if (p.type.isPtrClass()) {
"reinterpret_cast<${p.type.simpleName}*>(${p.simpleName})"
} else if (p.isPrimitivePtrType()) {
"&${p.simpleName}[0]"
} else if (p.type.isClass) {
when (p.type.simpleName) {
"ImBoolean", "ImInt", "ImFloat", "ImLong", "ImDouble" -> {
"(${p.simpleName} != NULL ? &${p.simpleName}[0] : NULL)"
}
"ImRect" -> {
"ImRect(${p.simpleName}MinX, ${p.simpleName}MinY, ${p.simpleName}MaxX, ${p.simpleName}MaxY)"
}
"ImPlotPoint" -> {
"ImPlotPoint(${p.simpleName}X, ${p.simpleName}Y)"
}
"ImPlotRange" -> {
"ImPlotRange(${p.simpleName}Min, ${p.simpleName}Max)"
}
"ImPlotLimits" -> {
"ImPlotLimits(${p.simpleName}MinX, ${p.simpleName}MinY, ${p.simpleName}MaxX, ${p.simpleName}MaxY)"
}
"TextEditorCoordinates" -> {
"TextEditor::Coordinates(${p.simpleName}Line, ${p.simpleName}Column)"
}
else -> p.simpleName
}
} else {
p.simpleName
}
}
val visibleParams = mutableListOf<String>()
for ((index, p) in params.withIndex()) {
if (defaults.isNotEmpty() && !defaults.contains(index)) {
visibleParams += p.getAnnotation(A_NAME_OPT_ARG)!!.getValueAsString(A_VALUE_CALL_VALUE)
continue
}
if (p.isType("Void")) {
visibleParams += p.getAnnotation(A_NAME_ARG_VALUE)?.getValueAsString(A_VALUE_CALL_VALUE) ?: p.simpleName
continue
}
var value = param2str(p)
p.getAnnotation(A_NAME_ARG_VALUE)?.let { a ->
a.getValueAsString(A_VALUE_CALL_VALUE).takeIf(String::isNotEmpty)?.let { v ->
value = v
}
a.getValueAsString(A_VALUE_CALL_PREFIX).takeIf(String::isNotEmpty)?.let { v ->
value = v + value
}
a.getValueAsString(A_VALUE_CALL_SUFFIX).takeIf(String::isNotEmpty)?.let { v ->
value += v
}
a.getValueAsString(A_VALUE_STATIC_CAST).takeIf(String::isNotEmpty)?.let { v ->
value = "static_cast<$v>($value)"
}
a.getValueAsString(A_VALUE_REINTERPRET_CAST).takeIf(String::isNotEmpty)?.let { v ->
value = "reinterpret_cast<$v>($value)"
}
}
visibleParams += value
}
return visibleParams.joinToString()
}
private fun createMethod(mOrig: CtMethod<*>, params: List<CtParameter<*>>, defaults: IntArray): CtMethod<*> {
val f = mOrig.factory
val newM = f.createMethod<Nothing>()
newM.setParent<Nothing>(mOrig.parent)
newM.addModifier<Nothing>(ModifierKind.PRIVATE)
newM.addModifier<Nothing>(ModifierKind.NATIVE)
if (mOrig.isStatic) {
newM.addModifier<Nothing>(ModifierKind.STATIC)
}
if (DST_RETURN_TYPE_SET.contains(mOrig.type.simpleName)) {
newM.setType<Nothing>(f.createTypeParam("void"))
} else if (mOrig.type.isPtrClass()) { // classes returned as a pointer
newM.setType<Nothing>(f.createTypeParam("long"))
} else {
newM.setType<Nothing>(mOrig.type)
}
newM.setSimpleName<Nothing>(mOrig.getJniName())
convertParams2jni(f, params, defaults).forEach {
newM.addParameter<Nothing>(it)
}
if (DST_RETURN_TYPE_SET.contains(mOrig.type.simpleName)) {
newM.addParameterAt<Nothing>(0, f.createParameter<Nothing>().apply {
setType<Nothing>(mOrig.type)
setSimpleName<Nothing>("dst")
})
}
newM.setBody<Nothing>(f.createCodeSnippet(
buildString {
val jniCpyReturn = DST_RETURN_TYPE_SET.contains(mOrig.type.simpleName)
val isStrReturn = mOrig.isType("String")
if (jniCpyReturn) {
append("Jni::${mOrig.type.simpleName}Cpy(env, ")
} else {
if (!mOrig.isType("void")) {
append("return ")
if (isStrReturn) {
append("env->NewStringUTF(")
} else if (!mOrig.type.isPrimitive) {
append("($PTR_JNI_CAST)")
}
mOrig.getAnnotation(A_NAME_RETURN_VALUE)?.let { a ->
append(a.getValueAsString(A_VALUE_CALL_PREFIX))
}
}
}
val callName = mOrig.getAnnotation(A_NAME_BINDING_METHOD)?.let { a ->
a.getValueAsString(A_VALUE_CALL_NAME)?.takeIf(String::isNotEmpty)
} ?: mOrig.simpleName
val callPtr = mOrig.parent.getAnnotation(A_NAME_BINDING_SOURCE)!!.let { a ->
a.getValueAsString(A_VALUE_CALL_PTR)?.takeIf(String::isNotEmpty) ?: if (mOrig.isStatic) {
mOrig.declaringType.simpleName
} else {
PTR_JNI_THIS
}
}
val callOperator = mOrig.parent.getAnnotation(A_NAME_BINDING_SOURCE)!!.let { a ->
a.getValueAsString(A_VALUE_CALL_OPERATOR)?.takeIf(String::isNotEmpty) ?: if (mOrig.isStatic) {
"::"
} else {
"->"
}
}
append("$callPtr$callOperator${callName}(")
append(joinInBodyParams(params, defaults))
append(')')
mOrig.getAnnotation(A_NAME_RETURN_VALUE)?.let { a ->
append(a.getValueAsString(A_VALUE_CALL_SUFFIX))
}
if (jniCpyReturn) {
append(", dst)")
} else if (isStrReturn) {
append(')')
}
}
))
return newM
}
private fun createMethodVecValueReturn(
vecVal: String,
mOrig: CtMethod<*>,
nameOrig: String,
params: List<CtParameter<*>>,
defaults: IntArray
): CtMethod<*> {
val callPtr = mOrig.parent.getAnnotation(A_NAME_BINDING_SOURCE)!!.let { a ->
a.getValueAsString(A_VALUE_CALL_PTR)?.takeIf(String::isNotEmpty) ?: if (mOrig.isStatic) {
mOrig.declaringType.simpleName
} else {
PTR_JNI_THIS
}
}
val callOperator = mOrig.parent.getAnnotation(A_NAME_BINDING_SOURCE)!!.let { a ->
a.getValueAsString(A_VALUE_CALL_OPERATOR)?.takeIf(String::isNotEmpty) ?: if (mOrig.isStatic) {
"::"
} else {
"->"
}
}
val mNew = mOrig.clone()
mNew.setSimpleName<Nothing>(mOrig.simpleName + vecVal.capitalize())
mNew.removeParameter(mNew.parameters[0]) // dst param which was added during orig method creation
mNew.type.setSimpleName<Nothing>("float")
mNew.setBody<Nothing>(mOrig.factory.createCodeSnippet(
buildString {
append("return ")
append("$callPtr$callOperator$nameOrig(")
append(joinInBodyParams(params, defaults))
append(").$vecVal")
}
))
return mNew
}
private fun convertManualJni(mOrig: CtMethod<*>, method: CtMethod<*>): CtMethod<*>? {
val mNew = method.clone()
val getLines = mutableListOf<String>()
val releaseLines = mutableListOf<String>()
mNew.parameters.forEach { p ->
var isConverted = false
if (p.isPrimitivePtrType()) {
val typeCast = PRIMITIVE_PTR_TYPECAST_MAP[p.type.simpleName]
getLines += "auto ${p.simpleName} = obj_${p.simpleName} == NULL ? NULL : (${typeCast})env->GetPrimitiveArrayCritical(obj_${p.simpleName}, JNI_FALSE)"
releaseLines += "if (${p.simpleName} != NULL) env->ReleasePrimitiveArrayCritical(obj_${p.simpleName}, ${p.simpleName}, JNI_FALSE)"
isConverted = true
}
if (p.isType("String")) {
getLines += "auto ${p.simpleName} = obj_${p.simpleName} == NULL ? NULL : (char*)env->GetStringUTFChars(obj_${p.simpleName}, JNI_FALSE)"
releaseLines += "if (${p.simpleName} != NULL) env->ReleaseStringUTFChars(obj_${p.simpleName}, ${p.simpleName})"
isConverted = true
}
if (p.isType("String[]")) {
val countParam = "${p.simpleName}$PARAM_ARR_LEN_POSTFIX"
getLines += """
const char* ${p.simpleName}[$countParam];
for (int i = 0; i < ${p.simpleName}$PARAM_ARR_LEN_POSTFIX; i++) {
const jstring str = (jstring)env->GetObjectArrayElement(obj_${p.simpleName}, i);
auto rawStr = (char*)env->GetStringUTFChars(str, JNI_FALSE);
${p.simpleName}[i] = rawStr;
}
""".trimIndent()
releaseLines += """
for (int i = 0; i < $countParam; i++) {
const jstring str = (jstring)env->GetObjectArrayElement(obj_${p.simpleName}, i);
env->ReleaseStringUTFChars(str, ${p.simpleName}[i]);
}
""".trimIndent()
isConverted = true
}
if (p.isType("ImVec2[]")) {
val lengthVar = "${p.simpleName}Length"
getLines += """
int $lengthVar = env->GetArrayLength(obj_${p.simpleName});
ImVec2 ${p.simpleName}[$lengthVar];
for (int i = 0; i < $lengthVar; i++) {
jobject src = env->GetObjectArrayElement(obj_${p.simpleName}, i);
ImVec2 dst;
Jni::ImVec2Cpy(env, src, &dst);
${p.simpleName}[i] = dst;
}
""".trimIndent()
isConverted = true
}
if (p.isType("ImVec4[]")) {
val lengthVar = "${p.simpleName}Length"
getLines += """
int $lengthVar = env->GetArrayLength(obj_${p.simpleName});
ImVec4 ${p.simpleName}[$lengthVar];
for (int i = 0; i < $lengthVar; i++) {
jobject src = env->GetObjectArrayElement(obj_${p.simpleName}, i);
ImVec4 dst;
Jni::ImVec4Cpy(env, src, &dst);
${p.simpleName}[i] = dst;
}
""".trimIndent()
isConverted = true
}
fun isAddPrefixType(type: CtTypeReference<*>): Boolean {
return setOf(
"String[]",
"ImVec2[]",
"ImVec4[]",
).contains(type.simpleName)
}
if (isConverted && (!mNew.isType("void") || isAddPrefixType(p.type))) {
p.setSimpleName<Nothing>("obj_" + p.simpleName)
}
}
// Sine we work with an already transformed method, which doesn't contain original information,
// we need to process the original method instead. For example, ImVec args are transformed into floats.
mOrig.parameters.forEach { p ->
// Transformed method may not have the current param. For example, if it's optional.
// So for ImVec arguments we check, if there is a parameter with the same name and "X" attached.
// It's a sort of marker in our case.
if (method.parameters.find { it.simpleName == p.simpleName + "X" } != null) {
if (p.isType("ImVec2")) {
getLines += "ImVec2 ${p.simpleName} = ImVec2(${p.simpleName}X, ${p.simpleName}Y)"
}
if (p.isType("ImVec4")) {
getLines += "ImVec4 ${p.simpleName} = ImVec4(${p.simpleName}X, ${p.simpleName}Y, ${p.simpleName}Z, ${p.simpleName}W)"
}
}
}
if (getLines.isNotEmpty() || releaseLines.isNotEmpty()) {
val bOrigCode = mNew.body.getLastStatement<CtStatement>().prettyprint()
mNew.body.statements.clear()
getLines.forEach {
mNew.body.addStatement<Nothing>(mNew.factory.createCodeSnippet(it))
}
mNew.body.addStatement<Nothing>(mNew.factory.createCodeSnippet(bOrigCode.replace("return ", "auto _result = ")))
releaseLines.forEach {
mNew.body.addStatement<Nothing>(mNew.factory.createCodeSnippet(it))
}
if (!mNew.isType("void")) {
mNew.body.addStatement<Nothing>(mNew.factory.createCodeSnippet("return _result"))
}
return mNew
}
return null
}
private fun CtMethod<*>.prettyprint(isManual: Boolean): String {
return buildString {
val str = prettyprint().let {
if (isManual) {
it.replaceFirst(" {", "; /*MANUAL")
} else {
it.replaceFirst(" {", "; /*")
}
}
append(str)
lastIndexOf("}").let { idx ->
replace(idx, idx + 1, "*/")
}
}
}
private fun transformMethodToContent(
mOrig: CtMethod<*>,
params: List<CtParameter<*>> = emptyList(),
defaults: IntArray = intArrayOf()
): List<String> {
fun CtMethod<*>.printJni(): String {
return convertManualJni(mOrig, this)?.prettyprint(true) ?: prettyprint(false)
}
val methods = mutableListOf<String>()
val mNew = createMethod(mOrig, params, defaults)
methods += mNew.printJni()
if (mOrig.isType("ImVec2") || mOrig.isType("ImVec4")) {
methods += createMethodVecValueReturn("x", mNew, mOrig.simpleName, params, defaults).printJni()
methods += createMethodVecValueReturn("y", mNew, mOrig.simpleName, params, defaults).printJni()
if (mOrig.isType("ImVec4")) {
methods += createMethodVecValueReturn("z", mNew, mOrig.simpleName, params, defaults).printJni()
methods += createMethodVecValueReturn("w", mNew, mOrig.simpleName, params, defaults).printJni()
}
}
return methods
}
fun jniMethodContent(method: CtMethod<*>): List<String> {
val methods = mutableListOf<String>()
for (paramsSize in (findFirstOptParam(method)..method.parameters.size)) {
val params = method.parameters.subList(0, paramsSize)
methods += transformMethodToContent(method, params)
}
for (defaults in findDefaultsCombinations(method)) {
methods += transformMethodToContent(method, method.parameters, defaults)
}
return methods
}
private fun createFieldGetContent(field: CtField<*>): List<String> {
val f = field.factory
val getAccessor = f.createMethod<Nothing>()
getAccessor.setParent<Nothing>(field.parent)
getAccessor.setSimpleName<Nothing>("get${field.simpleName}")
getAccessor.setType<Nothing>(field.type)
getAccessor.addModifier<Nothing>(ModifierKind.PRIVATE)
getAccessor.setAnnotations<Nothing>(field.annotations)
val result = mutableListOf<String>()
if (field.hasAnnotation(A_NAME_TYPE_ARRAY)) {
val arrayType = field.getAnnotation(A_NAME_TYPE_ARRAY)!!.getValueAsString(A_VALUE_TYPE)
val arraySize = field.getAnnotation(A_NAME_TYPE_ARRAY)!!.getValueAsString(A_VALUE_SIZE)
val getArray = getAccessor.clone()
getArray.addModifier<Nothing>(ModifierKind.NATIVE)
getArray.setSimpleName<Nothing>("nGet${field.simpleName}")
getArray.setType<Nothing>(f.createTypeParam("$arrayType[]"))
when (arrayType) {
"boolean", "short", "int", "float", "double", "long" -> {
getArray.setBody<Nothing>(
f.createCodeSnippet(
"""
j$arrayType jBuf[$arraySize];
for (int i = 0; i < $arraySize; i++)
jBuf[i] = $PTR_JNI_THIS->${field.getCallName()}[i];
j${arrayType}Array result = env->New${arrayType.capitalize()}Array($arraySize);
env->Set${arrayType.capitalize()}ArrayRegion(result, 0, $arraySize, jBuf);
return result
""".trimIndent()
)
)
}
"ImVec2", "ImVec4" -> {
getArray.setBody<Nothing>(
f.createCodeSnippet(
"""
return Jni::New${arrayType}Array(env, $PTR_JNI_THIS->${field.getCallName()}, $arraySize)
""".trimIndent()
)
)
}
}
result += getArray.prettyprint(false)
when (arrayType) {
"boolean", "short", "int", "float", "double", "long" -> {
val getArrayIdx = getArray.clone()
getArrayIdx.addParameter<Nothing>(f.createParameter<Nothing>().apply {
setType<Nothing>(f.createTypeParam("int"))
setSimpleName<Nothing>("idx")
})
getArrayIdx.setType<Nothing>(f.createTypeParam(arrayType))
getArrayIdx.setBody<Nothing>(f.createCodeSnippet("return $PTR_JNI_THIS->${field.getCallName()}[idx]"))
result += getArrayIdx.prettyprint(false)
}
}
} else {
getAccessor.addAnnotation<Nothing>(f.createAnnotation(f.createTypeReference<Nothing?>().apply {
setSimpleName<Nothing>("imgui.binding.annotation.BindingMethod")
}).apply {
addValue<Nothing>(A_VALUE_CALL_NAME, field.getCallName())
})
result += transformMethodToContent(getAccessor).map {
it.replace("$PTR_JNI_THIS->${getAccessor.simpleName}()", "$PTR_JNI_THIS->${field.getCallName()}")
}
}
return result
}
private fun createFieldSetContent(field: CtField<*>): List<String> {
val f = field.factory
val setAccessor = f.createMethod<Nothing>()
setAccessor.setType<Nothing>(f.createTypeParam("void"))
setAccessor.setParent<Nothing>(field.parent)
setAccessor.setSimpleName<Nothing>("set${field.simpleName}")
setAccessor.addModifier<Nothing>(ModifierKind.PRIVATE)
val valueParam = f.createParameter<Nothing>().apply {
setType<Nothing>(field.type)
setSimpleName<Nothing>("value")
}
// Add this param to the method placeholder, since some transformations can check it.
setAccessor.addParameter<Nothing>(valueParam)
val result = mutableListOf<String>()
if (field.hasAnnotation(A_NAME_TYPE_ARRAY)) {
val arrayType = field.getAnnotation(A_NAME_TYPE_ARRAY)!!.getValueAsString(A_VALUE_TYPE)
val arraySize = field.getAnnotation(A_NAME_TYPE_ARRAY)!!.getValueAsString(A_VALUE_SIZE)
val setArray = setAccessor.clone()
setArray.addModifier<Nothing>(ModifierKind.NATIVE)
setArray.setSimpleName<Nothing>("nSet${field.simpleName}")
when (arrayType) {
"boolean", "short", "int", "float", "double", "long" -> {
setArray.setBody<Nothing>(
f.createCodeSnippet(
"""
for (int i = 0; i < $arraySize; i++)
$PTR_JNI_THIS->${field.getCallName()}[i] = value[i]
""".trimIndent()
)
)
}
"ImVec2", "ImVec4" -> {
setArray.setBody<Nothing>(
f.createCodeSnippet("""
Jni::${arrayType}ArrayCpy(env, value, $PTR_JNI_THIS->${field.getCallName()}, $arraySize)
""".trimIndent()
)
)
}
}
result += setArray.prettyprint(false)
when (arrayType) {
"boolean", "short", "int", "float", "double", "long" -> {
val setArrayIdx = setArray.clone()
setArrayIdx.parameters.clear()
setArrayIdx.addParameter<Nothing>(f.createParameter<Nothing>().apply {
setType<Nothing>(f.createTypeParam("int"))
setSimpleName<Nothing>("idx")
})
setArrayIdx.addParameter<Nothing>(f.createParameter<Nothing>().apply {
setType<Nothing>(f.createTypeParam(arrayType))
setSimpleName<Nothing>("value")
})
setArrayIdx.setType<Nothing>(f.createTypeParam(arrayType))
setArrayIdx.setBody<Nothing>(f.createCodeSnippet("$PTR_JNI_THIS->${field.getCallName()}[idx] = value"))
result += setArrayIdx.prettyprint(false)
}
}
} else {
result += transformMethodToContent(setAccessor, listOf(valueParam)).map {
it.replace(
"$PTR_JNI_THIS->${setAccessor.simpleName}\\((.+)\\)".toRegex(),
"$PTR_JNI_THIS->${field.getCallName()} = $1"
)
}
}
return result
}
fun jniFieldContent(field: CtField<*>): List<String> {
val fields = mutableListOf<String>()
val a = field.getAnnotation(A_NAME_BINDING_FIELD)
if (a?.containsValue(A_VALUE_ACCESSORS, A_TYPE_VALUE_ACCESSOR_GETTER) == true) {
fields += createFieldGetContent(field)
}
if (a?.containsValue(A_VALUE_ACCESSORS, A_TYPE_VALUE_ACCESSOR_SETTER) == true) {
fields += createFieldSetContent(field)
}
return fields
}
@@ -0,0 +1,713 @@
package tool.generator.api
import spoon.reflect.code.CtJavaDoc
import spoon.reflect.code.CtJavaDocTag
import spoon.reflect.declaration.CtField
import spoon.reflect.declaration.CtMethod
import spoon.reflect.declaration.CtParameter
import spoon.reflect.declaration.ModifierKind
import kotlin.math.absoluteValue
private fun createStaticStructFieldName(method: CtMethod<*>): String {
return "_${method.simpleName.toUpperCase()}_${method.parameters.hashCode().absoluteValue}"
}
private fun createStaticStructField(typeName: String, fieldName: String): String {
return "private static final $typeName $fieldName = new $typeName(0);"
}
private fun joinInBodyParams(params: List<CtParameter<*>>, defaults: IntArray): String {
fun param2str(p: CtParameter<*>): String {
return if (p.type.isPtrClass()) {
"${p.simpleName}.$PTR_JVM_FIELD"
} else if (p.type.isClass) {
when (p.type.simpleName) {
"ImBoolean", "ImShort", "ImInt", "ImFloat", "ImLong", "ImDouble" -> {
"${p.simpleName} != null ? ${p.simpleName}.getData() : null"
}
"ImVec2" -> "${p.simpleName}.x, ${p.simpleName}.y"
"ImVec4" -> "${p.simpleName}.x, ${p.simpleName}.y, ${p.simpleName}.z, ${p.simpleName}.w"
"ImRect" -> "${p.simpleName}.min.x, ${p.simpleName}.min.y, ${p.simpleName}.max.x, ${p.simpleName}.max.y"
"ImPlotPoint" -> "${p.simpleName}.x, ${p.simpleName}.y"
"ImPlotRange" -> "${p.simpleName}.min, ${p.simpleName}.max"
"ImPlotLimits" -> "${p.simpleName}.x.min, ${p.simpleName}.y.min, ${p.simpleName}.x.max, ${p.simpleName}.y.max"
"TextEditorCoordinates" -> "${p.simpleName}.mLine, ${p.simpleName}.mColumn"
"String[]" -> "${p.simpleName}, ${p.simpleName}.length"
"boolean[]", "byte[]", "short[]", "int[]", "float[]", "long[]", "double[]" -> p.simpleName
else -> p.simpleName
}
} else {
p.simpleName
}
}
val visibleParams = mutableListOf<String>()
for ((index, p) in params.withIndex()) {
if (defaults.isNotEmpty() && !defaults.contains(index)) {
continue
}
if (p.isType("Void")) {
continue
}
visibleParams += param2str(p)
}
return visibleParams.joinToString()
}
private fun createBodyStaticStructReturn(
method: CtMethod<*>,
params: List<CtParameter<*>>,
defaults: IntArray
): String {
val fieldName = createStaticStructFieldName(method)
return buildString {
append("${fieldName}.$PTR_JVM_FIELD = ${method.getJniName()}(")
append(joinInBodyParams(params, defaults))
appendLine(");")
append("return $fieldName")
}
}
private fun createBodyStructReturn(
method: CtMethod<*>,
params: List<CtParameter<*>>,
defaults: IntArray
): String {
return buildString {
append("return new ${method.type.simpleName}(${method.getJniName()}(")
append(joinInBodyParams(params, defaults))
append("))")
}
}
private fun createBodyDstReturn(
method: CtMethod<*>,
params: List<CtParameter<*>>,
defaults: IntArray
): String {
val type = method.type.simpleName
return buildString {
appendLine("final $type dst = new ${type}();")
append("${method.getJniName()}(dst")
joinInBodyParams(params, defaults).let {
if (it.isNotEmpty()) {
append(", $it")
}
}
appendLine(");")
append("return dst")
}
}
private fun createMethod(origM: CtMethod<*>, params: List<CtParameter<*>>, defaults: IntArray): CtMethod<*> {
val f = origM.factory
val newM = f.createMethod<Nothing>()
if (origM.isPublic) {
newM.addModifier<Nothing>(ModifierKind.PUBLIC)
}
if (origM.isStatic) {
newM.addModifier<Nothing>(ModifierKind.STATIC)
}
if (origM.docComment.isNotBlank()) {
newM.setDocComment<Nothing>(origM.docComment)
}
newM.setAnnotations<Nothing>(origM.annotations)
newM.setType<Nothing>(origM.type)
newM.setSimpleName<Nothing>(origM.getName())
for ((index, p) in params.withIndex()) {
if (defaults.isNotEmpty() && !defaults.contains(index)) {
continue
}
if (p.isType("Void")) {
continue
}
newM.addParameter<Nothing>(f.createParameter<Nothing>().apply {
addModifier<Nothing>(ModifierKind.FINAL)
setType<Nothing>(p.type)
setSimpleName<Nothing>(p.simpleName)
})
}
sanitizeDocComment(newM)
sanitizeAnnotations(newM)
newM.setBody<Nothing>(f.createCodeSnippet(
buildString {
if (origM.isStaticStructReturnValue()) {
append(createBodyStaticStructReturn(origM, params, defaults))
} else if (DST_RETURN_TYPE_SET.contains(origM.type.simpleName)) {
append(createBodyDstReturn(origM, params, defaults))
} else if (origM.type.isClass && !origM.type.isPrimitive && !origM.isType("void") && !origM.isType("String") && !origM.isPrimitivePtrType()) {
append(createBodyStructReturn(origM, params, defaults))
} else {
if (!origM.isType("void")) {
append("return ")
}
append("${origM.getJniName()}(")
append(joinInBodyParams(params, defaults))
append(")")
}
}
))
return newM
}
private fun methodVecUnwrappedContent(method: CtMethod<*>): String {
val newMethod = method.clone()
val newParams = mutableListOf<CtParameter<*>>()
val vecParamNames = mutableSetOf<String>()
for (p in newMethod.parameters) {
if (p.isType("ImVec2") || p.isType("ImVec4")) {
vecParamNames += p.simpleName
val paramX = p.factory.createParameter<Nothing>()
paramX.addModifier<Nothing>(ModifierKind.FINAL)
paramX.setType<Nothing>(p.factory.createTypeParam("float"))
paramX.setSimpleName<Nothing>("${p.simpleName}X")
val paramY = paramX.clone()
paramY.setSimpleName<Nothing>("${p.simpleName}Y")
newParams += paramX
newParams += paramY
if (p.isType("ImVec4")) {
val paramZ = paramX.clone()
paramZ.setSimpleName<Nothing>("${p.simpleName}Z")
val paramW = paramX.clone()
paramW.setSimpleName<Nothing>("${p.simpleName}W")
newParams += paramZ
newParams += paramW
}
getJDoc(newMethod)?.let { jDoc ->
val idx = jDoc.tags.indexOfFirst { it.param == p.simpleName }
if (idx != -1) {
jDoc.removeTag<Nothing>(idx)
}
}
} else {
newParams += p
}
}
newMethod.setParameters<Nothing>(newParams)
val mContentOrig = method.prettyprint()
val mContent = newMethod.prettyprint().let {
var str = it
for (paramName in vecParamNames) {
str = str.replace("${paramName}.x, ${paramName}.y", "${paramName}X, ${paramName}Y")
str = str.replace("${paramName}.z, ${paramName}.w", "${paramName}Z, ${paramName}W")
}
str
}
if (mContent != mContentOrig) {
return mContent
}
return ""
}
private fun methodRectUnwrappedContent(method: CtMethod<*>): String {
val newMethod = method.clone()
val newParams = mutableListOf<CtParameter<*>>()
val paramNames = mutableSetOf<String>()
for (p in newMethod.parameters) {
if (p.isType("ImRect")) {
paramNames += p.simpleName
val paramMinX = p.factory.createParameter<Nothing>()
paramMinX.addModifier<Nothing>(ModifierKind.FINAL)
paramMinX.setType<Nothing>(p.factory.createTypeParam("float"))
paramMinX.setSimpleName<Nothing>("${p.simpleName}MinX")
val paramMinY = paramMinX.clone()
paramMinY.setSimpleName<Nothing>("${p.simpleName}MinY")
newParams += paramMinX
newParams += paramMinY
val paramMaxX = paramMinX.clone()
paramMaxX.setSimpleName<Nothing>("${p.simpleName}MaxX")
val paramMaxY = paramMinX.clone()
paramMaxY.setSimpleName<Nothing>("${p.simpleName}MaxY")
newParams += paramMaxX
newParams += paramMaxY
} else {
newParams += p
}
}
newMethod.setParameters<Nothing>(newParams)
val mContentOrig = method.prettyprint()
val mContent = newMethod.prettyprint().let {
var str = it
for (paramName in paramNames) {
str = str.replace(
"${paramName}.min.x, ${paramName}.min.y, ${paramName}.max.x, ${paramName}.max.y",
"${paramName}MinX, ${paramName}MinY, ${paramName}MaxX, ${paramName}MaxY"
)
}
str
}
if (mContent != mContentOrig) {
return mContent
}
return ""
}
private fun methodPlotPointUnwrappedContent(method: CtMethod<*>): String {
val newMethod = method.clone()
val newParams = mutableListOf<CtParameter<*>>()
val paramNames = mutableSetOf<String>()
for (p in newMethod.parameters) {
if (p.isType("ImPlotPoint")) {
paramNames += p.simpleName
val paramX = p.factory.createParameter<Nothing>()
paramX.addModifier<Nothing>(ModifierKind.FINAL)
paramX.setType<Nothing>(p.factory.createTypeParam("double"))
paramX.setSimpleName<Nothing>("${p.simpleName}X")
val paramY = paramX.clone()
paramY.setSimpleName<Nothing>("${p.simpleName}Y")
newParams += paramX
newParams += paramY
} else {
newParams += p
}
}
newMethod.setParameters<Nothing>(newParams)
val mContentOrig = method.prettyprint()
val mContent = newMethod.prettyprint().let {
var str = it
for (paramName in paramNames) {
str = str.replace("${paramName}.x, ${paramName}.y", "${paramName}X, ${paramName}Y")
}
str
}
if (mContent != mContentOrig) {
return mContent
}
return ""
}
private fun methodPlotRangeUnwrappedContent(method: CtMethod<*>): String {
val newMethod = method.clone()
val newParams = mutableListOf<CtParameter<*>>()
val paramNames = mutableSetOf<String>()
for (p in newMethod.parameters) {
if (p.isType("ImPlotRange")) {
paramNames += p.simpleName
val paramX = p.factory.createParameter<Nothing>()
paramX.addModifier<Nothing>(ModifierKind.FINAL)
paramX.setType<Nothing>(p.factory.createTypeParam("double"))
paramX.setSimpleName<Nothing>("${p.simpleName}Min")
val paramY = paramX.clone()
paramY.setSimpleName<Nothing>("${p.simpleName}Max")
newParams += paramX
newParams += paramY
} else {
newParams += p
}
}
newMethod.setParameters<Nothing>(newParams)
val mContentOrig = method.prettyprint()
val mContent = newMethod.prettyprint().let {
var str = it
for (paramName in paramNames) {
str = str.replace("${paramName}.min, ${paramName}.max", "${paramName}Min, ${paramName}Max")
}
str
}
if (mContent != mContentOrig) {
return mContent
}
return ""
}
private fun methodPlotLimitsUnwrappedContent(method: CtMethod<*>): String {
val newMethod = method.clone()
val newParams = mutableListOf<CtParameter<*>>()
val paramNames = mutableSetOf<String>()
for (p in newMethod.parameters) {
if (p.isType("ImPlotLimits")) {
paramNames += p.simpleName
val paramMinX = p.factory.createParameter<Nothing>()
paramMinX.addModifier<Nothing>(ModifierKind.FINAL)
paramMinX.setType<Nothing>(p.factory.createTypeParam("double"))
paramMinX.setSimpleName<Nothing>("${p.simpleName}MinX")
val paramMinY = paramMinX.clone()
paramMinY.setSimpleName<Nothing>("${p.simpleName}MinY")
newParams += paramMinX
newParams += paramMinY
val paramMaxX = paramMinX.clone()
paramMaxX.setSimpleName<Nothing>("${p.simpleName}MaxX")
val paramMaxY = paramMinX.clone()
paramMaxY.setSimpleName<Nothing>("${p.simpleName}MaxY")
newParams += paramMaxX
newParams += paramMaxY
} else {
newParams += p
}
}
newMethod.setParameters<Nothing>(newParams)
val mContentOrig = method.prettyprint()
val mContent = newMethod.prettyprint().let {
var str = it
for (paramName in paramNames) {
str = str.replace(
"${paramName}.x.min, ${paramName}.y.min, ${paramName}.x.max, ${paramName}.y.max",
"${paramName}MinX, ${paramName}MinY, ${paramName}MaxX, ${paramName}MaxY"
)
}
str
}
if (mContent != mContentOrig) {
return mContent
}
return ""
}
private fun methodCoordinatesUnwrappedContent(method: CtMethod<*>): String {
val newMethod = method.clone()
val newParams = mutableListOf<CtParameter<*>>()
val paramNames = mutableSetOf<String>()
for (p in newMethod.parameters) {
if (p.isType("TextEditorCoordinates")) {
paramNames += p.simpleName
val paramX = p.factory.createParameter<Nothing>()
paramX.addModifier<Nothing>(ModifierKind.FINAL)
paramX.setType<Nothing>(p.factory.createTypeParam("int"))
paramX.setSimpleName<Nothing>("${p.simpleName}Line")
val paramY = paramX.clone()
paramY.setSimpleName<Nothing>("${p.simpleName}Column")
newParams += paramX
newParams += paramY
} else {
newParams += p
}
}
newMethod.setParameters<Nothing>(newParams)
val mContentOrig = method.prettyprint()
val mContent = newMethod.prettyprint().let {
var str = it
for (paramName in paramNames) {
str = str.replace("${paramName}.mLine, ${paramName}.mColumn", "${paramName}Line, ${paramName}Column")
}
str
}
if (mContent != mContentOrig) {
return mContent
}
return ""
}
private fun createMethodDstReturn(
mOrig: CtMethod<*>,
params: List<CtParameter<*>>,
defaults: IntArray
): CtMethod<*> {
val mNew = mOrig.clone()
mNew.setType<Nothing>(mNew.factory.createTypeParam("void"))
mNew.addParameterAt<Nothing>(0, mOrig.factory.createParameter<Nothing>().apply {
addModifier<Nothing>(ModifierKind.FINAL)
setType<Nothing>(factory.createTypeParam(mOrig.type.simpleName))
setSimpleName<Nothing>("dst")
})
mNew.setBody<Nothing>(mOrig.factory.createCodeSnippet(
buildString {
append("${mOrig.getJniName()}(dst")
joinInBodyParams(params, defaults).let {
if (it.isNotEmpty()) {
append(", $it")
}
}
append(")")
}
))
return mNew
}
private fun createMethodVecValueReturn(
vecVal: String,
mOrig: CtMethod<*>,
params: List<CtParameter<*>>,
defaults: IntArray
): CtMethod<*> {
val mNew = mOrig.clone()
mNew.setSimpleName<Nothing>(mOrig.getName() + vecVal.capitalize())
mNew.type.setSimpleName<Nothing>("float")
mNew.setBody<Nothing>(mOrig.factory.createCodeSnippetStatement().apply {
setValue<Nothing>(buildString {
append("return ")
append("${mNew.getJniName()}(")
append(joinInBodyParams(params, defaults))
append(")")
})
})
return mNew
}
private fun transformMethodToContent(
mOrig: CtMethod<*>,
params: List<CtParameter<*>> = emptyList(),
defaults: IntArray = intArrayOf()
): List<String> {
val methods = mutableListOf<String>()
val mNew = createMethod(mOrig, params, defaults)
methods += mNew.prettyprint()
if (params.find { it.isType("ImVec2") || it.isType("ImVec4") } != null) {
methodVecUnwrappedContent(mNew).takeIf(String::isNotEmpty)?.run(methods::add)
}
if (params.find { it.isType("ImRect") } != null) {
methodRectUnwrappedContent(mNew).takeIf(String::isNotEmpty)?.run(methods::add)
}
if (params.find { it.isType("ImPlotPoint") } != null) {
methodPlotPointUnwrappedContent(mNew).takeIf(String::isNotEmpty)?.run(methods::add)
}
if (params.find { it.isType("ImPlotRange") } != null) {
methodPlotRangeUnwrappedContent(mNew).takeIf(String::isNotEmpty)?.run(methods::add)
}
if (params.find { it.isType("ImPlotLimits") } != null) {
methodPlotLimitsUnwrappedContent(mNew).takeIf(String::isNotEmpty)?.run(methods::add)
}
if (params.find { it.isType("TextEditorCoordinates") } != null) {
methodCoordinatesUnwrappedContent(mNew).takeIf(String::isNotEmpty)?.run(methods::add)
}
if (mOrig.isType("ImVec2") || mOrig.isType("ImVec4")) {
methods += createMethodVecValueReturn("x", mNew, params, defaults).prettyprint()
methods += createMethodVecValueReturn("y", mNew, params, defaults).prettyprint()
if (mOrig.isType("ImVec4")) {
methods += createMethodVecValueReturn("z", mNew, params, defaults).prettyprint()
methods += createMethodVecValueReturn("w", mNew, params, defaults).prettyprint()
}
}
if (DST_RETURN_TYPE_SET.contains(mOrig.type.simpleName)) {
methods += createMethodDstReturn(mNew, params, defaults).prettyprint()
}
return methods
}
fun jvmMethodContent(method: CtMethod<*>): List<String> {
val addContent = mutableListOf<String>()
if (method.isStaticStructReturnValue()) {
val staticStructFieldName = createStaticStructFieldName(method)
addContent += createStaticStructField(method.type.simpleName, staticStructFieldName)
}
val methods = mutableListOf<String>()
for (paramsSize in (findFirstOptParam(method)..method.parameters.size)) {
val params = method.parameters.subList(0, paramsSize)
methods += transformMethodToContent(method, params)
}
for (defaults in findDefaultsCombinations(method)) {
methods += transformMethodToContent(method, method.parameters, defaults)
}
return addContent + methods
}
private fun CtMethod<*>.isStaticStructReturnValue(): Boolean {
return !isType("void") && getAnnotation(A_NAME_RETURN_VALUE)?.getValueAsObject(A_VALUE_IS_STATIC) == true
}
private fun createFieldGetContent(field: CtField<*>): List<String> {
val f = field.factory
val getAccessor = f.createMethod<Nothing>()
getAccessor.setParent<Nothing>(field.parent)
getAccessor.setSimpleName<Nothing>("get${field.simpleName}")
getAccessor.setType<Nothing>(field.type)
getAccessor.addModifier<Nothing>(ModifierKind.PUBLIC)
getAccessor.setDocComment<Nothing>(field.docComment)
getAccessor.setAnnotations<Nothing>(field.annotations)
val result = jvmMethodContent(getAccessor).toMutableList()
if (field.hasAnnotation(A_NAME_TYPE_ARRAY)) {
when (val arrayType = field.getAnnotation(A_NAME_TYPE_ARRAY)!!.getValueAsString(A_VALUE_TYPE)) {
"boolean", "short", "int", "float", "double", "long" -> {
val newM = getAccessor.clone()
newM.setType<Nothing>(f.createTypeParam(arrayType))
newM.addParameter<Nothing>(f.createParameter<Nothing>().apply {
setType<Nothing>(f.createTypeParam("int"))
setSimpleName<Nothing>("idx")
})
result += jvmMethodContent(newM)
}
}
}
return result
}
private fun createFieldSetContent(field: CtField<*>): List<String> {
val f = field.factory
val setAccessor = f.createMethod<Nothing>()
setAccessor.setType<Nothing>(f.createTypeParam("void"))
setAccessor.setParent<Nothing>(field.parent)
setAccessor.setSimpleName<Nothing>("set${field.simpleName}")
setAccessor.addModifier<Nothing>(ModifierKind.PUBLIC)
setAccessor.setDocComment<Nothing>(field.docComment)
setAccessor.setAnnotations<Nothing>(field.annotations)
val valueParam = f.createParameter<Nothing>().apply {
setType<Nothing>(field.type)
setSimpleName<Nothing>("value")
}
val result = transformMethodToContent(setAccessor, listOf(valueParam)).toMutableList()
if (field.hasAnnotation(A_NAME_TYPE_ARRAY)) {
when (val arrayType = field.getAnnotation(A_NAME_TYPE_ARRAY)!!.getValueAsString(A_VALUE_TYPE)) {
"boolean", "short", "int", "float", "double", "long" -> {
val newM = setAccessor.clone()
newM.parameters.clear()
newM.addParameter<Nothing>(f.createParameter<Nothing>().apply {
setType<Nothing>(f.createTypeParam("int"))
setSimpleName<Nothing>("idx")
})
newM.addParameter<Nothing>(f.createParameter<Nothing>().apply {
setType<Nothing>(f.createTypeParam(arrayType))
setSimpleName<Nothing>("value")
})
result += transformMethodToContent(newM, newM.parameters)
}
}
}
return result
}
private fun createFieldFlagUtils(field: CtField<*>): List<String> {
val mAdd = field.factory.createMethod<Nothing>()
mAdd.setSimpleName<Nothing>("add${field.simpleName}")
mAdd.setType<Nothing>(field.factory.createTypeParam("void"))
mAdd.addModifier<Nothing>(ModifierKind.PUBLIC)
mAdd.setDocComment<Nothing>(field.docComment)
mAdd.addParameter<Nothing>(field.factory.createParameter<Nothing>().apply {
addModifier<Nothing>(ModifierKind.FINAL)
setType<Nothing>(field.factory.createTypeParam("int"))
setSimpleName<Nothing>("flags")
})
mAdd.setBody<Nothing>(field.factory.createCodeSnippet("set${field.simpleName}(get${field.simpleName}() | flags)"))
val mRemove = mAdd.clone()
mRemove.setSimpleName<Nothing>("remove${field.simpleName}")
mRemove.setBody<Nothing>(field.factory.createCodeSnippet("set${field.simpleName}(get${field.simpleName}() & ~(flags))"))
val mHas = mAdd.clone()
mHas.setSimpleName<Nothing>("has${field.simpleName}")
mHas.setType<Nothing>(field.factory.createTypeParam("boolean"))
mHas.setBody<Nothing>(field.factory.createCodeSnippet("return (get${field.simpleName}() & flags) != 0"))
val utilMethods = mutableListOf<String>()
val bindingFieldAnnotation = field.getAnnotation(A_NAME_BINDING_FIELD)
if (bindingFieldAnnotation?.containsValue(A_VALUE_ACCESSORS, A_TYPE_VALUE_ACCESSOR_SETTER) == true) {
utilMethods += mAdd.prettyprint()
utilMethods += mRemove.prettyprint()
}
if (bindingFieldAnnotation?.containsValue(A_VALUE_ACCESSORS, A_TYPE_VALUE_ACCESSOR_GETTER) == true) {
utilMethods += mHas.prettyprint()
}
return utilMethods
}
fun jvmFieldContent(field: CtField<*>): List<String> {
val fields = mutableListOf<String>()
val a = field.getAnnotation(A_NAME_BINDING_FIELD)
if (a?.containsValue(A_VALUE_ACCESSORS, A_TYPE_VALUE_ACCESSOR_GETTER) == true) {
fields += createFieldGetContent(field)
}
if (a?.containsValue(A_VALUE_ACCESSORS, A_TYPE_VALUE_ACCESSOR_SETTER) == true) {
fields += createFieldSetContent(field)
}
if (field.getAnnotation(A_NAME_BINDING_FIELD)?.getValueAsObject(A_VALUE_IS_FLAG) == true) {
fields += createFieldFlagUtils(field)
}
return fields
}
private fun getJDoc(method: CtMethod<*>): CtJavaDoc? {
return method.comments.filterIsInstance<CtJavaDoc>().firstOrNull()
}
private fun sanitizeDocComment(method: CtMethod<*>) {
val jDoc = getJDoc(method) ?: return
val paramNames = method.parameters.map { it.simpleName }
jDoc.setTags<Nothing>(jDoc.tags.filter { it.type != CtJavaDocTag.TagType.PARAM || paramNames.contains(it.param) })
}
private fun sanitizeAnnotations(method: CtMethod<*>) {
method.setAnnotations<Nothing>(method.annotations.filter { !CLEANUP_ANNOTATIONS_LIST.contains(it.name) })
}
@@ -0,0 +1,48 @@
package tool.generator.api.task
import org.gradle.api.DefaultTask
import org.gradle.api.tasks.Internal
import org.gradle.api.tasks.TaskAction
import spoon.Launcher
import spoon.support.compiler.FileSystemFolder
import tool.generator.api.BindingSourceProcessor
import tool.generator.api.ExcludedSourceProcessor
open class GenerateApi : DefaultTask() {
@Internal
override fun getGroup() = "build"
@Internal
override fun getDescription() = "Generate API for native binaries."
private val genSrcDir = project.file("src/main/java")
private val genDstDir = project.file("src/generated/java")
@TaskAction
fun run() {
logger.info("Generating API...")
logger.info("Removing old generated files in $genDstDir...")
project.file(genDstDir).deleteRecursively()
logger.info("Copying raw sources...")
logger.info("| from: $genSrcDir")
logger.info("| into: $genDstDir")
project.copy {
from(genSrcDir)
into(genDstDir)
}
logger.info("Processing generated sources...")
val launcher = Launcher()
launcher.addInputResource(FileSystemFolder(genDstDir))
val model = launcher.buildModel()
model.allTypes.filter(BindingSourceProcessor::isProcessable).forEach {
BindingSourceProcessor(it).process()
}
model.allTypes.filter(ExcludedSourceProcessor::isProcessable).forEach {
ExcludedSourceProcessor(it).process()
}
}
}
@@ -0,0 +1,186 @@
package tool.generator.api
import spoon.reflect.code.CtCodeSnippetStatement
import spoon.reflect.code.CtExpression
import spoon.reflect.code.CtFieldRead
import spoon.reflect.code.CtNewArray
import spoon.reflect.declaration.*
import spoon.reflect.factory.Factory
import spoon.reflect.reference.CtTypeParameterReference
import tool.generator.ast.Decl
import tool.generator.ast.DeclContainer
const val A_NAME_BINDING_SOURCE = "BindingSource"
const val A_NAME_BINDING_METHOD = "BindingMethod"
const val A_NAME_BINDING_FIELD = "BindingField"
const val A_NAME_BINDING_AST_ENUM = "BindingAstEnum"
const val A_NAME_OPT_ARG = "OptArg"
const val A_NAME_EXCLUDED_SOURCE = "ExcludedSource"
const val A_NAME_RETURN_VALUE = "ReturnValue"
const val A_NAME_ARG_VALUE = "ArgValue"
const val A_NAME_TYPE_ARRAY = "TypeArray"
const val A_VALUE_CALL_PTR = "callPtr"
const val A_VALUE_CALL_OPERATOR = "callOperator"
const val A_VALUE_CALL_PREFIX = "callPrefix"
const val A_VALUE_CALL_SUFFIX = "callSuffix"
const val A_VALUE_STATIC_CAST = "staticCast"
const val A_VALUE_REINTERPRET_CAST = "reinterpretCast"
const val A_VALUE_IS_STATIC = "isStatic"
const val A_VALUE_CALL_VALUE = "callValue"
const val A_VALUE_NAME = "name"
const val A_VALUE_CALL_NAME = "callName"
const val A_VALUE_ACCESSORS = "accessors"
const val A_VALUE_IS_FLAG = "isFlag"
const val A_VALUE_TYPE = "type"
const val A_VALUE_SIZE = "size"
const val A_VALUE_FILE = "file"
const val A_VALUE_QUAL_TYPE = "qualType"
const val A_VALUE_SANITIZE_NAME = "sanitizeName"
const val A_TYPE_VALUE_ACCESSOR_SETTER = "SETTER"
const val A_TYPE_VALUE_ACCESSOR_GETTER = "GETTER"
const val PTR_JVM_FIELD = "ptr"
const val PTR_JNI_CAST = "intptr_t"
const val PTR_JNI_THIS = "THIS"
const val PARAM_ARR_LEN_POSTFIX = "Count"
val CLEANUP_ANNOTATIONS_LIST = listOf(
A_NAME_BINDING_SOURCE,
A_NAME_BINDING_METHOD,
A_NAME_BINDING_FIELD,
A_NAME_RETURN_VALUE,
A_NAME_OPT_ARG,
A_NAME_ARG_VALUE,
A_NAME_TYPE_ARRAY,
A_NAME_BINDING_AST_ENUM,
)
val PRIMITIVE_PTR_TYPECAST_MAP = mapOf(
"boolean[]" to "bool*",
"byte[]" to "char*",
"short[]" to "short*",
"int[]" to "int*",
"float[]" to "float*",
"long[]" to "long*",
"double[]" to "double*",
)
val DST_RETURN_TYPE_SET = setOf(
"ImVec2",
"ImVec4",
"ImRect",
"ImPlotPoint",
"ImPlotRange",
"ImPlotLimits",
"TextEditorCoordinates",
)
fun CtElement.hasAnnotation(annotationName: String): Boolean {
return getAnnotation(annotationName) != null
}
fun CtElement.getAnnotation(annotationName: String): CtAnnotation<*>? {
return annotations.find { a -> a?.name == annotationName }
}
fun CtAnnotation<*>.containsValue(annotationField: String, value: String): Boolean {
val v = getValue<CtExpression<Any>>(annotationField)
if (v is CtFieldRead) {
return v.prettyprint().contains(value)
}
if (v is CtNewArray) {
return v.elements.find { it.prettyprint().contains(value) } != null
}
return false
}
fun Factory.createTypeParam(name: String): CtTypeParameterReference = createTypeParameterReference().apply {
setSimpleName<Nothing>(name)
}
fun Factory.createCodeSnippet(code: String): CtCodeSnippetStatement = createCodeSnippetStatement().apply {
setValue<Nothing>(code)
}
fun CtTypedElement<*>.isType(type: String): Boolean = this.type.simpleName == type
fun CtTypedElement<*>.isPrimitivePtrType(): Boolean {
return PRIMITIVE_PTR_TYPECAST_MAP.containsKey(type.simpleName)
}
fun CtTypeInformation.isPtrClass(): Boolean {
return getDeclaredOrInheritedField(PTR_JVM_FIELD) != null
}
fun CtMethod<*>.getJniName(): String = "n${simpleName.capitalize()}"
fun CtMethod<*>.getName(): String {
return getAnnotation(A_NAME_BINDING_METHOD)?.getValueAsString(A_VALUE_NAME)?.takeIf(String::isNotEmpty)
?: simpleName.decapitalize()
}
fun CtField<*>.getCallName(): String {
return getAnnotation(A_NAME_BINDING_FIELD)?.getValueAsString(A_VALUE_CALL_NAME)?.takeIf(String::isNotEmpty)
?: simpleName
}
fun findDefaultsCombinations(method: CtMethod<*>): List<IntArray> {
fun findDefaults(params: List<CtParameter<*>>): Map<Int, String> {
val defaults = mutableMapOf<Int, String>()
for ((index, p) in params.withIndex()) {
p.getAnnotation(A_NAME_OPT_ARG)?.let { a ->
val value = a.getValueAsString(A_VALUE_CALL_VALUE)
if (value.isNotEmpty()) {
defaults[index] = value
}
}
}
return defaults
}
fun concatNextParam0(combinations: MutableList<IntArray>, idx0: Int, idxN: Int) {
val p1 = method.parameters[idx0]
val p2 = method.parameters[idxN]
if (p1.type.simpleName != p2.type.simpleName) {
combinations.add(((0 until idx0) + (idxN until method.parameters.size)).toIntArray())
if (p2.getAnnotation(A_NAME_OPT_ARG)?.getValueAsString(A_VALUE_CALL_VALUE)?.isNotEmpty() == true) {
concatNextParam0(combinations, idx0, idxN + 1)
}
}
}
val combinations = mutableListOf<IntArray>()
findDefaults(method.parameters).forEach { (idx, _) -> concatNextParam0(combinations, idx, idx + 1) }
return combinations
}
fun findFirstOptParam(method: CtMethod<*>): Int {
if (method.parameters.isEmpty()) {
return method.parameters.size
}
for ((index, p) in method.parameters.withIndex()) {
if (p.hasAnnotation(A_NAME_OPT_ARG)) {
return index
}
}
return method.parameters.size
}
fun Collection<Decl>.filterDecls0(filter: (Decl) -> Boolean): Collection<Decl> {
val result = mutableListOf<Decl>()
fun filter0(decls: Collection<Decl>) {
decls.forEach { decl ->
if (filter(decl)) {
result += decl
}
if (decl is DeclContainer) {
filter0(decl.decls)
}
}
}
filter0(this)
return result
}
@@ -0,0 +1,22 @@
package tool.generator.ast
import com.fasterxml.jackson.databind.ObjectMapper
import java.io.InputStream
object AstParser {
const val RESOURCE_PATH: String = "generator/api/ast"
private val astCache = mutableMapOf<String, AstRoot>()
fun readFromResource(astResourcePath: String): AstRoot {
return astCache.computeIfAbsent(astResourcePath) {
val astResourceContent = getAtResourceStream(astResourcePath).use { s -> s.reader().use { r -> r.readText() } }
val objectMapper = ObjectMapper()
objectMapper.readValue(astResourceContent, AstRoot::class.java)
}
}
private fun getAtResourceStream(astResourcePath: String): InputStream {
return AstRoot::class.java.classLoader.getResourceAsStream("$RESOURCE_PATH/$astResourcePath")!!
}
}
@@ -0,0 +1,127 @@
package tool.generator.ast
import com.fasterxml.jackson.annotation.JsonIgnore
import com.fasterxml.jackson.annotation.JsonSubTypes
import com.fasterxml.jackson.annotation.JsonTypeInfo
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY)
@JsonSubTypes(
JsonSubTypes.Type(AstNamespaceDecl::class),
JsonSubTypes.Type(AstFullComment::class),
JsonSubTypes.Type(AstParagraphComment::class),
JsonSubTypes.Type(AstTextComment::class),
JsonSubTypes.Type(AstFunctionDecl::class),
JsonSubTypes.Type(AstParmVarDecl::class),
JsonSubTypes.Type(AstEnumDecl::class),
JsonSubTypes.Type(AstEnumConstantDecl::class),
JsonSubTypes.Type(AstRecordDecl::class),
JsonSubTypes.Type(AstFieldDecl::class),
)
interface Decl {
val offset: Int
}
interface DeclContainer {
val decls: List<Decl>
}
data class AstRoot(
val info: AstInfo = AstInfo(),
override val decls: List<Decl> = emptyList()
) : DeclContainer
data class AstInfo(
val source: String = "",
val hash: String = "",
val url: String = "",
val revision: String = "",
)
data class AstNamespaceDecl(
override val offset: Int = -1,
val name: String = "",
override val decls: List<Decl> = emptyList(),
) : Decl, DeclContainer
data class AstFullComment(
override val offset: Int = -1,
override val decls: List<Decl> = emptyList(),
) : Decl, DeclContainer
data class AstParagraphComment(
override val offset: Int = -1,
override val decls: List<Decl> = emptyList(),
) : Decl, DeclContainer
data class AstTextComment(
override val offset: Int = -1,
val text: String = "",
) : Decl
data class AstFunctionDecl(
override val offset: Int = -1,
val name: String = "",
val resultType: String = "",
override val decls: List<Decl> = emptyList(),
) : Decl, DeclContainer {
@JsonIgnore
fun getParams(): List<AstParmVarDecl> {
return decls.filterIsInstance<AstParmVarDecl>()
}
}
data class AstParmVarDecl(
override val offset: Int = -1,
val name: String = "",
val qualType: String = "",
val desugaredQualType: String = "",
val defaultValue: String? = null,
) : Decl {
companion object {
const val FORMAT_ATTR_NAME = "#FORMAT_ATTR_MARKER#"
fun asFormatAttr(offset: Int): AstParmVarDecl {
return AstParmVarDecl(
offset = offset,
name = FORMAT_ATTR_NAME,
qualType = FORMAT_ATTR_NAME,
desugaredQualType = FORMAT_ATTR_NAME,
defaultValue = null
)
}
}
@JsonIgnore
fun isFormatAttr(): Boolean {
return this.name == FORMAT_ATTR_NAME
}
}
data class AstEnumDecl(
override val offset: Int = -1,
val name: String = "",
override val decls: List<Decl> = emptyList(),
) : Decl, DeclContainer
data class AstEnumConstantDecl(
override val offset: Int = -1,
val name: String = "",
val docComment: String? = null,
val qualType: String = "",
val order: Int = -1,
val value: String? = null,
val evaluatedValue: String? = null,
) : Decl
data class AstRecordDecl(
override val offset: Int = -1,
val name: String = "",
override val decls: List<Decl> = emptyList(),
) : Decl, DeclContainer
data class AstFieldDecl(
override val offset: Int = -1,
val name: String = "",
val qualType: String = "",
val desugaredQualType: String = "",
) : Decl
@@ -0,0 +1,530 @@
package tool.generator.ast.task
import com.fasterxml.jackson.annotation.JsonInclude
import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.databind.SerializationFeature
import com.fasterxml.jackson.databind.node.ObjectNode
import com.lordcodes.turtle.shellRun
import org.gradle.api.DefaultTask
import org.gradle.api.tasks.InputFiles
import org.gradle.api.tasks.Internal
import org.gradle.api.tasks.TaskAction
import tool.generator.ast.*
import java.io.File
import java.math.BigInteger
import java.security.MessageDigest
import java.util.*
open class GenerateAst : DefaultTask() {
@Internal
override fun getGroup() = "build"
@Internal
override fun getDescription() = "Generate AST tree for declared header files."
@InputFiles
lateinit var headerFiles: Map<File, Collection<String>>
private val dstDir: File = File("${project.rootDir}/buildSrc/src/main/resources/${AstParser.RESOURCE_PATH}")
private val objectMapper: ObjectMapper = ObjectMapper()
/**
* During the parsing of ast-dump we need to access an initial header file content.
* Required for cases like: get the content of the file (comment or default param value) by offset pos in file.
*/
private var currentParsingHeaderContent: String = ""
/**
* This is used only to log stuff properly.
*/
private var currentParsingIndent: Int = 0
init {
objectMapper.configure(SerializationFeature.INDENT_OUTPUT, true)
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY)
}
@TaskAction
fun run() {
logger.info("Generating AST...")
dstDir.mkdirs()
val scriptPath = "$dstDir/_gen_ast.sh"
File(scriptPath).setExecutable(true)
logger.info("Processing headers...")
headerFiles.forEach { (header, defines) ->
System.gc()
logger.info("| $header")
// Store the header content in the field, so we can access it when parsing.
currentParsingHeaderContent = header.readText()
// Header hash content to create a unique path for generated content.
val headerHash = md5Hash(currentParsingHeaderContent)
// Append additional defines if provided.
currentParsingHeaderContent = defines.joinToString("\n") + currentParsingHeaderContent
// We create a unique folder to store files generated for the header.
// This is necessary because when we store all headers in the same directory,
// their AST dump can overlap with each other.
val astBuildDir = File("${project.buildDir}/generated/ast/$headerHash")
astBuildDir.mkdirs()
// Move the header content to the temp file to make an ast-dump of it.
val headerName = header.nameWithoutExtension
val tmpHeaderFile = File("$astBuildDir/$headerName.h")
tmpHeaderFile.createNewFile()
tmpHeaderFile.writeText(currentParsingHeaderContent)
logger.info(" | Making an ast-dump...")
// Destination for ast-dump.
val astBumpJson = File("$astBuildDir/$headerName.json")
// Call clang++ with the script.
// During the process of making an ast-dump there could be errors/warnings.
// Thus making a call like that can help to ignore them.
callClangAstBump(scriptPath, tmpHeaderFile, astBumpJson)
logger.info(" | Processing an ast-dump result: $astBumpJson...")
// Read the ast-dump of the whole header content.
// It will contain technical information, like unneeded typdefs, std types etc.
val fullDeclsList = mutableListOf<Decl>()
objectMapper.readTree(astBumpJson).get("inner").forEach { topDecl ->
parseDeclNode0(topDecl)?.let(fullDeclsList::add)
}
//////////////
// After parsing the entire header file, we need to remove unnecessary information from it.
// So we pre-process the initial content and parse it again.
// This way, we can compare the initial result with the trimmed version
// to remove types and declarations that represent compiler information.
// Remove all includes and typedefs.
// They are not needed to process the AST, but they add extra information to the final dump.
// And since we want to have an ast-dump as minimal as possible we remove that information.
currentParsingHeaderContent = currentParsingHeaderContent
.replace("#include .*".toRegex(), "")
.replace("typedef .*".toRegex(), "")
// Re-write with pre-processed content.
tmpHeaderFile.writeText(currentParsingHeaderContent)
callClangAstBump(scriptPath, tmpHeaderFile, astBumpJson)
// As its said - we do the parsing once again, but now the final result won't contain std types.
val strippedDeclsList = mutableListOf<Decl>()
objectMapper.readTree(astBumpJson).get("inner").forEach { topDecl ->
parseDeclNode0(topDecl)?.let(strippedDeclsList::add)
}
logger.info(" | Removing an ast-decls diff...")
val resultDeclsList = removeAstDiff(fullDeclsList, strippedDeclsList)
logger.info(" | Sorting an ast-decls...")
sortDecls0(resultDeclsList)
///////////////
// In the end we write down the ast-decls result to the file.
// The file itself will be stored in VCS, so we can understand if there were any changes in native code.
val astResultJson = File("$dstDir/ast-$headerName.json")
logger.info(" | Writing processed AST: $astResultJson...")
objectMapper.writer().writeValue(
astResultJson, AstRoot(
info = AstInfo(
source = header.relativeTo(project.rootDir).path,
hash = headerHash,
url = shellRun(header.parentFile) {
command("git", listOf("config", "--get", "remote.origin.url"))
},
revision = shellRun(header.parentFile) {
command("git", listOf("rev-parse", "HEAD"))
},
),
decls = resultDeclsList
)
)
}
}
private fun parseDeclNode0(declNode: JsonNode): Decl? {
fun logParsingDecl(name: String) {
logger.info(" ${" ".repeat(currentParsingIndent)}| Parsing $name...")
}
fun logParsingInner(name: String) {
logger.info(" ${" ".repeat(currentParsingIndent)}| $name")
}
fun JsonNode.hasNoName(): Boolean {
return !has("name") || get("name").asText().isBlank()
}
fun JsonNode.hasNoInnerContent(): Boolean {
return !has("inner") || get("inner").isEmpty
}
fun JsonNode.getOffset(): Int {
val loc = (get("loc") ?: get("range").get("begin")).let { loc ->
if (loc.has("expansionLoc")) {
loc.get("expansionLoc")
} else {
loc
}
}
return loc.get("offset")?.asInt() ?: -1
}
fun JsonNode.getDefaultParamValue(): String {
fun getOffset(jsonNode: JsonNode): Pair<Int, Int> {
val loc = if (jsonNode.has("expansionLoc")) {
jsonNode.get("expansionLoc")
} else {
jsonNode
}
return loc.get("offset").asInt() to loc.get("tokLen").asInt()
}
return get("inner").get(0).get("range").let { range ->
val (beginOffset, _) = getOffset(range.get("begin"))
val (endOffset, endTokLoc) = getOffset(range.get("end"))
currentParsingHeaderContent.substring(beginOffset, endOffset + endTokLoc)
}
}
try {
return when (declNode.get("kind").textValue()) {
"NamespaceDecl" -> {
if (declNode.hasNoInnerContent()) {
return null
}
val offset = declNode.getOffset()
val name = declNode.get("name").asText()
val decls = mutableListOf<Decl>()
if (name.startsWith("_")) { // internal API namespaces
return null
}
logParsingDecl("namespace $name")
currentParsingIndent++
declNode.get("inner").forEach { innerDecl ->
parseDeclNode0(innerDecl)?.let(decls::add)
}
currentParsingIndent--
return AstNamespaceDecl(offset, name, decls)
}
"FullComment" -> {
if (declNode.hasNoInnerContent()) {
return null
}
val offset = declNode.getOffset()
val decls = mutableListOf<Decl>()
logParsingDecl("full comment")
currentParsingIndent++
declNode.get("inner").forEach { innerDecl ->
parseDeclNode0(innerDecl)?.let(decls::add)
}
currentParsingIndent--
return AstFullComment(offset, decls)
}
"ParagraphComment" -> {
if (declNode.hasNoInnerContent()) {
return null
}
val offset = declNode.getOffset()
val decls = mutableListOf<Decl>()
logParsingDecl("paragraph comment")
currentParsingIndent++
declNode.get("inner").forEach { innerDecl ->
parseDeclNode0(innerDecl)?.let(decls::add)
}
currentParsingIndent--
return AstParagraphComment(offset, decls)
}
"TextComment" -> {
val offset = declNode.getOffset()
val text = declNode.get("text").asText()
logParsingInner("text comment")
return AstTextComment(offset, text)
}
"FunctionDecl", "CXXMethodDecl" -> {
val offset = declNode.getOffset()
val name = declNode.get("name").asText()
val resultType = declNode.get("type").get("qualType").asText().substringBefore("(").trim()
val decls = mutableListOf<Decl>()
logParsingDecl("function $name")
currentParsingIndent++
declNode.get("inner")?.forEach { innerDecl ->
parseDeclNode0(innerDecl)?.let(decls::add)
}
currentParsingIndent--
return AstFunctionDecl(offset, name, resultType, decls)
}
"ParmVarDecl" -> {
if (declNode.hasNoName()) {
return null
}
val offset = declNode.getOffset()
val name = declNode.get("name").asText()
val qualType = declNode.get("type").get("qualType").asText()
val desugaredQualType = declNode.get("type").get("desugaredQualType")?.asText() ?: qualType
val defaultValue: String? = if (declNode.has("init")) {
declNode.getDefaultParamValue()
} else {
null
}
logParsingInner("param $name")
return AstParmVarDecl(offset, name, qualType, desugaredQualType, defaultValue)
}
"FormatAttr" -> {
logParsingInner("param ...")
return AstParmVarDecl.asFormatAttr(declNode.getOffset())
}
"EnumDecl" -> {
if (declNode.hasNoInnerContent() || declNode.hasNoName()) {
return null
}
val offset = declNode.getOffset()
val name = declNode.get("name").asText()
val decls = mutableListOf<Decl>()
logParsingDecl("enum $name")
currentParsingIndent++
declNode.get("inner").forEach { innerDecl ->
parseDeclNode0(innerDecl)?.let(decls::add)
}
currentParsingIndent
// Sort enums by their real pos in the header file.
sortDecls0(decls)
var order = 0
val sortedDecls = decls.map { decl ->
if (decl is AstEnumConstantDecl) {
if (order == 0 && decl.value != null) {
order = decl.value.toIntOrNull() ?: 0
}
AstEnumConstantDecl(
decl.offset,
decl.name,
decl.docComment,
decl.qualType,
order++,
decl.value,
decl.evaluatedValue
)
} else {
decl
}
}
return AstEnumDecl(offset, name, sortedDecls)
}
"EnumConstantDecl" -> {
val offset = declNode.getOffset()
val name = declNode.get("name").asText()
val qualType = declNode.get("type").get("qualType").asText()
// ->inner[0]->
val declValue: String? = declNode.get("inner")?.get(0)?.let {
// Check if the first node is not a comment.
if (it.get("kind").asText() != "FullComment") {
declNode.getDefaultParamValue()
} else {
null
}
}
val evaluatedValue: String? = findNode0(declNode, "kind", "ConstantExpr")?.get("value")?.asText()
val docComment: String? = declNode.findValuesAsText("text")?.joinToString(" ") { it.trim() }
logParsingInner("enum value $name")
return AstEnumConstantDecl(
offset,
name,
docComment,
qualType,
// We provide a proper order in EnumDecl, after sorting all enums by their offset.
-1,
declValue,
evaluatedValue
)
}
"CXXRecordDecl" -> {
if (declNode.hasNoInnerContent() || declNode.hasNoName()) {
return null
}
val offset = declNode.getOffset()
val name = declNode.get("name").asText()
val decls = mutableListOf<Decl>()
logParsingDecl("record $name")
currentParsingIndent++
declNode.get("inner").forEach { innerDecl ->
parseDeclNode0(innerDecl)?.let(decls::add)
}
currentParsingIndent--
return AstRecordDecl(offset, name, decls)
}
"FieldDecl" -> {
if (declNode.hasNoName()) {
return null
}
val offset = declNode.getOffset()
val name = declNode.get("name").asText()
val qualType = declNode.get("type").get("qualType").asText()
val desugaredQualType = declNode.get("type").get("desugaredQualType")?.asText() ?: qualType
logParsingInner("field $name")
return AstFieldDecl(offset, name, qualType, desugaredQualType)
}
else -> {
null
}
}
} catch (e: Exception) {
logger.error("Unable to parse: {}", declNode)
throw Error(e)
}
}
private fun md5Hash(str: String): String {
val md = MessageDigest.getInstance("MD5")
val bigInt = BigInteger(1, md.digest(str.toByteArray(Charsets.UTF_8)))
return String.format("%032x", bigInt)
}
private fun callClangAstBump(scriptPath: String, srcHeader: File, dstJson: File) {
dstJson.delete()
val pb = ProcessBuilder()
pb.command(scriptPath, srcHeader.absolutePath, dstJson.absolutePath)
pb.start().waitFor()
}
/**
* Function removes difference between ast-trees.
* Basically, it returns the list which contains only types with the same name.
*/
private fun removeAstDiff(fullDeclsList: List<Decl>, strippedDeclsList: List<Decl>): List<Decl> {
fun isSameNamespaceName(d1: Decl, d2: Decl): Boolean {
return d1 is AstNamespaceDecl && d2 is AstNamespaceDecl && d1.name == d2.name
}
fun isSameRecordName(d1: Decl, d2: Decl): Boolean {
return d1 is AstRecordDecl && d2 is AstRecordDecl && d1.name == d2.name
}
fun isSameEnumName(d1: Decl, d2: Decl): Boolean {
return d1 is AstEnumDecl && d2 is AstEnumDecl && d1.name == d2.name
}
fun isSameFunctionName(d1: Decl, d2: Decl): Boolean {
return d1 is AstFunctionDecl && d2 is AstFunctionDecl && d1.name == d2.name
}
return fullDeclsList
.filter { d1 ->
strippedDeclsList
.find { d2 ->
d1 == d2
|| isSameRecordName(d1, d2)
|| isSameNamespaceName(d1, d2)
|| isSameEnumName(d1, d2)
|| isSameFunctionName(d1, d2)
} != null
}
.filterNot { it is AstFunctionDecl && it.name.startsWith("operator") }
.toMutableList() // Ensure final list will be mutable for later sorting.
}
/**
* Sort decls in the provided list recursively using offset value.
*/
@Suppress("JavaCollectionsStaticMethodOnImmutableList")
private fun sortDecls0(decls: List<Decl>) {
Collections.sort(decls) { d1, d2 ->
d1.offset.compareTo(d2.offset)
}
decls.forEach {
if (it is DeclContainer) {
sortDecls0(it.decls)
}
}
}
private fun findNode0(root: JsonNode, field: String, value: String): JsonNode? {
if (root.isObject) {
val objectNode = root as ObjectNode
val fields = objectNode.fields()
while (fields.hasNext()) {
val entry = fields.next()
if (entry.key == field && entry.value.asText() == value) {
return root
} else {
val foundNode = findNode0(entry.value, field, value)
if (foundNode != null) {
return foundNode
}
}
}
} else if (root.isArray) {
for (node in root) {
val foundNode = findNode0(node, field, value)
if (foundNode != null) {
return foundNode
}
}
}
return null
}
}
@@ -0,0 +1,7 @@
#!/usr/bin/env sh
# Separate shell script required to ensure that clang++ command is runnable.
# Java ProcessBuilder doesn't see command properly.
# Also, running like that helps to ignore local clang++ warnings which can happen.
clang++ -Xclang -ast-dump=json -fsyntax-only -fparse-all-comments -fmerge-all-constants "$1" >> "$2"
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,779 @@
{
"info" : {
"source" : "include/imguizmo/ImGuizmo.h",
"hash" : "e4cff3bc8014e2bccae881f1b0535298",
"url" : "https://github.com/CedricGuillemet/ImGuizmo.git",
"revision" : "f7bbbe39971d9d45816417a70e9b53a0f698c56e"
},
"decls" : [ {
"@type" : "AstNamespaceDecl",
"offset" : 4983,
"name" : "ImGuizmo",
"decls" : [ {
"@type" : "AstFunctionDecl",
"offset" : 5199,
"name" : "SetDrawlist",
"resultType" : "void",
"decls" : [ {
"@type" : "AstFullComment",
"offset" : 5001,
"decls" : [ {
"@type" : "AstParagraphComment",
"offset" : 5001,
"decls" : [ {
"@type" : "AstTextComment",
"offset" : 5001,
"text" : " call inside your own window and before Manipulate() in order to draw gizmo to that window."
}, {
"@type" : "AstTextComment",
"offset" : 5099,
"text" : " Or pass a specific ImDrawList to draw to (e.g. ImGui::GetForegroundDrawList())."
} ]
} ]
}, {
"@type" : "AstParmVarDecl",
"offset" : 5223,
"name" : "drawlist",
"qualType" : "int *",
"desugaredQualType" : "int *",
"defaultValue" : "="
} ]
}, {
"@type" : "AstFunctionDecl",
"offset" : 5323,
"name" : "BeginFrame",
"resultType" : "void",
"decls" : [ {
"@type" : "AstFullComment",
"offset" : 5252,
"decls" : [ {
"@type" : "AstParagraphComment",
"offset" : 5252,
"decls" : [ {
"@type" : "AstTextComment",
"offset" : 5252,
"text" : " call BeginFrame right after ImGui_XXXX_NewFrame();"
} ]
} ]
} ]
}, {
"@type" : "AstFunctionDecl",
"offset" : 5687,
"name" : "SetImGuiContext",
"resultType" : "void",
"decls" : [ {
"@type" : "AstFullComment",
"offset" : 5345,
"decls" : [ {
"@type" : "AstParagraphComment",
"offset" : 5345,
"decls" : [ {
"@type" : "AstTextComment",
"offset" : 5345,
"text" : " this is necessary because when imguizmo is compiled into a dll, and imgui into another"
}, {
"@type" : "AstTextComment",
"offset" : 5439,
"text" : " globals are not shared between them."
}, {
"@type" : "AstTextComment",
"offset" : 5483,
"text" : " More details at https://stackoverflow.com/questions/19373061/what-happens-to-global-and-static-variables-in-a-shared-library-when-it-is-dynam"
}, {
"@type" : "AstTextComment",
"offset" : 5632,
"text" : " expose method to set imgui context"
} ]
} ]
}, {
"@type" : "AstParmVarDecl",
"offset" : 5717,
"name" : "ctx",
"qualType" : "int *",
"desugaredQualType" : "int *"
} ]
}, {
"@type" : "AstFunctionDecl",
"offset" : 5838,
"name" : "IsOver",
"resultType" : "bool",
"decls" : [ {
"@type" : "AstFullComment",
"offset" : 5731,
"decls" : [ {
"@type" : "AstParagraphComment",
"offset" : 5731,
"decls" : [ {
"@type" : "AstTextComment",
"offset" : 5731,
"text" : " return true if mouse cursor is over any gizmo control (axis, plan or screen component)"
} ]
} ]
} ]
}, {
"@type" : "AstFunctionDecl",
"offset" : 5939,
"name" : "IsUsing",
"resultType" : "bool",
"decls" : [ {
"@type" : "AstFullComment",
"offset" : 5856,
"decls" : [ {
"@type" : "AstParagraphComment",
"offset" : 5856,
"decls" : [ {
"@type" : "AstTextComment",
"offset" : 5856,
"text" : " return true if mouse IsOver or if the gizmo is in moving state"
} ]
} ]
} ]
}, {
"@type" : "AstFunctionDecl",
"offset" : 6121,
"name" : "Enable",
"resultType" : "void",
"decls" : [ {
"@type" : "AstFullComment",
"offset" : 5958,
"decls" : [ {
"@type" : "AstParagraphComment",
"offset" : 5958,
"decls" : [ {
"@type" : "AstTextComment",
"offset" : 5958,
"text" : " enable/disable the gizmo. Stay in the state until next call to Enable."
}, {
"@type" : "AstTextComment",
"offset" : 6036,
"text" : " gizmo is rendered with gray half transparent color when disabled"
} ]
} ]
}, {
"@type" : "AstParmVarDecl",
"offset" : 6133,
"name" : "enable",
"qualType" : "bool",
"desugaredQualType" : "bool"
} ]
}, {
"@type" : "AstFunctionDecl",
"offset" : 6946,
"name" : "DecomposeMatrixToComponents",
"resultType" : "void",
"decls" : [ {
"@type" : "AstFullComment",
"offset" : 6150,
"decls" : [ {
"@type" : "AstParagraphComment",
"offset" : 6150,
"decls" : [ {
"@type" : "AstTextComment",
"offset" : 6150,
"text" : " helper functions for manualy editing translation/rotation/scale with an input float"
}, {
"@type" : "AstTextComment",
"offset" : 6241,
"text" : " translation, rotation and scale float points to 3 floats each"
}, {
"@type" : "AstTextComment",
"offset" : 6310,
"text" : " Angles are in degrees (more suitable for human editing)"
}, {
"@type" : "AstTextComment",
"offset" : 6373,
"text" : " example:"
}, {
"@type" : "AstTextComment",
"offset" : 6389,
"text" : " float matrixTranslation[3], matrixRotation[3], matrixScale[3];"
}, {
"@type" : "AstTextComment",
"offset" : 6459,
"text" : " ImGuizmo::DecomposeMatrixToComponents(gizmoMatrix.m16, matrixTranslation, matrixRotation, matrixScale);"
}, {
"@type" : "AstTextComment",
"offset" : 6570,
"text" : " ImGui::InputFloat3(\"Tr\", matrixTranslation, 3);"
}, {
"@type" : "AstTextComment",
"offset" : 6625,
"text" : " ImGui::InputFloat3(\"Rt\", matrixRotation, 3);"
}, {
"@type" : "AstTextComment",
"offset" : 6677,
"text" : " ImGui::InputFloat3(\"Sc\", matrixScale, 3);"
}, {
"@type" : "AstTextComment",
"offset" : 6726,
"text" : " ImGuizmo::RecomposeMatrixFromComponents(matrixTranslation, matrixRotation, matrixScale, gizmoMatrix.m16);"
} ]
}, {
"@type" : "AstParagraphComment",
"offset" : 6846,
"decls" : [ {
"@type" : "AstTextComment",
"offset" : 6846,
"text" : " These functions have some numerical stability issues for now. Use with caution."
} ]
} ]
}, {
"@type" : "AstParmVarDecl",
"offset" : 6987,
"name" : "matrix",
"qualType" : "const float *",
"desugaredQualType" : "const float *"
}, {
"@type" : "AstParmVarDecl",
"offset" : 7002,
"name" : "translation",
"qualType" : "float *",
"desugaredQualType" : "float *"
}, {
"@type" : "AstParmVarDecl",
"offset" : 7022,
"name" : "rotation",
"qualType" : "float *",
"desugaredQualType" : "float *"
}, {
"@type" : "AstParmVarDecl",
"offset" : 7039,
"name" : "scale",
"qualType" : "float *",
"desugaredQualType" : "float *"
} ]
}, {
"@type" : "AstFunctionDecl",
"offset" : 7066,
"name" : "RecomposeMatrixFromComponents",
"resultType" : "void",
"decls" : [ {
"@type" : "AstParmVarDecl",
"offset" : 7109,
"name" : "translation",
"qualType" : "const float *",
"desugaredQualType" : "const float *"
}, {
"@type" : "AstParmVarDecl",
"offset" : 7135,
"name" : "rotation",
"qualType" : "const float *",
"desugaredQualType" : "const float *"
}, {
"@type" : "AstParmVarDecl",
"offset" : 7158,
"name" : "scale",
"qualType" : "const float *",
"desugaredQualType" : "const float *"
}, {
"@type" : "AstParmVarDecl",
"offset" : 7172,
"name" : "matrix",
"qualType" : "float *",
"desugaredQualType" : "float *"
} ]
}, {
"@type" : "AstFunctionDecl",
"offset" : 7202,
"name" : "SetRect",
"resultType" : "void",
"decls" : [ {
"@type" : "AstParmVarDecl",
"offset" : 7216,
"name" : "x",
"qualType" : "float",
"desugaredQualType" : "float"
}, {
"@type" : "AstParmVarDecl",
"offset" : 7225,
"name" : "y",
"qualType" : "float",
"desugaredQualType" : "float"
}, {
"@type" : "AstParmVarDecl",
"offset" : 7234,
"name" : "width",
"qualType" : "float",
"desugaredQualType" : "float"
}, {
"@type" : "AstParmVarDecl",
"offset" : 7247,
"name" : "height",
"qualType" : "float",
"desugaredQualType" : "float"
} ]
}, {
"@type" : "AstFunctionDecl",
"offset" : 7299,
"name" : "SetOrthographic",
"resultType" : "void",
"decls" : [ {
"@type" : "AstFullComment",
"offset" : 7262,
"decls" : [ {
"@type" : "AstParagraphComment",
"offset" : 7262,
"decls" : [ {
"@type" : "AstTextComment",
"offset" : 7262,
"text" : " default is false"
} ]
} ]
}, {
"@type" : "AstParmVarDecl",
"offset" : 7320,
"name" : "isOrthographic",
"qualType" : "bool",
"desugaredQualType" : "bool"
} ]
}, {
"@type" : "AstFunctionDecl",
"offset" : 7449,
"name" : "DrawCubes",
"resultType" : "void",
"decls" : [ {
"@type" : "AstFullComment",
"offset" : 7345,
"decls" : [ {
"@type" : "AstParagraphComment",
"offset" : 7345,
"decls" : [ {
"@type" : "AstTextComment",
"offset" : 7345,
"text" : " Render a cube with face color corresponding to face normal. Usefull for debug/tests"
} ]
} ]
}, {
"@type" : "AstParmVarDecl",
"offset" : 7472,
"name" : "view",
"qualType" : "const float *",
"desugaredQualType" : "const float *"
}, {
"@type" : "AstParmVarDecl",
"offset" : 7491,
"name" : "projection",
"qualType" : "const float *",
"desugaredQualType" : "const float *"
}, {
"@type" : "AstParmVarDecl",
"offset" : 7516,
"name" : "matrices",
"qualType" : "const float *",
"desugaredQualType" : "const float *"
}, {
"@type" : "AstParmVarDecl",
"offset" : 7530,
"name" : "matrixCount",
"qualType" : "int",
"desugaredQualType" : "int"
} ]
}, {
"@type" : "AstFunctionDecl",
"offset" : 7563,
"name" : "DrawGrid",
"resultType" : "void",
"decls" : [ {
"@type" : "AstParmVarDecl",
"offset" : 7585,
"name" : "view",
"qualType" : "const float *",
"desugaredQualType" : "const float *"
}, {
"@type" : "AstParmVarDecl",
"offset" : 7604,
"name" : "projection",
"qualType" : "const float *",
"desugaredQualType" : "const float *"
}, {
"@type" : "AstParmVarDecl",
"offset" : 7629,
"name" : "matrix",
"qualType" : "const float *",
"desugaredQualType" : "const float *"
}, {
"@type" : "AstParmVarDecl",
"offset" : 7649,
"name" : "gridSize",
"qualType" : "const float",
"desugaredQualType" : "const float"
} ]
}, {
"@type" : "AstEnumDecl",
"offset" : 7946,
"name" : "OPERATION",
"decls" : [ {
"@type" : "AstFullComment",
"offset" : 7668,
"decls" : [ {
"@type" : "AstParagraphComment",
"offset" : 7668,
"decls" : [ {
"@type" : "AstTextComment",
"offset" : 7668,
"text" : " call it when you want a gizmo"
}, {
"@type" : "AstTextComment",
"offset" : 7705,
"text" : " Needs view and projection matrices. "
}, {
"@type" : "AstTextComment",
"offset" : 7749,
"text" : " matrix parameter is the source matrix (where will be gizmo be drawn) and might be transformed by the function. Return deltaMatrix is optional"
}, {
"@type" : "AstTextComment",
"offset" : 7898,
"text" : " translation is applied in world space"
} ]
} ]
}, {
"@type" : "AstEnumConstantDecl",
"offset" : 7969,
"name" : "TRANSLATE_X",
"qualType" : "ImGuizmo::OPERATION",
"order" : 0,
"value" : "(1u << 0)",
"evaluatedValue" : "1"
}, {
"@type" : "AstEnumConstantDecl",
"offset" : 8006,
"name" : "TRANSLATE_Y",
"qualType" : "ImGuizmo::OPERATION",
"order" : 1,
"value" : "(1u << 1)",
"evaluatedValue" : "2"
}, {
"@type" : "AstEnumConstantDecl",
"offset" : 8043,
"name" : "TRANSLATE_Z",
"qualType" : "ImGuizmo::OPERATION",
"order" : 2,
"value" : "(1u << 2)",
"evaluatedValue" : "4"
}, {
"@type" : "AstEnumConstantDecl",
"offset" : 8080,
"name" : "ROTATE_X",
"qualType" : "ImGuizmo::OPERATION",
"order" : 3,
"value" : "(1u << 3)",
"evaluatedValue" : "8"
}, {
"@type" : "AstEnumConstantDecl",
"offset" : 8117,
"name" : "ROTATE_Y",
"qualType" : "ImGuizmo::OPERATION",
"order" : 4,
"value" : "(1u << 4)",
"evaluatedValue" : "16"
}, {
"@type" : "AstEnumConstantDecl",
"offset" : 8154,
"name" : "ROTATE_Z",
"qualType" : "ImGuizmo::OPERATION",
"order" : 5,
"value" : "(1u << 5)",
"evaluatedValue" : "32"
}, {
"@type" : "AstEnumConstantDecl",
"offset" : 8191,
"name" : "ROTATE_SCREEN",
"qualType" : "ImGuizmo::OPERATION",
"order" : 6,
"value" : "(1u << 6)",
"evaluatedValue" : "64"
}, {
"@type" : "AstEnumConstantDecl",
"offset" : 8228,
"name" : "SCALE_X",
"qualType" : "ImGuizmo::OPERATION",
"order" : 7,
"value" : "(1u << 7)",
"evaluatedValue" : "128"
}, {
"@type" : "AstEnumConstantDecl",
"offset" : 8265,
"name" : "SCALE_Y",
"qualType" : "ImGuizmo::OPERATION",
"order" : 8,
"value" : "(1u << 8)",
"evaluatedValue" : "256"
}, {
"@type" : "AstEnumConstantDecl",
"offset" : 8302,
"name" : "SCALE_Z",
"qualType" : "ImGuizmo::OPERATION",
"order" : 9,
"value" : "(1u << 9)",
"evaluatedValue" : "512"
}, {
"@type" : "AstEnumConstantDecl",
"offset" : 8339,
"name" : "BOUNDS",
"qualType" : "ImGuizmo::OPERATION",
"order" : 10,
"value" : "(1u << 10)",
"evaluatedValue" : "1024"
}, {
"@type" : "AstEnumConstantDecl",
"offset" : 8377,
"name" : "TRANSLATE",
"qualType" : "ImGuizmo::OPERATION",
"order" : 11,
"value" : "TRANSLATE_X | TRANSLATE_Y | TRANSLATE_Z",
"evaluatedValue" : "7"
}, {
"@type" : "AstEnumConstantDecl",
"offset" : 8437,
"name" : "ROTATE",
"qualType" : "ImGuizmo::OPERATION",
"order" : 12,
"value" : "ROTATE_X | ROTATE_Y | ROTATE_Z | ROTATE_SCREEN",
"evaluatedValue" : "120"
}, {
"@type" : "AstEnumConstantDecl",
"offset" : 8501,
"name" : "SCALE",
"qualType" : "ImGuizmo::OPERATION",
"order" : 13,
"value" : "SCALE_X | SCALE_Y | SCALE_Z",
"evaluatedValue" : "896"
} ]
}, {
"@type" : "AstFunctionDecl",
"offset" : 8567,
"name" : "operator|",
"resultType" : "OPERATION",
"decls" : [ {
"@type" : "AstParmVarDecl",
"offset" : 8587,
"name" : "lhs",
"qualType" : "OPERATION",
"desugaredQualType" : "ImGuizmo::OPERATION"
}, {
"@type" : "AstParmVarDecl",
"offset" : 8602,
"name" : "rhs",
"qualType" : "OPERATION",
"desugaredQualType" : "ImGuizmo::OPERATION"
} ]
}, {
"@type" : "AstEnumDecl",
"offset" : 8714,
"name" : "MODE",
"decls" : [ {
"@type" : "AstEnumConstantDecl",
"offset" : 8732,
"name" : "LOCAL",
"qualType" : "ImGuizmo::MODE",
"order" : 0
}, {
"@type" : "AstEnumConstantDecl",
"offset" : 8746,
"name" : "WORLD",
"qualType" : "ImGuizmo::MODE",
"order" : 1
} ]
}, {
"@type" : "AstFunctionDecl",
"offset" : 8780,
"name" : "Manipulate",
"resultType" : "bool",
"decls" : [ {
"@type" : "AstParmVarDecl",
"offset" : 8804,
"name" : "view",
"qualType" : "const float *",
"desugaredQualType" : "const float *"
}, {
"@type" : "AstParmVarDecl",
"offset" : 8823,
"name" : "projection",
"qualType" : "const float *",
"desugaredQualType" : "const float *"
}, {
"@type" : "AstParmVarDecl",
"offset" : 8845,
"name" : "operation",
"qualType" : "OPERATION",
"desugaredQualType" : "ImGuizmo::OPERATION"
}, {
"@type" : "AstParmVarDecl",
"offset" : 8861,
"name" : "mode",
"qualType" : "MODE",
"desugaredQualType" : "ImGuizmo::MODE"
}, {
"@type" : "AstParmVarDecl",
"offset" : 8874,
"name" : "matrix",
"qualType" : "float *",
"desugaredQualType" : "float *"
}, {
"@type" : "AstParmVarDecl",
"offset" : 8889,
"name" : "deltaMatrix",
"qualType" : "float *",
"desugaredQualType" : "float *",
"defaultValue" : "="
}, {
"@type" : "AstParmVarDecl",
"offset" : 8922,
"name" : "snap",
"qualType" : "const float *",
"desugaredQualType" : "const float *",
"defaultValue" : "="
}, {
"@type" : "AstParmVarDecl",
"offset" : 8948,
"name" : "localBounds",
"qualType" : "const float *",
"desugaredQualType" : "const float *",
"defaultValue" : "="
}, {
"@type" : "AstParmVarDecl",
"offset" : 8981,
"name" : "boundsSnap",
"qualType" : "const float *",
"desugaredQualType" : "const float *",
"defaultValue" : "="
} ]
}, {
"@type" : "AstFunctionDecl",
"offset" : 9338,
"name" : "ViewManipulate",
"resultType" : "void",
"decls" : [ {
"@type" : "AstFullComment",
"offset" : 9014,
"decls" : [ {
"@type" : "AstParagraphComment",
"offset" : 9014,
"decls" : [ {
"@type" : "AstTextComment",
"offset" : 9014,
"text" : " Please note that this cubeview is patented by Autodesk : https://patents.google.com/patent/US7782319B2/en"
}, {
"@type" : "AstTextComment",
"offset" : 9127,
"text" : " It seems to be a defensive patent in the US. I don't think it will bring troubles using it as"
}, {
"@type" : "AstTextComment",
"offset" : 9228,
"text" : " other software are using the same mechanics. But just in case, you are now warned!"
} ]
} ]
}, {
"@type" : "AstParmVarDecl",
"offset" : 9360,
"name" : "view",
"qualType" : "float *",
"desugaredQualType" : "float *"
}, {
"@type" : "AstParmVarDecl",
"offset" : 9372,
"name" : "length",
"qualType" : "float",
"desugaredQualType" : "float"
}, {
"@type" : "AstParmVarDecl",
"offset" : 9387,
"name" : "position",
"qualType" : "int",
"desugaredQualType" : "int"
}, {
"@type" : "AstParmVarDecl",
"offset" : 9404,
"name" : "size",
"qualType" : "int",
"desugaredQualType" : "int"
}, {
"@type" : "AstParmVarDecl",
"offset" : 9416,
"name" : "backgroundColor",
"qualType" : "int",
"desugaredQualType" : "int"
} ]
}, {
"@type" : "AstFunctionDecl",
"offset" : 9455,
"name" : "SetID",
"resultType" : "void",
"decls" : [ {
"@type" : "AstParmVarDecl",
"offset" : 9465,
"name" : "id",
"qualType" : "int",
"desugaredQualType" : "int"
} ]
}, {
"@type" : "AstFunctionDecl",
"offset" : 9554,
"name" : "IsOver",
"resultType" : "bool",
"decls" : [ {
"@type" : "AstFullComment",
"offset" : 9478,
"decls" : [ {
"@type" : "AstParagraphComment",
"offset" : 9478,
"decls" : [ {
"@type" : "AstTextComment",
"offset" : 9478,
"text" : " return true if the cursor is over the operation's gizmo"
} ]
} ]
}, {
"@type" : "AstParmVarDecl",
"offset" : 9571,
"name" : "op",
"qualType" : "OPERATION",
"desugaredQualType" : "ImGuizmo::OPERATION"
} ]
}, {
"@type" : "AstFunctionDecl",
"offset" : 9595,
"name" : "SetGizmoSizeClipSpace",
"resultType" : "void",
"decls" : [ {
"@type" : "AstParmVarDecl",
"offset" : 9623,
"name" : "value",
"qualType" : "float",
"desugaredQualType" : "float"
} ]
}, {
"@type" : "AstFunctionDecl",
"offset" : 9821,
"name" : "AllowAxisFlip",
"resultType" : "void",
"decls" : [ {
"@type" : "AstFullComment",
"offset" : 9639,
"decls" : [ {
"@type" : "AstParagraphComment",
"offset" : 9639,
"decls" : [ {
"@type" : "AstTextComment",
"offset" : 9639,
"text" : " Allow axis to flip"
}, {
"@type" : "AstTextComment",
"offset" : 9665,
"text" : " When true (default), the guizmo axis flip for better visibility"
}, {
"@type" : "AstTextComment",
"offset" : 9736,
"text" : " When false, they always stay along the positive world/local axis"
} ]
} ]
}, {
"@type" : "AstParmVarDecl",
"offset" : 9840,
"name" : "value",
"qualType" : "bool",
"desugaredQualType" : "bool"
} ]
} ]
} ]
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,279 @@
{
"info" : {
"source" : "include/imgui-knobs/imgui-knobs.h",
"hash" : "1f637f21a158aff7116bdb283dc83d46",
"url" : "https://github.com/altschuler/imgui-knobs",
"revision" : "4f207526f9ef036a0aff7edfaad92cfbe12d987a"
},
"decls" : [ {
"@type" : "AstEnumDecl",
"offset" : 87,
"name" : "ImGuiKnobFlags_",
"decls" : [ {
"@type" : "AstEnumConstantDecl",
"offset" : 109,
"name" : "ImGuiKnobFlags_NoTitle",
"qualType" : "ImGuiKnobFlags_",
"order" : 0,
"value" : "1 << 0",
"evaluatedValue" : "1"
}, {
"@type" : "AstEnumConstantDecl",
"offset" : 146,
"name" : "ImGuiKnobFlags_NoInput",
"qualType" : "ImGuiKnobFlags_",
"order" : 1,
"value" : "1 << 1",
"evaluatedValue" : "2"
}, {
"@type" : "AstEnumConstantDecl",
"offset" : 183,
"name" : "ImGuiKnobFlags_ValueTooltip",
"qualType" : "ImGuiKnobFlags_",
"order" : 2,
"value" : "1 << 2",
"evaluatedValue" : "4"
}, {
"@type" : "AstEnumConstantDecl",
"offset" : 225,
"name" : "ImGuiKnobFlags_DragHorizontal",
"qualType" : "ImGuiKnobFlags_",
"order" : 3,
"value" : "1 << 3",
"evaluatedValue" : "8"
} ]
}, {
"@type" : "AstEnumDecl",
"offset" : 305,
"name" : "ImGuiKnobVariant_",
"decls" : [ {
"@type" : "AstEnumConstantDecl",
"offset" : 329,
"name" : "ImGuiKnobVariant_Tick",
"qualType" : "ImGuiKnobVariant_",
"order" : 0,
"value" : "1 << 0",
"evaluatedValue" : "1"
}, {
"@type" : "AstEnumConstantDecl",
"offset" : 365,
"name" : "ImGuiKnobVariant_Dot",
"qualType" : "ImGuiKnobVariant_",
"order" : 1,
"value" : "1 << 1",
"evaluatedValue" : "2"
}, {
"@type" : "AstEnumConstantDecl",
"offset" : 400,
"name" : "ImGuiKnobVariant_Wiper",
"qualType" : "ImGuiKnobVariant_",
"order" : 2,
"value" : "1 << 2",
"evaluatedValue" : "4"
}, {
"@type" : "AstEnumConstantDecl",
"offset" : 437,
"name" : "ImGuiKnobVariant_WiperOnly",
"qualType" : "ImGuiKnobVariant_",
"order" : 3,
"value" : "1 << 3",
"evaluatedValue" : "8"
}, {
"@type" : "AstEnumConstantDecl",
"offset" : 478,
"name" : "ImGuiKnobVariant_WiperDot",
"qualType" : "ImGuiKnobVariant_",
"order" : 4,
"value" : "1 << 4",
"evaluatedValue" : "16"
}, {
"@type" : "AstEnumConstantDecl",
"offset" : 518,
"name" : "ImGuiKnobVariant_Stepped",
"qualType" : "ImGuiKnobVariant_",
"order" : 5,
"value" : "1 << 5",
"evaluatedValue" : "32"
}, {
"@type" : "AstEnumConstantDecl",
"offset" : 557,
"name" : "ImGuiKnobVariant_Space",
"qualType" : "ImGuiKnobVariant_",
"order" : 6,
"value" : "1 << 6",
"evaluatedValue" : "64"
} ]
}, {
"@type" : "AstNamespaceDecl",
"offset" : 604,
"name" : "ImGuiKnobs",
"decls" : [ {
"@type" : "AstRecordDecl",
"offset" : 629,
"name" : "color_set",
"decls" : [ {
"@type" : "AstFieldDecl",
"offset" : 657,
"name" : "base",
"qualType" : "int",
"desugaredQualType" : "int"
}, {
"@type" : "AstFieldDecl",
"offset" : 679,
"name" : "hovered",
"qualType" : "int",
"desugaredQualType" : "int"
}, {
"@type" : "AstFieldDecl",
"offset" : 704,
"name" : "active",
"qualType" : "int",
"desugaredQualType" : "int"
} ]
}, {
"@type" : "AstFunctionDecl",
"offset" : 974,
"name" : "Knob",
"resultType" : "bool",
"decls" : [ {
"@type" : "AstParmVarDecl",
"offset" : 991,
"name" : "label",
"qualType" : "const char *",
"desugaredQualType" : "const char *"
}, {
"@type" : "AstParmVarDecl",
"offset" : 1005,
"name" : "p_value",
"qualType" : "float *",
"desugaredQualType" : "float *"
}, {
"@type" : "AstParmVarDecl",
"offset" : 1020,
"name" : "v_min",
"qualType" : "float",
"desugaredQualType" : "float"
}, {
"@type" : "AstParmVarDecl",
"offset" : 1033,
"name" : "v_max",
"qualType" : "float",
"desugaredQualType" : "float"
}, {
"@type" : "AstParmVarDecl",
"offset" : 1046,
"name" : "speed",
"qualType" : "float",
"desugaredQualType" : "float",
"defaultValue" : "0"
}, {
"@type" : "AstParmVarDecl",
"offset" : 1069,
"name" : "format",
"qualType" : "const char *",
"desugaredQualType" : "const char *",
"defaultValue" : "NULL"
}, {
"@type" : "AstParmVarDecl",
"offset" : 1101,
"name" : "variant",
"qualType" : "ImGuiKnobVariant",
"desugaredQualType" : "int",
"defaultValue" : "ImGuiKnobVariant_Tick"
}, {
"@type" : "AstParmVarDecl",
"offset" : 1140,
"name" : "size",
"qualType" : "float",
"desugaredQualType" : "float",
"defaultValue" : "0"
}, {
"@type" : "AstParmVarDecl",
"offset" : 1165,
"name" : "flags",
"qualType" : "ImGuiKnobFlags",
"desugaredQualType" : "int",
"defaultValue" : "0"
}, {
"@type" : "AstParmVarDecl",
"offset" : 1180,
"name" : "steps",
"qualType" : "int",
"desugaredQualType" : "int",
"defaultValue" : "10"
} ]
}, {
"@type" : "AstFunctionDecl",
"offset" : 1202,
"name" : "KnobInt",
"resultType" : "bool",
"decls" : [ {
"@type" : "AstParmVarDecl",
"offset" : 1222,
"name" : "label",
"qualType" : "const char *",
"desugaredQualType" : "const char *"
}, {
"@type" : "AstParmVarDecl",
"offset" : 1234,
"name" : "p_value",
"qualType" : "int *",
"desugaredQualType" : "int *"
}, {
"@type" : "AstParmVarDecl",
"offset" : 1247,
"name" : "v_min",
"qualType" : "int",
"desugaredQualType" : "int"
}, {
"@type" : "AstParmVarDecl",
"offset" : 1258,
"name" : "v_max",
"qualType" : "int",
"desugaredQualType" : "int"
}, {
"@type" : "AstParmVarDecl",
"offset" : 1271,
"name" : "speed",
"qualType" : "float",
"desugaredQualType" : "float",
"defaultValue" : "0"
}, {
"@type" : "AstParmVarDecl",
"offset" : 1294,
"name" : "format",
"qualType" : "const char *",
"desugaredQualType" : "const char *",
"defaultValue" : "NULL"
}, {
"@type" : "AstParmVarDecl",
"offset" : 1326,
"name" : "variant",
"qualType" : "ImGuiKnobVariant",
"desugaredQualType" : "int",
"defaultValue" : "ImGuiKnobVariant_Tick"
}, {
"@type" : "AstParmVarDecl",
"offset" : 1365,
"name" : "size",
"qualType" : "float",
"desugaredQualType" : "float",
"defaultValue" : "0"
}, {
"@type" : "AstParmVarDecl",
"offset" : 1390,
"name" : "flags",
"qualType" : "ImGuiKnobFlags",
"desugaredQualType" : "int",
"defaultValue" : "0"
}, {
"@type" : "AstParmVarDecl",
"offset" : 1405,
"name" : "steps",
"qualType" : "int",
"desugaredQualType" : "int",
"defaultValue" : "10"
} ]
} ]
} ]
}
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -1,5 +1,6 @@
import imgui.ImGui;
import imgui.extension.texteditor.TextEditor;
import imgui.extension.texteditor.TextEditorCoordinates;
import imgui.extension.texteditor.TextEditorLanguageDefinition;
import imgui.flag.ImGuiWindowFlags;
import imgui.type.ImBoolean;
@@ -11,7 +12,7 @@ public class ExampleImGuiColorTextEdit {
private static final TextEditor EDITOR = new TextEditor();
static {
TextEditorLanguageDefinition lang = TextEditorLanguageDefinition.c();
TextEditorLanguageDefinition lang = TextEditorLanguageDefinition.C();
String[] ppnames = {
"NULL", "PM_REMOVE",
@@ -122,13 +123,12 @@ public class ExampleImGuiColorTextEdit {
ImGui.endMenuBar();
}
int cposX = EDITOR.getCursorPositionLine();
int cposY = EDITOR.getCursorPositionColumn();
TextEditorCoordinates cpos = EDITOR.getCursorPosition();
String overwrite = EDITOR.isOverwrite() ? "Ovr" : "Ins";
String canUndo = EDITOR.canUndo() ? "*" : " ";
ImGui.text(cposX + "/" + cposY + " " + EDITOR.getTotalLines() + " lines | " + overwrite + " | " + canUndo);
ImGui.text(cpos.mLine + "/" + cpos.mColumn + " " + EDITOR.getTotalLines() + " lines | " + overwrite + " | " + canUndo);
EDITOR.render("TextEditor");
@@ -16,7 +16,7 @@ public class ExampleImGuiFileDialog {
private static long userData = 0;
private static ImGuiFileDialogPaneFun callback = new ImGuiFileDialogPaneFun() {
@Override
public void paneFun(String filter, long userDatas, boolean canContinue) {
public void accept(String filter, long userDatas, boolean canContinue) {
ImGui.text("Filter: " + filter);
}
};
@@ -51,7 +51,7 @@ public class ExampleImGuiFileDialog {
}
if (ImGui.button("Browse Folder")) {
ImGuiFileDialog.openDialog("browse-folder-key", "Choose Folder", null, ".", "", 1, 7, ImGuiFileDialogFlags.None);
ImGuiFileDialog.openDialog("browse-folder-key", "Choose Folder", null, ".", "", callback, 1, 7L, ImGuiFileDialogFlags.None);
}
if (ImGuiFileDialog.display("browse-folder-key", ImGuiFileDialogFlags.None, 200, 400, 800, 600)) {
@@ -1,3 +1,4 @@
import imgui.ImVec2;
import imgui.extension.nodeditor.NodeEditor;
import imgui.extension.nodeditor.NodeEditorConfig;
import imgui.extension.nodeditor.NodeEditorContext;
@@ -17,7 +18,7 @@ public class ExampleImGuiNodeEditor {
static {
NodeEditorConfig config = new NodeEditorConfig();
config.setSettingsFile(null);
CONTEXT = new NodeEditorContext(config);
CONTEXT = NodeEditor.createEditor(config);
}
public static void show(final ImBoolean showImNodeEditorWindow, final Graph graph) {
@@ -108,9 +109,8 @@ public class ExampleImGuiNodeEditor {
if (ImGui.beginPopup("node_editor_context")) {
if (ImGui.button("Create New Node")) {
final Graph.GraphNode node = graph.createGraphNode();
final float canvasX = NodeEditor.toCanvasX(ImGui.getMousePosX());
final float canvasY = NodeEditor.toCanvasY(ImGui.getMousePosY());
NodeEditor.setNodePosition(node.nodeId, canvasX, canvasY);
final ImVec2 canvas = NodeEditor.screenToCanvas(ImGui.getMousePos());
NodeEditor.setNodePosition(node.nodeId, canvas);
ImGui.closeCurrentPopup();
}
ImGui.endPopup();
+11 -12
View File
@@ -1,4 +1,5 @@
import imgui.ImGui;
import imgui.ImVec2;
import imgui.extension.imguizmo.ImGuizmo;
import imgui.extension.imguizmo.flag.Mode;
import imgui.extension.imguizmo.flag.Operation;
@@ -59,8 +60,6 @@ public class ExampleImGuizmo {
0.f, 0.f, 0.f, 1.f
};
private static final float[] VIEW_MANIPULATE_SIZE = new float[]{128f, 128f};
private static final float[] EMPTY = new float[]{0};
private static final float[] INPUT_CAMERA_VIEW = {
@@ -166,7 +165,7 @@ public class ExampleImGuizmo {
ImGui.inputFloat3("Sc", INPUT_MATRIX_SCALE, "%.3f", ImGuiInputTextFlags.ReadOnly);
if (ImGuizmo.isUsing()) {
ImGuizmo.recomposeMatrixFromComponents(OBJECT_MATRICES[0], INPUT_MATRIX_TRANSLATION, INPUT_MATRIX_ROTATION, INPUT_MATRIX_SCALE);
ImGuizmo.recomposeMatrixFromComponents(INPUT_MATRIX_TRANSLATION, INPUT_MATRIX_ROTATION, INPUT_MATRIX_SCALE, OBJECT_MATRICES[0]);
}
if (currentGizmoOperation != Operation.SCALE) {
@@ -217,7 +216,7 @@ public class ExampleImGuizmo {
float[] cameraProjection = perspective(27, aspect, 0.1f, 100f);
ImGuizmo.setOrthographic(false);
ImGuizmo.setEnabled(true);
ImGuizmo.enable(true);
ImGuizmo.setDrawList();
float windowWidth = ImGui.getWindowWidth();
@@ -225,26 +224,26 @@ public class ExampleImGuizmo {
ImGuizmo.setRect(ImGui.getWindowPosX(), ImGui.getWindowPosY(), windowWidth, windowHeight);
ImGuizmo.drawGrid(INPUT_CAMERA_VIEW, cameraProjection, IDENTITY_MATRIX, 100);
ImGuizmo.setId(0);
ImGuizmo.setID(0);
ImGuizmo.drawCubes(INPUT_CAMERA_VIEW, cameraProjection, OBJECT_MATRICES[0]);
if (USE_SNAP.get() && BOUNDING_SIZE.get() && boundSizingSnap) {
ImGuizmo.manipulate(INPUT_CAMERA_VIEW, cameraProjection, OBJECT_MATRICES[0], currentGizmoOperation, currentMode, INPUT_SNAP_VALUE, INPUT_BOUNDS, INPUT_BOUNDS_SNAP);
ImGuizmo.manipulate(INPUT_CAMERA_VIEW, cameraProjection, currentGizmoOperation, currentMode, OBJECT_MATRICES[0], null, INPUT_SNAP_VALUE, INPUT_BOUNDS, INPUT_BOUNDS_SNAP);
} else if (USE_SNAP.get() && BOUNDING_SIZE.get()) {
ImGuizmo.manipulate(INPUT_CAMERA_VIEW, cameraProjection, OBJECT_MATRICES[0], currentGizmoOperation, currentMode, INPUT_SNAP_VALUE, INPUT_BOUNDS);
ImGuizmo.manipulate(INPUT_CAMERA_VIEW, cameraProjection, currentGizmoOperation, currentMode, OBJECT_MATRICES[0], null, INPUT_SNAP_VALUE, INPUT_BOUNDS);
} else if (BOUNDING_SIZE.get() && boundSizingSnap) {
ImGuizmo.manipulate(INPUT_CAMERA_VIEW, cameraProjection, OBJECT_MATRICES[0], currentGizmoOperation, currentMode, EMPTY, INPUT_BOUNDS, INPUT_BOUNDS_SNAP);
ImGuizmo.manipulate(INPUT_CAMERA_VIEW, cameraProjection, currentGizmoOperation, currentMode, OBJECT_MATRICES[0], null, EMPTY, INPUT_BOUNDS, INPUT_BOUNDS_SNAP);
} else if (BOUNDING_SIZE.get()) {
ImGuizmo.manipulate(INPUT_CAMERA_VIEW, cameraProjection, OBJECT_MATRICES[0], currentGizmoOperation, currentMode, EMPTY, INPUT_BOUNDS);
ImGuizmo.manipulate(INPUT_CAMERA_VIEW, cameraProjection, currentGizmoOperation, currentMode, OBJECT_MATRICES[0], null, EMPTY, INPUT_BOUNDS);
} else if (USE_SNAP.get()) {
ImGuizmo.manipulate(INPUT_CAMERA_VIEW, cameraProjection, OBJECT_MATRICES[0], currentGizmoOperation, currentMode, INPUT_SNAP_VALUE);
ImGuizmo.manipulate(INPUT_CAMERA_VIEW, cameraProjection, currentGizmoOperation, currentMode, OBJECT_MATRICES[0], null, INPUT_SNAP_VALUE);
} else {
ImGuizmo.manipulate(INPUT_CAMERA_VIEW, cameraProjection, OBJECT_MATRICES[0], currentGizmoOperation, currentMode);
ImGuizmo.manipulate(INPUT_CAMERA_VIEW, cameraProjection, currentGizmoOperation, currentMode, OBJECT_MATRICES[0]);
}
float viewManipulateRight = ImGui.getWindowPosX() + windowWidth;
float viewManipulateTop = ImGui.getWindowPosY();
ImGuizmo.viewManipulate(INPUT_CAMERA_VIEW, CAM_DISTANCE, new float[]{viewManipulateRight - 128, viewManipulateTop}, VIEW_MANIPULATE_SIZE, 0x10101010);
ImGuizmo.viewManipulate(INPUT_CAMERA_VIEW, CAM_DISTANCE, viewManipulateRight - 128, viewManipulateTop, 128, 128, 0x10101010);
ImGui.endChild();
ImGui.end();
+5 -2
View File
@@ -1,5 +1,6 @@
import imgui.extension.imnodes.ImNodes;
import imgui.extension.imnodes.ImNodesContext;
import imgui.extension.imnodes.ImNodesEditorContext;
import imgui.extension.imnodes.flag.ImNodesPinShape;
import imgui.extension.imnodes.flag.ImNodesMiniMapLocation;
import imgui.flag.ImGuiCond;
@@ -12,14 +13,16 @@ import java.awt.Desktop;
import java.net.URI;
public class ExampleImNodes {
private static final ImNodesContext CONTEXT = new ImNodesContext();
private static final String URL = "https://github.com/Nelarius/imnodes/tree/857cc86";
private static final ImInt LINK_A = new ImInt();
private static final ImInt LINK_B = new ImInt();
private static ImNodesEditorContext editorContext = null;
static {
ImNodes.createContext();
editorContext = ImNodes.editorContextCreate();
}
public static void show(final ImBoolean showImNodesWindow, final Graph graph) {
@@ -39,7 +42,7 @@ public class ExampleImNodes {
}
}
ImNodes.editorContextSet(CONTEXT);
ImNodes.editorContextSet(editorContext);
ImNodes.beginNodeEditor();
for (Graph.GraphNode node : graph.nodes.values()) {
+27 -16
View File
@@ -1,4 +1,5 @@
import imgui.extension.implot.ImPlot;
import imgui.extension.implot.ImPlotPoint;
import imgui.flag.ImGuiCond;
import imgui.internal.ImGui;
import imgui.type.ImBoolean;
@@ -10,10 +11,10 @@ public class ExampleImPlot {
private static final String URL = "https://github.com/epezent/implot/tree/555ff68";
private static final ImBoolean showDemo = new ImBoolean(false);
private static final Integer[] xs = {0, 1, 2, 3, 4, 5};
private static final Integer[] ys = {0, 1, 2, 3, 4, 5};
private static final Integer[] ys1 = {0, 0, 1, 2, 3, 4};
private static final Integer[] ys2 = {1, 2, 3, 4, 5, 6};
private static final int[] xs = {0, 1, 2, 3, 4, 5};
private static final int[] ys = {0, 1, 2, 3, 4, 5};
private static final int[] ys1 = {0, 0, 1, 2, 3, 4};
private static final int[] ys2 = {1, 2, 3, 4, 5, 6};
static {
ImPlot.createContext();
@@ -38,20 +39,30 @@ public class ExampleImPlot {
ImGui.checkbox("Show ImPlot Built-In Demo", showDemo);
if (ImPlot.beginPlot("Example Plot")) {
ImPlot.plotShaded("Shaded", xs, ys1, ys2);
ImPlot.plotLine("Line", xs, ys);
ImPlot.plotBars("Bars", xs, ys);
ImPlot.endPlot();
}
if (ImPlot.beginPlot("Example Scatterplot")) {
ImPlot.plotScatter("Scatter", xs, ys);
ImPlot.endPlot();
}
if (showDemo.get()) {
ImPlot.showDemoWindow(showDemo);
} else {
if (ImPlot.beginPlot("Example Plot")) {
ImPlot.plotShaded("Shaded", xs, ys1, ys2);
ImPlot.plotLine("Line", xs, ys);
ImPlot.plotBars("Bars", xs, ys);
ImPlot.endPlot();
}
if (ImPlot.beginPlot("Example Scatterplot")) {
ImPlot.plotScatter("Scatter", xs, ys);
ImPlot.endPlot();
}
if (ImPlot.beginPlot("Example Piechart")) {
ImPlot.plotPieChart(new String[]{"1", "2", "3", "4", "5", "6"}, xs, .5, .5, .4);
ImPlot.endPlot();
}
if (ImPlot.beginPlot("Example Heatmap")) {
ImPlot.plotHeatmap("Heatmap", new int[]{1, 3, 6, 2, 8, 5, 4, 3}, 2, 4, 0, 0, "%d", new ImPlotPoint(0, 0), new ImPlotPoint(10, 10));
ImPlot.endPlot();
}
}
}
+7 -13
View File
@@ -23,19 +23,13 @@ public class ExampleKnobs {
if (ImGui.begin("Knobs Demo Window", showKnobsWindow, ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse)) {
ImGui.textWrapped("This is a demo for dear ImGui Knobs");
if (ImGui.beginChild("Float Knobs")) {
ImGuiKnobs.knobFloat("Example Tick Knob", EXAMPLE_TICK_KNOB_VAL, 0.0f, 10.0f, 0.2f, "%.1f", ImGuiKnobVariant.TICK, 50.0f, ImGuiKnobFlags.NONE, 1);
ImGuiKnobs.knobFloat("Example Dot Knob", EXAMPLE_DOT_KNOB_VAL, 0.0f, 10.0f, 0.2f, "%.1f", ImGuiKnobVariant.DOT, 50.0f, ImGuiKnobFlags.NONE, 1);
ImGuiKnobs.knobFloat("Example Space Knob", EXAMPLE_SPACE_KNOB_VAL, 0.0f, 10.0f, 0.2f, "%.1f", ImGuiKnobVariant.SPACE, 50.0f, ImGuiKnobFlags.NONE, 1);
ImGuiKnobs.knobFloat("Example Wiper Knob", EXAMPLE_WIPER_KNOB_VAL, 0.0f, 10.0f, 0.2f, "%.1f", ImGuiKnobVariant.WIPER, 50.0f, ImGuiKnobFlags.NONE, 1);
ImGuiKnobs.knobFloat("Example Wiper Dot Knob", EXAMPLE_WIPER_DOT_KNOB_VAL, 0.0f, 10.0f, 0.2f, "%.1f", ImGuiKnobVariant.WIPER_DOT, 50.0f, ImGuiKnobFlags.NONE, 1);
ImGuiKnobs.knobFloat("Example Wiper Only Knob", EXAMPLE_WIPER_ONLY_KNOB_VAL, 0.0f, 10.0f, 0.2f, "%.1f", ImGuiKnobVariant.WIPER_ONLY, 50.0f, ImGuiKnobFlags.NONE, 1);
ImGuiKnobs.knobFloat("Example Stepped Knob", EXAMPLE_STEPPED_KNOB_VAL, 0.0f, 10.0f, 0.2f, "%.1f", ImGuiKnobVariant.STEPPED, 50.0f, ImGuiKnobFlags.NONE, 1);
ImGuiKnobs.knob("Example Tick Knob", EXAMPLE_TICK_KNOB_VAL, 0.0f, 10.0f, 0.2f, "%.1f", ImGuiKnobVariant.Tick, 50.0f, ImGuiKnobFlags.None, 1);
ImGuiKnobs.knob("Example Dot Knob", EXAMPLE_DOT_KNOB_VAL, 0.0f, 10.0f, 0.2f, "%.1f", ImGuiKnobVariant.Dot, 50.0f, ImGuiKnobFlags.None, 1);
ImGuiKnobs.knob("Example Space Knob", EXAMPLE_SPACE_KNOB_VAL, 0.0f, 10.0f, 0.2f, "%.1f", ImGuiKnobVariant.Space, 50.0f, ImGuiKnobFlags.None, 1);
ImGuiKnobs.knob("Example Wiper Knob", EXAMPLE_WIPER_KNOB_VAL, 0.0f, 10.0f, 0.2f, "%.1f", ImGuiKnobVariant.Wiper, 50.0f, ImGuiKnobFlags.None, 1);
ImGuiKnobs.knob("Example Wiper Dot Knob", EXAMPLE_WIPER_DOT_KNOB_VAL, 0.0f, 10.0f, 0.2f, "%.1f", ImGuiKnobVariant.WiperDot, 50.0f, ImGuiKnobFlags.None, 1);
ImGuiKnobs.knob("Example Wiper Only Knob", EXAMPLE_WIPER_ONLY_KNOB_VAL, 0.0f, 10.0f, 0.2f, "%.1f", ImGuiKnobVariant.WiperOnly, 50.0f, ImGuiKnobFlags.None, 1);
ImGuiKnobs.knob("Example Stepped Knob", EXAMPLE_STEPPED_KNOB_VAL, 0.0f, 10.0f, 0.2f, "%.1f", ImGuiKnobVariant.Stepped, 50.0f, ImGuiKnobFlags.None, 1);
ImGui.endChild();
}
+15 -1
View File
@@ -1,9 +1,9 @@
import org.apache.tools.ant.filters.ReplaceTokens
import tool.generator.GenerateLibs
import tool.generator.api.task.GenerateApi
plugins {
id 'java'
id 'checkstyle'
id 'maven-publish'
id 'signing'
}
@@ -23,6 +23,20 @@ test {
useJUnitPlatform()
}
compileJava {
// By default we do not generate API, since we believe this should be done on purpose.
if (System.getProperty('build.debug.generate.api.enable')) {
dependsOn 'generateApi'
}
}
sourceSets {
main.java.srcDirs = ['src/generated/java']
raw.java.srcDirs = ['src/main/java']
}
tasks.register('generateApi', GenerateApi)
tasks.register('generateLibs', GenerateLibs) {
it.dependsOn assemble
}
@@ -1,81 +0,0 @@
def inputTxt = new File(args[0]).text
def outputFile = new File(args[1])
def jStructName = args[2] as String
outputFile.text = ''
inputTxt = inputTxt
.replace('ImGuiID', 'int')
.replace('bool', 'boolean')
.replace('char*', 'String')
.replace('const char*', 'String')
def regex = ~'(\\w+)\\s+(\\w+)(?:.*?//(.+))?'
inputTxt.eachLine { line ->
def trimmedLine = line.trim()
if (!trimmedLine.contains(';') || trimmedLine.startsWith('#'))
return
def m = regex.matcher(trimmedLine)
def fieldType
def fieldName
def fieldComment
m.find()
fieldType = m.group(1)
fieldName = m.group(2)
fieldComment = m.group(3)?.trim()
def javadoc = null
if (fieldComment) {
javadoc = """ /**
| * $fieldComment
| */""".stripMargin()
}
def classTxt
if (fieldType == 'ImVec2') {
classTxt = """
|${javadoc ? javadoc : ''}
| public native void get${fieldName.capitalize()}(ImVec2 dstImVec2); /*
| Jni::ImVec2Cpy(env, &$jStructName->$fieldName, dstImVec2);
| */
|
|${javadoc ? javadoc : ''}
| public native float get${fieldName.capitalize()}X(); /*
| return $jStructName->${fieldName}.x;
| */
|
|${javadoc ? javadoc : ''}
| public native float get${fieldName.capitalize()}Y(); /*
| return $jStructName->${fieldName}.y;
| */
|
|${javadoc ? javadoc : ''}
| public native void set${fieldName.capitalize()}(float x, float y); /*
| $jStructName->${fieldName}.x = x;
| $jStructName->${fieldName}.y = y;
| */
""".stripMargin()
} else {
classTxt = """
|${javadoc ? javadoc : ''}
| public native $fieldType get${fieldName.capitalize()}(); /*
| return $jStructName->$fieldName;
| */
|
|${javadoc ? javadoc : ''}
| public native void set${fieldName.capitalize()}($fieldType ${fieldName.uncapitalize()}); /*
| $jStructName->$fieldName = ${fieldName.uncapitalize()};
| */
""".stripMargin()
}
outputFile << classTxt
}
@@ -0,0 +1,209 @@
package imgui;
import java.awt.Color;
/**
* Helper class to get ABGR packed color used by Dear ImGui.
*/
public final class ImColor {
private ImColor() {
}
public static int rgba(final int r, final int g, final int b, final int a) {
return intToColor(r, g, b, a);
}
public static int rgb(final int r, final int g, final int b) {
return intToColor(r, g, b);
}
public static int rgba(final float r, final float g, final float b, final float a) {
return floatToColor(r, g, b, a);
}
public static int rgb(final float r, final float g, final float b) {
return floatToColor(r, g, b);
}
/**
* @param hex e.g. "#FFFFFFFF"
*/
public static int rgba(final String hex) {
return rgbaToColor(hex);
}
/**
* @param hex e.g. "#FFFFFF"
*/
public static int rgb(final String hex) {
return rgbToColor(hex);
}
public static int rgba(final ImVec4 color) {
return rgba(color.x, color.y, color.z, color.w);
}
public static int rgb(final ImVec4 color) {
return rgb(color.x, color.y, color.z);
}
public static int rgba(final Color color) {
return rgba(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha());
}
public static int rgb(final Color color) {
return rgb(color.getRed(), color.getGreen(), color.getBlue());
}
public static int hsla(final float h, final float s, final float l, final float a) {
return hslToColor(h, s, l, a);
}
public static int hsl(final float h, final float s, final float l) {
return hslToColor(h, s, l);
}
public static int hsla(final int h, final int s, final int l, final int a) {
return hslToColor(h, s, l, a);
}
public static int hsl(final int h, final int s, final int l) {
return hslToColor(h, s, l);
}
/**
* @deprecated use {@link #rgb(int, int, int)}
*/
@Deprecated
public static int intToColor(final int r, final int g, final int b, final int a) {
return a << 24 | b << 16 | g << 8 | r;
}
/**
* @deprecated use {@link #rgba(int, int, int, int)}
*/
@Deprecated
public static int intToColor(final int r, final int g, final int b) {
return intToColor(r, g, b, 255);
}
/**
* @deprecated use {@link #rgb(float, float, float)}
*/
@Deprecated
public static int floatToColor(final float r, final float g, final float b, final float a) {
return intToColor((int) (r * 255), (int) (g * 255), (int) (b * 255), (int) (a * 255));
}
/**
* @deprecated use {@link #rgba(float, float, float, float)}
*/
@Deprecated
public static int floatToColor(final float r, final float g, final float b) {
return floatToColor(r, g, b, 1f);
}
/**
* @param hex e.g. "#FFFFFF"
* @deprecated use {@link #rgb(String)}
*/
@Deprecated
public static int rgbToColor(final String hex) {
return intToColor(
Integer.parseInt(hex.substring(1, 3), 16),
Integer.parseInt(hex.substring(3, 5), 16),
Integer.parseInt(hex.substring(5, 7), 16)
);
}
/**
* @param hex e.g. "#FFFFFFFF"
* @deprecated use {@link #rgba(String)}
*/
@Deprecated
public static int rgbaToColor(final String hex) {
return intToColor(
Integer.parseInt(hex.substring(1, 3), 16),
Integer.parseInt(hex.substring(3, 5), 16),
Integer.parseInt(hex.substring(5, 7), 16),
Integer.parseInt(hex.substring(7, 9), 16)
);
}
/**
* @deprecated use {@link #hsl(int, int, int)}
*/
@Deprecated
public static int hslToColor(final int h, final int s, final int l) {
return hslToColor(h, s, l, 1);
}
/**
* @deprecated use {@link #hsla(int, int, int, int)}
*/
@Deprecated
public static int hslToColor(final int h, final int s, final int l, final float a) {
return hslToColor(h / 360f, s / 100f, l / 100f, a);
}
/**
* @deprecated use {@link #hsl(float, float, float)}
*/
@Deprecated
public static int hslToColor(final float h, final float s, final float l) {
return hslToColor(h, s, l, 1);
}
/**
* @deprecated use {@link #hsla(float, float, float, float)}
*/
@Deprecated
public static int hslToColor(final float h, final float s, final float l, final float a) {
final float q;
final float p;
final float r;
final float g;
final float b;
// Achromatic
if (s == 0) {
r = l;
g = l;
b = l;
} else {
q = l < 0.5 ? (l * (1 + s)) : (l + s - l * s);
p = 2 * l - q;
r = hue2rgb(p, q, h + 1.0f / 3);
g = hue2rgb(p, q, h);
b = hue2rgb(p, q, h - 1.0f / 3);
}
return floatToColor(r, g, b, a);
}
private static float hue2rgb(final float p, final float q, final float hue) {
float h = hue;
if (h < 0) {
h += 1;
}
if (h > 1) {
h -= 1;
}
if (6 * h < 1) {
return p + ((q - p) * 6 * h);
}
if (2 * h < 1) {
return q;
}
if (3 * h < 2) {
return p + ((q - p) * 6 * ((2.0f / 3.0f) - h));
}
return p;
}
}
@@ -0,0 +1,370 @@
package imgui;
import imgui.binding.ImGuiStruct;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
/**
* All draw data to render Dear ImGui frame
* (NB: the style and the naming convention here is a little inconsistent, we currently preserve them for backward compatibility purpose,
* as this is one of the oldest structure exposed by the library! Basically, ImDrawList == CmdList)
* <p>
* BINDING NOTICE: Since it's impossible to do a 1:1 mapping with JNI, current class provides "getCmdList*()" methods.
* Those are used to get the data needed to do a rendering.
*/
public final class ImDrawData extends ImGuiStruct {
private static final int RESIZE_FACTOR = 5_000;
private static ByteBuffer dataBuffer = ByteBuffer.allocateDirect(25_000).order(ByteOrder.nativeOrder());
public ImDrawData(final long ptr) {
super(ptr);
}
/*JNI
#include "_common.h"
#define THIS ((ImDrawData*)STRUCT_PTR)
*/
///////// Start of Render Methods | Binding
/**
* Draw commands. Typically 1 command = 1 GPU draw call, unless the command is a callback.
*/
public native int getCmdListCmdBufferSize(int cmdListIdx); /*
return THIS->CmdLists[cmdListIdx]->CmdBuffer.Size;
*/
/**
* Number of indices (multiple of 3) to be rendered as triangles.
* Vertices are stored in the callee ImDrawList's vtx_buffer[] array, indices in idx_buffer[].
*/
public native int getCmdListCmdBufferElemCount(int cmdListIdx, int cmdBufferIdx); /*
return THIS->CmdLists[cmdListIdx]->CmdBuffer[cmdBufferIdx].ElemCount;
*/
/**
* Clipping rectangle (x1, y1, x2, y2). Subtract ImDrawData.DisplayPos to get clipping rectangle in "viewport" coordinates
*/
public ImVec4 getCmdListCmdBufferClipRect(final int cmdListIdx, final int cmdBufferIdx) {
final ImVec4 dst = new ImVec4();
getCmdListCmdBufferClipRect(dst, cmdListIdx, cmdBufferIdx);
return dst;
}
/**
* Clipping rectangle (x1, y1, x2, y2). Subtract ImDrawData.DisplayPos to get clipping rectangle in "viewport" coordinates
*/
public native void getCmdListCmdBufferClipRect(ImVec4 dst, int cmdListIdx, int cmdBufferIdx); /*
Jni::ImVec4Cpy(env, &THIS->CmdLists[cmdListIdx]->CmdBuffer[cmdBufferIdx].ClipRect, dst);
*/
/**
* User-provided texture ID. Set by user in ImfontAtlas::SetTexID() for fonts or passed to Image*() functions.
* Ignore if never using images or multiple fonts atlas.
*/
public native int getCmdListCmdBufferTextureId(int cmdListIdx, int cmdBufferIdx); /*
return (intptr_t)THIS->CmdLists[cmdListIdx]->CmdBuffer[cmdBufferIdx].GetTexID();
*/
/**
* Start offset in vertex buffer. Pre-1.71 or without ImGuiBackendFlags_RendererHasVtxOffset: always 0.
* With ImGuiBackendFlags_RendererHasVtxOffset: may be {@code >}0 to support meshes larger than 64K vertices with 16-bit indices.
*/
public native int getCmdListCmdBufferVtxOffset(int cmdListIdx, int cmdBufferIdx); /*
return THIS->CmdLists[cmdListIdx]->CmdBuffer[cmdBufferIdx].VtxOffset;
*/
/**
* Start offset in index buffer. Always equal to sum of ElemCount drawn so far.
*/
public native int getCmdListCmdBufferIdxOffset(int cmdListIdx, int cmdBufferIdx); /*
return THIS->CmdLists[cmdListIdx]->CmdBuffer[cmdBufferIdx].IdxOffset;
*/
/**
* Index buffer. Each command consume ImDrawCmd::ElemCount of those
*/
public native int getCmdListIdxBufferSize(int cmdListIdx); /*
return THIS->CmdLists[cmdListIdx]->IdxBuffer.Size;
*/
public ByteBuffer getCmdListIdxBufferData(final int cmdListIdx) {
final int idxBufferCapacity = getCmdListIdxBufferSize(cmdListIdx) * sizeOfImDrawIdx();
if (dataBuffer.capacity() < idxBufferCapacity) {
dataBuffer.clear();
dataBuffer = ByteBuffer.allocateDirect(idxBufferCapacity + RESIZE_FACTOR).order(ByteOrder.nativeOrder());
}
nGetCmdListIdxBufferData(cmdListIdx, dataBuffer, idxBufferCapacity);
dataBuffer.position(0);
dataBuffer.limit(idxBufferCapacity);
return dataBuffer;
}
private native void nGetCmdListIdxBufferData(int cmdListIdx, ByteBuffer idxBuffer, int idxBufferCapacity); /*
memcpy(idxBuffer, THIS->CmdLists[cmdListIdx]->IdxBuffer.Data, idxBufferCapacity);
*/
/**
* Vertex buffer.
*/
public native int getCmdListVtxBufferSize(int cmdListIdx); /*
return THIS->CmdLists[cmdListIdx]->VtxBuffer.Size;
*/
public ByteBuffer getCmdListVtxBufferData(final int cmdListIdx) {
final int vtxBufferCapacity = getCmdListVtxBufferSize(cmdListIdx) * sizeOfImDrawVert();
if (dataBuffer.capacity() < vtxBufferCapacity) {
dataBuffer.clear();
dataBuffer = ByteBuffer.allocateDirect(vtxBufferCapacity + RESIZE_FACTOR).order(ByteOrder.nativeOrder());
}
nGetCmdListVtxBufferData(cmdListIdx, dataBuffer, vtxBufferCapacity);
dataBuffer.position(0);
dataBuffer.limit(vtxBufferCapacity);
return dataBuffer;
}
private native void nGetCmdListVtxBufferData(int cmdListIdx, ByteBuffer vtxBuffer, int vtxBufferCapacity); /*
memcpy(vtxBuffer, THIS->CmdLists[cmdListIdx]->VtxBuffer.Data, vtxBufferCapacity);
*/
public static native int sizeOfImDrawVert(); /*
return (int)sizeof(ImDrawVert);
*/
public static native int sizeOfImDrawIdx(); /*
return (int)sizeof(ImDrawIdx);
*/
///////// End of Render Methods
/**
* Only valid after Render() is called and before the next NewFrame() is called.
*/
public boolean getValid() {
return nGetValid();
}
private native boolean nGetValid(); /*
return THIS->Valid;
*/
/**
* Number of ImDrawList* to render
*/
public int getCmdListsCount() {
return nGetCmdListsCount();
}
private native int nGetCmdListsCount(); /*
return THIS->CmdListsCount;
*/
/**
* For convenience, sum of all ImDrawList's IdxBuffer.Size
*/
public int getTotalIdxCount() {
return nGetTotalIdxCount();
}
private native int nGetTotalIdxCount(); /*
return THIS->TotalIdxCount;
*/
/**
* For convenience, sum of all ImDrawList's VtxBuffer.Size
*/
public int getTotalVtxCount() {
return nGetTotalVtxCount();
}
private native int nGetTotalVtxCount(); /*
return THIS->TotalVtxCount;
*/
/**
* Upper-left position of the viewport to render (== upper-left of the orthogonal projection matrix to use)
*/
public ImVec2 getDisplayPos() {
final ImVec2 dst = new ImVec2();
nGetDisplayPos(dst);
return dst;
}
/**
* Upper-left position of the viewport to render (== upper-left of the orthogonal projection matrix to use)
*/
public float getDisplayPosX() {
return nGetDisplayPosX();
}
/**
* Upper-left position of the viewport to render (== upper-left of the orthogonal projection matrix to use)
*/
public float getDisplayPosY() {
return nGetDisplayPosY();
}
/**
* Upper-left position of the viewport to render (== upper-left of the orthogonal projection matrix to use)
*/
public void getDisplayPos(final ImVec2 dst) {
nGetDisplayPos(dst);
}
private native void nGetDisplayPos(ImVec2 dst); /*
Jni::ImVec2Cpy(env, THIS->DisplayPos, dst);
*/
private native float nGetDisplayPosX(); /*
return THIS->DisplayPos.x;
*/
private native float nGetDisplayPosY(); /*
return THIS->DisplayPos.y;
*/
/**
* Size of the viewport to render (== io.DisplaySize for the main viewport)
* (DisplayPos + DisplaySize == lower-right of the orthogonal projection matrix to use)
*/
public ImVec2 getDisplaySize() {
final ImVec2 dst = new ImVec2();
nGetDisplaySize(dst);
return dst;
}
/**
* Size of the viewport to render (== io.DisplaySize for the main viewport)
* (DisplayPos + DisplaySize == lower-right of the orthogonal projection matrix to use)
*/
public float getDisplaySizeX() {
return nGetDisplaySizeX();
}
/**
* Size of the viewport to render (== io.DisplaySize for the main viewport)
* (DisplayPos + DisplaySize == lower-right of the orthogonal projection matrix to use)
*/
public float getDisplaySizeY() {
return nGetDisplaySizeY();
}
/**
* Size of the viewport to render (== io.DisplaySize for the main viewport)
* (DisplayPos + DisplaySize == lower-right of the orthogonal projection matrix to use)
*/
public void getDisplaySize(final ImVec2 dst) {
nGetDisplaySize(dst);
}
private native void nGetDisplaySize(ImVec2 dst); /*
Jni::ImVec2Cpy(env, THIS->DisplaySize, dst);
*/
private native float nGetDisplaySizeX(); /*
return THIS->DisplaySize.x;
*/
private native float nGetDisplaySizeY(); /*
return THIS->DisplaySize.y;
*/
/**
* Amount of pixels for each unit of DisplaySize. Based on io.DisplayFramebufferScale. Generally (1,1) on normal display, (2,2) on OSX with Retina display.
*/
public ImVec2 getFramebufferScale() {
final ImVec2 dst = new ImVec2();
nGetFramebufferScale(dst);
return dst;
}
/**
* Amount of pixels for each unit of DisplaySize. Based on io.DisplayFramebufferScale. Generally (1,1) on normal display, (2,2) on OSX with Retina display.
*/
public float getFramebufferScaleX() {
return nGetFramebufferScaleX();
}
/**
* Amount of pixels for each unit of DisplaySize. Based on io.DisplayFramebufferScale. Generally (1,1) on normal display, (2,2) on OSX with Retina display.
*/
public float getFramebufferScaleY() {
return nGetFramebufferScaleY();
}
/**
* Amount of pixels for each unit of DisplaySize. Based on io.DisplayFramebufferScale. Generally (1,1) on normal display, (2,2) on OSX with Retina display.
*/
public void getFramebufferScale(final ImVec2 dst) {
nGetFramebufferScale(dst);
}
private native void nGetFramebufferScale(ImVec2 dst); /*
Jni::ImVec2Cpy(env, THIS->FramebufferScale, dst);
*/
private native float nGetFramebufferScaleX(); /*
return THIS->FramebufferScale.x;
*/
private native float nGetFramebufferScaleY(); /*
return THIS->FramebufferScale.y;
*/
/**
* Viewport carrying the ImDrawData instance, might be of use to the renderer (generally not).
*/
public ImGuiViewport getOwnerViewport() {
return new ImGuiViewport(nGetOwnerViewport());
}
private native long nGetOwnerViewport(); /*
return (intptr_t)THIS->OwnerViewport;
*/
// Functions
/**
* Helper to convert all buffers from indexed to non-indexed, in case you cannot render indexed. Note: this is slow and most likely a waste of resources.
* Always prefer indexed rendering!
*/
public void deIndexAllBuffers() {
nDeIndexAllBuffers();
}
private native void nDeIndexAllBuffers(); /*
THIS->DeIndexAllBuffers();
*/
/**
* Helper to scale the ClipRect field of each ImDrawCmd. Use if your final output buffer is at a different scale than Dear ImGui expects,
* or if there is a difference between your window resolution and framebuffer resolution.
*/
public void scaleClipRects(final ImVec2 fbScale) {
nScaleClipRects(fbScale.x, fbScale.y);
}
/**
* Helper to scale the ClipRect field of each ImDrawCmd. Use if your final output buffer is at a different scale than Dear ImGui expects,
* or if there is a difference between your window resolution and framebuffer resolution.
*/
public void scaleClipRects(final float fbScaleX, final float fbScaleY) {
nScaleClipRects(fbScaleX, fbScaleY);
}
private native void nScaleClipRects(float fbScaleX, float fbScaleY); /*MANUAL
ImVec2 fbScale = ImVec2(fbScaleX, fbScaleY);
THIS->ScaleClipRects(fbScale);
*/
/*JNI
#undef THIS
*/
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,529 @@
package imgui;
import imgui.binding.ImGuiStructDestroyable;
/**
* Font runtime data and rendering
* ImFontAtlas automatically loads a default embedded font for you when you call GetTexDataAsAlpha8() or GetTexDataAsRGBA32().
*/
public final class ImFont extends ImGuiStructDestroyable {
public ImFont() {
}
public ImFont(final long ptr) {
super(ptr);
}
@Override
protected long create() {
return nCreate();
}
/*JNI
#include "_common.h"
#define THIS ((ImFont*)STRUCT_PTR)
*/
private native long nCreate(); /*
return (intptr_t)(new ImFont());
*/
// TODO IndexAdvanceX
/**
* = FallbackGlyph.AdvanceX
*/
public float getFallbackAdvanceX() {
return nGetFallbackAdvanceX();
}
/**
* = FallbackGlyph.AdvanceX
*/
public void setFallbackAdvanceX(final float value) {
nSetFallbackAdvanceX(value);
}
private native float nGetFallbackAdvanceX(); /*
return THIS->FallbackAdvanceX;
*/
private native void nSetFallbackAdvanceX(float value); /*
THIS->FallbackAdvanceX = value;
*/
/**
* Height of characters/line, set during loading (don't change after loading)
*/
public float getFontSize() {
return nGetFontSize();
}
/**
* Height of characters/line, set during loading (don't change after loading)
*/
public void setFontSize(final float value) {
nSetFontSize(value);
}
private native float nGetFontSize(); /*
return THIS->FontSize;
*/
private native void nSetFontSize(float value); /*
THIS->FontSize = value;
*/
// TODO IndexLookup, Glyphs
private static final ImFontGlyph _GETFALLBACKGLYPH_1 = new ImFontGlyph(0);
/**
* = FindGlyph(FontFallbackChar)
*/
public ImFontGlyph getFallbackGlyph() {
_GETFALLBACKGLYPH_1.ptr = nGetFallbackGlyph();
return _GETFALLBACKGLYPH_1;
}
/**
* = FindGlyph(FontFallbackChar)
*/
public void setFallbackGlyph(final ImFontGlyph value) {
nSetFallbackGlyph(value.ptr);
}
private native long nGetFallbackGlyph(); /*
return (intptr_t)THIS->FallbackGlyph;
*/
private native void nSetFallbackGlyph(long value); /*
THIS->FallbackGlyph = reinterpret_cast<ImFontGlyph*>(value);
*/
// TODO ContainerAtlas, ConfigData
/**
* Number of ImFontConfig involved in creating this font.
* Bigger than 1 when merging multiple font sources into one ImFont.
*/
public short getConfigDataCount() {
return nGetConfigDataCount();
}
/**
* Number of ImFontConfig involved in creating this font.
* Bigger than 1 when merging multiple font sources into one ImFont.
*/
public void setConfigDataCount(final short value) {
nSetConfigDataCount(value);
}
private native short nGetConfigDataCount(); /*
return THIS->ConfigDataCount;
*/
private native void nSetConfigDataCount(short value); /*
THIS->ConfigDataCount = value;
*/
/**
* Character used for ellipsis rendering.
*/
public short getEllipsisChar() {
return nGetEllipsisChar();
}
/**
* Character used for ellipsis rendering.
*/
public void setEllipsisChar(final short value) {
nSetEllipsisChar(value);
}
private native short nGetEllipsisChar(); /*
return THIS->EllipsisChar;
*/
private native void nSetEllipsisChar(short value); /*
THIS->EllipsisChar = value;
*/
/**
* Character used for ellipsis rendering (if a single '...' character isn't found)
*/
public short getDotChar() {
return nGetDotChar();
}
/**
* Character used for ellipsis rendering (if a single '...' character isn't found)
*/
public void setDotChar(final short value) {
nSetDotChar(value);
}
private native short nGetDotChar(); /*
return THIS->DotChar;
*/
private native void nSetDotChar(short value); /*
THIS->DotChar = value;
*/
public boolean getDirtyLookupTables() {
return nGetDirtyLookupTables();
}
public void setDirtyLookupTables(final boolean value) {
nSetDirtyLookupTables(value);
}
private native boolean nGetDirtyLookupTables(); /*
return THIS->DirtyLookupTables;
*/
private native void nSetDirtyLookupTables(boolean value); /*
THIS->DirtyLookupTables = value;
*/
/**
* Base font scale, multiplied by the per-window font scale which you can adjust with SetWindowFontScale()
*/
public float getScale() {
return nGetScale();
}
/**
* Base font scale, multiplied by the per-window font scale which you can adjust with SetWindowFontScale()
*/
public void setScale(final float value) {
nSetScale(value);
}
private native float nGetScale(); /*
return THIS->Scale;
*/
private native void nSetScale(float value); /*
THIS->Scale = value;
*/
/**
* Ascent: distance from top to bottom of e.g. 'A' [0..FontSize]
*/
public float getAscent() {
return nGetAscent();
}
/**
* Ascent: distance from top to bottom of e.g. 'A' [0..FontSize]
*/
public void setAscent(final float value) {
nSetAscent(value);
}
private native float nGetAscent(); /*
return THIS->Ascent;
*/
private native void nSetAscent(float value); /*
THIS->Ascent = value;
*/
public float getDescent() {
return nGetDescent();
}
public void setDescent(final float value) {
nSetDescent(value);
}
private native float nGetDescent(); /*
return THIS->Descent;
*/
private native void nSetDescent(float value); /*
THIS->Descent = value;
*/
/**
* Total surface in pixels to get an idea of the font rasterization/texture cost (not exact, we approximate the cost of padding between glyphs)
*/
public int getMetricsTotalSurface() {
return nGetMetricsTotalSurface();
}
/**
* Total surface in pixels to get an idea of the font rasterization/texture cost (not exact, we approximate the cost of padding between glyphs)
*/
public void setMetricsTotalSurface(final int value) {
nSetMetricsTotalSurface(value);
}
private native int nGetMetricsTotalSurface(); /*
return THIS->MetricsTotalSurface;
*/
private native void nSetMetricsTotalSurface(int value); /*
THIS->MetricsTotalSurface = value;
*/
// Methods
public ImFontGlyph findGlyph(final int c) {
return new ImFontGlyph(nFindGlyph(c));
}
private native long nFindGlyph(int c); /*
return (intptr_t)THIS->FindGlyph((ImWchar)c);
*/
public ImFontGlyph findGlyphNoFallback(final int c) {
return new ImFontGlyph(nFindGlyphNoFallback(c));
}
private native long nFindGlyphNoFallback(int c); /*
return (intptr_t)THIS->FindGlyphNoFallback((ImWchar)c);
*/
public float getCharAdvance(final int c) {
return nGetCharAdvance(c);
}
private native float nGetCharAdvance(int c); /*
return THIS->GetCharAdvance((ImWchar)c);
*/
public boolean isLoaded() {
return nIsLoaded();
}
private native boolean nIsLoaded(); /*
return THIS->IsLoaded();
*/
public String getDebugName() {
return nGetDebugName();
}
private native String nGetDebugName(); /*
return env->NewStringUTF(THIS->GetDebugName());
*/
/**
* 'max_width' stops rendering after a certain width (could be turned into a 2d size). FLT_MAX to disable.
* 'wrap_width' enable automatic word-wrapping across multiple lines to fit into given width. 0.0f to disable.
*/
public ImVec2 calcTextSizeA(final float size, final float maxWidth, final float wrapWidth, final String textBegin) {
final ImVec2 dst = new ImVec2();
nCalcTextSizeA(dst, size, maxWidth, wrapWidth, textBegin);
return dst;
}
/**
* 'max_width' stops rendering after a certain width (could be turned into a 2d size). FLT_MAX to disable.
* 'wrap_width' enable automatic word-wrapping across multiple lines to fit into given width. 0.0f to disable.
*/
public float calcTextSizeAX(final float size, final float maxWidth, final float wrapWidth, final String textBegin) {
return nCalcTextSizeAX(size, maxWidth, wrapWidth, textBegin);
}
/**
* 'max_width' stops rendering after a certain width (could be turned into a 2d size). FLT_MAX to disable.
* 'wrap_width' enable automatic word-wrapping across multiple lines to fit into given width. 0.0f to disable.
*/
public float calcTextSizeAY(final float size, final float maxWidth, final float wrapWidth, final String textBegin) {
return nCalcTextSizeAY(size, maxWidth, wrapWidth, textBegin);
}
/**
* 'max_width' stops rendering after a certain width (could be turned into a 2d size). FLT_MAX to disable.
* 'wrap_width' enable automatic word-wrapping across multiple lines to fit into given width. 0.0f to disable.
*/
public void calcTextSizeA(final ImVec2 dst, final float size, final float maxWidth, final float wrapWidth, final String textBegin) {
nCalcTextSizeA(dst, size, maxWidth, wrapWidth, textBegin);
}
/**
* 'max_width' stops rendering after a certain width (could be turned into a 2d size). FLT_MAX to disable.
* 'wrap_width' enable automatic word-wrapping across multiple lines to fit into given width. 0.0f to disable.
*/
public ImVec2 calcTextSizeA(final float size, final float maxWidth, final float wrapWidth, final String textBegin, final String textEnd) {
final ImVec2 dst = new ImVec2();
nCalcTextSizeA(dst, size, maxWidth, wrapWidth, textBegin, textEnd);
return dst;
}
/**
* 'max_width' stops rendering after a certain width (could be turned into a 2d size). FLT_MAX to disable.
* 'wrap_width' enable automatic word-wrapping across multiple lines to fit into given width. 0.0f to disable.
*/
public float calcTextSizeAX(final float size, final float maxWidth, final float wrapWidth, final String textBegin, final String textEnd) {
return nCalcTextSizeAX(size, maxWidth, wrapWidth, textBegin, textEnd);
}
/**
* 'max_width' stops rendering after a certain width (could be turned into a 2d size). FLT_MAX to disable.
* 'wrap_width' enable automatic word-wrapping across multiple lines to fit into given width. 0.0f to disable.
*/
public float calcTextSizeAY(final float size, final float maxWidth, final float wrapWidth, final String textBegin, final String textEnd) {
return nCalcTextSizeAY(size, maxWidth, wrapWidth, textBegin, textEnd);
}
/**
* 'max_width' stops rendering after a certain width (could be turned into a 2d size). FLT_MAX to disable.
* 'wrap_width' enable automatic word-wrapping across multiple lines to fit into given width. 0.0f to disable.
*/
public void calcTextSizeA(final ImVec2 dst, final float size, final float maxWidth, final float wrapWidth, final String textBegin, final String textEnd) {
nCalcTextSizeA(dst, size, maxWidth, wrapWidth, textBegin, textEnd);
}
private native void nCalcTextSizeA(ImVec2 dst, float size, float maxWidth, float wrapWidth, String textBegin); /*MANUAL
auto textBegin = obj_textBegin == NULL ? NULL : (char*)env->GetStringUTFChars(obj_textBegin, JNI_FALSE);
Jni::ImVec2Cpy(env, THIS->CalcTextSizeA(size, maxWidth, wrapWidth, textBegin), dst);
if (textBegin != NULL) env->ReleaseStringUTFChars(obj_textBegin, textBegin);
*/
private native float nCalcTextSizeAX(float size, float maxWidth, float wrapWidth, String obj_textBegin); /*MANUAL
auto textBegin = obj_textBegin == NULL ? NULL : (char*)env->GetStringUTFChars(obj_textBegin, JNI_FALSE);
auto _result = THIS->CalcTextSizeA(size, maxWidth, wrapWidth, textBegin).x;
if (textBegin != NULL) env->ReleaseStringUTFChars(obj_textBegin, textBegin);
return _result;
*/
private native float nCalcTextSizeAY(float size, float maxWidth, float wrapWidth, String obj_textBegin); /*MANUAL
auto textBegin = obj_textBegin == NULL ? NULL : (char*)env->GetStringUTFChars(obj_textBegin, JNI_FALSE);
auto _result = THIS->CalcTextSizeA(size, maxWidth, wrapWidth, textBegin).y;
if (textBegin != NULL) env->ReleaseStringUTFChars(obj_textBegin, textBegin);
return _result;
*/
private native void nCalcTextSizeA(ImVec2 dst, float size, float maxWidth, float wrapWidth, String textBegin, String textEnd); /*MANUAL
auto textBegin = obj_textBegin == NULL ? NULL : (char*)env->GetStringUTFChars(obj_textBegin, JNI_FALSE);
auto textEnd = obj_textEnd == NULL ? NULL : (char*)env->GetStringUTFChars(obj_textEnd, JNI_FALSE);
Jni::ImVec2Cpy(env, THIS->CalcTextSizeA(size, maxWidth, wrapWidth, textBegin, textEnd), dst);
if (textBegin != NULL) env->ReleaseStringUTFChars(obj_textBegin, textBegin);
if (textEnd != NULL) env->ReleaseStringUTFChars(obj_textEnd, textEnd);
*/
private native float nCalcTextSizeAX(float size, float maxWidth, float wrapWidth, String obj_textBegin, String obj_textEnd); /*MANUAL
auto textBegin = obj_textBegin == NULL ? NULL : (char*)env->GetStringUTFChars(obj_textBegin, JNI_FALSE);
auto textEnd = obj_textEnd == NULL ? NULL : (char*)env->GetStringUTFChars(obj_textEnd, JNI_FALSE);
auto _result = THIS->CalcTextSizeA(size, maxWidth, wrapWidth, textBegin, textEnd).x;
if (textBegin != NULL) env->ReleaseStringUTFChars(obj_textBegin, textBegin);
if (textEnd != NULL) env->ReleaseStringUTFChars(obj_textEnd, textEnd);
return _result;
*/
private native float nCalcTextSizeAY(float size, float maxWidth, float wrapWidth, String obj_textBegin, String obj_textEnd); /*MANUAL
auto textBegin = obj_textBegin == NULL ? NULL : (char*)env->GetStringUTFChars(obj_textBegin, JNI_FALSE);
auto textEnd = obj_textEnd == NULL ? NULL : (char*)env->GetStringUTFChars(obj_textEnd, JNI_FALSE);
auto _result = THIS->CalcTextSizeA(size, maxWidth, wrapWidth, textBegin, textEnd).y;
if (textBegin != NULL) env->ReleaseStringUTFChars(obj_textBegin, textBegin);
if (textEnd != NULL) env->ReleaseStringUTFChars(obj_textEnd, textEnd);
return _result;
*/
public String calcWordWrapPositionA(final float scale, final String text, final String textEnd, final float wrapWidth) {
return nCalcWordWrapPositionA(scale, text, textEnd, wrapWidth);
}
private native String nCalcWordWrapPositionA(float scale, String obj_text, String obj_textEnd, float wrapWidth); /*MANUAL
auto text = obj_text == NULL ? NULL : (char*)env->GetStringUTFChars(obj_text, JNI_FALSE);
auto textEnd = obj_textEnd == NULL ? NULL : (char*)env->GetStringUTFChars(obj_textEnd, JNI_FALSE);
auto _result = env->NewStringUTF(THIS->CalcWordWrapPositionA(scale, text, textEnd, wrapWidth));
if (text != NULL) env->ReleaseStringUTFChars(obj_text, text);
if (textEnd != NULL) env->ReleaseStringUTFChars(obj_textEnd, textEnd);
return _result;
*/
public void renderChar(final ImDrawList drawList, final float size, final ImVec2 pos, final int col, final int c) {
nRenderChar(drawList.ptr, size, pos.x, pos.y, col, c);
}
public void renderChar(final ImDrawList drawList, final float size, final float posX, final float posY, final int col, final int c) {
nRenderChar(drawList.ptr, size, posX, posY, col, c);
}
private native void nRenderChar(long drawList, float size, float posX, float posY, int col, int c); /*MANUAL
ImVec2 pos = ImVec2(posX, posY);
THIS->RenderChar(reinterpret_cast<ImDrawList*>(drawList), size, pos, col, (ImWchar)c);
*/
public void renderText(final ImDrawList drawList, final float size, final ImVec2 pos, final int col, final ImVec4 clipRect, final String textBegin, final String textEnd) {
nRenderText(drawList.ptr, size, pos.x, pos.y, col, clipRect.x, clipRect.y, clipRect.z, clipRect.w, textBegin, textEnd);
}
public void renderText(final ImDrawList drawList, final float size, final float posX, final float posY, final int col, final float clipRectX, final float clipRectY, final float clipRectZ, final float clipRectW, final String textBegin, final String textEnd) {
nRenderText(drawList.ptr, size, posX, posY, col, clipRectX, clipRectY, clipRectZ, clipRectW, textBegin, textEnd);
}
public void renderText(final ImDrawList drawList, final float size, final ImVec2 pos, final int col, final ImVec4 clipRect, final String textBegin, final String textEnd, final float wrapWidth) {
nRenderText(drawList.ptr, size, pos.x, pos.y, col, clipRect.x, clipRect.y, clipRect.z, clipRect.w, textBegin, textEnd, wrapWidth);
}
public void renderText(final ImDrawList drawList, final float size, final float posX, final float posY, final int col, final float clipRectX, final float clipRectY, final float clipRectZ, final float clipRectW, final String textBegin, final String textEnd, final float wrapWidth) {
nRenderText(drawList.ptr, size, posX, posY, col, clipRectX, clipRectY, clipRectZ, clipRectW, textBegin, textEnd, wrapWidth);
}
public void renderText(final ImDrawList drawList, final float size, final ImVec2 pos, final int col, final ImVec4 clipRect, final String textBegin, final String textEnd, final float wrapWidth, final boolean cpuFineClip) {
nRenderText(drawList.ptr, size, pos.x, pos.y, col, clipRect.x, clipRect.y, clipRect.z, clipRect.w, textBegin, textEnd, wrapWidth, cpuFineClip);
}
public void renderText(final ImDrawList drawList, final float size, final float posX, final float posY, final int col, final float clipRectX, final float clipRectY, final float clipRectZ, final float clipRectW, final String textBegin, final String textEnd, final float wrapWidth, final boolean cpuFineClip) {
nRenderText(drawList.ptr, size, posX, posY, col, clipRectX, clipRectY, clipRectZ, clipRectW, textBegin, textEnd, wrapWidth, cpuFineClip);
}
public void renderText(final ImDrawList drawList, final float size, final ImVec2 pos, final int col, final ImVec4 clipRect, final String textBegin, final String textEnd, final boolean cpuFineClip) {
nRenderText(drawList.ptr, size, pos.x, pos.y, col, clipRect.x, clipRect.y, clipRect.z, clipRect.w, textBegin, textEnd, cpuFineClip);
}
public void renderText(final ImDrawList drawList, final float size, final float posX, final float posY, final int col, final float clipRectX, final float clipRectY, final float clipRectZ, final float clipRectW, final String textBegin, final String textEnd, final boolean cpuFineClip) {
nRenderText(drawList.ptr, size, posX, posY, col, clipRectX, clipRectY, clipRectZ, clipRectW, textBegin, textEnd, cpuFineClip);
}
private native void nRenderText(long drawList, float size, float posX, float posY, int col, float clipRectX, float clipRectY, float clipRectZ, float clipRectW, String textBegin, String textEnd); /*MANUAL
auto textBegin = obj_textBegin == NULL ? NULL : (char*)env->GetStringUTFChars(obj_textBegin, JNI_FALSE);
auto textEnd = obj_textEnd == NULL ? NULL : (char*)env->GetStringUTFChars(obj_textEnd, JNI_FALSE);
ImVec2 pos = ImVec2(posX, posY);
ImVec4 clipRect = ImVec4(clipRectX, clipRectY, clipRectZ, clipRectW);
THIS->RenderText(reinterpret_cast<ImDrawList*>(drawList), size, pos, col, clipRect, textBegin, textEnd);
if (textBegin != NULL) env->ReleaseStringUTFChars(obj_textBegin, textBegin);
if (textEnd != NULL) env->ReleaseStringUTFChars(obj_textEnd, textEnd);
*/
private native void nRenderText(long drawList, float size, float posX, float posY, int col, float clipRectX, float clipRectY, float clipRectZ, float clipRectW, String textBegin, String textEnd, float wrapWidth); /*MANUAL
auto textBegin = obj_textBegin == NULL ? NULL : (char*)env->GetStringUTFChars(obj_textBegin, JNI_FALSE);
auto textEnd = obj_textEnd == NULL ? NULL : (char*)env->GetStringUTFChars(obj_textEnd, JNI_FALSE);
ImVec2 pos = ImVec2(posX, posY);
ImVec4 clipRect = ImVec4(clipRectX, clipRectY, clipRectZ, clipRectW);
THIS->RenderText(reinterpret_cast<ImDrawList*>(drawList), size, pos, col, clipRect, textBegin, textEnd, wrapWidth);
if (textBegin != NULL) env->ReleaseStringUTFChars(obj_textBegin, textBegin);
if (textEnd != NULL) env->ReleaseStringUTFChars(obj_textEnd, textEnd);
*/
private native void nRenderText(long drawList, float size, float posX, float posY, int col, float clipRectX, float clipRectY, float clipRectZ, float clipRectW, String textBegin, String textEnd, float wrapWidth, boolean cpuFineClip); /*MANUAL
auto textBegin = obj_textBegin == NULL ? NULL : (char*)env->GetStringUTFChars(obj_textBegin, JNI_FALSE);
auto textEnd = obj_textEnd == NULL ? NULL : (char*)env->GetStringUTFChars(obj_textEnd, JNI_FALSE);
ImVec2 pos = ImVec2(posX, posY);
ImVec4 clipRect = ImVec4(clipRectX, clipRectY, clipRectZ, clipRectW);
THIS->RenderText(reinterpret_cast<ImDrawList*>(drawList), size, pos, col, clipRect, textBegin, textEnd, wrapWidth, cpuFineClip);
if (textBegin != NULL) env->ReleaseStringUTFChars(obj_textBegin, textBegin);
if (textEnd != NULL) env->ReleaseStringUTFChars(obj_textEnd, textEnd);
*/
private native void nRenderText(long drawList, float size, float posX, float posY, int col, float clipRectX, float clipRectY, float clipRectZ, float clipRectW, String textBegin, String textEnd, boolean cpuFineClip); /*MANUAL
auto textBegin = obj_textBegin == NULL ? NULL : (char*)env->GetStringUTFChars(obj_textBegin, JNI_FALSE);
auto textEnd = obj_textEnd == NULL ? NULL : (char*)env->GetStringUTFChars(obj_textEnd, JNI_FALSE);
ImVec2 pos = ImVec2(posX, posY);
ImVec4 clipRect = ImVec4(clipRectX, clipRectY, clipRectZ, clipRectW);
THIS->RenderText(reinterpret_cast<ImDrawList*>(drawList), size, pos, col, clipRect, textBegin, textEnd, 0.0f, cpuFineClip);
if (textBegin != NULL) env->ReleaseStringUTFChars(obj_textBegin, textBegin);
if (textEnd != NULL) env->ReleaseStringUTFChars(obj_textEnd, textEnd);
*/
/*JNI
#undef THIS
*/
}
@@ -0,0 +1,812 @@
package imgui;
import imgui.binding.ImGuiStructDestroyable;
import imgui.type.ImInt;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
/**
* Load and rasterize multiple TTF/OTF fonts into a same texture. The font atlas will build a single texture holding:
* - One or more fonts.
* - Custom graphics data needed to render the shapes needed by Dear ImGui.
* - Mouse cursor shapes for software cursor rendering (unless setting 'Flags |= ImFontAtlasFlags_NoMouseCursors' in the font atlas).
* It is the user-code responsibility to setup/build the atlas, then upload the pixel data into a texture accessible by your graphics api.
* - Optionally, call any of the AddFont*** functions. If you don't call any, the default font embedded in the code will be loaded for you.
* - Call GetTexDataAsAlpha8() or GetTexDataAsRGBA32() to build and retrieve pixels data.
* - Upload the pixels data into a texture within your graphics system (see imgui_impl_xxxx.cpp examples)
* - Call SetTexID(my_tex_id); and pass the pointer/identifier to your texture in a format natural to your graphics API.
* This value will be passed back to you during rendering to identify the texture. Read FAQ entry about ImTextureID for more details.
* Common pitfalls:
* - If you pass a 'glyph_ranges' array to AddFont*** functions, you need to make sure that your array persist up until the
* atlas is build (when calling GetTexData*** or Build()). We only copy the pointer, not the data.
* - Important: By default, AddFontFromMemoryTTF() takes ownership of the data. Even though we are not writing to it, we will free the pointer on destruction.
* You can set font_cfg.FontDataOwnedByAtlas=false to keep ownership of your data and it won't be freed,
* - Even though many functions are suffixed with "TTF", OTF data is supported just as well.
* - This is an old API and it is currently awkward for those and and various other reasons! We will address them in the future!
*/
public final class ImFontAtlas extends ImGuiStructDestroyable {
private ByteBuffer alpha8pixels = null;
private ByteBuffer rgba32pixels = null;
public ImFontAtlas() {
}
public ImFontAtlas(final long ptr) {
super(ptr);
}
@Override
protected long create() {
return nCreate();
}
/*JNI
#include "_common.h"
#define THIS ((ImFontAtlas*)STRUCT_PTR)
jmethodID jImFontAtlasCreateAlpha8PixelsMID;
jmethodID jImFontAtlasCreateRgba32PixelsMID;
*/
static native void nInit(); /*
jclass jImFontAtlasClass = env->FindClass("imgui/ImFontAtlas");
jImFontAtlasCreateAlpha8PixelsMID = env->GetMethodID(jImFontAtlasClass, "createAlpha8Pixels", "(I)Ljava/nio/ByteBuffer;");
jImFontAtlasCreateRgba32PixelsMID = env->GetMethodID(jImFontAtlasClass, "createRgba32Pixels", "(I)Ljava/nio/ByteBuffer;");
*/
private native long nCreate(); /*
return (intptr_t)(new ImFontConfig());
*/
public ImFont addFont(final ImFontConfig imFontConfig) {
return new ImFont(nAddFont(imFontConfig.ptr));
}
private native long nAddFont(long imFontConfig); /*
return (intptr_t)THIS->AddFont(reinterpret_cast<ImFontConfig*>(imFontConfig));
*/
public ImFont addFontDefault() {
return new ImFont(nAddFontDefault());
}
public ImFont addFontDefault(final ImFontConfig imFontConfig) {
return new ImFont(nAddFontDefault(imFontConfig.ptr));
}
private native long nAddFontDefault(); /*
return (intptr_t)THIS->AddFontDefault();
*/
private native long nAddFontDefault(long imFontConfig); /*
return (intptr_t)THIS->AddFontDefault(reinterpret_cast<ImFontConfig*>(imFontConfig));
*/
public ImFont addFontFromFileTTF(final String filename, final float sizePixels) {
return new ImFont(nAddFontFromFileTTF(filename, sizePixels));
}
public ImFont addFontFromFileTTF(final String filename, final float sizePixels, final ImFontConfig fontConfig) {
return new ImFont(nAddFontFromFileTTF(filename, sizePixels, fontConfig.ptr));
}
public ImFont addFontFromFileTTF(final String filename, final float sizePixels, final ImFontConfig fontConfig, final short[] glyphRanges) {
return new ImFont(nAddFontFromFileTTF(filename, sizePixels, fontConfig.ptr, glyphRanges));
}
public ImFont addFontFromFileTTF(final String filename, final float sizePixels, final short[] glyphRanges) {
return new ImFont(nAddFontFromFileTTF(filename, sizePixels, glyphRanges));
}
private native long nAddFontFromFileTTF(String obj_filename, float sizePixels); /*MANUAL
auto filename = obj_filename == NULL ? NULL : (char*)env->GetStringUTFChars(obj_filename, JNI_FALSE);
auto _result = (intptr_t)THIS->AddFontFromFileTTF(filename, sizePixels);
if (filename != NULL) env->ReleaseStringUTFChars(obj_filename, filename);
return _result;
*/
private native long nAddFontFromFileTTF(String obj_filename, float sizePixels, long fontConfig); /*MANUAL
auto filename = obj_filename == NULL ? NULL : (char*)env->GetStringUTFChars(obj_filename, JNI_FALSE);
auto _result = (intptr_t)THIS->AddFontFromFileTTF(filename, sizePixels, reinterpret_cast<ImFontConfig*>(fontConfig));
if (filename != NULL) env->ReleaseStringUTFChars(obj_filename, filename);
return _result;
*/
private native long nAddFontFromFileTTF(String obj_filename, float sizePixels, long fontConfig, short[] obj_glyphRanges); /*MANUAL
auto filename = obj_filename == NULL ? NULL : (char*)env->GetStringUTFChars(obj_filename, JNI_FALSE);
auto glyphRanges = obj_glyphRanges == NULL ? NULL : (short*)env->GetPrimitiveArrayCritical(obj_glyphRanges, JNI_FALSE);
auto _result = (intptr_t)THIS->AddFontFromFileTTF(filename, sizePixels, reinterpret_cast<ImFontConfig*>(fontConfig), (ImWchar*)&glyphRanges[0]);
if (filename != NULL) env->ReleaseStringUTFChars(obj_filename, filename);
if (glyphRanges != NULL) env->ReleasePrimitiveArrayCritical(obj_glyphRanges, glyphRanges, JNI_FALSE);
return _result;
*/
private native long nAddFontFromFileTTF(String obj_filename, float sizePixels, short[] obj_glyphRanges); /*MANUAL
auto filename = obj_filename == NULL ? NULL : (char*)env->GetStringUTFChars(obj_filename, JNI_FALSE);
auto glyphRanges = obj_glyphRanges == NULL ? NULL : (short*)env->GetPrimitiveArrayCritical(obj_glyphRanges, JNI_FALSE);
auto _result = (intptr_t)THIS->AddFontFromFileTTF(filename, sizePixels, NULL, (ImWchar*)&glyphRanges[0]);
if (filename != NULL) env->ReleaseStringUTFChars(obj_filename, filename);
if (glyphRanges != NULL) env->ReleasePrimitiveArrayCritical(obj_glyphRanges, glyphRanges, JNI_FALSE);
return _result;
*/
/**
* Note: Transfer ownership of 'ttf_data' to ImFontAtlas! Will be deleted after destruction of the atlas.
* Set font_cfg.FontDataOwnedByAtlas=false to keep ownership of your data and it won't be freed.
*/
public ImFont addFontFromMemoryTTF(final byte[] fontData, final float sizePixels) {
return new ImFont(nAddFontFromMemoryTTF(fontData, sizePixels));
}
/**
* Note: Transfer ownership of 'ttf_data' to ImFontAtlas! Will be deleted after destruction of the atlas.
* Set font_cfg.FontDataOwnedByAtlas=false to keep ownership of your data and it won't be freed.
*/
public ImFont addFontFromMemoryTTF(final byte[] fontData, final float sizePixels, final ImFontConfig fontConfig) {
return new ImFont(nAddFontFromMemoryTTF(fontData, sizePixels, fontConfig.ptr));
}
/**
* Note: Transfer ownership of 'ttf_data' to ImFontAtlas! Will be deleted after destruction of the atlas.
* Set font_cfg.FontDataOwnedByAtlas=false to keep ownership of your data and it won't be freed.
*/
public ImFont addFontFromMemoryTTF(final byte[] fontData, final float sizePixels, final ImFontConfig fontConfig, final short[] glyphRanges) {
return new ImFont(nAddFontFromMemoryTTF(fontData, sizePixels, fontConfig.ptr, glyphRanges));
}
/**
* Note: Transfer ownership of 'ttf_data' to ImFontAtlas! Will be deleted after destruction of the atlas.
* Set font_cfg.FontDataOwnedByAtlas=false to keep ownership of your data and it won't be freed.
*/
public ImFont addFontFromMemoryTTF(final byte[] fontData, final float sizePixels, final short[] glyphRanges) {
return new ImFont(nAddFontFromMemoryTTF(fontData, sizePixels, glyphRanges));
}
private native long nAddFontFromMemoryTTF(byte[] obj_fontData, float sizePixels); /*MANUAL
auto fontData = obj_fontData == NULL ? NULL : (char*)env->GetPrimitiveArrayCritical(obj_fontData, JNI_FALSE);
auto _result = (intptr_t)THIS->AddFontFromMemoryTTF(&fontData[0], (int)env->GetArrayLength(obj_fontData), sizePixels);
if (fontData != NULL) env->ReleasePrimitiveArrayCritical(obj_fontData, fontData, JNI_FALSE);
return _result;
*/
private native long nAddFontFromMemoryTTF(byte[] obj_fontData, float sizePixels, long fontConfig); /*MANUAL
auto fontData = obj_fontData == NULL ? NULL : (char*)env->GetPrimitiveArrayCritical(obj_fontData, JNI_FALSE);
auto _result = (intptr_t)THIS->AddFontFromMemoryTTF(&fontData[0], (int)env->GetArrayLength(obj_fontData), sizePixels, reinterpret_cast<ImFontConfig*>(fontConfig));
if (fontData != NULL) env->ReleasePrimitiveArrayCritical(obj_fontData, fontData, JNI_FALSE);
return _result;
*/
private native long nAddFontFromMemoryTTF(byte[] obj_fontData, float sizePixels, long fontConfig, short[] obj_glyphRanges); /*MANUAL
auto fontData = obj_fontData == NULL ? NULL : (char*)env->GetPrimitiveArrayCritical(obj_fontData, JNI_FALSE);
auto glyphRanges = obj_glyphRanges == NULL ? NULL : (short*)env->GetPrimitiveArrayCritical(obj_glyphRanges, JNI_FALSE);
auto _result = (intptr_t)THIS->AddFontFromMemoryTTF(&fontData[0], (int)env->GetArrayLength(obj_fontData), sizePixels, reinterpret_cast<ImFontConfig*>(fontConfig), (ImWchar*)&glyphRanges[0]);
if (fontData != NULL) env->ReleasePrimitiveArrayCritical(obj_fontData, fontData, JNI_FALSE);
if (glyphRanges != NULL) env->ReleasePrimitiveArrayCritical(obj_glyphRanges, glyphRanges, JNI_FALSE);
return _result;
*/
private native long nAddFontFromMemoryTTF(byte[] obj_fontData, float sizePixels, short[] obj_glyphRanges); /*MANUAL
auto fontData = obj_fontData == NULL ? NULL : (char*)env->GetPrimitiveArrayCritical(obj_fontData, JNI_FALSE);
auto glyphRanges = obj_glyphRanges == NULL ? NULL : (short*)env->GetPrimitiveArrayCritical(obj_glyphRanges, JNI_FALSE);
auto _result = (intptr_t)THIS->AddFontFromMemoryTTF(&fontData[0], (int)env->GetArrayLength(obj_fontData), sizePixels, NULL, (ImWchar*)&glyphRanges[0]);
if (fontData != NULL) env->ReleasePrimitiveArrayCritical(obj_fontData, fontData, JNI_FALSE);
if (glyphRanges != NULL) env->ReleasePrimitiveArrayCritical(obj_glyphRanges, glyphRanges, JNI_FALSE);
return _result;
*/
/**
* Note: Transfer ownership of 'ttf_data' to ImFontAtlas! Will be deleted after destruction of the atlas.
* Set font_cfg.FontDataOwnedByAtlas=false to keep ownership of your data and it won't be freed.
*/
public ImFont addFontFromMemoryTTF(final byte[] fontData, final int fontSize, final float sizePixels) {
return new ImFont(nAddFontFromMemoryTTF(fontData, fontSize, sizePixels));
}
/**
* Note: Transfer ownership of 'ttf_data' to ImFontAtlas! Will be deleted after destruction of the atlas.
* Set font_cfg.FontDataOwnedByAtlas=false to keep ownership of your data and it won't be freed.
*/
public ImFont addFontFromMemoryTTF(final byte[] fontData, final int fontSize, final float sizePixels, final ImFontConfig fontConfig) {
return new ImFont(nAddFontFromMemoryTTF(fontData, fontSize, sizePixels, fontConfig.ptr));
}
/**
* Note: Transfer ownership of 'ttf_data' to ImFontAtlas! Will be deleted after destruction of the atlas.
* Set font_cfg.FontDataOwnedByAtlas=false to keep ownership of your data and it won't be freed.
*/
public ImFont addFontFromMemoryTTF(final byte[] fontData, final int fontSize, final float sizePixels, final ImFontConfig fontConfig, final short[] glyphRanges) {
return new ImFont(nAddFontFromMemoryTTF(fontData, fontSize, sizePixels, fontConfig.ptr, glyphRanges));
}
/**
* Note: Transfer ownership of 'ttf_data' to ImFontAtlas! Will be deleted after destruction of the atlas.
* Set font_cfg.FontDataOwnedByAtlas=false to keep ownership of your data and it won't be freed.
*/
public ImFont addFontFromMemoryTTF(final byte[] fontData, final int fontSize, final float sizePixels, final short[] glyphRanges) {
return new ImFont(nAddFontFromMemoryTTF(fontData, fontSize, sizePixels, glyphRanges));
}
private native long nAddFontFromMemoryTTF(byte[] obj_fontData, int fontSize, float sizePixels); /*MANUAL
auto fontData = obj_fontData == NULL ? NULL : (char*)env->GetPrimitiveArrayCritical(obj_fontData, JNI_FALSE);
auto _result = (intptr_t)THIS->AddFontFromMemoryTTF(&fontData[0], fontSize, sizePixels);
if (fontData != NULL) env->ReleasePrimitiveArrayCritical(obj_fontData, fontData, JNI_FALSE);
return _result;
*/
private native long nAddFontFromMemoryTTF(byte[] obj_fontData, int fontSize, float sizePixels, long fontConfig); /*MANUAL
auto fontData = obj_fontData == NULL ? NULL : (char*)env->GetPrimitiveArrayCritical(obj_fontData, JNI_FALSE);
auto _result = (intptr_t)THIS->AddFontFromMemoryTTF(&fontData[0], fontSize, sizePixels, reinterpret_cast<ImFontConfig*>(fontConfig));
if (fontData != NULL) env->ReleasePrimitiveArrayCritical(obj_fontData, fontData, JNI_FALSE);
return _result;
*/
private native long nAddFontFromMemoryTTF(byte[] obj_fontData, int fontSize, float sizePixels, long fontConfig, short[] obj_glyphRanges); /*MANUAL
auto fontData = obj_fontData == NULL ? NULL : (char*)env->GetPrimitiveArrayCritical(obj_fontData, JNI_FALSE);
auto glyphRanges = obj_glyphRanges == NULL ? NULL : (short*)env->GetPrimitiveArrayCritical(obj_glyphRanges, JNI_FALSE);
auto _result = (intptr_t)THIS->AddFontFromMemoryTTF(&fontData[0], fontSize, sizePixels, reinterpret_cast<ImFontConfig*>(fontConfig), (ImWchar*)&glyphRanges[0]);
if (fontData != NULL) env->ReleasePrimitiveArrayCritical(obj_fontData, fontData, JNI_FALSE);
if (glyphRanges != NULL) env->ReleasePrimitiveArrayCritical(obj_glyphRanges, glyphRanges, JNI_FALSE);
return _result;
*/
private native long nAddFontFromMemoryTTF(byte[] obj_fontData, int fontSize, float sizePixels, short[] obj_glyphRanges); /*MANUAL
auto fontData = obj_fontData == NULL ? NULL : (char*)env->GetPrimitiveArrayCritical(obj_fontData, JNI_FALSE);
auto glyphRanges = obj_glyphRanges == NULL ? NULL : (short*)env->GetPrimitiveArrayCritical(obj_glyphRanges, JNI_FALSE);
auto _result = (intptr_t)THIS->AddFontFromMemoryTTF(&fontData[0], fontSize, sizePixels, NULL, (ImWchar*)&glyphRanges[0]);
if (fontData != NULL) env->ReleasePrimitiveArrayCritical(obj_fontData, fontData, JNI_FALSE);
if (glyphRanges != NULL) env->ReleasePrimitiveArrayCritical(obj_glyphRanges, glyphRanges, JNI_FALSE);
return _result;
*/
/**
* 'compressed_font_data' still owned by caller. Compress with binary_to_compressed_c.cpp.
*/
public ImFont addFontFromMemoryCompressedTTF(final byte[] compressedFontData, final float sizePixels) {
return new ImFont(nAddFontFromMemoryCompressedTTF(compressedFontData, sizePixels));
}
/**
* 'compressed_font_data' still owned by caller. Compress with binary_to_compressed_c.cpp.
*/
public ImFont addFontFromMemoryCompressedTTF(final byte[] compressedFontData, final float sizePixels, final ImFontConfig imFontConfig) {
return new ImFont(nAddFontFromMemoryCompressedTTF(compressedFontData, sizePixels, imFontConfig.ptr));
}
/**
* 'compressed_font_data' still owned by caller. Compress with binary_to_compressed_c.cpp.
*/
public ImFont addFontFromMemoryCompressedTTF(final byte[] compressedFontData, final float sizePixels, final ImFontConfig imFontConfig, final short[] glyphRanges) {
return new ImFont(nAddFontFromMemoryCompressedTTF(compressedFontData, sizePixels, imFontConfig.ptr, glyphRanges));
}
/**
* 'compressed_font_data' still owned by caller. Compress with binary_to_compressed_c.cpp.
*/
public ImFont addFontFromMemoryCompressedTTF(final byte[] compressedFontData, final float sizePixels, final short[] glyphRanges) {
return new ImFont(nAddFontFromMemoryCompressedTTF(compressedFontData, sizePixels, glyphRanges));
}
private native long nAddFontFromMemoryCompressedTTF(byte[] obj_compressedFontData, float sizePixels); /*MANUAL
auto compressedFontData = obj_compressedFontData == NULL ? NULL : (char*)env->GetPrimitiveArrayCritical(obj_compressedFontData, JNI_FALSE);
auto _result = (intptr_t)THIS->AddFontFromMemoryCompressedTTF(&compressedFontData[0], (int)env->GetArrayLength(obj_compressedFontData), sizePixels);
if (compressedFontData != NULL) env->ReleasePrimitiveArrayCritical(obj_compressedFontData, compressedFontData, JNI_FALSE);
return _result;
*/
private native long nAddFontFromMemoryCompressedTTF(byte[] obj_compressedFontData, float sizePixels, long imFontConfig); /*MANUAL
auto compressedFontData = obj_compressedFontData == NULL ? NULL : (char*)env->GetPrimitiveArrayCritical(obj_compressedFontData, JNI_FALSE);
auto _result = (intptr_t)THIS->AddFontFromMemoryCompressedTTF(&compressedFontData[0], (int)env->GetArrayLength(obj_compressedFontData), sizePixels, reinterpret_cast<ImFontConfig*>(imFontConfig));
if (compressedFontData != NULL) env->ReleasePrimitiveArrayCritical(obj_compressedFontData, compressedFontData, JNI_FALSE);
return _result;
*/
private native long nAddFontFromMemoryCompressedTTF(byte[] obj_compressedFontData, float sizePixels, long imFontConfig, short[] obj_glyphRanges); /*MANUAL
auto compressedFontData = obj_compressedFontData == NULL ? NULL : (char*)env->GetPrimitiveArrayCritical(obj_compressedFontData, JNI_FALSE);
auto glyphRanges = obj_glyphRanges == NULL ? NULL : (short*)env->GetPrimitiveArrayCritical(obj_glyphRanges, JNI_FALSE);
auto _result = (intptr_t)THIS->AddFontFromMemoryCompressedTTF(&compressedFontData[0], (int)env->GetArrayLength(obj_compressedFontData), sizePixels, reinterpret_cast<ImFontConfig*>(imFontConfig), (ImWchar*)&glyphRanges[0]);
if (compressedFontData != NULL) env->ReleasePrimitiveArrayCritical(obj_compressedFontData, compressedFontData, JNI_FALSE);
if (glyphRanges != NULL) env->ReleasePrimitiveArrayCritical(obj_glyphRanges, glyphRanges, JNI_FALSE);
return _result;
*/
private native long nAddFontFromMemoryCompressedTTF(byte[] obj_compressedFontData, float sizePixels, short[] obj_glyphRanges); /*MANUAL
auto compressedFontData = obj_compressedFontData == NULL ? NULL : (char*)env->GetPrimitiveArrayCritical(obj_compressedFontData, JNI_FALSE);
auto glyphRanges = obj_glyphRanges == NULL ? NULL : (short*)env->GetPrimitiveArrayCritical(obj_glyphRanges, JNI_FALSE);
auto _result = (intptr_t)THIS->AddFontFromMemoryCompressedTTF(&compressedFontData[0], (int)env->GetArrayLength(obj_compressedFontData), sizePixels, NULL, (ImWchar*)&glyphRanges[0]);
if (compressedFontData != NULL) env->ReleasePrimitiveArrayCritical(obj_compressedFontData, compressedFontData, JNI_FALSE);
if (glyphRanges != NULL) env->ReleasePrimitiveArrayCritical(obj_glyphRanges, glyphRanges, JNI_FALSE);
return _result;
*/
/**
* 'compressed_font_data' still owned by caller. Compress with binary_to_compressed_c.cpp.
*/
public ImFont addFontFromMemoryCompressedTTF(final byte[] compressedFontData, final int compressedFontSize, final float sizePixels) {
return new ImFont(nAddFontFromMemoryCompressedTTF(compressedFontData, compressedFontSize, sizePixels));
}
/**
* 'compressed_font_data' still owned by caller. Compress with binary_to_compressed_c.cpp.
*/
public ImFont addFontFromMemoryCompressedTTF(final byte[] compressedFontData, final int compressedFontSize, final float sizePixels, final ImFontConfig imFontConfig) {
return new ImFont(nAddFontFromMemoryCompressedTTF(compressedFontData, compressedFontSize, sizePixels, imFontConfig.ptr));
}
/**
* 'compressed_font_data' still owned by caller. Compress with binary_to_compressed_c.cpp.
*/
public ImFont addFontFromMemoryCompressedTTF(final byte[] compressedFontData, final int compressedFontSize, final float sizePixels, final ImFontConfig imFontConfig, final short[] glyphRanges) {
return new ImFont(nAddFontFromMemoryCompressedTTF(compressedFontData, compressedFontSize, sizePixels, imFontConfig.ptr, glyphRanges));
}
/**
* 'compressed_font_data' still owned by caller. Compress with binary_to_compressed_c.cpp.
*/
public ImFont addFontFromMemoryCompressedTTF(final byte[] compressedFontData, final int compressedFontSize, final float sizePixels, final short[] glyphRanges) {
return new ImFont(nAddFontFromMemoryCompressedTTF(compressedFontData, compressedFontSize, sizePixels, glyphRanges));
}
private native long nAddFontFromMemoryCompressedTTF(byte[] obj_compressedFontData, int compressedFontSize, float sizePixels); /*MANUAL
auto compressedFontData = obj_compressedFontData == NULL ? NULL : (char*)env->GetPrimitiveArrayCritical(obj_compressedFontData, JNI_FALSE);
auto _result = (intptr_t)THIS->AddFontFromMemoryCompressedTTF(&compressedFontData[0], compressedFontSize, sizePixels);
if (compressedFontData != NULL) env->ReleasePrimitiveArrayCritical(obj_compressedFontData, compressedFontData, JNI_FALSE);
return _result;
*/
private native long nAddFontFromMemoryCompressedTTF(byte[] obj_compressedFontData, int compressedFontSize, float sizePixels, long imFontConfig); /*MANUAL
auto compressedFontData = obj_compressedFontData == NULL ? NULL : (char*)env->GetPrimitiveArrayCritical(obj_compressedFontData, JNI_FALSE);
auto _result = (intptr_t)THIS->AddFontFromMemoryCompressedTTF(&compressedFontData[0], compressedFontSize, sizePixels, reinterpret_cast<ImFontConfig*>(imFontConfig));
if (compressedFontData != NULL) env->ReleasePrimitiveArrayCritical(obj_compressedFontData, compressedFontData, JNI_FALSE);
return _result;
*/
private native long nAddFontFromMemoryCompressedTTF(byte[] obj_compressedFontData, int compressedFontSize, float sizePixels, long imFontConfig, short[] obj_glyphRanges); /*MANUAL
auto compressedFontData = obj_compressedFontData == NULL ? NULL : (char*)env->GetPrimitiveArrayCritical(obj_compressedFontData, JNI_FALSE);
auto glyphRanges = obj_glyphRanges == NULL ? NULL : (short*)env->GetPrimitiveArrayCritical(obj_glyphRanges, JNI_FALSE);
auto _result = (intptr_t)THIS->AddFontFromMemoryCompressedTTF(&compressedFontData[0], compressedFontSize, sizePixels, reinterpret_cast<ImFontConfig*>(imFontConfig), (ImWchar*)&glyphRanges[0]);
if (compressedFontData != NULL) env->ReleasePrimitiveArrayCritical(obj_compressedFontData, compressedFontData, JNI_FALSE);
if (glyphRanges != NULL) env->ReleasePrimitiveArrayCritical(obj_glyphRanges, glyphRanges, JNI_FALSE);
return _result;
*/
private native long nAddFontFromMemoryCompressedTTF(byte[] obj_compressedFontData, int compressedFontSize, float sizePixels, short[] obj_glyphRanges); /*MANUAL
auto compressedFontData = obj_compressedFontData == NULL ? NULL : (char*)env->GetPrimitiveArrayCritical(obj_compressedFontData, JNI_FALSE);
auto glyphRanges = obj_glyphRanges == NULL ? NULL : (short*)env->GetPrimitiveArrayCritical(obj_glyphRanges, JNI_FALSE);
auto _result = (intptr_t)THIS->AddFontFromMemoryCompressedTTF(&compressedFontData[0], compressedFontSize, sizePixels, NULL, (ImWchar*)&glyphRanges[0]);
if (compressedFontData != NULL) env->ReleasePrimitiveArrayCritical(obj_compressedFontData, compressedFontData, JNI_FALSE);
if (glyphRanges != NULL) env->ReleasePrimitiveArrayCritical(obj_glyphRanges, glyphRanges, JNI_FALSE);
return _result;
*/
/**
* 'compressed_font_data_base85' still owned by caller. Compress with binary_to_compressed_c.cpp with -base85 parameter.
*/
public ImFont addFontFromMemoryCompressedBase85TTF(final String compressedFontDataBase85, final float sizePixels, final ImFontConfig fontConfig) {
return new ImFont(nAddFontFromMemoryCompressedBase85TTF(compressedFontDataBase85, sizePixels, fontConfig.ptr));
}
/**
* 'compressed_font_data_base85' still owned by caller. Compress with binary_to_compressed_c.cpp with -base85 parameter.
*/
public ImFont addFontFromMemoryCompressedBase85TTF(final String compressedFontDataBase85, final float sizePixels, final ImFontConfig fontConfig, final short[] glyphRanges) {
return new ImFont(nAddFontFromMemoryCompressedBase85TTF(compressedFontDataBase85, sizePixels, fontConfig.ptr, glyphRanges));
}
private native long nAddFontFromMemoryCompressedBase85TTF(String obj_compressedFontDataBase85, float sizePixels, long fontConfig); /*MANUAL
auto compressedFontDataBase85 = obj_compressedFontDataBase85 == NULL ? NULL : (char*)env->GetStringUTFChars(obj_compressedFontDataBase85, JNI_FALSE);
auto _result = (intptr_t)THIS->AddFontFromMemoryCompressedBase85TTF(compressedFontDataBase85, sizePixels, reinterpret_cast<ImFontConfig*>(fontConfig));
if (compressedFontDataBase85 != NULL) env->ReleaseStringUTFChars(obj_compressedFontDataBase85, compressedFontDataBase85);
return _result;
*/
private native long nAddFontFromMemoryCompressedBase85TTF(String obj_compressedFontDataBase85, float sizePixels, long fontConfig, short[] obj_glyphRanges); /*MANUAL
auto compressedFontDataBase85 = obj_compressedFontDataBase85 == NULL ? NULL : (char*)env->GetStringUTFChars(obj_compressedFontDataBase85, JNI_FALSE);
auto glyphRanges = obj_glyphRanges == NULL ? NULL : (short*)env->GetPrimitiveArrayCritical(obj_glyphRanges, JNI_FALSE);
auto _result = (intptr_t)THIS->AddFontFromMemoryCompressedBase85TTF(compressedFontDataBase85, sizePixels, reinterpret_cast<ImFontConfig*>(fontConfig), (ImWchar*)&glyphRanges[0]);
if (compressedFontDataBase85 != NULL) env->ReleaseStringUTFChars(obj_compressedFontDataBase85, compressedFontDataBase85);
if (glyphRanges != NULL) env->ReleasePrimitiveArrayCritical(obj_glyphRanges, glyphRanges, JNI_FALSE);
return _result;
*/
/**
* Clear input data (all ImFontConfig structures including sizes, TTF data, glyph ranges, etc.) = all the data used to build the texture and fonts.
*/
public void clearInputData() {
nClearInputData();
}
private native void nClearInputData(); /*
THIS->ClearInputData();
*/
/**
* Clear output texture data (CPU side). Saves RAM once the texture has been copied to graphics memory.
*/
public void clearTexData() {
nClearTexData();
}
private native void nClearTexData(); /*
THIS->ClearTexData();
*/
/**
* Clear output font data (glyphs storage, UV coordinates).
*/
public void clearFonts() {
nClearFonts();
}
private native void nClearFonts(); /*
THIS->ClearFonts();
*/
/**
* Clear all input and output.
*/
public void clear() {
nClear();
}
private native void nClear(); /*
THIS->Clear();
*/
// Build atlas, retrieve pixel data.
// User is in charge of copying the pixels into graphics memory (e.g. create a texture with your engine). Then store your texture handle with SetTexID().
// The pitch is always = Width * BytesPerPixels (1 or 4)
// Building in RGBA32 format is provided for convenience and compatibility, but note that unless you manually manipulate or copy color data into
// the texture (e.g. when using the AddCustomRect*** api), then the RGB pixels emitted will always be white (~75% of memory/bandwidth waste.
/**
* Build pixels data. This is called automatically for you by the GetTexData*** functions.
*/
public boolean build() {
return nBuild();
}
private native boolean nBuild(); /*
return THIS->Build();
*/
/**
* 1 byte-per-pixel
*/
public ByteBuffer getTexDataAsAlpha8(final ImInt outWidth, final ImInt outHeight) {
return getTexDataAsAlpha8(outWidth, outHeight, new ImInt());
}
/**
* 1 byte-per-pixel
*/
public ByteBuffer getTexDataAsAlpha8(final ImInt outWidth, final ImInt outHeight, final ImInt outBytesPerPixel) {
getTexDataAsAlpha8(outWidth.getData(), outHeight.getData(), outBytesPerPixel.getData());
return alpha8pixels;
}
private ByteBuffer createAlpha8Pixels(final int size) {
if (alpha8pixels == null || alpha8pixels.limit() != size) {
alpha8pixels = ByteBuffer.allocateDirect(size).order(ByteOrder.nativeOrder());
} else {
alpha8pixels.clear();
}
return alpha8pixels;
}
private native void getTexDataAsAlpha8(int[] outWidth, int[] outHeight, int[] outBytesPerPixel); /*
unsigned char* pixels;
THIS->GetTexDataAsAlpha8(&pixels, &outWidth[0], &outHeight[0], &outBytesPerPixel[0]);
int size = outWidth[0] * outHeight[0] * outBytesPerPixel[0];
jobject jBuffer = env->CallObjectMethod(object, jImFontAtlasCreateAlpha8PixelsMID, size);
char* buffer = (char*)env->GetDirectBufferAddress(jBuffer);
memcpy(buffer, pixels, size);
*/
/**
* 4 bytes-per-pixel
*/
public ByteBuffer getTexDataAsRGBA32(final ImInt outWidth, final ImInt outHeight) {
return getTexDataAsRGBA32(outWidth, outHeight, new ImInt());
}
/**
* 4 bytes-per-pixel
*/
public ByteBuffer getTexDataAsRGBA32(final ImInt outWidth, final ImInt outHeight, final ImInt outBytesPerPixel) {
nGetTexDataAsRGBA32(outWidth.getData(), outHeight.getData(), outBytesPerPixel.getData());
return rgba32pixels;
}
private ByteBuffer createRgba32Pixels(final int size) {
if (rgba32pixels == null || rgba32pixels.limit() != size) {
rgba32pixels = ByteBuffer.allocateDirect(size).order(ByteOrder.nativeOrder());
} else {
rgba32pixels.clear();
}
return rgba32pixels;
}
private native void nGetTexDataAsRGBA32(int[] outWidth, int[] outHeight, int[] outBytesPerPixel); /*
unsigned char* pixels;
THIS->GetTexDataAsRGBA32(&pixels, &outWidth[0], &outHeight[0], &outBytesPerPixel[0]);
int size = outWidth[0] * outHeight[0] * outBytesPerPixel[0];
jobject jBuffer = env->CallObjectMethod(object, jImFontAtlasCreateRgba32PixelsMID, size);
char* buffer = (char*)env->GetDirectBufferAddress(jBuffer);
memcpy(buffer, pixels, size);
*/
public boolean isBuilt() {
return nIsBuilt();
}
private native boolean nIsBuilt(); /*
return THIS->IsBuilt();
*/
/**
* User data to refer to the texture once it has been uploaded to user's graphic systems.
* It is passed back to you during rendering via the ImDrawCmd structure.
*/
public void setTexID(final int textureID) {
nSetTexID(textureID);
}
private native void nSetTexID(int textureID); /*
THIS->SetTexID((ImTextureID)(intptr_t)textureID);
*/
//-------------------------------------------
// Glyph Ranges
//-------------------------------------------
// Helpers to retrieve list of common Unicode ranges (2 value per range, values are inclusive, zero-terminated list)
// NB: Make sure that your string are UTF-8 and NOT in your local code page. In C++11, you can create UTF-8 string literal using the u8"Hello world" syntax. See FAQ for details.
// NB: Consider using ImFontGlyphRangesBuilder to build glyph ranges from textual data.
/*JNI
#define RETURN_GLYPH_2_SHORT(glyphs) \
const ImWchar* ranges = glyphs; \
int size = 0; \
for (; ranges[0]; ranges += 2) \
size += 2; \
jshortArray jShorts = env->NewShortArray(size); \
env->SetShortArrayRegion(jShorts, 0, size, (jshort*)glyphs); \
return jShorts;
*/
/**
* Basic Latin, Extended Latin
*/
public native short[] getGlyphRangesDefault(); /*
RETURN_GLYPH_2_SHORT(THIS->GetGlyphRangesDefault());
*/
/**
* Default + Korean characters
*/
public native short[] getGlyphRangesKorean(); /*
RETURN_GLYPH_2_SHORT(THIS->GetGlyphRangesKorean());
*/
/**
* Default + Hiragana, Katakana, Half-Width, Selection of 2999 Ideographs
*/
public native short[] getGlyphRangesJapanese(); /*
RETURN_GLYPH_2_SHORT(THIS->GetGlyphRangesJapanese());
*/
/**
* Default + Half-Width + Japanese Hiragana/Katakana + full set of about 21000 CJK Unified Ideographs
*/
public native short[] getGlyphRangesChineseFull(); /*
RETURN_GLYPH_2_SHORT(THIS->GetGlyphRangesChineseFull());
*/
/**
* Default + Half-Width + Japanese Hiragana/Katakana + set of 2500 CJK Unified Ideographs for common simplified Chinese
*/
public native short[] getGlyphRangesChineseSimplifiedCommon(); /*
RETURN_GLYPH_2_SHORT(THIS->GetGlyphRangesChineseSimplifiedCommon());
*/
/**
* Default + about 400 Cyrillic characters
*/
public native short[] getGlyphRangesCyrillic(); /*
RETURN_GLYPH_2_SHORT(THIS->GetGlyphRangesCyrillic());
*/
/**
* Default + Thai characters
*/
public native short[] getGlyphRangesThai(); /*
RETURN_GLYPH_2_SHORT(THIS->GetGlyphRangesThai());
*/
/**
* Default + Vietnamese characters
*/
public native short[] getGlyphRangesVietnamese(); /*
RETURN_GLYPH_2_SHORT(THIS->GetGlyphRangesVietnamese());
*/
/*JNI
#undef RETURN_GLYPH_2_SHORT
*/
//-------------------------------------------
// [BETA] Custom Rectangles/Glyphs API
//-------------------------------------------
// You can request arbitrary rectangles to be packed into the atlas, for your own purposes.
// After calling Build(), you can query the rectangle position and render your pixels.
// You can also request your rectangles to be mapped as font glyph (given a font + Unicode point),
// so you can render e.g. custom colorful icons and use them as regular glyphs.
// Read docs/FONTS.md for more details about using colorful icons.
// Note: this API may be redesigned later in order to support multi-monitor varying DPI settings.
public int addCustomRectRegular(final int width, final int height) {
return nAddCustomRectRegular(width, height);
}
private native int nAddCustomRectRegular(int width, int height); /*
return THIS->AddCustomRectRegular(width, height);
*/
/**
* Id needs to be {@code <} 0x110000 to register a rectangle to map into a specific font.
*/
public int addCustomRectFontGlyph(final ImFont imFont, final short id, final int width, final int height, final float advanceX) {
return nAddCustomRectFontGlyph(imFont.ptr, id, width, height, advanceX);
}
/**
* Id needs to be {@code <} 0x110000 to register a rectangle to map into a specific font.
*/
public int addCustomRectFontGlyph(final ImFont imFont, final short id, final int width, final int height, final float advanceX, final ImVec2 offset) {
return nAddCustomRectFontGlyph(imFont.ptr, id, width, height, advanceX, offset.x, offset.y);
}
/**
* Id needs to be {@code <} 0x110000 to register a rectangle to map into a specific font.
*/
public int addCustomRectFontGlyph(final ImFont imFont, final short id, final int width, final int height, final float advanceX, final float offsetX, final float offsetY) {
return nAddCustomRectFontGlyph(imFont.ptr, id, width, height, advanceX, offsetX, offsetY);
}
private native int nAddCustomRectFontGlyph(long imFont, short id, int width, int height, float advanceX); /*
return THIS->AddCustomRectFontGlyph(reinterpret_cast<ImFont*>(imFont), (ImWchar)id, width, height, advanceX);
*/
private native int nAddCustomRectFontGlyph(long imFont, short id, int width, int height, float advanceX, float offsetX, float offsetY); /*MANUAL
ImVec2 offset = ImVec2(offsetX, offsetY);
auto _result = THIS->AddCustomRectFontGlyph(reinterpret_cast<ImFont*>(imFont), (ImWchar)id, width, height, advanceX, offset);
return _result;
*/
// TODO GetCustomRectByIndex
//-------------------------------------------
// Members
//-------------------------------------------
/**
* Build flags (see {@link imgui.flag.ImFontAtlasFlags})
*/
public int getFlags() {
return nGetFlags();
}
/**
* Build flags (see {@link imgui.flag.ImFontAtlasFlags})
*/
public void setFlags(final int value) {
nSetFlags(value);
}
/**
* Build flags (see {@link imgui.flag.ImFontAtlasFlags})
*/
public void addFlags(final int flags) {
setFlags(getFlags() | flags);
}
/**
* Build flags (see {@link imgui.flag.ImFontAtlasFlags})
*/
public void removeFlags(final int flags) {
setFlags(getFlags() & ~(flags));
}
/**
* Build flags (see {@link imgui.flag.ImFontAtlasFlags})
*/
public boolean hasFlags(final int flags) {
return (getFlags() & flags) != 0;
}
private native int nGetFlags(); /*
return THIS->Flags;
*/
private native void nSetFlags(int value); /*
THIS->Flags = value;
*/
// TexID implemented as SetTexID function
/**
* Texture width desired by user before Build(). Must be a power-of-two.
* If have many glyphs your graphics API have texture size restrictions you may want to increase texture width to decrease height.
*/
public int getTexDesiredWidth() {
return nGetTexDesiredWidth();
}
/**
* Texture width desired by user before Build(). Must be a power-of-two.
* If have many glyphs your graphics API have texture size restrictions you may want to increase texture width to decrease height.
*/
public void setTexDesiredWidth(final int value) {
nSetTexDesiredWidth(value);
}
private native int nGetTexDesiredWidth(); /*
return THIS->TexDesiredWidth;
*/
private native void nSetTexDesiredWidth(int value); /*
THIS->TexDesiredWidth = value;
*/
/**
* Padding between glyphs within texture in pixels. Defaults to 1.
* If your rendering method doesn't rely on bilinear filtering you may set this to 0.
*/
public int getTexGlyphPadding() {
return nGetTexGlyphPadding();
}
/**
* Padding between glyphs within texture in pixels. Defaults to 1.
* If your rendering method doesn't rely on bilinear filtering you may set this to 0.
*/
public void setTexGlyphPadding(final int value) {
nSetTexGlyphPadding(value);
}
private native int nGetTexGlyphPadding(); /*
return THIS->TexGlyphPadding;
*/
private native void nSetTexGlyphPadding(int value); /*
THIS->TexGlyphPadding = value;
*/
/**
* Marked as Locked by ImGui::NewFrame() so attempt to modify the atlas will assert.
*/
public boolean getLocked() {
return nGetLocked();
}
/**
* Marked as Locked by ImGui::NewFrame() so attempt to modify the atlas will assert.
*/
public void setLocked(final boolean value) {
nSetLocked(value);
}
private native boolean nGetLocked(); /*
return THIS->Locked;
*/
private native void nSetLocked(boolean value); /*
THIS->Locked = value;
*/
/*JNI
#undef THIS
*/
}
@@ -0,0 +1,501 @@
package imgui;
import imgui.binding.ImGuiStructDestroyable;
public final class ImFontConfig extends ImGuiStructDestroyable {
public ImFontConfig() {
super();
}
ImFontConfig(final long ptr) {
super(ptr);
}
@Override
protected long create() {
return nCreate();
}
/*JNI
#include "_common.h"
#define THIS ((ImFontConfig*)STRUCT_PTR)
*/
private native long nCreate(); /*
ImFontConfig* cfg = new ImFontConfig();
cfg->FontDataOwnedByAtlas = false;
return (intptr_t)cfg;
*/
// TODO: FontData
/**
* TTF/OTF data size
*/
public int getFontDataSize() {
return nGetFontDataSize();
}
/**
* TTF/OTF data size
*/
public void setFontDataSize(final int value) {
nSetFontDataSize(value);
}
private native int nGetFontDataSize(); /*
return THIS->FontDataSize;
*/
private native void nSetFontDataSize(int value); /*
THIS->FontDataSize = value;
*/
/**
* TTF/OTF data ownership taken by the container ImFontAtlas (will delete memory itself).
*/
public boolean getFontDataOwnedByAtlas() {
return nGetFontDataOwnedByAtlas();
}
/**
* TTF/OTF data ownership taken by the container ImFontAtlas (will delete memory itself).
*/
public void setFontDataOwnedByAtlas(final boolean value) {
nSetFontDataOwnedByAtlas(value);
}
private native boolean nGetFontDataOwnedByAtlas(); /*
return THIS->FontDataOwnedByAtlas;
*/
private native void nSetFontDataOwnedByAtlas(boolean value); /*
THIS->FontDataOwnedByAtlas = value;
*/
/**
* Index of font within TTF/OTF file
*/
public int getFontNo() {
return nGetFontNo();
}
/**
* Index of font within TTF/OTF file
*/
public void setFontNo(final int value) {
nSetFontNo(value);
}
private native int nGetFontNo(); /*
return THIS->FontNo;
*/
private native void nSetFontNo(int value); /*
THIS->FontNo = value;
*/
/**
* Size in pixels for rasterizer (more or less maps to the resulting font height).
*/
public float getSizePixels() {
return nGetSizePixels();
}
/**
* Size in pixels for rasterizer (more or less maps to the resulting font height).
*/
public void setSizePixels(final float value) {
nSetSizePixels(value);
}
private native float nGetSizePixels(); /*
return THIS->SizePixels;
*/
private native void nSetSizePixels(float value); /*
THIS->SizePixels = value;
*/
/**
* Rasterize at higher quality for sub-pixel positioning.
* Note the difference between 2 and 3 is minimal so you can reduce this to 2 to save memory.
* Read https://github.com/nothings/stb/blob/master/tests/oversample/README.md for details.
*/
public int getOversampleH() {
return nGetOversampleH();
}
/**
* Rasterize at higher quality for sub-pixel positioning.
* Note the difference between 2 and 3 is minimal so you can reduce this to 2 to save memory.
* Read https://github.com/nothings/stb/blob/master/tests/oversample/README.md for details.
*/
public void setOversampleH(final int value) {
nSetOversampleH(value);
}
private native int nGetOversampleH(); /*
return THIS->OversampleH;
*/
private native void nSetOversampleH(int value); /*
THIS->OversampleH = value;
*/
/**
* Rasterize at higher quality for sub-pixel positioning.
* This is not really useful as we don't use sub-pixel positions on the Y axis.
*/
public int getOversampleV() {
return nGetOversampleV();
}
/**
* Rasterize at higher quality for sub-pixel positioning.
* This is not really useful as we don't use sub-pixel positions on the Y axis.
*/
public void setOversampleV(final int value) {
nSetOversampleV(value);
}
private native int nGetOversampleV(); /*
return THIS->OversampleV;
*/
private native void nSetOversampleV(int value); /*
THIS->OversampleV = value;
*/
/**
* Align every glyph to pixel boundary. Useful e.g. if you are merging a non-pixel aligned font with the default font.
* If enabled, you can set OversampleH/V to 1.
*/
public boolean getPixelSnapH() {
return nGetPixelSnapH();
}
/**
* Align every glyph to pixel boundary. Useful e.g. if you are merging a non-pixel aligned font with the default font.
* If enabled, you can set OversampleH/V to 1.
*/
public void setPixelSnapH(final boolean value) {
nSetPixelSnapH(value);
}
private native boolean nGetPixelSnapH(); /*
return THIS->PixelSnapH;
*/
private native void nSetPixelSnapH(boolean value); /*
THIS->PixelSnapH = value;
*/
/**
* Extra spacing (in pixels) between glyphs. Only X axis is supported for now.
*/
public ImVec2 getGlyphExtraSpacing() {
final ImVec2 dst = new ImVec2();
nGetGlyphExtraSpacing(dst);
return dst;
}
/**
* Extra spacing (in pixels) between glyphs. Only X axis is supported for now.
*/
public float getGlyphExtraSpacingX() {
return nGetGlyphExtraSpacingX();
}
/**
* Extra spacing (in pixels) between glyphs. Only X axis is supported for now.
*/
public float getGlyphExtraSpacingY() {
return nGetGlyphExtraSpacingY();
}
/**
* Extra spacing (in pixels) between glyphs. Only X axis is supported for now.
*/
public void getGlyphExtraSpacing(final ImVec2 dst) {
nGetGlyphExtraSpacing(dst);
}
/**
* Extra spacing (in pixels) between glyphs. Only X axis is supported for now.
*/
public void setGlyphExtraSpacing(final ImVec2 value) {
nSetGlyphExtraSpacing(value.x, value.y);
}
/**
* Extra spacing (in pixels) between glyphs. Only X axis is supported for now.
*/
public void setGlyphExtraSpacing(final float valueX, final float valueY) {
nSetGlyphExtraSpacing(valueX, valueY);
}
private native void nGetGlyphExtraSpacing(ImVec2 dst); /*
Jni::ImVec2Cpy(env, THIS->GlyphExtraSpacing, dst);
*/
private native float nGetGlyphExtraSpacingX(); /*
return THIS->GlyphExtraSpacing.x;
*/
private native float nGetGlyphExtraSpacingY(); /*
return THIS->GlyphExtraSpacing.y;
*/
private native void nSetGlyphExtraSpacing(float valueX, float valueY); /*MANUAL
ImVec2 value = ImVec2(valueX, valueY);
THIS->GlyphExtraSpacing = value;
*/
/**
* Offset all glyphs from this font input.
*/
public ImVec2 getGlyphOffset() {
final ImVec2 dst = new ImVec2();
nGetGlyphOffset(dst);
return dst;
}
/**
* Offset all glyphs from this font input.
*/
public float getGlyphOffsetX() {
return nGetGlyphOffsetX();
}
/**
* Offset all glyphs from this font input.
*/
public float getGlyphOffsetY() {
return nGetGlyphOffsetY();
}
/**
* Offset all glyphs from this font input.
*/
public void getGlyphOffset(final ImVec2 dst) {
nGetGlyphOffset(dst);
}
/**
* Offset all glyphs from this font input.
*/
public void setGlyphOffset(final ImVec2 value) {
nSetGlyphOffset(value.x, value.y);
}
/**
* Offset all glyphs from this font input.
*/
public void setGlyphOffset(final float valueX, final float valueY) {
nSetGlyphOffset(valueX, valueY);
}
private native void nGetGlyphOffset(ImVec2 dst); /*
Jni::ImVec2Cpy(env, THIS->GlyphOffset, dst);
*/
private native float nGetGlyphOffsetX(); /*
return THIS->GlyphOffset.x;
*/
private native float nGetGlyphOffsetY(); /*
return THIS->GlyphOffset.y;
*/
private native void nSetGlyphOffset(float valueX, float valueY); /*MANUAL
ImVec2 value = ImVec2(valueX, valueY);
THIS->GlyphOffset = value;
*/
// TODO: GlyphRanges
/**
* Minimum AdvanceX for glyphs, set Min to align font icons, set both Min/Max to enforce mono-space font
*/
public float getGlyphMinAdvanceX() {
return nGetGlyphMinAdvanceX();
}
/**
* Minimum AdvanceX for glyphs, set Min to align font icons, set both Min/Max to enforce mono-space font
*/
public void setGlyphMinAdvanceX(final float value) {
nSetGlyphMinAdvanceX(value);
}
private native float nGetGlyphMinAdvanceX(); /*
return THIS->GlyphMinAdvanceX;
*/
private native void nSetGlyphMinAdvanceX(float value); /*
THIS->GlyphMinAdvanceX = value;
*/
/**
* Maximum AdvanceX for glyphs
*/
public float getGlyphMaxAdvanceX() {
return nGetGlyphMaxAdvanceX();
}
/**
* Maximum AdvanceX for glyphs
*/
public void setGlyphMaxAdvanceX(final float value) {
nSetGlyphMaxAdvanceX(value);
}
private native float nGetGlyphMaxAdvanceX(); /*
return THIS->GlyphMaxAdvanceX;
*/
private native void nSetGlyphMaxAdvanceX(float value); /*
THIS->GlyphMaxAdvanceX = value;
*/
/**
* Merge into previous ImFont, so you can combine multiple inputs font into one ImFont (e.g. ASCII font + icons + Japanese glyphs).
* You may want to use GlyphOffset.y when merge font of different heights.
*/
public boolean getMergeMode() {
return nGetMergeMode();
}
/**
* Merge into previous ImFont, so you can combine multiple inputs font into one ImFont (e.g. ASCII font + icons + Japanese glyphs).
* You may want to use GlyphOffset.y when merge font of different heights.
*/
public void setMergeMode(final boolean value) {
nSetMergeMode(value);
}
private native boolean nGetMergeMode(); /*
return THIS->MergeMode;
*/
private native void nSetMergeMode(boolean value); /*
THIS->MergeMode = value;
*/
/**
* Settings for custom font builder. THIS IS BUILDER IMPLEMENTATION DEPENDENT. Leave as zero if unsure.
*/
public int getFontBuilderFlags() {
return nGetFontBuilderFlags();
}
/**
* Settings for custom font builder. THIS IS BUILDER IMPLEMENTATION DEPENDENT. Leave as zero if unsure.
*/
public void setFontBuilderFlags(final int value) {
nSetFontBuilderFlags(value);
}
/**
* Settings for custom font builder. THIS IS BUILDER IMPLEMENTATION DEPENDENT. Leave as zero if unsure.
*/
public void addFontBuilderFlags(final int flags) {
setFontBuilderFlags(getFontBuilderFlags() | flags);
}
/**
* Settings for custom font builder. THIS IS BUILDER IMPLEMENTATION DEPENDENT. Leave as zero if unsure.
*/
public void removeFontBuilderFlags(final int flags) {
setFontBuilderFlags(getFontBuilderFlags() & ~(flags));
}
/**
* Settings for custom font builder. THIS IS BUILDER IMPLEMENTATION DEPENDENT. Leave as zero if unsure.
*/
public boolean hasFontBuilderFlags(final int flags) {
return (getFontBuilderFlags() & flags) != 0;
}
private native int nGetFontBuilderFlags(); /*
return THIS->FontBuilderFlags;
*/
private native void nSetFontBuilderFlags(int value); /*
THIS->FontBuilderFlags = value;
*/
/**
* Brighten ({@code >}1.0f) or darken ({@code <}1.0f) font output. Brightening small fonts may be a good workaround to make them more readable.
*/
public float getRasterizerMultiply() {
return nGetRasterizerMultiply();
}
/**
* Brighten ({@code >}1.0f) or darken ({@code <}1.0f) font output. Brightening small fonts may be a good workaround to make them more readable.
*/
public void setRasterizerMultiply(final float value) {
nSetRasterizerMultiply(value);
}
private native float nGetRasterizerMultiply(); /*
return THIS->RasterizerMultiply;
*/
private native void nSetRasterizerMultiply(float value); /*
THIS->RasterizerMultiply = value;
*/
/**
* Explicitly specify unicode codepoint of ellipsis character. When fonts are being merged first specified ellipsis will be used.
*/
public short getEllipsisChar() {
return nGetEllipsisChar();
}
/**
* Explicitly specify unicode codepoint of ellipsis character. When fonts are being merged first specified ellipsis will be used.
*/
public void setEllipsisChar(final short value) {
nSetEllipsisChar(value);
}
private native short nGetEllipsisChar(); /*
return THIS->EllipsisChar;
*/
private native void nSetEllipsisChar(short value); /*
THIS->EllipsisChar = value;
*/
// [Internal]
/**
* Name (strictly to ease debugging)
*/
public native void setName(String name); /*
strcpy(THIS->Name, name);
*/
public ImFont getDstFont() {
return new ImFont(nGetDstFont());
}
public void setDstFont(final ImFont value) {
nSetDstFont(value.ptr);
}
private native long nGetDstFont(); /*
return (intptr_t)THIS->DstFont;
*/
private native void nSetDstFont(long value); /*
THIS->DstFont = reinterpret_cast<ImFont*>(value);
*/
/*JNI
#undef THIS
*/
}
@@ -0,0 +1,298 @@
package imgui;
import imgui.binding.ImGuiStructDestroyable;
/**
* Hold rendering data for one glyph.
* (Note: some language parsers may fail to convert the 31+1 bitfield members, in this case maybe drop store a single u32 or we can rework this)
*/
public final class ImFontGlyph extends ImGuiStructDestroyable {
public ImFontGlyph() {
}
public ImFontGlyph(final long ptr) {
super(ptr);
}
@Override
protected long create() {
return nCreate();
}
/*JNI
#include "_common.h"
#define THIS ((ImFontGlyph*)STRUCT_PTR)
*/
private native long nCreate(); /*
return (intptr_t)(new ImFontGlyph());
*/
/**
* Flag to indicate glyph is colored and should generally ignore tinting (make it usable with no shift on little-endian as this is used in loops).
*/
public int getColored() {
return nGetColored();
}
/**
* Flag to indicate glyph is colored and should generally ignore tinting (make it usable with no shift on little-endian as this is used in loops).
*/
public void setColored(final int value) {
nSetColored(value);
}
private native int nGetColored(); /*
return THIS->Colored;
*/
private native void nSetColored(int value); /*
THIS->Colored = value;
*/
/**
* Flag to indicate glyph has no visible pixels (e.g. space). Allow early out when rendering.
*/
public int getVisible() {
return nGetVisible();
}
/**
* Flag to indicate glyph has no visible pixels (e.g. space). Allow early out when rendering.
*/
public void setVisible(final int value) {
nSetVisible(value);
}
private native int nGetVisible(); /*
return THIS->Visible;
*/
private native void nSetVisible(int value); /*
THIS->Visible = value;
*/
/**
* 0x0000..0xFFFF
*/
public int getCodepoint() {
return nGetCodepoint();
}
/**
* 0x0000..0xFFFF
*/
public void setCodepoint(final int value) {
nSetCodepoint(value);
}
private native int nGetCodepoint(); /*
return THIS->Codepoint;
*/
private native void nSetCodepoint(int value); /*
THIS->Codepoint = value;
*/
/**
* Distance to next character (= data from font + ImFontConfig::GlyphExtraSpacing.x baked in)
*/
public float getAdvanceX() {
return nGetAdvanceX();
}
/**
* Distance to next character (= data from font + ImFontConfig::GlyphExtraSpacing.x baked in)
*/
public void setAdvanceX(final float value) {
nSetAdvanceX(value);
}
private native float nGetAdvanceX(); /*
return THIS->AdvanceX;
*/
private native void nSetAdvanceX(float value); /*
THIS->AdvanceX = value;
*/
/**
* Glyph corners
*/
public float getX0() {
return nGetX0();
}
/**
* Glyph corners
*/
public void setX0(final float value) {
nSetX0(value);
}
private native float nGetX0(); /*
return THIS->X0;
*/
private native void nSetX0(float value); /*
THIS->X0 = value;
*/
/**
* Glyph corners
*/
public float getY0() {
return nGetY0();
}
/**
* Glyph corners
*/
public void setY0(final float value) {
nSetY0(value);
}
private native float nGetY0(); /*
return THIS->Y0;
*/
private native void nSetY0(float value); /*
THIS->Y0 = value;
*/
/**
* Glyph corners
*/
public float getX1() {
return nGetX1();
}
/**
* Glyph corners
*/
public void setX1(final float value) {
nSetX1(value);
}
private native float nGetX1(); /*
return THIS->X1;
*/
private native void nSetX1(float value); /*
THIS->X1 = value;
*/
/**
* Glyph corners
*/
public float getY1() {
return nGetY1();
}
/**
* Glyph corners
*/
public void setY1(final float value) {
nSetY1(value);
}
private native float nGetY1(); /*
return THIS->Y1;
*/
private native void nSetY1(float value); /*
THIS->Y1 = value;
*/
/**
* Texture coordinates
*/
public float getU0() {
return nGetU0();
}
/**
* Texture coordinates
*/
public void setU0(final float value) {
nSetU0(value);
}
private native float nGetU0(); /*
return THIS->U0;
*/
private native void nSetU0(float value); /*
THIS->U0 = value;
*/
/**
* Texture coordinates
*/
public float getV0() {
return nGetV0();
}
/**
* Texture coordinates
*/
public void setV0(final float value) {
nSetV0(value);
}
private native float nGetV0(); /*
return THIS->V0;
*/
private native void nSetV0(float value); /*
THIS->V0 = value;
*/
/**
* Texture coordinates
*/
public float getU1() {
return nGetU1();
}
/**
* Texture coordinates
*/
public void setU1(final float value) {
nSetU1(value);
}
private native float nGetU1(); /*
return THIS->U1;
*/
private native void nSetU1(float value); /*
THIS->U1 = value;
*/
/**
* Texture coordinates
*/
public float getV1() {
return nGetV1();
}
/**
* Texture coordinates
*/
public void setV1(final float value) {
nSetV1(value);
}
private native float nGetV1(); /*
return THIS->V1;
*/
private native void nSetV1(float value); /*
THIS->V1 = value;
*/
/*JNI
#undef THIS
*/
}
@@ -0,0 +1,95 @@
package imgui;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* Helper to build glyph ranges from text/string data. Feed your application strings/characters to it then call buildRanges().
* <p>
* You can use the ImFontGlyphRangesBuilder helper to create glyph ranges based on text input. For example: for a game where your script is known,
* if you can feed your entire script to it and only build the characters the game needs.
* <p>
* Direct reimplementation of native ImFontGlyphRangesBuilder in java
*/
public final class ImFontGlyphRangesBuilder {
private static final int UNICODE_CODEPOINT_MAX = 0xFFFF;
// have to use type long because values are unsigned integers
private final long[] usedChars = new long[(UNICODE_CODEPOINT_MAX + 1) / 8];
public ImFontGlyphRangesBuilder() {
clear();
}
/**
* Adds single character to resulting ranges
*/
public void addChar(final char c) {
setBit(c);
}
/**
* Adds all characters from the given string to resulting ranges
*/
public void addText(final String text) {
for (int i = 0; i < text.length(); i++) {
addChar(text.charAt(i));
}
}
/**
* Copies all given ranges to resulting ranges
*/
public void addRanges(final short[] ranges) {
for (int i = 0; i < ranges.length; i += 2) {
if (ranges[i] == 0) {
break;
}
for (int k = ranges[i]; k <= ranges[i + 1]; k++) {
addChar((char) k);
}
}
}
/**
* Builds the final result (ordered ranges with all the unique characters submitted)
* Result of this function can be directly passed to ImFontAtlas
*/
public short[] buildRanges() {
final List<Short> out = new ArrayList<>();
for (int n = 0; n <= UNICODE_CODEPOINT_MAX; n++) {
if (getBit(n)) {
out.add((short) n);
while (n < UNICODE_CODEPOINT_MAX && getBit(n + 1)) {
n++;
}
out.add((short) n);
}
}
final short[] result = new short[out.size() + 1];
for (int i = 0; i < out.size(); i++) {
result[i] = out.get(i);
}
result[result.length - 1] = 0;
return result;
}
public void clear() {
Arrays.fill(usedChars, 0L);
}
public void setBit(final int n) {
final int off = n >> 5;
final long mask = 1L << (n & 31L);
usedChars[off] |= mask;
}
public boolean getBit(final int n) {
final int off = n >> 5;
final long mask = 1L << (n & 31L);
return (usedChars[off] & mask) > 0;
}
}
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,294 @@
package imgui;
import imgui.binding.ImGuiStruct;
/**
* Shared state of InputText(), passed as an argument to your callback when a ImGuiInputTextFlags_Callback* flag is used.<p>
* The callback function should return 0 by default.<p>
* Callbacks (follow a flag name and see comments in ImGuiInputTextFlags_ declarations for more details)<p>
* - ImGuiInputTextFlags_CallbackEdit: Callback on buffer edit (note that InputText() already returns true on edit, the callback is useful mainly to manipulate the underlying buffer while focus is active)<p>
* - ImGuiInputTextFlags_CallbackAlways: Callback on each iteration<p>
* - ImGuiInputTextFlags_CallbackCompletion: Callback on pressing TAB<p>
* - ImGuiInputTextFlags_CallbackHistory: Callback on pressing Up/Down arrows<p>
* - ImGuiInputTextFlags_CallbackCharFilter: Callback on character inputs to replace or discard them. Modify 'EventChar' to replace or discard, or return 1 in callback to discard.<p>
* - ImGuiInputTextFlags_CallbackResize: Callback on buffer capacity changes request (beyond 'buf_size' parameter value), allowing the string to grow.<p>
*/
public class ImGuiInputTextCallbackData extends ImGuiStruct {
public ImGuiInputTextCallbackData(final long ptr) {
super(ptr);
}
/*JNI
#include "_common.h"
#define THIS ((ImGuiInputTextCallbackData*)STRUCT_PTR)
*/
/**
* One ImGuiInputTextFlags_Callback*
*/
public int getEventFlag() {
return nGetEventFlag();
}
/**
* One ImGuiInputTextFlags_Callback*
*/
public boolean hasEventFlag(final int flags) {
return (getEventFlag() & flags) != 0;
}
private native int nGetEventFlag(); /*
return THIS->EventFlag;
*/
/**
* What user passed to InputText()
*/
public int getFlags() {
return nGetFlags();
}
/**
* What user passed to InputText()
*/
public boolean hasFlags(final int flags) {
return (getFlags() & flags) != 0;
}
private native int nGetFlags(); /*
return THIS->Flags;
*/
// TODO: UserData
/**
* [CharFilter] Replace character with another one, or set to zero to drop. return 1 is equivalent to setting EventChar=0;
*/
public int getEventChar() {
return nGetEventChar();
}
/**
* [CharFilter] Replace character with another one, or set to zero to drop. return 1 is equivalent to setting EventChar=0;
*/
public void setEventChar(final int value) {
nSetEventChar(value);
}
private native int nGetEventChar(); /*
return THIS->EventChar;
*/
private native void nSetEventChar(int value); /*
THIS->EventChar = value;
*/
/**
* [Completion,History]
*/
public int getEventKey() {
return nGetEventKey();
}
private native int nGetEventKey(); /*
return THIS->EventKey;
*/
/**
* [Resize] Can replace pointer <p>
* [Completion,History,Always] Only write to pointed data, don't replace the actual pointer!
*/
public String getBuf() {
return nGetBuf();
}
/**
* [Resize] Can replace pointer <p>
* [Completion,History,Always] Only write to pointed data, don't replace the actual pointer!
*/
public void setBuf(final String value) {
nSetBuf(value);
}
private native String nGetBuf(); /*
return env->NewStringUTF(THIS->Buf);
*/
private native void nSetBuf(String value); /*MANUAL
auto value = obj_value == NULL ? NULL : (char*)env->GetStringUTFChars(obj_value, JNI_FALSE);
THIS->Buf = value;
if (value != NULL) env->ReleaseStringUTFChars(obj_value, value);
*/
/**
* [Resize,Completion,History,Always] Exclude zero-terminator storage. In C land: == strlen(some_text), in C++ land: string.length()
*/
public int getBufTextLen() {
return nGetBufTextLen();
}
/**
* [Resize,Completion,History,Always] Exclude zero-terminator storage. In C land: == strlen(some_text), in C++ land: string.length()
*/
public void setBufTextLen(final int value) {
nSetBufTextLen(value);
}
private native int nGetBufTextLen(); /*
return THIS->BufTextLen;
*/
private native void nSetBufTextLen(int value); /*
THIS->BufTextLen = value;
*/
/**
* Set if you modify Buf/BufTextLen!
*/
public boolean getBufDirty() {
return nGetBufDirty();
}
/**
* Set if you modify Buf/BufTextLen!
*/
public void setBufDirty(final boolean value) {
nSetBufDirty(value);
}
private native boolean nGetBufDirty(); /*
return THIS->BufDirty;
*/
private native void nSetBufDirty(boolean value); /*
THIS->BufDirty = value;
*/
/**
* Current cursor position
*/
public int getCursorPos() {
return nGetCursorPos();
}
/**
* Current cursor position
*/
public void setCursorPos(final int value) {
nSetCursorPos(value);
}
private native int nGetCursorPos(); /*
return THIS->CursorPos;
*/
private native void nSetCursorPos(int value); /*
THIS->CursorPos = value;
*/
/**
* Selection Start
*/
public int getSelectionStart() {
return nGetSelectionStart();
}
/**
* Selection Start
*/
public void setSelectionStart(final int value) {
nSetSelectionStart(value);
}
private native int nGetSelectionStart(); /*
return THIS->SelectionStart;
*/
private native void nSetSelectionStart(int value); /*
THIS->SelectionStart = value;
*/
/**
* Selection End
*/
public int getSelectionEnd() {
return nGetSelectionEnd();
}
/**
* Selection End
*/
public void setSelectionEnd(final int value) {
nSetSelectionEnd(value);
}
private native int nGetSelectionEnd(); /*
return THIS->SelectionEnd;
*/
private native void nSetSelectionEnd(int value); /*
THIS->SelectionEnd = value;
*/
/**
* Delete Chars
*
* @param pos
* Start Delete Pos
* @param bytesCount
* Delete Char Count
*/
public void deleteChars(final int pos, final int bytesCount) {
nDeleteChars(pos, bytesCount);
}
private native void nDeleteChars(int pos, int bytesCount); /*
THIS->DeleteChars(pos, bytesCount);
*/
/**
* Insert Chars
*
* @param pos
* insert Psos
* @param str
* insert String
*/
public void insertChars(final int pos, final String str) {
nInsertChars(pos, str);
}
private native void nInsertChars(int pos, String str); /*MANUAL
auto str = obj_str == NULL ? NULL : (char*)env->GetStringUTFChars(obj_str, JNI_FALSE);
THIS->InsertChars(pos, str);
if (str != NULL) env->ReleaseStringUTFChars(obj_str, str);
*/
public void selectAll() {
nSelectAll();
}
private native void nSelectAll(); /*
THIS->SelectAll();
*/
public void clearSelection() {
nClearSelection();
}
private native void nClearSelection(); /*
THIS->ClearSelection();
*/
public boolean hasSelection() {
return nHasSelection();
}
private native boolean nHasSelection(); /*
return THIS->HasSelection();
*/
/*JNI
#undef THIS
*/
}
@@ -0,0 +1,69 @@
package imgui;
import imgui.callback.ImListClipperCallback;
/**
* Helper: Manually clip large list of items.
* If you are submitting lots of evenly spaced items and you have a random access to the list, you can perform coarse
* clipping based on visibility to save yourself from processing those items at all.
* The clipper calculates the range of visible items and advance the cursor to compensate for the non-visible items we have skipped.
* (Dear ImGui already clip items based on their bounds but it needs to measure text size to do so, whereas manual coarse clipping before submission makes this cost and your own data fetching/submission cost almost null)
* <pre>
* ImGuiListClipper clipper;
* clipper.Begin(1000); // We have 1000 elements, evenly spaced.
* while (clipper.Step())
* for (int i = clipper.DisplayStart; i {@code <} clipper.DisplayEnd; i++)
* ImGui::Text("line number %d", i);
* </pre>
* Generally what happens is:
* - Clipper lets you process the first element (DisplayStart = 0, DisplayEnd = 1) regardless of it being visible or not.
* - User code submit one element.
* - Clipper can measure the height of the first element
* - Clipper calculate the actual range of elements to display based on the current clipping rectangle, position the cursor before the first visible element.
* - User code submit visible elements.
* - The clipper also handles various subtleties related to keyboard/gamepad navigation, wrapping etc.
* <p>
* BINDING NOTICE:
* It's impossible to implement the same API like in the original. Method {@link #forEach(int, int, ImListClipperCallback)} could be used instead.
* <pre>
* ImGuiListClipper.forEach(1000, new ImListClipperCallback() {
* public void accept(int index) {
* ImGui.text(String.format("line number %d", index));
* }
* });
* </pre>
*/
public final class ImGuiListClipper {
private ImGuiListClipper() {
}
/*JNI
#include "_common.h"
*/
/**
* @param itemsCount Use -1 to ignore (you can call Begin later).
* Use INT_MAX if you don't know how many items you have (in which case the cursor won't be advanced in the final step).
* @param callback action to do in iterations
*/
public static void forEach(final int itemsCount, final ImListClipperCallback callback) {
forEach(itemsCount, -1, callback);
}
/**
* @param itemsCount Use -1 to ignore (you can call Begin later).
* Use INT_MAX if you don't know how many items you have (in which case the cursor won't be advanced in the final step).
* @param itemsHeight Use -1.0f to be calculated automatically on first step.
* Otherwise pass in the distance between your items, typically GetTextLineHeightWithSpacing() or GetFrameHeightWithSpacing().
* @param callback action to do in iterations
*/
public static native void forEach(int itemsCount, int itemsHeight, ImListClipperCallback callback); /*
ImGuiListClipper clipper;
clipper.Begin(itemsCount, itemsHeight);
while (clipper.Step()) {
for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) {
Jni::CallImListClipperCallback(env, callback, i);
}
}
*/
}
@@ -0,0 +1,23 @@
package imgui;
/**
* Helper: Execute a block of code at maximum once a frame.
* Convenient if you want to quickly create an UI within deep-nested code that runs multiple times every frame.
* Usage: static ImGuiOnceUponAFrame oaf; if (oaf) ImGui::Text("This will be called only once per frame");
* <p>
* BINDING NOTICE:
* Java example: if (ImGuiOnceUponAFrame.get()) ImGui.text("This will be called only once per frame");
*/
public final class ImGuiOnceUponAFrame {
private ImGuiOnceUponAFrame() {
}
/*JNI
#include "_common.h"
*/
public static native boolean get(); /*
ImGuiOnceUponAFrame oaf;
return (bool)oaf;
*/
}
@@ -0,0 +1,540 @@
package imgui;
import imgui.binding.ImGuiStruct;
import imgui.callback.ImPlatformFuncViewport;
import imgui.callback.ImPlatformFuncViewportFloat;
import imgui.callback.ImPlatformFuncViewportImVec2;
import imgui.callback.ImPlatformFuncViewportString;
import imgui.callback.ImPlatformFuncViewportSuppBoolean;
import imgui.callback.ImPlatformFuncViewportSuppFloat;
import imgui.callback.ImPlatformFuncViewportSuppImVec2;
/**
* -----------------------------------------------------------------------------
* [BETA] Platform interface for multi-viewport support
* -----------------------------------------------------------------------------
* (Optional) This is completely optional, for advanced users!
* If you are new to Dear ImGui and trying to integrate it into your engine, you can probably ignore this for now.
* This feature allows you to seamlessly drag Dear ImGui windows outside of your application viewport.
* This is achieved by creating new Platform/OS windows on the fly, and rendering into them.
* Dear ImGui manages the viewport structures, and the backend create and maintain one Platform/OS window for each of those viewports.
* See Glossary https://github.com/ocornut/imgui/wiki/Glossary for details about some of the terminology.
* See Thread https://github.com/ocornut/imgui/issues/1542 for gifs, news and questions about this evolving feature.
* About the coordinates system:
* - When multi-viewports are enabled, all Dear ImGui coordinates become absolute coordinates (same as OS coordinates!)
* - So e.g. ImGui::SetNextWindowPos(ImVec2(0,0)) will position a window relative to your primary monitor!
* - If you want to position windows relative to your main application viewport, use ImGui::GetMainViewport().Pos as a base position.
* Steps to use multi-viewports in your application, when using a default backend from the examples/ folder:
* - Application: Enable feature with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
* - Backend: The backend initialization will setup all necessary ImGuiPlatformIO's functions and update monitors info every frame.
* - Application: In your main loop, call ImGui::UpdatePlatformWindows(), ImGui::RenderPlatformWindowsDefault() after EndFrame() or Render().
* - Application: Fix absolute coordinates used in ImGui::SetWindowPos() or ImGui::SetNextWindowPos() calls.
* Steps to use multi-viewports in your application, when using a custom backend:
* - Important: THIS IS NOT EASY TO DO and comes with many subtleties not described here!
* It's also an experimental feature, so some of the requirements may evolve.
* Consider using default backends if you can. Either way, carefully follow and refer to examples/ backends for details.
* - Application: Enable feature with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
* - Backend: Hook ImGuiPlatformIO's Platform_* and Renderer_* callbacks (see below).
* Set 'io.BackendFlags |= ImGuiBackendFlags_PlatformHasViewports' and 'io.BackendFlags |= ImGuiBackendFlags_PlatformHasViewports'.
* Update ImGuiPlatformIO's Monitors list every frame.
* Update MousePos every frame, in absolute coordinates.
* - Application: In your main loop, call ImGui::UpdatePlatformWindows(), ImGui::RenderPlatformWindowsDefault() after EndFrame() or Render().
* You may skip calling RenderPlatformWindowsDefault() if its API is not convenient for your needs. Read comments below.
* - Application: Fix absolute coordinates used in ImGui::SetWindowPos() or ImGui::SetNextWindowPos() calls.
* About ImGui::RenderPlatformWindowsDefault():
* - This function is a mostly a _helper_ for the common-most cases, and to facilitate using default backends.
* - You can check its simple source code to understand what it does.
* It basically iterates secondary viewports and call 4 functions that are setup in ImGuiPlatformIO, if available:
* Platform_RenderWindow(), Renderer_RenderWindow(), Platform_SwapBuffers(), Renderer_SwapBuffers()
* Those functions pointers exists only for the benefit of RenderPlatformWindowsDefault().
* - If you have very specific rendering needs (e.g. flipping multiple swap-chain simultaneously, unusual sync/threading issues, etc.),
* you may be tempted to ignore RenderPlatformWindowsDefault() and write customized code to perform your renderingg.
* You may decide to setup the platform_io's *RenderWindow and *SwapBuffers pointers and call your functions through those pointers,
* or you may decide to never setup those pointers and call your code directly. They are a convenience, not an obligatory interface.
* -----------------------------------------------------------------------------
* (Optional) Access via ImGui::GetPlatformIO()
* <p>
* ------------------------------------------------------------------
* Input - Backend interface/functions + Monitor List
* ------------------------------------------------------------------
* (Optional) Platform functions (e.g. Win32, GLFW, SDL2)
* For reference, the second column shows which function are generally calling the Platform Functions:
* N = ImGui::NewFrame() ~ beginning of the dear imgui frame: read info from platform/OS windows (latest size/position)
* F = ImGui::Begin(), ImGui::EndFrame() ~ during the dear imgui frame
* U = ImGui::UpdatePlatformWindows() ~ after the dear imgui frame: create and update all platform/OS windows
* R = ImGui::RenderPlatformWindowsDefault() ~ render
* D = ImGui::DestroyPlatformWindows() ~ shutdown
* The general idea is that NewFrame() we will read the current Platform/OS state, and UpdatePlatformWindows() will write to it.
* The functions are designed so we can mix and match 2 imgui_impl_xxxx files, one for the Platform (~window/input handling), one for Renderer.
* Custom engine backends will often provide both Platform and Renderer interfaces and so may not need to use all functions.
* Platform functions are typically called before their Renderer counterpart, apart from Destroy which are called the other way.
*/
public final class ImGuiPlatformIO extends ImGuiStruct {
private static final ImGuiViewport TMP_VIEWPORT = new ImGuiViewport(0);
private static final ImGuiPlatformMonitor TMP_MONITOR = new ImGuiPlatformMonitor(0);
private static final ImVec2 TMP_IM_VEC2 = new ImVec2();
public ImGuiPlatformIO(final long ptr) {
super(ptr);
}
/*JNI
#include "_common.h"
#define IMGUI_PLATFORM_IO ((ImGuiPlatformIO*)STRUCT_PTR)
jobject jTmpViewport = NULL;
jobject jTmpImVec2 = NULL;
*/
static void init() {
nInit(TMP_VIEWPORT, TMP_IM_VEC2);
}
private static native void nInit(ImGuiViewport tmpViewport, ImVec2 tmpImVec2); /*
jTmpViewport = env->NewGlobalRef(tmpViewport);
jTmpImVec2 = env->NewGlobalRef(tmpImVec2);
*/
/*JNI
#define IM_PLATFORM_FUNC_VIEWPORT_TMPL(name)\
jobject platformCallback##name = NULL;\
void PlatformStub##name(ImGuiViewport* vp) {\
if (platformCallback##name != NULL) {\
JNIEnv* env = Jni::GetEnv();\
env->SetLongField(jTmpViewport, Jni::GetBindingStructPtrID(), (intptr_t)vp);\
Jni::CallImPlatformFuncViewport(env, platformCallback##name, jTmpViewport);\
}\
}\
void PlatformStub##name(ImGuiViewport* vp, void*) {\
PlatformStub##name(vp);\
}
IM_PLATFORM_FUNC_VIEWPORT_TMPL(CreateWindow)
#define IM_PLATFORM_FUNC_VIEWPORT_METHOD_TMPL(name)\
if (platformCallback##name != NULL) {\
env->DeleteGlobalRef(platformCallback##name);\
}\
platformCallback##name = env->NewGlobalRef(func);\
IMGUI_PLATFORM_IO->Platform_##name = PlatformStub##name;
*/
/**
* // . . U . . // Create a new platform window for the given viewport.
*/
public native void setPlatformCreateWindow(ImPlatformFuncViewport func); /*
IM_PLATFORM_FUNC_VIEWPORT_METHOD_TMPL(CreateWindow)
*/
/*JNI
IM_PLATFORM_FUNC_VIEWPORT_TMPL(DestroyWindow)
*/
/**
* // N . U . D //
*/
public native void setPlatformDestroyWindow(ImPlatformFuncViewport func); /*
IM_PLATFORM_FUNC_VIEWPORT_METHOD_TMPL(DestroyWindow)
*/
/*JNI
IM_PLATFORM_FUNC_VIEWPORT_TMPL(ShowWindow)
*/
/**
* // . . U . . // Newly created windows are initially hidden so SetWindowPos/Size/Title can be called on them before showing the window.
*/
public native void setPlatformShowWindow(ImPlatformFuncViewport func); /*
IM_PLATFORM_FUNC_VIEWPORT_METHOD_TMPL(ShowWindow)
*/
/*JNI
#define IM_PLATFORM_FUNC_VIEWPORT_IM_VEC2_TMPL(name)\
jobject platformCallback##name = NULL;\
void PlatformStub##name(ImGuiViewport* vp, ImVec2 pos) {\
if (platformCallback##name != NULL) {\
JNIEnv* env = Jni::GetEnv();\
env->SetLongField(jTmpViewport, Jni::GetBindingStructPtrID(), (intptr_t)vp);\
Jni::ImVec2Cpy(env, pos, jTmpImVec2);\
Jni::CallImPlatformFuncViewportImVec2(env, platformCallback##name, jTmpViewport, jTmpImVec2);\
}\
}
IM_PLATFORM_FUNC_VIEWPORT_IM_VEC2_TMPL(SetWindowPos)
#define IM_PLATFORM_FUNC_VIEWPORT_IM_VEC2_METHOD_TMPL(name)\
if (platformCallback##name != NULL) {\
env->DeleteGlobalRef(platformCallback##name);\
}\
platformCallback##name = env->NewGlobalRef(func);\
IMGUI_PLATFORM_IO->Platform_##name = PlatformStub##name;
*/
/**
* // . . U . . // Set platform window position (given the upper-left corner of client area).
*/
public native void setPlatformSetWindowPos(ImPlatformFuncViewportImVec2 func); /*
IM_PLATFORM_FUNC_VIEWPORT_IM_VEC2_METHOD_TMPL(SetWindowPos)
*/
/*JNI
#define IM_PLATFORM_FUNC_VIEWPORT_SUPP_IM_VEC2_TMPL(name)\
jobject platformCallback##name = NULL;\
ImVec2 PlatformStub##name(ImGuiViewport* vp) {\
ImVec2 dst;\
if (platformCallback##name != NULL) {\
JNIEnv* env = Jni::GetEnv();\
env->SetLongField(jTmpViewport, Jni::GetBindingStructPtrID(), (intptr_t)vp);\
Jni::CallImPlatformFuncViewportSuppImVec2(env, platformCallback##name, jTmpViewport, jTmpImVec2);\
Jni::ImVec2Cpy(env, jTmpImVec2, &dst);\
}\
return dst;\
}
IM_PLATFORM_FUNC_VIEWPORT_SUPP_IM_VEC2_TMPL(GetWindowPos)
#define IM_PLATFORM_FUNC_VIEWPORT_SUPP_IM_VEC2_METHOD_TMPL(name)\
if (platformCallback##name != NULL) {\
env->DeleteGlobalRef(platformCallback##name);\
}\
platformCallback##name = env->NewGlobalRef(func);\
IMGUI_PLATFORM_IO->Platform_##name = PlatformStub##name;
*/
/**
* // N . . . . //
*/
public native void setPlatformGetWindowPos(ImPlatformFuncViewportSuppImVec2 func); /*
IM_PLATFORM_FUNC_VIEWPORT_SUPP_IM_VEC2_METHOD_TMPL(GetWindowPos)
*/
/*JNI
IM_PLATFORM_FUNC_VIEWPORT_IM_VEC2_TMPL(SetWindowSize)
*/
/**
* // . . U . . // Set platform window client area size (ignoring OS decorations such as OS title bar etc.)
*/
public native void setPlatformSetWindowSize(ImPlatformFuncViewportImVec2 func); /*
IM_PLATFORM_FUNC_VIEWPORT_IM_VEC2_METHOD_TMPL(SetWindowSize)
*/
/*JNI
IM_PLATFORM_FUNC_VIEWPORT_SUPP_IM_VEC2_TMPL(GetWindowSize)
*/
/**
* // N . . . . // Get platform window client area size
*/
public native void setPlatformGetWindowSize(ImPlatformFuncViewportSuppImVec2 func); /*
IM_PLATFORM_FUNC_VIEWPORT_SUPP_IM_VEC2_METHOD_TMPL(GetWindowSize)
*/
/*JNI
IM_PLATFORM_FUNC_VIEWPORT_TMPL(SetWindowFocus)
*/
/**
* // N . . . . // Move window to front and set input focus.
*/
public native void setPlatformSetWindowFocus(ImPlatformFuncViewport func); /*
IM_PLATFORM_FUNC_VIEWPORT_METHOD_TMPL(SetWindowFocus)
*/
/*JNI
#define IM_PLATFORM_FUNC_VIEWPORT_SUPP_BOOLEAN_TMPL(name)\
jobject platformCallback##name = NULL;\
bool PlatformStub##name(ImGuiViewport* vp) {\
if (platformCallback##name != NULL) {\
JNIEnv* env = Jni::GetEnv();\
env->SetLongField(jTmpViewport, Jni::GetBindingStructPtrID(), (intptr_t)vp);\
return Jni::CallImPlatformFuncViewportSuppBoolean(env, platformCallback##name, jTmpViewport);\
}\
return false;\
}
IM_PLATFORM_FUNC_VIEWPORT_SUPP_BOOLEAN_TMPL(GetWindowFocus)
#define IM_PLATFORM_FUNC_VIEWPORT_SUPP_BOOLEAN_METHOD_TMPL(name)\
if (platformCallback##name != NULL) {\
env->DeleteGlobalRef(platformCallback##name);\
}\
platformCallback##name = env->NewGlobalRef(func);\
IMGUI_PLATFORM_IO->Platform_##name = PlatformStub##name;
*/
/**
* // . . U . . //
*/
public native void setPlatformGetWindowFocus(ImPlatformFuncViewportSuppBoolean func); /*
IM_PLATFORM_FUNC_VIEWPORT_SUPP_BOOLEAN_METHOD_TMPL(GetWindowFocus)
*/
/*JNI
IM_PLATFORM_FUNC_VIEWPORT_SUPP_BOOLEAN_TMPL(GetWindowMinimized)
*/
/**
* // N . . . . // Get platform window minimized state. When minimized, we generally won't attempt to get/set size and contents will be culled more easily.
*/
public native void setPlatformGetWindowMinimized(ImPlatformFuncViewportSuppBoolean func); /*
IM_PLATFORM_FUNC_VIEWPORT_SUPP_BOOLEAN_METHOD_TMPL(GetWindowMinimized)
*/
/*JNI
jobject platformCallbackSetWindowTitle = NULL;
void PlatformStubSetWindowTitle(ImGuiViewport* vp, const char* str) {
if (platformCallbackSetWindowTitle != NULL) {
JNIEnv* env = Jni::GetEnv();
env->SetLongField(jTmpViewport, Jni::GetBindingStructPtrID(), (intptr_t)vp);
Jni::CallImPlatformFuncViewportString(env, platformCallbackSetWindowTitle, jTmpViewport, str);
}
}
*/
/**
* // . . U . . // Set platform window title (given an UTF-8 string)
*/
public native void setPlatformSetWindowTitle(ImPlatformFuncViewportString func); /*
if (platformCallbackSetWindowTitle != NULL) {
env->DeleteGlobalRef(platformCallbackSetWindowTitle);
}
platformCallbackSetWindowTitle = env->NewGlobalRef(func);
IMGUI_PLATFORM_IO->Platform_SetWindowTitle = PlatformStubSetWindowTitle;
*/
/*JNI
jobject platformCallbackSetWindowAlpha = NULL;
void PlatformStubSetWindowAlpha(ImGuiViewport* vp, float alpha) {
if (platformCallbackSetWindowAlpha != NULL) {
JNIEnv* env = Jni::GetEnv();
env->SetLongField(jTmpViewport, Jni::GetBindingStructPtrID(), (intptr_t)vp);
Jni::CallImPlatformFuncViewportFloat(env, platformCallbackSetWindowAlpha, jTmpViewport, alpha);
}
}
*/
/**
* // . . U . . // (Optional) Setup window transparency
*/
public native void setPlatformSetWindowAlpha(ImPlatformFuncViewportFloat func); /*
if (platformCallbackSetWindowAlpha != NULL) {
env->DeleteGlobalRef(platformCallbackSetWindowAlpha);
}
platformCallbackSetWindowAlpha = env->NewGlobalRef(func);
IMGUI_PLATFORM_IO->Platform_SetWindowAlpha = PlatformStubSetWindowAlpha;
*/
/*JNI
IM_PLATFORM_FUNC_VIEWPORT_TMPL(UpdateWindow)
*/
/**
* // . . U . . // (Optional) Called by UpdatePlatformWindows(). Optional hook to allow the platform backend from doing general book-keeping every frame.
*/
public native void setPlatformUpdateWindow(ImPlatformFuncViewport func); /*
IM_PLATFORM_FUNC_VIEWPORT_METHOD_TMPL(UpdateWindow)
*/
/*JNI
IM_PLATFORM_FUNC_VIEWPORT_TMPL(RenderWindow)
*/
/**
* // . . . R . // (Optional) Main rendering (platform side! This is often unused, or just setting a "current" context for OpenGL bindings).
*/
public native void setPlatformRenderWindow(ImPlatformFuncViewport func); /*
IM_PLATFORM_FUNC_VIEWPORT_METHOD_TMPL(RenderWindow)
*/
/*JNI
IM_PLATFORM_FUNC_VIEWPORT_TMPL(SwapBuffers)
*/
/**
* // . . . R . // (Optional) Call Present/SwapBuffers (platform side! This is often unused!).
*/
public native void setPlatformSwapBuffers(ImPlatformFuncViewport func); /*
IM_PLATFORM_FUNC_VIEWPORT_METHOD_TMPL(SwapBuffers)
*/
/*JNI
jobject platformCallbackGetWindowDpiScale = NULL;
float PlatformStubGetWindowDpiScale(ImGuiViewport* vp) {
if (platformCallbackGetWindowDpiScale != NULL) {
JNIEnv* env = Jni::GetEnv();
env->SetLongField(jTmpViewport, Jni::GetBindingStructPtrID(), (intptr_t)vp);
return Jni::CallImPlatformFuncViewportSuppFloat(env, platformCallbackGetWindowDpiScale, jTmpViewport);
}
return false;
}
*/
/**
* // N . . . . // (Optional) [BETA] FIXME-DPI: DPI handling: Return DPI scale for this viewport. 1.0f = 96 DPI.
*/
public native void setPlatformGetWindowDpiScale(ImPlatformFuncViewportSuppFloat func); /*
if (platformCallbackGetWindowDpiScale != NULL) {
env->DeleteGlobalRef(platformCallbackGetWindowDpiScale);
}
platformCallbackGetWindowDpiScale = env->NewGlobalRef(func);
IMGUI_PLATFORM_IO->Platform_GetWindowDpiScale = PlatformStubGetWindowDpiScale;
*/
/*JNI
IM_PLATFORM_FUNC_VIEWPORT_TMPL(OnChangedViewport)
*/
/**
* // (Optional) [BETA] FIXME-DPI: DPI handling: Called during Begin() every time the viewport we are outputting into changes, so backend has a chance to swap fonts to adjust style.
*/
public native void setPlatformOnChangedViewport(ImPlatformFuncViewport func); /*
IM_PLATFORM_FUNC_VIEWPORT_METHOD_TMPL(OnChangedViewport)
*/
// (Optional) Renderer functions (e.g. DirectX, OpenGL, Vulkan)
/*JNI
#define IM_RENDERER_FUNC_VIEWPORT_TMPL(name)\
jobject rendererCallback##name = NULL;\
void RendererStub##name(ImGuiViewport* vp) {\
if (rendererCallback##name != NULL) {\
JNIEnv* env = Jni::GetEnv();\
env->SetLongField(jTmpViewport, Jni::GetBindingStructPtrID(), (intptr_t)vp);\
Jni::CallImPlatformFuncViewport(env, rendererCallback##name, jTmpViewport);\
}\
}\
void RendererStub##name(ImGuiViewport* vp, void*) {\
RendererStub##name(vp);\
}
IM_RENDERER_FUNC_VIEWPORT_TMPL(CreateWindow)
#define IM_RENDERER_FUNC_VIEWPORT_METHOD_TMPL(name)\
if (rendererCallback##name != NULL) {\
env->DeleteGlobalRef(rendererCallback##name);\
}\
rendererCallback##name = env->NewGlobalRef(func);\
IMGUI_PLATFORM_IO->Renderer_##name = RendererStub##name;
*/
/**
* // . . U . . // Create swap chain, frame buffers etc. (called after Platform_CreateWindow)
*/
public native void setRendererCreateWindow(ImPlatformFuncViewport func); /*
IM_RENDERER_FUNC_VIEWPORT_METHOD_TMPL(CreateWindow)
*/
/*JNI
IM_RENDERER_FUNC_VIEWPORT_TMPL(DestroyWindow)
*/
/**
* // N . U . D // Destroy swap chain, frame buffers etc. (called before Platform_DestroyWindow)
*/
public native void setRendererDestroyWindow(ImPlatformFuncViewport func); /*
IM_RENDERER_FUNC_VIEWPORT_METHOD_TMPL(DestroyWindow)
*/
/*JNI
jobject rendererCallbackSetWindowSize = NULL;
void RendererStubSetWindowSize(ImGuiViewport* vp, ImVec2 pos) {
if (rendererCallbackSetWindowSize != NULL) {
JNIEnv* env = Jni::GetEnv();
env->SetLongField(jTmpViewport, Jni::GetBindingStructPtrID(), (intptr_t)vp);
Jni::ImVec2Cpy(env, pos, jTmpImVec2);
Jni::CallImPlatformFuncViewportImVec2(env, rendererCallbackSetWindowSize, jTmpViewport, jTmpImVec2);
}
}
*/
/**
* // . . U . . // Resize swap chain, frame buffers etc. (called after Platform_SetWindowSize)
*/
public native void setRendererSetWindowPos(ImPlatformFuncViewportImVec2 func); /*
if (rendererCallbackSetWindowSize != NULL) {
env->DeleteGlobalRef(rendererCallbackSetWindowSize);
}
rendererCallbackSetWindowSize = env->NewGlobalRef(func);
IMGUI_PLATFORM_IO->Renderer_SetWindowSize = RendererStubSetWindowSize;
*/
/*JNI
IM_RENDERER_FUNC_VIEWPORT_TMPL(RenderWindow)
*/
/**
* // . . . R . // (Optional) Clear framebuffer, setup render target,
* then render the viewport.DrawData. 'render_arg' is the value passed to RenderPlatformWindowsDefault().
*/
public native void setRendererRenderWindow(ImPlatformFuncViewport func); /*
IM_RENDERER_FUNC_VIEWPORT_METHOD_TMPL(RenderWindow)
*/
/*JNI
IM_RENDERER_FUNC_VIEWPORT_TMPL(SwapBuffers)
*/
/**
* // . . . R . // (Optional) Call Present/SwapBuffers. 'render_arg' is the value passed to RenderPlatformWindowsDefault().
*/
public native void setRendererSwapBuffers(ImPlatformFuncViewport func); /*
IM_RENDERER_FUNC_VIEWPORT_METHOD_TMPL(SwapBuffers)
*/
// (Optional) Monitor list
// - Updated by: app/backend. Update every frame to dynamically support changing monitor or DPI configuration.
// - Used by: dear imgui to query DPI info, clamp popups/tooltips within same monitor and not have them straddle monitors.
//------------------------------------------------------------------
// Output - List of viewports to render into platform windows
//------------------------------------------------------------------
public native void resizeMonitors(int size); /*
IMGUI_PLATFORM_IO->Monitors.resize(0);
*/
public native int getMonitorsSize(); /*
return IMGUI_PLATFORM_IO->Monitors.Size;
*/
public native void pushMonitors(float mainPosX, float mainPosY, float mainSizeX, float mainSizeY, float workPosX, float workPosY, float workSizeX, float workSizeY, float dpiScale); /*
ImGuiPlatformMonitor monitor;
monitor.MainPos = ImVec2(mainPosX, mainPosY);
monitor.MainSize = ImVec2(mainSizeX, mainSizeY);
monitor.WorkPos = ImVec2(workPosX, workPosY);
monitor.WorkSize = ImVec2(workSizeX, workSizeY);
monitor.DpiScale = dpiScale;
IMGUI_PLATFORM_IO->Monitors.push_back(monitor);
*/
public ImGuiPlatformMonitor getMonitors(final int idx) {
TMP_MONITOR.ptr = nGetMonitors(idx);
return TMP_MONITOR;
}
private native long nGetMonitors(int idx); /*
return (intptr_t)&IMGUI_PLATFORM_IO->Monitors[idx];
*/
// Viewports list (the list is updated by calling ImGui::EndFrame or ImGui::Render)
// (in the future we will attempt to organize this feature to remove the need for a "main viewport")
public native int getViewportsSize(); /*
return IMGUI_PLATFORM_IO->Viewports.Size;
*/
public ImGuiViewport getViewports(final int idx) {
TMP_VIEWPORT.ptr = nGetViewports(idx);
return TMP_VIEWPORT;
}
private native long nGetViewports(int idx); /*
return (intptr_t)IMGUI_PLATFORM_IO->Viewports[idx];
*/
}
@@ -0,0 +1,300 @@
package imgui;
import imgui.binding.ImGuiStruct;
/**
* (Optional) This is required when enabling multi-viewport. Represent the bounds of each connected monitor/display and their DPI.
* We use this information for multiple DPI support + clamping the position of popups and tooltips so they don't straddle multiple monitors.
*/
public final class ImGuiPlatformMonitor extends ImGuiStruct {
public ImGuiPlatformMonitor(final long ptr) {
super(ptr);
}
/*JNI
#include "_common.h"
#define THIS ((ImGuiPlatformMonitor*)STRUCT_PTR)
*/
/**
* Coordinates of the area displayed on this monitor (Min = upper left, Max = bottom right)
*/
public ImVec2 getMainPos() {
final ImVec2 dst = new ImVec2();
nGetMainPos(dst);
return dst;
}
/**
* Coordinates of the area displayed on this monitor (Min = upper left, Max = bottom right)
*/
public float getMainPosX() {
return nGetMainPosX();
}
/**
* Coordinates of the area displayed on this monitor (Min = upper left, Max = bottom right)
*/
public float getMainPosY() {
return nGetMainPosY();
}
/**
* Coordinates of the area displayed on this monitor (Min = upper left, Max = bottom right)
*/
public void getMainPos(final ImVec2 dst) {
nGetMainPos(dst);
}
/**
* Coordinates of the area displayed on this monitor (Min = upper left, Max = bottom right)
*/
public void setMainPos(final ImVec2 value) {
nSetMainPos(value.x, value.y);
}
/**
* Coordinates of the area displayed on this monitor (Min = upper left, Max = bottom right)
*/
public void setMainPos(final float valueX, final float valueY) {
nSetMainPos(valueX, valueY);
}
private native void nGetMainPos(ImVec2 dst); /*
Jni::ImVec2Cpy(env, THIS->MainPos, dst);
*/
private native float nGetMainPosX(); /*
return THIS->MainPos.x;
*/
private native float nGetMainPosY(); /*
return THIS->MainPos.y;
*/
private native void nSetMainPos(float valueX, float valueY); /*MANUAL
ImVec2 value = ImVec2(valueX, valueY);
THIS->MainPos = value;
*/
/**
* Coordinates of the area displayed on this monitor (Min = upper left, Max = bottom right)
*/
public ImVec2 getMainSize() {
final ImVec2 dst = new ImVec2();
nGetMainSize(dst);
return dst;
}
/**
* Coordinates of the area displayed on this monitor (Min = upper left, Max = bottom right)
*/
public float getMainSizeX() {
return nGetMainSizeX();
}
/**
* Coordinates of the area displayed on this monitor (Min = upper left, Max = bottom right)
*/
public float getMainSizeY() {
return nGetMainSizeY();
}
/**
* Coordinates of the area displayed on this monitor (Min = upper left, Max = bottom right)
*/
public void getMainSize(final ImVec2 dst) {
nGetMainSize(dst);
}
/**
* Coordinates of the area displayed on this monitor (Min = upper left, Max = bottom right)
*/
public void setMainSize(final ImVec2 value) {
nSetMainSize(value.x, value.y);
}
/**
* Coordinates of the area displayed on this monitor (Min = upper left, Max = bottom right)
*/
public void setMainSize(final float valueX, final float valueY) {
nSetMainSize(valueX, valueY);
}
private native void nGetMainSize(ImVec2 dst); /*
Jni::ImVec2Cpy(env, THIS->MainSize, dst);
*/
private native float nGetMainSizeX(); /*
return THIS->MainSize.x;
*/
private native float nGetMainSizeY(); /*
return THIS->MainSize.y;
*/
private native void nSetMainSize(float valueX, float valueY); /*MANUAL
ImVec2 value = ImVec2(valueX, valueY);
THIS->MainSize = value;
*/
/**
* Coordinates without task bars / side bars / menu bars.
* Used to avoid positioning popups/tooltips inside this region. If you don't have this info, please copy the value for MainPos/MainSize.
*/
public ImVec2 getWorkPos() {
final ImVec2 dst = new ImVec2();
nGetWorkPos(dst);
return dst;
}
/**
* Coordinates without task bars / side bars / menu bars.
* Used to avoid positioning popups/tooltips inside this region. If you don't have this info, please copy the value for MainPos/MainSize.
*/
public float getWorkPosX() {
return nGetWorkPosX();
}
/**
* Coordinates without task bars / side bars / menu bars.
* Used to avoid positioning popups/tooltips inside this region. If you don't have this info, please copy the value for MainPos/MainSize.
*/
public float getWorkPosY() {
return nGetWorkPosY();
}
/**
* Coordinates without task bars / side bars / menu bars.
* Used to avoid positioning popups/tooltips inside this region. If you don't have this info, please copy the value for MainPos/MainSize.
*/
public void getWorkPos(final ImVec2 dst) {
nGetWorkPos(dst);
}
/**
* Coordinates without task bars / side bars / menu bars.
* Used to avoid positioning popups/tooltips inside this region. If you don't have this info, please copy the value for MainPos/MainSize.
*/
public void setWorkPos(final ImVec2 value) {
nSetWorkPos(value.x, value.y);
}
/**
* Coordinates without task bars / side bars / menu bars.
* Used to avoid positioning popups/tooltips inside this region. If you don't have this info, please copy the value for MainPos/MainSize.
*/
public void setWorkPos(final float valueX, final float valueY) {
nSetWorkPos(valueX, valueY);
}
private native void nGetWorkPos(ImVec2 dst); /*
Jni::ImVec2Cpy(env, THIS->WorkPos, dst);
*/
private native float nGetWorkPosX(); /*
return THIS->WorkPos.x;
*/
private native float nGetWorkPosY(); /*
return THIS->WorkPos.y;
*/
private native void nSetWorkPos(float valueX, float valueY); /*MANUAL
ImVec2 value = ImVec2(valueX, valueY);
THIS->WorkPos = value;
*/
/**
* Coordinates without task bars / side bars / menu bars.
* Used to avoid positioning popups/tooltips inside this region. If you don't have this info, please copy the value for MainPos/MainSize.
*/
public ImVec2 getWorkSize() {
final ImVec2 dst = new ImVec2();
nGetWorkSize(dst);
return dst;
}
/**
* Coordinates without task bars / side bars / menu bars.
* Used to avoid positioning popups/tooltips inside this region. If you don't have this info, please copy the value for MainPos/MainSize.
*/
public float getWorkSizeX() {
return nGetWorkSizeX();
}
/**
* Coordinates without task bars / side bars / menu bars.
* Used to avoid positioning popups/tooltips inside this region. If you don't have this info, please copy the value for MainPos/MainSize.
*/
public float getWorkSizeY() {
return nGetWorkSizeY();
}
/**
* Coordinates without task bars / side bars / menu bars.
* Used to avoid positioning popups/tooltips inside this region. If you don't have this info, please copy the value for MainPos/MainSize.
*/
public void getWorkSize(final ImVec2 dst) {
nGetWorkSize(dst);
}
/**
* Coordinates without task bars / side bars / menu bars.
* Used to avoid positioning popups/tooltips inside this region. If you don't have this info, please copy the value for MainPos/MainSize.
*/
public void setWorkSize(final ImVec2 value) {
nSetWorkSize(value.x, value.y);
}
/**
* Coordinates without task bars / side bars / menu bars.
* Used to avoid positioning popups/tooltips inside this region. If you don't have this info, please copy the value for MainPos/MainSize.
*/
public void setWorkSize(final float valueX, final float valueY) {
nSetWorkSize(valueX, valueY);
}
private native void nGetWorkSize(ImVec2 dst); /*
Jni::ImVec2Cpy(env, THIS->WorkSize, dst);
*/
private native float nGetWorkSizeX(); /*
return THIS->WorkSize.x;
*/
private native float nGetWorkSizeY(); /*
return THIS->WorkSize.y;
*/
private native void nSetWorkSize(float valueX, float valueY); /*MANUAL
ImVec2 value = ImVec2(valueX, valueY);
THIS->WorkSize = value;
*/
/**
* 1.0f = 96 DPI
*/
public float getDpiScale() {
return nGetDpiScale();
}
/**
* 1.0f = 96 DPI
*/
public void setDpiScale(final float value) {
nSetDpiScale(value);
}
private native float nGetDpiScale(); /*
return THIS->DpiScale;
*/
private native void nSetDpiScale(float value); /*
THIS->DpiScale = value;
*/
/*JNI
#undef THIS
*/
}
@@ -0,0 +1,146 @@
package imgui;
import imgui.binding.ImGuiStructDestroyable;
/**
* Helper: Key-Value storage
* Typically you don't have to worry about this since a storage is held within each Window.
* We use it to e.g. store collapse state for a tree (Int 0/1)
* This is optimized for efficient lookup (dichotomy into a contiguous buffer) and rare insertion (typically tied to user interactions aka max once a frame)
* You can use it as custom user storage for temporary values. Declare your own storage if, for example:
* - You want to manipulate the open/close state of a particular sub-tree in your interface (tree node uses Int 0/1 to store their state).
* - You want to store custom debug data easily without adding or editing structures in your code (probably not efficient, but convenient)
* Types are NOT stored, so it is up to you to make sure your Key don't collide with different types.
*/
public final class ImGuiStorage extends ImGuiStructDestroyable {
public ImGuiStorage() {
}
public ImGuiStorage(final long ptr) {
super(ptr);
}
@Override
protected long create() {
return nCreate();
}
/*JNI
#include "_common.h"
#define THIS ((ImGuiStorage*)STRUCT_PTR)
*/
private native long nCreate(); /*
return (intptr_t)(new ImGuiStorage());
*/
// - Get***() functions find pair, never add/allocate. Pairs are sorted so a query is O(log N)
// - Set***() functions find pair, insertion on demand if missing.
// - Sorted insertion is costly, paid once. A typical frame shouldn't need to insert any new pair.
public void clear() {
nClear();
}
private native void nClear(); /*
THIS->Clear();
*/
public int getInt(final int key) {
return nGetInt(key);
}
public int getInt(final int key, final int defaultVal) {
return nGetInt(key, defaultVal);
}
private native int nGetInt(int key); /*
return THIS->GetInt(key);
*/
private native int nGetInt(int key, int defaultVal); /*
return THIS->GetInt(key, defaultVal);
*/
public void setInt(final int key, final int val) {
nSetInt(key, val);
}
private native void nSetInt(int key, int val); /*
THIS->SetInt(key, val);
*/
public boolean getBool(final int key) {
return nGetBool(key);
}
public boolean getBool(final int key, final boolean defaultVal) {
return nGetBool(key, defaultVal);
}
private native boolean nGetBool(int key); /*
return THIS->GetBool(key);
*/
private native boolean nGetBool(int key, boolean defaultVal); /*
return THIS->GetBool(key, defaultVal);
*/
public void setBool(final int key, final boolean val) {
nSetBool(key, val);
}
private native void nSetBool(int key, boolean val); /*
THIS->SetBool(key, val);
*/
public float getFloat(final int key) {
return nGetFloat(key);
}
public float getFloat(final int key, final float defaultVal) {
return nGetFloat(key, defaultVal);
}
private native float nGetFloat(int key); /*
return THIS->GetFloat(key);
*/
private native float nGetFloat(int key, float defaultVal); /*
return THIS->GetFloat(key, defaultVal);
*/
public void setFloat(final int key, final float val) {
nSetFloat(key, val);
}
private native void nSetFloat(int key, float val); /*
THIS->SetFloat(key, val);
*/
/**
* Use on your own storage if you know only integer are being stored (open/close all tree nodes)
*/
public void setAllInt(final int val) {
nSetAllInt(val);
}
private native void nSetAllInt(int val); /*
THIS->SetAllInt(val);
*/
/**
* For quicker full rebuild of a storage (instead of an incremental one), you may add all your contents and then sort once.
*/
public void buildSortByKey() {
nBuildSortByKey();
}
private native void nBuildSortByKey(); /*
THIS->BuildSortByKey();
*/
/*JNI
#undef THIS
*/
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,135 @@
package imgui;
import imgui.binding.ImGuiStructDestroyable;
/**
* Helper: Parse and apply text filters. In format "aaaaa[,bbbb][,ccccc]"
*/
public final class ImGuiTextFilter extends ImGuiStructDestroyable {
public ImGuiTextFilter() {
this("");
}
public ImGuiTextFilter(final String defaultFilter) {
ptr = nCreate(defaultFilter);
}
public ImGuiTextFilter(final long ptr) {
super(ptr);
}
@Override
protected long create() {
return nCreate("");
}
/*JNI
#include "_common.h"
#define THIS ((ImGuiTextFilter*)STRUCT_PTR)
*/
private native long nCreate(String defaultFilter); /*
return (intptr_t)(new ImGuiTextFilter(defaultFilter));
*/
public boolean draw() {
return nDraw();
}
public boolean draw(final String label) {
return nDraw(label);
}
public boolean draw(final String label, final float width) {
return nDraw(label, width);
}
public boolean draw(final float width) {
return nDraw(width);
}
private native boolean nDraw(); /*
return THIS->Draw();
*/
private native boolean nDraw(String obj_label); /*MANUAL
auto label = obj_label == NULL ? NULL : (char*)env->GetStringUTFChars(obj_label, JNI_FALSE);
auto _result = THIS->Draw(label);
if (label != NULL) env->ReleaseStringUTFChars(obj_label, label);
return _result;
*/
private native boolean nDraw(String obj_label, float width); /*MANUAL
auto label = obj_label == NULL ? NULL : (char*)env->GetStringUTFChars(obj_label, JNI_FALSE);
auto _result = THIS->Draw(label, width);
if (label != NULL) env->ReleaseStringUTFChars(obj_label, label);
return _result;
*/
private native boolean nDraw(float width); /*
return THIS->Draw("Filter (inc,-exc)", width);
*/
public boolean passFilter(final String text) {
return nPassFilter(text);
}
private native boolean nPassFilter(String obj_text); /*MANUAL
auto text = obj_text == NULL ? NULL : (char*)env->GetStringUTFChars(obj_text, JNI_FALSE);
auto _result = THIS->PassFilter(text, NULL);
if (text != NULL) env->ReleaseStringUTFChars(obj_text, text);
return _result;
*/
public void build() {
nBuild();
}
private native void nBuild(); /*
THIS->Build();
*/
public void clear() {
nClear();
}
private native void nClear(); /*
THIS->Clear();
*/
public boolean isActive() {
return nIsActive();
}
private native boolean nIsActive(); /*
return THIS->IsActive();
*/
public native String getInputBuffer(); /*
return env->NewStringUTF(THIS->InputBuf);
*/
public native void setInputBuffer(String inputBuf); /*
strncpy(THIS->InputBuf, inputBuf, sizeof(THIS->InputBuf));
*/
public int getCountGrep() {
return nGetCountGrep();
}
public void setCountGrep(final int value) {
nSetCountGrep(value);
}
private native int nGetCountGrep(); /*
return THIS->CountGrep;
*/
private native void nSetCountGrep(int value); /*
THIS->CountGrep = value;
*/
/*JNI
#undef THIS
*/
}
@@ -0,0 +1,593 @@
package imgui;
import imgui.binding.ImGuiStruct;
/**
* The viewports created and managed by Dear ImGui. The role of the platform backend is to create the platform/OS windows corresponding to each viewport.
* - Main Area = entire viewport.
* - Work Area = entire viewport minus sections optionally used by menu bars, status bars. Some positioning code will prefer to use this. Window are also trying to stay within this area.
*/
public final class ImGuiViewport extends ImGuiStruct {
public ImGuiViewport(final long ptr) {
super(ptr);
}
/*JNI
#include "_common.h"
#define THIS ((ImGuiViewport*)STRUCT_PTR)
*/
/**
* Unique identifier for the viewport.
*/
public int getID() {
return nGetID();
}
/**
* Unique identifier for the viewport.
*/
public void setID(final int value) {
nSetID(value);
}
private native int nGetID(); /*
return THIS->ID;
*/
private native void nSetID(int value); /*
THIS->ID = value;
*/
/**
* See {@link imgui.flag.ImGuiViewportFlags}.
*/
public int getFlags() {
return nGetFlags();
}
/**
* See {@link imgui.flag.ImGuiViewportFlags}.
*/
public void setFlags(final int value) {
nSetFlags(value);
}
/**
* See {@link imgui.flag.ImGuiViewportFlags}.
*/
public void addFlags(final int flags) {
setFlags(getFlags() | flags);
}
/**
* See {@link imgui.flag.ImGuiViewportFlags}.
*/
public void removeFlags(final int flags) {
setFlags(getFlags() & ~(flags));
}
/**
* See {@link imgui.flag.ImGuiViewportFlags}.
*/
public boolean hasFlags(final int flags) {
return (getFlags() & flags) != 0;
}
private native int nGetFlags(); /*
return THIS->Flags;
*/
private native void nSetFlags(int value); /*
THIS->Flags = value;
*/
/**
* Main Area: Position of the viewport (the imgui coordinates are the same as OS desktop/native coordinates).
*/
public ImVec2 getPos() {
final ImVec2 dst = new ImVec2();
nGetPos(dst);
return dst;
}
/**
* Main Area: Position of the viewport (the imgui coordinates are the same as OS desktop/native coordinates).
*/
public float getPosX() {
return nGetPosX();
}
/**
* Main Area: Position of the viewport (the imgui coordinates are the same as OS desktop/native coordinates).
*/
public float getPosY() {
return nGetPosY();
}
/**
* Main Area: Position of the viewport (the imgui coordinates are the same as OS desktop/native coordinates).
*/
public void getPos(final ImVec2 dst) {
nGetPos(dst);
}
/**
* Main Area: Position of the viewport (the imgui coordinates are the same as OS desktop/native coordinates).
*/
public void setPos(final ImVec2 value) {
nSetPos(value.x, value.y);
}
/**
* Main Area: Position of the viewport (the imgui coordinates are the same as OS desktop/native coordinates).
*/
public void setPos(final float valueX, final float valueY) {
nSetPos(valueX, valueY);
}
private native void nGetPos(ImVec2 dst); /*
Jni::ImVec2Cpy(env, THIS->Pos, dst);
*/
private native float nGetPosX(); /*
return THIS->Pos.x;
*/
private native float nGetPosY(); /*
return THIS->Pos.y;
*/
private native void nSetPos(float valueX, float valueY); /*MANUAL
ImVec2 value = ImVec2(valueX, valueY);
THIS->Pos = value;
*/
/**
* Main Area: Size of the viewport.
*/
public ImVec2 getSize() {
final ImVec2 dst = new ImVec2();
nGetSize(dst);
return dst;
}
/**
* Main Area: Size of the viewport.
*/
public float getSizeX() {
return nGetSizeX();
}
/**
* Main Area: Size of the viewport.
*/
public float getSizeY() {
return nGetSizeY();
}
/**
* Main Area: Size of the viewport.
*/
public void getSize(final ImVec2 dst) {
nGetSize(dst);
}
/**
* Main Area: Size of the viewport.
*/
public void setSize(final ImVec2 value) {
nSetSize(value.x, value.y);
}
/**
* Main Area: Size of the viewport.
*/
public void setSize(final float valueX, final float valueY) {
nSetSize(valueX, valueY);
}
private native void nGetSize(ImVec2 dst); /*
Jni::ImVec2Cpy(env, THIS->Size, dst);
*/
private native float nGetSizeX(); /*
return THIS->Size.x;
*/
private native float nGetSizeY(); /*
return THIS->Size.y;
*/
private native void nSetSize(float valueX, float valueY); /*MANUAL
ImVec2 value = ImVec2(valueX, valueY);
THIS->Size = value;
*/
/**
* Work Area: Position of the viewport minus task bars, menus bars, status bars.
*/
public ImVec2 getWorkPos() {
final ImVec2 dst = new ImVec2();
nGetWorkPos(dst);
return dst;
}
/**
* Work Area: Position of the viewport minus task bars, menus bars, status bars.
*/
public float getWorkPosX() {
return nGetWorkPosX();
}
/**
* Work Area: Position of the viewport minus task bars, menus bars, status bars.
*/
public float getWorkPosY() {
return nGetWorkPosY();
}
/**
* Work Area: Position of the viewport minus task bars, menus bars, status bars.
*/
public void getWorkPos(final ImVec2 dst) {
nGetWorkPos(dst);
}
/**
* Work Area: Position of the viewport minus task bars, menus bars, status bars.
*/
public void setWorkPos(final ImVec2 value) {
nSetWorkPos(value.x, value.y);
}
/**
* Work Area: Position of the viewport minus task bars, menus bars, status bars.
*/
public void setWorkPos(final float valueX, final float valueY) {
nSetWorkPos(valueX, valueY);
}
private native void nGetWorkPos(ImVec2 dst); /*
Jni::ImVec2Cpy(env, THIS->WorkPos, dst);
*/
private native float nGetWorkPosX(); /*
return THIS->WorkPos.x;
*/
private native float nGetWorkPosY(); /*
return THIS->WorkPos.y;
*/
private native void nSetWorkPos(float valueX, float valueY); /*MANUAL
ImVec2 value = ImVec2(valueX, valueY);
THIS->WorkPos = value;
*/
/**
* Work Area: Size of the viewport minus task bars, menu bars, status bars.
*/
public ImVec2 getWorkSize() {
final ImVec2 dst = new ImVec2();
nGetWorkSize(dst);
return dst;
}
/**
* Work Area: Size of the viewport minus task bars, menu bars, status bars.
*/
public float getWorkSizeX() {
return nGetWorkSizeX();
}
/**
* Work Area: Size of the viewport minus task bars, menu bars, status bars.
*/
public float getWorkSizeY() {
return nGetWorkSizeY();
}
/**
* Work Area: Size of the viewport minus task bars, menu bars, status bars.
*/
public void getWorkSize(final ImVec2 dst) {
nGetWorkSize(dst);
}
/**
* Work Area: Size of the viewport minus task bars, menu bars, status bars.
*/
public void setWorkSize(final ImVec2 value) {
nSetWorkSize(value.x, value.y);
}
/**
* Work Area: Size of the viewport minus task bars, menu bars, status bars.
*/
public void setWorkSize(final float valueX, final float valueY) {
nSetWorkSize(valueX, valueY);
}
private native void nGetWorkSize(ImVec2 dst); /*
Jni::ImVec2Cpy(env, THIS->WorkSize, dst);
*/
private native float nGetWorkSizeX(); /*
return THIS->WorkSize.x;
*/
private native float nGetWorkSizeY(); /*
return THIS->WorkSize.y;
*/
private native void nSetWorkSize(float valueX, float valueY); /*MANUAL
ImVec2 value = ImVec2(valueX, valueY);
THIS->WorkSize = value;
*/
/**
* 1.0f = 96 DPI = No extra scale.
*/
public float getDpiScale() {
return nGetDpiScale();
}
/**
* 1.0f = 96 DPI = No extra scale.
*/
public void setDpiScale(final float value) {
nSetDpiScale(value);
}
private native float nGetDpiScale(); /*
return THIS->DpiScale;
*/
private native void nSetDpiScale(float value); /*
THIS->DpiScale = value;
*/
/**
* (Advanced) 0: no parent. Instruct the platform backend to setup a parent/child relationship between platform windows.
*/
public int getParentViewportId() {
return nGetParentViewportId();
}
/**
* (Advanced) 0: no parent. Instruct the platform backend to setup a parent/child relationship between platform windows.
*/
public void setParentViewportId(final int value) {
nSetParentViewportId(value);
}
private native int nGetParentViewportId(); /*
return THIS->ParentViewportId;
*/
private native void nSetParentViewportId(int value); /*
THIS->ParentViewportId = value;
*/
/**
* The ImDrawData corresponding to this viewport. Valid after Render() and until the next call to NewFrame().
*/
public ImDrawData getDrawData() {
return new ImDrawData(nGetDrawData());
}
/**
* The ImDrawData corresponding to this viewport. Valid after Render() and until the next call to NewFrame().
*/
public void setDrawData(final ImDrawData value) {
nSetDrawData(value.ptr);
}
private native long nGetDrawData(); /*
return (intptr_t)THIS->DrawData;
*/
private native void nSetDrawData(long value); /*
THIS->DrawData = reinterpret_cast<ImDrawData*>(value);
*/
// Our design separate the Renderer and Platform backends to facilitate combining default backends with each others.
// When our create your own backend for a custom engine, it is possible that both Renderer and Platform will be handled
// by the same system and you may not need to use all the UserData/Handle fields.
// The library never uses those fields, they are merely storage to facilitate backend implementation.
/**
* void* to hold custom data structure for the renderer (e.g. swap chain, framebuffers etc.). generally set by your Renderer_CreateWindow function.
*/
public native void setRendererUserData(Object data); /*
if (THIS->RendererUserData != NULL) {
env->DeleteGlobalRef((jobject)THIS->RendererUserData);
}
THIS->RendererUserData = (data == NULL ? NULL : (void*)env->NewGlobalRef(data));
*/
/**
* void* to hold custom data structure for the renderer (e.g. swap chain, framebuffers etc.). generally set by your Renderer_CreateWindow function.
*/
public native Object getRendererUserData(); /*
return (jobject)THIS->RendererUserData;
*/
/**
* void* to hold custom data structure for the OS / platform (e.g. windowing info, render context). generally set by your Platform_CreateWindow function.
*/
public native void setPlatformUserData(Object data); /*
if (THIS->PlatformUserData != NULL) {
env->DeleteGlobalRef((jobject)THIS->PlatformUserData);
}
THIS->PlatformUserData = (data == NULL ? NULL : (void*)env->NewGlobalRef(data));
*/
/**
* void* to hold custom data structure for the OS / platform (e.g. windowing info, render context). generally set by your Platform_CreateWindow function.
*/
public native Object getPlatformUserData(); /*
return (jobject)THIS->PlatformUserData;
*/
/**
* void* for FindViewportByPlatformHandle(). (e.g. suggested to use natural platform handle such as HWND, GLFWWindow*, SDL_Window*)
*/
public native void setPlatformHandle(long data); /*
THIS->PlatformHandle = (void*)data;
*/
/**
* void* for FindViewportByPlatformHandle(). (e.g. suggested to use natural platform handle such as HWND, GLFWWindow*, SDL_Window*)
*/
public native long getPlatformHandle(); /*
return (intptr_t)THIS->PlatformHandle;
*/
/**
* void* to hold lower-level, platform-native window handle (e.g. the HWND) when using an abstraction layer like GLFW or SDL (where PlatformHandle would be a SDL_Window*)
*/
public native void setPlatformHandleRaw(long data); /*
THIS->PlatformHandleRaw = (void*)data;
*/
/**
* void* to hold lower-level, platform-native window handle (e.g. the HWND) when using an abstraction layer like GLFW or SDL (where PlatformHandle would be a SDL_Window*)
*/
public native long getPlatformHandleRaw(); /*
return (intptr_t)THIS->PlatformHandleRaw;
*/
/**
* Platform window requested move (e.g. window was moved by the OS / host window manager, authoritative position will be OS window position).
*/
public boolean getPlatformRequestMove() {
return nGetPlatformRequestMove();
}
/**
* Platform window requested move (e.g. window was moved by the OS / host window manager, authoritative position will be OS window position).
*/
public void setPlatformRequestMove(final boolean value) {
nSetPlatformRequestMove(value);
}
private native boolean nGetPlatformRequestMove(); /*
return THIS->PlatformRequestMove;
*/
private native void nSetPlatformRequestMove(boolean value); /*
THIS->PlatformRequestMove = value;
*/
/**
* Platform window requested resize (e.g. window was resized by the OS / host window manager, authoritative size will be OS window size).
*/
public boolean getPlatformRequestResize() {
return nGetPlatformRequestResize();
}
/**
* Platform window requested resize (e.g. window was resized by the OS / host window manager, authoritative size will be OS window size).
*/
public void setPlatformRequestResize(final boolean value) {
nSetPlatformRequestResize(value);
}
private native boolean nGetPlatformRequestResize(); /*
return THIS->PlatformRequestResize;
*/
private native void nSetPlatformRequestResize(boolean value); /*
THIS->PlatformRequestResize = value;
*/
/**
* Platform window requested closure (e.g. window was moved by the OS / host window manager, e.g. pressing ALT-F4).
*/
public boolean getPlatformRequestClose() {
return nGetPlatformRequestClose();
}
/**
* Platform window requested closure (e.g. window was moved by the OS / host window manager, e.g. pressing ALT-F4).
*/
public void setPlatformRequestClose(final boolean value) {
nSetPlatformRequestClose(value);
}
private native boolean nGetPlatformRequestClose(); /*
return THIS->PlatformRequestClose;
*/
private native void nSetPlatformRequestClose(boolean value); /*
THIS->PlatformRequestClose = value;
*/
// Helpers
public ImVec2 getCenter() {
final ImVec2 dst = new ImVec2();
nGetCenter(dst);
return dst;
}
public float getCenterX() {
return nGetCenterX();
}
public float getCenterY() {
return nGetCenterY();
}
public void getCenter(final ImVec2 dst) {
nGetCenter(dst);
}
private native void nGetCenter(ImVec2 dst); /*
Jni::ImVec2Cpy(env, THIS->GetCenter(), dst);
*/
private native float nGetCenterX(); /*
return THIS->GetCenter().x;
*/
private native float nGetCenterY(); /*
return THIS->GetCenter().y;
*/
public ImVec2 getWorkCenter() {
final ImVec2 dst = new ImVec2();
nGetWorkCenter(dst);
return dst;
}
public float getWorkCenterX() {
return nGetWorkCenterX();
}
public float getWorkCenterY() {
return nGetWorkCenterY();
}
public void getWorkCenter(final ImVec2 dst) {
nGetWorkCenter(dst);
}
private native void nGetWorkCenter(ImVec2 dst); /*
Jni::ImVec2Cpy(env, THIS->GetWorkCenter(), dst);
*/
private native float nGetWorkCenterX(); /*
return THIS->GetWorkCenter().x;
*/
private native float nGetWorkCenterY(); /*
return THIS->GetWorkCenter().y;
*/
/*JNI
#undef THIS
*/
}
@@ -0,0 +1,318 @@
package imgui;
import imgui.binding.ImGuiStructDestroyable;
/**
* [ALPHA] Rarely used / very advanced uses only. Use with SetNextWindowClass() and DockSpace() functions.
* Important: the content of this class is still highly WIP and likely to change and be refactored
* before we stabilize Docking features. Please be mindful if using this.
* Provide hints:
* - To the platform backend via altered viewport flags (enable/disable OS decoration, OS task bar icons, etc.)
* - To the platform backend for OS level parent/child relationships of viewport.
* - To the docking system for various options and filtering.
*/
public final class ImGuiWindowClass extends ImGuiStructDestroyable {
public ImGuiWindowClass() {
}
public ImGuiWindowClass(final long ptr) {
super(ptr);
}
@Override
protected long create() {
return nCreate();
}
/*JNI
#include "_common.h"
#define THIS ((ImGuiWindowClass*)STRUCT_PTR)
*/
private native long nCreate(); /*
return (intptr_t)(new ImGuiWindowClass());
*/
/**
* User data. 0 = Default class (unclassed). Windows of different classes cannot be docked with each others.
*/
public int getClassId() {
return nGetClassId();
}
/**
* User data. 0 = Default class (unclassed). Windows of different classes cannot be docked with each others.
*/
public void setClassId(final int value) {
nSetClassId(value);
}
private native int nGetClassId(); /*
return THIS->ClassId;
*/
private native void nSetClassId(int value); /*
THIS->ClassId = value;
*/
/**
* Hint for the platform backend. If non-zero, the platform backend can create a parent{@code <>}child relationship between the platform windows.
* Not conforming backends are free to e.g. parent every viewport to the main viewport or not.
*/
public int getParentViewportId() {
return nGetParentViewportId();
}
/**
* Hint for the platform backend. If non-zero, the platform backend can create a parent{@code <>}child relationship between the platform windows.
* Not conforming backends are free to e.g. parent every viewport to the main viewport or not.
*/
public void setParentViewportId(final int value) {
nSetParentViewportId(value);
}
private native int nGetParentViewportId(); /*
return THIS->ParentViewportId;
*/
private native void nSetParentViewportId(int value); /*
THIS->ParentViewportId = value;
*/
/**
* Viewport flags to set when a window of this class owns a viewport.
* This allows you to enforce OS decoration or task bar icon, override the defaults on a per-window basis.
*/
public int getViewportFlagsOverrideSet() {
return nGetViewportFlagsOverrideSet();
}
/**
* Viewport flags to set when a window of this class owns a viewport.
* This allows you to enforce OS decoration or task bar icon, override the defaults on a per-window basis.
*/
public void setViewportFlagsOverrideSet(final int value) {
nSetViewportFlagsOverrideSet(value);
}
/**
* Viewport flags to set when a window of this class owns a viewport.
* This allows you to enforce OS decoration or task bar icon, override the defaults on a per-window basis.
*/
public void addViewportFlagsOverrideSet(final int flags) {
setViewportFlagsOverrideSet(getViewportFlagsOverrideSet() | flags);
}
/**
* Viewport flags to set when a window of this class owns a viewport.
* This allows you to enforce OS decoration or task bar icon, override the defaults on a per-window basis.
*/
public void removeViewportFlagsOverrideSet(final int flags) {
setViewportFlagsOverrideSet(getViewportFlagsOverrideSet() & ~(flags));
}
/**
* Viewport flags to set when a window of this class owns a viewport.
* This allows you to enforce OS decoration or task bar icon, override the defaults on a per-window basis.
*/
public boolean hasViewportFlagsOverrideSet(final int flags) {
return (getViewportFlagsOverrideSet() & flags) != 0;
}
private native int nGetViewportFlagsOverrideSet(); /*
return THIS->ViewportFlagsOverrideSet;
*/
private native void nSetViewportFlagsOverrideSet(int value); /*
THIS->ViewportFlagsOverrideSet = value;
*/
/**
* Viewport flags to clear when a window of this class owns a viewport.
* This allows you to enforce OS decoration or task bar icon, override the defaults on a per-window basis.
*/
public int getViewportFlagsOverrideClear() {
return nGetViewportFlagsOverrideClear();
}
/**
* Viewport flags to clear when a window of this class owns a viewport.
* This allows you to enforce OS decoration or task bar icon, override the defaults on a per-window basis.
*/
public void setViewportFlagsOverrideClear(final int value) {
nSetViewportFlagsOverrideClear(value);
}
/**
* Viewport flags to clear when a window of this class owns a viewport.
* This allows you to enforce OS decoration or task bar icon, override the defaults on a per-window basis.
*/
public void addViewportFlagsOverrideClear(final int flags) {
setViewportFlagsOverrideClear(getViewportFlagsOverrideClear() | flags);
}
/**
* Viewport flags to clear when a window of this class owns a viewport.
* This allows you to enforce OS decoration or task bar icon, override the defaults on a per-window basis.
*/
public void removeViewportFlagsOverrideClear(final int flags) {
setViewportFlagsOverrideClear(getViewportFlagsOverrideClear() & ~(flags));
}
/**
* Viewport flags to clear when a window of this class owns a viewport.
* This allows you to enforce OS decoration or task bar icon, override the defaults on a per-window basis.
*/
public boolean hasViewportFlagsOverrideClear(final int flags) {
return (getViewportFlagsOverrideClear() & flags) != 0;
}
private native int nGetViewportFlagsOverrideClear(); /*
return THIS->ViewportFlagsOverrideClear;
*/
private native void nSetViewportFlagsOverrideClear(int value); /*
THIS->ViewportFlagsOverrideClear = value;
*/
/**
* [EXPERIMENTAL] TabItem flags to set when a window of this class gets submitted into a dock node tab bar.
* May use with ImGuiTabItemFlags_Leading or ImGuiTabItemFlags_Trailing.
*/
public int getTabItemFlagsOverrideSet() {
return nGetTabItemFlagsOverrideSet();
}
/**
* [EXPERIMENTAL] TabItem flags to set when a window of this class gets submitted into a dock node tab bar.
* May use with ImGuiTabItemFlags_Leading or ImGuiTabItemFlags_Trailing.
*/
public void setTabItemFlagsOverrideSet(final int value) {
nSetTabItemFlagsOverrideSet(value);
}
/**
* [EXPERIMENTAL] TabItem flags to set when a window of this class gets submitted into a dock node tab bar.
* May use with ImGuiTabItemFlags_Leading or ImGuiTabItemFlags_Trailing.
*/
public void addTabItemFlagsOverrideSet(final int flags) {
setTabItemFlagsOverrideSet(getTabItemFlagsOverrideSet() | flags);
}
/**
* [EXPERIMENTAL] TabItem flags to set when a window of this class gets submitted into a dock node tab bar.
* May use with ImGuiTabItemFlags_Leading or ImGuiTabItemFlags_Trailing.
*/
public void removeTabItemFlagsOverrideSet(final int flags) {
setTabItemFlagsOverrideSet(getTabItemFlagsOverrideSet() & ~(flags));
}
/**
* [EXPERIMENTAL] TabItem flags to set when a window of this class gets submitted into a dock node tab bar.
* May use with ImGuiTabItemFlags_Leading or ImGuiTabItemFlags_Trailing.
*/
public boolean hasTabItemFlagsOverrideSet(final int flags) {
return (getTabItemFlagsOverrideSet() & flags) != 0;
}
private native int nGetTabItemFlagsOverrideSet(); /*
return THIS->TabItemFlagsOverrideSet;
*/
private native void nSetTabItemFlagsOverrideSet(int value); /*
THIS->TabItemFlagsOverrideSet = value;
*/
/**
* [EXPERIMENTAL] Dock node flags to set when a window of this class is hosted by a dock node (it doesn't have to be selected!)
*/
public int getDockNodeFlagsOverrideSet() {
return nGetDockNodeFlagsOverrideSet();
}
/**
* [EXPERIMENTAL] Dock node flags to set when a window of this class is hosted by a dock node (it doesn't have to be selected!)
*/
public void setDockNodeFlagsOverrideSet(final int value) {
nSetDockNodeFlagsOverrideSet(value);
}
/**
* [EXPERIMENTAL] Dock node flags to set when a window of this class is hosted by a dock node (it doesn't have to be selected!)
*/
public void addDockNodeFlagsOverrideSet(final int flags) {
setDockNodeFlagsOverrideSet(getDockNodeFlagsOverrideSet() | flags);
}
/**
* [EXPERIMENTAL] Dock node flags to set when a window of this class is hosted by a dock node (it doesn't have to be selected!)
*/
public void removeDockNodeFlagsOverrideSet(final int flags) {
setDockNodeFlagsOverrideSet(getDockNodeFlagsOverrideSet() & ~(flags));
}
/**
* [EXPERIMENTAL] Dock node flags to set when a window of this class is hosted by a dock node (it doesn't have to be selected!)
*/
public boolean hasDockNodeFlagsOverrideSet(final int flags) {
return (getDockNodeFlagsOverrideSet() & flags) != 0;
}
private native int nGetDockNodeFlagsOverrideSet(); /*
return THIS->DockNodeFlagsOverrideSet;
*/
private native void nSetDockNodeFlagsOverrideSet(int value); /*
THIS->DockNodeFlagsOverrideSet = value;
*/
/**
* Set to true to enforce single floating windows of this class always having their own docking node
* (equivalent of setting the global io.ConfigDockingAlwaysTabBar)
*/
public boolean getDockingAlwaysTabBar() {
return nGetDockingAlwaysTabBar();
}
/**
* Set to true to enforce single floating windows of this class always having their own docking node
* (equivalent of setting the global io.ConfigDockingAlwaysTabBar)
*/
public void setDockingAlwaysTabBar(final boolean value) {
nSetDockingAlwaysTabBar(value);
}
private native boolean nGetDockingAlwaysTabBar(); /*
return THIS->DockingAlwaysTabBar;
*/
private native void nSetDockingAlwaysTabBar(boolean value); /*
THIS->DockingAlwaysTabBar = value;
*/
/**
* Set to true to allow windows of this class to be docked/merged with an unclassed window.
*/
public boolean getDockingAllowUnclassed() {
return nGetDockingAllowUnclassed();
}
/**
* Set to true to allow windows of this class to be docked/merged with an unclassed window.
*/
public void setDockingAllowUnclassed(final boolean value) {
nSetDockingAllowUnclassed(value);
}
private native boolean nGetDockingAllowUnclassed(); /*
return THIS->DockingAllowUnclassed;
*/
private native void nSetDockingAllowUnclassed(boolean value); /*
THIS->DockingAllowUnclassed = value;
*/
/*JNI
#undef THIS
*/
}
@@ -0,0 +1,93 @@
package imgui;
import java.util.Objects;
/**
* 2D vector (often used to store positions or sizes).
*/
public final class ImVec2 implements Cloneable {
public float x;
public float y;
public ImVec2() {
}
public ImVec2(final float x, final float y) {
set(x, y);
}
public ImVec2(final ImVec2 value) {
set(value.x, value.y);
}
public ImVec2 set(final float x, final float y) {
this.x = x;
this.y = y;
return this;
}
public ImVec2 set(final ImVec2 value) {
return set(value.x, value.y);
}
public ImVec2 plus(final float x, final float y) {
this.x += x;
this.y += y;
return this;
}
public ImVec2 plus(final ImVec2 value) {
return plus(value.x, value.y);
}
public ImVec2 minus(final float x, final float y) {
this.x -= x;
this.y -= y;
return this;
}
public ImVec2 minus(final ImVec2 value) {
return minus(value.x, value.y);
}
public ImVec2 times(final float x, final float y) {
this.x *= x;
this.y *= y;
return this;
}
public ImVec2 times(final ImVec2 value) {
return times(value.x, value.y);
}
@Override
public String toString() {
return "ImVec2{"
+ "x=" + x
+ ", y=" + y
+ '}';
}
@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
final ImVec2 imVec2 = (ImVec2) o;
return Float.compare(imVec2.x, x) == 0 && Float.compare(imVec2.y, y) == 0;
}
@Override
public int hashCode() {
return Objects.hash(x, y);
}
@Override
@SuppressWarnings("MethodDoesntCallSuperMethod")
public ImVec2 clone() {
return new ImVec2(this);
}
}
@@ -0,0 +1,105 @@
package imgui;
import java.util.Objects;
/**
* 4D vector (often used to store floating-point colors).
*/
public final class ImVec4 implements Cloneable {
public float x;
public float y;
public float z;
public float w;
public ImVec4() {
}
public ImVec4(final float x, final float y, final float z, final float w) {
set(x, y, z, w);
}
public ImVec4(final ImVec4 value) {
set(value.x, value.y, value.z, value.w);
}
public ImVec4 set(final float x, final float y, final float z, final float w) {
this.x = x;
this.y = y;
this.z = z;
this.w = w;
return this;
}
public ImVec4 set(final ImVec4 value) {
return set(value.x, value.y, value.z, value.w);
}
public ImVec4 plus(final float x, final float y, final float z, final float w) {
this.x += x;
this.y += y;
this.z += z;
this.w += w;
return this;
}
public ImVec4 plus(final ImVec4 value) {
return plus(value.x, value.y, value.z, value.w);
}
public ImVec4 minus(final float x, final float y, final float z, final float w) {
this.x -= x;
this.y -= y;
this.z -= z;
this.w -= w;
return this;
}
public ImVec4 minus(final ImVec4 value) {
return minus(value.x, value.y, value.z, value.w);
}
public ImVec4 times(final float x, final float y, final float z, final float w) {
this.x *= x;
this.y *= y;
this.z *= z;
this.w *= w;
return this;
}
public ImVec4 times(final ImVec4 value) {
return times(value.x, value.y, value.z, value.w);
}
@Override
public String toString() {
return "ImVec4{"
+ "x=" + x
+ ", y=" + y
+ ", z=" + z
+ ", w=" + w
+ '}';
}
@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
final ImVec4 imVec4 = (ImVec4) o;
return Float.compare(imVec4.x, x) == 0 && Float.compare(imVec4.y, y) == 0 && Float.compare(imVec4.z, z) == 0 && Float.compare(imVec4.w, w) == 0;
}
@Override
public int hashCode() {
return Objects.hash(x, y, z, w);
}
@Override
@SuppressWarnings("MethodDoesntCallSuperMethod")
public ImVec4 clone() {
return new ImVec4(this);
}
}
@@ -0,0 +1,45 @@
package imgui.assertion;
/**
* Callback for native IM_ASSERT calls.
*/
public abstract class ImAssertCallback {
/**
* Called from native code to bring the callback into java side.
* Will force the application to terminate with exit code 1 after forwarding the callback, this is required, otherwise
* if execution is returned to the native layer, a EXCEPTION_ACCESS_VIOLATION will be thrown.
* If the callback throws an exception, it will be caught and printed along with a warning to prevent execution
* from returning to the native layer.
*
* @param assertion The assertion string
* @param line The line number of the assertion in the source file
* @param file The source file where the assertion occurred
*/
public void imAssert(final String assertion, final int line, final String file) {
try {
imAssertCallback(assertion, line, file);
} catch (Exception ex) {
System.err.println("WARNING: Exception thrown in Dear ImGui Assertion Callback!");
System.err.println("Dear ImGui Assertion Failed: " + assertion);
System.err.println("Assertion Located At: " + file + ":" + line);
ex.printStackTrace();
}
System.exit(1);
}
/**
* The assertion callback from ImGui.
* Do not throw an exception within this callback, to prevent
* execution from returned to the native layer and cause a EXCEPTION_ACCESS_VIOLATION,
* the callback will catch any exceptions and print a warning.
* <p>
* There is no way to catch the assertion and continue execution.
* You may however call <code>System.exit(code)</code> with your own exit code.
*
* @param assertion The assertion string
* @param line The line number of the assertion in the source file
* @param file The source file where the assertion occurred
*/
public abstract void imAssertCallback(String assertion, int line, String file);
}
@@ -0,0 +1,38 @@
package imgui.binding;
import imgui.ImGui;
/**
* Class provides a communication layer between binding and Dear ImGui library through the "pointer" field.
*/
public abstract class ImGuiStruct {
/**
* Pointer to the natively allocated object.
* Could be zero if JNI returned NULL instead of the real object.
* For such cases methods {@link #isValidPtr()} and {@link #isNotValidPtr()} could be used to verify that object points to the real object.
*/
public long ptr;
public ImGuiStruct(final long ptr) {
ImGui.init();
this.ptr = ptr;
}
/**
* Shows if object pointer is valid and does it point to the existing object.
*
* @return true, if pointer is valid
*/
public final boolean isValidPtr() {
return ptr != 0;
}
/**
* Shows if object pointer is valid and does it point to the existing object.
*
* @return true, if pointer is invalid
*/
public final boolean isNotValidPtr() {
return !isValidPtr();
}
}
@@ -0,0 +1,31 @@
package imgui.binding;
/**
* Class extends {@link ImGuiStruct} and provides additional API to allocated and de-allocate native objects.
*/
public abstract class ImGuiStructDestroyable extends ImGuiStruct {
/**
* Constructor, which creates natively allocated struct. Those structs should be manually disposed with {@link #destroy()} method.
*/
public ImGuiStructDestroyable() {
this(0);
ptr = create();
}
public ImGuiStructDestroyable(final long ptr) {
super(ptr);
}
protected abstract long create();
/**
* Method to free natively allocated memory for the struct mapped with pointer.
*/
public void destroy() {
nDestroy(ptr);
}
private native void nDestroy(long ptr); /*
delete (void*)ptr;
*/
}
@@ -0,0 +1,17 @@
package imgui.callback;
import imgui.ImGuiInputTextCallbackData;
import java.util.function.Consumer;
/**
* Callback to use in {@link imgui.ImGui#inputText(String, imgui.type.ImString, int, ImGuiInputTextCallback)}.
*/
public abstract class ImGuiInputTextCallback implements Consumer<ImGuiInputTextCallbackData> {
/**
* This function will be called by the native Callback and wrapped.
*/
public final void accept(final long ptr) {
accept(new ImGuiInputTextCallbackData(ptr));
}
}
@@ -0,0 +1,8 @@
package imgui.callback;
/**
* Callback for {@link imgui.ImGuiListClipper} class.
*/
public abstract class ImListClipperCallback {
public abstract void accept(int index);
}
@@ -0,0 +1,10 @@
package imgui.callback;
import imgui.ImGuiViewport;
/**
* Callback to represent ImGuiPlatformIO function with args: (ImGuiViewport*)
*/
public abstract class ImPlatformFuncViewport {
public abstract void accept(ImGuiViewport vp);
}
@@ -0,0 +1,10 @@
package imgui.callback;
import imgui.ImGuiViewport;
/**
* Callback to represent ImGuiPlatformIO function with args: (ImGuiViewport*, String)
*/
public abstract class ImPlatformFuncViewportFloat {
public abstract void accept(ImGuiViewport vp, float f);
}
@@ -0,0 +1,11 @@
package imgui.callback;
import imgui.ImGuiViewport;
import imgui.ImVec2;
/**
* Callback to represent ImGuiPlatformIO function with args: (ImGuiViewport*, ImVec2)
*/
public abstract class ImPlatformFuncViewportImVec2 {
public abstract void accept(ImGuiViewport vp, ImVec2 imVec2);
}
@@ -0,0 +1,10 @@
package imgui.callback;
import imgui.ImGuiViewport;
/**
* Callback to represent ImGuiPlatformIO function with args: (ImGuiViewport*, String)
*/
public abstract class ImPlatformFuncViewportString {
public abstract void accept(ImGuiViewport vp, String str);
}
@@ -0,0 +1,10 @@
package imgui.callback;
import imgui.ImGuiViewport;
/**
* Callback to represent ImGuiPlatformIO function with args: (ImGuiViewport*) - Boolean
*/
public abstract class ImPlatformFuncViewportSuppBoolean {
public abstract boolean get(ImGuiViewport vp);
}
@@ -0,0 +1,10 @@
package imgui.callback;
import imgui.ImGuiViewport;
/**
* Callback to represent ImGuiPlatformIO function with args: (ImGuiViewport*) - Boolean
*/
public abstract class ImPlatformFuncViewportSuppFloat {
public abstract float get(ImGuiViewport vp);
}
@@ -0,0 +1,11 @@
package imgui.callback;
import imgui.ImGuiViewport;
import imgui.ImVec2;
/**
* Callback to represent ImGuiPlatformIO function with args: (ImGuiViewport*) - ImVec2
*/
public abstract class ImPlatformFuncViewportSuppImVec2 {
public abstract void get(ImGuiViewport vp, ImVec2 dstImVec2);
}
@@ -0,0 +1,8 @@
package imgui.callback;
/**
* Callback to supply Java string form native code.
*/
public abstract class ImStrConsumer {
public abstract void accept(String str);
}
@@ -0,0 +1,8 @@
package imgui.callback;
/**
* Callback to get Java string from native code.
*/
public abstract class ImStrSupplier {
public abstract String get();
}
@@ -0,0 +1,5 @@
package imgui.extension.imguifiledialog.callback;
public abstract class ImGuiFileDialogPaneFun {
public abstract void accept(String filter, long userDatas, boolean canContinue);
}
@@ -0,0 +1,59 @@
package imgui.extension.imguifiledialog.flag;
public final class ImGuiFileDialogFlags {
private ImGuiFileDialogFlags() {
}
/**
* Definition: {@code 0}
*/
public static final int None = 0;
/**
* show confirm to overwrite dialog
*
* <p>Definition: {@code (1 << 0)}
*/
public static final int ConfirmOverwrite = 1;
/**
* dont show hidden file (file starting with a .)
*
* <p>Definition: {@code (1 << 1)}
*/
public static final int DontShowHiddenFiles = 2;
/**
* disable the create directory button
*
* <p>Definition: {@code (1 << 2)}
*/
public static final int DisableCreateDirectoryButton = 4;
/**
* hide column file type
*
* <p>Definition: {@code (1 << 3)}
*/
public static final int HideColumnType = 8;
/**
* hide column file size
*
* <p>Definition: {@code (1 << 4)}
*/
public static final int HideColumnSize = 16;
/**
* hide column file date
*
* <p>Definition: {@code (1 << 5)}
*/
public static final int HideColumnDate = 32;
/**
* Definition: {@code ImGuiFileDialogFlags_ConfirmOverwrite}
*/
public static final int Default = 1;
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,29 @@
package imgui.extension.imguiknobs.flag;
public final class ImGuiKnobFlags {
private ImGuiKnobFlags() {
}
public static final int None = 0;
/**
* Definition: {@code 1 << 0}
*/
public static final int NoTitle = 1;
/**
* Definition: {@code 1 << 1}
*/
public static final int NoInput = 2;
/**
* Definition: {@code 1 << 2}
*/
public static final int ValueTooltip = 4;
/**
* Definition: {@code 1 << 3}
*/
public static final int DragHorizontal = 8;
}
@@ -0,0 +1,42 @@
package imgui.extension.imguiknobs.flag;
public final class ImGuiKnobVariant {
private ImGuiKnobVariant() {
}
/**
* Definition: {@code 1 << 0}
*/
public static final int Tick = 1;
/**
* Definition: {@code 1 << 1}
*/
public static final int Dot = 2;
/**
* Definition: {@code 1 << 2}
*/
public static final int Wiper = 4;
/**
* Definition: {@code 1 << 3}
*/
public static final int WiperOnly = 8;
/**
* Definition: {@code 1 << 4}
*/
public static final int WiperDot = 16;
/**
* Definition: {@code 1 << 5}
*/
public static final int Stepped = 32;
/**
* Definition: {@code 1 << 6}
*/
public static final int Space = 64;
}
@@ -0,0 +1,542 @@
package imgui.extension.imguizmo;
import imgui.ImDrawList;
import imgui.ImVec2;
import imgui.internal.ImGuiContext;
public final class ImGuizmo {
private ImGuizmo() {
}
/*JNI
#include "_imguizmo.h"
*/
/**
* Call inside your own window and before Manipulate() in order to draw gizmo to that window.
* Or pass a specific ImDrawList to draw to (e.g. ImGui::GetForegroundDrawList()).
*/
public static void setDrawList() {
nSetDrawList();
}
/**
* Call inside your own window and before Manipulate() in order to draw gizmo to that window.
* Or pass a specific ImDrawList to draw to (e.g. ImGui::GetForegroundDrawList()).
*/
public static void setDrawList(final ImDrawList drawList) {
nSetDrawList(drawList.ptr);
}
private static native void nSetDrawList(); /*
ImGuizmo::SetDrawlist();
*/
private static native void nSetDrawList(long drawList); /*
ImGuizmo::SetDrawlist(reinterpret_cast<ImDrawList*>(drawList));
*/
/**
* Call BeginFrame right after ImGui_XXXX_NewFrame();
*/
public static void beginFrame() {
nBeginFrame();
}
private static native void nBeginFrame(); /*
ImGuizmo::BeginFrame();
*/
/**
* This is necessary because when imguizmo is compiled into a dll, and imgui into another
* Globals are not shared between them.
* More details at https://stackoverflow.com/questions/19373061/what-happens-to-global-and-static-variables-in-a-shared-library-when-it-is-dynam
* Expose method to set imgui context
*/
public static void setImGuiContext(final ImGuiContext ctx) {
nSetImGuiContext(ctx.ptr);
}
private static native void nSetImGuiContext(long ctx); /*
ImGuizmo::SetImGuiContext(reinterpret_cast<ImGuiContext*>(ctx));
*/
/**
* Return true if mouse cursor is over any gizmo control (axis, plan or screen component)
*/
public static boolean isOver() {
return nIsOver();
}
private static native boolean nIsOver(); /*
return ImGuizmo::IsOver();
*/
/**
* Return true if mouse IsOver or if the gizmo is in moving state
*/
public static boolean isUsing() {
return nIsUsing();
}
private static native boolean nIsUsing(); /*
return ImGuizmo::IsUsing();
*/
/**
* Enable/disable the gizmo. Stay in the state until next call to Enable.
* Gizmo is rendered with gray half transparent color when disabled
*/
public static void enable(final boolean enable) {
nEnable(enable);
}
private static native void nEnable(boolean enable); /*
ImGuizmo::Enable(enable);
*/
/**
* Helper function for manually editing Translation/Rotation/Scale with an input float.
* Translation, Rotation and Scale float points to 3 floats each.
* Angles are in degrees (more suitable for human editing).
*
* @param matrix
* the model matrix
* @param translation
* the model translation
* @param rotation
* the model rotation
* @param scale
* the model scale
* @see <a target="_blank" href="https://github.com/CedricGuillemet/ImGuizmo">Reference Page</a>
*/
public static void decomposeMatrixToComponents(final float[] matrix, final float[] translation, final float[] rotation, final float[] scale) {
nDecomposeMatrixToComponents(matrix, translation, rotation, scale);
}
private static native void nDecomposeMatrixToComponents(float[] matrix, float[] translation, float[] rotation, float[] scale); /*MANUAL
auto matrix = obj_matrix == NULL ? NULL : (float*)env->GetPrimitiveArrayCritical(obj_matrix, JNI_FALSE);
auto translation = obj_translation == NULL ? NULL : (float*)env->GetPrimitiveArrayCritical(obj_translation, JNI_FALSE);
auto rotation = obj_rotation == NULL ? NULL : (float*)env->GetPrimitiveArrayCritical(obj_rotation, JNI_FALSE);
auto scale = obj_scale == NULL ? NULL : (float*)env->GetPrimitiveArrayCritical(obj_scale, JNI_FALSE);
ImGuizmo::DecomposeMatrixToComponents(&matrix[0], &translation[0], &rotation[0], &scale[0]);
if (matrix != NULL) env->ReleasePrimitiveArrayCritical(obj_matrix, matrix, JNI_FALSE);
if (translation != NULL) env->ReleasePrimitiveArrayCritical(obj_translation, translation, JNI_FALSE);
if (rotation != NULL) env->ReleasePrimitiveArrayCritical(obj_rotation, rotation, JNI_FALSE);
if (scale != NULL) env->ReleasePrimitiveArrayCritical(obj_scale, scale, JNI_FALSE);
*/
/**
* Helper function for manually editing Translation/Rotation/Scale with an input float.
* Translation, Rotation and Scale float points to 3 floats each.
* Angles are in degrees (more suitable for human editing).
*
* @param translation
* the model translation
* @param rotation
* the model rotation
* @param scale
* the model scale
* @param matrix
* the model matrix
* @see <a target="_blank" href="https://github.com/CedricGuillemet/ImGuizmo">Reference Page</a>
*/
public static void recomposeMatrixFromComponents(final float[] translation, final float[] rotation, final float[] scale, final float[] matrix) {
nRecomposeMatrixFromComponents(translation, rotation, scale, matrix);
}
private static native void nRecomposeMatrixFromComponents(float[] translation, float[] rotation, float[] scale, float[] matrix); /*MANUAL
auto translation = obj_translation == NULL ? NULL : (float*)env->GetPrimitiveArrayCritical(obj_translation, JNI_FALSE);
auto rotation = obj_rotation == NULL ? NULL : (float*)env->GetPrimitiveArrayCritical(obj_rotation, JNI_FALSE);
auto scale = obj_scale == NULL ? NULL : (float*)env->GetPrimitiveArrayCritical(obj_scale, JNI_FALSE);
auto matrix = obj_matrix == NULL ? NULL : (float*)env->GetPrimitiveArrayCritical(obj_matrix, JNI_FALSE);
ImGuizmo::RecomposeMatrixFromComponents(&translation[0], &rotation[0], &scale[0], &matrix[0]);
if (translation != NULL) env->ReleasePrimitiveArrayCritical(obj_translation, translation, JNI_FALSE);
if (rotation != NULL) env->ReleasePrimitiveArrayCritical(obj_rotation, rotation, JNI_FALSE);
if (scale != NULL) env->ReleasePrimitiveArrayCritical(obj_scale, scale, JNI_FALSE);
if (matrix != NULL) env->ReleasePrimitiveArrayCritical(obj_matrix, matrix, JNI_FALSE);
*/
/**
* This will set the rect position.
*
* @param x
* x coordinate of the rectangle
* @param y
* y coordinate of the rectangle
* @param width
* width of the rectangle
* @param height
* height of the rectangle
*/
public static void setRect(final float x, final float y, final float width, final float height) {
nSetRect(x, y, width, height);
}
private static native void nSetRect(float x, float y, float width, float height); /*
ImGuizmo::SetRect(x, y, width, height);
*/
/**
* Making sure if we're set to ortho or not.
*/
public static void setOrthographic(final boolean isOrthographic) {
nSetOrthographic(isOrthographic);
}
private static native void nSetOrthographic(boolean isOrthographic); /*
ImGuizmo::SetOrthographic(isOrthographic);
*/
/**
* Drawing an arbitrary cube in the world.
*
* @param view
* target camera view
* @param projection
* target camera projection
* @param matrices
* cube matrices (max. 4 cubes allowed)
*/
public static void drawCubes(final float[] view, final float[] projection, final float[] matrices) {
nDrawCubes(view, projection, matrices);
}
private static native void nDrawCubes(float[] view, float[] projection, float[] matrices); /*MANUAL
auto view = obj_view == NULL ? NULL : (float*)env->GetPrimitiveArrayCritical(obj_view, JNI_FALSE);
auto projection = obj_projection == NULL ? NULL : (float*)env->GetPrimitiveArrayCritical(obj_projection, JNI_FALSE);
auto matrices = obj_matrices == NULL ? NULL : (float*)env->GetPrimitiveArrayCritical(obj_matrices, JNI_FALSE);
ImGuizmo::DrawCubes(&view[0], &projection[0], &matrices[0], (int)(env->GetArrayLength(obj_matrices)/16));
if (view != NULL) env->ReleasePrimitiveArrayCritical(obj_view, view, JNI_FALSE);
if (projection != NULL) env->ReleasePrimitiveArrayCritical(obj_projection, projection, JNI_FALSE);
if (matrices != NULL) env->ReleasePrimitiveArrayCritical(obj_matrices, matrices, JNI_FALSE);
*/
/**
* Drawing an arbitrary cube in the world.
*
* @param view
* target camera view
* @param projection
* target camera projection
* @param matrices
* cube matrices (max. 4 cubes allowed)
* @param matrixCount
* number of matrices
*/
public static void drawCubes(final float[] view, final float[] projection, final float[] matrices, final int matrixCount) {
nDrawCubes(view, projection, matrices, matrixCount);
}
private static native void nDrawCubes(float[] view, float[] projection, float[] matrices, int matrixCount); /*MANUAL
auto view = obj_view == NULL ? NULL : (float*)env->GetPrimitiveArrayCritical(obj_view, JNI_FALSE);
auto projection = obj_projection == NULL ? NULL : (float*)env->GetPrimitiveArrayCritical(obj_projection, JNI_FALSE);
auto matrices = obj_matrices == NULL ? NULL : (float*)env->GetPrimitiveArrayCritical(obj_matrices, JNI_FALSE);
ImGuizmo::DrawCubes(&view[0], &projection[0], &matrices[0], matrixCount);
if (view != NULL) env->ReleasePrimitiveArrayCritical(obj_view, view, JNI_FALSE);
if (projection != NULL) env->ReleasePrimitiveArrayCritical(obj_projection, projection, JNI_FALSE);
if (matrices != NULL) env->ReleasePrimitiveArrayCritical(obj_matrices, matrices, JNI_FALSE);
*/
/**
* Drawing an arbitrary cube in the world.
*
* @param view target camera view
* @param projection target camera projection
* @param matrices cube matrices (max. 4 cubes allowed)
*/
public static void drawCubes(final float[] view, final float[] projection, final float[]... matrices) {
if (matrices.length > 4) {
throw new IllegalArgumentException("Only up to 4 cubes matrices is supported");
}
final float[] cubeMatrices = new float[matrices.length * 16];
for (int i = 0, cubeMatricesLength = matrices.length; i < cubeMatricesLength; i++) {
final float[] cubeMatrix = matrices[i];
System.arraycopy(cubeMatrix, 0, cubeMatrices, i * cubeMatrix.length, cubeMatrix.length);
}
drawCubes(view, projection, cubeMatrices, cubeMatrices.length);
}
/**
* Drawing a grid to the world (should only be used for debugging purposes).
*
* @param view
* target camera view
* @param projection
* target camera projection
* @param matrix
* grid matrix
* @param gridSize
* grid size
*/
public static void drawGrid(final float[] view, final float[] projection, final float[] matrix, final float gridSize) {
nDrawGrid(view, projection, matrix, gridSize);
}
private static native void nDrawGrid(float[] view, float[] projection, float[] matrix, float gridSize); /*MANUAL
auto view = obj_view == NULL ? NULL : (float*)env->GetPrimitiveArrayCritical(obj_view, JNI_FALSE);
auto projection = obj_projection == NULL ? NULL : (float*)env->GetPrimitiveArrayCritical(obj_projection, JNI_FALSE);
auto matrix = obj_matrix == NULL ? NULL : (float*)env->GetPrimitiveArrayCritical(obj_matrix, JNI_FALSE);
ImGuizmo::DrawGrid(&view[0], &projection[0], &matrix[0], gridSize);
if (view != NULL) env->ReleasePrimitiveArrayCritical(obj_view, view, JNI_FALSE);
if (projection != NULL) env->ReleasePrimitiveArrayCritical(obj_projection, projection, JNI_FALSE);
if (matrix != NULL) env->ReleasePrimitiveArrayCritical(obj_matrix, matrix, JNI_FALSE);
*/
/**
* Manipulating the given model matrix with delta matrix
*
* @param view
* target camera view
* @param projection
* target camera projection
* @param operation
* target operation
* @param mode
* target mode
* @param matrix
* model matrix
*/
public static void manipulate(final float[] view, final float[] projection, final int operation, final int mode, final float[] matrix) {
nManipulate(view, projection, operation, mode, matrix);
}
/**
* Manipulating the given model matrix with delta matrix
*
* @param view
* target camera view
* @param projection
* target camera projection
* @param operation
* target operation
* @param mode
* target mode
* @param matrix
* model matrix
* @param deltaMatrix
* delta matrix
*/
public static void manipulate(final float[] view, final float[] projection, final int operation, final int mode, final float[] matrix, final float[] deltaMatrix) {
nManipulate(view, projection, operation, mode, matrix, deltaMatrix);
}
/**
* Manipulating the given model matrix with delta matrix
*
* @param view
* target camera view
* @param projection
* target camera projection
* @param operation
* target operation
* @param mode
* target mode
* @param matrix
* model matrix
* @param deltaMatrix
* delta matrix
* @param snap
* snap value
*/
public static void manipulate(final float[] view, final float[] projection, final int operation, final int mode, final float[] matrix, final float[] deltaMatrix, final float[] snap) {
nManipulate(view, projection, operation, mode, matrix, deltaMatrix, snap);
}
/**
* Manipulating the given model matrix with delta matrix
*
* @param view
* target camera view
* @param projection
* target camera projection
* @param operation
* target operation
* @param mode
* target mode
* @param matrix
* model matrix
* @param deltaMatrix
* delta matrix
* @param snap
* snap value
* @param localBounds
* bounds value
*/
public static void manipulate(final float[] view, final float[] projection, final int operation, final int mode, final float[] matrix, final float[] deltaMatrix, final float[] snap, final float[] localBounds) {
nManipulate(view, projection, operation, mode, matrix, deltaMatrix, snap, localBounds);
}
/**
* Manipulating the given model matrix with delta matrix
*
* @param view
* target camera view
* @param projection
* target camera projection
* @param operation
* target operation
* @param mode
* target mode
* @param matrix
* model matrix
* @param deltaMatrix
* delta matrix
* @param snap
* snap value
* @param localBounds
* bounds value
* @param boundsSnap
* bounds snap value
*/
public static void manipulate(final float[] view, final float[] projection, final int operation, final int mode, final float[] matrix, final float[] deltaMatrix, final float[] snap, final float[] localBounds, final float[] boundsSnap) {
nManipulate(view, projection, operation, mode, matrix, deltaMatrix, snap, localBounds, boundsSnap);
}
private static native void nManipulate(float[] view, float[] projection, int operation, int mode, float[] matrix); /*MANUAL
auto view = obj_view == NULL ? NULL : (float*)env->GetPrimitiveArrayCritical(obj_view, JNI_FALSE);
auto projection = obj_projection == NULL ? NULL : (float*)env->GetPrimitiveArrayCritical(obj_projection, JNI_FALSE);
auto matrix = obj_matrix == NULL ? NULL : (float*)env->GetPrimitiveArrayCritical(obj_matrix, JNI_FALSE);
ImGuizmo::Manipulate(&view[0], &projection[0], static_cast<ImGuizmo::OPERATION>(operation), static_cast<ImGuizmo::MODE>(mode), &matrix[0]);
if (view != NULL) env->ReleasePrimitiveArrayCritical(obj_view, view, JNI_FALSE);
if (projection != NULL) env->ReleasePrimitiveArrayCritical(obj_projection, projection, JNI_FALSE);
if (matrix != NULL) env->ReleasePrimitiveArrayCritical(obj_matrix, matrix, JNI_FALSE);
*/
private static native void nManipulate(float[] view, float[] projection, int operation, int mode, float[] matrix, float[] deltaMatrix); /*MANUAL
auto view = obj_view == NULL ? NULL : (float*)env->GetPrimitiveArrayCritical(obj_view, JNI_FALSE);
auto projection = obj_projection == NULL ? NULL : (float*)env->GetPrimitiveArrayCritical(obj_projection, JNI_FALSE);
auto matrix = obj_matrix == NULL ? NULL : (float*)env->GetPrimitiveArrayCritical(obj_matrix, JNI_FALSE);
auto deltaMatrix = obj_deltaMatrix == NULL ? NULL : (float*)env->GetPrimitiveArrayCritical(obj_deltaMatrix, JNI_FALSE);
ImGuizmo::Manipulate(&view[0], &projection[0], static_cast<ImGuizmo::OPERATION>(operation), static_cast<ImGuizmo::MODE>(mode), &matrix[0], &deltaMatrix[0]);
if (view != NULL) env->ReleasePrimitiveArrayCritical(obj_view, view, JNI_FALSE);
if (projection != NULL) env->ReleasePrimitiveArrayCritical(obj_projection, projection, JNI_FALSE);
if (matrix != NULL) env->ReleasePrimitiveArrayCritical(obj_matrix, matrix, JNI_FALSE);
if (deltaMatrix != NULL) env->ReleasePrimitiveArrayCritical(obj_deltaMatrix, deltaMatrix, JNI_FALSE);
*/
private static native void nManipulate(float[] view, float[] projection, int operation, int mode, float[] matrix, float[] deltaMatrix, float[] snap); /*MANUAL
auto view = obj_view == NULL ? NULL : (float*)env->GetPrimitiveArrayCritical(obj_view, JNI_FALSE);
auto projection = obj_projection == NULL ? NULL : (float*)env->GetPrimitiveArrayCritical(obj_projection, JNI_FALSE);
auto matrix = obj_matrix == NULL ? NULL : (float*)env->GetPrimitiveArrayCritical(obj_matrix, JNI_FALSE);
auto deltaMatrix = obj_deltaMatrix == NULL ? NULL : (float*)env->GetPrimitiveArrayCritical(obj_deltaMatrix, JNI_FALSE);
auto snap = obj_snap == NULL ? NULL : (float*)env->GetPrimitiveArrayCritical(obj_snap, JNI_FALSE);
ImGuizmo::Manipulate(&view[0], &projection[0], static_cast<ImGuizmo::OPERATION>(operation), static_cast<ImGuizmo::MODE>(mode), &matrix[0], &deltaMatrix[0], &snap[0]);
if (view != NULL) env->ReleasePrimitiveArrayCritical(obj_view, view, JNI_FALSE);
if (projection != NULL) env->ReleasePrimitiveArrayCritical(obj_projection, projection, JNI_FALSE);
if (matrix != NULL) env->ReleasePrimitiveArrayCritical(obj_matrix, matrix, JNI_FALSE);
if (deltaMatrix != NULL) env->ReleasePrimitiveArrayCritical(obj_deltaMatrix, deltaMatrix, JNI_FALSE);
if (snap != NULL) env->ReleasePrimitiveArrayCritical(obj_snap, snap, JNI_FALSE);
*/
private static native void nManipulate(float[] view, float[] projection, int operation, int mode, float[] matrix, float[] deltaMatrix, float[] snap, float[] localBounds); /*MANUAL
auto view = obj_view == NULL ? NULL : (float*)env->GetPrimitiveArrayCritical(obj_view, JNI_FALSE);
auto projection = obj_projection == NULL ? NULL : (float*)env->GetPrimitiveArrayCritical(obj_projection, JNI_FALSE);
auto matrix = obj_matrix == NULL ? NULL : (float*)env->GetPrimitiveArrayCritical(obj_matrix, JNI_FALSE);
auto deltaMatrix = obj_deltaMatrix == NULL ? NULL : (float*)env->GetPrimitiveArrayCritical(obj_deltaMatrix, JNI_FALSE);
auto snap = obj_snap == NULL ? NULL : (float*)env->GetPrimitiveArrayCritical(obj_snap, JNI_FALSE);
auto localBounds = obj_localBounds == NULL ? NULL : (float*)env->GetPrimitiveArrayCritical(obj_localBounds, JNI_FALSE);
ImGuizmo::Manipulate(&view[0], &projection[0], static_cast<ImGuizmo::OPERATION>(operation), static_cast<ImGuizmo::MODE>(mode), &matrix[0], &deltaMatrix[0], &snap[0], &localBounds[0]);
if (view != NULL) env->ReleasePrimitiveArrayCritical(obj_view, view, JNI_FALSE);
if (projection != NULL) env->ReleasePrimitiveArrayCritical(obj_projection, projection, JNI_FALSE);
if (matrix != NULL) env->ReleasePrimitiveArrayCritical(obj_matrix, matrix, JNI_FALSE);
if (deltaMatrix != NULL) env->ReleasePrimitiveArrayCritical(obj_deltaMatrix, deltaMatrix, JNI_FALSE);
if (snap != NULL) env->ReleasePrimitiveArrayCritical(obj_snap, snap, JNI_FALSE);
if (localBounds != NULL) env->ReleasePrimitiveArrayCritical(obj_localBounds, localBounds, JNI_FALSE);
*/
private static native void nManipulate(float[] view, float[] projection, int operation, int mode, float[] matrix, float[] deltaMatrix, float[] snap, float[] localBounds, float[] boundsSnap); /*MANUAL
auto view = obj_view == NULL ? NULL : (float*)env->GetPrimitiveArrayCritical(obj_view, JNI_FALSE);
auto projection = obj_projection == NULL ? NULL : (float*)env->GetPrimitiveArrayCritical(obj_projection, JNI_FALSE);
auto matrix = obj_matrix == NULL ? NULL : (float*)env->GetPrimitiveArrayCritical(obj_matrix, JNI_FALSE);
auto deltaMatrix = obj_deltaMatrix == NULL ? NULL : (float*)env->GetPrimitiveArrayCritical(obj_deltaMatrix, JNI_FALSE);
auto snap = obj_snap == NULL ? NULL : (float*)env->GetPrimitiveArrayCritical(obj_snap, JNI_FALSE);
auto localBounds = obj_localBounds == NULL ? NULL : (float*)env->GetPrimitiveArrayCritical(obj_localBounds, JNI_FALSE);
auto boundsSnap = obj_boundsSnap == NULL ? NULL : (float*)env->GetPrimitiveArrayCritical(obj_boundsSnap, JNI_FALSE);
ImGuizmo::Manipulate(&view[0], &projection[0], static_cast<ImGuizmo::OPERATION>(operation), static_cast<ImGuizmo::MODE>(mode), &matrix[0], &deltaMatrix[0], &snap[0], &localBounds[0], &boundsSnap[0]);
if (view != NULL) env->ReleasePrimitiveArrayCritical(obj_view, view, JNI_FALSE);
if (projection != NULL) env->ReleasePrimitiveArrayCritical(obj_projection, projection, JNI_FALSE);
if (matrix != NULL) env->ReleasePrimitiveArrayCritical(obj_matrix, matrix, JNI_FALSE);
if (deltaMatrix != NULL) env->ReleasePrimitiveArrayCritical(obj_deltaMatrix, deltaMatrix, JNI_FALSE);
if (snap != NULL) env->ReleasePrimitiveArrayCritical(obj_snap, snap, JNI_FALSE);
if (localBounds != NULL) env->ReleasePrimitiveArrayCritical(obj_localBounds, localBounds, JNI_FALSE);
if (boundsSnap != NULL) env->ReleasePrimitiveArrayCritical(obj_boundsSnap, boundsSnap, JNI_FALSE);
*/
/**
* Manipulating the view
*
* @param view
* target camera view
* @param length
* camera distance/length
*/
public static void viewManipulate(final float[] view, final float length, final ImVec2 position, final ImVec2 size, final int backgroundColor) {
nViewManipulate(view, length, position.x, position.y, size.x, size.y, backgroundColor);
}
/**
* Manipulating the view
*
* @param view
* target camera view
* @param length
* camera distance/length
*/
public static void viewManipulate(final float[] view, final float length, final float positionX, final float positionY, final float sizeX, final float sizeY, final int backgroundColor) {
nViewManipulate(view, length, positionX, positionY, sizeX, sizeY, backgroundColor);
}
private static native void nViewManipulate(float[] view, float length, float positionX, float positionY, float sizeX, float sizeY, int backgroundColor); /*MANUAL
auto view = obj_view == NULL ? NULL : (float*)env->GetPrimitiveArrayCritical(obj_view, JNI_FALSE);
ImVec2 position = ImVec2(positionX, positionY);
ImVec2 size = ImVec2(sizeX, sizeY);
ImGuizmo::ViewManipulate(&view[0], length, position, size, backgroundColor);
if (view != NULL) env->ReleasePrimitiveArrayCritical(obj_view, view, JNI_FALSE);
*/
/**
* This will update the current id
*/
public static void setID(final int id) {
nSetID(id);
}
private static native void nSetID(int id); /*
ImGuizmo::SetID(id);
*/
/**
* Return true if the cursor is over the operation's gizmo
*/
public static boolean isOver(final int operation) {
return nIsOver(operation);
}
private static native boolean nIsOver(int operation); /*
return ImGuizmo::IsOver(static_cast<ImGuizmo::OPERATION>(operation));
*/
public static void setGizmoSizeClipSpace(final float value) {
nSetGizmoSizeClipSpace(value);
}
private static native void nSetGizmoSizeClipSpace(float value); /*
ImGuizmo::SetGizmoSizeClipSpace(value);
*/
/**
* Allow axis to flip.
* When true (default), the guizmo axis flip for better visibility.
* When false, they always stay along the positive world/local axis.
*/
public static void allowAxisFlip(final boolean value) {
nAllowAxisFlip(value);
}
private static native void nAllowAxisFlip(boolean value); /*
ImGuizmo::AllowAxisFlip(value);
*/
}
@@ -0,0 +1,11 @@
package imgui.extension.imguizmo.flag;
public final class Mode {
private Mode() {
}
public static final int LOCAL = 0;
public static final int WORLD = 1;
}
@@ -0,0 +1,82 @@
package imgui.extension.imguizmo.flag;
/**
* Needs view and projection matrices.
* Matrix parameter is the source matrix (where will be gizmo be drawn) and might be transformed by the function. Return deltaMatrix is optional.
* Translation is applied in world space.
*/
public final class Operation {
private Operation() {
}
/**
* Definition: {@code (1u << 0)}
*/
public static final int TRANSLATE_X = 1;
/**
* Definition: {@code (1u << 1)}
*/
public static final int TRANSLATE_Y = 2;
/**
* Definition: {@code (1u << 2)}
*/
public static final int TRANSLATE_Z = 4;
/**
* Definition: {@code (1u << 3)}
*/
public static final int ROTATE_X = 8;
/**
* Definition: {@code (1u << 4)}
*/
public static final int ROTATE_Y = 16;
/**
* Definition: {@code (1u << 5)}
*/
public static final int ROTATE_Z = 32;
/**
* Definition: {@code (1u << 6)}
*/
public static final int ROTATE_SCREEN = 64;
/**
* Definition: {@code (1u << 7)}
*/
public static final int SCALE_X = 128;
/**
* Definition: {@code (1u << 8)}
*/
public static final int SCALE_Y = 256;
/**
* Definition: {@code (1u << 9)}
*/
public static final int SCALE_Z = 512;
/**
* Definition: {@code (1u << 10)}
*/
public static final int BOUNDS = 1024;
/**
* Definition: {@code TRANSLATE_X | TRANSLATE_Y | TRANSLATE_Z}
*/
public static final int TRANSLATE = 7;
/**
* Definition: {@code ROTATE_X | ROTATE_Y | ROTATE_Z | ROTATE_SCREEN}
*/
public static final int ROTATE = 120;
/**
* Definition: {@code SCALE_X | SCALE_Y | SCALE_Z}
*/
public static final int SCALE = 896;
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,9 @@
package imgui.extension.imnodes;
import imgui.binding.ImGuiStruct;
public final class ImNodesContext extends ImGuiStruct {
public ImNodesContext(final long ptr) {
super(ptr);
}
}
@@ -0,0 +1,9 @@
package imgui.extension.imnodes;
import imgui.binding.ImGuiStruct;
public final class ImNodesEditorContext extends ImGuiStruct {
public ImNodesEditorContext(final long ptr) {
super(ptr);
}
}
@@ -0,0 +1,64 @@
package imgui.extension.imnodes;
import imgui.binding.ImGuiStruct;
public final class ImNodesIO extends ImGuiStruct {
public ImNodesIO(final long ptr) {
super(ptr);
}
/*JNI
#include "_imnodes.h"
#define THIS ((ImNodesIO*)STRUCT_PTR)
*/
/**
* Holding alt mouse button pans the node area, by default middle mouse button will be used
* Set based on ImGuiMouseButton values
*/
public int getAltMouseButton() {
return nGetAltMouseButton();
}
/**
* Holding alt mouse button pans the node area, by default middle mouse button will be used
* Set based on ImGuiMouseButton values
*/
public void setAltMouseButton(final int value) {
nSetAltMouseButton(value);
}
private native int nGetAltMouseButton(); /*
return THIS->AltMouseButton;
*/
private native void nSetAltMouseButton(int value); /*
THIS->AltMouseButton = value;
*/
/**
* Panning speed when dragging an element and mouse is outside the main editor view.
*/
public float getAutoPanningSpeed() {
return nGetAutoPanningSpeed();
}
/**
* Panning speed when dragging an element and mouse is outside the main editor view.
*/
public void setAutoPanningSpeed(final float value) {
nSetAutoPanningSpeed(value);
}
private native float nGetAutoPanningSpeed(); /*
return THIS->AutoPanningSpeed;
*/
private native void nSetAutoPanningSpeed(float value); /*
THIS->AutoPanningSpeed = value;
*/
/*JNI
#undef THIS
*/
}
@@ -0,0 +1,494 @@
package imgui.extension.imnodes;
import imgui.ImVec2;
import imgui.ImVec4;
import imgui.binding.ImGuiStruct;
public final class ImNodesStyle extends ImGuiStruct {
public ImNodesStyle(final long ptr) {
super(ptr);
}
/*JNI
#include "_imnodes.h"
#define THIS ((ImNodesStyle*)STRUCT_PTR)
*/
public float getGridSpacing() {
return nGetGridSpacing();
}
public void setGridSpacing(final float value) {
nSetGridSpacing(value);
}
private native float nGetGridSpacing(); /*
return THIS->GridSpacing;
*/
private native void nSetGridSpacing(float value); /*
THIS->GridSpacing = value;
*/
public float getNodeCornerRounding() {
return nGetNodeCornerRounding();
}
public void setNodeCornerRounding(final float value) {
nSetNodeCornerRounding(value);
}
private native float nGetNodeCornerRounding(); /*
return THIS->NodeCornerRounding;
*/
private native void nSetNodeCornerRounding(float value); /*
THIS->NodeCornerRounding = value;
*/
public ImVec2 getNodePadding() {
final ImVec2 dst = new ImVec2();
nGetNodePadding(dst);
return dst;
}
public float getNodePaddingX() {
return nGetNodePaddingX();
}
public float getNodePaddingY() {
return nGetNodePaddingY();
}
public void getNodePadding(final ImVec2 dst) {
nGetNodePadding(dst);
}
public void setNodePadding(final ImVec2 value) {
nSetNodePadding(value.x, value.y);
}
public void setNodePadding(final float valueX, final float valueY) {
nSetNodePadding(valueX, valueY);
}
private native void nGetNodePadding(ImVec2 dst); /*
Jni::ImVec2Cpy(env, THIS->NodePadding, dst);
*/
private native float nGetNodePaddingX(); /*
return THIS->NodePadding.x;
*/
private native float nGetNodePaddingY(); /*
return THIS->NodePadding.y;
*/
private native void nSetNodePadding(float valueX, float valueY); /*MANUAL
ImVec2 value = ImVec2(valueX, valueY);
THIS->NodePadding = value;
*/
public float getNodeBorderThickness() {
return nGetNodeBorderThickness();
}
public void setNodeBorderThickness(final float value) {
nSetNodeBorderThickness(value);
}
private native float nGetNodeBorderThickness(); /*
return THIS->NodeBorderThickness;
*/
private native void nSetNodeBorderThickness(float value); /*
THIS->NodeBorderThickness = value;
*/
public float getLinkThickness() {
return nGetLinkThickness();
}
public void setLinkThickness(final float value) {
nSetLinkThickness(value);
}
private native float nGetLinkThickness(); /*
return THIS->LinkThickness;
*/
private native void nSetLinkThickness(float value); /*
THIS->LinkThickness = value;
*/
public float getLinkLineSegmentsPerLength() {
return nGetLinkLineSegmentsPerLength();
}
public void setLinkLineSegmentsPerLength(final float value) {
nSetLinkLineSegmentsPerLength(value);
}
private native float nGetLinkLineSegmentsPerLength(); /*
return THIS->LinkLineSegmentsPerLength;
*/
private native void nSetLinkLineSegmentsPerLength(float value); /*
THIS->LinkLineSegmentsPerLength = value;
*/
public float getLinkHoverDistance() {
return nGetLinkHoverDistance();
}
public void setLinkHoverDistance(final float value) {
nSetLinkHoverDistance(value);
}
private native float nGetLinkHoverDistance(); /*
return THIS->LinkHoverDistance;
*/
private native void nSetLinkHoverDistance(float value); /*
THIS->LinkHoverDistance = value;
*/
/**
* The circle radius used when the pin shape is either PinShape_Circle or PinShape_CircleFilled.
*/
public float getPinCircleRadius() {
return nGetPinCircleRadius();
}
/**
* The circle radius used when the pin shape is either PinShape_Circle or PinShape_CircleFilled.
*/
public void setPinCircleRadius(final float value) {
nSetPinCircleRadius(value);
}
private native float nGetPinCircleRadius(); /*
return THIS->PinCircleRadius;
*/
private native void nSetPinCircleRadius(float value); /*
THIS->PinCircleRadius = value;
*/
/**
* The quad side length used when the shape is either PinShape_Quad or PinShape_QuadFilled.
*/
public float getPinQuadSideLength() {
return nGetPinQuadSideLength();
}
/**
* The quad side length used when the shape is either PinShape_Quad or PinShape_QuadFilled.
*/
public void setPinQuadSideLength(final float value) {
nSetPinQuadSideLength(value);
}
private native float nGetPinQuadSideLength(); /*
return THIS->PinQuadSideLength;
*/
private native void nSetPinQuadSideLength(float value); /*
THIS->PinQuadSideLength = value;
*/
/**
* The equilateral triangle side length used when the pin shape is either PinShape_Triangle or PinShape_TriangleFilled.
*/
public float getPinTriangleSideLength() {
return nGetPinTriangleSideLength();
}
/**
* The equilateral triangle side length used when the pin shape is either PinShape_Triangle or PinShape_TriangleFilled.
*/
public void setPinTriangleSideLength(final float value) {
nSetPinTriangleSideLength(value);
}
private native float nGetPinTriangleSideLength(); /*
return THIS->PinTriangleSideLength;
*/
private native void nSetPinTriangleSideLength(float value); /*
THIS->PinTriangleSideLength = value;
*/
/**
* The thickness of the line used when the pin shape is not filled.
*/
public float getPinLineThickness() {
return nGetPinLineThickness();
}
/**
* The thickness of the line used when the pin shape is not filled.
*/
public void setPinLineThickness(final float value) {
nSetPinLineThickness(value);
}
private native float nGetPinLineThickness(); /*
return THIS->PinLineThickness;
*/
private native void nSetPinLineThickness(float value); /*
THIS->PinLineThickness = value;
*/
/**
* The radius from the pin's center position inside of which it is detected as being hovered over.
*/
public float getPinHoverRadius() {
return nGetPinHoverRadius();
}
/**
* The radius from the pin's center position inside of which it is detected as being hovered over.
*/
public void setPinHoverRadius(final float value) {
nSetPinHoverRadius(value);
}
private native float nGetPinHoverRadius(); /*
return THIS->PinHoverRadius;
*/
private native void nSetPinHoverRadius(float value); /*
THIS->PinHoverRadius = value;
*/
/**
* Offsets the pins' positions from the edge of the node to the outside of the node.
*/
public float getPinOffset() {
return nGetPinOffset();
}
/**
* Offsets the pins' positions from the edge of the node to the outside of the node.
*/
public void setPinOffset(final float value) {
nSetPinOffset(value);
}
private native float nGetPinOffset(); /*
return THIS->PinOffset;
*/
private native void nSetPinOffset(float value); /*
THIS->PinOffset = value;
*/
/**
* Mini-map padding size between mini-map edge and mini-map content.
*/
public ImVec2 getMiniMapPadding() {
final ImVec2 dst = new ImVec2();
nGetMiniMapPadding(dst);
return dst;
}
/**
* Mini-map padding size between mini-map edge and mini-map content.
*/
public float getMiniMapPaddingX() {
return nGetMiniMapPaddingX();
}
/**
* Mini-map padding size between mini-map edge and mini-map content.
*/
public float getMiniMapPaddingY() {
return nGetMiniMapPaddingY();
}
/**
* Mini-map padding size between mini-map edge and mini-map content.
*/
public void getMiniMapPadding(final ImVec2 dst) {
nGetMiniMapPadding(dst);
}
/**
* Mini-map padding size between mini-map edge and mini-map content.
*/
public void setMiniMapPadding(final ImVec2 value) {
nSetMiniMapPadding(value.x, value.y);
}
/**
* Mini-map padding size between mini-map edge and mini-map content.
*/
public void setMiniMapPadding(final float valueX, final float valueY) {
nSetMiniMapPadding(valueX, valueY);
}
private native void nGetMiniMapPadding(ImVec2 dst); /*
Jni::ImVec2Cpy(env, THIS->MiniMapPadding, dst);
*/
private native float nGetMiniMapPaddingX(); /*
return THIS->MiniMapPadding.x;
*/
private native float nGetMiniMapPaddingY(); /*
return THIS->MiniMapPadding.y;
*/
private native void nSetMiniMapPadding(float valueX, float valueY); /*MANUAL
ImVec2 value = ImVec2(valueX, valueY);
THIS->MiniMapPadding = value;
*/
/**
* Mini-map offset from the screen side.
*/
public ImVec2 getMiniMapOffset() {
final ImVec2 dst = new ImVec2();
nGetMiniMapOffset(dst);
return dst;
}
/**
* Mini-map offset from the screen side.
*/
public float getMiniMapOffsetX() {
return nGetMiniMapOffsetX();
}
/**
* Mini-map offset from the screen side.
*/
public float getMiniMapOffsetY() {
return nGetMiniMapOffsetY();
}
/**
* Mini-map offset from the screen side.
*/
public void getMiniMapOffset(final ImVec2 dst) {
nGetMiniMapOffset(dst);
}
/**
* Mini-map offset from the screen side.
*/
public void setMiniMapOffset(final ImVec2 value) {
nSetMiniMapOffset(value.x, value.y);
}
/**
* Mini-map offset from the screen side.
*/
public void setMiniMapOffset(final float valueX, final float valueY) {
nSetMiniMapOffset(valueX, valueY);
}
private native void nGetMiniMapOffset(ImVec2 dst); /*
Jni::ImVec2Cpy(env, THIS->MiniMapOffset, dst);
*/
private native float nGetMiniMapOffsetX(); /*
return THIS->MiniMapOffset.x;
*/
private native float nGetMiniMapOffsetY(); /*
return THIS->MiniMapOffset.y;
*/
private native void nSetMiniMapOffset(float valueX, float valueY); /*MANUAL
ImVec2 value = ImVec2(valueX, valueY);
THIS->MiniMapOffset = value;
*/
/**
* By default, ImNodesStyleFlags_NodeOutline and ImNodesStyleFlags_Gridlines are enabled.
*/
public int getFlags() {
return nGetFlags();
}
/**
* By default, ImNodesStyleFlags_NodeOutline and ImNodesStyleFlags_Gridlines are enabled.
*/
public void setFlags(final int value) {
nSetFlags(value);
}
/**
* By default, ImNodesStyleFlags_NodeOutline and ImNodesStyleFlags_Gridlines are enabled.
*/
public void addFlags(final int flags) {
setFlags(getFlags() | flags);
}
/**
* By default, ImNodesStyleFlags_NodeOutline and ImNodesStyleFlags_Gridlines are enabled.
*/
public void removeFlags(final int flags) {
setFlags(getFlags() & ~(flags));
}
/**
* By default, ImNodesStyleFlags_NodeOutline and ImNodesStyleFlags_Gridlines are enabled.
*/
public boolean hasFlags(final int flags) {
return (getFlags() & flags) != 0;
}
private native int nGetFlags(); /*
return THIS->Flags;
*/
private native void nSetFlags(int value); /*
THIS->Flags = value;
*/
public int[] getColors() {
return nGetColors();
}
public int getColors(final int idx) {
return nGetColors(idx);
}
public void setColors(final int[] value) {
nSetColors(value);
}
public void setColors(final int idx, final int value) {
nSetColors(idx, value);
}
private native int[] nGetColors(); /*
jint jBuf[ImNodesCol_COUNT];
for (int i = 0; i < ImNodesCol_COUNT; i++)
jBuf[i] = THIS->Colors[i];
jintArray result = env->NewIntArray(ImNodesCol_COUNT);
env->SetIntArrayRegion(result, 0, ImNodesCol_COUNT, jBuf);
return result;
*/
private native int nGetColors(int idx); /*
return THIS->Colors[idx];
*/
private native void nSetColors(int[] value); /*
for (int i = 0; i < ImNodesCol_COUNT; i++)
THIS->Colors[i] = value[i];
*/
private native int nSetColors(int idx, int value); /*
THIS->Colors[idx] = value;
*/
/*JNI
#undef THIS
*/
}
@@ -0,0 +1,29 @@
package imgui.extension.imnodes.flag;
/**
* This enum controls the way the attribute pins behave.
*/
public final class ImNodesAttributeFlags {
private ImNodesAttributeFlags() {
}
/**
* Definition: {@code 0}
*/
public static final int None = 0;
/**
* Allow detaching a link by left-clicking and dragging the link at a pin it is connected to. NOTE: the user has to actually delete the link for this to work. A deleted link can be detected by calling IsLinkDestroyed() after EndNodeEditor().
*
* <p>Definition: {@code 1 << 0}
*/
public static final int EnableLinkDetachWithDragClick = 1;
/**
* Visual snapping of an in progress link will trigger IsLink Created/Destroyed events. Allows for previewing the creation of a link while dragging it across attributes. See here for demo: https://github.com/Nelarius/imnodes/issues/41#issuecomment-647132113 NOTE: the user has to actually delete the link for this to work. A deleted link can be detected by calling IsLinkDestroyed() after EndNodeEditor().
*
* <p>Definition: {@code 1 << 1}
*/
public static final int EnableLinkCreationOnSnap = 2;
}
@@ -1,36 +1,68 @@
package imgui.extension.imnodes.flag;
public final class ImNodesColorStyle {
private ImNodesColorStyle() {
public final class ImNodesCol {
private ImNodesCol() {
}
/**
* Definition: {@code 0}
*/
public static final int NodeBackground = 0;
public static final int NodeBackgroundHovered = 1;
public static final int NodeBackgroundSelected = 2;
public static final int NodeOutline = 3;
public static final int TitleBar = 4;
public static final int TitleBarHovered = 5;
public static final int TitleBarSelected = 6;
public static final int Link = 7;
public static final int LinkHovered = 8;
public static final int LinkSelected = 9;
public static final int Pin = 10;
public static final int PinHovered = 11;
public static final int BoxSelector = 12;
public static final int BoxSelectorOutline = 13;
public static final int GridBackground = 14;
public static final int GridLine = 15;
public static final int MiniMapBackground = 16;
public static final int MiniMapBackgroundHovered = 17;
public static final int MiniMapOutline = 18;
public static final int MiniMapOutlineHovered = 19;
public static final int MiniMapNodeBackground = 20;
public static final int MiniMapNodeBackgroundHovered = 21;
public static final int MiniMapNodeBackgroundSelected = 22;
public static final int MiniMapNodeOutline = 23;
public static final int MiniMapLink = 24;
public static final int MiniMapLinkSelected = 25;
public static final int MiniMapCanvas = 26;
public static final int MiniMapCanvasOutline = 27;
public static final int COUNT = 28;
}
@@ -0,0 +1,18 @@
package imgui.extension.imnodes.flag;
/**
* This enum controls the minimap's location.
*/
public final class ImNodesMiniMapLocation {
private ImNodesMiniMapLocation() {
}
public static final int BottomLeft = 0;
public static final int BottomRight = 1;
public static final int TopLeft = 2;
public static final int TopRight = 3;
}
@@ -0,0 +1,22 @@
package imgui.extension.imnodes.flag;
/**
* This enum controls the way attribute pins look.
*/
public final class ImNodesPinShape {
private ImNodesPinShape() {
}
public static final int Circle = 0;
public static final int CircleFilled = 1;
public static final int Triangle = 2;
public static final int TriangleFilled = 3;
public static final int Quad = 4;
public static final int QuadFilled = 5;
}
@@ -0,0 +1,22 @@
package imgui.extension.imnodes.flag;
public final class ImNodesStyleFlags {
private ImNodesStyleFlags() {
}
/**
* Definition: {@code 0}
*/
public static final int None = 0;
/**
* Definition: {@code 1 << 0}
*/
public static final int NodeOutline = 1;
/**
* Definition: {@code 1 << 2}
*/
public static final int GridLines = 4;
}
@@ -0,0 +1,42 @@
package imgui.extension.imnodes.flag;
public final class ImNodesStyleVar {
private ImNodesStyleVar() {
}
/**
* Definition: {@code 0}
*/
public static final int GridSpacing = 0;
public static final int NodeCornerRounding = 1;
public static final int NodePadding = 2;
public static final int NodeBorderThickness = 3;
public static final int LinkThickness = 4;
public static final int LinkLineSegmentsPerLength = 5;
public static final int LinkHoverDistance = 6;
public static final int PinCircleRadius = 7;
public static final int PinQuadSideLength = 8;
public static final int PinTriangleSideLength = 9;
public static final int PinLineThickness = 10;
public static final int PinHoverRadius = 11;
public static final int PinOffset = 12;
public static final int MiniMapPadding = 13;
public static final int MiniMapOffset = 14;
public static final int COUNT = 15;
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,9 @@
package imgui.extension.implot;
import imgui.binding.ImGuiStruct;
public final class ImPlotContext extends ImGuiStruct {
public ImPlotContext(final long ptr) {
super(ptr);
}
}
@@ -0,0 +1,93 @@
package imgui.extension.implot;
import imgui.ImVec2;
import java.util.Objects;
public final class ImPlotLimits implements Cloneable {
public final ImPlotRange x = new ImPlotRange();
public final ImPlotRange y = new ImPlotRange();
public ImPlotLimits() {
}
public ImPlotLimits(final double xMin, final double yMin, final double xMax, final double yMax) {
set(xMin, yMin, xMax, yMax);
}
public ImPlotLimits(final ImVec2 min, final ImVec2 max) {
set(min, max);
}
public ImPlotLimits(final ImPlotLimits value) {
set(value);
}
public boolean contains(final double x, final double y) {
return this.x.contains(x) && this.y.contains(y);
}
public boolean contains(final ImPlotPoint value) {
return contains(value.x, value.y);
}
public ImPlotPoint min() {
return new ImPlotPoint(x.min, y.min);
}
public ImPlotPoint max() {
return new ImPlotPoint(x.max, y.max);
}
public void set(final double xMin, final double yMin, final double xMax, final double yMax) {
this.x.min = xMin;
this.x.max = xMax;
this.y.min = yMin;
this.y.max = yMax;
}
public void set(final ImVec2 min, final ImVec2 max) {
set(min.x, min.y, max.x, max.y);
}
public void set(final ImPlotRange x, final ImPlotRange y) {
set(x.min, y.min, x.max, y.max);
}
public void set(final ImPlotLimits value) {
set(value.x, value.y);
}
@Override
public String toString() {
return "ImPlotLimits{"
+ "x=" + x
+ ", y=" + y
+ '}';
}
@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
final ImPlotLimits imPlotLimits = (ImPlotLimits) o;
return Objects.equals(x, imPlotLimits.x) && Objects.equals(y, imPlotLimits.y);
}
@Override
public int hashCode() {
return Objects.hash(x, y);
}
@Override
@SuppressWarnings("MethodDoesntCallSuperMethod")
public ImPlotLimits clone() {
return new ImPlotLimits(this);
}
}
@@ -0,0 +1,100 @@
package imgui.extension.implot;
import imgui.ImVec2;
import java.util.Objects;
public final class ImPlotPoint implements Cloneable {
public double x;
public double y;
public ImPlotPoint() {
}
public ImPlotPoint(final double x, final double y) {
set(x, y);
}
public ImPlotPoint(final ImVec2 value) {
set(value.x, value.y);
}
public ImPlotPoint(final ImPlotPoint value) {
set(value.x, value.y);
}
public ImPlotPoint set(final double x, final double y) {
this.x = x;
this.y = y;
return this;
}
public ImPlotPoint set(final ImPlotPoint value) {
return set(value.x, value.y);
}
public ImPlotPoint set(final ImVec2 value) {
return set(value.x, value.y);
}
public ImPlotPoint plus(final double x, final double y) {
this.x += x;
this.y += y;
return this;
}
public ImPlotPoint plus(final ImPlotPoint value) {
return plus(value.x, value.y);
}
public ImPlotPoint minus(final double x, final double y) {
this.x -= x;
this.y -= y;
return this;
}
public ImPlotPoint minus(final ImPlotPoint value) {
return minus(value.x, value.y);
}
public ImPlotPoint times(final double x, final double y) {
this.x *= x;
this.y *= y;
return this;
}
public ImPlotPoint times(final ImPlotPoint value) {
return times(value.x, value.y);
}
@Override
public String toString() {
return "ImPlotPoint{"
+ "x=" + x
+ ", y=" + y
+ '}';
}
@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
final ImPlotPoint imPlotPoint = (ImPlotPoint) o;
return Double.compare(imPlotPoint.x, x) == 0 && Double.compare(imPlotPoint.y, y) == 0;
}
@Override
public int hashCode() {
return Objects.hash(x, y);
}
@Override
@SuppressWarnings("MethodDoesntCallSuperMethod")
public ImPlotPoint clone() {
return new ImPlotPoint(this);
}
}
@@ -0,0 +1,98 @@
package imgui.extension.implot;
import java.util.Objects;
public final class ImPlotRange implements Cloneable {
public double min;
public double max;
public ImPlotRange() {
}
public ImPlotRange(final double min, final double max) {
set(min, max);
}
public ImPlotRange(final ImPlotRange value) {
set(value.min, value.max);
}
public boolean contains(final double value) {
return value >= min && value <= max;
}
public double size() {
return max - min;
}
public ImPlotRange set(final double min, final double max) {
this.min = min;
this.max = max;
return this;
}
public ImPlotRange set(final ImPlotRange value) {
return set(value.min, value.max);
}
public ImPlotRange plus(final double min, final double max) {
this.min += min;
this.max += max;
return this;
}
public ImPlotRange plus(final ImPlotRange value) {
return plus(value.min, value.max);
}
public ImPlotRange minus(final double min, final double max) {
this.min -= min;
this.max -= max;
return this;
}
public ImPlotRange minus(final ImPlotRange value) {
return minus(value.min, value.max);
}
public ImPlotRange times(final double min, final double max) {
this.min *= min;
this.max *= max;
return this;
}
public ImPlotRange times(final ImPlotRange value) {
return times(value.min, value.max);
}
@Override
public String toString() {
return "ImPlotRange{"
+ "min=" + min
+ ", max=" + max
+ '}';
}
@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
final ImPlotRange ImPlotRange = (ImPlotRange) o;
return Double.compare(ImPlotRange.min, min) == 0 && Double.compare(ImPlotRange.max, max) == 0;
}
@Override
public int hashCode() {
return Objects.hash(min, max);
}
@Override
@SuppressWarnings("MethodDoesntCallSuperMethod")
public ImPlotRange clone() {
return new ImPlotRange(this);
}
}
@@ -0,0 +1,992 @@
package imgui.extension.implot;
import imgui.ImVec2;
import imgui.ImVec4;
import imgui.binding.ImGuiStructDestroyable;
public final class ImPlotStyle extends ImGuiStructDestroyable {
public ImPlotStyle() {
}
public ImPlotStyle(final long ptr) {
super(ptr);
}
@Override
protected long create() {
return nCreate();
}
/*JNI
#include "_implot.h"
#define THIS ((ImPlotStyle*)STRUCT_PTR)
*/
private native long nCreate(); /*
return (intptr_t)(new ImPlotStyle());
*/
public float getLineWeight() {
return nGetLineWeight();
}
public void setLineWeight(final float value) {
nSetLineWeight(value);
}
private native float nGetLineWeight(); /*
return THIS->LineWeight;
*/
private native void nSetLineWeight(float value); /*
THIS->LineWeight = value;
*/
public int getMarker() {
return nGetMarker();
}
public void setMarker(final int value) {
nSetMarker(value);
}
private native int nGetMarker(); /*
return THIS->Marker;
*/
private native void nSetMarker(int value); /*
THIS->Marker = value;
*/
public float getMarkerSize() {
return nGetMarkerSize();
}
public void setMarkerSize(final float value) {
nSetMarkerSize(value);
}
private native float nGetMarkerSize(); /*
return THIS->MarkerSize;
*/
private native void nSetMarkerSize(float value); /*
THIS->MarkerSize = value;
*/
public float getMarkerWeight() {
return nGetMarkerWeight();
}
public void setMarkerWeight(final float value) {
nSetMarkerWeight(value);
}
private native float nGetMarkerWeight(); /*
return THIS->MarkerWeight;
*/
private native void nSetMarkerWeight(float value); /*
THIS->MarkerWeight = value;
*/
public float getFillAlpha() {
return nGetFillAlpha();
}
public void setFillAlpha(final float value) {
nSetFillAlpha(value);
}
private native float nGetFillAlpha(); /*
return THIS->FillAlpha;
*/
private native void nSetFillAlpha(float value); /*
THIS->FillAlpha = value;
*/
public float getErrorBarSize() {
return nGetErrorBarSize();
}
public void setErrorBarSize(final float value) {
nSetErrorBarSize(value);
}
private native float nGetErrorBarSize(); /*
return THIS->ErrorBarSize;
*/
private native void nSetErrorBarSize(float value); /*
THIS->ErrorBarSize = value;
*/
public float getErrorBarWeight() {
return nGetErrorBarWeight();
}
public void setErrorBarWeight(final float value) {
nSetErrorBarWeight(value);
}
private native float nGetErrorBarWeight(); /*
return THIS->ErrorBarWeight;
*/
private native void nSetErrorBarWeight(float value); /*
THIS->ErrorBarWeight = value;
*/
public float getDigitalBitHeight() {
return nGetDigitalBitHeight();
}
public void setDigitalBitHeight(final float value) {
nSetDigitalBitHeight(value);
}
private native float nGetDigitalBitHeight(); /*
return THIS->DigitalBitHeight;
*/
private native void nSetDigitalBitHeight(float value); /*
THIS->DigitalBitHeight = value;
*/
public float getDigitalBitGap() {
return nGetDigitalBitGap();
}
public void setDigitalBitGap(final float value) {
nSetDigitalBitGap(value);
}
private native float nGetDigitalBitGap(); /*
return THIS->DigitalBitGap;
*/
private native void nSetDigitalBitGap(float value); /*
THIS->DigitalBitGap = value;
*/
public float getPlotBorderSize() {
return nGetPlotBorderSize();
}
public void setPlotBorderSize(final float value) {
nSetPlotBorderSize(value);
}
private native float nGetPlotBorderSize(); /*
return THIS->PlotBorderSize;
*/
private native void nSetPlotBorderSize(float value); /*
THIS->PlotBorderSize = value;
*/
public float getMinorAlpha() {
return nGetMinorAlpha();
}
public void setMinorAlpha(final float value) {
nSetMinorAlpha(value);
}
private native float nGetMinorAlpha(); /*
return THIS->MinorAlpha;
*/
private native void nSetMinorAlpha(float value); /*
THIS->MinorAlpha = value;
*/
public ImVec2 getMajorTickLen() {
final ImVec2 dst = new ImVec2();
nGetMajorTickLen(dst);
return dst;
}
public float getMajorTickLenX() {
return nGetMajorTickLenX();
}
public float getMajorTickLenY() {
return nGetMajorTickLenY();
}
public void getMajorTickLen(final ImVec2 dst) {
nGetMajorTickLen(dst);
}
public void setMajorTickLen(final ImVec2 value) {
nSetMajorTickLen(value.x, value.y);
}
public void setMajorTickLen(final float valueX, final float valueY) {
nSetMajorTickLen(valueX, valueY);
}
private native void nGetMajorTickLen(ImVec2 dst); /*
Jni::ImVec2Cpy(env, THIS->MajorTickLen, dst);
*/
private native float nGetMajorTickLenX(); /*
return THIS->MajorTickLen.x;
*/
private native float nGetMajorTickLenY(); /*
return THIS->MajorTickLen.y;
*/
private native void nSetMajorTickLen(float valueX, float valueY); /*MANUAL
ImVec2 value = ImVec2(valueX, valueY);
THIS->MajorTickLen = value;
*/
public ImVec2 getMinorTickLen() {
final ImVec2 dst = new ImVec2();
nGetMinorTickLen(dst);
return dst;
}
public float getMinorTickLenX() {
return nGetMinorTickLenX();
}
public float getMinorTickLenY() {
return nGetMinorTickLenY();
}
public void getMinorTickLen(final ImVec2 dst) {
nGetMinorTickLen(dst);
}
public void setMinorTickLen(final ImVec2 value) {
nSetMinorTickLen(value.x, value.y);
}
public void setMinorTickLen(final float valueX, final float valueY) {
nSetMinorTickLen(valueX, valueY);
}
private native void nGetMinorTickLen(ImVec2 dst); /*
Jni::ImVec2Cpy(env, THIS->MinorTickLen, dst);
*/
private native float nGetMinorTickLenX(); /*
return THIS->MinorTickLen.x;
*/
private native float nGetMinorTickLenY(); /*
return THIS->MinorTickLen.y;
*/
private native void nSetMinorTickLen(float valueX, float valueY); /*MANUAL
ImVec2 value = ImVec2(valueX, valueY);
THIS->MinorTickLen = value;
*/
public ImVec2 getMajorTickSize() {
final ImVec2 dst = new ImVec2();
nGetMajorTickSize(dst);
return dst;
}
public float getMajorTickSizeX() {
return nGetMajorTickSizeX();
}
public float getMajorTickSizeY() {
return nGetMajorTickSizeY();
}
public void getMajorTickSize(final ImVec2 dst) {
nGetMajorTickSize(dst);
}
public void setMajorTickSize(final ImVec2 value) {
nSetMajorTickSize(value.x, value.y);
}
public void setMajorTickSize(final float valueX, final float valueY) {
nSetMajorTickSize(valueX, valueY);
}
private native void nGetMajorTickSize(ImVec2 dst); /*
Jni::ImVec2Cpy(env, THIS->MajorTickSize, dst);
*/
private native float nGetMajorTickSizeX(); /*
return THIS->MajorTickSize.x;
*/
private native float nGetMajorTickSizeY(); /*
return THIS->MajorTickSize.y;
*/
private native void nSetMajorTickSize(float valueX, float valueY); /*MANUAL
ImVec2 value = ImVec2(valueX, valueY);
THIS->MajorTickSize = value;
*/
public ImVec2 getMinorTickSize() {
final ImVec2 dst = new ImVec2();
nGetMinorTickSize(dst);
return dst;
}
public float getMinorTickSizeX() {
return nGetMinorTickSizeX();
}
public float getMinorTickSizeY() {
return nGetMinorTickSizeY();
}
public void getMinorTickSize(final ImVec2 dst) {
nGetMinorTickSize(dst);
}
public void setMinorTickSize(final ImVec2 value) {
nSetMinorTickSize(value.x, value.y);
}
public void setMinorTickSize(final float valueX, final float valueY) {
nSetMinorTickSize(valueX, valueY);
}
private native void nGetMinorTickSize(ImVec2 dst); /*
Jni::ImVec2Cpy(env, THIS->MinorTickSize, dst);
*/
private native float nGetMinorTickSizeX(); /*
return THIS->MinorTickSize.x;
*/
private native float nGetMinorTickSizeY(); /*
return THIS->MinorTickSize.y;
*/
private native void nSetMinorTickSize(float valueX, float valueY); /*MANUAL
ImVec2 value = ImVec2(valueX, valueY);
THIS->MinorTickSize = value;
*/
public ImVec2 getMajorGridSize() {
final ImVec2 dst = new ImVec2();
nGetMajorGridSize(dst);
return dst;
}
public float getMajorGridSizeX() {
return nGetMajorGridSizeX();
}
public float getMajorGridSizeY() {
return nGetMajorGridSizeY();
}
public void getMajorGridSize(final ImVec2 dst) {
nGetMajorGridSize(dst);
}
public void setMajorGridSize(final ImVec2 value) {
nSetMajorGridSize(value.x, value.y);
}
public void setMajorGridSize(final float valueX, final float valueY) {
nSetMajorGridSize(valueX, valueY);
}
private native void nGetMajorGridSize(ImVec2 dst); /*
Jni::ImVec2Cpy(env, THIS->MajorGridSize, dst);
*/
private native float nGetMajorGridSizeX(); /*
return THIS->MajorGridSize.x;
*/
private native float nGetMajorGridSizeY(); /*
return THIS->MajorGridSize.y;
*/
private native void nSetMajorGridSize(float valueX, float valueY); /*MANUAL
ImVec2 value = ImVec2(valueX, valueY);
THIS->MajorGridSize = value;
*/
public ImVec2 getMinorGridSize() {
final ImVec2 dst = new ImVec2();
nGetMinorGridSize(dst);
return dst;
}
public float getMinorGridSizeX() {
return nGetMinorGridSizeX();
}
public float getMinorGridSizeY() {
return nGetMinorGridSizeY();
}
public void getMinorGridSize(final ImVec2 dst) {
nGetMinorGridSize(dst);
}
public void setMinorGridSize(final ImVec2 value) {
nSetMinorGridSize(value.x, value.y);
}
public void setMinorGridSize(final float valueX, final float valueY) {
nSetMinorGridSize(valueX, valueY);
}
private native void nGetMinorGridSize(ImVec2 dst); /*
Jni::ImVec2Cpy(env, THIS->MinorGridSize, dst);
*/
private native float nGetMinorGridSizeX(); /*
return THIS->MinorGridSize.x;
*/
private native float nGetMinorGridSizeY(); /*
return THIS->MinorGridSize.y;
*/
private native void nSetMinorGridSize(float valueX, float valueY); /*MANUAL
ImVec2 value = ImVec2(valueX, valueY);
THIS->MinorGridSize = value;
*/
public ImVec2 getPlotPadding() {
final ImVec2 dst = new ImVec2();
nGetPlotPadding(dst);
return dst;
}
public float getPlotPaddingX() {
return nGetPlotPaddingX();
}
public float getPlotPaddingY() {
return nGetPlotPaddingY();
}
public void getPlotPadding(final ImVec2 dst) {
nGetPlotPadding(dst);
}
public void setPlotPadding(final ImVec2 value) {
nSetPlotPadding(value.x, value.y);
}
public void setPlotPadding(final float valueX, final float valueY) {
nSetPlotPadding(valueX, valueY);
}
private native void nGetPlotPadding(ImVec2 dst); /*
Jni::ImVec2Cpy(env, THIS->PlotPadding, dst);
*/
private native float nGetPlotPaddingX(); /*
return THIS->PlotPadding.x;
*/
private native float nGetPlotPaddingY(); /*
return THIS->PlotPadding.y;
*/
private native void nSetPlotPadding(float valueX, float valueY); /*MANUAL
ImVec2 value = ImVec2(valueX, valueY);
THIS->PlotPadding = value;
*/
public ImVec2 getLabelPadding() {
final ImVec2 dst = new ImVec2();
nGetLabelPadding(dst);
return dst;
}
public float getLabelPaddingX() {
return nGetLabelPaddingX();
}
public float getLabelPaddingY() {
return nGetLabelPaddingY();
}
public void getLabelPadding(final ImVec2 dst) {
nGetLabelPadding(dst);
}
public void setLabelPadding(final ImVec2 value) {
nSetLabelPadding(value.x, value.y);
}
public void setLabelPadding(final float valueX, final float valueY) {
nSetLabelPadding(valueX, valueY);
}
private native void nGetLabelPadding(ImVec2 dst); /*
Jni::ImVec2Cpy(env, THIS->LabelPadding, dst);
*/
private native float nGetLabelPaddingX(); /*
return THIS->LabelPadding.x;
*/
private native float nGetLabelPaddingY(); /*
return THIS->LabelPadding.y;
*/
private native void nSetLabelPadding(float valueX, float valueY); /*MANUAL
ImVec2 value = ImVec2(valueX, valueY);
THIS->LabelPadding = value;
*/
public ImVec2 getLegendPadding() {
final ImVec2 dst = new ImVec2();
nGetLegendPadding(dst);
return dst;
}
public float getLegendPaddingX() {
return nGetLegendPaddingX();
}
public float getLegendPaddingY() {
return nGetLegendPaddingY();
}
public void getLegendPadding(final ImVec2 dst) {
nGetLegendPadding(dst);
}
public void setLegendPadding(final ImVec2 value) {
nSetLegendPadding(value.x, value.y);
}
public void setLegendPadding(final float valueX, final float valueY) {
nSetLegendPadding(valueX, valueY);
}
private native void nGetLegendPadding(ImVec2 dst); /*
Jni::ImVec2Cpy(env, THIS->LegendPadding, dst);
*/
private native float nGetLegendPaddingX(); /*
return THIS->LegendPadding.x;
*/
private native float nGetLegendPaddingY(); /*
return THIS->LegendPadding.y;
*/
private native void nSetLegendPadding(float valueX, float valueY); /*MANUAL
ImVec2 value = ImVec2(valueX, valueY);
THIS->LegendPadding = value;
*/
public ImVec2 getLegendInnerPadding() {
final ImVec2 dst = new ImVec2();
nGetLegendInnerPadding(dst);
return dst;
}
public float getLegendInnerPaddingX() {
return nGetLegendInnerPaddingX();
}
public float getLegendInnerPaddingY() {
return nGetLegendInnerPaddingY();
}
public void getLegendInnerPadding(final ImVec2 dst) {
nGetLegendInnerPadding(dst);
}
public void setLegendInnerPadding(final ImVec2 value) {
nSetLegendInnerPadding(value.x, value.y);
}
public void setLegendInnerPadding(final float valueX, final float valueY) {
nSetLegendInnerPadding(valueX, valueY);
}
private native void nGetLegendInnerPadding(ImVec2 dst); /*
Jni::ImVec2Cpy(env, THIS->LegendInnerPadding, dst);
*/
private native float nGetLegendInnerPaddingX(); /*
return THIS->LegendInnerPadding.x;
*/
private native float nGetLegendInnerPaddingY(); /*
return THIS->LegendInnerPadding.y;
*/
private native void nSetLegendInnerPadding(float valueX, float valueY); /*MANUAL
ImVec2 value = ImVec2(valueX, valueY);
THIS->LegendInnerPadding = value;
*/
public ImVec2 getLegendSpacing() {
final ImVec2 dst = new ImVec2();
nGetLegendSpacing(dst);
return dst;
}
public float getLegendSpacingX() {
return nGetLegendSpacingX();
}
public float getLegendSpacingY() {
return nGetLegendSpacingY();
}
public void getLegendSpacing(final ImVec2 dst) {
nGetLegendSpacing(dst);
}
public void setLegendSpacing(final ImVec2 value) {
nSetLegendSpacing(value.x, value.y);
}
public void setLegendSpacing(final float valueX, final float valueY) {
nSetLegendSpacing(valueX, valueY);
}
private native void nGetLegendSpacing(ImVec2 dst); /*
Jni::ImVec2Cpy(env, THIS->LegendSpacing, dst);
*/
private native float nGetLegendSpacingX(); /*
return THIS->LegendSpacing.x;
*/
private native float nGetLegendSpacingY(); /*
return THIS->LegendSpacing.y;
*/
private native void nSetLegendSpacing(float valueX, float valueY); /*MANUAL
ImVec2 value = ImVec2(valueX, valueY);
THIS->LegendSpacing = value;
*/
public ImVec2 getMousePosPadding() {
final ImVec2 dst = new ImVec2();
nGetMousePosPadding(dst);
return dst;
}
public float getMousePosPaddingX() {
return nGetMousePosPaddingX();
}
public float getMousePosPaddingY() {
return nGetMousePosPaddingY();
}
public void getMousePosPadding(final ImVec2 dst) {
nGetMousePosPadding(dst);
}
public void setMousePosPadding(final ImVec2 value) {
nSetMousePosPadding(value.x, value.y);
}
public void setMousePosPadding(final float valueX, final float valueY) {
nSetMousePosPadding(valueX, valueY);
}
private native void nGetMousePosPadding(ImVec2 dst); /*
Jni::ImVec2Cpy(env, THIS->MousePosPadding, dst);
*/
private native float nGetMousePosPaddingX(); /*
return THIS->MousePosPadding.x;
*/
private native float nGetMousePosPaddingY(); /*
return THIS->MousePosPadding.y;
*/
private native void nSetMousePosPadding(float valueX, float valueY); /*MANUAL
ImVec2 value = ImVec2(valueX, valueY);
THIS->MousePosPadding = value;
*/
public ImVec2 getAnnotationPadding() {
final ImVec2 dst = new ImVec2();
nGetAnnotationPadding(dst);
return dst;
}
public float getAnnotationPaddingX() {
return nGetAnnotationPaddingX();
}
public float getAnnotationPaddingY() {
return nGetAnnotationPaddingY();
}
public void getAnnotationPadding(final ImVec2 dst) {
nGetAnnotationPadding(dst);
}
public void setAnnotationPadding(final ImVec2 value) {
nSetAnnotationPadding(value.x, value.y);
}
public void setAnnotationPadding(final float valueX, final float valueY) {
nSetAnnotationPadding(valueX, valueY);
}
private native void nGetAnnotationPadding(ImVec2 dst); /*
Jni::ImVec2Cpy(env, THIS->AnnotationPadding, dst);
*/
private native float nGetAnnotationPaddingX(); /*
return THIS->AnnotationPadding.x;
*/
private native float nGetAnnotationPaddingY(); /*
return THIS->AnnotationPadding.y;
*/
private native void nSetAnnotationPadding(float valueX, float valueY); /*MANUAL
ImVec2 value = ImVec2(valueX, valueY);
THIS->AnnotationPadding = value;
*/
public ImVec2 getFitPadding() {
final ImVec2 dst = new ImVec2();
nGetFitPadding(dst);
return dst;
}
public float getFitPaddingX() {
return nGetFitPaddingX();
}
public float getFitPaddingY() {
return nGetFitPaddingY();
}
public void getFitPadding(final ImVec2 dst) {
nGetFitPadding(dst);
}
public void setFitPadding(final ImVec2 value) {
nSetFitPadding(value.x, value.y);
}
public void setFitPadding(final float valueX, final float valueY) {
nSetFitPadding(valueX, valueY);
}
private native void nGetFitPadding(ImVec2 dst); /*
Jni::ImVec2Cpy(env, THIS->FitPadding, dst);
*/
private native float nGetFitPaddingX(); /*
return THIS->FitPadding.x;
*/
private native float nGetFitPaddingY(); /*
return THIS->FitPadding.y;
*/
private native void nSetFitPadding(float valueX, float valueY); /*MANUAL
ImVec2 value = ImVec2(valueX, valueY);
THIS->FitPadding = value;
*/
public ImVec2 getPlotDefaultSize() {
final ImVec2 dst = new ImVec2();
nGetPlotDefaultSize(dst);
return dst;
}
public float getPlotDefaultSizeX() {
return nGetPlotDefaultSizeX();
}
public float getPlotDefaultSizeY() {
return nGetPlotDefaultSizeY();
}
public void getPlotDefaultSize(final ImVec2 dst) {
nGetPlotDefaultSize(dst);
}
public void setPlotDefaultSize(final ImVec2 value) {
nSetPlotDefaultSize(value.x, value.y);
}
public void setPlotDefaultSize(final float valueX, final float valueY) {
nSetPlotDefaultSize(valueX, valueY);
}
private native void nGetPlotDefaultSize(ImVec2 dst); /*
Jni::ImVec2Cpy(env, THIS->PlotDefaultSize, dst);
*/
private native float nGetPlotDefaultSizeX(); /*
return THIS->PlotDefaultSize.x;
*/
private native float nGetPlotDefaultSizeY(); /*
return THIS->PlotDefaultSize.y;
*/
private native void nSetPlotDefaultSize(float valueX, float valueY); /*MANUAL
ImVec2 value = ImVec2(valueX, valueY);
THIS->PlotDefaultSize = value;
*/
public ImVec2 getPlotMinSize() {
final ImVec2 dst = new ImVec2();
nGetPlotMinSize(dst);
return dst;
}
public float getPlotMinSizeX() {
return nGetPlotMinSizeX();
}
public float getPlotMinSizeY() {
return nGetPlotMinSizeY();
}
public void getPlotMinSize(final ImVec2 dst) {
nGetPlotMinSize(dst);
}
public void setPlotMinSize(final ImVec2 value) {
nSetPlotMinSize(value.x, value.y);
}
public void setPlotMinSize(final float valueX, final float valueY) {
nSetPlotMinSize(valueX, valueY);
}
private native void nGetPlotMinSize(ImVec2 dst); /*
Jni::ImVec2Cpy(env, THIS->PlotMinSize, dst);
*/
private native float nGetPlotMinSizeX(); /*
return THIS->PlotMinSize.x;
*/
private native float nGetPlotMinSizeY(); /*
return THIS->PlotMinSize.y;
*/
private native void nSetPlotMinSize(float valueX, float valueY); /*MANUAL
ImVec2 value = ImVec2(valueX, valueY);
THIS->PlotMinSize = value;
*/
public ImVec4[] getColors() {
return nGetColors();
}
public void setColors(final ImVec4[] value) {
nSetColors(value);
}
private native ImVec4[] nGetColors(); /*
return Jni::NewImVec4Array(env, THIS->Colors, ImPlotCol_COUNT);
*/
private native void nSetColors(ImVec4[] value); /*
Jni::ImVec4ArrayCpy(env, value, THIS->Colors, ImPlotCol_COUNT);
*/
public int getColormap() {
return nGetColormap();
}
public void setColormap(final int value) {
nSetColormap(value);
}
private native int nGetColormap(); /*
return THIS->Colormap;
*/
private native void nSetColormap(int value); /*
THIS->Colormap = value;
*/
public boolean getAntiAliasedLines() {
return nGetAntiAliasedLines();
}
public void setAntiAliasedLines(final boolean value) {
nSetAntiAliasedLines(value);
}
private native boolean nGetAntiAliasedLines(); /*
return THIS->AntiAliasedLines;
*/
private native void nSetAntiAliasedLines(boolean value); /*
THIS->AntiAliasedLines = value;
*/
public boolean getUseLocalTime() {
return nGetUseLocalTime();
}
public void setUseLocalTime(final boolean value) {
nSetUseLocalTime(value);
}
private native boolean nGetUseLocalTime(); /*
return THIS->UseLocalTime;
*/
private native void nSetUseLocalTime(boolean value); /*
THIS->UseLocalTime = value;
*/
public boolean getUseISO8601() {
return nGetUseISO8601();
}
public void setUseISO8601(final boolean value) {
nSetUseISO8601(value);
}
private native boolean nGetUseISO8601(); /*
return THIS->UseISO8601;
*/
private native void nSetUseISO8601(boolean value); /*
THIS->UseISO8601 = value;
*/
public boolean getUse24HourClock() {
return nGetUse24HourClock();
}
public void setUse24HourClock(final boolean value) {
nSetUse24HourClock(value);
}
private native boolean nGetUse24HourClock(); /*
return THIS->Use24HourClock;
*/
private native void nSetUse24HourClock(boolean value); /*
THIS->Use24HourClock = value;
*/
/*JNI
#undef THIS
*/
}
@@ -0,0 +1,115 @@
package imgui.extension.implot.flag;
public final class ImPlotAxisFlags {
private ImPlotAxisFlags() {
}
/**
* default
*
* <p>Definition: {@code 0}
*/
public static final int None = 0;
/**
* the axis label will not be displayed (axis labels also hidden if the supplied string name is NULL)
*
* <p>Definition: {@code 1 << 0}
*/
public static final int NoLabel = 1;
/**
* no grid lines will be displayed
*
* <p>Definition: {@code 1 << 1}
*/
public static final int NoGridLines = 2;
/**
* no tick marks will be displayed
*
* <p>Definition: {@code 1 << 2}
*/
public static final int NoTickMarks = 4;
/**
* no text labels will be displayed
*
* <p>Definition: {@code 1 << 3}
*/
public static final int NoTickLabels = 8;
/**
* grid lines will be displayed in the foreground (i.e. on top of data) in stead of the background
*
* <p>Definition: {@code 1 << 4}
*/
public static final int Foreground = 16;
/**
* a logartithmic (base 10) axis scale will be used (mutually exclusive with ImPlotAxisFlags_Time)
*
* <p>Definition: {@code 1 << 5}
*/
public static final int LogScale = 32;
/**
* axis will display date/time formatted labels (mutually exclusive with ImPlotAxisFlags_LogScale)
*
* <p>Definition: {@code 1 << 6}
*/
public static final int Time = 64;
/**
* the axis will be inverted
*
* <p>Definition: {@code 1 << 7}
*/
public static final int Invert = 128;
/**
* axis will not be initially fit to data extents on the first rendered frame (also the case if SetNextPlotLimits explicitly called)
*
* <p>Definition: {@code 1 << 8}
*/
public static final int NoInitialFit = 256;
/**
* axis will be auto-fitting to data extents
*
* <p>Definition: {@code 1 << 9}
*/
public static final int AutoFit = 512;
/**
* axis will only fit points if the point is in the visible range of the **orthoganol** axis
*
* <p>Definition: {@code 1 << 10}
*/
public static final int RangeFit = 1024;
/**
* the axis minimum value will be locked when panning/zooming
*
* <p>Definition: {@code 1 << 11}
*/
public static final int LockMin = 2048;
/**
* the axis maximum value will be locked when panning/zooming
*
* <p>Definition: {@code 1 << 12}
*/
public static final int LockMax = 4096;
/**
* Definition: {@code ImPlotAxisFlags_LockMin | ImPlotAxisFlags_LockMax}
*/
public static final int Lock = 6144;
/**
* Definition: {@code ImPlotAxisFlags_NoLabel | ImPlotAxisFlags_NoGridLines | ImPlotAxisFlags_NoTickMarks | ImPlotAxisFlags_NoTickLabels}
*/
public static final int NoDecorations = 15;
}
@@ -0,0 +1,35 @@
package imgui.extension.implot.flag;
public final class ImPlotBin {
private ImPlotBin() {
}
/**
* k = sqrt(n)
*
* <p>Definition: {@code -1}
*/
public static final int Sqrt = -1;
/**
* k = 1 + log2(n)
*
* <p>Definition: {@code -2}
*/
public static final int Sturges = -2;
/**
* k = 2 * cbrt(n)
*
* <p>Definition: {@code -3}
*/
public static final int Rice = -3;
/**
* w = 3.49 * sigma / cbrt(n)
*
* <p>Definition: {@code -4}
*/
public static final int Scott = -4;
}
@@ -0,0 +1,129 @@
package imgui.extension.implot.flag;
public final class ImPlotCol {
private ImPlotCol() {
}
/**
* plot line/outline color (defaults to next unused color in current colormap)
*/
public static final int Line = 0;
/**
* plot fill color for bars (defaults to the current line color)
*/
public static final int Fill = 1;
/**
* marker outline color (defaults to the current line color)
*/
public static final int MarkerOutline = 2;
/**
* marker fill color (defaults to the current line color)
*/
public static final int MarkerFill = 3;
/**
* error bar color (defaults to ImGuiCol_Text)
*/
public static final int ErrorBar = 4;
/**
* plot frame background color (defaults to ImGuiCol_FrameBg)
*/
public static final int FrameBg = 5;
/**
* plot area background color (defaults to ImGuiCol_WindowBg)
*/
public static final int PlotBg = 6;
/**
* plot area border color (defaults to ImGuiCol_Border)
*/
public static final int PlotBorder = 7;
/**
* legend background color (defaults to ImGuiCol_PopupBg)
*/
public static final int LegendBg = 8;
/**
* legend border color (defaults to ImPlotCol_PlotBorder)
*/
public static final int LegendBorder = 9;
/**
* legend text color (defaults to ImPlotCol_InlayText)
*/
public static final int LegendText = 10;
/**
* plot title text color (defaults to ImGuiCol_Text)
*/
public static final int TitleText = 11;
/**
* color of text appearing inside of plots (defaults to ImGuiCol_Text)
*/
public static final int InlayText = 12;
/**
* x-axis label and tick lables color (defaults to ImGuiCol_Text)
*/
public static final int XAxis = 13;
/**
* x-axis grid color (defaults to 25% ImPlotCol_XAxis)
*/
public static final int XAxisGrid = 14;
/**
* y-axis label and tick labels color (defaults to ImGuiCol_Text)
*/
public static final int YAxis = 15;
/**
* y-axis grid color (defaults to 25% ImPlotCol_YAxis)
*/
public static final int YAxisGrid = 16;
/**
* 2nd y-axis label and tick labels color (defaults to ImGuiCol_Text)
*/
public static final int YAxis2 = 17;
/**
* 2nd y-axis grid/label color (defaults to 25% ImPlotCol_YAxis2)
*/
public static final int YAxisGrid2 = 18;
/**
* 3rd y-axis label and tick labels color (defaults to ImGuiCol_Text)
*/
public static final int YAxis3 = 19;
/**
* 3rd y-axis grid/label color (defaults to 25% ImPlotCol_YAxis3)
*/
public static final int YAxisGrid3 = 20;
/**
* box-selection color (defaults to yellow)
*/
public static final int Selection = 21;
/**
* box-query color (defaults to green)
*/
public static final int Query = 22;
/**
* crosshairs color (defaults to ImPlotCol_PlotBorder)
*/
public static final int Crosshairs = 23;
public static final int COUNT = 24;
}
@@ -0,0 +1,119 @@
package imgui.extension.implot.flag;
public final class ImPlotColormap {
private ImPlotColormap() {
}
/**
* a.k.a. seaborn deep (qual=true, n=10) (default)
*
* <p>Definition: {@code 0}
*/
public static final int Deep = 0;
/**
* a.k.a. matplotlib "Set1" (qual=true, n=9 )
*
* <p>Definition: {@code 1}
*/
public static final int Dark = 1;
/**
* a.k.a. matplotlib "Pastel1" (qual=true, n=9 )
*
* <p>Definition: {@code 2}
*/
public static final int Pastel = 2;
/**
* a.k.a. matplotlib "Paired" (qual=true, n=12)
*
* <p>Definition: {@code 3}
*/
public static final int Paired = 3;
/**
* a.k.a. matplotlib "viridis" (qual=false, n=11)
*
* <p>Definition: {@code 4}
*/
public static final int Viridis = 4;
/**
* a.k.a. matplotlib "plasma" (qual=false, n=11)
*
* <p>Definition: {@code 5}
*/
public static final int Plasma = 5;
/**
* a.k.a. matplotlib/MATLAB "hot" (qual=false, n=11)
*
* <p>Definition: {@code 6}
*/
public static final int Hot = 6;
/**
* a.k.a. matplotlib/MATLAB "cool" (qual=false, n=11)
*
* <p>Definition: {@code 7}
*/
public static final int Cool = 7;
/**
* a.k.a. matplotlib/MATLAB "pink" (qual=false, n=11)
*
* <p>Definition: {@code 8}
*/
public static final int Pink = 8;
/**
* a.k.a. MATLAB "jet" (qual=false, n=11)
*
* <p>Definition: {@code 9}
*/
public static final int Jet = 9;
/**
* a.k.a. matplotlib "twilight" (qual=false, n=11)
*
* <p>Definition: {@code 10}
*/
public static final int Twilight = 10;
/**
* red/blue, Color Brewer (qual=false, n=11)
*
* <p>Definition: {@code 11}
*/
public static final int RdBu = 11;
/**
* brown/blue-green, Color Brewer (qual=false, n=11)
*
* <p>Definition: {@code 12}
*/
public static final int BrBG = 12;
/**
* pink/yellow-green, Color Brewer (qual=false, n=11)
*
* <p>Definition: {@code 13}
*/
public static final int PiYG = 13;
/**
* color spectrum, Color Brewer (qual=false, n=11)
*
* <p>Definition: {@code 14}
*/
public static final int Spectral = 14;
/**
* white/black (qual=false, n=2 )
*
* <p>Definition: {@code 15}
*/
public static final int Greys = 15;
}
@@ -0,0 +1,110 @@
package imgui.extension.implot.flag;
public final class ImPlotFlags {
private ImPlotFlags() {
}
/**
* default
*
* <p>Definition: {@code 0}
*/
public static final int None = 0;
/**
* the plot title will not be displayed (titles are also hidden if preceeded by double hashes, e.g. "##MyPlot")
*
* <p>Definition: {@code 1 << 0}
*/
public static final int NoTitle = 1;
/**
* the legend will not be displayed
*
* <p>Definition: {@code 1 << 1}
*/
public static final int NoLegend = 2;
/**
* the user will not be able to open context menus with right-click
*
* <p>Definition: {@code 1 << 2}
*/
public static final int NoMenus = 4;
/**
* the user will not be able to box-select with right-click drag
*
* <p>Definition: {@code 1 << 3}
*/
public static final int NoBoxSelect = 8;
/**
* the mouse position, in plot coordinates, will not be displayed inside of the plot
*
* <p>Definition: {@code 1 << 4}
*/
public static final int NoMousePos = 16;
/**
* plot items will not be highlighted when their legend entry is hovered
*
* <p>Definition: {@code 1 << 5}
*/
public static final int NoHighlight = 32;
/**
* a child window region will not be used to capture mouse scroll (can boost performance for single ImGui window applications)
*
* <p>Definition: {@code 1 << 6}
*/
public static final int NoChild = 64;
/**
* primary x and y axes will be constrained to have the same units/pixel (does not apply to auxiliary y-axes)
*
* <p>Definition: {@code 1 << 7}
*/
public static final int Equal = 128;
/**
* enable a 2nd y-axis on the right side
*
* <p>Definition: {@code 1 << 8}
*/
public static final int YAxis2 = 256;
/**
* enable a 3rd y-axis on the right side
*
* <p>Definition: {@code 1 << 9}
*/
public static final int YAxis3 = 512;
/**
* the user will be able to draw query rects with middle-mouse or CTRL + right-click drag
*
* <p>Definition: {@code 1 << 10}
*/
public static final int Query = 1024;
/**
* the default mouse cursor will be replaced with a crosshair when hovered
*
* <p>Definition: {@code 1 << 11}
*/
public static final int Crosshairs = 2048;
/**
* plot lines will be software anti-aliased (not recommended for high density plots, prefer MSAA)
*
* <p>Definition: {@code 1 << 12}
*/
public static final int AntiAliased = 4096;
/**
* Definition: {@code ImPlotFlags_NoTitle | ImPlotFlags_NoLegend | ImPlotFlags_NoMenus | ImPlotFlags_NoBoxSelect | ImPlotFlags_NoMousePos}
*/
public static final int CanvasOnly = 31;
}
Loaded 100 of 323 files, more files were not shown because too many files have changed in this diff. Show more