From fcecffa5faae3a09953f58b6156b03d2a4ebdae4 Mon Sep 17 00:00:00 2001 From: SpaiR Date: Sun, 22 Dec 2019 22:15:10 +0300 Subject: [PATCH] ImGui API --- .../groovy/imgui/generate/GenerateLibs.groovy | 1 + .../src/main/java/imgui/DrawData.java | 38 - imgui-binding/src/main/java/imgui/ImBool.java | 40 + .../imgui/{ImGuiDouble.java => ImDouble.java} | 8 +- .../src/main/java/imgui/ImDrawData.java | 171 + .../src/main/java/imgui/ImDrawList.java | 390 +- .../imgui/{ImGuiFloat.java => ImFloat.java} | 8 +- imgui-binding/src/main/java/imgui/ImGui.java | 5130 +++++++++++++---- .../src/main/java/imgui/ImGuiBoolean.java | 27 - .../src/main/java/imgui/ImGuiIO.java | 621 +- .../main/java/imgui/ImGuiInputTextData.java | 2 +- .../src/main/java/imgui/ImGuiStyle.java | 439 +- .../java/imgui/{ImGuiInt.java => ImInt.java} | 8 +- imgui-binding/src/main/java/imgui/ImLong.java | 25 + .../src/main/java/imgui/ImShort.java | 25 + .../imgui/{ImGuiString.java => ImString.java} | 14 +- imgui-binding/src/main/java/imgui/ImVec2.java | 26 +- imgui-binding/src/main/java/imgui/ImVec4.java | 39 +- imgui-binding/src/main/java/imgui/Native.java | 2162 ------- .../src/main/java/imgui/TexDataRGBA32.java | 40 +- .../java/imgui/enums/ImDrawCornerFlags.java | 2 +- .../java/imgui/enums/ImGuiBackendFlags.java | 2 +- .../java/imgui/enums/ImGuiColorEditFlags.java | 2 +- .../java/imgui/enums/ImGuiComboFlags.java | 2 +- .../src/main/java/imgui/enums/ImGuiCond.java | 2 +- .../java/imgui/enums/ImGuiConfigFlags.java | 2 +- .../src/main/java/imgui/enums/ImGuiDir.java | 2 +- .../java/imgui/enums/ImGuiDockNodeFlags.java | 2 +- .../java/imgui/enums/ImGuiDragDropFlags.java | 2 +- .../java/imgui/enums/ImGuiFocusedFlags.java | 2 +- .../java/imgui/enums/ImGuiHoveredFlags.java | 2 +- .../java/imgui/enums/ImGuiInputTextFlags.java | 2 +- .../src/main/java/imgui/enums/ImGuiKey.java | 2 +- .../java/imgui/enums/ImGuiMouseCursor.java | 8 +- .../main/java/imgui/enums/ImGuiNavInput.java | 5 +- .../imgui/enums/ImGuiSelectableFlags.java | 2 +- .../java/imgui/enums/ImGuiTabBarFlags.java | 2 +- .../java/imgui/enums/ImGuiTabItemFlags.java | 2 +- .../java/imgui/enums/ImGuiTreeNodeFlags.java | 2 +- .../java/imgui/enums/ImGuiWindowFlags.java | 2 +- .../src/main/java/imgui/enums/ImLayout.java | 2 +- imgui-binding/src/main/native/jni_common.cpp | 58 + imgui-binding/src/main/native/jni_common.h | 21 + .../src/main/java/imgui/gl3/ImGuiImplGl3.java | 23 +- .../src/test/java/ImGuiGlfwExample.java | 241 +- 45 files changed, 6025 insertions(+), 3583 deletions(-) delete mode 100644 imgui-binding/src/main/java/imgui/DrawData.java create mode 100644 imgui-binding/src/main/java/imgui/ImBool.java rename imgui-binding/src/main/java/imgui/{ImGuiDouble.java => ImDouble.java} (69%) create mode 100644 imgui-binding/src/main/java/imgui/ImDrawData.java rename imgui-binding/src/main/java/imgui/{ImGuiFloat.java => ImFloat.java} (70%) delete mode 100644 imgui-binding/src/main/java/imgui/ImGuiBoolean.java rename imgui-binding/src/main/java/imgui/{ImGuiInt.java => ImInt.java} (71%) create mode 100644 imgui-binding/src/main/java/imgui/ImLong.java create mode 100644 imgui-binding/src/main/java/imgui/ImShort.java rename imgui-binding/src/main/java/imgui/{ImGuiString.java => ImString.java} (71%) delete mode 100644 imgui-binding/src/main/java/imgui/Native.java create mode 100644 imgui-binding/src/main/native/jni_common.cpp create mode 100644 imgui-binding/src/main/native/jni_common.h diff --git a/buildSrc/src/main/groovy/imgui/generate/GenerateLibs.groovy b/buildSrc/src/main/groovy/imgui/generate/GenerateLibs.groovy index 86ee0ee..aa1e85f 100644 --- a/buildSrc/src/main/groovy/imgui/generate/GenerateLibs.groovy +++ b/buildSrc/src/main/groovy/imgui/generate/GenerateLibs.groovy @@ -24,6 +24,7 @@ class GenerateLibs extends DefaultTask { // Copy ImGui h/cpp files project.copy { CopySpec spec -> spec.from(project.rootProject.file('imgui')) { CopySpec it -> it.include('*.h', '*.cpp') } + spec.from(project.rootProject.file('imgui-binding/src/main/native')) spec.into(jniDir) } diff --git a/imgui-binding/src/main/java/imgui/DrawData.java b/imgui-binding/src/main/java/imgui/DrawData.java deleted file mode 100644 index fc17376..0000000 --- a/imgui-binding/src/main/java/imgui/DrawData.java +++ /dev/null @@ -1,38 +0,0 @@ -package imgui; - -import java.nio.ByteBuffer; -import java.nio.ByteOrder; - -public final class DrawData { - public final static int vBufferSize = (4 + 1) * 4; - public final static int iBufferSize = 2; - public final static int cmdBufferSize = (1 + 4 + 1) * 4; - public int cmdListsCount; // Number of ImDrawList* to render - public int totalIdxCount; // For convenience, sum of all ImDrawList's IdxBuffer.Size - public int totalVtxCount; - public int totalCmdCount; - public float displayPosX; - public float displayPosY; - public float displaySizeX; - public float displaySizeY; - public float framebufferScaleX; - public float framebufferScaleY; - public ByteBuffer vByteBuffer; - public ByteBuffer iByteBuffer; - public ByteBuffer cmdByteBuffer; - - public DrawData(ByteBuffer vByteBuffer, ByteBuffer iByteBuffer, ByteBuffer cmdByteBuffer) { - this.vByteBuffer = vByteBuffer; - this.iByteBuffer = iByteBuffer; - this.cmdByteBuffer = cmdByteBuffer; - } - - public DrawData(int maxVertice, int maxIndices, int maxCmd) { - this.vByteBuffer = ByteBuffer.allocateDirect(maxVertice * vBufferSize); - this.iByteBuffer = ByteBuffer.allocateDirect(maxIndices * iBufferSize); - this.cmdByteBuffer = ByteBuffer.allocateDirect(maxCmd * cmdBufferSize); - vByteBuffer.order(ByteOrder.nativeOrder()); - iByteBuffer.order(ByteOrder.nativeOrder()); - cmdByteBuffer.order(ByteOrder.nativeOrder()); - } -} diff --git a/imgui-binding/src/main/java/imgui/ImBool.java b/imgui-binding/src/main/java/imgui/ImBool.java new file mode 100644 index 0000000..98586c3 --- /dev/null +++ b/imgui-binding/src/main/java/imgui/ImBool.java @@ -0,0 +1,40 @@ +package imgui; + +import java.util.Objects; + +public final class ImBool { + boolean[] data = new boolean[]{false}; + + public ImBool() { + } + + public ImBool(boolean value) { + data[0] = value; + } + + public boolean get() { + return data[0]; + } + + public void set(boolean value) { + data[0] = value; + } + + @Override + public String toString() { + return String.valueOf(data[0]); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ImBool imBool = (ImBool) o; + return data[0] == imBool.data[0]; + } + + @Override + public int hashCode() { + return Objects.hash(data[0]); + } +} diff --git a/imgui-binding/src/main/java/imgui/ImGuiDouble.java b/imgui-binding/src/main/java/imgui/ImDouble.java similarity index 69% rename from imgui-binding/src/main/java/imgui/ImGuiDouble.java rename to imgui-binding/src/main/java/imgui/ImDouble.java index ede7da2..8c40d7f 100644 --- a/imgui-binding/src/main/java/imgui/ImGuiDouble.java +++ b/imgui-binding/src/main/java/imgui/ImDouble.java @@ -1,14 +1,14 @@ package imgui; -public class ImGuiDouble { - public static ImGuiDouble TMP = new ImGuiDouble(); +public final class ImDouble { + public static ImDouble TMP = new ImDouble(); double[] data = new double[]{0.0d}; - public ImGuiDouble() { + public ImDouble() { } - public ImGuiDouble(double value) { + public ImDouble(double value) { setValue(value); } diff --git a/imgui-binding/src/main/java/imgui/ImDrawData.java b/imgui-binding/src/main/java/imgui/ImDrawData.java new file mode 100644 index 0000000..938a92d --- /dev/null +++ b/imgui-binding/src/main/java/imgui/ImDrawData.java @@ -0,0 +1,171 @@ +package imgui; + +import java.nio.Buffer; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; + +/** + * All draw data to render a Dear ImGui frame. + * BINDING NOTICE: DO NOT TRY TO MODIFY FIELDS OF THIS CLASS MANUALLY! You should only access their values after {@link ImGui#Render()} call. + */ +public final class ImDrawData { + public static int V_BUFFER_SIZE = (4 + 1) * 4; + public static int I_BUFFER_SIZE = 2; + public static int CMD_BUFFER_SIZE = (1 + 4 + 1) * 4; + + public ByteBuffer vByteBuffer; + public ByteBuffer iByteBuffer; + public ByteBuffer cmdByteBuffer; + + public int totalIdxCount; // For convenience, sum of all ImDrawList's IdxBuffer.Size + public int totalVtxCount; // For convenience, sum of all ImDrawList's VtxBuffer.Size + public int cmdListsCount; // Number of ImDrawList* to render + + // Upper-left position of the viewport to render (== upper-left of the orthogonal projection matrix to use) + // + public float displayPosX; + public float displayPosY; + + // 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 displaySizeX; + public float displaySizeY; + + // 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 framebufferScaleX; + public float framebufferScaleY; + + ImDrawData(int maxVertices, int maxIndices, int maxCmd) { + vByteBuffer = ByteBuffer.allocateDirect(maxVertices * V_BUFFER_SIZE).order(ByteOrder.nativeOrder()); + iByteBuffer = ByteBuffer.allocateDirect(maxIndices * I_BUFFER_SIZE).order(ByteOrder.nativeOrder()); + cmdByteBuffer = ByteBuffer.allocateDirect(maxCmd * CMD_BUFFER_SIZE).order(ByteOrder.nativeOrder()); + } + + /*JNI + #include + + jfieldID totalVtxCountID; + jfieldID totalIdxCountID; + jfieldID CmdListsCountID; + jfieldID displayPosXID; + jfieldID displayPosYID; + jfieldID displaySizeXID; + jfieldID displaySizeYID; + jfieldID framebufferScaleXID; + jfieldID framebufferScaleYID; + */ + + static native void nInit(); /* + jclass jDrawDataClass = env->FindClass("imgui/ImDrawData"); + + totalVtxCountID = env->GetFieldID(jDrawDataClass, "totalVtxCount", "I"); + totalIdxCountID = env->GetFieldID(jDrawDataClass, "totalIdxCount", "I"); + CmdListsCountID = env->GetFieldID(jDrawDataClass, "cmdListsCount", "I"); + displayPosXID = env->GetFieldID(jDrawDataClass, "displayPosX", "F"); + displayPosYID = env->GetFieldID(jDrawDataClass, "displayPosY", "F"); + displaySizeXID = env->GetFieldID(jDrawDataClass, "displaySizeX", "F"); + displaySizeYID = env->GetFieldID(jDrawDataClass, "displaySizeY", "F"); + framebufferScaleXID = env->GetFieldID(jDrawDataClass, "framebufferScaleX", "F"); + framebufferScaleYID = env->GetFieldID(jDrawDataClass, "framebufferScaleY", "F"); + */ + + native void nFillDrawData(Buffer indexBuffer, Buffer vertexBuffer, Buffer cmdBuffer); /* + ImDrawData* drawData = ImGui::GetDrawData(); + + if (drawData == NULL) { + return; + } + + int cmdListsCount = drawData->CmdListsCount; + + // Set values + env->SetIntField(object, totalVtxCountID, drawData->TotalVtxCount); + env->SetIntField(object, totalIdxCountID, drawData->TotalIdxCount); + env->SetIntField(object, CmdListsCountID, cmdListsCount); + + env->SetFloatField(object, displayPosXID, drawData->DisplayPos.x); + env->SetFloatField(object, displayPosYID, drawData->DisplayPos.y); + + env->SetFloatField(object, displaySizeXID, drawData->DisplaySize.x); + env->SetFloatField(object, displaySizeYID, drawData->DisplaySize.y); + + env->SetFloatField(object, framebufferScaleXID, drawData->FramebufferScale.x); + env->SetFloatField(object, framebufferScaleYID, drawData->FramebufferScale.y); + + ImDrawList** drawLists = drawData->CmdLists; + + int verticesOffset = 0; + int indicesOffset = 0; + int cmdOffset = 0; + + for(int i = 0; i < cmdListsCount; i++) { + ImDrawList& drawList = *drawLists[i]; + ImVector& imDrawCmdList = drawList.CmdBuffer; + ImVector& idxBuffer = drawList.IdxBuffer; + ImVector& vtxBuffer = drawList.VtxBuffer; + + float* vertexArrayDest = (float*)vertexBuffer; + short* indexArrayDest = (short*)indexBuffer; + + int colorSize = 1; + int verticesItemSize = (4 + colorSize); + + vertexArrayDest[verticesOffset++] = vtxBuffer.Size; + + // copy vertices to Destination buffer + for(int j = 0; j < vtxBuffer.Size; j++) { + ImDrawVert v = vtxBuffer[j]; + float posX = v.pos.x; + float posY = v.pos.y; + float uvX = v.uv.x; + float uvY = v.uv.y; + + int byteIndex = (j * verticesItemSize) + verticesOffset; + + float color = 0; + memcpy(&color, &v.col, 4); // move unsigned int color to float + + vertexArrayDest[byteIndex + 0] = posX; + vertexArrayDest[byteIndex + 1] = posY; + vertexArrayDest[byteIndex + 2] = uvX; + vertexArrayDest[byteIndex + 3] = uvY; + vertexArrayDest[byteIndex + 4] = color; + } + verticesOffset += vtxBuffer.Size * verticesItemSize; + + // copy index to destination buffer + indexArrayDest[indicesOffset++] = idxBuffer.Size; + + for(int j = 0; j < idxBuffer.Size; j++) { + indexArrayDest[j + indicesOffset] = idxBuffer[j]; + } + + indicesOffset += idxBuffer.Size; + + float* cmdArrayDest = (float*)cmdBuffer; + + cmdArrayDest[cmdOffset++] = imDrawCmdList.Size; + int bytesOffset = 0; + int imDrawCmdSize = 1 + 4 + 1; + + for (int cmd_i = 0; cmd_i < imDrawCmdList.Size; cmd_i++) { + const ImDrawCmd* pcmd = &imDrawCmdList[cmd_i]; + + float textureID = (float)(intptr_t)pcmd->TextureId; + float tempArray [6] = { + pcmd->ElemCount, + pcmd->ClipRect.x, pcmd->ClipRect.y, + pcmd->ClipRect.z, pcmd->ClipRect.w, + textureID + }; + + memcpy((cmdArrayDest + (cmd_i * imDrawCmdSize) + cmdOffset), tempArray, imDrawCmdSize * 4); + bytesOffset = bytesOffset + imDrawCmdSize; + } + + cmdOffset += imDrawCmdList.Size * imDrawCmdSize; + } + */ +} diff --git a/imgui-binding/src/main/java/imgui/ImDrawList.java b/imgui-binding/src/main/java/imgui/ImDrawList.java index f508d46..2459f2a 100644 --- a/imgui-binding/src/main/java/imgui/ImDrawList.java +++ b/imgui-binding/src/main/java/imgui/ImDrawList.java @@ -1,128 +1,332 @@ package imgui; -import imgui.enums.ImDrawCornerFlags; +/** + * Draw command list + * This is the low-level list of polygons that ImGui:: functions are filling. At the end of the frame, + * all command lists are passed to your ImGuiIO::RenderDrawListFn function for rendering. + * Each dear imgui window contains its own ImDrawList. You can use ImGui::GetWindowDrawList() to + * access the current window draw list and draw custom primitives. + * You can interleave normal ImGui:: calls and adding primitives to the current draw list. + * All positions are generally in pixel coordinates (top-left at (0,0), bottom-right at io.DisplaySize), + * but you are totally free to apply whatever transformation matrix to want to the data (if you apply such transformation you'll want to apply it to ClipRect as well) + * Important: Primitives are always added to the list and not culled (culling is done at higher-level by ImGui:: functions), if you use this API a lot consider coarse culling your drawn objects. + */ +public final class ImDrawList { + public static final int TYPE_DEFAULT = 0; + public static final int TYPE_BACKGROUND = 1; + public static final int TYPE_FOREGROUND = 2; -public class ImDrawList { + private final int drawListType; - public final static int TYPE_DEFAULT = 0; - public final static int TYPE_BACKGROUND = 1; - public final static int TYPE_FOREGROUND = 2; - - private int type = TYPE_DEFAULT; - - public ImDrawList(int type) { - this.type = type; + ImDrawList(int drawListType) { + this.drawListType = drawListType; } - public void AddLine(float a_x, float a_y, float b_x, float b_y, int col) { - Native.AddLine(type, a_x, a_y, b_x, b_y, col); - } + /*JNI + #include + #include "jni_common.h" - public void AddLine(float a_x, float a_y, float b_x, float b_y, int col, float thinkness) { - Native.AddLine(type, a_x, a_y, b_x, b_y, col, thinkness); - } + const static int DRAWLIST_TYPE_DEFAULT = 0; + const static int DRAWLIST_TYPE_BACKGROUND = 1; + const static int DRAWLIST_TYPE_FOREGROUND = 2; - public void AddRect(float a_x, float a_y, float b_x, float b_y, int col) { - Native.AddRect(type, a_x, a_y, b_x, b_y, col); - } + ImDrawList* getDrawList(int drawListType) { + switch (drawListType) { + case DRAWLIST_TYPE_DEFAULT: + return ImGui::GetWindowDrawList(); + case DRAWLIST_TYPE_BACKGROUND: + return ImGui::GetBackgroundDrawList(); + case DRAWLIST_TYPE_FOREGROUND: + return ImGui::GetForegroundDrawList(); + default: + return NULL; + } + } - public void AddRect(float a_x, float a_y, float b_x, float b_y, int col, float rounding) { - Native.AddRect(type, a_x, a_y, b_x, b_y, col, rounding); - } + jfieldID drawListTypeID; + */ - public void AddRect(float a_x, float a_y, float b_x, float b_y, int col, float rounding, ImDrawCornerFlags rounding_corners_flags) { - Native.AddRect(type, a_x, a_y, b_x, b_y, col, rounding, rounding_corners_flags.getValue()); - } + static native void nInit(); /* + jclass jImDrawListClass = env->FindClass("imgui/ImDrawList"); + drawListTypeID = env->GetFieldID(jImDrawListClass, "drawListType", "I"); + */ - public void AddRect(float a_x, float a_y, float b_x, float b_y, int col, float rounding, ImDrawCornerFlags rounding_corners_flags, float thickness) { - Native.AddRect(type, a_x, a_y, b_x, b_y, col, rounding, rounding_corners_flags.getValue(), thickness); - } + // Flags, you may poke into these to adjust anti-aliasing settings per-primitive. + public native int getImDrawListFlags(); /* + return getDrawList(env->GetIntField(object, drawListTypeID))->Flags; + */ - public void AddRectFilled(float a_x, float a_y, float b_x, float b_y, int col) { - Native.AddRectFilled(type, a_x, a_y, b_x, b_y, col); - } + public native void setImDrawListFlags(int imDrawListFlags); /* + getDrawList(env->GetIntField(object, drawListTypeID))->Flags = imDrawListFlags; + */ - public void AddRectFilled(float a_x, float a_y, float b_x, float b_y, int col, float rounding) { - Native.AddRectFilled(type, a_x, a_y, b_x, b_y, col, rounding); - } + // Primitives + // - For rectangular primitives, "p_min" and "p_max" represent the upper-left and lower-right corners. - public void AddRectFilled(float a_x, float a_y, float b_x, float b_y, int col, float rounding, ImDrawCornerFlags rounding_corners_flags) { - Native.AddRectFilled(type, a_x, a_y, b_x, b_y, col, rounding, rounding_corners_flags.getValue()); - } + public native void AddLine(float p1_x, float p1_y, float p2_x, float p2_y, long col); /* + getDrawList(env->GetIntField(object, drawListTypeID))->AddLine(ImVec2(p1_x, p1_y), ImVec2(p2_x, p2_y), col); + */ - public void AddRectFilledMultiColor(float a_x, float a_y, float b_x, float b_y, int col_upr_left, float col_upr_right, int col_bot_right, int col_bot_left) { - Native.AddRectFilledMultiColor(type, a_x, a_y, b_x, b_y, col_upr_left, col_upr_right, col_bot_right, col_bot_left); - } + public native void AddLine(float p1_x, float p1_y, float p2_x, float p2_y, long col, float thickness); /* + getDrawList(env->GetIntField(object, drawListTypeID))->AddLine(ImVec2(p1_x, p1_y), ImVec2(p2_x, p2_y), col, thickness); + */ - public void AddQuad(float a_x, float a_y, float b_x, float b_y, float c_x, float c_y, float d_x, float d_y, int col) { - Native.AddQuad(type, a_x, a_y, b_x, b_y, c_x, c_y, d_x, d_y, col); - } + public native void AddRect(float p_min_x, float p_min_y, float p_max_x, float p_max_y, long col); /* + getDrawList(env->GetIntField(object, drawListTypeID))->AddRect(ImVec2(p_min_x, p_min_y), ImVec2(p_max_x, p_max_y), col); + */ - public void AddQuad(float a_x, float a_y, float b_x, float b_y, float c_x, float c_y, float d_x, float d_y, int col, float thickness) { - Native.AddQuad(type, a_x, a_y, b_x, b_y, c_x, c_y, d_x, d_y, col, thickness); - } + public native void AddRect(float p_min_x, float p_min_y, float p_max_x, float p_max_y, long col, float rounding); /* + getDrawList(env->GetIntField(object, drawListTypeID))->AddRect(ImVec2(p_min_x, p_min_y), ImVec2(p_max_x, p_max_y), col, rounding); + */ - public void AddQuadFilled(float a_x, float a_y, float b_x, float b_y, float c_x, float c_y, float d_x, float d_y, int col) { - Native.AddQuadFilled(type, a_x, a_y, b_x, b_y, c_x, c_y, d_x, d_y, col); - } + public native void AddRect(float p_min_x, float p_min_y, float p_max_x, float p_max_y, long col, float rounding, int rounding_corners_flags); /* + getDrawList(env->GetIntField(object, drawListTypeID))->AddRect(ImVec2(p_min_x, p_min_y), ImVec2(p_max_x, p_max_y), col, rounding, rounding_corners_flags); + */ - public void AddTriangle(float a_x, float a_y, float b_x, float b_y, float c_x, float c_y, int col) { - Native.AddTriangle(type, a_x, a_y, b_x, b_y, c_x, c_y, col); - } + public native void AddRect(float p_min_x, float p_min_y, float p_max_x, float p_max_y, long col, float rounding, int rounding_corners_flags, float thickness); /* + getDrawList(env->GetIntField(object, drawListTypeID))->AddRect(ImVec2(p_min_x, p_min_y), ImVec2(p_max_x, p_max_y), col, rounding, rounding_corners_flags, thickness); + */ - public void AddTriangle(float a_x, float a_y, float b_x, float b_y, float c_x, float c_y, int col, float thickness) { - Native.AddTriangle(type, a_x, a_y, b_x, b_y, c_x, c_y, col, thickness); - } + public native void AddRectFilled(float p_min_x, float p_min_y, float p_max_x, float p_max_y, long col); /* + getDrawList(env->GetIntField(object, drawListTypeID))->AddRectFilled(ImVec2(p_min_x, p_min_y), ImVec2(p_max_x, p_max_y), col); + */ - public void AddTriangleFilled(float a_x, float a_y, float b_x, float b_y, float c_x, float c_y, int col) { - Native.AddTriangleFilled(type, a_x, a_y, b_x, b_y, c_x, c_y, col); - } + public native void AddRectFilled(float p_min_x, float p_min_y, float p_max_x, float p_max_y, long col, float rounding); /* + getDrawList(env->GetIntField(object, drawListTypeID))->AddRectFilled(ImVec2(p_min_x, p_min_y), ImVec2(p_max_x, p_max_y), col, rounding); + */ - public void AddCircle(float centre_x, float centre_y, float radius, float col, int num_segments, float thickness) { - Native.AddCircle(type, centre_x, centre_y, radius, col, num_segments, thickness); - } + public native void AddRectFilled(float p_min_x, float p_min_y, float p_max_x, float p_max_y, long col, float rounding, int rounding_corners_flags); /* + getDrawList(env->GetIntField(object, drawListTypeID))->AddRectFilled(ImVec2(p_min_x, p_min_y), ImVec2(p_max_x, p_max_y), col, rounding, rounding_corners_flags); + */ - public void AddCircleFilled(float centre_x, float centre_y, float radius, float col) { - Native.AddCircleFilled(type, centre_x, centre_y, radius, col); - } + public native void AddRectFilledMultiColor(float p_min_x, float p_min_y, float p_max_x, float p_max_y, long col_upr_left, long col_upr_right, long col_bot_right, long col_bot_left); /* + getDrawList(env->GetIntField(object, drawListTypeID))->AddRectFilledMultiColor(ImVec2(p_min_x, p_min_y), ImVec2(p_max_x, p_max_y), col_upr_left, col_upr_right, col_bot_right, col_bot_left); + */ - public void AddCircleFilled(float centre_x, float centre_y, float radius, float col, int num_segments) { - Native.AddCircleFilled(type, centre_x, centre_y, radius, col, num_segments); - } + public native void AddQuad(float p1_x, float p1_y, float p2_x, float p2_y, float p3_x, float p3_y, float p4_x, float p4_y, long col); /* + getDrawList(env->GetIntField(object, drawListTypeID))->AddQuad(ImVec2(p1_x, p1_y), ImVec2(p2_x, p2_y), ImVec2(p3_x, p3_y), ImVec2(p4_x, p4_y), col); + */ - public void AddText(float pos_x, float pos_y, int col, String text_begin) { - Native.AddText(type, pos_x, pos_y, col, text_begin); - } + public native void AddQuad(float p1_x, float p1_y, float p2_x, float p2_y, float p3_x, float p3_y, float p4_x, float p4_y, long col, float thickness); /* + getDrawList(env->GetIntField(object, drawListTypeID))->AddQuad(ImVec2(p1_x, p1_y), ImVec2(p2_x, p2_y), ImVec2(p3_x, p3_y), ImVec2(p4_x, p4_y), col, thickness); + */ - public void AddText(float pos_x, float pos_y, int col, String text_begin, String text_end) { - Native.AddText(type, pos_x, pos_y, col, text_begin, text_end); - } + public native void AddQuadFilled(float p1_x, float p1_y, float p2_x, float p2_y, float p3_x, float p3_y, float p4_x, float p4_y, long col); /* + getDrawList(env->GetIntField(object, drawListTypeID))->AddQuadFilled(ImVec2(p1_x, p1_y), ImVec2(p2_x, p2_y), ImVec2(p3_x, p3_y), ImVec2(p4_x, p4_y), col); + */ - // TODO AddText + public native void AddTriangle(float p1_x, float p1_y, float p2_x, float p2_y, float p3_x, float p3_y, long col); /* + getDrawList(env->GetIntField(object, drawListTypeID))->AddTriangle(ImVec2(p1_x, p1_y), ImVec2(p2_x, p2_y), ImVec2(p3_x, p3_y), col); + */ - public void AddImage(int textureID, float a_x, float a_y, float b_x, float b_y) { - Native.AddImage(type, textureID, a_x, a_y, b_x, b_y); - } + public native void AddTriangle(float p1_x, float p1_y, float p2_x, float p2_y, float p3_x, float p3_y, long col, float thickness); /* + getDrawList(env->GetIntField(object, drawListTypeID))->AddTriangle(ImVec2(p1_x, p1_y), ImVec2(p2_x, p2_y), ImVec2(p3_x, p3_y), col, thickness); + */ - public void AddImage(int textureID, float a_x, float a_y, float b_x, float b_y, float uv_a_x, float uv_a_y, float uv_b_x, float uv_b_y) { - Native.AddImage(type, textureID, a_x, a_y, b_x, b_y, uv_a_x, uv_a_y, uv_b_x, uv_b_y); - } + public native void AddTriangleFilled(float p1_x, float p1_y, float p2_x, float p2_y, float p3_x, float p3_y, long col); /* + getDrawList(env->GetIntField(object, drawListTypeID))->AddTriangleFilled(ImVec2(p1_x, p1_y), ImVec2(p2_x, p2_y), ImVec2(p3_x, p3_y), col); + */ - //TODO AddImageQuad, AddImageRounded, AddPolyline, AddConvexPolyFilled + public native void AddCircle(float centre_x, float centre_y, float radius, float col); /* + getDrawList(env->GetIntField(object, drawListTypeID))->AddCircle(ImVec2(centre_x, centre_y), radius, col); + */ - public void AddBezierCurve(float pos0_x, float pos0_y, float cp0_x, float cp0_y, float cp1_x, float cp1_y, float pos1_x, float pos1_y, float col, float thickness) { - Native.AddBezierCurve(type, pos0_x, pos0_y, cp0_x, cp0_y, cp1_x, cp1_y, pos1_x, pos1_y, col, thickness); - } + public native void AddCircle(float centre_x, float centre_y, float radius, float col, int num_segments); /* + getDrawList(env->GetIntField(object, drawListTypeID))->AddCircle(ImVec2(centre_x, centre_y), radius, col, num_segments); + */ - public void ChannelsSplit(int count) { - Native.ChannelsSplit(type, count); - } + public native void AddCircle(float centre_x, float centre_y, float radius, float col, int num_segments, float thickness); /* + getDrawList(env->GetIntField(object, drawListTypeID))->AddCircle(ImVec2(centre_x, centre_y), radius, col, num_segments, thickness); + */ - public void ChannelsMerge() { - Native.ChannelsMerge(type); - } + public native void AddCircleFilled(float centre_x, float centre_y, float radius, float col); /* + getDrawList(env->GetIntField(object, drawListTypeID))->AddCircleFilled(ImVec2(centre_x, centre_y), radius, col); + */ - public void ChannelsSetCurrent(int n) { - Native.ChannelsSetCurrent(type, n); - } + public native void AddCircleFilled(float centre_x, float centre_y, float radius, float col, int num_segments); /* + getDrawList(env->GetIntField(object, drawListTypeID))->AddCircleFilled(ImVec2(centre_x, centre_y), radius, col, num_segments); + */ + + public native void AddText(float pos_x, float pos_y, int col, String text_begin); /* + getDrawList(env->GetIntField(object, drawListTypeID))->AddText(ImVec2(pos_x, pos_y), col, text_begin); + */ + + public native void AddText(float pos_x, float pos_y, int col, String text_begin, String text_end); /* + getDrawList(env->GetIntField(object, drawListTypeID))->AddText(ImVec2(pos_x, pos_y), col, text_begin, text_end); + */ + + // TODO add text with font support + + public native void AddPolyline(ImVec2[] points, int num_points, long col, boolean closed, float thickness); /* + int points_num = env->GetArrayLength(points); + ImVec2 _points[points_num]; + for (int i = 0; i < points_num; i++) { + jobject jImVec2 = env->GetObjectArrayElement(points, i); + ImVec2 dst; + Jni::ImVec2Cpy(env, jImVec2, &dst); + _points[i] = dst; + } + getDrawList(env->GetIntField(object, drawListTypeID))->AddPolyline(_points, num_points, col, closed, thickness); + */ + + // Note: Anti-aliased filling requires points to be in clockwise order. + public native void AddConvexPolyFilled(ImVec2[] points, int num_points, long col); /* + int points_num = env->GetArrayLength(points); + ImVec2 _points[points_num]; + for (int i = 0; i < points_num; i++) { + jobject jImVec2 = env->GetObjectArrayElement(points, i); + ImVec2 dst; + Jni::ImVec2Cpy(env, jImVec2, &dst); + _points[i] = dst; + } + getDrawList(env->GetIntField(object, drawListTypeID))->AddConvexPolyFilled(_points, num_points, col); + */ + + public native void AddBezierCurve(float pos0_x, float pos0_y, float cp0_x, float cp0_y, float cp1_x, float cp1_y, float pos1_x, float pos1_y, long col, float thickness); /* + getDrawList(env->GetIntField(object, drawListTypeID))->AddBezierCurve(ImVec2(pos0_x, pos0_y), ImVec2(cp0_x, cp0_y), ImVec2(cp1_x, cp1_y), ImVec2(pos1_x, pos1_y), col, thickness); + */ + + public native void AddBezierCurve(float pos0_x, float pos0_y, float cp0_x, float cp0_y, float cp1_x, float cp1_y, float pos1_x, float pos1_y, long col, float thickness, int num_segments); /* + getDrawList(env->GetIntField(object, drawListTypeID))->AddBezierCurve(ImVec2(pos0_x, pos0_y), ImVec2(cp0_x, cp0_y), ImVec2(cp1_x, cp1_y), ImVec2(pos1_x, pos1_y), col, thickness, num_segments); + */ + + // Image primitives + // - Read FAQ to understand what ImTextureID is. + // - "p_min" and "p_max" represent the upper-left and lower-right corners of the rectangle. + // - "uv_min" and "uv_max" represent the normalized texture coordinates to use for those corners. Using (0,0)->(1,1) texture coordinates will generally display the entire texture. + + public native void AddImage(int textureID, float p_min_x, float p_min_y, float p_max_x, float p_max_y); /* + ImDrawList* drawList = getDrawList(env->GetIntField(object, drawListTypeID)); + drawList->AddImage((ImTextureID)textureID, ImVec2(p_min_x, p_min_y), ImVec2(p_max_x, p_max_y)); + */ + + public native void AddImage(int textureID, float p_min_x, float p_min_y, float p_max_x, float p_max_y, float uv_min_x, float uv_min_y); /* + ImDrawList* drawList = getDrawList(env->GetIntField(object, drawListTypeID)); + drawList->AddImage((ImTextureID)textureID, ImVec2(p_min_x, p_min_y), ImVec2(p_max_x, p_max_y), ImVec2(uv_min_x, uv_min_y)); + */ + + public native void AddImage(int textureID, float p_min_x, float p_min_y, float p_max_x, float p_max_y, float uv_min_x, float uv_min_y, float uv_max_x, float uv_max_y); /* + ImDrawList* drawList = getDrawList(env->GetIntField(object, drawListTypeID)); + drawList->AddImage((ImTextureID)textureID, ImVec2(p_min_x, p_min_y), ImVec2(p_max_x, p_max_y), ImVec2(uv_min_x, uv_min_y), ImVec2(uv_max_x, uv_max_y)); + */ + + public native void AddImage(int textureID, float p_min_x, float p_min_y, float p_max_x, float p_max_y, float uv_min_x, float uv_min_y, float uv_max_x, float uv_max_y, long col); /* + ImDrawList* drawList = getDrawList(env->GetIntField(object, drawListTypeID)); + drawList->AddImage((ImTextureID)textureID, ImVec2(p_min_x, p_min_y), ImVec2(p_max_x, p_max_y), ImVec2(uv_min_x, uv_min_y), ImVec2(uv_max_x, uv_max_y), col); + */ + + public native void AddImageQuad(int textureID, float p1_x, float p1_y, float p2_x, float p2_y, float p3_x, float p3_y, float p4_x, float p4_y); /* + ImDrawList* drawList = getDrawList(env->GetIntField(object, drawListTypeID)); + drawList->AddImageQuad((ImTextureID)textureID, ImVec2(p1_x, p1_y), ImVec2(p2_x, p2_y), ImVec2(p3_x, p3_y), ImVec2(p4_x, p4_y)); + */ + + public native void AddImageQuad(int textureID, float p1_x, float p1_y, float p2_x, float p2_y, float p3_x, float p3_y, float p4_x, float p4_y, float uv1_x, float uv1_y); /* + ImDrawList* drawList = getDrawList(env->GetIntField(object, drawListTypeID)); + drawList->AddImageQuad((ImTextureID)textureID, ImVec2(p1_x, p1_y), ImVec2(p2_x, p2_y), ImVec2(p3_x, p3_y), ImVec2(p4_x, p4_y), ImVec2(uv1_x, uv1_y)); + */ + + public native void AddImageQuad(int textureID, float p1_x, float p1_y, float p2_x, float p2_y, float p3_x, float p3_y, float p4_x, float p4_y, float uv1_x, float uv1_y, float uv2_x, float uv2_y); /* + ImDrawList* drawList = getDrawList(env->GetIntField(object, drawListTypeID)); + drawList->AddImageQuad((ImTextureID)textureID, ImVec2(p1_x, p1_y), ImVec2(p2_x, p2_y), ImVec2(p3_x, p3_y), ImVec2(p4_x, p4_y), ImVec2(uv1_x, uv1_y), ImVec2(uv2_x, uv2_y)); + */ + + public native void AddImageQuad(int textureID, float p1_x, float p1_y, float p2_x, float p2_y, float p3_x, float p3_y, float p4_x, float p4_y, float uv1_x, float uv1_y, float uv2_x, float uv2_y, float uv3_x, float uv3_y); /* + ImDrawList* drawList = getDrawList(env->GetIntField(object, drawListTypeID)); + drawList->AddImageQuad((ImTextureID)textureID, ImVec2(p1_x, p1_y), ImVec2(p2_x, p2_y), ImVec2(p3_x, p3_y), ImVec2(p4_x, p4_y), ImVec2(uv1_x, uv1_y), ImVec2(uv2_x, uv2_y), ImVec2(uv3_x, uv3_y)); + */ + + public native void AddImageQuad(int textureID, float p1_x, float p1_y, float p2_x, float p2_y, float p3_x, float p3_y, float p4_x, float p4_y, float uv1_x, float uv1_y, float uv2_x, float uv2_y, float uv3_x, float uv3_y, float uv4_x, float uv4_y); /* + ImDrawList* drawList = getDrawList(env->GetIntField(object, drawListTypeID)); + drawList->AddImageQuad((ImTextureID)textureID, ImVec2(p1_x, p1_y), ImVec2(p2_x, p2_y), ImVec2(p3_x, p3_y), ImVec2(p4_x, p4_y), ImVec2(uv1_x, uv1_y), ImVec2(uv2_x, uv2_y), ImVec2(uv3_x, uv3_y), ImVec2(uv4_x, uv4_y)); + */ + + public native void AddImageQuad(int textureID, float p1_x, float p1_y, float p2_x, float p2_y, float p3_x, float p3_y, float p4_x, float p4_y, float uv1_x, float uv1_y, float uv2_x, float uv2_y, float uv3_x, float uv3_y, float uv4_x, float uv4_y, long col); /* + ImDrawList* drawList = getDrawList(env->GetIntField(object, drawListTypeID)); + drawList->AddImageQuad((ImTextureID)textureID, ImVec2(p1_x, p1_y), ImVec2(p2_x, p2_y), ImVec2(p3_x, p3_y), ImVec2(p4_x, p4_y), ImVec2(uv1_x, uv1_y), ImVec2(uv2_x, uv2_y), ImVec2(uv3_x, uv3_y), ImVec2(uv4_x, uv4_y), col); + */ + + public native void AddImageRounded(int textureID, float p_min_x, float p_min_y, float p_max_x, float p_max_y, float uv_min_x, float uv_min_y, float uv_max_x, float uv_max_y, long col, float rounding); /* + ImDrawList* drawList = getDrawList(env->GetIntField(object, drawListTypeID)); + drawList->AddImageRounded((ImTextureID)textureID, ImVec2(p_min_x, p_min_y), ImVec2(p_max_x, p_max_y), ImVec2(uv_min_x, uv_min_y), ImVec2(uv_max_x, uv_max_y), col, rounding); + */ + + public native void AddImageRounded(int textureID, float p_min_x, float p_min_y, float p_max_x, float p_max_y, float uv_min_x, float uv_min_y, float uv_max_x, float uv_max_y, long col, float rounding, int imDrawCornerFlags); /* + ImDrawList* drawList = getDrawList(env->GetIntField(object, drawListTypeID)); + drawList->AddImageRounded((ImTextureID)textureID, ImVec2(p_min_x, p_min_y), ImVec2(p_max_x, p_max_y), ImVec2(uv_min_x, uv_min_y), ImVec2(uv_max_x, uv_max_y), col, rounding, imDrawCornerFlags); + */ + + // Stateful path API, add points then finish with PathFillConvex() or PathStroke() + + public native void PathClear(); /* + getDrawList(env->GetIntField(object, drawListTypeID))->PathClear(); + */ + + public native void PathLineTo(float pos_x, float pos_y); /* + getDrawList(env->GetIntField(object, drawListTypeID))->PathLineTo(ImVec2(pos_x, pos_y)); + */ + + public native void PathLineToMergeDuplicate(float pos_x, float pos_y); /* + getDrawList(env->GetIntField(object, drawListTypeID))->PathLineToMergeDuplicate(ImVec2(pos_x, pos_y)); + */ + + // Note: Anti-aliased filling requires points to be in clockwise order. + public native void PathFillConvex(long col); /* + getDrawList(env->GetIntField(object, drawListTypeID))->PathFillConvex(col); + */ + + public native void PathStroke(long col, boolean closed); /* + getDrawList(env->GetIntField(object, drawListTypeID))->PathStroke(col, closed); + */ + + public native void PathStroke(long col, boolean closed, float thickness); /* + getDrawList(env->GetIntField(object, drawListTypeID))->PathStroke(col, closed, thickness); + */ + + public native void PathArcTo(float center_x, float center_y, float radius, float a_min, float a_max); /* + getDrawList(env->GetIntField(object, drawListTypeID))->PathArcTo(ImVec2(center_x, center_y), radius, a_min, a_max); + */ + + public native void PathArcTo(float center_x, float center_y, float radius, float a_min, float a_max, int num_segments); /* + getDrawList(env->GetIntField(object, drawListTypeID))->PathArcTo(ImVec2(center_x, center_y), radius, a_min, a_max, num_segments); + */ + + // Use precomputed angles for a 12 steps circle + public native void PathArcToFast(float center_x, float center_y, float radius, int a_min_of_12, int a_max_of_12); /* + getDrawList(env->GetIntField(object, drawListTypeID))->PathArcToFast(ImVec2(center_x, center_y), radius, a_min_of_12, a_max_of_12); + */ + + public native void PathBezierCurveTo(float p1_x, float p1_y, float p2_x, float p2_y, float p3_x, float p3_y, int num_segments); /* + getDrawList(env->GetIntField(object, drawListTypeID))->PathBezierCurveTo(ImVec2(p1_x, p1_y), ImVec2(p2_x, p2_y), ImVec2(p3_x, p3_y), num_segments); + */ + + public native void PathRect(float rect_min_x, float rect_min_y, float rect_max_x, float rect_max_y); /* + getDrawList(env->GetIntField(object, drawListTypeID))->PathRect(ImVec2(rect_min_x, rect_min_y), ImVec2(rect_max_x, rect_max_y)); + */ + + public native void PathRect(float rect_min_x, float rect_min_y, float rect_max_x, float rect_max_y, float rounding); /* + getDrawList(env->GetIntField(object, drawListTypeID))->PathRect(ImVec2(rect_min_x, rect_min_y), ImVec2(rect_max_x, rect_max_y), rounding); + */ + + public native void PathRect(float rect_min_x, float rect_min_y, float rect_max_x, float rect_max_y, float rounding, int imDrawCornerFlags); /* + getDrawList(env->GetIntField(object, drawListTypeID))->PathRect(ImVec2(rect_min_x, rect_min_y), ImVec2(rect_max_x, rect_max_y), rounding, imDrawCornerFlags); + */ + + // Advanced: Channels + // - Use to split render into layers. By switching channels to can render out-of-order (e.g. submit foreground primitives before background primitives) + // - Use to minimize draw calls (e.g. if going back-and-forth between multiple non-overlapping clipping rectangles, prefer to append into separate channels then merge at the end) + + public native void ChannelsSplit(int count); /* + ImDrawList* drawList = getDrawList(env->GetIntField(object, drawListTypeID)); + drawList->ChannelsSplit(count); + */ + + public native void ChannelsMerge(); /* + ImDrawList* drawList = getDrawList(env->GetIntField(object, drawListTypeID)); + drawList->ChannelsMerge(); + */ + + public native void ChannelsSetCurrent(int n); /* + ImDrawList* drawList = getDrawList(env->GetIntField(object, drawListTypeID)); + drawList->ChannelsSetCurrent(n); + */ } diff --git a/imgui-binding/src/main/java/imgui/ImGuiFloat.java b/imgui-binding/src/main/java/imgui/ImFloat.java similarity index 70% rename from imgui-binding/src/main/java/imgui/ImGuiFloat.java rename to imgui-binding/src/main/java/imgui/ImFloat.java index 36a25a5..e347b56 100644 --- a/imgui-binding/src/main/java/imgui/ImGuiFloat.java +++ b/imgui-binding/src/main/java/imgui/ImFloat.java @@ -1,14 +1,14 @@ package imgui; -public class ImGuiFloat { - public static ImGuiFloat TMP = new ImGuiFloat(); +public final class ImFloat { + public static ImFloat TMP = new ImFloat(); float[] data = new float[]{0.0f}; - public ImGuiFloat() { + public ImFloat() { } - public ImGuiFloat(float value) { + public ImFloat(float value) { setValue(value); } diff --git a/imgui-binding/src/main/java/imgui/ImGui.java b/imgui-binding/src/main/java/imgui/ImGui.java index f5a9a59..fa46a28 100644 --- a/imgui-binding/src/main/java/imgui/ImGui.java +++ b/imgui-binding/src/main/java/imgui/ImGui.java @@ -1,166 +1,250 @@ package imgui; -import imgui.enums.*; +import imgui.enums.ImGuiInputTextFlags; -import java.nio.Buffer; import java.nio.ByteBuffer; -public class ImGui { - private static final String LIB_NAME_PROP = "imgui.library.name"; - private static final String LIB_NAME_DEFAULT = "imgui-java"; +public final class ImGui { + private final static String LIB_NAME_PROP = "imgui.library.name"; + private final static String LIB_NAME_DEFAULT = "imgui-java"; - public static boolean enableLogging = true; - public static String TAG = "ImGui"; - private static boolean IMGUIINIT = false; - private static DrawData drawData = new DrawData(100000, 100000, 1000); - private static ImGuiIO imguiIO = new ImGuiIO(); - private static ImGuiStyle imguiStyle = new ImGuiStyle(); - private static ImVec2 imVec2 = new ImVec2(); - private static ImVec4 imVec4 = new ImVec4(); - private static ImDrawList imDrawList = new ImDrawList(ImDrawList.TYPE_DEFAULT); - private static ImDrawList imDrawListBackground = new ImDrawList(ImDrawList.TYPE_BACKGROUND); - private static ImDrawList imDrawListForeground = new ImDrawList(ImDrawList.TYPE_FOREGROUND); + private static final ImDrawData DRAW_DATA = new ImDrawData(100_000, 100_000, 1000); + private static final ImGuiIO IMGUI_IO = new ImGuiIO(); + private static final ImGuiStyle IMGUI_STYLE = new ImGuiStyle(); + private static final ImDrawList IM_DRAW_LIST = new ImDrawList(ImDrawList.TYPE_DEFAULT); + private static final ImDrawList IM_DRAW_LIST_BACKGROUND = new ImDrawList(ImDrawList.TYPE_BACKGROUND); + private static final ImDrawList IM_DRAW_LIST_FOREGROUND = new ImDrawList(ImDrawList.TYPE_FOREGROUND); - protected ImGui() { - } - - public static void init() { - init(true); - } - - public static void init(boolean logging) { - if (ImGui.IMGUIINIT) - return; + static { System.loadLibrary(System.getProperty(LIB_NAME_PROP, LIB_NAME_DEFAULT)); - ImGui.IMGUIINIT = true; - ImGui.enableLogging = logging; - - Native.init(); - Native.CreateContext(); + initJniCommon(); + ImDrawList.nInit(); + ImDrawData.nInit(); + nInitInputTextData(); } - public static void destroy() { - Native.DestroyContext(); + private ImGui() { } + /*JNI + #include + #include "jni_common.h" + */ + + private native static void initJniCommon(); /* + Jni::InitCommon(env); + */ + + // Context creation and access + // Each context create its own ImFontAtlas by default. + // You may instance one yourself and pass it to CreateContext() to share a font atlas between imgui contexts. + // None of those functions is reliant on the current context. + // + // BINDING NOTICE: Getting of the current context is not implemented since it's a part of internal API which is not exposed here. + + public native static void CreateContext(); /* + ImGui::CreateContext(); + */ + + // public static void CreateContext(ImFontAtlas sharedFontAtlas) TODO create context with fonts + + public native static void DestroyContext(); /* + ImGui::DestroyContext(); + */ + + // Main + + /** + * Access the IO structure (mouse/keyboard/gamepad inputs, time, various configuration options/flags). + */ public static ImGuiIO GetIO() { - return imguiIO; + return IMGUI_IO; } + /** + * Access the Style structure (colors, sizes). Always use PushStyleCol(), PushStyleVar() to modify style mid-frame. + */ public static ImGuiStyle GetStyle() { - return imguiStyle; + return IMGUI_STYLE; } - public static void ShowStyleEditor() { - Native.ShowStyleEditor(); - } + /** + * Start a new Dear ImGui frame, you can submit any command from this point until Render()/EndFrame(). + */ + public native static void NewFrame(); /* + ImGui::NewFrame(); + */ - public static void ShowDemoWindow() { - Native.ShowDemoWindow(); - } + /** + * Ends the Dear ImGui frame. automatically called by Render(), you likely don't need to call that yourself directly. + * If you don't need to render data (skipping rendering) you may call EndFrame() but you'll have wasted CPU already! + * If you don't need to render, better to not create any imgui windows and not call NewFrame() at all! + */ + public native static void EndFrame(); /* + ImGui::EndFrame(); + */ - public static void ShowDemoWindow(boolean open) { - Native.ShowDemoWindow(open); - } + /** + * Ends the Dear ImGui frame, finalize the draw data. + * You can get call GetDrawData() to obtain it and run your rendering function. + */ + public native static void Render(); /* + ImGui::Render(); + */ - public static void ShowMetricsWindow() { - Native.ShowMetricsWindow(); - } - - public static void ShowMetricsWindow(boolean open) { - Native.ShowMetricsWindow(open); - } - - public static void UpdateDisplaySize(float width, float height, float frameBufferWidth, float frameBufferHeight) { - Native.UpdateDisplaySize(width, height, frameBufferWidth, frameBufferHeight); - } - - public static void UpdateMousePos(float mouseX, float mouseY) { - Native.UpdateMousePos(mouseX, mouseY); - } - - public static void UpdateMouseState(boolean mouseDown0, boolean mouseDown1, boolean mouseDown2, boolean mouseDown3, boolean mouseDown4, boolean mouseDown5) { - Native.UpdateMouseState(mouseDown0, mouseDown1, mouseDown2, mouseDown3, mouseDown4, mouseDown5); - } - - public static void UpdateImGui() { - Native.UpdateImGui(imguiIO, imguiStyle); - } - - public static void UpdateDeltaTime(float deltaTime) { - Native.UpdateDeltaTime(deltaTime); - } - - public static void initKeyMap(int[] keys) { - Native.initKeyMap(keys); - } - - public static void UpdateKey(int key, boolean pressed, boolean released, boolean ctrlKey, boolean shiftKey, boolean altKey, boolean superKey) { - Native.UpdateKey(key, pressed, released, ctrlKey, shiftKey, altKey, superKey); - } - - public static void UpdateScroll(float amountX, float amountY) { - Native.UpdateScroll(amountX, amountY); - } - - public static void UpdateKeyTyped(int c) { - Native.UpdateKeyTyped(c); - } - - public static void NewFrame() { - Native.NewFrame(); - } - - public static void EndFrame() { - Native.EndFrame(); - } - - public static void Render() { - Native.Render(); - } - - public static DrawData GetDrawData() { - ByteBuffer cmdByteBuffer = drawData.cmdByteBuffer; - ByteBuffer vByteBuffer = drawData.vByteBuffer; - ByteBuffer iByteBuffer = drawData.iByteBuffer; + /** + * Valid after Render() and until the next call to NewFrame(). this is what you have to render. + */ + public static ImDrawData GetDrawData() { + ByteBuffer cmdByteBuffer = DRAW_DATA.cmdByteBuffer; + ByteBuffer vByteBuffer = DRAW_DATA.vByteBuffer; + ByteBuffer iByteBuffer = DRAW_DATA.iByteBuffer; vByteBuffer.position(0); iByteBuffer.position(0); cmdByteBuffer.position(0); - Native.GetDrawData(drawData, iByteBuffer, vByteBuffer, cmdByteBuffer); - return drawData; + DRAW_DATA.nFillDrawData(iByteBuffer, vByteBuffer, cmdByteBuffer); + return DRAW_DATA; } - public static void GetTexDataAsRGBA32(TexDataRGBA32 jTexData, Buffer pixelBuffer) { - Native.GetTexDataAsRGBA32(jTexData, pixelBuffer); + // Demo, Debug, Information + + /** + * Create Demo window (previously called ShowTestWindow). demonstrate most ImGui features. + * Call this to learn about the library! + */ + public native static void ShowDemoWindow(); /* + ImGui::ShowDemoWindow(); + */ + + public static void ShowDemoWindow(ImBool pOpen) { + nShowDemoWindow(pOpen.data); } - public static void SetFontTexID(int id) { - Native.SetFontTexID(id); + private native static void nShowDemoWindow(boolean[] pOpen); /* + ImGui::ShowDemoWindow(&pOpen[0]); + */ + + /** + * Create About window. display Dear ImGui version, credits and build/system information. + */ + public native static void ShowAboutWindow(); /* + ImGui::ShowAboutWindow(); + */ + + public static void ShowAboutWindow(ImBool pOpen) { + nShowAboutWindow(pOpen.data); } - public static void StyleColorsDark() { - Native.StyleColorsDark(); + private native static void nShowAboutWindow(boolean[] pOpen); /* + ImGui::ShowAboutWindow(&pOpen[0]); + */ + + /** + * Create Metrics/Debug window. + * Display Dear ImGui internals: draw commands (with individual draw calls and vertices), window list, basic internal state, etc. + */ + public native static void ShowMetricsWindow(); /* + ImGui::ShowMetricsWindow(); + */ + + public static void ShowMetricsWindow(ImBool pOpen) { + nShowMetricsWindow(pOpen.data); } - public static void StyleColorsClassic() { - Native.StyleColorsClassic(); + private native static void nShowMetricsWindow(boolean[] pOpen); /* + ImGui::ShowMetricsWindow(&pOpen[0]); + */ + + /** + * Add style editor block (not a window). + * You can pass in a reference ImGuiStyle structure to compare to, revert to and save to (else it uses the default style) + */ + public native static void ShowStyleEditor(); /* + ImGui::ShowStyleEditor(); + */ + + /** + * Add style selector block (not a window), essentially a combo listing the default styles. + */ + public native static boolean ShowStyleSelector(String label); /* + return ImGui::ShowStyleSelector(label); + */ + + /** + * Add font selector block (not a window), essentially a combo listing the loaded fonts. + */ + public native static void ShowFontSelector(String label); /* + ImGui::ShowFontSelector(label); + */ + + /** + * Add basic help/info block (not a window): how to manipulate ImGui as a end-user (mouse/keyboard controls). + */ + public native static void ShowUserGuide(); /* + ImGui::ShowUserGuide(); + */ + + /** + * Get the compiled version string e.g. "1.23" (essentially the compiled value for IMGUI_VERSION) + */ + public native static String GetVersion(); /* + return env->NewStringUTF(ImGui::GetVersion()); + */ + + // Styles + + /** + * New, recommended style (default) + */ + public native static void StyleColorsDark(); /* + ImGui::StyleColorsDark(); + */ + + /** + * Classic imgui style + */ + public native static void StyleColorsClassic(); /* + ImGui::StyleColorsClassic(); + */ + + /** + * Best used with borders and a custom, thicker font + */ + public native static void StyleColorsLight(); /* + ImGui::StyleColorsLight(); + */ + + // Windows + // - Begin() = push window to the stack and start appending to it. End() = pop window from the stack. + // - You may append multiple times to the same window during the same frame. + // - Passing 'bool* pOpen != NULL' shows a window-closing widget in the upper-right corner of the window, + // which clicking will set the boolean to false when clicked. + // - Begin() return false to indicate the window is collapsed or fully clipped, so you may early out and omit submitting + // anything to the window. Always call a matching End() for each Begin() call, regardless of its return value! + // [Important: due to legacy reason, this is inconsistent with most other functions such as BeginMenu/EndMenu, + // BeginPopup/EndPopup, etc. where the EndXXX call should only be called if the corresponding BeginXXX function + // returned true. Begin and BeginChild are the only odd ones out. Will be fixed in a future update.] + // - Note that the bottom of window stack always contains a window called "Debug". + + public native static boolean Begin(String title); /* + return ImGui::Begin(title); + */ + + public static boolean Begin(String title, ImBool pOpen) { + return nBegin(title, pOpen.data, 0); } - public static void StyleColorsLight() { - Native.StyleColorsLight(); + public static boolean Begin(String title, ImBool pOpen, int imGuiWindowFlags) { + return nBegin(title, pOpen.data, imGuiWindowFlags); } - public static boolean Begin(String title) { - return Native.Begin(title); - } + private native static boolean nBegin(String title, boolean[] pOpen, int imGuiWindowFlags); /* + return ImGui::Begin(title, &pOpen[0], imGuiWindowFlags); + */ - public static boolean Begin(String title, ImGuiBoolean p_open, ImGuiWindowFlags flags) { - return Native.Begin(title, p_open.data, flags.getValue()); - } - - public static void End() { - Native.End(); - } + public native static void End(); /* + ImGui::End(); + */ // Child Windows // - Use child windows to begin into a self-contained independent scrolling/clipping regions within a host window. Child windows can embed their own child. @@ -168,426 +252,799 @@ public class ImGui { // - BeginChild() returns false to indicate the window is collapsed or fully clipped, so you may early out and omit submitting anything to the window. // Always call a matching EndChild() for each BeginChild() call, regardless of its return value [this is due to legacy reason and is inconsistent with most other functions such as BeginMenu/EndMenu, BeginPopup/EndPopup, etc. where the EndXXX call should only be called if the corresponding BeginXXX function returned true.] + public native static boolean BeginChild(String strId); /* + return ImGui::BeginChild(strId); + */ - public static boolean BeginChild(String str_id) { - return Native.BeginChild(str_id); - } + public static native boolean BeginChild(String str_id, float width, float height); /* + return ImGui::BeginChild(str_id, ImVec2(width, height)); + */ - public static boolean BeginChild(String str_id, float width, float height) { - return Native.BeginChild(str_id, width, height); - } + public static native boolean BeginChild(String str_id, float width, float height, boolean border); /* + return ImGui::BeginChild(str_id, ImVec2(width, height), border); + */ - public static boolean BeginChild(String str_id, float width, float height, boolean border) { - return Native.BeginChild(str_id, width, height, border); - } + public static native boolean BeginChild(String str_id, float width, float height, boolean border, int imGuiWindowFlags); /* + return ImGui::BeginChild(str_id, ImVec2(width, height), border, imGuiWindowFlags); + */ - public static boolean BeginChild(String str_id, float width, float height, boolean border, ImGuiWindowFlags flags) { - return Native.BeginChild(str_id, width, height, border, flags.getValue()); - } + public static native boolean BeginChild(int imGuiID); /* + return ImGui::BeginChild(imGuiID); + */ - public static boolean BeginChild(int imGuiID) { - return Native.BeginChild(imGuiID); - } + public static native boolean BeginChild(int imGuiID, float width, float height, boolean border); /* + return ImGui::BeginChild(imGuiID, ImVec2(width, height), border); + */ - public static boolean BeginChild(int imGuiID, float width, float height, boolean border) { - return Native.BeginChild(imGuiID, width, height, border); - } + public static native boolean BeginChild(int imGuiID, float width, float height, boolean border, int imGuiWindowFlags); /* + return ImGui::BeginChild(imGuiID, ImVec2(width, height), border, imGuiWindowFlags); + */ - public static boolean BeginChild(int imGuiID, float width, float height, boolean border, ImGuiWindowFlags flags) { - return Native.BeginChild(imGuiID, width, height, border, flags.getValue()); - } - - public static void EndChild() { - Native.EndChild(); - } + public static native void EndChild(); /* + ImGui::EndChild(); + */ // Windows Utilities // - "current window" = the window we are appending into while inside a Begin()/End() block. "next window" = next window we will Begin() into. - public static boolean IsWindowAppearing() { - return Native.IsWindowAppearing(); - } + public static native boolean IsWindowAppearing(); /* + return ImGui::IsWindowAppearing(); + */ - public static boolean IsWindowCollapsed() { - return Native.IsWindowCollapsed(); - } + public static native boolean IsWindowCollapsed(); /* + return ImGui::IsWindowCollapsed(); + */ - public static boolean IsWindowFocused() { - return Native.IsWindowFocused(); - } + /** + * Is current window focused? or its root/child, depending on flags. see flags for options. + */ + public static native boolean IsWindowFocused(); /* + return ImGui::IsWindowFocused(); + */ - public static boolean IsWindowFocused(ImGuiFocusedFlags flags) { - return Native.IsWindowFocused(flags.getValue()); - } + /** + * Is current window focused? or its root/child, depending on flags. see flags for options. + */ + public static native boolean IsWindowFocused(int imGuiFocusedFlags); /* + return ImGui::IsWindowFocused(imGuiFocusedFlags); + */ - public static boolean IsWindowHovered() { - return Native.IsWindowHovered(); - } + /** + * Is current window hovered (and typically: not blocked by a popup/modal)? see flags for options. + * NB: If you are trying to check whether your mouse should be dispatched to imgui or to your app, + * you should use the 'io.WantCaptureMouse' boolean for that! Please read the FAQ! + */ + public static native boolean IsWindowHovered(); /* + return ImGui::IsWindowHovered(); + */ - public static boolean IsWindowHovered(ImGuiHoveredFlags flags) { - return Native.IsWindowHovered(flags.getValue()); - } + /** + * Is current window hovered (and typically: not blocked by a popup/modal)? see flags for options. + * NB: If you are trying to check whether your mouse should be dispatched to imgui or to your app, + * you should use the 'io.WantCaptureMouse' boolean for that! Please read the FAQ! + */ + public static native boolean IsWindowHovered(int imGuiHoveredFlags); /* + return ImGui::IsWindowHovered(imGuiHoveredFlags); + */ + /** + * Get draw list associated to the current window, to append your own drawing primitives + */ public static ImDrawList GetWindowDrawList() { - return imDrawList; + return IM_DRAW_LIST; } - public static ImDrawList GetBackgroundDrawList() { - return imDrawListBackground; - } + /** + * Get current window position in screen space (useful if you want to do your own drawing via the DrawList API) + */ + public native static void GetWindowPos(ImVec2 dstImVec2); /* + Jni::ImVec2Cpy(env, ImGui::GetWindowPos(), dstImVec2); + */ - public static ImDrawList GetForegroundDrawList() { - return imDrawListForeground; - } + /** + * Get current window size + */ + public static native void GetWindowSize(ImVec2 dstImVec2); /* + Jni::ImVec2Cpy(env, ImGui::GetWindowSize(), dstImVec2); + */ - public static ImVec2 GetWindowPos() { - Native.GetWindowPos(imVec2); - return imVec2; - } + /** + * Get current window width (shortcut for GetWindowSize().x) + */ + public static native float GetWindowWidth(); /* + return ImGui::GetWindowWidth(); + */ - public static float GetWindowPosX() { - return Native.GetWindowPosX(); - } - - public static float GetWindowPosY() { - return Native.GetWindowPosY(); - } - - public static ImVec2 GetWindowSize() { - Native.GetWindowSize(imVec2); - return imVec2; - } - - public static float GetWindowWidth() { - return Native.GetWindowWidth(); - } - - public static float GetWindowHeight() { - return Native.GetWindowHeight(); - } + /** + * Get current window height (shortcut for GetWindowSize().y) + */ + public static native float GetWindowHeight(); /* + return ImGui::GetWindowHeight(); + */ // Prefer using SetNextXXX functions (before Begin) rather that SetXXX functions (after Begin). - public static void SetNextWindowPos(float x, float y) { - Native.SetNextWindowPos(x, y); - } + /** + * Set next window position. call before Begin(). use pivot=(0.5f,0.5f) to center on given point, etc. + */ + public static native void SetNextWindowPos(float x, float y); /* + ImGui::SetNextWindowPos(ImVec2(x, y)); + */ - public static void SetNextWindowPos(float x, float y, ImGuiCond cond) { - Native.SetNextWindowPos(x, y, cond.getValue()); - } + /** + * Set next window position. call before Begin(). use pivot=(0.5f,0.5f) to center on given point, etc. + */ + public static native void SetNextWindowPos(float x, float y, int imGuiCond); /* + ImGui::SetNextWindowPos(ImVec2(x, y), imGuiCond); + */ - public static void SetNextWindowPos(float x, float y, ImGuiCond cond, float pivotX, float pivotY) { - Native.SetNextWindowPos(x, y, cond.getValue(), pivotX, pivotY); - } + /** + * Set next window position. call before Begin(). use pivot=(0.5f,0.5f) to center on given point, etc. + */ + public static native void SetNextWindowPos(float x, float y, int cond, float pivotX, float pivotY); /* + ImGui::SetNextWindowPos(ImVec2(x, y), cond, ImVec2(pivotX, pivotY)); + */ - public static void SetNextWindowSize(int width, int height) { - Native.SetNextWindowSize(width, height); - } + /** + * Set next window size. set axis to 0.0f to force an auto-fit on this axis. call before Begin() + */ + public static native void SetNextWindowSize(float width, float height); /* + ImGui::SetNextWindowSize(ImVec2(width, height)); + */ - public static void SetNextWindowSize(int width, int height, ImGuiCond cond) { - Native.SetNextWindowSize(width, height, cond.getValue()); - } + /** + * Set next window size. set axis to 0.0f to force an auto-fit on this axis. call before Begin() + */ + public static native void SetNextWindowSize(float width, float height, int imGuiCond); /* + ImGui::SetNextWindowSize(ImVec2(width, height), imGuiCond); + */ - public static void SetNextWindowSizeConstraints(float minWidth, float minHeight, float maxWidth, float maxHeight) { - Native.SetNextWindowSizeConstraints(minWidth, minHeight, maxWidth, maxHeight); - } + /** + * Set next window size limits. use -1,-1 on either X/Y axis to preserve the current size. Sizes will be rounded down. + */ + public static native void SetNextWindowSizeConstraints(float minWidth, float minHeight, float maxWidth, float maxHeight); /* + ImGui::SetNextWindowSizeConstraints(ImVec2(minWidth, minHeight), ImVec2(maxWidth, maxHeight)); + */ - public static void SetNextWindowContentSize(float sizeX, float sizeY) { - Native.SetNextWindowContentSize(sizeX, sizeY); - } + /** + * Set next window content size (~ scrollable client area, which enforce the range of scrollbars). + * Not including window decorations (title bar, menu bar, etc.) nor WindowPadding. set an axis to 0.0f to leave it automatic. call before Begin() + */ + public static native void SetNextWindowContentSize(float width, float height); /* + ImGui::SetNextWindowContentSize(ImVec2(width, height)); + */ - public static void SetNextWindowCollapsed(boolean flag) { - Native.SetNextWindowCollapsed(flag); - } + /** + * Set next window collapsed state. call before Begin() + */ + public static native void SetNextWindowCollapsed(boolean collapsed); /* + ImGui::SetNextWindowCollapsed(collapsed); + */ - public static void SetNextWindowFocus() { - Native.SetNextWindowFocus(); - } + /** + * Set next window collapsed state. call before Begin() + */ + public static native void SetNextWindowCollapsed(boolean collapsed, int imGuiCond); /* + ImGui::SetNextWindowCollapsed(collapsed, imGuiCond); + */ - public static void SetNextWindowBgAlpha(float alpha) { - Native.SetNextWindowBgAlpha(alpha); - } + /** + * Set next window to be focused / top-most. call before Begin() + */ + public static native void SetNextWindowFocus(); /* + ImGui::SetNextWindowFocus(); + */ - //TODO add more methods + /** + * Set next window background color alpha. helper to easily modify ImGuiCol_WindowBg/ChildBg/PopupBg. + * You may also use ImGuiWindowFlags_NoBackground. + */ + public static native void SetNextWindowBgAlpha(float alpha); /* + ImGui::SetNextWindowBgAlpha(alpha); + */ - public static void SetWindowFocus() { - Native.SetWindowFocus(); - } + /** + * (not recommended) set current window position - call within Begin()/End(). + * Prefer using SetNextWindowPos(), as this may incur tearing and side-effects. + */ + public static native void SetWindowPos(float x, float y); /* + ImGui::SetWindowPos(ImVec2(x, y)); + */ - public static void SetWindowFocus(String name) { - if (name == null) { - Native.RemoveWindowFocus(); - } else { - Native.SetWindowFocus(name); + /** + * (not recommended) set current window position - call within Begin()/End(). + * Prefer using SetNextWindowPos(), as this may incur tearing and side-effects. + */ + public static native void SetWindowPos(float x, float y, int imGuiCond); /* + ImGui::SetWindowPos(ImVec2(x, y), imGuiCond); + */ + + /** + * (not recommended) set current window size - call within Begin()/End(). set to ImVec2(0,0) to force an auto-fit. + * Prefer using SetNextWindowSize(), as this may incur tearing and minor side-effects. + */ + public static native void SetWindowSize(float width, float height); /* + ImGui::SetWindowSize(ImVec2(width, height)); + */ + + /** + * (not recommended) set current window size - call within Begin()/End(). set to ImVec2(0,0) to force an auto-fit. + * Prefer using SetNextWindowSize(), as this may incur tearing and minor side-effects. + */ + public static native void SetWindowSize(float width, float height, int imGuiCond); /* + ImGui::SetWindowSize(ImVec2(width, height), imGuiCond); + */ + + /** + * (not recommended) set current window collapsed state. prefer using SetNextWindowCollapsed(). + */ + public static native void SetWindowCollapsed(boolean collapsed); /* + ImGui::SetWindowCollapsed(collapsed); + */ + + /** + * (not recommended) set current window collapsed state. prefer using SetNextWindowCollapsed(). + */ + public static native void SetWindowCollapsed(boolean collapsed, int imGuiCond); /* + ImGui::SetWindowCollapsed(collapsed, imGuiCond); + */ + + /** + * (not recommended) set current window to be focused / top-most. prefer using SetNextWindowFocus(). + */ + public static native void SetWindowFocus(); /* + ImGui::SetWindowFocus(); + */ + + /** + * Set font scale. Adjust IO.FontGlobalScale if you want to scale all windows. + * This is an old API! For correct scaling, prefer to reload font + rebuild ImFontAtlas + call style.ScaleAllSizes(). + */ + public native void SetWindowFontScale(float scale); /* + ImGui::SetWindowFontScale(scale); + */ + + /** + * Set named window position. + */ + public static native void SetWindowPos(String name, float x, float y); /* + ImGui::SetWindowPos(name, ImVec2(x, y)); + */ + + /** + * Set named window position. + */ + public static native void SetWindowPos(String name, float x, float y, int imGuiCond); /* + ImGui::SetWindowPos(name, ImVec2(x, y), imGuiCond); + */ + + /** + * Set named window size. set axis to 0.0f to force an auto-fit on this axis. + */ + public static native void SetWindowSize(String name, float x, float y); /* + ImGui::SetWindowSize(name, ImVec2(x, y)); + */ + + /** + * Set named window size. set axis to 0.0f to force an auto-fit on this axis. + */ + public static native void SetWindowSize(String name, float x, float y, int imGuiCond); /* + ImGui::SetWindowSize(name, ImVec2(x, y), imGuiCond); + */ + + /** + * Set named window collapsed state + */ + public static native void SetWindowCollapsed(String name, boolean collapsed); /* + ImGui::SetWindowCollapsed(name, collapsed); + */ + + /** + * Set named window collapsed state + */ + public static native void SetWindowCollapsed(String name, boolean collapsed, int imGuiCond); /* + ImGui::SetWindowCollapsed(name, collapsed, imGuiCond); + */ + + /** + * Set named window to be focused / top-most. Use NULL to remove focus. + */ + public static native void SetWindowFocus(String name); /*MANUAL + if (obj_name == NULL) + ImGui::SetWindowFocus(NULL); + else { + char* name = (char*)env->GetStringUTFChars(obj_name, JNI_FALSE); + ImGui::SetWindowFocus(name); + env->ReleaseStringUTFChars(obj_name, name); } - } + */ // Content region // - Those functions are bound to be redesigned soon (they are confusing, incomplete and return values in local window coordinates which increases confusion) - public static ImVec2 GetContentRegionMax() { - Native.GetContentRegionMax(imVec2); - return imVec2; - } + /** + * Current content boundaries (typically window boundaries including scrolling, or current column boundaries), in windows coordinates + */ + public static native void GetContentRegionMax(ImVec2 dstImVec2); /* + Jni::ImVec2Cpy(env, ImGui::GetContentRegionMax(), dstImVec2); + */ - public static ImVec2 GetContentRegionAvail() { - Native.GetContentRegionAvail(imVec2); - return imVec2; - } + /** + * == GetContentRegionMax() - GetCursorPos() + */ + public static native void GetContentRegionAvail(ImVec2 dstImVec2); /* + Jni::ImVec2Cpy(env, ImGui::GetContentRegionAvail(), dstImVec2); + */ - public static float GetContentRegionAvailWidth() { - return Native.GetContentRegionAvailWidth(); - } + /** + * Content boundaries min (roughly (0,0)-Scroll), in window coordinates + */ + public static native float GetContentRegionAvailWidth(); /* + return ImGui::GetContentRegionAvailWidth(); + */ - public static ImVec2 GetWindowContentRegionMin() { - Native.GetWindowContentRegionMin(imVec2); - return imVec2; - } + /** + * Content boundaries max (roughly (0,0)+Size-Scroll) where Size can be override with SetNextWindowContentSize(), in window coordinates + */ + public static native void GetWindowContentRegionMin(ImVec2 dstImVec2); /* + Jni::ImVec2Cpy(env, ImGui::GetWindowContentRegionMin(), dstImVec2); + */ - public static ImVec2 GetWindowContentRegionMax() { - Native.GetWindowContentRegionMax(imVec2); - return imVec2; - } - - public static float GetWindowContentRegionWidth() { - return Native.GetWindowContentRegionWidth(); - } + public static native void GetWindowContentRegionMax(ImVec2 dstImVec2); /* + Jni::ImVec2Cpy(env, ImGui::GetWindowContentRegionMax(), dstImVec2); + */ // Windows Scrolling - public static float GetScrollX() { - return Native.GetScrollX(); - } + /** + * Get scrolling amount [0..GetScrollMaxX()] + */ + public static native float GetScrollX(); /* + return ImGui::GetScrollX(); + */ - public static float GetScrollY() { - return Native.GetScrollY(); - } + /** + * Get scrolling amount [0..GetScrollMaxY()] + */ + public static native float GetScrollY(); /* + return ImGui::GetScrollY(); + */ - public static float GetScrollMaxX() { - return Native.GetScrollMaxX(); - } + /** + * Get maximum scrolling amount ~~ ContentSize.X - WindowSize.X + */ + public static native float GetScrollMaxX(); /* + return ImGui::GetScrollMaxX(); + */ - public static float GetScrollMaxY() { - return Native.GetScrollMaxY(); - } + /** + * Get maximum scrolling amount ~~ ContentSize.Y - WindowSize.Y + */ + public static native float GetScrollMaxY(); /* + return ImGui::GetScrollMaxY(); + */ - public static void SetScrollX(float scroll_x) { - Native.SetScrollX(scroll_x); - } + /** + * Set scrolling amount [0..GetScrollMaxX()] + */ + public static native void SetScrollX(float scrollX); /* + ImGui::SetScrollX(scrollX); + */ - public static void SetScrollY(float scroll_y) { - Native.SetScrollY(scroll_y); - } + /** + * Set scrolling amount [0..GetScrollMaxY()] + */ + public static native void SetScrollY(float scrollY); /* + ImGui::SetScrollY(scrollY); + */ - public static void SetScrollHereY() { - Native.SetScrollHereY(); - } + /** + * Adjust scrolling amount to make current cursor position visible. center_x_ratio=0.0: left, 0.5: center, 1.0: right. + * When using to make a "default/current item" visible, consider using SetItemDefaultFocus() instead. + */ + public static native void SetScrollHereX(); /* + ImGui::SetScrollHereX(); + */ - public static void SetScrollHereY(float center_y_ratio) { - Native.SetScrollHereY(center_y_ratio); - } + /** + * Adjust scrolling amount to make current cursor position visible. center_x_ratio=0.0: left, 0.5: center, 1.0: right. + * When using to make a "default/current item" visible, consider using SetItemDefaultFocus() instead. + */ + public static native void SetScrollHereX(float centerXRatio); /* + ImGui::SetScrollHereX(centerXRatio); + */ - public static void SetScrollFromPosY(float local_y) { - Native.SetScrollFromPosY(local_y); - } + /** + * Adjust scrolling amount to make current cursor position visible. center_y_ratio=0.0: top, 0.5: center, 1.0: bottom. + * When using to make a "default/current item" visible, consider using SetItemDefaultFocus() instead. + */ + public static native void SetScrollHereY(); /* + ImGui::SetScrollHereY(); + */ - public static void SetScrollFromPosY(float local_y, float center_y_ratio) { - Native.SetScrollFromPosY(local_y, center_y_ratio); - } + /** + * Adjust scrolling amount to make current cursor position visible. center_y_ratio=0.0: top, 0.5: center, 1.0: bottom. + * When using to make a "default/current item" visible, consider using SetItemDefaultFocus() instead. + */ + public static native void SetScrollHereY(float centerYRatio); /* + ImGui::SetScrollHereY(centerYRatio); + */ + + /** + * Adjust scrolling amount to make given position visible. Generally GetCursorStartPos() + offset to compute a valid position. + */ + public static native void SetScrollFromPosX(float localX); /* + ImGui::SetScrollFromPosX(localX); + */ + + /** + * Adjust scrolling amount to make given position visible. Generally GetCursorStartPos() + offset to compute a valid position. + */ + public static native void SetScrollFromPosX(float localX, float centerXRatio); /* + ImGui::SetScrollFromPosX(localX, centerXRatio); + */ + + /** + * Adjust scrolling amount to make given position visible. Generally GetCursorStartPos() + offset to compute a valid position. + */ + public static native void SetScrollFromPosY(float localY); /* + ImGui::SetScrollFromPosY(localY); + */ + + /** + * Adjust scrolling amount to make given position visible. Generally GetCursorStartPos() + offset to compute a valid position. + */ + public static native void SetScrollFromPosY(float localY, float centerYRatio); /* + ImGui::SetScrollFromPosY(localY, centerYRatio); + */ // Parameters stacks (shared) - public static void PushStyleColor(ImGuiCol idx, int col) { - Native.PushStyleColor(idx.getValue(), col); - } + // TODO void PushFont(ImFont* font); - public static void PushStyleColor(ImGuiCol idx, float r, float g, float b, float a) { - Native.PushStyleColor(idx.getValue(), r, g, b, a); - } + public static native void PopFont(); /* + ImGui::PopFont(); + */ - public static void PopStyleColor() { - Native.PopStyleColor(); - } + public static native void PushStyleColor(int imGuiCol, long col); /* + ImGui::PushStyleColor(imGuiCol, col); + */ - public static void PopStyleColor(int count) { - Native.PopStyleColor(count); - } + public static native void PushStyleColor(int imGuiCol, float r, float g, float b, float a); /* + ImGui::PushStyleColor(imGuiCol, ImVec4(r, g, b, a)); + */ - public static void PushStyleVar(ImGuiStyleVar idx, float val) { - Native.PushStyleVar(idx.getValue(), val); - } + public static native void PopStyleColor(); /* + ImGui::PopStyleColor(); + */ - public static void PushStyleVar(ImGuiStyleVar idx, float valX, float valY) { - Native.PushStyleVar(idx.getValue(), valX, valY); - } + public static native void PopStyleColor(int count); /* + ImGui::PopStyleColor(count); + */ - public static void PopStyleVar() { - Native.PopStyleVar(); - } + public static native void PushStyleVar(int imGuiStyleVar, float val); /* + ImGui::PushStyleVar(imGuiStyleVar, val); + */ - public static void PopStyleVar(int count) { - Native.PopStyleVar(count); - } + public static native void PushStyleVar(int imGuiStyleVar, float val_x, float val_y); /* + ImGui::PushStyleVar(imGuiStyleVar, ImVec2(val_x, val_y)); + */ + + public static native void PopStyleVar(); /* + ImGui::PopStyleVar(); + */ + + public static native void PopStyleVar(int count); /* + ImGui::PopStyleVar(count); + */ + + /** + * Retrieve style color as stored in ImGuiStyle structure. use to feed back into PushStyleColor(), + * otherwise use GetColorU32() to get style color with style alpha baked in. + */ + public static native void GetStyleColorVec4(int imGuiStyleVar, ImVec4 dstImVec4); /* + Jni::ImVec4Cpy(env, ImGui::GetStyleColorVec4(imGuiStyleVar), dstImVec4); + */ + + // TODO ImFont* GetFont(); + + /** + * Get current font size (= height in pixels) of current font with current scale applied + */ + public static native int GetFontSize(); /* + return ImGui::GetFontSize(); + */ + + /** + * Get UV coordinate for a while pixel, useful to draw custom shapes via the ImDrawList API + */ + public static native void GetFontTexUvWhitePixel(ImVec2 dstImVec2); /* + Jni::ImVec2Cpy(env, ImGui::GetFontTexUvWhitePixel(), dstImVec2); + */ + + /** + * Retrieve given style color with style alpha applied and optional extra alpha multiplier + */ + public static native long GetColorU32(int imGuiCol); /* + return ImGui::GetColorU32((ImGuiCol)imGuiCol); + */ + + /** + * Retrieve given style color with style alpha applied and optional extra alpha multiplier + */ + public static native long GetColorU32(int imGuiCol, float alpha_mul); /* + return ImGui::GetColorU32(imGuiCol, alpha_mul); + */ + + /** + * Retrieve given color with style alpha applied + */ + public static native long GetColorU32(float col_r, float col_g, float col_b, float col_a); /* + return ImGui::GetColorU32(ImVec4(col_r, col_g, col_b, col_a)); + */ + + /** + * Retrieve given color with style alpha applied + */ + public static native long GetColorU32(long col); /* + return ImGui::GetColorU32((ImU32)col); + */ // Parameters stacks (current window) - public static void PushItemWidth(float item_width) { - Native.PushItemWidth(item_width); - } + /** + * Set width of items for common large "item+label" widgets. >0.0f: width in pixels, + * <0.0f align xx pixels to the right of window (so -1.0f always align width to the right side). 0.0f = default to ~2/3 of windows width, + */ + public static native void PushItemWidth(float item_width); /* + ImGui::PushItemWidth(item_width); + */ - public static void PopItemWidth() { - Native.PopItemWidth(); - } + public static native void PopItemWidth(); /* + ImGui::PopItemWidth(); + */ - public static void SetNextItemWidth(float item_width) { - Native.SetNextItemWidth(item_width); - } + /** + * Set width of the _next_ common large "item+label" widget. >0.0f: width in pixels, + * <0.0f align xx pixels to the right of window (so -1.0f always align width to the right side) + */ + public static native void SetNextItemWidth(float item_width); /* + ImGui::SetNextItemWidth(item_width); + */ - public static float CalcItemWidth() { - return Native.CalcItemWidth(); - } + /** + * Width of item given pushed settings and current cursor position. NOT necessarily the width of last item unlike most 'Item' functions. + */ + public static native float CalcItemWidth(); /* + return ImGui::CalcItemWidth(); + */ - public static void PushTextWrapPos() { - Native.PushTextWrapPos(); - } + /** + * Word-wrapping for Text*() commands. < 0.0f: no wrapping; 0.0f: wrap to end of window (or column); > 0.0f: wrap at 'wrap_pos_x' + * position in window local space + */ + public static native void PushTextWrapPos(); /* + ImGui::PushTextWrapPos(); + */ - public static void PushTextWrapPos(float wrap_local_pos_x) { - Native.PushTextWrapPos(wrap_local_pos_x); - } + /** + * Word-wrapping for Text*() commands. < 0.0f: no wrapping; 0.0f: wrap to end of window (or column); > 0.0f: wrap at 'wrap_pos_x' + * position in window local space + */ + public static native void PushTextWrapPos(float wrap_local_pos_x); /* + ImGui::PushTextWrapPos(wrap_local_pos_x); + */ - public static void PopTextWrapPos() { - Native.PopTextWrapPos(); - } + public static native void PopTextWrapPos(); /* + ImGui::PopTextWrapPos(); + */ - public static void PushAllowKeyboardFocus(boolean allow_keyboard_focus) { - Native.PushAllowKeyboardFocus(allow_keyboard_focus); - } + /** + * Allow focusing using TAB/Shift-TAB, enabled by default but you can disable it for certain widgets + */ + public static native void PushAllowKeyboardFocus(boolean allow_keyboard_focus); /* + ImGui::PushAllowKeyboardFocus(allow_keyboard_focus); + */ - public static void PushButtonRepeat() { - Native.PopAllowKeyboardFocus(); - } + public static native void PopAllowKeyboardFocus(); /* + ImGui::PopAllowKeyboardFocus(); + */ - public static void PushButtonRepeat(boolean repeat) { - Native.PushButtonRepeat(repeat); - } + /** + * In 'repeat' mode, Button*() functions return repeated true in a typematic manner (using io.KeyRepeatDelay/io.KeyRepeatRate setting). + * Note that you can call IsItemActive() after any Button() to tell if the button is held in the current frame. + */ + public static native void PushButtonRepeat(boolean repeat); /* + ImGui::PushButtonRepeat(repeat); + */ - public static void PopButtonRepeat() { - Native.PopButtonRepeat(); - } + public static native void PopButtonRepeat(); /* + ImGui::PopButtonRepeat(); + */ // Cursor / Layout // - By "cursor" we mean the current output position. // - The typical widget behavior is to output themselves at the current cursor position, then move the cursor one line down. + // - You can call SameLine() between widgets to undo the last carriage return and output at the right of the preceeding widget. - public static void Separator() { - Native.Separator(); - } + /** + * Separator, generally horizontal. inside a menu bar or in horizontal layout mode, this becomes a vertical separator. + */ + public static native void Separator(); /* + ImGui::Separator(); + */ - public static void SameLine() { - Native.SameLine(); - } + /** + * Call between widgets or groups to layout them horizontally. X position given in window coordinates. + */ + public static native void SameLine(); /* + ImGui::SameLine(); + */ - public static void SameLine(float offsetFromStartX) { - Native.SameLine(offsetFromStartX); - } + /** + * Call between widgets or groups to layout them horizontally. X position given in window coordinates. + */ + public static native void SameLine(float offsetFromStartX); /* + ImGui::SameLine(offsetFromStartX); + */ - public static void SameLine(float offsetFromStartX, float spacing) { - Native.SameLine(offsetFromStartX, spacing); - } + /** + * Call between widgets or groups to layout them horizontally. X position given in window coordinates. + */ + public static native void SameLine(float offsetFromStartX, float spacing); /* + ImGui::SameLine(offsetFromStartX, spacing); + */ - public static void NewLine() { - Native.NewLine(); - } + /** + * Undo a SameLine() or force a new line when in an horizontal-layout context. + */ + public static native void NewLine(); /* + ImGui::NewLine(); + */ - public static void Spacing() { - Native.Spacing(); - } + /** + * Add vertical spacing. + */ + public static native void Spacing(); /* + ImGui::Spacing(); + */ - public static void Dummy(float width, float height) { - Native.Dummy(width, height); - } + /** + * Add a dummy item of given size. unlike InvisibleButton(), Dummy() won't take the mouse click or be navigable into. + */ + public static native void Dummy(float width, float height); /* + ImGui::Dummy(ImVec2(width, height)); + */ - public static void Indent() { - Native.Indent(); - } + /** + * Move content position toward the right, by style.IndentSpacing or indent_w if != 0 + */ + public static native void Indent(); /* + ImGui::Indent(); + */ - public static void Indent(float indentW) { - Native.Indent(indentW); - } + /** + * Move content position toward the right, by style.IndentSpacing or indent_w if != 0 + */ + public static native void Indent(float indentW); /* + ImGui::Indent(indentW); + */ - public static void Unindent() { - Native.Unindent(); - } + /** + * Move content position back to the left, by style.IndentSpacing or indent_w if != 0 + */ + public static native void Unindent(); /* + ImGui::Unindent(); + */ - public static void Unindent(float indentW) { - Native.Unindent(indentW); - } + /** + * Move content position back to the left, by style.IndentSpacing or indent_w if != 0 + */ + public static native void Unindent(float indentW); /* + ImGui::Unindent(indentW); + */ - public static void BeginGroup() { - Native.BeginGroup(); - } + /** + * Lock horizontal starting position + */ + public static native void BeginGroup(); /* + ImGui::BeginGroup(); + */ - public static void EndGroup() { - Native.EndGroup(); - } + /** + * Unlock horizontal starting position + capture the whole group bounding box into one "item" (so you can use IsItemHovered() or layout primitives such as SameLine() on whole group, etc.) + */ + public static native void EndGroup(); /* + ImGui::EndGroup(); + */ - public static void GetCursorPos() { - //TODO impl - } + // (some functions are using window-relative coordinates, such as: GetCursorPos, GetCursorStartPos, GetContentRegionMax, GetWindowContentRegion* etc. + // other functions such as GetCursorScreenPos or everything in ImDrawList:: + // are using the main, absolute coordinate system. + // GetWindowPos() + GetCursorPos() == GetCursorScreenPos() etc.) - public static float GetCursorPosX() { - return Native.GetCursorPosX(); - } + /** + * Cursor position in window coordinates (relative to window position) + */ + public static native void GetCursorPos(ImVec2 dstImVec2); /* + Jni::ImVec2Cpy(env, ImGui::GetCursorPos(), dstImVec2); + */ - public static float GetCursorPosY() { - return Native.GetCursorPosY(); - } + public static native float GetCursorPosX(); /* + return ImGui::GetCursorPosX(); + */ - public static void SetCursorPos(float x, float y) { - Native.SetCursorPos(x, y); - } + public static native float GetCursorPosY(); /* + return ImGui::GetCursorPosY(); + */ - public static void SetCursorPosX(float x) { - Native.SetCursorPosX(x); - } + public static native void SetCursorPos(float x, float y); /* + ImGui::SetCursorPos(ImVec2(x, y)); + */ - public static void SetCursorPosY(float y) { - Native.SetCursorPosY(y); - } + public static native void SetCursorPosX(float x); /* + ImGui::SetCursorPosX(x); + */ - public static ImVec2 GetCursorStartPos() { - Native.GetCursorStartPos(imVec2); - return imVec2; - } + public static native void SetCursorPosY(float y); /* + ImGui::SetCursorPosY(y); + */ - public static ImVec2 GetCursorScreenPos() { - Native.GetCursorScreenPos(imVec2); - return imVec2; - } + /** + * Initial cursor position in window coordinates + */ + public static native void GetCursorStartPos(ImVec2 dstImVec2); /* + Jni::ImVec2Cpy(env, ImGui::GetCursorStartPos(), dstImVec2); + */ - public static void SetCursorScreenPos(float x, float y) { - Native.SetCursorScreenPos(x, y); - } + /** + * Cursor position in absolute screen coordinates [0..io.DisplaySize] (useful to work with ImDrawList API) + */ + public static native void GetCursorScreenPos(ImVec2 dstImVec2); /* + Jni::ImVec2Cpy(env, ImGui::GetCursorScreenPos(), dstImVec2); + */ - public static void AlignTextToFramePadding() { - Native.AlignTextToFramePadding(); - } + /** + * Cursor position in absolute screen coordinates [0..io.DisplaySize] + */ + public static native void SetCursorScreenPos(float x, float y); /* + ImGui::SetCursorScreenPos(ImVec2(x, y)); + */ - public static float GetTextLineHeight() { - return Native.GetTextLineHeight(); - } + /** + * Vertically align upcoming text baseline to FramePadding.y so that it will align properly to regularly framed items (call if you have text on a line before a framed item) + */ + public static native void AlignTextToFramePadding(); /* + ImGui::AlignTextToFramePadding(); + */ - public static float GetTextLineHeightWithSpacing() { - return Native.GetTextLineHeightWithSpacing(); - } + /** + * ~ FontSize + */ + public static native float GetTextLineHeight(); /* + return ImGui::GetTextLineHeight(); + */ - public static float GetFrameHeight() { - return Native.GetFrameHeight(); - } + /** + * ~ FontSize + style.ItemSpacing.y (distance in pixels between 2 consecutive lines of text) + */ + public static native float GetTextLineHeightWithSpacing(); /* + return ImGui::GetTextLineHeightWithSpacing(); + */ - public static float GetFrameHeightWithSpacing() { - return Native.GetFrameHeightWithSpacing(); - } + /** + * ~ FontSize + style.FramePadding.y * 2 + */ + public static native float GetFrameHeight(); /* + return ImGui::GetFrameHeight(); + */ + + /** + * ~ FontSize + style.FramePadding.y * 2 + style.ItemSpacing.y (distance in pixels between 2 consecutive lines of framed widgets) + */ + public static native float GetFrameHeightWithSpacing(); /* + return ImGui::GetFrameHeightWithSpacing(); + */ // ID stack/scopes // - Read the FAQ for more details about how ID are handled in dear imgui. If you are creating widgets in a loop you most @@ -597,646 +1054,2464 @@ public class ImGui { // - In this header file we use the "label"/"name" terminology to denote a string that will be displayed and used as an ID, // whereas "str_id" denote a string that is only used as an ID and not normally displayed. - public static void PushID(String str_id) { - Native.PushID(str_id); - } + /** + * Push string into the ID stack (will hash string). + */ + public static native void PushID(String str_id); /* + ImGui::PushID(str_id); + */ - public static void PushID(String str_id_begin, String str_id_end) { - Native.PushID(str_id_begin, str_id_end); - } + /** + * Push string into the ID stack (will hash string). + */ + public static native void PushID(String str_id_begin, String str_id_end); /* + ImGui::PushID(str_id_begin, str_id_end); + */ - public static void PushID(int int_id) { - Native.PushID(int_id); - } + /** + * Push pointer into the ID stack (will hash pointer). + */ + public static native void PushID(long ptr_id); /* + ImGui::PushID((void*)ptr_id); + */ - public static void PopID() { - Native.PopID(); - } + /** + * Push integer into the ID stack (will hash integer). + */ + public static native void PushID(int int_id); /* + ImGui::PushID(int_id); + */ - public static int GetID(String str_id) { - return Native.GetID(str_id); - } + /** + * Pop from the ID stack. + */ + public static native void PopID(); /* + ImGui::PopID(); + */ - public static int GetID(String str_id_begin, String str_id_end) { - return Native.GetID(str_id_begin, str_id_end); - } + /** + * Calculate unique ID (hash of whole ID stack + given parameter). e.g. if you want to query into ImGuiStorage yourself + */ + public static native long GetID(String str_id); /* + return ImGui::GetID(str_id); + */ - // TODO GetID ptr_id + public static native long GetID(String str_id_begin, String str_id_end); /* + return ImGui::GetID(str_id_begin, str_id_end); + */ + + public static native long GetID(long ptr_id); /* + return ImGui::GetID((void*)ptr_id); + */ // Widgets: Text - public static void TextUnformatted(String text) { - Native.TextUnformatted(text); - } + /** + * Raw text without formatting. Roughly equivalent to Text("%s", text) but: + * A) doesn't require null terminated string if 'text_end' is specified, + * B) it's faster, no memory copy is done, no buffer size limits, recommended for long chunks of text. + */ + public static native void TextUnformatted(String text); /* + ImGui::TextUnformatted(text); + */ - public static void TextUnformatted(String text, String text_end) { - Native.TextUnformatted(text, text_end); - } + /** + * Raw text without formatting. Roughly equivalent to Text("%s", text) but: + * A) doesn't require null terminated string if 'text_end' is specified, + * B) it's faster, no memory copy is done, no buffer size limits, recommended for long chunks of text. + */ + public static native void TextUnformatted(String text, String text_end); /* + ImGui::TextUnformatted(text, text_end); + */ - public static void Text(String text) { - Native.Text(text); - } + /** + * Formatted text + * BINDING NOTICE: Since all text formatting could be done on Java side, this call is equal to {@link ImGui#TextUnformatted(String)}. + */ + public static native void Text(String text); /* + ImGui::TextUnformatted(text); + */ - public static void TextColored(float r, float g, float b, float a, String text) { - Native.TextColored(r, g, b, a, text); - } + /** + * Shortcut for PushStyleColor(ImGuiCol_Text, col); Text(fmt, ...); PopStyleColor(); + */ + public static native void TextColored(float r, float g, float b, float a, String text); /* + ImGui::TextColored(ImVec4(r, g, b, a), text); + */ - public static void TextDisabled(String text) { - Native.TextDisabled(text); - } + /** + * Shortcut for PushStyleColor(ImGuiCol_Text, style.Colors[ImGuiCol_TextDisabled]); Text(fmt, ...); PopStyleColor(); + */ + public static native void TextDisabled(String text); /* + ImGui::TextDisabled(text); + */ - public static void TextWrapped(String text) { - Native.TextWrapped(text); - } + /** + * Shortcut for PushTextWrapPos(0.0f); Text(fmt, ...); PopTextWrapPos();. + * Note that this won't work on an auto-resizing window if there's no other widgets to extend the window width, + * yoy may need to set a size using SetNextWindowSize(). + */ + public static native void TextWrapped(String text); /* + ImGui::TextWrapped(text); + */ - public static void LabelText(String label, String text) { - Native.LabelText(label, text); - } + /** + * Display text+label aligned the same way as value+label widgets + */ + public static native void LabelText(String label, String text); /* + ImGui::LabelText(label, text); + */ - public static void BulletText(String text) { - Native.BulletText(text); - } + /** + * Shortcut for Bullet()+Text() + */ + public static native void BulletText(String text); /* + ImGui::BulletText(text); + */ // Widgets: Main // - Most widgets return true when the value has been changed or when pressed/selected + // - You may also use one of the many IsItemXXX functions (e.g. IsItemActive, IsItemHovered, etc.) to query widget state. /** - * button + * Button */ - public static boolean Button(String label) { - return Native.Button(label); - } + public static native boolean Button(String label); /* + return ImGui::Button(label); + */ /** - * button + * Button */ - public static boolean Button(String label, float width, float height) { - return Native.Button(label, width, height); - } + public static native boolean Button(String label, float width, float height); /* + return ImGui::Button(label, ImVec2(width, height)); + */ /** - * button with FramePadding=(0,0) to easily embed within text + * Button with FramePadding=(0,0) to easily embed within text */ - public static boolean SmallButton(String label) { - return Native.SmallButton(label); - } + public static native boolean SmallButton(String label); /* + return ImGui::SmallButton(label); + */ /** - * button behavior without the visuals, frequently useful to build custom behaviors using the public api (along with IsItemActive, IsItemHovered, etc.) + * Button behavior without the visuals, frequently useful to build custom behaviors using the public api (along with IsItemActive, IsItemHovered, etc.) */ - public static boolean InvisibleButton(String strId, float width, float height) { - return Native.InvisibleButton(strId, width, height); - } + public static native boolean InvisibleButton(String strId, float width, float height); /* + return ImGui::InvisibleButton(strId, ImVec2(width, height)); + */ /** - * square button with an arrow shape + * Square button with an arrow shape */ - public static boolean ArrowButton(String strId, ImGuiDir dir) { - return Native.ArrowButton(strId, dir.toInt()); + public static native boolean ArrowButton(String strId, int dir); /* + return ImGui::ArrowButton(strId, dir); + */ + + public static native void Image(int textureID, float sizeX, float sizeY); /* + ImGui::Image((ImTextureID)textureID, ImVec2(sizeX, sizeY)); + */ + + public static native void Image(int textureID, float sizeX, float sizeY, float uv0_x, float uv0_y, float uv1_x, float uv1_y); /* + ImGui::Image((ImTextureID)textureID, ImVec2(sizeX, sizeY), ImVec2(uv0_x, uv0_y), ImVec2(uv1_x, uv1_y)); + */ + + public static native void Image(int textureID, float sizeX, float sizeY, float uv0_x, float uv0_y, float uv1_x, float uv1_y, float tint_color_r, float tint_color_g, float tint_color_b, float tint_color_a, float border_col_r, float border_col_g, float border_col_b, float border_col_a); /* + ImGui::Image((ImTextureID)textureID, ImVec2(sizeX, sizeY), ImVec2(uv0_x, uv0_y), ImVec2(uv1_x, uv1_y), ImVec4(tint_color_r, tint_color_g, tint_color_b, tint_color_a), ImVec4(border_col_r, border_col_g, border_col_b, border_col_a)); + */ + + /** + * <0 frame_padding uses default frame padding settings. 0 for no padding + */ + public static native boolean ImageButton(int textureID, float sizeX, float sizeY); /* + return ImGui::ImageButton((ImTextureID)textureID, ImVec2(sizeX, sizeY)); + */ + + /** + * <0 frame_padding uses default frame padding settings. 0 for no padding + */ + public static native boolean ImageButton(int textureID, float sizeX, float sizeY, float uv0_x, float uv0_y, float uv1_x, float uv1_y, int frame_padding); /* + return ImGui::ImageButton((ImTextureID)textureID, ImVec2(sizeX, sizeY), ImVec2(uv0_x, uv0_y), ImVec2(uv1_x, uv1_y), frame_padding); + */ + + /** + * <0 frame_padding uses default frame padding settings. 0 for no padding + */ + public static native boolean ImageButton(int textureID, float sizeX, float sizeY, float uv0_x, float uv0_y, float uv1_x, float uv1_y, int frame_padding, float bg_color_r, float bg_color_g, float bg_color_b, float bg_color_a, float tint_col_r, float tint_col_g, float tint_col_b, float tint_col_a); /* + return ImGui::ImageButton((ImTextureID)textureID, ImVec2(sizeX, sizeY), ImVec2(uv0_x, uv0_y), ImVec2(uv1_x, uv1_y), frame_padding, ImVec4(bg_color_r, bg_color_g, bg_color_b, bg_color_a), ImVec4(tint_col_r, tint_col_g, tint_col_b, tint_col_a)); + */ + + public static boolean Checkbox(String label, ImBool active) { + return nCheckbox(label, active.data); } - public static void Image(int textureID, float sizeX, float sizeY) { - Native.Image(textureID, sizeX, sizeY); + private static native boolean nCheckbox(String label, boolean[] data); /* + return ImGui::Checkbox(label, &data[0]); + */ + + public static boolean CheckboxFlags(String label, ImInt v, int flagsValue) { + return nCheckboxFlags(label, v.data, flagsValue); } - public static void Image(int textureID, float sizeX, float sizeY, float uv0_x, float uv0_y, float uv1_x, float uv1_y) { - Native.Image(textureID, sizeX, sizeY, uv0_x, uv0_y, uv1_x, uv1_y); + private static native boolean nCheckboxFlags(String label, int[] data, int flagsValue); /* + return ImGui::CheckboxFlags(label, (unsigned int*)&data[0], flagsValue); + */ + + /** + * Use with e.g. if (RadioButton("one", my_value==1)) { my_value = 1; } + */ + public static native boolean RadioButton(String label, boolean active); /* + return ImGui::RadioButton(label, active); + */ + + /** + * Shortcut to handle the above pattern when value is an integer + */ + public static boolean RadioButton(String label, ImInt v, int v_button) { + return nRadioButton(label, v.data, v_button); } - public static boolean ImageButton(int textureID, float sizeX, float sizeY) { - return Native.ImageButton(textureID, sizeX, sizeY); - } + private static native boolean nRadioButton(String label, int[] data, int v_button); /* + return ImGui::RadioButton(label, &data[0], v_button); + */ - public static boolean ImageButton(int textureID, float sizeX, float sizeY, float uv0_x, float uv0_y, float uv1_x, float uv1_y, int frame_padding) { - return Native.ImageButton(textureID, sizeX, sizeY, uv0_x, uv0_y, uv1_x, uv1_y, frame_padding); - } + public static native void ProgressBar(float fraction); /* + ImGui::ProgressBar(fraction); + */ - public static boolean Checkbox(String label, ImGuiBoolean value) { - return Native.Checkbox(label, value.data); - } + public static native void ProgressBar(float fraction, float size_arg_x, float size_arg_y); /* + ImGui::ProgressBar(fraction, ImVec2(size_arg_x, size_arg_y)); + */ - public static boolean CheckboxFlags(String label, ImGuiInt flags, ImGuiTabBarFlags flagsValues) { - return Native.CheckboxFlags(label, flags.data, flagsValues.getValue()); - } + public static native void ProgressBar(float fraction, float size_arg_x, float size_arg_y, String overlay); /* + ImGui::ProgressBar(fraction, ImVec2(size_arg_x, size_arg_y), overlay); + */ - public static boolean RadioButton(String label, boolean active) { - return Native.RadioButton(label, active); - } - - public static boolean RadioButton(String label, ImGuiInt value, int v_button) { - return Native.RadioButton(label, value.data, v_button); - } - - public static void ProgressBar(float fraction) { - Native.ProgressBar(fraction); - } - - public static void ProgressBar(float fraction, float size_arg_x, float size_arg_y) { - Native.ProgressBar(fraction, size_arg_x, size_arg_y); - } - - public static void Bullet() { - Native.Bullet(); - } + /** + * Draw a small circle and keep the cursor on the same line. advance cursor x position by GetTreeNodeToLabelSpacing(), same distance that TreeNode() uses + */ + public static native void Bullet(); /* + ImGui::Bullet(); + */ // Widgets: Combo Box - // - The new BeginCombo()/EndCombo() api allows you to manage your contents and selection state however you want it, by creating e.g. Selectable() items. + // - The BeginCombo()/EndCombo() api allows you to manage your contents and selection state however you want it, by creating e.g. Selectable() items. // - The old Combo() api are helpers over BeginCombo()/EndCombo() which are kept available for convenience purpose. - public static boolean BeginCombo(String label, String preview_value) { - return Native.BeginCombo(label, preview_value); + public static native boolean BeginCombo(String label, String preview_value); /* + return ImGui::BeginCombo(label, preview_value); + */ + + public static native boolean BeginCombo(String label, String preview_value, int imGuiComboFlags); /* + return ImGui::BeginCombo(label, preview_value, imGuiComboFlags); + */ + + /** + * Only call EndCombo() if BeginCombo() returns true! + */ + public static native void EndCombo(); /* + ImGui::EndCombo(); + */ + + public static boolean Combo(String label, ImInt current_item, String[] items, int items_count) { + return nCombo(label, current_item.data, items, items_count, -1); } - public static boolean BeginCombo(String label, String preview_value, ImGuiComboFlags flags) { - return Native.BeginCombo(label, preview_value, flags.getValue()); + public static boolean Combo(String label, ImInt current_item, String[] items, int items_count, int popup_max_height_in_items) { + return nCombo(label, current_item.data, items, items_count, popup_max_height_in_items); } - public static void EndCombo() { - Native.EndCombo(); + private static native boolean nCombo(String label, int[] current_item, String[] items, int items_count, int popup_max_height_in_items); /* + const char* listbox_items[items_count]; + for(int i = 0; i < items_count; i++) { + jstring string = (jstring)env->GetObjectArrayElement(items, i); + const char* rawString = env->GetStringUTFChars(string, 0); + listbox_items[i] = rawString; + } + return ImGui::Combo(label, ¤t_item[0], listbox_items, items_count, popup_max_height_in_items); + */ + + /** + * Separate items with \0 within a string, end item-list with \0\0. e.g. "One\0Two\0Three\0" + */ + public static boolean Combo(String label, ImInt current_item, String items_separated_by_zeros) { + return nCombo(label, current_item.data, items_separated_by_zeros, -1); } - public static boolean Combo(String label, ImGuiInt current_item, String[] items, int items_count) { - return Native.Combo(label, current_item.data, items, items_count); + public static boolean Combo(String label, ImInt current_item, String items_separated_by_zeros, int popup_max_height_in_items) { + return nCombo(label, current_item.data, items_separated_by_zeros, popup_max_height_in_items); } - public static boolean Combo(String label, ImGuiInt current_item, String[] items, int items_count, int popup_max_height_in_items) { - return Native.Combo(label, current_item.data, items, items_count, popup_max_height_in_items); - } - - public static boolean Combo(String label, ImGuiInt current_item, String items_separated_by_zeros) { - return Native.Combo(label, current_item.data, items_separated_by_zeros); - } - - public static boolean Combo(String label, ImGuiInt current_item, String items_separated_by_zeros, int popup_max_height_in_items) { - return Native.Combo(label, current_item.data, items_separated_by_zeros, popup_max_height_in_items); - } + private static native boolean nCombo(String label, int[] current_item, String items_separated_by_zeros, int popup_max_height_in_items); /* + return ImGui::Combo(label, ¤t_item[0], items_separated_by_zeros, popup_max_height_in_items); + */ // Widgets: Drags // - CTRL+Click on any drag box to turn them into an input box. Manually input values aren't clamped and can go off-bounds. // - For all the Float2/Float3/Float4/Int2/Int3/Int4 versions of every functions, note that a 'float v[X]' function argument is the same as 'float* v', the array syntax is just a way to document the number of elements that are expected to be accessible. You can pass address of your first element out of a contiguous set, e.g. &myvector.x // - Adjust format string to decorate the value with a prefix, a suffix, or adapt the editing and display precision e.g. "%.3f" -> 1.234; "%5.2f secs" -> 01.23 secs; "Biscuit: %.0f" -> Biscuit: 1; etc. // - Speed are per-pixel of mouse movement (v_speed=0.2f: mouse needs to move by 5 pixels to increase value by 1). For gamepad/keyboard navigation, minimum speed is Max(v_speed, minimum_step_at_given_precision). + // - Use v_min < v_max to clamp edits to given limits. Note that CTRL+Click manual input can override those limits. + // - Use v_min > v_max to lock edits. - public static boolean DragFloat(String label, ImGuiFloat v) { - return Native.DragFloat(label, v.data); + public static native boolean DragFloat(String label, float[] v); /* + return ImGui::DragFloat(label, &v[0]); + */ + + public static native boolean DragFloat(String label, float[] v, float v_speed); /* + return ImGui::DragFloat(label, &v[0], v_speed); + */ + + /** + * If v_min >= v_max we have no bound + */ + public static native boolean DragFloat(String label, float[] v, float v_speed, float v_min, float v_max); /* + return ImGui::DragFloat(label, &v[0], v_speed, v_min, v_max); + */ + + /** + * If v_min >= v_max we have no bound + */ + public static native boolean DragFloat(String label, float[] v, float v_speed, float v_min, float v_max, String format); /* + return ImGui::DragFloat(label, &v[0], v_speed, v_min, v_max, format); + */ + + /** + * If v_min >= v_max we have no bound + */ + public static native boolean DragFloat(String label, float[] v, float v_speed, float v_min, float v_max, String format, float power); /* + return ImGui::DragFloat(label, &v[0], v_speed, v_min, v_max, format, power); + */ + + public static native boolean DragFloat2(String label, float[] v); /* + return ImGui::DragFloat2(label, v); + */ + + public static native boolean DragFloat2(String label, float[] v, float v_speed); /* + return ImGui::DragFloat2(label, v, v_speed); + */ + + public static native boolean DragFloat2(String label, float[] v, float v_speed, float v_min); /* + return ImGui::DragFloat2(label, v, v_speed, v_min); + */ + + public static native boolean DragFloat2(String label, float[] v, float v_speed, float v_min, float v_max); /* + return ImGui::DragFloat2(label, v, v_speed, v_min, v_max); + */ + + public static native boolean DragFloat2(String label, float[] v, float v_speed, float v_min, float v_max, String format); /* + return ImGui::DragFloat2(label, v, v_speed, v_min, v_max, format); + */ + + public static native boolean DragFloat2(String label, float[] v, float v_speed, float v_min, float v_max, String format, float power); /* + return ImGui::DragFloat2(label, v, v_speed, v_min, v_max, format, power); + */ + + public static native boolean DragFloat3(String label, float[] v); /* + return ImGui::DragFloat3(label, v); + */ + + public static native boolean DragFloat3(String label, float[] v, float v_speed); /* + return ImGui::DragFloat3(label, v, v_speed); + */ + + public static native boolean DragFloat3(String label, float[] v, float v_speed, float v_min); /* + return ImGui::DragFloat3(label, v, v_speed, v_min); + */ + + public static native boolean DragFloat3(String label, float[] v, float v_speed, float v_min, float v_max); /* + return ImGui::DragFloat3(label, v, v_speed, v_min, v_max); + */ + + public static native boolean DragFloat3(String label, float[] v, float v_speed, float v_min, float v_max, String format); /* + return ImGui::DragFloat3(label, v, v_speed, v_min, v_max, format); + */ + + public static native boolean DragFloat3(String label, float[] v, float v_speed, float v_min, float v_max, String format, float power); /* + return ImGui::DragFloat3(label, v, v_speed, v_min, v_max, format, power); + */ + + public static native boolean DragFloat4(String label, float[] v); /* + return ImGui::DragFloat4(label, v); + */ + + public static native boolean DragFloat4(String label, float[] v, float v_speed); /* + return ImGui::DragFloat4(label, v, v_speed); + */ + + public static native boolean DragFloat4(String label, float[] v, float v_speed, float v_min); /* + return ImGui::DragFloat4(label, v, v_speed, v_min); + */ + + public static native boolean DragFloat4(String label, float[] v, float v_speed, float v_min, float v_max); /* + return ImGui::DragFloat4(label, v, v_speed, v_min, v_max); + */ + + public static native boolean DragFloat4(String label, float[] v, float v_speed, float v_min, float v_max, String format); /* + return ImGui::DragFloat4(label, v, v_speed, v_min, v_max, format); + */ + + public static native boolean DragFloat4(String label, float[] v, float v_speed, float v_min, float v_max, String format, float power); /* + return ImGui::DragFloat4(label, v, v_speed, v_min, v_max, format, power); + */ + + public static native boolean DragFloatRange2(String label, float[] v_current_min, float[] v_current_max); /* + return ImGui::DragFloatRange2(label, &v_current_min[0], &v_current_max[0]); + */ + + public static native boolean DragFloatRange2(String label, float[] v_current_min, float[] v_current_max, float v_speed); /* + return ImGui::DragFloatRange2(label, &v_current_min[0], &v_current_max[0], v_speed); + */ + + public static native boolean DragFloatRange2(String label, float[] v_current_min, float[] v_current_max, float v_speed, float v_min); /* + return ImGui::DragFloatRange2(label, &v_current_min[0], &v_current_max[0], v_speed, v_min); + */ + + public static native boolean DragFloatRange2(String label, float[] v_current_min, float[] v_current_max, float v_speed, float v_min, float v_max); /* + return ImGui::DragFloatRange2(label, &v_current_min[0], &v_current_max[0], v_speed, v_min, v_max); + */ + + public static native boolean DragFloatRange2(String label, float[] v_current_min, float[] v_current_max, float v_speed, float v_min, float v_max, String format); /* + return ImGui::DragFloatRange2(label, &v_current_min[0], &v_current_max[0], v_speed, v_min, v_max, format); + */ + + public static native boolean DragFloatRange2(String label, float[] v_current_min, float[] v_current_max, float v_speed, float v_min, float v_max, String format, String format_max); /* + return ImGui::DragFloatRange2(label, &v_current_min[0], &v_current_max[0], v_speed, v_min, v_max, format, format_max); + */ + + public static native boolean DragFloatRange2(String label, float[] v_current_min, float[] v_current_max, float v_speed, float v_min, float v_max, String format, String format_max, float power); /* + return ImGui::DragFloatRange2(label, &v_current_min[0], &v_current_max[0], v_speed, v_min, v_max, format, format_max, power); + */ + + public static native boolean DragInt(String label, int[] v); /* + return ImGui::DragInt(label, &v[0]); + */ + + public static native boolean DragInt(String label, int[] v, float v_speed); /* + return ImGui::DragInt(label, &v[0], v_speed); + */ + + public static native boolean DragInt(String label, int[] v, float v_speed, float v_min); /* + return ImGui::DragInt(label, &v[0], v_speed, v_min); + */ + + /** + * If v_min >= v_max we have no bound + */ + public static native boolean DragInt(String label, int[] v, float v_speed, float v_min, float v_max); /* + return ImGui::DragInt(label, &v[0], v_speed, v_min, v_max); + */ + + /** + * If v_min >= v_max we have no bound + */ + public static native boolean DragInt(String label, int[] v, float v_speed, float v_min, float v_max, String format); /* + return ImGui::DragInt(label, &v[0], v_speed, v_min, v_max, format); + */ + + public static native boolean DragInt2(String label, int[] v); /* + return ImGui::DragInt2(label, v); + */ + + public static native boolean DragInt2(String label, int[] v, float v_speed); /* + return ImGui::DragInt2(label, v, v_speed); + */ + + public static native boolean DragInt2(String label, int[] v, float v_speed, float v_min); /* + return ImGui::DragInt2(label, v, v_speed, v_min); + */ + + public static native boolean DragInt2(String label, int[] v, float v_speed, float v_min, float v_max); /* + return ImGui::DragInt2(label, v, v_speed, v_min, v_max); + */ + + public static native boolean DragInt2(String label, int[] v, float v_speed, float v_min, float v_max, String format); /* + return ImGui::DragInt2(label, v, v_speed, v_min, v_max, format); + */ + + public static native boolean DragInt3(String label, int[] v); /* + return ImGui::DragInt2(label, v); + */ + + public static native boolean DragInt3(String label, int[] v, float v_speed); /* + return ImGui::DragInt2(label, v, v_speed); + */ + + public static native boolean DragInt3(String label, int[] v, float v_speed, float v_min); /* + return ImGui::DragInt2(label, v, v_speed, v_min); + */ + + public static native boolean DragInt3(String label, int[] v, float v_speed, float v_min, float v_max); /* + return ImGui::DragInt2(label, v, v_speed, v_min, v_max); + */ + + public static native boolean DragInt3(String label, int[] v, float v_speed, float v_min, float v_max, String format); /* + return ImGui::DragInt2(label, v, v_speed, v_min, v_max, format); + */ + + public static native boolean DragInt4(String label, int[] v); /* + return ImGui::DragInt4(label, v); + */ + + public static native boolean DragInt4(String label, int[] v, float v_speed); /* + return ImGui::DragInt4(label, v, v_speed); + */ + + public static native boolean DragInt4(String label, int[] v, float v_speed, float v_min); /* + return ImGui::DragInt4(label, v, v_speed, v_min); + */ + + public static native boolean DragInt4(String label, int[] v, float v_speed, float v_min, float v_max); /* + return ImGui::DragInt4(label, v, v_speed, v_min, v_max); + */ + + public static native boolean DragInt4(String label, int[] v, float v_speed, float v_min, float v_max, String format); /* + return ImGui::DragInt4(label, v, v_speed, v_min, v_max, format); + */ + + public static native boolean DragIntRange2(String label, int[] v_current_min, int[] v_current_max); /* + return ImGui::DragIntRange2(label, &v_current_min[0], &v_current_max[0]); + */ + + public static native boolean DragIntRange2(String label, int[] v_current_min, int[] v_current_max, float v_speed); /* + return ImGui::DragIntRange2(label, &v_current_min[0], &v_current_max[0], v_speed); + */ + + public static native boolean DragIntRange2(String label, int[] v_current_min, int[] v_current_max, float v_speed, float v_min); /* + return ImGui::DragIntRange2(label, &v_current_min[0], &v_current_max[0], v_speed, v_min); + */ + + public static native boolean DragIntRange2(String label, int[] v_current_min, int[] v_current_max, float v_speed, float v_min, float v_max); /* + return ImGui::DragIntRange2(label, &v_current_min[0], &v_current_max[0], v_speed, v_min, v_max); + */ + + public static native boolean DragIntRange2(String label, int[] v_current_min, int[] v_current_max, float v_speed, float v_min, float v_max, String format); /* + return ImGui::DragIntRange2(label, &v_current_min[0], &v_current_max[0], v_speed, v_min, v_max, format); + */ + + public static native boolean DragIntRange2(String label, int[] v_current_min, int[] v_current_max, float v_speed, float v_min, float v_max, String format, String format_max); /* + return ImGui::DragIntRange2(label, &v_current_min[0], &v_current_max[0], v_speed, v_min, v_max, format, format_max); + */ + + public static boolean DragScalar(String label, int data_type, ImInt p_data, float v_speed) { + return nDragScalar(label, data_type, p_data.data, v_speed); } - public static boolean DragFloat(String label, ImGuiFloat v, float v_speed) { - return Native.DragFloat(label, v.data, v_speed); + private static native boolean nDragScalar(String label, int data_type, int[] p_data, float v_speed); /* + return ImGui::DragScalar(label, data_type, &p_data[0], v_speed); + */ + + public static boolean DragScalar(String label, int data_type, ImInt p_data, float v_speed, int p_min) { + return nDragScalar(label, data_type, p_data.data, v_speed, p_min); } - public static boolean DragFloat(String label, ImGuiFloat v, float v_speed, float v_min, float v_max, String format) { - return Native.DragFloat(label, v.data, v_speed, v_min, v_max, format); + private static native boolean nDragScalar(String label, int data_type, int[] p_data, float v_speed, int p_min); /* + return ImGui::DragScalar(label, data_type, &p_data[0], v_speed, &p_min); + */ + + public static boolean DragScalar(String label, int data_type, ImInt p_data, float v_speed, int p_min, int p_max) { + return nDragScalar(label, data_type, p_data.data, v_speed, p_min, p_max); } - public static boolean DragFloat(String label, ImGuiFloat v, float v_speed, float v_min, float v_max, String format, float power) { - return Native.DragFloat(label, v.data, v_speed, v_min, v_max, format, power); + private static native boolean nDragScalar(String label, int data_type, int[] p_data, float v_speed, int p_min, int p_max); /* + return ImGui::DragScalar(label, data_type, &p_data[0], v_speed, &p_min, &p_max); + */ + + public static boolean DragScalar(String label, int data_type, ImInt p_data, float v_speed, int p_min, int p_max, String format) { + return nDragScalar(label, data_type, p_data.data, v_speed, p_min, p_max, format, 1.0f); } - public static boolean DragFloat2(String label, float[] v) { - return Native.DragFloat2(label, v); + public static boolean DragScalar(String label, int data_type, ImInt p_data, float v_speed, int p_min, int p_max, String format, float power) { + return nDragScalar(label, data_type, p_data.data, v_speed, p_min, p_max, format, power); } - public static boolean DragFloat2(String label, float[] v, float v_speed, float v_min, float v_max, String format, float power) { - return Native.DragFloat2(label, v, v_speed, v_min, v_max, format, power); + private static native boolean nDragScalar(String label, int data_type, int[] p_data, float v_speed, int p_min, int p_max, String format, float power); /* + return ImGui::DragScalar(label, data_type, &p_data[0], v_speed, &p_min, &p_max, format, power); + */ + + public static boolean DragScalar(String label, int data_type, ImFloat p_data, float v_speed) { + return nDragScalar(label, data_type, p_data.data, v_speed); } - public static boolean DragFloat3(String label, float[] v) { - return Native.DragFloat3(label, v); + private static native boolean nDragScalar(String label, int data_type, float[] p_data, float v_speed); /* + return ImGui::DragScalar(label, data_type, &p_data[0], v_speed); + */ + + public static boolean DragScalar(String label, int data_type, ImFloat p_data, float v_speed, float p_min) { + return nDragScalar(label, data_type, p_data.data, v_speed, p_min); } - public static boolean DragFloat3(String label, float[] v, float v_speed, float v_min, float v_max, String format, float power) { - return Native.DragFloat3(label, v, v_speed, v_min, v_max, format, power); + private static native boolean nDragScalar(String label, int data_type, float[] p_data, float v_speed, float p_min); /* + return ImGui::DragScalar(label, data_type, &p_data[0], v_speed, &p_min); + */ + + public static boolean DragScalar(String label, int data_type, ImFloat p_data, float v_speed, float p_min, float p_max) { + return nDragScalar(label, data_type, p_data.data, v_speed, p_min, p_max); } - public static boolean DragFloat4(String label, float[] v) { - return Native.DragFloat4(label, v); + private static native boolean nDragScalar(String label, int data_type, float[] p_data, float v_speed, float p_min, float p_max); /* + return ImGui::DragScalar(label, data_type, &p_data[0], v_speed, &p_min, &p_max); + */ + + public static boolean DragScalar(String label, int data_type, ImFloat p_data, float v_speed, float p_min, float p_max, String format) { + return nDragScalar(label, data_type, p_data.data, v_speed, p_min, p_max, format, 1.0f); } - public static boolean DragFloat4(String label, float[] v, float v_speed, float v_min, float v_max, String format, float power) { - return Native.DragFloat4(label, v, v_speed, v_min, v_max, format, power); + public static boolean DragScalar(String label, int data_type, ImFloat p_data, float v_speed, float p_min, float p_max, String format, float power) { + return nDragScalar(label, data_type, p_data.data, v_speed, p_min, p_max, format, power); } - public static boolean DragFloatRange2(String label, ImGuiFloat v_current_min, ImGuiFloat v_current_max) { - return Native.DragFloatRange2(label, v_current_min.data, v_current_max.data); + private static native boolean nDragScalar(String label, int data_type, float[] p_data, float v_speed, float p_min, float p_max, String format, float power); /* + return ImGui::DragScalar(label, data_type, &p_data[0], v_speed, &p_min, &p_max, format, power); + */ + + public static boolean DragScalar(String label, int data_type, ImDouble p_data, float v_speed) { + return nDragScalar(label, data_type, p_data.data, v_speed); } - public static boolean DragFloatRange2(String label, ImGuiFloat v_current_min, ImGuiFloat v_current_max, float v_speed, float v_min, float v_max, String format, String format_max, float power) { - return Native.DragFloatRange2(label, v_current_min.data, v_current_max.data, v_speed, v_min, v_max, format, format_max, power); + private static native boolean nDragScalar(String label, int data_type, double[] p_data, float v_speed); /* + return ImGui::DragScalar(label, data_type, &p_data[0], v_speed); + */ + + public static boolean DragScalar(String label, int data_type, ImDouble p_data, float v_speed, double p_min) { + return nDragScalar(label, data_type, p_data.data, v_speed, p_min); } - public static boolean DragInt(String label, ImGuiInt v) { - return Native.DragInt(label, v.data); + private static native boolean nDragScalar(String label, int data_type, double[] p_data, float v_speed, double p_min); /* + return ImGui::DragScalar(label, data_type, &p_data[0], v_speed, &p_min); + */ + + public static boolean DragScalar(String label, int data_type, ImDouble p_data, float v_speed, double p_min, double p_max) { + return nDragScalar(label, data_type, p_data.data, v_speed, p_min, p_max); } - public static boolean DragInt(String label, ImGuiInt v, float v_speed) { - return Native.DragInt(label, v.data, v_speed); + private static native boolean nDragScalar(String label, int data_type, double[] p_data, float v_speed, double p_min, double p_max); /* + return ImGui::DragScalar(label, data_type, &p_data[0], v_speed, &p_min, &p_max); + */ + + public static boolean DragScalar(String label, int data_type, ImDouble p_data, float v_speed, double p_min, double p_max, String format) { + return nDragScalar(label, data_type, p_data.data, v_speed, p_min, p_max, format, 1.0f); } - public static boolean DragInt(String label, ImGuiInt v, float v_speed, float v_min, float v_max, String format) { - return Native.DragInt(label, v.data, v_speed, v_min, v_max, format); + public static boolean DragScalar(String label, int data_type, ImDouble p_data, float v_speed, double p_min, double p_max, String format, float power) { + return nDragScalar(label, data_type, p_data.data, v_speed, p_min, p_max, format, power); } - public static boolean DragInt2(String label, int[] v) { - return Native.DragInt2(label, v); + private static native boolean nDragScalar(String label, int data_type, double[] p_data, float v_speed, double p_min, double p_max, String format, float power); /* + return ImGui::DragScalar(label, data_type, &p_data[0], v_speed, &p_min, &p_max, format, power); + */ + + public static boolean DragScalar(String label, int data_type, ImLong p_data, float v_speed) { + return nDragScalar(label, data_type, p_data.data, v_speed); } - public static boolean DragInt2(String label, int[] v, float v_speed, float v_min, float v_max, String format) { - return Native.DragInt2(label, v, v_speed, v_min, v_max, format); + private static native boolean nDragScalar(String label, int data_type, long[] p_data, float v_speed); /* + return ImGui::DragScalar(label, data_type, &p_data[0], v_speed); + */ + + public static boolean DragScalar(String label, int data_type, ImLong p_data, float v_speed, long p_min) { + return nDragScalar(label, data_type, p_data.data, v_speed, p_min); } - public static boolean DragInt3(String label, int[] v) { - return Native.DragInt3(label, v); + private static native boolean nDragScalar(String label, int data_type, long[] p_data, float v_speed, long p_min); /* + return ImGui::DragScalar(label, data_type, &p_data[0], v_speed, &p_min); + */ + + public static boolean DragScalar(String label, int data_type, ImLong p_data, float v_speed, long p_min, long p_max) { + return nDragScalar(label, data_type, p_data.data, v_speed, p_min, p_max); } - public static boolean DragInt3(String label, int[] v, float v_speed, float v_min, float v_max, String format) { - return Native.DragInt3(label, v, v_speed, v_min, v_max, format); + private static native boolean nDragScalar(String label, int data_type, long[] p_data, float v_speed, long p_min, long p_max); /* + return ImGui::DragScalar(label, data_type, &p_data[0], v_speed, &p_min, &p_max); + */ + + public static boolean DragScalar(String label, int data_type, ImLong p_data, float v_speed, long p_min, long p_max, String format) { + return nDragScalar(label, data_type, p_data.data, v_speed, p_min, p_max, format, 1.0f); } - public static boolean DragInt4(String label, int[] v) { - return Native.DragInt4(label, v); + public static boolean DragScalar(String label, int data_type, ImLong p_data, float v_speed, long p_min, long p_max, String format, float power) { + return nDragScalar(label, data_type, p_data.data, v_speed, p_min, p_max, format, power); } - public static boolean DragInt4(String label, int[] v, float v_speed, float v_min, float v_max, String format) { - return Native.DragInt4(label, v, v_speed, v_min, v_max, format); + private static native boolean nDragScalar(String label, int data_type, long[] p_data, float v_speed, long p_min, long p_max, String format, float power); /* + return ImGui::DragScalar(label, data_type, &p_data[0], v_speed, &p_min, &p_max, format, power); + */ + + public static boolean DragScalar(String label, int data_type, ImShort p_data, float v_speed) { + return nDragScalar(label, data_type, p_data.data, v_speed); } - public static boolean DragIntRange2(String label, ImGuiInt v_current_min, ImGuiInt v_current_max) { - return Native.DragIntRange2(label, v_current_min.data, v_current_max.data); + private static native boolean nDragScalar(String label, int data_type, short[] p_data, float v_speed); /* + return ImGui::DragScalar(label, data_type, &p_data[0], v_speed); + */ + + public static boolean DragScalar(String label, int data_type, ImShort p_data, float v_speed, short p_min) { + return nDragScalar(label, data_type, p_data.data, v_speed, p_min); } - public static boolean DragIntRange2(String label, ImGuiInt v_current_min, ImGuiInt v_current_max, float v_speed, float v_min, float v_max, String format, String format_max) { - return Native.DragIntRange2(label, v_current_min.data, v_current_max.data, v_speed, v_min, v_max, format, format_max); + private static native boolean nDragScalar(String label, int data_type, short[] p_data, float v_speed, short p_min); /* + return ImGui::DragScalar(label, data_type, &p_data[0], v_speed, &p_min); + */ + + public static boolean DragScalar(String label, int data_type, ImShort p_data, float v_speed, short p_min, short p_max) { + return nDragScalar(label, data_type, p_data.data, v_speed, p_min, p_max); } - //TODO impl -// public static boolean DragScalar(String label, ImGuiDataType_ data_type, ImGuiInt v, ImGuiInt v_current_max, float v_speed, float v_min, float v_max, String format, String format_max) { -// return ImGuiNative.DragScalar(label, data_type.getValue(), v.data, v_current_max.data, v_speed, v_min, v_max, format, format_max); -// } + private static native boolean nDragScalar(String label, int data_type, short[] p_data, float v_speed, short p_min, short p_max); /* + return ImGui::DragScalar(label, data_type, &p_data[0], v_speed, &p_min, &p_max); + */ + public static boolean DragScalar(String label, int data_type, ImShort p_data, float v_speed, short p_min, short p_max, String format) { + return nDragScalar(label, data_type, p_data.data, v_speed, p_min, p_max, format, 1.0f); + } + + public static boolean DragScalar(String label, int data_type, ImShort p_data, float v_speed, short p_min, short p_max, String format, float power) { + return nDragScalar(label, data_type, p_data.data, v_speed, p_min, p_max, format, power); + } + + private static native boolean nDragScalar(String label, int data_type, short[] p_data, float v_speed, short p_min, short p_max, String format, float power); /* + return ImGui::DragScalar(label, data_type, &p_data[0], v_speed, &p_min, &p_max, format, power); + */ + + public static boolean DragScalarN(String label, int data_type, ImInt p_data, int components, float v_speed) { + return nDragScalarN(label, data_type, p_data.data, components, v_speed); + } + + private static native boolean nDragScalarN(String label, int data_type, int[] p_data, int components, float v_speed); /* + return ImGui::DragScalarN(label, data_type, &p_data[0], components, v_speed); + */ + + public static boolean DragScalarN(String label, int data_type, ImInt p_data, int components, float v_speed, int p_min) { + return nDragScalarN(label, data_type, p_data.data, components, v_speed, p_min); + } + + private static native boolean nDragScalarN(String label, int data_type, int[] p_data, int components, float v_speed, int p_min); /* + return ImGui::DragScalarN(label, data_type, &p_data[0], components, v_speed, &p_min); + */ + + public static boolean DragScalarN(String label, int data_type, ImInt p_data, int components, float v_speed, int p_min, int p_max) { + return nDragScalarN(label, data_type, p_data.data, components, v_speed, p_min, p_max); + } + + private static native boolean nDragScalarN(String label, int data_type, int[] p_data, int components, float v_speed, int p_min, int p_max); /* + return ImGui::DragScalarN(label, data_type, &p_data[0], components, v_speed, &p_min, &p_max); + */ + + public static boolean DragScalarN(String label, int data_type, ImInt p_data, int components, float v_speed, int p_min, int p_max, String format) { + return nDragScalarN(label, data_type, p_data.data, components, v_speed, p_min, p_max, format, 1.0f); + } + + public static boolean DragScalarN(String label, int data_type, ImInt p_data, int components, float v_speed, int p_min, int p_max, String format, float power) { + return nDragScalarN(label, data_type, p_data.data, components, v_speed, p_min, p_max, format, power); + } + + private static native boolean nDragScalarN(String label, int data_type, int[] p_data, int components, float v_speed, int p_min, int p_max, String format, float power); /* + return ImGui::DragScalarN(label, data_type, &p_data[0], components, v_speed, &p_min, &p_max, format, power); + */ + + public static boolean DragScalarN(String label, int data_type, ImFloat p_data, int components, float v_speed) { + return nDragScalarN(label, data_type, p_data.data, components, v_speed); + } + + private static native boolean nDragScalarN(String label, int data_type, float[] p_data, int components, float v_speed); /* + return ImGui::DragScalarN(label, data_type, &p_data[0], components, v_speed); + */ + + public static boolean DragScalarN(String label, int data_type, ImFloat p_data, int components, float v_speed, float p_min) { + return nDragScalarN(label, data_type, p_data.data, components, v_speed, p_min); + } + + private static native boolean nDragScalarN(String label, int data_type, float[] p_data, int components, float v_speed, float p_min); /* + return ImGui::DragScalarN(label, data_type, &p_data[0], components, v_speed, &p_min); + */ + + public static boolean DragScalarN(String label, int data_type, ImFloat p_data, int components, float v_speed, float p_min, float p_max) { + return nDragScalarN(label, data_type, p_data.data, components, v_speed, p_min, p_max); + } + + private static native boolean nDragScalarN(String label, int data_type, float[] p_data, int components, float v_speed, float p_min, float p_max); /* + return ImGui::DragScalarN(label, data_type, &p_data[0], components, v_speed, &p_min, &p_max); + */ + + public static boolean DragScalarN(String label, int data_type, ImFloat p_data, int components, float v_speed, float p_min, float p_max, String format) { + return nDragScalarN(label, data_type, p_data.data, components, v_speed, p_min, p_max, format, 1.0f); + } + + public static boolean DragScalarN(String label, int data_type, ImFloat p_data, int components, float v_speed, float p_min, float p_max, String format, float power) { + return nDragScalarN(label, data_type, p_data.data, components, v_speed, p_min, p_max, format, power); + } + + private static native boolean nDragScalarN(String label, int data_type, float[] p_data, int components, float v_speed, float p_min, float p_max, String format, float power); /* + return ImGui::DragScalarN(label, data_type, &p_data[0], components, v_speed, &p_min, &p_max, format, power); + */ + + public static boolean DragScalarN(String label, int data_type, ImDouble p_data, int components, float v_speed) { + return nDragScalarN(label, data_type, p_data.data, components, v_speed); + } + + private static native boolean nDragScalarN(String label, int data_type, double[] p_data, int components, float v_speed); /* + return ImGui::DragScalarN(label, data_type, &p_data[0], components, v_speed); + */ + + public static boolean DragScalarN(String label, int data_type, ImDouble p_data, int components, float v_speed, double p_min) { + return nDragScalarN(label, data_type, p_data.data, components, v_speed, p_min); + } + + private static native boolean nDragScalarN(String label, int data_type, double[] p_data, int components, float v_speed, double p_min); /* + return ImGui::DragScalarN(label, data_type, &p_data[0], components, v_speed, &p_min); + */ + + public static boolean DragScalarN(String label, int data_type, ImDouble p_data, int components, float v_speed, double p_min, double p_max) { + return nDragScalarN(label, data_type, p_data.data, components, v_speed, p_min, p_max); + } + + private static native boolean nDragScalarN(String label, int data_type, double[] p_data, int components, float v_speed, double p_min, double p_max); /* + return ImGui::DragScalarN(label, data_type, &p_data[0], components, v_speed, &p_min, &p_max); + */ + + public static boolean DragScalarN(String label, int data_type, ImDouble p_data, int components, float v_speed, double p_min, double p_max, String format) { + return nDragScalarN(label, data_type, p_data.data, components, v_speed, p_min, p_max, format, 1.0f); + } + + public static boolean DragScalarN(String label, int data_type, ImDouble p_data, int components, float v_speed, double p_min, double p_max, String format, float power) { + return nDragScalarN(label, data_type, p_data.data, components, v_speed, p_min, p_max, format, power); + } + + private static native boolean nDragScalarN(String label, int data_type, double[] p_data, int components, float v_speed, double p_min, double p_max, String format, float power); /* + return ImGui::DragScalarN(label, data_type, &p_data[0], components, v_speed, &p_min, &p_max, format, power); + */ + + public static boolean DragScalarN(String label, int data_type, ImLong p_data, int components, float v_speed) { + return nDragScalarN(label, data_type, p_data.data, components, v_speed); + } + + private static native boolean nDragScalarN(String label, int data_type, long[] p_data, int components, float v_speed); /* + return ImGui::DragScalarN(label, data_type, &p_data[0], components, v_speed); + */ + + public static boolean DragScalarN(String label, int data_type, ImLong p_data, int components, float v_speed, long p_min) { + return nDragScalarN(label, data_type, p_data.data, components, v_speed, p_min); + } + + private static native boolean nDragScalarN(String label, int data_type, long[] p_data, int components, float v_speed, long p_min); /* + return ImGui::DragScalarN(label, data_type, &p_data[0], components, v_speed, &p_min); + */ + + public static boolean DragScalarN(String label, int data_type, ImLong p_data, int components, float v_speed, long p_min, long p_max) { + return nDragScalarN(label, data_type, p_data.data, components, v_speed, p_min, p_max); + } + + private static native boolean nDragScalarN(String label, int data_type, long[] p_data, int components, float v_speed, long p_min, long p_max); /* + return ImGui::DragScalarN(label, data_type, &p_data[0], components, v_speed, &p_min, &p_max); + */ + + public static boolean DragScalarN(String label, int data_type, ImLong p_data, int components, float v_speed, long p_min, long p_max, String format) { + return nDragScalarN(label, data_type, p_data.data, components, v_speed, p_min, p_max, format, 1.0f); + } + + public static boolean DragScalarN(String label, int data_type, ImLong p_data, int components, float v_speed, long p_min, long p_max, String format, float power) { + return nDragScalarN(label, data_type, p_data.data, components, v_speed, p_min, p_max, format, power); + } + + private static native boolean nDragScalarN(String label, int data_type, long[] p_data, int components, float v_speed, long p_min, long p_max, String format, float power); /* + return ImGui::DragScalarN(label, data_type, &p_data[0], components, v_speed, &p_min, &p_max, format, power); + */ + + public static boolean DragScalarN(String label, int data_type, ImShort p_data, int components, float v_speed) { + return nDragScalarN(label, data_type, p_data.data, components, v_speed); + } + + private static native boolean nDragScalarN(String label, int data_type, short[] p_data, int components, float v_speed); /* + return ImGui::DragScalarN(label, data_type, &p_data[0], components, v_speed); + */ + + public static boolean DragScalarN(String label, int data_type, ImShort p_data, int components, float v_speed, short p_min) { + return nDragScalarN(label, data_type, p_data.data, components, v_speed, p_min); + } + + private static native boolean nDragScalarN(String label, int data_type, short[] p_data, int components, float v_speed, short p_min); /* + return ImGui::DragScalarN(label, data_type, &p_data[0], components, v_speed, &p_min); + */ + + public static boolean DragScalarN(String label, int data_type, ImShort p_data, int components, float v_speed, short p_min, short p_max) { + return nDragScalarN(label, data_type, p_data.data, components, v_speed, p_min, p_max); + } + + private static native boolean nDragScalarN(String label, int data_type, short[] p_data, int components, float v_speed, short p_min, short p_max); /* + return ImGui::DragScalarN(label, data_type, &p_data[0], components, v_speed, &p_min, &p_max); + */ + + public static boolean DragScalarN(String label, int data_type, ImShort p_data, int components, float v_speed, short p_min, short p_max, String format) { + return nDragScalarN(label, data_type, p_data.data, components, v_speed, p_min, p_max, format, 1.0f); + } + + public static boolean DragScalarN(String label, int data_type, ImShort p_data, int components, float v_speed, short p_min, short p_max, String format, float power) { + return nDragScalarN(label, data_type, p_data.data, components, v_speed, p_min, p_max, format, power); + } + + private static native boolean nDragScalarN(String label, int data_type, short[] p_data, int components, float v_speed, short p_min, short p_max, String format, float power); /* + return ImGui::DragScalarN(label, data_type, &p_data[0], components, v_speed, &p_min, &p_max, format, power); + */ // Widgets: Sliders // - CTRL+Click on any slider to turn them into an input box. Manually input values aren't clamped and can go off-bounds. // - Adjust format string to decorate the value with a prefix, a suffix, or adapt the editing and display precision e.g. "%.3f" -> 1.234; "%5.2f secs" -> 01.23 secs; "Biscuit: %.0f" -> Biscuit: 1; etc. - public static boolean SliderFloat(String label, ImGuiFloat v, float v_min, float v_max) { - return Native.SliderFloat(label, v.data, v_min, v_max); + /** + * Adjust format to decorate the value with a prefix or a suffix for in-slider labels or unit display. Use power!=1.0 for power curve sliders + */ + public static native boolean SliderFloat(String label, float[] v, float v_min, float v_max); /* + return ImGui::SliderFloat(label, &v[0],v_min, v_max); + */ + + public static native boolean SliderFloat(String label, float[] v, float v_min, float v_max, String format); /* + return ImGui::SliderFloat(label, &v[0], v_min, v_max, format); + */ + + public static native boolean SliderFloat(String label, float[] v, float v_min, float v_max, String format, float power); /* + return ImGui::SliderFloat(label, &v[0], v_min, v_max, format, power); + */ + + public static native boolean SliderFloat2(String label, float[] v, float v_min, float v_max); /* + return ImGui::SliderFloat2(label, v, v_min, v_max); + */ + + public static native boolean SliderFloat2(String label, float[] v, float v_min, float v_max, String format); /* + return ImGui::SliderFloat2(label, v, v_min, v_max, format); + */ + + public static native boolean SliderFloat2(String label, float[] v, float v_min, float v_max, String format, float power); /* + return ImGui::SliderFloat2(label, v, v_min, v_max, format, power); + */ + + public static native boolean SliderFloat3(String label, float[] v, float v_min, float v_max); /* + return ImGui::SliderFloat3(label, v, v_min, v_max); + */ + + public static native boolean SliderFloat3(String label, float[] v, float v_min, float v_max, String format); /* + return ImGui::SliderFloat3(label, v, v_min, v_max, format); + */ + + public static native boolean SliderFloat3(String label, float[] v, float v_min, float v_max, String format, float power); /* + return ImGui::SliderFloat3(label, v, v_min, v_max, format, power); + */ + + public static native boolean SliderFloat4(String label, float[] v, float v_min, float v_max); /* + return ImGui::SliderFloat4(label, v, v_min, v_max); + */ + + public static native boolean SliderFloat4(String label, float[] v, float v_min, float v_max, String format); /* + return ImGui::SliderFloat4(label, v, v_min, v_max, format); + */ + + public static native boolean SliderFloat4(String label, float[] v, float v_min, float v_max, String format, float power); /* + return ImGui::SliderFloat4(label, v, v_min, v_max, format, power); + */ + + public static native boolean SliderAngle(String label, float[] v_rad); /* + return ImGui::SliderAngle(label, &v_rad[0]); + */ + + public static native boolean SliderAngle(String label, float[] v_rad, float v_degrees_min); /* + return ImGui::SliderAngle(label, &v_rad[0], v_degrees_min); + */ + + public static native boolean SliderAngle(String label, float[] v_rad, float v_degrees_min, float v_degrees_max); /* + return ImGui::SliderAngle(label, &v_rad[0], v_degrees_min, v_degrees_max); + */ + + public static native boolean SliderAngle(String label, float[] v_rad, float v_degrees_min, float v_degrees_max, String format); /* + return ImGui::SliderAngle(label, &v_rad[0], v_degrees_min, v_degrees_max, format); + */ + + public static native boolean SliderInt(String label, int[] v, int v_min, int v_max); /* + return ImGui::SliderInt(label, &v[0], v_min, v_max); + */ + + public static native boolean SliderInt(String label, int[] v, int v_min, int v_max, String format); /* + return ImGui::SliderInt(label, &v[0], v_min, v_max, format); + */ + + public static native boolean SliderInt2(String label, int[] v, int v_min, int v_max); /* + return ImGui::SliderInt2(label, v, v_min, v_max); + */ + + public static native boolean SliderInt2(String label, int[] v, int v_min, int v_max, String format); /* + return ImGui::SliderInt2(label, v, v_min, v_max, format); + */ + + public static native boolean SliderInt3(String label, int[] v, int v_min, int v_max); /* + return ImGui::SliderInt3(label, v, v_min, v_max); + */ + + public static native boolean SliderInt3(String label, int[] v, int v_min, int v_max, String format); /* + return ImGui::SliderInt3(label, v, v_min, v_max, format); + */ + + public static native boolean SliderInt4(String label, int[] v, int v_min, int v_max); /* + return ImGui::SliderInt4(label, v, v_min, v_max); + */ + + public static native boolean SliderInt4(String label, int[] v, int v_min, int v_max, String format); /* + return ImGui::SliderInt4(label, v, v_min, v_max, format); + */ + + public static boolean SliderScalar(String label, int data_type, ImInt v, int v_min, int v_max) { + return nSliderScalar(label, data_type, v.data, v_min, v_max); } - public static boolean SliderFloat(String label, ImGuiFloat v, float v_min, float v_max, String format) { - return Native.SliderFloat(label, v.data, v_min, v_max, format); + private static native boolean nSliderScalar(String label, int data_type, int[] v, int v_min, int v_max); /* + return ImGui::SliderScalar(label, data_type, &v[0], &v_min, &v_max); + */ + + public static boolean SliderScalar(String label, int data_type, ImInt v, int v_min, int v_max, String format) { + return nSliderScalar(label, data_type, v.data, v_min, v_max, format, 1.0f); } - public static boolean SliderFloat(String label, ImGuiFloat v, float v_min, float v_max, String format, float power) { - return Native.SliderFloat(label, v.data, v_min, v_max, format, power); + public static boolean SliderScalar(String label, int data_type, ImInt v, int v_min, int v_max, String format, float power) { + return nSliderScalar(label, data_type, v.data, v_min, v_max, format, power); } - public static boolean SliderFloat2(String label, float[] v, float v_min, float v_max) { - return Native.SliderFloat2(label, v, v_min, v_max); + private static native boolean nSliderScalar(String label, int data_type, int[] v, int v_min, int v_max, String format, float power); /* + return ImGui::SliderScalar(label, data_type, &v[0], &v_min, &v_max, format, power); + */ + + public static boolean SliderScalar(String label, int data_type, ImFloat v, float v_min, float v_max) { + return nSliderScalar(label, data_type, v.data, v_min, v_max); } - public static boolean SliderFloat2(String label, float[] v, float v_min, float v_max, String format, float power) { - return Native.SliderFloat2(label, v, v_min, v_max, format, power); + private static native boolean nSliderScalar(String label, int data_type, float[] v, float v_min, float v_max); /* + return ImGui::SliderScalar(label, data_type, &v[0], &v_min, &v_max); + */ + + public static boolean SliderScalar(String label, int data_type, ImFloat v, float v_min, float v_max, String format) { + return nSliderScalar(label, data_type, v.data, v_min, v_max, format, 1.0f); } - public static boolean SliderFloat3(String label, float[] v, float v_min, float v_max) { - return Native.SliderFloat3(label, v, v_min, v_max); + public static boolean SliderScalar(String label, int data_type, ImFloat v, float v_min, float v_max, String format, float power) { + return nSliderScalar(label, data_type, v.data, v_min, v_max, format, power); } - public static boolean SliderFloat3(String label, float[] v, float v_min, float v_max, String format, float power) { - return Native.SliderFloat3(label, v, v_min, v_max, format, power); + private static native boolean nSliderScalar(String label, int data_type, float[] v, float v_min, float v_max, String format, float power); /* + return ImGui::SliderScalar(label, data_type, &v[0], &v_min, &v_max, format, power); + */ + + public static boolean SliderScalar(String label, int data_type, ImLong v, long v_min, long v_max) { + return nSliderScalar(label, data_type, v.data, v_min, v_max); } - public static boolean SliderFloat4(String label, float[] v, float v_min, float v_max) { - return Native.SliderFloat4(label, v, v_min, v_max); + private static native boolean nSliderScalar(String label, int data_type, long[] v, long v_min, long v_max); /* + return ImGui::SliderScalar(label, data_type, &v[0], &v_min, &v_max); + */ + + public static boolean SliderScalar(String label, int data_type, ImLong v, long v_min, long v_max, String format) { + return nSliderScalar(label, data_type, v.data, v_min, v_max, format, 1.0f); } - public static boolean SliderFloat4(String label, float[] v, float v_min, float v_max, String format, float power) { - return Native.SliderFloat4(label, v, v_min, v_max, format, power); + public static boolean SliderScalar(String label, int data_type, ImLong v, long v_min, long v_max, String format, float power) { + return nSliderScalar(label, data_type, v.data, v_min, v_max, format, power); } - public static boolean SliderAngle(String label, ImGuiFloat v) { - return Native.SliderAngle(label, v.data); + private static native boolean nSliderScalar(String label, int data_type, long[] v, long v_min, long v_max, String format, float power); /* + return ImGui::SliderScalar(label, data_type, &v[0], &v_min, &v_max, format, power); + */ + + public static boolean SliderScalar(String label, int data_type, ImDouble v, double v_min, double v_max) { + return nSliderScalar(label, data_type, v.data, v_min, v_max); } - public static boolean SliderAngle(String label, ImGuiFloat v, float v_degrees_min, float v_degrees_max, String format) { - return Native.SliderAngle(label, v.data, v_degrees_min, v_degrees_max, format); + private static native boolean nSliderScalar(String label, int data_type, double[] v, double v_min, double v_max); /* + return ImGui::SliderScalar(label, data_type, &v[0], &v_min, &v_max); + */ + + public static boolean SliderScalar(String label, int data_type, ImDouble v, double v_min, double v_max, String format) { + return nSliderScalar(label, data_type, v.data, v_min, v_max, format, 1.0f); } - public static boolean SliderInt(String label, ImGuiInt v, int v_min, int v_max) { - return Native.SliderInt(label, v.data, v_min, v_max); + public static boolean SliderScalar(String label, int data_type, ImDouble v, double v_min, double v_max, String format, float power) { + return nSliderScalar(label, data_type, v.data, v_min, v_max, format, power); } - public static boolean SliderInt(String label, ImGuiInt v, int v_min, int v_max, String format) { - return Native.SliderInt(label, v.data, v_min, v_max, format); + private static native boolean nSliderScalar(String label, int data_type, double[] v, double v_min, double v_max, String format, float power); /* + return ImGui::SliderScalar(label, data_type, &v[0], &v_min, &v_max, format, power); + */ + + public static boolean SliderScalar(String label, int data_type, ImShort v, short v_min, short v_max) { + return nSliderScalar(label, data_type, v.data, v_min, v_max); } - public static boolean SliderInt2(String label, int[] v, int v_min, int v_max) { - return Native.SliderInt2(label, v, v_min, v_max); + private static native boolean nSliderScalar(String label, int data_type, short[] v, short v_min, short v_max); /* + return ImGui::SliderScalar(label, data_type, &v[0], &v_min, &v_max); + */ + + public static boolean SliderScalar(String label, int data_type, ImShort v, short v_min, short v_max, String format) { + return nSliderScalar(label, data_type, v.data, v_min, v_max, format, 1.0f); } - public static boolean SliderInt2(String label, int[] v, int v_min, int v_max, String format) { - return Native.SliderInt2(label, v, v_min, v_max, format); + public static boolean SliderScalar(String label, int data_type, ImShort v, short v_min, short v_max, String format, float power) { + return nSliderScalar(label, data_type, v.data, v_min, v_max, format, power); } - public static boolean SliderInt3(String label, int[] v, int v_min, int v_max) { - return Native.SliderInt3(label, v, v_min, v_max); + private static native boolean nSliderScalar(String label, int data_type, short[] v, short v_min, short v_max, String format, float power); /* + return ImGui::SliderScalar(label, data_type, &v[0], &v_min, &v_max, format, power); + */ + + public static boolean SliderScalarN(String label, int data_type, int components, ImInt v, int v_min, int v_max) { + return nSliderScalarN(label, data_type, components, v.data, v_min, v_max); } - public static boolean SliderInt3(String label, int[] v, int v_min, int v_max, String format) { - return Native.SliderInt3(label, v, v_min, v_max, format); + private static native boolean nSliderScalarN(String label, int data_type, int components, int[] v, int v_min, int v_max); /* + return ImGui::SliderScalarN(label, data_type, &v[0], components, &v_min, &v_max); + */ + + public static boolean SliderScalarN(String label, int data_type, int components, ImInt v, int v_min, int v_max, String format) { + return nSliderScalarN(label, data_type, components, v.data, v_min, v_max, format, 1.0f); } - public static boolean SliderInt4(String label, int[] v, int v_min, int v_max) { - return Native.SliderInt4(label, v, v_min, v_max); + public static boolean SliderScalarN(String label, int data_type, int components, ImInt v, int v_min, int v_max, String format, float power) { + return nSliderScalarN(label, data_type, components, v.data, v_min, v_max, format, power); } - public static boolean SliderInt4(String label, int[] v, int v_min, int v_max, String format) { - return Native.SliderInt4(label, v, v_min, v_max, format); + private static native boolean nSliderScalarN(String label, int data_type, int components, int[] v, int v_min, int v_max, String format, float power); /* + return ImGui::SliderScalarN(label, data_type, &v[0], components, &v_min, &v_max, format, power); + */ + + public static boolean SliderScalarN(String label, int data_type, int components, ImFloat v, float v_min, float v_max) { + return nSliderScalarN(label, data_type, components, v.data, v_min, v_max); } - public static boolean SliderScalar(String label, ImGuiDataType data_type, ImGuiInt v, int v_min, int v_max) { - return Native.SliderScalar(label, data_type.getValue(), v.data, v_min, v_max); + private static native boolean nSliderScalarN(String label, int data_type, int components, float[] v, float v_min, float v_max); /* + return ImGui::SliderScalarN(label, data_type, &v[0], components, &v_min, &v_max); + */ + + public static boolean SliderScalarN(String label, int data_type, int components, ImFloat v, float v_min, float v_max, String format) { + return nSliderScalarN(label, data_type, components, v.data, v_min, v_max, format, 1.0f); } - public static boolean SliderScalar(String label, ImGuiDataType data_type, ImGuiInt v, int v_min, int v_max, String format, float power) { - return Native.SliderScalar(label, data_type.getValue(), v.data, v_min, v_max, format, power); + public static boolean SliderScalarN(String label, int data_type, int components, ImFloat v, float v_min, float v_max, String format, float power) { + return nSliderScalarN(label, data_type, components, v.data, v_min, v_max, format, power); } - public static boolean SliderScalar(String label, ImGuiDataType data_type, ImGuiFloat v, float v_min, float v_max) { - return Native.SliderScalar(label, data_type.getValue(), v.data, v_min, v_max); + private static native boolean nSliderScalarN(String label, int data_type, int components, float[] v, float v_min, float v_max, String format, float power); /* + return ImGui::SliderScalarN(label, data_type, &v[0], components, &v_min, &v_max, format, power); + */ + + public static boolean SliderScalarN(String label, int data_type, int components, ImLong v, long v_min, long v_max) { + return nSliderScalarN(label, data_type, components, v.data, v_min, v_max); } - public static boolean SliderScalar(String label, ImGuiDataType data_type, ImGuiFloat v, float v_min, float v_max, String format, float power) { - return Native.SliderScalar(label, data_type.getValue(), v.data, v_min, v_max, format, power); + private static native boolean nSliderScalarN(String label, int data_type, int components, long[] v, long v_min, long v_max); /* + return ImGui::SliderScalarN(label, data_type, &v[0], components, &v_min, &v_max); + */ + + public static boolean SliderScalarN(String label, int data_type, int components, ImLong v, long v_min, long v_max, String format) { + return nSliderScalarN(label, data_type, components, v.data, v_min, v_max, format, 1.0f); } - public static boolean VSliderFloat(String label, float sizeX, float sizeY, ImGuiFloat v, float v_min, float v_max) { - return Native.VSliderFloat(label, sizeX, sizeY, v.data, v_min, v_max); + public static boolean SliderScalarN(String label, int data_type, int components, ImLong v, long v_min, long v_max, String format, float power) { + return nSliderScalarN(label, data_type, components, v.data, v_min, v_max, format, power); } - public static boolean VSliderFloat(String label, float sizeX, float sizeY, ImGuiFloat v, float v_min, float v_max, String format, float power) { - return Native.VSliderFloat(label, sizeX, sizeY, v.data, v_min, v_max, format, power); + private static native boolean nSliderScalarN(String label, int data_type, int components, long[] v, long v_min, long v_max, String format, float power); /* + return ImGui::SliderScalarN(label, data_type, &v[0], components, &v_min, &v_max, format, power); + */ + + public static boolean SliderScalarN(String label, int data_type, int components, ImDouble v, double v_min, double v_max) { + return nSliderScalarN(label, data_type, components, v.data, v_min, v_max); } - public static boolean VSliderInt(String label, float sizeX, float sizeY, ImGuiInt v, int v_min, int v_max) { - return Native.VSliderInt(label, sizeX, sizeY, v.data, v_min, v_max); + private static native boolean nSliderScalarN(String label, int data_type, int components, double[] v, double v_min, double v_max); /* + return ImGui::SliderScalarN(label, data_type, &v[0], components, &v_min, &v_max); + */ + + public static boolean SliderScalarN(String label, int data_type, int components, ImDouble v, double v_min, double v_max, String format) { + return nSliderScalarN(label, data_type, components, v.data, v_min, v_max, format, 1.0f); } - public static boolean VSliderInt(String label, float sizeX, float sizeY, ImGuiInt v, int v_min, int v_max, String format) { - return Native.VSliderInt(label, sizeX, sizeY, v.data, v_min, v_max, format); + public static boolean SliderScalarN(String label, int data_type, int components, ImDouble v, double v_min, double v_max, String format, float power) { + return nSliderScalarN(label, data_type, components, v.data, v_min, v_max, format, power); } - public static boolean VSliderScalar(String label, float sizeX, float sizeY, ImGuiDataType data_type, ImGuiFloat v, float v_min, float v_max) { - return Native.VSliderScalar(label, sizeX, sizeY, data_type.getValue(), v.data, v_min, v_max); + private static native boolean nSliderScalarN(String label, int data_type, int components, double[] v, double v_min, double v_max, String format, float power); /* + return ImGui::SliderScalarN(label, data_type, &v[0], components, &v_min, &v_max, format, power); + */ + + public static boolean SliderScalarN(String label, int data_type, int components, ImShort v, short v_min, short v_max) { + return nSliderScalarN(label, data_type, components, v.data, v_min, v_max); } - public static boolean VSliderScalar(String label, float sizeX, float sizeY, ImGuiDataType data_type, ImGuiFloat v, float v_min, float v_max, String format, float power) { - return Native.VSliderScalar(label, sizeX, sizeY, data_type.getValue(), v.data, v_min, v_max, format, power); + private static native boolean nSliderScalarN(String label, int data_type, int components, short[] v, short v_min, short v_max); /* + return ImGui::SliderScalarN(label, data_type, &v[0], components, &v_min, &v_max); + */ + + public static boolean SliderScalarN(String label, int data_type, int components, ImShort v, short v_min, short v_max, String format) { + return nSliderScalarN(label, data_type, components, v.data, v_min, v_max, format, 1.0f); } - public static boolean VSliderScalar(String label, float sizeX, float sizeY, ImGuiDataType data_type, ImGuiInt v, int v_min, int v_max) { - return Native.VSliderScalar(label, sizeX, sizeY, data_type.getValue(), v.data, v_min, v_max); + public static boolean SliderScalarN(String label, int data_type, int components, ImShort v, short v_min, short v_max, String format, float power) { + return nSliderScalarN(label, data_type, components, v.data, v_min, v_max, format, power); } - public static boolean VSliderScalar(String label, float sizeX, float sizeY, ImGuiDataType data_type, ImGuiInt v, int v_min, int v_max, String format, float power) { - return Native.VSliderScalar(label, sizeX, sizeY, data_type.getValue(), v.data, v_min, v_max, format, power); + private static native boolean nSliderScalarN(String label, int data_type, int components, short[] v, short v_min, short v_max, String format, float power); /* + return ImGui::SliderScalarN(label, data_type, &v[0], components, &v_min, &v_max, format, power); + */ + + public static native boolean VSliderFloat(String label, float sizeX, float sizeY, float[] v, float v_min, float v_max); /* + return ImGui::VSliderFloat(label, ImVec2(sizeX, sizeY), &v[0], v_min, v_max); + */ + + public static native boolean VSliderFloat(String label, float sizeX, float sizeY, float[] v, float v_min, float v_max, String format); /* + return ImGui::VSliderFloat(label, ImVec2(sizeX, sizeY), &v[0], v_min, v_max); + */ + + public static native boolean VSliderFloat(String label, float sizeX, float sizeY, float[] v, float v_min, float v_max, String format, float power); /* + return ImGui::VSliderFloat(label, ImVec2(sizeX, sizeY), &v[0], v_min, v_max, format, power); + */ + + public static native boolean VSliderInt(String label, float sizeX, float sizeY, int[] v, int v_min, int v_max); /* + return ImGui::VSliderInt(label, ImVec2(sizeX, sizeY), &v[0], v_min, v_max); + */ + + public static native boolean VSliderInt(String label, float sizeX, float sizeY, int[] v, int v_min, int v_max, String format); /* + return ImGui::VSliderInt(label, ImVec2(sizeX, sizeY), &v[0], v_min, v_max, format); + */ + + public static boolean VSliderScalar(String label, float sizeX, float sizeY, int data_type, ImInt v, int v_min, int v_max) { + return nVSliderScalar(label, sizeX, sizeY, data_type, v.data, v_min, v_max); } + private static native boolean nVSliderScalar(String label, float sizeX, float sizeY, int data_type, int[] v, int v_min, int v_max); /* + return ImGui::VSliderScalar(label, ImVec2(sizeX, sizeY), data_type, &v[0], &v_min, &v_max); + */ + + public static boolean VSliderScalar(String label, float sizeX, float sizeY, int data_type, ImInt v, int v_min, int v_max, String format) { + return nVSliderScalar(label, sizeX, sizeY, data_type, v.data, v_min, v_max, format, 1.0f); + } + + public static boolean VSliderScalar(String label, float sizeX, float sizeY, int data_type, ImInt v, int v_min, int v_max, String format, float power) { + return nVSliderScalar(label, sizeX, sizeY, data_type, v.data, v_min, v_max, format, power); + } + + private static native boolean nVSliderScalar(String label, float sizeX, float sizeY, int data_type, int[] v, int v_min, int v_max, String format, float power); /* + return ImGui::VSliderScalar(label, ImVec2(sizeX, sizeY), data_type, &v[0], &v_min, &v_max, format, power); + */ + + public static boolean VSliderScalar(String label, float sizeX, float sizeY, int data_type, ImFloat v, float v_min, float v_max) { + return nVSliderScalar(label, sizeX, sizeY, data_type, v.data, v_min, v_max); + } + + private static native boolean nVSliderScalar(String label, float sizeX, float sizeY, int data_type, float[] v, float v_min, float v_max); /* + return ImGui::VSliderScalar(label, ImVec2(sizeX, sizeY), data_type, &v[0], &v_min, &v_max); + */ + + public static boolean VSliderScalar(String label, float sizeX, float sizeY, int data_type, ImFloat v, float v_min, float v_max, String format) { + return nVSliderScalar(label, sizeX, sizeY, data_type, v.data, v_min, v_max, format, 1.0f); + } + + public static boolean VSliderScalar(String label, float sizeX, float sizeY, int data_type, ImFloat v, float v_min, float v_max, String format, float power) { + return nVSliderScalar(label, sizeX, sizeY, data_type, v.data, v_min, v_max, format, power); + } + + private static native boolean nVSliderScalar(String label, float sizeX, float sizeY, int data_type, float[] v, float v_min, float v_max, String format, float power); /* + return ImGui::VSliderScalar(label, ImVec2(sizeX, sizeY), data_type, &v[0], &v_min, &v_max, format, power); + */ + + public static boolean VSliderScalar(String label, float sizeX, float sizeY, int data_type, ImLong v, long v_min, long v_max) { + return nVSliderScalar(label, sizeX, sizeY, data_type, v.data, v_min, v_max); + } + + private static native boolean nVSliderScalar(String label, float sizeX, float sizeY, int data_type, long[] v, long v_min, long v_max); /* + return ImGui::VSliderScalar(label, ImVec2(sizeX, sizeY), data_type, &v[0], &v_min, &v_max); + */ + + public static boolean VSliderScalar(String label, float sizeX, float sizeY, int data_type, ImLong v, long v_min, long v_max, String format) { + return nVSliderScalar(label, sizeX, sizeY, data_type, v.data, v_min, v_max, format, 1.0f); + } + + public static boolean VSliderScalar(String label, float sizeX, float sizeY, int data_type, ImLong v, long v_min, long v_max, String format, float power) { + return nVSliderScalar(label, sizeX, sizeY, data_type, v.data, v_min, v_max, format, power); + } + + private static native boolean nVSliderScalar(String label, float sizeX, float sizeY, int data_type, long[] v, long v_min, long v_max, String format, float power); /* + return ImGui::VSliderScalar(label, ImVec2(sizeX, sizeY), data_type, &v[0], &v_min, &v_max, format, power); + */ + + public static boolean VSliderScalar(String label, float sizeX, float sizeY, int data_type, ImDouble v, double v_min, double v_max) { + return nVSliderScalar(label, sizeX, sizeY, data_type, v.data, v_min, v_max); + } + + private static native boolean nVSliderScalar(String label, float sizeX, float sizeY, int data_type, double[] v, double v_min, double v_max); /* + return ImGui::VSliderScalar(label, ImVec2(sizeX, sizeY), data_type, &v[0], &v_min, &v_max); + */ + + public static boolean VSliderScalar(String label, float sizeX, float sizeY, int data_type, ImDouble v, double v_min, double v_max, String format) { + return nVSliderScalar(label, sizeX, sizeY, data_type, v.data, v_min, v_max, format, 1.0f); + } + + public static boolean VSliderScalar(String label, float sizeX, float sizeY, int data_type, ImDouble v, double v_min, double v_max, String format, float power) { + return nVSliderScalar(label, sizeX, sizeY, data_type, v.data, v_min, v_max, format, power); + } + + private static native boolean nVSliderScalar(String label, float sizeX, float sizeY, int data_type, double[] v, double v_min, double v_max, String format, float power); /* + return ImGui::VSliderScalar(label, ImVec2(sizeX, sizeY), data_type, &v[0], &v_min, &v_max, format, power); + */ + + public static boolean VSliderScalar(String label, float sizeX, float sizeY, int data_type, ImShort v, short v_min, short v_max) { + return nVSliderScalar(label, sizeX, sizeY, data_type, v.data, v_min, v_max); + } + + private static native boolean nVSliderScalar(String label, float sizeX, float sizeY, int data_type, short[] v, short v_min, short v_max); /* + return ImGui::VSliderScalar(label, ImVec2(sizeX, sizeY), data_type, &v[0], &v_min, &v_max); + */ + + public static boolean VSliderScalar(String label, float sizeX, float sizeY, int data_type, ImShort v, short v_min, short v_max, String format) { + return nVSliderScalar(label, sizeX, sizeY, data_type, v.data, v_min, v_max, format, 1.0f); + } + + public static boolean VSliderScalar(String label, float sizeX, float sizeY, int data_type, ImShort v, short v_min, short v_max, String format, float power) { + return nVSliderScalar(label, sizeX, sizeY, data_type, v.data, v_min, v_max, format, power); + } + + private static native boolean nVSliderScalar(String label, float sizeX, float sizeY, int data_type, short[] v, short v_min, short v_max, String format, float power); /* + return ImGui::VSliderScalar(label, ImVec2(sizeX, sizeY), data_type, &v[0], &v_min, &v_max, format, power); + */ + // Widgets: Input with Keyboard // - If you want to use InputText() with a dynamic string type such as std::string or your own, see misc/cpp/imgui_stdlib.h // - Most of the ImGuiInputTextFlags flags are only useful for InputText() and not for InputFloatX, InputIntX, InputDouble etc. - public static boolean InputText(String label, ImGuiString text) { - return Native.InputText(label, text.data, text.data.length, 0, text.inputData, text.inputData.maxChar, text.inputData.allowedChar, text.inputData.allowedChar.length()); + /*JNI + jfieldID imTextInputDataSizeID; + jfieldID imTextInputDataIsDirtyID; + + struct InputTextCallback_UserData { + jobject* textInputData; + JNIEnv* env; + int maxChar; + char* allowedChar; + int allowedCharLength; + int maxSize; + int curSize; + }; + + static int TextEditCallbackStub(ImGuiInputTextCallbackData* data) { + InputTextCallback_UserData* userData = (InputTextCallback_UserData*)data->UserData; + + if (data->EventFlag == ImGuiInputTextFlags_CallbackCharFilter) { + if(userData->allowedCharLength > 0) { + bool found = false; + for(int i = 0; i < userData->allowedCharLength; i++) { + if(userData->allowedChar[i] == data->EventChar) { + found = true; + break; + } + } + return found ? 0 : 1; + } + } + + return 0; + } + */ + + private static native void nInitInputTextData(); /* + jclass jImInputTextDataClass = env->FindClass("imgui/ImGuiInputTextData"); + imTextInputDataSizeID = env->GetFieldID(jImInputTextDataClass, "size", "I"); + imTextInputDataIsDirtyID = env->GetFieldID(jImInputTextDataClass, "isDirty", "Z"); + */ + + public static boolean InputText(String label, ImString text) { + return nInputText(label, text.data, text.data.length, 0, text.inputData, text.inputData.maxChar, text.inputData.allowedChar, text.inputData.allowedChar.length()); } - public static boolean InputText(String label, ImGuiString text, ImGuiInputTextFlags flags) { - return Native.InputText(label, text.data, text.data.length, flags.getValue(), text.inputData, text.inputData.maxChar, text.inputData.allowedChar, text.inputData.allowedChar.length()); + public static boolean InputText(String label, ImString text, ImGuiInputTextFlags flags) { + return nInputText(label, text.data, text.data.length, flags.getValue(), text.inputData, text.inputData.maxChar, text.inputData.allowedChar, text.inputData.allowedChar.length()); } - public static boolean InputFloat(String label, ImGuiFloat v) { - return Native.InputFloat(label, v.data); + private static native boolean nInputText(String label, byte[] buff, int maxSize, int flags, ImGuiInputTextData textInputData, int maxChar, String allowedChar, int allowedCharLength); /* + int size = (int)strlen(buff); + + InputTextCallback_UserData cb_user_data; + cb_user_data.textInputData = &textInputData; + cb_user_data.env = env; + cb_user_data.curSize = size; + cb_user_data.maxSize = maxSize; + cb_user_data.maxChar = maxChar; + cb_user_data.allowedChar = allowedChar; + cb_user_data.allowedCharLength = allowedCharLength; + + char tempArray[maxSize]; + + memset(tempArray, 0, sizeof(tempArray)); + memcpy(tempArray, buff, size); + + if(maxChar >= 0 && maxChar < maxSize) { + maxSize = maxChar; + } + + bool flag = ImGui::InputText(label, tempArray, maxSize, flags | ImGuiInputTextFlags_CallbackCharFilter, &TextEditCallbackStub, &cb_user_data); + + if (flag) { + size = (int)strlen(tempArray); + env->SetIntField(textInputData, imTextInputDataSizeID, size); + env->SetBooleanField(textInputData, imTextInputDataIsDirtyID, true); + memset(buff, 0, maxSize); + memcpy(buff, tempArray, size); + } + + return flag; + */ + + public static boolean InputTextMultiline(String label, ImString text) { + return nInputTextMultiline(label, text.data, text.data.length, 0, 0, 0, text.inputData, text.inputData.maxChar, text.inputData.allowedChar, text.inputData.allowedChar.length()); } - public static boolean InputFloat(String label, ImGuiFloat v, float step, float step_fast, String format) { - return Native.InputFloat(label, v.data, step, step_fast, format); + public static boolean InputTextMultiline(String label, ImString text, float width, float height) { + return nInputTextMultiline(label, text.data, text.data.length, width, height, 0, text.inputData, text.inputData.maxChar, text.inputData.allowedChar, text.inputData.allowedChar.length()); } - public static boolean InputFloat(String label, ImGuiFloat v, float step, float step_fast, String format, ImGuiInputTextFlags flags) { - return Native.InputFloat(label, v.data, step, step_fast, format, flags.getValue()); + public static boolean InputTextMultiline(String label, ImString text, float width, float height, ImGuiInputTextFlags flags) { + return nInputTextMultiline(label, text.data, text.data.length, width, height, flags.getValue(), text.inputData, text.inputData.maxChar, text.inputData.allowedChar, text.inputData.allowedChar.length()); } - public static boolean InputInt(String label, ImGuiInt v) { - return Native.InputInt(label, v.data); + private static native boolean nInputTextMultiline(String label, byte[] buff, int maxSize, float width, float height, int flags, ImGuiInputTextData textInputData, int maxChar, String allowedChar, int allowedCharLength); /* + int size = (int)strlen(buff); + + InputTextCallback_UserData cb_user_data; + cb_user_data.textInputData = &textInputData; + cb_user_data.env = env; + cb_user_data.curSize = size; + cb_user_data.maxSize = maxSize; + cb_user_data.maxChar = maxChar; + cb_user_data.allowedChar = allowedChar; + cb_user_data.allowedCharLength = allowedCharLength; + + char tempArray[maxSize]; + + memset(tempArray, 0, sizeof(tempArray)); + memcpy(tempArray, buff, size); + + if(maxChar >= 0 && maxChar < maxSize) { + maxSize = maxChar; + } + + bool flag = ImGui::InputTextMultiline(label, tempArray, maxSize, ImVec2(width, height), flags | ImGuiInputTextFlags_CallbackCharFilter, &TextEditCallbackStub, &cb_user_data); + + if (flag) { + size = (int)strlen(tempArray); + env->SetIntField(textInputData, imTextInputDataSizeID, size); + env->SetBooleanField(textInputData, imTextInputDataIsDirtyID, true); + memset(buff, 0, maxSize); + memcpy(buff, tempArray, size); + } + + return flag; + */ + + public static boolean InputFloat(String label, ImFloat v) { + return nInputFloat(label, v.data, 0, 0, "%.3f", 0); } - public static boolean InputInt(String label, ImGuiInt v, float step, float step_fast) { - return Native.InputInt(label, v.data, step, step_fast); + public static boolean InputFloat(String label, ImFloat v, float step) { + return nInputFloat(label, v.data, step, 0, "%.3f", 0); } - public static boolean InputInt(String label, ImGuiInt v, float step, float step_fast, ImGuiInputTextFlags flags) { - return Native.InputInt(label, v.data, step, step_fast, flags.getValue()); + public static boolean InputFloat(String label, ImFloat v, float step, float step_fast) { + return nInputFloat(label, v.data, step, step_fast, "%.3f", 0); } - public static boolean InputDouble(String label, ImGuiDouble v) { - return Native.InputDouble(label, v.data); + public static boolean InputFloat(String label, ImFloat v, float step, float step_fast, String format) { + return nInputFloat(label, v.data, step, step_fast, format, 0); } - public static boolean InputDouble(String label, ImGuiDouble v, float step, float step_fast, String format) { - return Native.InputDouble(label, v.data, step, step_fast, format); + public static boolean InputFloat(String label, ImFloat v, float step, float step_fast, String format, int flags) { + return nInputFloat(label, v.data, step, step_fast, format, flags); } - public static boolean InputDouble(String label, ImGuiDouble v, float step, float step_fast, String format, ImGuiInputTextFlags flags) { - return Native.InputDouble(label, v.data, step, step_fast, format, flags.getValue()); + private static native boolean nInputFloat(String label, float[] v, float step, float step_fast, String format, int flags); /* + return ImGui::InputFloat(label, &v[0], step, step_fast, format, flags); + */ + + public static native boolean InputFloat2(String label, float[] v); /* + return ImGui::InputFloat2(label, v, "%.3f", 0); + */ + + public static native boolean InputFloat2(String label, float[] v, String format); /* + return ImGui::InputFloat2(label, v, format, 0); + */ + + public static native boolean InputFloat2(String label, float[] v, String format, int flags); /* + return ImGui::InputFloat2(label, v, format, flags); + */ + + public static native boolean InputFloat3(String label, float[] v); /* + return ImGui::InputFloat2(label, v, "%.3f", 0); + */ + + public static native boolean InputFloat3(String label, float[] v, String format); /* + return ImGui::InputFloat2(label, v, format, 0); + */ + + public static native boolean InputFloat3(String label, float[] v, String format, int flags); /* + return ImGui::InputFloat2(label, v, format, flags); + */ + + public static native boolean InputFloat4(String label, float[] v); /* + return ImGui::InputFloat2(label, v, "%.3f", 0); + */ + + public static native boolean InputFloat4(String label, float[] v, String format); /* + return ImGui::InputFloat2(label, v, format, 0); + */ + + public static native boolean InputFloat4(String label, float[] v, String format, int flags); /* + return ImGui::InputFloat2(label, v, format, flags); + */ + + public static boolean InputInt(String label, ImInt v) { + return nInputInt(label, v.data, 1, 100, 0); } + public static boolean InputInt(String label, ImInt v, int step) { + return nInputInt(label, v.data, step, 100, 0); + } + + public static boolean InputInt(String label, ImInt v, int step, int step_fast) { + return nInputInt(label, v.data, step, step_fast, 0); + } + + public static boolean InputInt(String label, ImInt v, int step, int step_fast, int flags) { + return nInputInt(label, v.data, step, step_fast, flags); + } + + private static native boolean nInputInt(String label, int[] v, int step, int step_fast, int flags); /* + return ImGui::InputInt(label, &v[0], step, step_fast, flags); + */ + + public static native boolean InputInt2(String label, int[] v); /* + return ImGui::InputInt2(label, v, 0); + */ + + public static native boolean InputInt2(String label, int[] v, int flags); /* + return ImGui::InputInt2(label, v, flags); + */ + + public static native boolean InputInt3(String label, int[] v); /* + return ImGui::InputInt2(label, v, 0); + */ + + public static native boolean InputInt3(String label, int[] v, int flags); /* + return ImGui::InputInt2(label, v, flags); + */ + + public static native boolean InputInt4(String label, int[] v); /* + return ImGui::InputInt2(label, v, 0); + */ + + public static native boolean InputInt4(String label, int[] v, int flags); /* + return ImGui::InputInt2(label, v, flags); + */ + + public static boolean InputDouble(String label, ImDouble v) { + return nInputDouble(label, v.data, 0, 0, "%.6f", 0); + } + + public static boolean InputDouble(String label, ImDouble v, double step) { + return nInputDouble(label, v.data, step, 0, "%.6f", 0); + } + + public static boolean InputDouble(String label, ImDouble v, double step, double step_fast) { + return nInputDouble(label, v.data, step, step_fast, "%.6f", 0); + } + + public static boolean InputDouble(String label, ImDouble v, double step, double step_fast, String format) { + return nInputDouble(label, v.data, step, step_fast, format, 0); + } + + public static boolean InputDouble(String label, ImDouble v, double step, double step_fast, String format, int flags) { + return nInputDouble(label, v.data, step, step_fast, format, flags); + } + + private static native boolean nInputDouble(String label, double[] v, double step, double step_fast, String format, int flags); /* + return ImGui::InputDouble(label, &v[0], step, step_fast, format, flags); + */ + + public static boolean InputScalar(String label, int data_type, ImInt p_data) { + return nInputScalar(label, data_type, p_data.data); + } + + private static native boolean nInputScalar(String label, int data_type, int[] p_data); /* + return ImGui::InputScalar(label, data_type, &p_data[0]); + */ + + public static boolean InputScalar(String label, int data_type, ImInt p_data, int p_step) { + return nInputScalar(label, data_type, p_data.data, p_step); + } + + private static native boolean nInputScalar(String label, int data_type, int[] p_data, int p_step); /* + return ImGui::InputScalar(label, data_type, &p_data[0], &p_step); + */ + + public static boolean InputScalar(String label, int data_type, ImInt p_data, int p_step, int p_step_fast) { + return nInputScalar(label, data_type, p_data.data, p_step, p_step_fast); + } + + private static native boolean nInputScalar(String label, int data_type, int[] p_data, int p_step, int p_step_fast); /* + return ImGui::InputScalar(label, data_type, &p_data[0], &p_step, &p_step_fast); + */ + + public static boolean InputScalar(String label, int data_type, ImInt p_data, int p_step, int p_step_fast, String format) { + return nInputScalar(label, data_type, p_data.data, p_step, p_step_fast, format); + } + + private static native boolean nInputScalar(String label, int data_type, int[] p_data, int p_step, int p_step_fast, String format); /* + return ImGui::InputScalar(label, data_type, &p_data[0], &p_step, &p_step_fast, format); + */ + + public static boolean InputScalar(String label, int data_type, ImInt p_data, int p_step, int p_step_fast, String format, int flags) { + return nInputScalar(label, data_type, p_data.data, p_step, p_step_fast, format, flags); + } + + private static native boolean nInputScalar(String label, int data_type, int[] p_data, int p_step, int p_step_fast, String format, int flags); /* + return ImGui::InputScalar(label, data_type, &p_data[0], &p_step, &p_step_fast, format, flags); + */ + + public static boolean InputScalar(String label, int data_type, ImFloat p_data) { + return nInputScalar(label, data_type, p_data.data); + } + + private static native boolean nInputScalar(String label, int data_type, float[] p_data); /* + return ImGui::InputScalar(label, data_type, &p_data[0]); + */ + + public static boolean InputScalar(String label, int data_type, ImFloat p_data, float p_step) { + return nInputScalar(label, data_type, p_data.data, p_step); + } + + private static native boolean nInputScalar(String label, int data_type, float[] p_data, float p_step); /* + return ImGui::InputScalar(label, data_type, &p_data[0], &p_step); + */ + + public static boolean InputScalar(String label, int data_type, ImFloat p_data, float p_step, float p_step_fast) { + return nInputScalar(label, data_type, p_data.data, p_step, p_step_fast); + } + + private static native boolean nInputScalar(String label, int data_type, float[] p_data, float p_step, float p_step_fast); /* + return ImGui::InputScalar(label, data_type, &p_data[0], &p_step, &p_step_fast); + */ + + public static boolean InputScalar(String label, int data_type, ImFloat p_data, float p_step, float p_step_fast, String format) { + return nInputScalar(label, data_type, p_data.data, p_step, p_step_fast, format); + } + + private static native boolean nInputScalar(String label, int data_type, float[] p_data, float p_step, float p_step_fast, String format); /* + return ImGui::InputScalar(label, data_type, &p_data[0], &p_step, &p_step_fast, format); + */ + + public static boolean InputScalar(String label, int data_type, ImFloat p_data, float p_step, float p_step_fast, String format, int flags) { + return nInputScalar(label, data_type, p_data.data, p_step, p_step_fast, format, flags); + } + + private static native boolean nInputScalar(String label, int data_type, float[] p_data, float p_step, float p_step_fast, String format, int flags); /* + return ImGui::InputScalar(label, data_type, &p_data[0], &p_step, &p_step_fast, format, flags); + */ + + public static boolean InputScalar(String label, int data_type, ImLong p_data) { + return nInputScalar(label, data_type, p_data.data); + } + + private static native boolean nInputScalar(String label, int data_type, long[] p_data); /* + return ImGui::InputScalar(label, data_type, &p_data[0]); + */ + + public static boolean InputScalar(String label, int data_type, ImLong p_data, long p_step) { + return nInputScalar(label, data_type, p_data.data, p_step); + } + + private static native boolean nInputScalar(String label, int data_type, long[] p_data, long p_step); /* + return ImGui::InputScalar(label, data_type, &p_data[0], &p_step); + */ + + public static boolean InputScalar(String label, int data_type, ImLong p_data, long p_step, long p_step_fast) { + return nInputScalar(label, data_type, p_data.data, p_step, p_step_fast); + } + + private static native boolean nInputScalar(String label, int data_type, long[] p_data, long p_step, long p_step_fast); /* + return ImGui::InputScalar(label, data_type, &p_data[0], &p_step, &p_step_fast); + */ + + public static boolean InputScalar(String label, int data_type, ImLong p_data, long p_step, long p_step_fast, String format) { + return nInputScalar(label, data_type, p_data.data, p_step, p_step_fast, format); + } + + private static native boolean nInputScalar(String label, int data_type, long[] p_data, long p_step, long p_step_fast, String format); /* + return ImGui::InputScalar(label, data_type, &p_data[0], &p_step, &p_step_fast, format); + */ + + public static boolean InputScalar(String label, int data_type, ImLong p_data, long p_step, long p_step_fast, String format, int flags) { + return nInputScalar(label, data_type, p_data.data, p_step, p_step_fast, format, flags); + } + + private static native boolean nInputScalar(String label, int data_type, long[] p_data, long p_step, long p_step_fast, String format, int flags); /* + return ImGui::InputScalar(label, data_type, &p_data[0], &p_step, &p_step_fast, format, flags); + */ + + public static boolean InputScalar(String label, int data_type, ImDouble p_data) { + return nInputScalar(label, data_type, p_data.data); + } + + private static native boolean nInputScalar(String label, int data_type, double[] p_data); /* + return ImGui::InputScalar(label, data_type, &p_data[0]); + */ + + public static boolean InputScalar(String label, int data_type, ImDouble p_data, double p_step) { + return nInputScalar(label, data_type, p_data.data, p_step); + } + + private static native boolean nInputScalar(String label, int data_type, double[] p_data, double p_step); /* + return ImGui::InputScalar(label, data_type, &p_data[0], &p_step); + */ + + public static boolean InputScalar(String label, int data_type, ImDouble p_data, double p_step, double p_step_fast) { + return nInputScalar(label, data_type, p_data.data, p_step, p_step_fast); + } + + private static native boolean nInputScalar(String label, int data_type, double[] p_data, double p_step, double p_step_fast); /* + return ImGui::InputScalar(label, data_type, &p_data[0], &p_step, &p_step_fast); + */ + + public static boolean InputScalar(String label, int data_type, ImDouble p_data, double p_step, double p_step_fast, String format) { + return nInputScalar(label, data_type, p_data.data, p_step, p_step_fast, format); + } + + private static native boolean nInputScalar(String label, int data_type, double[] p_data, double p_step, double p_step_fast, String format); /* + return ImGui::InputScalar(label, data_type, &p_data[0], &p_step, &p_step_fast, format); + */ + + public static boolean InputScalar(String label, int data_type, ImDouble p_data, double p_step, double p_step_fast, String format, int flags) { + return nInputScalar(label, data_type, p_data.data, p_step, p_step_fast, format, flags); + } + + private static native boolean nInputScalar(String label, int data_type, double[] p_data, double p_step, double p_step_fast, String format, int flags); /* + return ImGui::InputScalar(label, data_type, &p_data[0], &p_step, &p_step_fast, format, flags); + */ + + public static boolean InputScalar(String label, int data_type, ImShort p_data) { + return nInputScalar(label, data_type, p_data.data); + } + + private static native boolean nInputScalar(String label, int data_type, short[] p_data); /* + return ImGui::InputScalar(label, data_type, &p_data[0]); + */ + + public static boolean InputScalar(String label, int data_type, ImShort p_data, short p_step) { + return nInputScalar(label, data_type, p_data.data, p_step); + } + + private static native boolean nInputScalar(String label, int data_type, short[] p_data, short p_step); /* + return ImGui::InputScalar(label, data_type, &p_data[0], &p_step); + */ + + public static boolean InputScalar(String label, int data_type, ImShort p_data, short p_step, short p_step_fast) { + return nInputScalar(label, data_type, p_data.data, p_step, p_step_fast); + } + + private static native boolean nInputScalar(String label, int data_type, short[] p_data, short p_step, short p_step_fast); /* + return ImGui::InputScalar(label, data_type, &p_data[0], &p_step, &p_step_fast); + */ + + public static boolean InputScalar(String label, int data_type, ImShort p_data, short p_step, short p_step_fast, String format) { + return nInputScalar(label, data_type, p_data.data, p_step, p_step_fast, format); + } + + private static native boolean nInputScalar(String label, int data_type, short[] p_data, short p_step, short p_step_fast, String format); /* + return ImGui::InputScalar(label, data_type, &p_data[0], &p_step, &p_step_fast, format); + */ + + public static boolean InputScalar(String label, int data_type, ImShort p_data, short p_step, short p_step_fast, String format, int flags) { + return nInputScalar(label, data_type, p_data.data, p_step, p_step_fast, format, flags); + } + + private static native boolean nInputScalar(String label, int data_type, short[] p_data, short p_step, short p_step_fast, String format, int flags); /* + return ImGui::InputScalar(label, data_type, &p_data[0], &p_step, &p_step_fast, format, flags); + */ + + public static boolean InputScalarN(String label, int data_type, ImInt p_data, int components) { + return nInputScalarN(label, data_type, p_data.data, components); + } + + private static native boolean nInputScalarN(String label, int data_type, int[] p_data, int components); /* + return ImGui::InputScalarN(label, data_type, &p_data[0], components); + */ + + public static boolean InputScalarN(String label, int data_type, ImInt p_data, int components, int p_step) { + return nInputScalarN(label, data_type, p_data.data, components, p_step); + } + + private static native boolean nInputScalarN(String label, int data_type, int[] p_data, int components, int p_step); /* + return ImGui::InputScalarN(label, data_type, &p_data[0], components, &p_step); + */ + + public static boolean InputScalarN(String label, int data_type, ImInt p_data, int components, int p_step, int p_step_fast) { + return nInputScalarN(label, data_type, p_data.data, components, p_step, p_step_fast); + } + + private static native boolean nInputScalarN(String label, int data_type, int[] p_data, int components, int p_step, int p_step_fast); /* + return ImGui::InputScalarN(label, data_type, &p_data[0], components, &p_step, &p_step_fast); + */ + + public static boolean InputScalarN(String label, int data_type, ImInt p_data, int components, int p_step, int p_step_fast, String format) { + return nInputScalarN(label, data_type, p_data.data, components, p_step, p_step_fast, format); + } + + private static native boolean nInputScalarN(String label, int data_type, int[] p_data, int components, int p_step, int p_step_fast, String format); /* + return ImGui::InputScalarN(label, data_type, &p_data[0], components, &p_step, &p_step_fast, format); + */ + + public static boolean InputScalarN(String label, int data_type, ImInt p_data, int components, int p_step, int p_step_fast, String format, int flags) { + return nInputScalarN(label, data_type, p_data.data, components, p_step, p_step_fast, format, flags); + } + + private static native boolean nInputScalarN(String label, int data_type, int[] p_data, int components, int p_step, int p_step_fast, String format, int flags); /* + return ImGui::InputScalarN(label, data_type, &p_data[0], components, &p_step, &p_step_fast, format, flags); + */ + + public static boolean InputScalarN(String label, int data_type, ImFloat p_data, int components) { + return nInputScalarN(label, data_type, p_data.data, components); + } + + private static native boolean nInputScalarN(String label, int data_type, float[] p_data, int components); /* + return ImGui::InputScalarN(label, data_type, &p_data[0], components); + */ + + public static boolean InputScalarN(String label, int data_type, ImFloat p_data, int components, float p_step) { + return nInputScalarN(label, data_type, p_data.data, components, p_step); + } + + private static native boolean nInputScalarN(String label, int data_type, float[] p_data, int components, float p_step); /* + return ImGui::InputScalarN(label, data_type, &p_data[0], components, &p_step); + */ + + public static boolean InputScalarN(String label, int data_type, ImFloat p_data, int components, float p_step, float p_step_fast) { + return nInputScalarN(label, data_type, p_data.data, components, p_step, p_step_fast); + } + + private static native boolean nInputScalarN(String label, int data_type, float[] p_data, int components, float p_step, float p_step_fast); /* + return ImGui::InputScalarN(label, data_type, &p_data[0], components, &p_step, &p_step_fast); + */ + + public static boolean InputScalarN(String label, int data_type, ImFloat p_data, int components, float p_step, float p_step_fast, String format) { + return nInputScalarN(label, data_type, p_data.data, components, p_step, p_step_fast, format); + } + + private static native boolean nInputScalarN(String label, int data_type, float[] p_data, int components, float p_step, float p_step_fast, String format); /* + return ImGui::InputScalarN(label, data_type, &p_data[0], components, &p_step, &p_step_fast, format); + */ + + public static boolean InputScalarN(String label, int data_type, ImFloat p_data, int components, float p_step, float p_step_fast, String format, int flags) { + return nInputScalarN(label, data_type, p_data.data, components, p_step, p_step_fast, format, flags); + } + + private static native boolean nInputScalarN(String label, int data_type, float[] p_data, int components, float p_step, float p_step_fast, String format, int flags); /* + return ImGui::InputScalarN(label, data_type, &p_data[0], components, &p_step, &p_step_fast, format, flags); + */ + + public static boolean InputScalarN(String label, int data_type, ImLong p_data, int components) { + return nInputScalarN(label, data_type, p_data.data, components); + } + + private static native boolean nInputScalarN(String label, int data_type, long[] p_data, int components); /* + return ImGui::InputScalarN(label, data_type, &p_data[0], components); + */ + + public static boolean InputScalarN(String label, int data_type, ImLong p_data, int components, long p_step) { + return nInputScalarN(label, data_type, p_data.data, components, p_step); + } + + private static native boolean nInputScalarN(String label, int data_type, long[] p_data, int components, long p_step); /* + return ImGui::InputScalarN(label, data_type, &p_data[0], components, &p_step); + */ + + public static boolean InputScalarN(String label, int data_type, ImLong p_data, int components, long p_step, long p_step_fast) { + return nInputScalarN(label, data_type, p_data.data, components, p_step, p_step_fast); + } + + private static native boolean nInputScalarN(String label, int data_type, long[] p_data, int components, long p_step, long p_step_fast); /* + return ImGui::InputScalarN(label, data_type, &p_data[0], components, &p_step, &p_step_fast); + */ + + public static boolean InputScalarN(String label, int data_type, ImLong p_data, int components, long p_step, long p_step_fast, String format) { + return nInputScalarN(label, data_type, p_data.data, components, p_step, p_step_fast, format); + } + + private static native boolean nInputScalarN(String label, int data_type, long[] p_data, int components, long p_step, long p_step_fast, String format); /* + return ImGui::InputScalarN(label, data_type, &p_data[0], components, &p_step, &p_step_fast, format); + */ + + public static boolean InputScalarN(String label, int data_type, ImLong p_data, int components, long p_step, long p_step_fast, String format, int flags) { + return nInputScalarN(label, data_type, p_data.data, components, p_step, p_step_fast, format, flags); + } + + private static native boolean nInputScalarN(String label, int data_type, long[] p_data, int components, long p_step, long p_step_fast, String format, int flags); /* + return ImGui::InputScalarN(label, data_type, &p_data[0], components, &p_step, &p_step_fast, format, flags); + */ + + public static boolean InputScalarN(String label, int data_type, ImDouble p_data, int components) { + return nInputScalarN(label, data_type, p_data.data, components); + } + + private static native boolean nInputScalarN(String label, int data_type, double[] p_data, int components); /* + return ImGui::InputScalarN(label, data_type, &p_data[0], components); + */ + + public static boolean InputScalarN(String label, int data_type, ImDouble p_data, int components, double p_step) { + return nInputScalarN(label, data_type, p_data.data, components, p_step); + } + + private static native boolean nInputScalarN(String label, int data_type, double[] p_data, int components, double p_step); /* + return ImGui::InputScalarN(label, data_type, &p_data[0], components, &p_step); + */ + + public static boolean InputScalarN(String label, int data_type, ImDouble p_data, int components, double p_step, double p_step_fast) { + return nInputScalarN(label, data_type, p_data.data, components, p_step, p_step_fast); + } + + private static native boolean nInputScalarN(String label, int data_type, double[] p_data, int components, double p_step, double p_step_fast); /* + return ImGui::InputScalarN(label, data_type, &p_data[0], components, &p_step, &p_step_fast); + */ + + public static boolean InputScalarN(String label, int data_type, ImDouble p_data, int components, double p_step, double p_step_fast, String format) { + return nInputScalarN(label, data_type, p_data.data, components, p_step, p_step_fast, format); + } + + private static native boolean nInputScalarN(String label, int data_type, double[] p_data, int components, double p_step, double p_step_fast, String format); /* + return ImGui::InputScalarN(label, data_type, &p_data[0], components, &p_step, &p_step_fast, format); + */ + + public static boolean InputScalarN(String label, int data_type, ImDouble p_data, int components, double p_step, double p_step_fast, String format, int flags) { + return nInputScalarN(label, data_type, p_data.data, components, p_step, p_step_fast, format, flags); + } + + private static native boolean nInputScalarN(String label, int data_type, double[] p_data, int components, double p_step, double p_step_fast, String format, int flags); /* + return ImGui::InputScalarN(label, data_type, &p_data[0], components, &p_step, &p_step_fast, format, flags); + */ + + public static boolean InputScalarN(String label, int data_type, ImShort p_data, int components) { + return nInputScalarN(label, data_type, p_data.data, components); + } + + private static native boolean nInputScalarN(String label, int data_type, short[] p_data, int components); /* + return ImGui::InputScalarN(label, data_type, &p_data[0], components); + */ + + public static boolean InputScalarN(String label, int data_type, ImShort p_data, int components, short p_step) { + return nInputScalarN(label, data_type, p_data.data, components, p_step); + } + + private static native boolean nInputScalarN(String label, int data_type, short[] p_data, int components, short p_step); /* + return ImGui::InputScalarN(label, data_type, &p_data[0], components, &p_step); + */ + + public static boolean InputScalarN(String label, int data_type, ImShort p_data, int components, short p_step, short p_step_fast) { + return nInputScalarN(label, data_type, p_data.data, components, p_step, p_step_fast); + } + + private static native boolean nInputScalarN(String label, int data_type, short[] p_data, int components, short p_step, short p_step_fast); /* + return ImGui::InputScalarN(label, data_type, &p_data[0], components, &p_step, &p_step_fast); + */ + + public static boolean InputScalarN(String label, int data_type, ImShort p_data, int components, short p_step, short p_step_fast, String format) { + return nInputScalarN(label, data_type, p_data.data, components, p_step, p_step_fast, format); + } + + private static native boolean nInputScalarN(String label, int data_type, short[] p_data, int components, short p_step, short p_step_fast, String format); /* + return ImGui::InputScalarN(label, data_type, &p_data[0], components, &p_step, &p_step_fast, format); + */ + + public static boolean InputScalarN(String label, int data_type, ImShort p_data, int components, short p_step, short p_step_fast, String format, int flags) { + return nInputScalarN(label, data_type, p_data.data, components, p_step, p_step_fast, format, flags); + } + + private static native boolean nInputScalarN(String label, int data_type, short[] p_data, int components, short p_step, short p_step_fast, String format, int flags); /* + return ImGui::InputScalarN(label, data_type, &p_data[0], components, &p_step, &p_step_fast, format, flags); + */ + + // Widgets: Color Editor/Picker (tip: the ColorEdit* functions have a little colored preview square that can be left-clicked to open a picker, and right-clicked to open an option menu.) + // - Note that in C++ a 'float v[X]' function argument is the _same_ as 'float* v', the array syntax is just a way to document the number of elements that are expected to be accessible. + // - You can pass the address of a first float element out of a contiguous structure, e.g. &myvector.x + + public native static boolean ColorEdit3(String label, float[] col); /* + return ImGui::ColorEdit3(label, col); + */ + + public native static boolean ColorEdit3(String label, float[] col, int imGuiColorEditFlags); /* + return ImGui::ColorEdit3(label, col, imGuiColorEditFlags); + */ + + public native static boolean ColorEdit4(String label, float[] col); /* + return ImGui::ColorEdit4(label, col); + */ + + public native static boolean ColorEdit4(String label, float[] col, int imGuiColorEditFlags); /* + return ImGui::ColorEdit4(label, col, imGuiColorEditFlags); + */ + + public native static boolean ColorPicker3(String label, float[] col); /* + return ImGui::ColorPicker3(label, col); + */ + + public native static boolean ColorPicker3(String label, float[] col, int imGuiColorEditFlags); /* + return ImGui::ColorPicker3(label, col, imGuiColorEditFlags); + */ + + public native static boolean ColorPicker4(String label, float[] col); /* + return ImGui::ColorPicker4(label, col); + */ + + public native static boolean ColorPicker4(String label, float[] col, int imGuiColorEditFlags); /* + return ImGui::ColorPicker4(label, col, imGuiColorEditFlags); + */ + + public native static boolean ColorPicker4(String label, float[] col, int imGuiColorEditFlags, float ref_col); /* + return ImGui::ColorPicker4(label, col, imGuiColorEditFlags, &ref_col); + */ + + /** + * Display a colored square/button, hover for details, return true when pressed. + */ + public native static boolean ColorButton(String desc_id, float[] col); /* + return ImGui::ColorButton(desc_id, ImVec4(col[0], col[1], col[2], col[3])); + */ + + /** + * Display a colored square/button, hover for details, return true when pressed. + */ + public native static boolean ColorButton(String desc_id, float[] col, int imGuiColorEditFlags); /* + return ImGui::ColorButton(desc_id, ImVec4(col[0], col[1], col[2], col[3]), imGuiColorEditFlags); + */ + + /** + * Display a colored square/button, hover for details, return true when pressed. + */ + public native static boolean ColorButton(String desc_id, float[] col, int imGuiColorEditFlags, float width, float height); /* + return ImGui::ColorButton(desc_id, ImVec4(col[0], col[1], col[2], col[3]), imGuiColorEditFlags, ImVec2(width, height)); + */ + + /** + * Initialize current options (generally on application startup) if you want to select a default format, + * picker type, etc. User will be able to change many settings, unless you pass the _NoOptions flag to your calls. + */ + public native static void SetColorEditOptions(int imGuiColorEditFlags); /* + ImGui::SetColorEditOptions(imGuiColorEditFlags); + */ + // Widgets: Trees // - TreeNode functions return true when the node is open, in which case you need to also call TreePop() when you are finished displaying the tree node contents. - public static boolean TreeNode(String label) { - return Native.TreeNode(label); + public static native boolean TreeNode(String label); /* + return ImGui::TreeNode(label); + */ + + /** + * Helper variation to easily decorelate the id from the displayed string. + * Read the FAQ about why and how to use ID. to align arbitrary text at the same level as a TreeNode() you can use Bullet(). + */ + public static native boolean TreeNode(String str_id, String label); /* + return ImGui::TreeNode(str_id, label); + */ + + public static native boolean TreeNode(long ptr_id, String label); /* + return ImGui::TreeNode((void*)ptr_id, label); + */ + + public static native boolean TreeNodeEx(String label); /* + return ImGui::TreeNodeEx(label); + */ + + public static native boolean TreeNodeEx(String label, int flags); /* + return ImGui::TreeNodeEx(label, flags); + */ + + public static native boolean TreeNodeEx(String str_id, int flags, String label); /* + return ImGui::TreeNodeEx(str_id, flags, label); + */ + + public static native boolean TreeNodeEx(int ptr_id, int flags, String label); /* + return ImGui::TreeNodeEx((void*)(intptr_t)ptr_id, flags, label); + */ + + /** + * ~ Indent()+PushId(). Already called by TreeNode() when returning true, but you can call TreePush/TreePop yourself if desired. + */ + public static native void TreePush(); /* + ImGui::TreePush(); + */ + + public static native void TreePush(String str_id); /* + ImGui::TreePush(str_id); + */ + + public static native void TreePush(long ptr_id); /* + ImGui::TreePush((void*)(intptr_t)ptr_id); + */ + + /** + * ~ Unindent()+PopId() + */ + public static native void TreePop(); /* + ImGui::TreePop(); + */ + + public static native void TreeAdvanceToLabelPos(); /* + ImGui::TreeAdvanceToLabelPos(); + */ + + /** + * Horizontal distance preceding label when using TreeNode*() or Bullet() == (g.FontSize + style.FramePadding.x*2) for a regular unframed TreeNode + */ + public static native float GetTreeNodeToLabelSpacing(); /* + return ImGui::GetTreeNodeToLabelSpacing(); + */ + + /** + * If returning 'true' the header is open. doesn't indent nor push on ID stack. user doesn't have to call TreePop(). + */ + public static native boolean CollapsingHeader(String label); /* + return ImGui::CollapsingHeader(label); + */ + + /** + * If returning 'true' the header is open. doesn't indent nor push on ID stack. user doesn't have to call TreePop(). + */ + public static native boolean CollapsingHeader(String label, int flags); /* + return ImGui::CollapsingHeader(label, flags); + */ + + /** + * When 'p_open' isn't NULL, display an additional small close button on upper right of the header + */ + public static boolean CollapsingHeader(String label, ImBool p_open) { + return nCollapsingHeader(label, p_open.data, 0); } - public static boolean TreeNode(String str_id, String label) { - return Native.TreeNode(str_id, label); + /** + * When 'p_open' isn't NULL, display an additional small close button on upper right of the header + */ + public static boolean CollapsingHeader(String label, ImBool p_open, int flags) { + return nCollapsingHeader(label, p_open.data, flags); } - public static boolean TreeNode(int ptr_id, String label) { - return Native.TreeNode(ptr_id, label); - } + private static native boolean nCollapsingHeader(String label, boolean[] p_open, int flags); /* + return ImGui::CollapsingHeader(label, p_open, flags); + */ - public static boolean TreeNodeEx(String label) { - return Native.TreeNodeEx(label); - } - - public static boolean TreeNodeEx(String label, ImGuiTreeNodeFlags flags) { - return Native.TreeNodeEx(label, flags.getValue()); - } - - public static boolean TreeNodeEx(String str_id, ImGuiTreeNodeFlags flags, String label) { - return Native.TreeNodeEx(str_id, flags.getValue(), label); - } - - public static boolean TreeNodeEx(int ptr_id, ImGuiTreeNodeFlags flags, String label) { - return Native.TreeNodeEx(ptr_id, flags.getValue(), label); - } - - public static void TreePush() { - Native.TreePush(); - } - - public static void TreePush(String str_id) { - Native.TreePush(str_id); - } - - public static void TreePush(int ptr_id) { - Native.TreePush(ptr_id); - } - - public static void TreePop() { - Native.TreePop(); - } - - public static void TreeAdvanceToLabelPos() { - Native.TreeAdvanceToLabelPos(); - } - - public static float GetTreeNodeToLabelSpacing() { - return Native.GetTreeNodeToLabelSpacing(); - } - - public static void SetNextTreeNodeOpen(boolean is_open) { - Native.SetNextTreeNodeOpen(is_open); - } - - public static void SetNextTreeNodeOpen(boolean is_open, ImGuiCond cond) { - Native.SetNextTreeNodeOpen(is_open, cond.getValue()); - } - - public static boolean CollapsingHeader(String label) { - return Native.CollapsingHeader(label); - } - - public static boolean CollapsingHeader(String label, ImGuiTreeNodeFlags flags) { - return Native.CollapsingHeader(label, flags.getValue()); - } - - public static boolean CollapsingHeader(String label, ImGuiBoolean p_open) { - return Native.CollapsingHeader(label, p_open.data); - } - - public static boolean CollapsingHeader(String label, ImGuiBoolean p_open, ImGuiTreeNodeFlags flags) { - return Native.CollapsingHeader(label, p_open.data, flags.getValue()); - } + /** + * Set next TreeNode/CollapsingHeader open state. + */ + public static native void SetNextItemOpen(boolean is_open); /* + ImGui::SetNextItemOpen(is_open); + */ + /** + * Set next TreeNode/CollapsingHeader open state. + */ + public static native void SetNextItemOpen(boolean is_open, int cond); /* + ImGui::SetNextItemOpen(is_open, cond); + */ // Widgets: Selectables // - A selectable highlights when hovered, and can display another color when selected. // - Neighbors selectable extend their highlight bounds in order to leave no gap between them. - public static boolean Selectable(String label) { - return Native.Selectable(label); + public static native boolean Selectable(String label); /* + return ImGui::Selectable(label); + */ + + public static native boolean Selectable(String label, boolean selected); /* + return ImGui::Selectable(label, selected); + */ + + public static native boolean Selectable(String label, boolean selected, int flags); /* + return ImGui::Selectable(label, selected, flags); + */ + + public static native boolean Selectable(String label, boolean selected, int flags, float sizeX, float sizeY); /* + return ImGui::Selectable(label, selected, flags, ImVec2(sizeX, sizeY)); + */ + + public static boolean Selectable(String label, ImBool selected) { + return nSelectable(label, selected.data, 0, 0, 0); } - public static boolean Selectable(String label, boolean selected) { - return Native.Selectable(label, selected); + public static boolean Selectable(String label, ImBool selected, int flags) { + return nSelectable(label, selected.data, flags, 0, 0); } - public static boolean Selectable(String label, boolean selected, int flags, float sizeX, float sizeY) { - return Native.Selectable(label, selected, flags, sizeX, sizeY); + public static boolean Selectable(String label, ImBool selected, int flags, float sizeX, float sizeY) { + return nSelectable(label, selected.data, flags, sizeX, sizeY); } - public static boolean Selectable(String label, ImGuiBoolean selected) { - return Native.Selectable(label, selected.data); - } - - public static boolean Selectable(String label, ImGuiBoolean selected, int flags, float sizeX, float sizeY) { - return Native.Selectable(label, selected.data, flags, sizeX, sizeY); - } + private static native boolean nSelectable(String label, boolean[] selected, int flags, float sizeX, float sizeY); /* + return ImGui::Selectable(label, &selected[0], flags, ImVec2(sizeX, sizeY)); + */ // Widgets: List Boxes // - FIXME: To be consistent with all the newer API, ListBoxHeader/ListBoxFooter should in reality be called BeginListBox/EndListBox. Will rename them. - public static void ListBox(String label, ImGuiInt current_item, String[] items, int items_count) { - Native.ListBox(label, current_item.data, items, items_count); + public static void ListBox(String label, ImInt current_item, String[] items, int items_count) { + nListBox(label, current_item.data, items, items_count, -1); } - public static void ListBoxHeader(String label) { - Native.ListBoxHeader(label); + public static void ListBox(String label, ImInt current_item, String[] items, int items_count, int height_in_items) { + nListBox(label, current_item.data, items, items_count, height_in_items); } - public static void ListBoxHeader(String label, float sizeX, float sizeY) { - Native.ListBoxHeader(label, sizeX, sizeY); - } + private static native boolean nListBox(String label, int[] current_item, String [] items, int items_count, int height_in_items); /* + const char* listbox_items[items_count]; - public static void ListBoxHeader(String label, int items_count) { - Native.ListBoxHeader(label, items_count); - } + for(int i = 0; i < items_count; i++) { + jstring string = (jstring)env->GetObjectArrayElement(items, i); + const char *rawString = env->GetStringUTFChars(string, 0); + listbox_items[i] = rawString; + } - public static void ListBoxHeader(String label, int items_count, int height_in_items) { - Native.ListBoxHeader(label, items_count, height_in_items); - } + return ImGui::ListBox(label, ¤t_item[0], listbox_items, items_count, height_in_items); + */ + + /** + * Use if you want to reimplement ListBox() will custom data or interactions. + * If the function return true, you can output elements then call ListBoxFooter() afterwards. + */ + public static native boolean ListBoxHeader(String label); /* + return ImGui::ListBoxHeader(label); + */ + + /** + * Use if you want to reimplement ListBox() will custom data or interactions. + * If the function return true, you can output elements then call ListBoxFooter() afterwards. + */ + public static native boolean ListBoxHeader(String label, float sizeX, float sizeY); /* + return ImGui::ListBoxHeader(label, ImVec2(sizeX, sizeY)); + */ + + public static native boolean ListBoxHeader(String label, int items_count); /* + return ImGui::ListBoxHeader(label, items_count); + */ + + public static native boolean ListBoxHeader(String label, int items_count, int height_in_items); /* + return ImGui::ListBoxHeader(label, items_count, height_in_items); + */ + + /** + * Terminate the scrolling region. Only call ListBoxFooter() if ListBoxHeader() returned true! + */ + public static native void ListBoxFooter(); /* + ImGui::ListBoxFooter(); + */ + + // Widgets: Data Plotting + + public static native void PlotLines(String label, float[] values, int values_count); /* + ImGui::PlotLines(label, &values[0], values_count); + */ + + public static native void PlotLines(String label, float[] values, int values_count, int values_offset); /* + ImGui::PlotLines(label, &values[0], values_count, values_offset); + */ + + public static native void PlotLines(String label, float[] values, int values_count, int values_offset, String overlay_text); /* + ImGui::PlotLines(label, &values[0], values_count, values_offset, overlay_text); + */ + + public static native void PlotLines(String label, float[] values, int values_count, int values_offset, String overlay_text, float scale_min); /* + ImGui::PlotLines(label, &values[0], values_count, values_offset, overlay_text, scale_min); + */ + + public static native void PlotLines(String label, float[] values, int values_count, int values_offset, String overlay_text, float scale_min, float scale_max); /* + ImGui::PlotLines(label, &values[0], values_count, values_offset, overlay_text, scale_min, scale_max); + */ + + public static native void PlotLines(String label, float[] values, int values_count, int values_offset, String overlay_text, float scale_min, float scale_max, float graph_width, float graph_height); /* + ImGui::PlotLines(label, &values[0], values_count, values_offset, overlay_text, scale_min, scale_max, ImVec2(graph_width, graph_height)); + */ + + public static native void PlotLines(String label, float[] values, int values_count, int values_offset, String overlay_text, float scale_min, float scale_max, float graph_width, float graph_height, int stride); /* + ImGui::PlotLines(label, &values[0], values_count, values_offset, overlay_text, scale_min, scale_max, ImVec2(graph_width, graph_height), stride); + */ + + public static native void PlotHistogram(String label, float[] values, int values_count); /* + ImGui::PlotHistogram(label, &values[0], values_count); + */ + + public static native void PlotHistogram(String label, float[] values, int values_count, int values_offset); /* + ImGui::PlotHistogram(label, &values[0], values_count, values_offset); + */ + + public static native void PlotHistogram(String label, float[] values, int values_count, int values_offset, String overlay_text); /* + ImGui::PlotHistogram(label, &values[0], values_count, values_offset, overlay_text); + */ + + public static native void PlotHistogram(String label, float[] values, int values_count, int values_offset, String overlay_text, float scale_min); /* + ImGui::PlotHistogram(label, &values[0], values_count, values_offset, overlay_text, scale_min); + */ + + public static native void PlotHistogram(String label, float[] values, int values_count, int values_offset, String overlay_text, float scale_min, float scale_max); /* + ImGui::PlotHistogram(label, &values[0], values_count, values_offset, overlay_text, scale_min, scale_max); + */ + + public static native void PlotHistogram(String label, float[] values, int values_count, int values_offset, String overlay_text, float scale_min, float scale_max, float graph_width, float graph_height); /* + ImGui::PlotHistogram(label, &values[0], values_count, values_offset, overlay_text, scale_min, scale_max, ImVec2(graph_width, graph_height)); + */ + + public static native void PlotHistogram(String label, float[] values, int values_count, int values_offset, String overlay_text, float scale_min, float scale_max, float graph_width, float graph_height, int stride); /* + ImGui::PlotHistogram(label, &values[0], values_count, values_offset, overlay_text, scale_min, scale_max, ImVec2(graph_width, graph_height), stride); + */ + + // Widgets: Value() Helpers. + // - Those are merely shortcut to calling Text() with a format string. Output single value in "name: value" format (tip: freely declare more in your code to handle your types. you can add functions to the ImGui namespace) + + public static native void Value(String prefix, boolean b); /* + ImGui::Value(prefix, b); + */ + + public static native void Value(String prefix, int v); /* + ImGui::Value(prefix, (int)v); + */ + + public static native void Value(String prefix, long v); /* + ImGui::Value(prefix, (unsigned int)v); + */ + + public static native void Value(String prefix, float f); /* + ImGui::Value(prefix, f); + */ + + public static native void Value(String prefix, float f, String float_format); /* + ImGui::Value(prefix, f, float_format); + */ // Widgets: Menus + // - Use BeginMenuBar() on a window ImGuiWindowFlags_MenuBar to append to its menu bar. + // - Use BeginMainMenuBar() to create a menu bar at the top of the screen. - public static boolean BeginMainMenuBar() { - return Native.BeginMainMenuBar(); + /** + * Append to menu-bar of current window (requires ImGuiWindowFlags_MenuBar flag set on parent window). + */ + public static native boolean BeginMenuBar(); /* + return ImGui::BeginMenuBar(); + */ + + /** + * Only call EndMenuBar() if BeginMenuBar() returns true! + */ + public static native void EndMenuBar(); /* + ImGui::EndMenuBar(); + */ + + /** + * Create and append to a full screen menu-bar. + */ + public static native boolean BeginMainMenuBar(); /* + return ImGui::BeginMainMenuBar(); + */ + + /** + * Only call EndMainMenuBar() if BeginMainMenuBar() returns true! + */ + public static native void EndMainMenuBar(); /* + ImGui::EndMainMenuBar(); + */ + + /** + * Create a sub-menu entry. only call EndMenu() if this returns true! + */ + public static native boolean BeginMenu(String label); /* + return ImGui::BeginMenu(label); + */ + + /** + * Create a sub-menu entry. only call EndMenu() if this returns true! + */ + public static native boolean BeginMenu(String label, boolean enabled); /* + return ImGui::BeginMenu(label, enabled); + */ + + /** + * Only call EndMenu() if BeginMenu() returns true! + */ + public static native void EndMenu(); /* + ImGui::EndMenu(); + */ + + /** + * Return true when activated. shortcuts are displayed for convenience but not processed by ImGui at the moment + */ + public static native boolean MenuItem(String label); /* + return ImGui::MenuItem(label); + */ + + /** + * Return true when activated. shortcuts are displayed for convenience but not processed by ImGui at the moment + */ + public static native boolean MenuItem(String label, String shortcut); /* + return ImGui::MenuItem(label, shortcut); + */ + + /** + * Return true when activated. shortcuts are displayed for convenience but not processed by ImGui at the moment + */ + public static native boolean MenuItem(String label, String shortcut, boolean selected); /* + return ImGui::MenuItem(label, shortcut, selected); + */ + + /** + * Return true when activated. shortcuts are displayed for convenience but not processed by ImGui at the moment + */ + public static native boolean MenuItem(String label, String shortcut, boolean selected, boolean enabled); /* + return ImGui::MenuItem(label, shortcut, selected, enabled); + */ + + /** + * Return true when activated + toggle (*p_selected) if p_selected != NULL + */ + public static boolean MenuItem(String label, String shortcut, ImBool p_selected) { + return nMenuItem(label, shortcut, p_selected.data, true); } - public static void EndMainMenuBar() { - Native.EndMainMenuBar(); + /** + * Return true when activated + toggle (*p_selected) if p_selected != NULL + */ + public static boolean MenuItem(String label, String shortcut, ImBool p_selected, boolean enabled) { + return nMenuItem(label, shortcut, p_selected.data, enabled); } - public static boolean BeginMenuBar() { - return Native.BeginMenuBar(); - } - - public static void EndMenuBar() { - Native.EndMenuBar(); - } - - public static boolean BeginMenu(String label) { - return Native.BeginMenu(label); - } - - public static boolean BeginMenu(String label, boolean enabled) { - return Native.BeginMenu(label, enabled); - } - - public static void EndMenu() { - Native.EndMenu(); - } - - public static boolean MenuItem(String label) { - return Native.MenuItem(label); - } - - public static boolean MenuItem(String label, String shortcut, boolean selected, boolean enabled) { - return Native.MenuItem(label, shortcut, selected, enabled); - } - - public static boolean MenuItem(String label, String shortcut, ImGuiBoolean p_selected) { - return Native.MenuItem(label, shortcut, p_selected.data); - } - - public static boolean MenuItem(String label, String shortcut, ImGuiBoolean p_selected, boolean enabled) { - return Native.MenuItem(label, shortcut, p_selected.data, enabled); - } + /** + * Return true when activated + toggle (*p_selected) if p_selected != NULL + */ + private static native boolean nMenuItem(String label, String shortcut, boolean[] p_selected, boolean enabled); /* + return ImGui::MenuItem(label, shortcut, &p_selected[0], enabled); + */ // Tooltips + // - Tooltip are windows following the mouse which do not take focus away. - public static void BeginTooltip() { - Native.BeginTooltip(); - } + /** + * Begin/append a tooltip window. to create full-featured tooltip (with any kind of items). + */ + public static native void BeginTooltip(); /* + ImGui::BeginTooltip(); + */ - public static void EndTooltip() { - Native.EndTooltip(); - } + public static native void EndTooltip(); /* + ImGui::EndTooltip(); + */ - public static void SetTooltip(String text) { - Native.SetTooltip(text); - } + /** + * Set a text-only tooltip, typically use with ImGui::IsItemHovered(). override any previous call to SetTooltip(). + */ + public static native void SetTooltip(String text); /* + ImGui::SetTooltip(text); + */ // Popups, Modals // The properties of popups windows are: @@ -1244,333 +3519,1054 @@ public class ImGui { // - Unless modal, they can be closed by clicking anywhere outside them, or by pressing ESCAPE. // - Their visibility state (~bool) is held internally by imgui instead of being held by the programmer as we are used to with regular Begin() calls. // User can manipulate the visibility state by calling OpenPopup(). - // (*) One can use IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup) to bypass it and detect hovering even when normally blocked by a popup. + // (*) You can use IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup) to bypass it and detect hovering even when normally blocked by a popup. // Those three properties are connected. The library needs to hold their visibility state because it can close popups at any time. - public static void OpenPopup(String str_id) { - Native.OpenPopup(str_id); + /** + * Call to mark popup as open (don't call every frame!). + * Popups are closed when user click outside, or if CloseCurrentPopup() is called within a BeginPopup()/EndPopup() block. + * By default, Selectable()/MenuItem() are calling CloseCurrentPopup(). + * Popup identifiers are relative to the current ID-stack (so OpenPopup and BeginPopup needs to be at the same level). + */ + public static native void OpenPopup(String str_id); /* + ImGui::OpenPopup(str_id); + */ + + /** + * Return true if the popup is open, and you can start outputting to it. only call EndPopup() if BeginPopup() returns true! + */ + public static native boolean BeginPopup(String str_id); /* + return ImGui::BeginPopup(str_id); + */ + + /** + * Return true if the popup is open, and you can start outputting to it. only call EndPopup() if BeginPopup() returns true! + */ + public static native boolean BeginPopup(String str_id, int flags); /* + return ImGui::BeginPopup(str_id, flags); + */ + + /** + * helper to open and begin popup when clicked on last item. if you can pass a NULL str_id only if the previous item had an id. + * If you want to use that on a non-interactive item such as Text() you need to pass in an explicit ID here. read comments in .cpp! + */ + public static native boolean BeginPopupContextItem(); /* + return ImGui::BeginPopupContextItem(); + */ + + /** + * helper to open and begin popup when clicked on last item. if you can pass a NULL str_id only if the previous item had an id. + * If you want to use that on a non-interactive item such as Text() you need to pass in an explicit ID here. read comments in .cpp! + */ + public static native boolean BeginPopupContextItem(String str_id); /* + return ImGui::BeginPopupContextItem(str_id); + */ + + /** + * helper to open and begin popup when clicked on last item. if you can pass a NULL str_id only if the previous item had an id. + * If you want to use that on a non-interactive item such as Text() you need to pass in an explicit ID here. read comments in .cpp! + */ + public static native boolean BeginPopupContextItem(String str_id, int mouse_button); /* + return ImGui::BeginPopupContextItem(str_id, mouse_button); + */ + + /** + * Helper to open and begin popup when clicked on current window. + */ + public static native boolean BeginPopupContextWindow(); /* + return ImGui::BeginPopupContextWindow(); + */ + + /** + * Helper to open and begin popup when clicked on current window. + */ + public static native boolean BeginPopupContextWindow(String str_id); /* + return ImGui::BeginPopupContextWindow(str_id); + */ + + /** + * Helper to open and begin popup when clicked on current window. + */ + public static native boolean BeginPopupContextWindow(String str_id, int mouse_button); /* + return ImGui::BeginPopupContextWindow(str_id, mouse_button); + */ + + /** + * Helper to open and begin popup when clicked on current window. + */ + public static native boolean BeginPopupContextWindow(String str_id, int mouse_button, boolean also_over_items); /* + return ImGui::BeginPopupContextWindow(str_id, mouse_button, also_over_items); + */ + + /** + * Helper to open and begin popup when clicked in void (where there are no imgui windows). + */ + public static native boolean BeginPopupContextVoid(); /* + return ImGui::BeginPopupContextVoid(); + */ + + /** + * Helper to open and begin popup when clicked in void (where there are no imgui windows). + */ + public static native boolean BeginPopupContextVoid(String str_id); /* + return ImGui::BeginPopupContextVoid(str_id); + */ + + /** + * Helper to open and begin popup when clicked in void (where there are no imgui windows). + */ + public static native boolean BeginPopupContextVoid(String str_id, int mouse_button); /* + return ImGui::BeginPopupContextVoid(str_id, mouse_button); + */ + + /** + * Modal dialog (regular window with title bar, block interactions behind the modal window, can't close the modal window by clicking outside) + */ + public static native boolean BeginPopupModal(String name); /* + return ImGui::BeginPopupModal(name); + */ + + /** + * Modal dialog (regular window with title bar, block interactions behind the modal window, can't close the modal window by clicking outside) + */ + public static boolean BeginPopupModal(String name, ImBool p_open) { + return nBeginPopupModal(name, p_open.data, 0); } - public static boolean BeginPopup(String str_id) { - return Native.BeginPopup(str_id); + /** + * Modal dialog (regular window with title bar, block interactions behind the modal window, can't close the modal window by clicking outside) + */ + public static boolean BeginPopupModal(String name, ImBool p_open, int flags) { + return nBeginPopupModal(name, p_open.data, flags); } - public static boolean BeginPopup(String str_id, ImGuiWindowFlags flags) { - return Native.BeginPopup(str_id, flags.getValue()); - } + private static native boolean nBeginPopupModal(String name, boolean[] p_open, int flags); /* + return ImGui::BeginPopupModal(name, &p_open[0], flags); + */ - public static boolean BeginPopupContextItem() { - return Native.BeginPopupContextItem(); - } + /** + * only call EndPopup() if BeginPopupXXX() returns true! + */ + public static native void EndPopup(); /* + ImGui::EndPopup(); + */ - public static boolean BeginPopupContextItem(String str_id, int mouse_button) { - return Native.BeginPopupContextItem(str_id, mouse_button); - } + /** + * Helper to open popup when clicked on last item (note: actually triggers on the mouse _released_ event to be consistent with popup behaviors). + * return true when just opened. + */ + public static native boolean OpenPopupOnItemClick(); /* + return ImGui::OpenPopupOnItemClick(); + */ - public static boolean BeginPopupContextWindow() { - return Native.BeginPopupContextWindow(); - } + /** + * Helper to open popup when clicked on last item (note: actually triggers on the mouse _released_ event to be consistent with popup behaviors). + * return true when just opened. + */ + public static native boolean OpenPopupOnItemClick(String str_id); /* + return ImGui::OpenPopupOnItemClick(str_id); + */ - public static boolean BeginPopupContextWindow(String str_id, int mouse_button, boolean also_over_items) { - return Native.BeginPopupContextWindow(str_id, mouse_button, also_over_items); - } + /** + * Helper to open popup when clicked on last item (note: actually triggers on the mouse _released_ event to be consistent with popup behaviors). + * return true when just opened. + */ + public static native boolean OpenPopupOnItemClick(String str_id, int mouse_button); /* + return ImGui::OpenPopupOnItemClick(str_id, mouse_button); + */ - public static boolean BeginPopupContextVoid() { - return Native.BeginPopupContextVoid(); - } + /** + * Return true if the popup is open at the current begin-ed level of the popup stack. + */ + public static native boolean IsPopupOpen(String str_id); /* + return ImGui::IsPopupOpen(str_id); + */ - public static boolean BeginPopupContextVoid(String str_id, int mouse_button) { - return Native.BeginPopupContextVoid(str_id, mouse_button); - } - - public static boolean BeginPopupModal(String name) { - return Native.BeginPopupModal(name); - } - - public static boolean BeginPopupModal(String name, ImGuiBoolean p_open, ImGuiWindowFlags flags) { - return Native.BeginPopupModal(name, p_open.data, flags.getValue()); - } - - public static void EndPopup() { - Native.EndPopup(); - } - - public static boolean OpenPopupOnItemClick() { - return Native.OpenPopupOnItemClick(); - } - - public static boolean OpenPopupOnItemClick(String str_id, int mouse_button) { - return Native.OpenPopupOnItemClick(str_id, mouse_button); - } - - public static boolean IsPopupOpen(String str_id) { - return Native.IsPopupOpen(str_id); - } - - public static void CloseCurrentPopup() { - Native.CloseCurrentPopup(); - } + /** + * Close the popup we have begin-ed into. clicking on a MenuItem or Selectable automatically close the current popup. + */ + public static native void CloseCurrentPopup(); /* + ImGui::CloseCurrentPopup(); + */ // Columns // - You can also use SameLine(pos_x) to mimic simplified columns. // - The columns API is work-in-progress and rather lacking (columns are arguably the worst part of dear imgui at the moment!) + // - By end of the 2019 we will expose a new 'Table' api which will replace columns. - public static void Columns() { - Native.Columns(); - } + public static native void Columns(); /* + ImGui::Columns(); + */ - public static void Columns(int count) { - Native.Columns(count); - } + public static native void Columns(int count); /* + ImGui::Columns(count); + */ - public static void Columns(int count, String id) { - Native.Columns(count, id); - } + public static native void Columns(int count, String id); /* + ImGui::Columns(count, id); + */ - public static void Columns(int count, String id, boolean border) { - Native.Columns(count, id, border); - } + public static native void Columns(int count, String id, boolean border); /* + ImGui::Columns(count, id, border); + */ - public static void NextColumn() { - Native.NextColumn(); - } + /** + * Next column, defaults to current row or next row if the current row is finished + */ + public static native void NextColumn(); /* + ImGui::NextColumn(); + */ - public static int GetColumnIndex() { - return Native.GetColumnIndex(); - } + /** + * Get current column index + */ + public static native int GetColumnIndex(); /* + return ImGui::GetColumnIndex(); + */ - public static float GetColumnWidth() { - return Native.GetColumnWidth(); - } + /** + * Get column width (in pixels). pass -1 to use current column + */ + public static native float GetColumnWidth(); /* + return ImGui::GetColumnWidth(); + */ - public static float GetColumnWidth(int column_index) { - return Native.GetColumnWidth(column_index); - } + /** + * Get column width (in pixels). pass -1 to use current column + */ + public static native float GetColumnWidth(int column_index); /* + return ImGui::GetColumnWidth(column_index); + */ - public static void SetColumnWidth(int column_index, float width) { - Native.SetColumnWidth(column_index, width); - } + /** + * Set column width (in pixels). pass -1 to use current column + */ + public static native void SetColumnWidth(int column_index, float width); /* + ImGui::SetColumnWidth(column_index, width); + */ - public static float GetColumnOffset() { - return Native.GetColumnOffset(); - } + /** + * Get position of column line (in pixels, from the left side of the contents region). pass -1 to use current column, otherwise 0..GetColumnsCount() inclusive. column 0 is typically 0.0f + */ + public static native float GetColumnOffset(); /* + return ImGui::GetColumnOffset(); + */ - public static float GetColumnOffset(int column_index) { - return Native.GetColumnOffset(column_index); - } + /** + * Get position of column line (in pixels, from the left side of the contents region). pass -1 to use current column, otherwise 0..GetColumnsCount() inclusive. column 0 is typically 0.0f + */ + public static native float GetColumnOffset(int column_index); /* + return ImGui::GetColumnOffset(column_index); + */ - public static void SetColumnOffset(int column_index, float offset_x) { - Native.SetColumnOffset(column_index, offset_x); - } + /** + * Set position of column line (in pixels, from the left side of the contents region). pass -1 to use current column + */ + public static native void SetColumnOffset(int column_index, float offset_x); /* + ImGui::SetColumnOffset(column_index, offset_x); + */ - public static int GetColumnsCount() { - return Native.GetColumnsCount(); - } + public static native int GetColumnsCount(); /* + return ImGui::GetColumnsCount(); + */ // Tab Bars, Tabs + + /** + * Create and append into a TabBar + */ + public static native boolean BeginTabBar(String str_id); /* + return ImGui::BeginTabBar(str_id); + */ + + /** + * Create and append into a TabBar + */ + public static native boolean BeginTabBar(String str_id, int flags); /* + return ImGui::BeginTabBar(str_id, flags); + */ + + /** + * Only call EndTabBar() if BeginTabBar() returns true! + */ + public static native void EndTabBar(); /* + ImGui::EndTabBar(); + */ + + /** + * Create a Tab. Returns true if the Tab is selected. + */ + public static native boolean BeginTabItem(String label); /* + return ImGui::BeginTabItem(label); + */ + + /** + * Create a Tab. Returns true if the Tab is selected. + */ + public static boolean BeginTabItem(String label, ImBool p_open) { + return nBeginTabItem(label, p_open.data, 0); + } + + /** + * Create a Tab. Returns true if the Tab is selected. + */ + public static boolean BeginTabItem(String label, ImBool p_open, int flags) { + return nBeginTabItem(label, p_open.data, flags); + } + + private static native boolean nBeginTabItem(String label, boolean[] p_open, int flags); /* + return ImGui::BeginTabItem(label, &p_open[0], flags); + */ + + /** + * Only call EndTabItem() if BeginTabItem() returns true! + */ + public static native void EndTabItem(); /* + ImGui::EndTabItem(); + */ + + /** + * Notify TabBar or Docking system of a closed tab/window ahead (useful to reduce visual flicker on reorderable tab bars). + * For tab-bar: call after BeginTabBar() and before Tab submissions. Otherwise call with a window name. + */ + public static native void SetTabItemClosed(String tab_or_docked_window_label); /* + ImGui::SetTabItemClosed(tab_or_docked_window_label); + */ + + // Logging/Capture + // - All text output from the interface can be captured into tty/file/clipboard. By default, tree nodes are automatically opened during logging. + + /** + * Start logging to tty (stdout) + */ + public static native void LogToTTY(); /* + ImGui::LogToTTY(); + */ + + /** + * Start logging to tty (stdout) + */ + public static native void LogToTTY(int auto_open_depth); /* + ImGui::LogToTTY(auto_open_depth); + */ + + /** + * Start logging to file + */ + public static native void LogToFile(); /* + ImGui::LogToFile(); + */ + + /** + * Start logging to file + */ + public static native void LogToFile(int auto_open_depth); /* + ImGui::LogToFile(auto_open_depth); + */ + + /** + * Start logging to file + */ + public static native void LogToFile(int auto_open_depth, String filename); /* + ImGui::LogToFile(auto_open_depth, filename); + */ + + /** + * Start logging to OS clipboard + */ + public static native void LogToClipboard(); /* + ImGui::LogToClipboard(); + */ + + + /** + * Start logging to OS clipboard + */ + public static native void LogToClipboard(int auto_open_depth); /* + ImGui::LogToClipboard(auto_open_depth); + */ + + /** + * Stop logging (close file, etc.) + */ + public static native void LogFinish(); /* + ImGui::LogFinish(); + */ + + /** + * Helper to display buttons for logging to tty/file/clipboard + */ + public static native void LogButtons(); /* + ImGui::LogButtons(); + */ + + /** + * Pass text data straight to log (without being displayed) + */ + public static native void LogText(String text); /* + ImGui::LogText(text); + */ + + // Drag and Drop // [BETA API] API may evolve! - public static boolean BeginTabBar(String str_id) { - return Native.BeginTabBar(str_id); + /** + * Call when the current item is active. If this return true, you can call SetDragDropPayload() + EndDragDropSource() + */ + public static native boolean BeginDragDropSource(); /* + return ImGui::BeginDragDropSource(); + */ + + /** + * Call when the current item is active. If this return true, you can call SetDragDropPayload() + EndDragDropSource() + */ + public static native boolean BeginDragDropSource(int flags); /* + return ImGui::BeginDragDropSource(flags); + */ + + /** + * Type is a user defined string of maximum 32 characters. Strings starting with '_' are reserved for dear imgui internal types. + * Data is copied and held by imgui. + */ + public static native boolean SetDragDropPayload(String type, byte[] data, int sz); /* + return ImGui::SetDragDropPayload(type, &data[0], sz); + */ + + /** + * Type is a user defined string of maximum 32 characters. Strings starting with '_' are reserved for dear imgui internal types. + * Data is copied and held by imgui. + */ + public static native boolean SetDragDropPayload(String type, byte[] data, int sz, int cond); /* + return ImGui::SetDragDropPayload(type, &data[0], sz, cond); + */ + + /** + * Only call EndDragDropSource() if BeginDragDropSource() returns true! + */ + public static native void EndDragDropSource(); /* + ImGui::EndDragDropSource(); + */ + + /** + * Call after submitting an item that may receive a payload. If this returns true, you can call AcceptDragDropPayload() + EndDragDropTarget() + */ + public static native boolean BeginDragDropTarget(); /* + return ImGui::BeginDragDropTarget(); + */ + + /** + * Accept contents of a given type. If ImGuiDragDropFlags_AcceptBeforeDelivery is set you can peek into the payload before the mouse button is released. + */ + public static byte[] AcceptDragDropPayload(String type) { + return nAcceptDragDropPayload(type, 0); } - public static boolean BeginTabBar(String str_id, ImGuiTabBarFlags flags) { - return Native.BeginTabBar(str_id, flags.getValue()); + /** + * Accept contents of a given type. If ImGuiDragDropFlags_AcceptBeforeDelivery is set you can peek into the payload before the mouse button is released. + */ + public static byte[] AcceptDragDropPayload(String type, int flags) { + return nAcceptDragDropPayload(type, flags); } - public static void EndTabBar() { - Native.EndTabBar(); - } + private static native byte[] nAcceptDragDropPayload(String type, int flags); /* + if (const ImGuiPayload* payload = ImGui::AcceptDragDropPayload(type, flags)) { + jbyteArray array = env->NewByteArray(payload->DataSize); + env->SetByteArrayRegion(array, 0, payload->DataSize, (jbyte*)payload->Data); + return array; + } + return NULL; + */ - public static boolean BeginTabItem(String label) { - return Native.BeginTabItem(label); - } + /** + * Only call EndDragDropTarget() if BeginDragDropTarget() returns true! + */ + public static native void EndDragDropTarget(); /* + ImGui::EndDragDropTarget(); + */ - public static boolean BeginTabItem(String label, ImGuiBoolean p_open, ImGuiTabItemFlags flags) { - return Native.BeginTabItem(label, p_open.data, flags.getValue()); - } + /** + * Peek directly into the current payload from anywhere. May return NULL. use ImGuiPayload::IsDataType() to test for the payload type. + * TODO implement ImGuiPayload class + */ + public static native byte[] GetDragDropPayload(); /* + if (const ImGuiPayload* payload = ImGui::GetDragDropPayload()) { + jbyteArray array = env->NewByteArray(payload->DataSize); + env->SetByteArrayRegion(array, 0, payload->DataSize, (jbyte*)payload->Data); + return array; + } + return NULL; + */ - public static void EndTabItem() { - Native.EndTabItem(); - } + // Clipping - public static void SetTabItemClosed(String tab_or_docked_window_label) { - Native.SetTabItemClosed(tab_or_docked_window_label); - } + public static native void PushClipRect(float clip_rect_min_x, float clip_rect_min_y, float clip_rect_max_x, float clip_rect_max_y, boolean intersect_with_current_clip_rect); /* + ImGui::PushClipRect(ImVec2(clip_rect_min_x, clip_rect_min_y), ImVec2(clip_rect_max_x, clip_rect_max_y), intersect_with_current_clip_rect); + */ - // Docking - // [BETA API] Enable with io.ConfigFlags |= ImGuiConfigFlags_DockingEnable. - // Note: you DO NOT need to call DockSpace() to use most Docking facilities! - // To dock windows: if io.ConfigDockingWithShift == false: drag window from their title bar. - // To dock windows: if io.ConfigDockingWithShift == true: hold SHIFT anywhere while moving windows. - // Use DockSpace() to create an explicit dock node _within_ an existing window. See Docking demo for details. - - // TODO: Available after docking comes from BETA -// public static void DockSpace(int id) { -// Native.DockSpace(id); -// } - - // TODO: Available after docking comes from BETA -// public static void DockSpace(int id, float sizeX, float sizeY) { -// Native.DockSpace(id, sizeX, sizeY); -// } - - // TODO: Available after docking comes from BETA -// public static void DockSpace(int id, float sizeX, float sizeY, ImGuiDockNodeFlags flags) { -// Native.DockSpace(id, sizeX, sizeY, flags.getValue()); -// } + public static native void PopClipRect(); /* + ImGui::PopClipRect(); + */ // Focus, Activation // - Prefer using "SetItemDefaultFocus()" over "if (IsWindowAppearing()) SetScrollHereY()" when applicable to signify "this is the default item" - public static void SetItemDefaultFocus() { - Native.SetItemDefaultFocus(); - } + /** + * Make last item the default focused item of a window. + */ + public static native void SetItemDefaultFocus(); /* + ImGui::SetItemDefaultFocus(); + */ - public static void SetKeyboardFocusHere() { - Native.SetKeyboardFocusHere(); - } + /** + * Focus keyboard on the next widget. Use positive 'offset' to access sub components of a multiple component widget. Use -1 to access previous widget. + */ + public static native void SetKeyboardFocusHere(); /* + ImGui::SetKeyboardFocusHere(); + */ - public static void SetKeyboardFocusHere(int offset) { - Native.SetKeyboardFocusHere(offset); - } + /** + * Focus keyboard on the next widget. Use positive 'offset' to access sub components of a multiple component widget. Use -1 to access previous widget. + */ + public static native void SetKeyboardFocusHere(int offset); /* + ImGui::SetKeyboardFocusHere(offset); + */ // Item/Widgets Utilities // - Most of the functions are referring to the last/previous item we submitted. // - See Demo Window under "Widgets->Querying Status" for an interactive visualization of most of those functions. - public static boolean IsItemHovered() { - return Native.IsItemHovered(); - } + /** + * Is the last item hovered? (and usable, aka not blocked by a popup, etc.). See ImGuiHoveredFlags for more options. + */ + public static native boolean IsItemHovered(); /* + return ImGui::IsItemHovered(); + */ - public static boolean IsItemHovered(ImGuiHoveredFlags flags) { - return Native.IsItemHovered(flags.getValue()); - } + /** + * Is the last item hovered? (and usable, aka not blocked by a popup, etc.). See ImGuiHoveredFlags for more options. + */ + public static native boolean IsItemHovered(int flags); /* + return ImGui::IsItemHovered(flags); + */ - public static boolean IsItemActive() { - return Native.IsItemActive(); - } + /** + * Is the last item active? (e.g. button being held, text field being edited. + * This will continuously return true while holding mouse button on an item. + * Items that don't interact will always return false) + */ + public static native boolean IsItemActive(); /* + return ImGui::IsItemActive(); + */ - public static boolean IsItemFocused() { - return Native.IsItemFocused(); - } + /** + * Is the last item focused for keyboard/gamepad navigation? + */ + public static native boolean IsItemFocused(); /* + return ImGui::IsItemFocused(); + */ - public static boolean IsItemClicked() { - return Native.IsItemClicked(); - } + /** + * Is the last item clicked? (e.g. button/node just clicked on) == IsMouseClicked(mouse_button) && IsItemHovered() + */ + public static native boolean IsItemClicked(); /* + return ImGui::IsItemClicked(); + */ - public static boolean IsItemClicked(int mouse_button) { - return Native.IsItemClicked(mouse_button); - } + /** + * Is the last item clicked? (e.g. button/node just clicked on) == IsMouseClicked(mouse_button) && IsItemHovered() + */ + public static native boolean IsItemClicked(int mouse_button); /* + return ImGui::IsItemClicked(mouse_button); + */ - public static boolean IsItemVisible() { - return Native.IsItemVisible(); - } + /** + * Is the last item visible? (items may be out of sight because of clipping/scrolling) + */ + public static native boolean IsItemVisible(); /* + return ImGui::IsItemVisible(); + */ - public static boolean IsItemEdited() { - return Native.IsItemEdited(); - } + /** + * Did the last item modify its underlying value this frame? or was pressed? This is generally the same as the "bool" return value of many widgets. + */ + public static native boolean IsItemEdited(); /* + return ImGui::IsItemEdited(); + */ - public static boolean IsItemActivated() { - return Native.IsItemActivated(); - } + /** + * Was the last item just made active (item was previously inactive). + */ + public static native boolean IsItemActivated(); /* + return ImGui::IsItemActivated(); + */ - public static boolean IsItemDeactivated() { - return Native.IsItemDeactivated(); - } + /** + * Was the last item just made inactive (item was previously active). Useful for Undo/Redo patterns with widgets that requires continuous editing. + */ + public static native boolean IsItemDeactivated(); /* + return ImGui::IsItemDeactivated(); + */ - public static boolean IsItemDeactivatedAfterEdit() { - return Native.IsItemDeactivatedAfterEdit(); - } + /** + * Was the last item just made inactive and made a value change when it was active? (e.g. Slider/Drag moved). + * Useful for Undo/Redo patterns with widgets that requires continuous editing. + * Note that you may get false positives (some widgets such as Combo()/ListBox()/Selectable() will return true even when clicking an already selected item). + */ + public static native boolean IsItemDeactivatedAfterEdit(); /* + return ImGui::IsItemDeactivatedAfterEdit(); + */ - public static boolean IsAnyItemHovered() { - return Native.IsAnyItemHovered(); - } + /** + * Was the last item open state toggled? set by TreeNode(). + */ + public static native boolean IsItemToggledOpen(); /* + return ImGui::IsItemToggledOpen(); + */ - public static boolean IsAnyItemActive() { - return Native.IsAnyItemActive(); - } + /** + * Is any item hovered? + */ + public static native boolean IsAnyItemHovered(); /* + return ImGui::IsAnyItemHovered(); + */ - public static boolean IsAnyItemFocused() { - return Native.IsAnyItemFocused(); - } + /** + * Is any item active? + */ + public static native boolean IsAnyItemActive(); /* + return ImGui::IsAnyItemActive(); + */ - public static ImVec2 GetItemRectMin() { - Native.GetItemRectMin(imVec2); - return imVec2; - } + /** + * Is any item focused? + */ + public static native boolean IsAnyItemFocused(); /* + return ImGui::IsAnyItemFocused(); + */ - public static ImVec2 GetItemRectMax() { - Native.GetItemRectMax(imVec2); - return imVec2; - } + /** + * Get upper-left bounding rectangle of the last item (screen space) + */ + public static native void GetItemRectMin(ImVec2 dstImVec2); /* + Jni::ImVec2Cpy(env, ImGui::GetItemRectMin(), dstImVec2); + */ - public static ImVec2 GetItemRectSize() { - Native.GetItemRectSize(imVec2); - return imVec2; - } + /** + * Get lower-right bounding rectangle of the last item (screen space) + */ + public static native void GetItemRectMax(ImVec2 dstImVec2); /* + Jni::ImVec2Cpy(env, ImGui::GetItemRectMax(), dstImVec2); + */ - public static void SetItemAllowOverlap() { - Native.SetItemAllowOverlap(); - } + /** + * Get size of last item + */ + public static native void GetItemRectSize(ImVec2 dstImVec2); /* + Jni::ImVec2Cpy(env, ImGui::GetItemRectSize(), dstImVec2); + */ + + /** + * Allow last item to be overlapped by a subsequent item. sometimes useful with invisible buttons, selectables, etc. to catch unused area. + */ + public static native void SetItemAllowOverlap(); /* + ImGui::SetItemAllowOverlap(); + */ // Miscellaneous Utilities - public static boolean BeginChildFrame(int id, float width, float height) { - return Native.BeginChildFrame(id, width, height); + /** + * Test if rectangle (of given size, starting from cursor position) is visible / not clipped. + */ + public static native boolean IsRectVisible(float width, float height); /* + return ImGui::IsRectVisible(ImVec2(width, height)); + */ + + /** + * Test if rectangle (in screen space) is visible / not clipped. to perform coarse clipping on user's side. + */ + public static native boolean IsRectVisible(float min_x, float min_y, float max_x, float max_y); /* + return ImGui::IsRectVisible(ImVec2(min_x, min_y), ImVec2(max_x, max_y)); + */ + + /** + * Get global imgui time. incremented by io.DeltaTime every frame. + */ + public static native double GetTime(); /* + return ImGui::GetTime(); + */ + + /** + * Get global imgui frame count. incremented by 1 every frame. + */ + public static native int GetFrameCount(); /* + return ImGui::GetFrameCount(); + */ + + /** + * This draw list will be the first rendering one. Useful to quickly draw shapes/text behind dear imgui contents. + */ + public static ImDrawList GetBackgroundDrawList() { + return IM_DRAW_LIST_BACKGROUND; } - public static boolean BeginChildFrame(int id, float width, float height, ImGuiWindowFlags flags) { - return Native.BeginChildFrame(id, width, height, flags.getValue()); + /** + * This draw list will be the last rendered one. Useful to quickly draw shapes/text over dear imgui contents. + */ + public static ImDrawList GetForegroundDrawList() { + return IM_DRAW_LIST_FOREGROUND; } - public static void EndChildFrame() { - Native.EndChildFrame(); - } + // TODO GetDrawListSharedData + + /** + * Get a string corresponding to the enum value (for display, saving, etc.). + */ + public static native String GetStyleColorName(int imGuiCol); /* + return env->NewStringUTF(ImGui::GetStyleColorName(imGuiCol)); + */ + + // TODO SetStateStorage, GetStateStorage + + public static native void CalcTextSize(ImVec2 dstImVec2, String text); /* + ImVec2 src = ImGui::CalcTextSize(text); + Jni::ImVec2Cpy(env, src, dstImVec2); + */ + + public static native void CalcTextSize(ImVec2 dstImVec2, String text, String text_end); /* + ImVec2 src = ImGui::CalcTextSize(text, text_end); + Jni::ImVec2Cpy(env, src, dstImVec2); + */ + + public static native void CalcTextSize(ImVec2 dstImVec2, String text, String text_end, boolean hide_text_after_double_has); /* + ImVec2 src = ImGui::CalcTextSize(text, text_end, hide_text_after_double_has); + Jni::ImVec2Cpy(env, src, dstImVec2); + */ + + public static native void CalcTextSize(ImVec2 dstImVec2, String text, String text_end, boolean hide_text_after_double_has, float wrap_width); /* + ImVec2 src = ImGui::CalcTextSize(text, text_end, hide_text_after_double_has, wrap_width); + Jni::ImVec2Cpy(env, src, dstImVec2); + */ + + /** + * Calculate coarse clipping for large list of evenly sized items. Prefer using the ImGuiListClipper higher-level helper if you can. + */ + public static native void CalcListClipping(int item_count, float items_height, int[] out_items_display_start, int[] out_items_display_end); /* + ImGui::CalcListClipping(item_count, items_height, &out_items_display_start[0], &out_items_display_end[0]); + */ + + /** + * Helper to create a child window / scrolling region that looks like a normal widget frame + */ + public static native boolean BeginChildFrame(int id, float width, float height); /* + return ImGui::BeginChildFrame(id, ImVec2(width, height)); + */ + + /** + * Helper to create a child window / scrolling region that looks like a normal widget frame + */ + public static native boolean BeginChildFrame(int id, float width, float height, int flags); /* + return ImGui::BeginChildFrame(id, ImVec2(width, height), flags); + */ + + /** + * Always call EndChildFrame() regardless of BeginChildFrame() return values (which indicates a collapsed/clipped window) + */ + public static native void EndChildFrame(); /* + ImGui::EndChildFrame(); + */ + + // Color Utilities + + public static native void ColorConvertU32ToFloat4(long in, ImVec4 dstImVec4); /* + Jni::ImVec4Cpy(env, ImGui::ColorConvertU32ToFloat4(in), dstImVec4); + */ + + public static native long ColorConvertFloat4ToU32(float r, float g, float b, float a); /* + return ImGui::ColorConvertFloat4ToU32(ImVec4(r, g, b, a)); + */ + + public static native void ColorConvertRGBtoHSV(float[] rgb, float[] hsv); /* + ImGui::ColorConvertRGBtoHSV(rgb[0], rgb[1], rgb[2], hsv[0], hsv[1], hsv[2]); + */ + + public static native void ColorConvertHSVtoRGB(float[] hsv, float[] rgb); /* + ImGui::ColorConvertHSVtoRGB(hsv[0], hsv[1], hsv[2], rgb[0], rgb[1], rgb[2]); + */ // Inputs Utilities - public static boolean IsMouseDown(int button) { - return Native.IsMouseDown(button); - } + /** + * Map ImGuiKey_* values into user's key index. == io.KeyMap[key] + */ + public static native int GetKeyIndex(int imgui_key); /* + return ImGui::GetKeyIndex(imgui_key); + */ - public static boolean IsMouseClicked(int button) { - return Native.IsMouseClicked(button); - } + /** + * Is key being held. == io.KeysDown[user_key_index]. note that imgui doesn't know the semantic of each entry of io.KeysDown[]. + * Use your own indices/enums according to how your backend/engine stored them into io.KeysDown[]! + */ + public static native boolean IsKeyDown(int user_key_index); /* + return ImGui::IsKeyDown(user_key_index); + */ - public static boolean IsMouseClicked(int button, boolean repeat) { - return Native.IsMouseClicked(button, repeat); - } + /** + * Was key pressed (went from !Down to Down). if repeat=true, uses io.KeyRepeatDelay / KeyRepeatRate + */ + public static native boolean IsKeyPressed(int user_key_index); /* + return ImGui::IsKeyPressed(user_key_index); + */ - public static boolean IsMouseReleased(int button) { - return Native.IsMouseReleased(button); - } + /** + * Was key pressed (went from !Down to Down). if repeat=true, uses io.KeyRepeatDelay / KeyRepeatRate + */ + public static native boolean IsKeyPressed(int user_key_index, boolean repeat); /* + return ImGui::IsKeyPressed(user_key_index, repeat); + */ - public static boolean IsMouseDragging() { - return Native.IsMouseDragging(); - } + /** + * Was key released (went from Down to !Down).. + */ + public static native boolean IsKeyReleased(int user_key_index); /* + return ImGui::IsKeyReleased(user_key_index); + */ - public static boolean IsMouseDragging(int button) { - return Native.IsMouseDragging(button); - } + /** + * uUses provided repeat rate/delay. return a count, most often 0 or 1 but might be >1 if RepeatRate is small enough that DeltaTime > RepeatRate + */ + public static native boolean GetKeyPressedAmount(int key_index, float repeat_delay, float rate); /* + return ImGui::GetKeyPressedAmount(key_index, repeat_delay, rate); + */ - public static boolean IsMouseDragging(int button, float lock_threshold) { - return Native.IsMouseDragging(button, lock_threshold); - } + /** + * Is mouse button held (0=left, 1=right, 2=middle) + */ + public static native boolean IsMouseDown(int button); /* + return ImGui::IsMouseDown(button); + */ - public static boolean IsMouseHoveringRect(float minX, float minY, float maxX, float maxY) { - return Native.IsMouseHoveringRect(minX, minY, maxX, maxY); - } + /** + * Is any mouse button held + */ + public static native boolean IsAnyMouseDown(); /* + return ImGui::IsAnyMouseDown(); + */ - public static boolean IsMouseHoveringRect(float minX, float minY, float maxX, float maxY, boolean clip) { - return Native.IsMouseHoveringRect(minX, minY, maxX, maxY, clip); - } + /** + * Did mouse button clicked (went from !Down to Down) (0=left, 1=right, 2=middle) + */ + public static native boolean IsMouseClicked(int button); /* + return ImGui::IsMouseClicked(button); + */ - public static ImGuiMouseCursor GetMouseCursor() { - return ImGuiMouseCursor.valueOf(Native.GetMouseCursor()); - } + public static native boolean IsMouseClicked(int button, boolean repeat); /* + return ImGui::IsMouseClicked(button, repeat); + */ - public static void SetMouseCursor(ImGuiMouseCursor type) { - Native.SetMouseCursor(type.getValue()); - } + /** + * Did mouse button double-clicked. a double-click returns false in IsMouseClicked(). uses io.MouseDoubleClickTime. + */ + public static native boolean IsMouseDoubleClicked(int button); /* + return ImGui::IsMouseDoubleClicked(button); + */ + + /** + * Did mouse button released (went from Down to !Down) + */ + public static native boolean IsMouseReleased(int button); /* + return ImGui::IsMouseReleased(button); + */ + + /** + * Is mouse dragging. if lock_threshold < -1.0f uses io.MouseDraggingThreshold + */ + public static native boolean IsMouseDragging(); /* + return ImGui::IsMouseDragging(); + */ + + /** + * Is mouse dragging. if lock_threshold < -1.0f uses io.MouseDraggingThreshold + */ + public static native boolean IsMouseDragging(int button); /* + return ImGui::IsMouseDragging(button); + */ + + /** + * Is mouse dragging. if lock_threshold < -1.0f uses io.MouseDraggingThreshold + */ + public static native boolean IsMouseDragging(int button, float lock_threshold); /* + return ImGui::IsMouseDragging(button, lock_threshold); + */ + + /** + * Is mouse hovering given bounding rect (in screen space). clipped by current clipping settings, but disregarding of other consideration of focus/window ordering/popup-block. + */ + public static native boolean IsMouseHoveringRect(float minX, float minY, float maxX, float maxY); /* + return ImGui::IsMouseHoveringRect(ImVec2(minX, minY), ImVec2(maxX, maxY)); + */ + + /** + * Is mouse hovering given bounding rect (in screen space). clipped by current clipping settings, but disregarding of other consideration of focus/window ordering/popup-block. + */ + public static native boolean IsMouseHoveringRect(float minX, float minY, float maxX, float maxY, boolean clip); /* + return ImGui::IsMouseHoveringRect(ImVec2(minX, minY), ImVec2(maxX, maxY), clip); + */ + + /** + * By convention we use (-FLT_MAX,-FLT_MAX) to denote that there is no mouse + */ + public static native boolean IsMousePosValid(); /* + return ImGui::IsMousePosValid(); + */ + + /** + * By convention we use (-FLT_MAX,-FLT_MAX) to denote that there is no mouse + */ + public static native boolean IsMousePosValid(float mouse_pos_x, float mouse_pos_y); /* + ImVec2 pos = ImVec2(mouse_pos_x, mouse_pos_y); + return ImGui::IsMousePosValid(&pos); + */ + + /** + * Shortcut to ImGui::GetIO().MousePos provided by user, to be consistent with other calls + */ + public static native void GetMousePos(ImVec2 dstImVec2); /* + Jni::ImVec2Cpy(env, ImGui::GetMousePos(), dstImVec2); + */ + + /** + * Retrieve backup of mouse position at the time of opening popup we have BeginPopup() into + */ + public static native void GetMousePosOnOpeningCurrentPopup(ImVec2 dstImVec2); /* + Jni::ImVec2Cpy(env, ImGui::GetMousePosOnOpeningCurrentPopup(), dstImVec2); + */ + + /** + * Return the delta from the initial clicking position while the mouse button is pressed or was just released. + * This is locked and return 0.0f until the mouse moves past a distance threshold at least once. If lock_threshold < -1.0f uses io.MouseDraggingThreshold. + */ + public static native void GetMouseDragDelta(ImVec2 dstImVec2); /* + Jni::ImVec2Cpy(env, ImGui::GetMouseDragDelta(), dstImVec2); + */ + + /** + * Return the delta from the initial clicking position while the mouse button is pressed or was just released. + * This is locked and return 0.0f until the mouse moves past a distance threshold at least once. If lock_threshold < -1.0f uses io.MouseDraggingThreshold. + */ + public static native void GetMouseDragDelta(ImVec2 dstImVec2, int button); /* + Jni::ImVec2Cpy(env, ImGui::GetMouseDragDelta(button), dstImVec2); + */ + + /** + * Return the delta from the initial clicking position while the mouse button is pressed or was just released. + * This is locked and return 0.0f until the mouse moves past a distance threshold at least once. If lock_threshold < -1.0f uses io.MouseDraggingThreshold. + */ + public static native void GetMouseDragDelta(ImVec2 dstImVec2, int button, float lock_threshold); /* + Jni::ImVec2Cpy(env, ImGui::GetMouseDragDelta(button, lock_threshold), dstImVec2); + */ + + public static native void ResetMouseDragDelta(); /* + ImGui::ResetMouseDragDelta(); + */ + + public static native void ResetMouseDragDelta(int button); /* + ImGui::ResetMouseDragDelta(button); + */ + + /** + * Get desired cursor type, reset in ImGui::NewFrame(), this is updated during the frame. valid before Render(). + * If you use software rendering by setting io.MouseDrawCursor ImGui will render those for you + */ + public static native int GetMouseCursor(); /* + return ImGui::GetMouseCursor(); + */ + + /** + * Set desired cursor type + */ + public static native void SetMouseCursor(int type); /* + ImGui::SetMouseCursor(type); + */ + + /** + * Attention: misleading name! manually override io.WantCaptureKeyboard flag next frame (said flag is entirely left for your application to handle). + * e.g. force capture keyboard when your widget is being hovered. + * This is equivalent to setting "io.WantCaptureKeyboard = want_capture_keyboard_value"; after the next NewFrame() call. + */ + public static native void CaptureKeyboardFromApp(); /* + ImGui::CaptureKeyboardFromApp(); + */ + + /** + * Attention: misleading name! manually override io.WantCaptureKeyboard flag next frame (said flag is entirely left for your application to handle). + * e.g. force capture keyboard when your widget is being hovered. + * This is equivalent to setting "io.WantCaptureKeyboard = want_capture_keyboard_value"; after the next NewFrame() call. + */ + public static native void CaptureKeyboardFromApp(boolean want_capture_keyboard_value); /* + ImGui::CaptureKeyboardFromApp(want_capture_keyboard_value); + */ + + /** + * Attention: misleading name! manually override io.WantCaptureMouse flag next frame (said flag is entirely left for your application to handle). + * This is equivalent to setting "io.WantCaptureMouse = want_capture_mouse_value;" after the next NewFrame() call. + */ + public static native void CaptureMouseFromApp(); /* + ImGui::CaptureMouseFromApp(); + */ + + /** + * Attention: misleading name! manually override io.WantCaptureMouse flag next frame (said flag is entirely left for your application to handle). + * This is equivalent to setting "io.WantCaptureMouse = want_capture_mouse_value;" after the next NewFrame() call. + */ + public static native void CaptureMouseFromApp(boolean want_capture_mouse_value); /* + ImGui::CaptureMouseFromApp(want_capture_mouse_value); + */ + + // Settings/.Ini Utilities + // - The disk functions are automatically called if io.IniFilename != NULL (default is "imgui.ini"). + // - Set io.IniFilename to NULL to load/save manually. Read io.WantSaveIniSettings description about handling .ini saving manually. + + /** + * Call after CreateContext() and before the first call to NewFrame(). NewFrame() automatically calls LoadIniSettingsFromDisk(io.IniFilename). + */ + public static native void LoadIniSettingsFromDisk(String ini_filename); /* + ImGui::LoadIniSettingsFromDisk(ini_filename); + */ + + /** + * Call after CreateContext() and before the first call to NewFrame() to provide .ini data from your own data source. + */ + public static native void LoadIniSettingsFromMemory(String ini_data); /* + ImGui::LoadIniSettingsFromMemory(ini_data); + */ + + /** + * Call after CreateContext() and before the first call to NewFrame() to provide .ini data from your own data source. + */ + public static native void LoadIniSettingsFromMemory(String ini_data, int ini_size); /* + ImGui::LoadIniSettingsFromMemory(ini_data, ini_size); + */ + + /** + * This is automatically called (if io.IniFilename is not empty) a few seconds after any modification that should be reflected in the .ini file (and also by DestroyContext). + */ + public static native void SaveIniSettingsToDisk(String ini_filename); /* + ImGui::SaveIniSettingsToDisk(ini_filename); + */ + + /** + * Return a zero-terminated string with the .ini data which you can save by your own mean. + * Call when io.WantSaveIniSettings is set, then save data by your own mean and clear io.WantSaveIniSettings. + */ + public static native String SaveIniSettingsToMemory(); /* + return env->NewStringUTF(ImGui::SaveIniSettingsToMemory()); + */ + + /** + * Return a zero-terminated string with the .ini data which you can save by your own mean. + * Call when io.WantSaveIniSettings is set, then save data by your own mean and clear io.WantSaveIniSettings. + */ + public static native String SaveIniSettingsToMemory(long out_ini_size); /* + return env->NewStringUTF(ImGui::SaveIniSettingsToMemory((size_t*)&out_ini_size)); + */ } diff --git a/imgui-binding/src/main/java/imgui/ImGuiBoolean.java b/imgui-binding/src/main/java/imgui/ImGuiBoolean.java deleted file mode 100644 index 72d405a..0000000 --- a/imgui-binding/src/main/java/imgui/ImGuiBoolean.java +++ /dev/null @@ -1,27 +0,0 @@ -package imgui; - -public class ImGuiBoolean { - public static ImGuiBoolean TMP = new ImGuiBoolean(); - - boolean[] data = new boolean[]{false}; - - public ImGuiBoolean() { - } - - public ImGuiBoolean(boolean value) { - setValue(value); - } - - public boolean getValue() { - return this.data[0]; - } - - public void setValue(boolean value) { - this.data[0] = value; - } - - @Override - public String toString() { - return String.valueOf(getValue()); - } -} diff --git a/imgui-binding/src/main/java/imgui/ImGuiIO.java b/imgui-binding/src/main/java/imgui/ImGuiIO.java index c0de172..7def913 100644 --- a/imgui-binding/src/main/java/imgui/ImGuiIO.java +++ b/imgui-binding/src/main/java/imgui/ImGuiIO.java @@ -1,35 +1,608 @@ package imgui; -import imgui.enums.ImGuiConfigFlags; +/** + * Communicate most settings and inputs/outputs to Dear ImGui using this structure. + * Access via ImGui::GetIO(). Read 'Programmer guide' section in .cpp file for general usage. + */ +public final class ImGuiIO { + ImGuiIO() { + } -public class ImGuiIO { + /*JNI + #include + #include "jni_common.h" + */ + + //------------------------------------------------------------------ + // Configuration (fill once) + //------------------------------------------------------------------ + + // ConfigFlags + // See ImGuiConfigFlags enum. Set by user/application. Gamepad/keyboard navigation options, etc. + // + public native int getConfigFlags(); /* + return ImGui::GetIO().ConfigFlags; + */ + + public native void setConfigFlags(int configFlags); /* + ImGui::GetIO().ConfigFlags = configFlags; + */ + + // BackendFlags + // See ImGuiBackendFlags enum. Set by back-end to communicate features supported by the back-end. + // + public native int getBackendFlags(); /* + return ImGui::GetIO().BackendFlags; + */ + + public native void setBackendFlags(int backendFlags); /* + ImGui::GetIO().BackendFlags = backendFlags; + */ + + + // IniSavingRate + // Minimum time between saving positions/sizes to .ini file, in seconds. + // + public native float getIniSavingRate(); /* + return ImGui::GetIO().IniSavingRate; + */ + + public native void setIniSavingRate(float iniSavingRate); /* + ImGui::GetIO().IniSavingRate = iniSavingRate; + */ + + // IniFilename + // Path to .ini file. Set NULL to disable automatic .ini loading/saving, if e.g. you want to manually load/save from memory. + // + public native String getIniFilename(); /* + return env->NewStringUTF(ImGui::GetIO().IniFilename); + */ + + public native void setIniFilename(String iniFilename); /*MANUAL + ImGui::GetIO().IniFilename = obj_iniFilename == NULL ? NULL : (char*)env->GetStringUTFChars(obj_iniFilename, JNI_FALSE); + */ + + // LogFilename + // Path to .log file (default parameter to ImGui::LogToFile when no file is specified). + // + public native String getLogFilename(); /* + return env->NewStringUTF(ImGui::GetIO().LogFilename); + */ + + public native void setLogFilename(String logFilename); /*MANUAL + ImGui::GetIO().LogFilename = obj_logFilename == NULL ? NULL : (char*)env->GetStringUTFChars(obj_logFilename, JNI_FALSE); + */ + + // MouseDoubleClickTime + // Time for a double-click, in seconds. + // + public native float getMouseDoubleClickTime(); /* + return ImGui::GetIO().MouseDoubleClickTime; + */ + + public native void setMouseDoubleClickTime(float mouseDoubleClickTime); /* + ImGui::GetIO().MouseDoubleClickTime = mouseDoubleClickTime; + */ + + // MouseDoubleClickTime + // Distance threshold to stay in to validate a double-click, in pixels. + // + public native float getMouseDoubleClickMaxDist(); /* + return ImGui::GetIO().MouseDoubleClickTime; + */ + + public native void setMouseDoubleClickMaxDist(float mouseDoubleClickMaxDist); /* + ImGui::GetIO().MouseDoubleClickMaxDist = mouseDoubleClickMaxDist; + */ + + // MouseDoubleClickTime + // Distance threshold before considering we are dragging. + public native float getMouseDragThreshold(); /* + return ImGui::GetIO().MouseDoubleClickTime; + */ + + public native void setMouseDragThreshold(float mouseDragThreshold); /* + ImGui::GetIO().MouseDragThreshold = mouseDragThreshold; + */ + + // KeyMap + // Map of indices into the KeysDown[512] entries array which represent your "native" keyboard state. + // + public native void getKeyMap(int[] buff); /* + for(int i = 0; i < ImGuiKey_COUNT; i++) + buff[i] = ImGui::GetIO().KeyMap[i]; + */ + + public native int getKeyMap(int idx); /* + return ImGui::GetIO().KeyMap[idx]; + */ + + public native void setKeyMap(int idx, int code); /* + ImGui::GetIO().KeyMap[idx] = code; + */ + + public native void setKeyMap(int[] keyMap); /* + for (int i = 0; i < ImGuiKey_COUNT; i++) + ImGui::GetIO().KeyMap[i] = keyMap[i]; + */ + + // KeyRepeatDelay + // When holding a key/button, time before it starts repeating, in seconds (for buttons in Repeat mode, etc.). + // + public native float getKeyRepeatDelay(); /* + return ImGui::GetIO().KeyRepeatDelay; + */ + + public native void setKeyRepeatDelay(float keyRepeatDelay); /* + ImGui::GetIO().KeyRepeatDelay = keyRepeatDelay; + */ + + // KeyRepeatRate + // When holding a key/button, rate at which it repeats, in seconds. + // + public native float getKeyRepeatRate(); /* + return ImGui::GetIO().KeyRepeatRate; + */ + + public native void setKeyRepeatRate(float keyRepeatRate); /* + ImGui::GetIO().KeyRepeatRate = keyRepeatRate; + */ + + // TODO fonts configuration + + // BINDING NOTICE: this is a stub to pass important for ImGui info + public native void SetFontsTexID(int id); /* + ImGui::GetIO().Fonts->TexID = (ImTextureID)id; + */ + + // Miscellaneous options + + // MouseDrawCursor + // Request ImGui to draw a mouse cursor for you (if you are on a platform without a mouse cursor). + // Cannot be easily renamed to 'io.ConfigXXX' because this is frequently used by back-end implementations. + // + public native boolean getMouseDrawCursor(); /* + return ImGui::GetIO().MouseDrawCursor; + */ + + public native void setMouseDrawCursor(boolean mouseDrawCursor); /* + ImGui::GetIO().MouseDrawCursor = mouseDrawCursor; + */ + + // ConfigMacOSXBehaviors + // OS X style: Text editing cursor movement using Alt instead of Ctrl, Shortcuts using Cmd/Super instead of Ctrl, + // Line/Text Start and End using Cmd+Arrows instead of Home/End, Double click selects by word instead of selecting whole text, + // Multi-selection in lists uses Cmd/Super instead of Ctrl (was called io.OptMacOSXBehaviors prior to 1.63) + // + public native boolean getConfigMacOSXBehaviors(); /* + return ImGui::GetIO().ConfigMacOSXBehaviors; + */ + + public native void setConfigMacOSXBehaviors(boolean configMacOSXBehaviors); /* + ImGui::GetIO().ConfigMacOSXBehaviors = configMacOSXBehaviors; + */ + + // ConfigInputTextCursorBlink + // Set to false to disable blinking cursor, for users who consider it distracting. (was called: io.OptCursorBlink prior to 1.63) + // + public native boolean getConfigInputTextCursorBlink(); /* + return ImGui::GetIO().ConfigInputTextCursorBlink; + */ + + public native void setConfigInputTextCursorBlink(boolean configInputTextCursorBlink); /* + ImGui::GetIO().ConfigInputTextCursorBlink = configInputTextCursorBlink; + */ + + // ConfigWindowsResizeFromEdges + // Enable resizing of windows from their edges and from the lower-left corner. + // This requires (io.BackendFlags & ImGuiBackendFlags_HasMouseCursors) because it needs mouse cursor feedback. + // (This used to be a per-window ImGuiWindowFlags_ResizeFromAnySide flag) + // + public native boolean getConfigWindowsResizeFromEdges(); /* + return ImGui::GetIO().ConfigWindowsResizeFromEdges; + */ + + public native void setConfigWindowsResizeFromEdges(boolean configWindowsResizeFromEdges); /* + ImGui::GetIO().ConfigWindowsResizeFromEdges = configWindowsResizeFromEdges; + */ + + // ConfigWindowsMoveFromTitleBarOnly + // [BETA] Set to true to only allow moving windows when clicked+dragged from the title bar. Windows without a title bar are not affected. + // + public native boolean getConfigWindowsMoveFromTitleBarOnly(); /* + return ImGui::GetIO().ConfigWindowsMoveFromTitleBarOnly; + */ + + public native void setConfigWindowsMoveFromTitleBarOnly(boolean configWindowsMoveFromTitleBarOnly); /* + ImGui::GetIO().ConfigWindowsMoveFromTitleBarOnly = configWindowsMoveFromTitleBarOnly; + */ + + // ConfigWindowsMemoryCompactTimer + // [BETA] Compact window memory usage when unused. Set to -1.0f to disable. + // + public native float getConfigWindowsMemoryCompactTimer(); /* + return ImGui::GetIO().ConfigWindowsMemoryCompactTimer; + */ + + public native void setConfigWindowsMemoryCompactTimer(float configWindowsMemoryCompactTimer); /* + ImGui::GetIO().ConfigWindowsMemoryCompactTimer = configWindowsMemoryCompactTimer; + */ + + //------------------------------------------------------------------ + // Platform Functions + //------------------------------------------------------------------ + + // BackendPlatformName + // Optional: Platform/Renderer back-end name (informational only! will be displayed in About Window) + User data for back-end/wrappers to store their own stuff. + // + public native String getBackendPlatformName(); /* + return env -> NewStringUTF(ImGui::GetIO().BackendPlatformName); + */ + + public native void setBackendPlatformName(String backendPlatformName); /*MANUAL + ImGui::GetIO().BackendPlatformName = obj_backendPlatformName == NULL ? NULL : (char*)env->GetStringUTFChars(obj_backendPlatformName, JNI_FALSE); + */ + + // BackendRendererName + // + public native String getBackendRendererName(); /* + return env -> NewStringUTF(ImGui::GetIO().BackendRendererName); + */ + + public native void setBackendRendererName(String backendRendererName); /*MANUAL + ImGui::GetIO().BackendRendererName = obj_backendRendererName == NULL ? NULL : (char*)env->GetStringUTFChars(obj_backendRendererName, JNI_FALSE); + */ + + // TODO clipboard callback + + //------------------------------------------------------------------ + // Input - Fill before calling NewFrame() + //------------------------------------------------------------------ + + // DisplaySize + // Main display size, in pixels. + // BINDING NOTICE: This should be a "Config" part, but since those values may be different for every frame I don't see how it is possible to set them only once. + // + public native void getDisplaySize(ImVec2 dstImVec2); /* + Jni::ImVec2Cpy(env, &ImGui::GetIO().DisplaySize, dstImVec2); + */ + + public native void setDisplaySize(float x, float y); /* + ImGui::GetIO().DisplaySize.x = x; + ImGui::GetIO().DisplaySize.y = y; + */ + + // DisplayFramebufferScale + // For retina display or other situations where window coordinates are different from framebuffer coordinates. This generally ends up in ImDrawData::FramebufferScale. + // BINDING NOTICE: This should be a "Config" part, but since those values may be different for every frame I don't see how it is possible to set them only once. + // + public native void getDisplayFramebufferScale(ImVec2 dstImVec2); /* + Jni::ImVec2Cpy(env, &ImGui::GetIO().DisplayFramebufferScale, dstImVec2); + */ + + public native void setDisplayFramebufferScale(float x, float y); /* + ImGui::GetIO().DisplayFramebufferScale.x = x; + ImGui::GetIO().DisplayFramebufferScale.y = y; + */ + + // DeltaTime + // Time elapsed since last frame, in seconds. + // BINDING NOTICE: Same as for DisplaySize. This should be modified every frame. + // + public native float getDeltaTime(); /* + return ImGui::GetIO().DeltaTime; + */ + + public native void setDeltaTime(float deltaTime); /* + ImGui::GetIO().DeltaTime = deltaTime; + */ + + // MousePos + // Mouse position, in pixels. Set to ImVec2(-FLT_MAX,-FLT_MAX) if mouse is unavailable (on another screen, etc.) + // + public native void getMousePos(ImVec2 dstImVec2); /* + Jni::ImVec2Cpy(env, &ImGui::GetIO().MousePos, dstImVec2); + */ + + public native void setMousePos(float x, float y); /* + ImGui::GetIO().MousePos.x = x; + ImGui::GetIO().MousePos.y = y; + */ + + // MouseDown + // Mouse buttons: 0=left, 1=right, 2=middle + extras. ImGui itself mostly only uses left button (BeginPopupContext** are using right button). + // Others buttons allows us to track if the mouse is being used by your application + available to user as a convenience via IsMouse** API. + // + public native void getMouseDown(boolean[] buff); /* + for (int i = 0; i < 5; i++) + buff[i] = ImGui::GetIO().MouseDown[i]; + */ + + public native boolean getMouseDown(int idx); /* + return ImGui::GetIO().MouseDown[idx]; + */ + + public native void setMouseDown(int idx, boolean down); /* + ImGui::GetIO().MouseDown[idx] = down; + */ + + public native void setMouseDown(boolean[] mouseDown); /* + for (int i = 0; i < 5; i++) + ImGui::GetIO().MouseDown[i] = mouseDown[i]; + */ + + // MouseWheel + // Mouse wheel Vertical: 1 unit scrolls about 5 lines text. + // + public native float getMouseWheel(); /* + return ImGui::GetIO().MouseWheel; + */ + + public native void setMouseWheel(float mouseDeltaY); /* + ImGui::GetIO().MouseWheel = mouseDeltaY; + */ + + // MouseWheelH + // Mouse wheel Horizontal. Most users don't have a mouse with an horizontal wheel, may not be filled by all back-ends. + // + public native float getMouseWheelH(); /* + return ImGui::GetIO().MouseWheelH; + */ + + public native void setMouseWheelH(float mouseDeltaX); /* + ImGui::GetIO().MouseWheelH = mouseDeltaX; + */ + + // KeyCtrl + // Keyboard modifier pressed: Control + // + public native boolean getKeyCtrl(); /* + return ImGui::GetIO().KeyCtrl; + */ + + public native void setKeyCtrl(boolean value); /* + ImGui::GetIO().KeyCtrl = value; + */ + + // KeyShift + // Keyboard modifier pressed: Shift + // + public native boolean getKeyShift(); /* + return ImGui::GetIO().KeyShift; + */ + + public native void setKeyShift(boolean value); /* + ImGui::GetIO().KeyShift = value; + */ + + // KeyAlt + // Keyboard modifier pressed: Alt + // + public native boolean getKeyAlt(); /* + return ImGui::GetIO().KeyAlt; + */ + + public native void setKeyAlt(boolean value); /* + ImGui::GetIO().KeyAlt = value; + */ + + // KeySuper + // Keyboard modifier pressed: Cmd/Super/Windows + // + public native boolean getKeySuper(); /* + return ImGui::GetIO().KeySuper; + */ + + public native void setKeySuper(boolean value); /* + ImGui::GetIO().KeySuper = value; + */ + + // KeysDown + // Keyboard keys that are pressed (ideally left in the "native" order your engine has access to keyboard keys, so you can use your own defines/enums for keys). + // + public native void getKeysDown(boolean[] buff); /* + for (int i = 0; i < 512; i++) + buff[i] = ImGui::GetIO().KeysDown[i]; + */ + + public native boolean getKeysDown(int idx); /* + return ImGui::GetIO().KeysDown[idx]; + */ + + public native void setKeysDown(int idx, boolean pressed); /* + ImGui::GetIO().KeysDown[idx] = pressed; + */ + + public native void setKeysDown(boolean[] keysDown); /* + for (int i = 0; i < 512; i++) + ImGui::GetIO().KeysDown[i] = keysDown[i]; + */ //------------------------------------------------------------------ // Output - Retrieve after calling NewFrame() //------------------------------------------------------------------ - public boolean WantCaptureMouse; // When io.WantCaptureMouse is true, imgui will use the mouse inputs, do not dispatch them to your main game/application (in both cases, always pass on mouse inputs to imgui). (e.g. unclicked mouse is hovering over an imgui window, widget is active, mouse was clicked over an imgui window, etc.). - public boolean WantCaptureKeyboard; // When io.WantCaptureKeyboard is true, imgui will use the keyboard inputs, do not dispatch them to your main game/application (in both cases, always pass keyboard inputs to imgui). (e.g. InputText active, or an imgui window is focused and navigation is enabled, etc.). - public boolean WantTextInput; // Mobile/console: when io.WantTextInput is true, you may display an on-screen keyboard. This is set by ImGui when it wants textual keyboard input to happen (e.g. when a InputText widget is active). - public boolean WantSetMousePos; // MousePos has been altered, back-end should reposition mouse on next frame. Set only when ImGuiConfigFlags_NavEnableSetMousePos flag is enabled. - public boolean WantSaveIniSettings; // When manual .ini load/save is active (io.IniFilename == NULL), this will be set to notify your application that you can call SaveIniSettingsToMemory() and save yourself. IMPORTANT: You need to clear io.WantSaveIniSettings yourself. - public boolean NavActive; // Directional navigation is currently allowed (will handle ImGuiKey_NavXXX events) = a window is focused and it doesn't use the ImGuiWindowFlags_NoNavInputs flag. - public boolean NavVisible; // Directional navigation is visible and allowed (will handle ImGuiKey_NavXXX events). - public float Framerate; // Application framerate estimation, in frame per second. Solely for convenience. Rolling average estimation based on IO.DeltaTime over 120 frames - public int MetricsRenderVertices; // Vertices output during last call to Render() - public int MetricsRenderIndices; // Indices output during last call to Render() = number of triangles * 3 - public int MetricsRenderWindows; // Number of visible windows - public int MetricsActiveWindows; // Number of active windows - public int MetricsActiveAllocations; // Number of active allocations, updated by MemAlloc/MemFree based on current context. May be off if you have multiple imgui contexts. - public float MouseDeltaX; // Mouse delta. Note that this is zero if either current or previous position are invalid (-FLT_MAX,-FLT_MAX), so a disappearing/reappearing mouse won't have a huge delta. - public float MouseDeltaY; + // WantCaptureMouse + // When io.WantCaptureMouse is true, imgui will use the mouse inputs, do not dispatch them to your main game/application (in both cases, always pass on mouse inputs to imgui). + // (e.g. unclicked mouse is hovering over an imgui window, widget is active, mouse was clicked over an imgui window, etc.). + // + public native boolean getWantCaptureMouse(); /* + return ImGui::GetIO().WantCaptureMouse; + */ - public void SetConfigFlags(ImGuiConfigFlags flags) { - Native.SetConfigFlags(flags.getValue()); - } + public native void setWantCaptureMouse(boolean wantCaptureMouse); /* + ImGui::GetIO().WantCaptureMouse = wantCaptureMouse; + */ - // TODO: Available after docking comes from BETA -// public void SetDockingFlags(boolean ConfigDockingNoSplit, boolean ConfigDockingWithShift, boolean ConfigDockingAlwaysTabBar, boolean ConfigDockingTransparentPayload) { -// Native.SetDockingFlags(ConfigDockingNoSplit, ConfigDockingWithShift, ConfigDockingAlwaysTabBar, ConfigDockingTransparentPayload); -// } + // WantCaptureKeyboard + // When io.WantCaptureKeyboard is true, imgui will use the keyboard inputs, do not dispatch them to your main game/application (in both cases, always pass keyboard inputs to imgui). + // (e.g. InputText active, or an imgui window is focused and navigation is enabled, etc.). + // + public native boolean getWantCaptureKeyboard(); /* + return ImGui::GetIO().WantCaptureKeyboard; + */ + + public native void setWantCaptureKeyboard(boolean wantCaptureKeyboard); /* + ImGui::GetIO().WantCaptureKeyboard = wantCaptureKeyboard; + */ + + // WantTextInput + // Mobile/console: when io.WantTextInput is true, you may display an on-screen keyboard. + // This is set by ImGui when it wants textual keyboard input to happen (e.g. when a InputText widget is active). + // + public native boolean getWantTextInput(); /* + return ImGui::GetIO().WantTextInput; + */ + + public native void setWantTextInput(boolean wantTextInput); /* + ImGui::GetIO().WantTextInput = wantTextInput; + */ + + // WantSetMousePos + // MousePos has been altered, back-end should reposition mouse on next frame. Set only when ImGuiConfigFlags_NavEnableSetMousePos flag is enabled. + // + public native boolean getWantSetMousePos(); /* + return ImGui::GetIO().WantSetMousePos; + */ + + public native void setWantSetMousePos(boolean wantSetMousePos); /* + ImGui::GetIO().WantSetMousePos = wantSetMousePos; + */ + + // WantSaveIniSettings + // When manual .ini load/save is active (io.IniFilename == NULL), + // this will be set to notify your application that you can call SaveIniSettingsToMemory() and save yourself. + // IMPORTANT: You need to clear io.WantSaveIniSettings yourself. + // + public native boolean getWantSaveIniSettings(); /* + return ImGui::GetIO().WantSaveIniSettings; + */ + + public native void setWantSaveIniSettings(boolean wantSaveIniSettings); /* + ImGui::GetIO().WantSaveIniSettings = wantSaveIniSettings; + */ + + // NavActive + // Directional navigation is currently allowed (will handle ImGuiKey_NavXXX events) = a window is focused and it doesn't use the ImGuiWindowFlags_NoNavInputs flag. + // + public native boolean getNavActive(); /* + return ImGui::GetIO().NavActive; + */ + + public native void setNavActive(boolean navActive); /* + ImGui::GetIO().NavActive = navActive; + */ + + // NavVisible + // Directional navigation is visible and allowed (will handle ImGuiKey_NavXXX events). + // + public native boolean getNavVisible(); /* + return ImGui::GetIO().NavVisible; + */ + + public native void setNavVisible(boolean navVisible); /* + ImGui::GetIO().NavVisible = navVisible; + */ + + // Framerate + // Application framerate estimation, in frame per second. Solely for convenience. Rolling average estimation based on IO.DeltaTime over 120 frames + // + public native float getFramerate(); /* + return ImGui::GetIO().Framerate; + */ + + public native void setFramerate(float framerate); /* + ImGui::GetIO().Framerate = framerate; + */ + + // MetricsRenderVertices + // Vertices output during last call to Render() + // + public native int getMetricsRenderVertices(); /* + return ImGui::GetIO().MetricsRenderVertices; + */ + + public native void setMetricsRenderVertices(int metricsRenderVertices); /* + ImGui::GetIO().MetricsRenderVertices = metricsRenderVertices; + */ + + // MetricsRenderIndices + // Indices output during last call to Render() = number of triangles * 3 + // + public native int getMetricsRenderIndices(); /* + return ImGui::GetIO().MetricsRenderIndices; + */ + + public native void setMetricsRenderIndices(int metricsRenderIndices); /* + ImGui::GetIO().MetricsRenderIndices = metricsRenderIndices; + */ + + // MetricsRenderWindows + // Number of visible windows + // + public native int getMetricsRenderWindows(); /* + return ImGui::GetIO().MetricsRenderWindows; + */ + + public native void setMetricsRenderWindows(int metricsRenderWindows); /* + ImGui::GetIO().MetricsRenderWindows = metricsRenderWindows; + */ + + // MetricsActiveWindows + // Number of active windows + // + public native int getMetricsActiveWindows(); /* + return ImGui::GetIO().MetricsActiveWindows; + */ + + public native void setMetricsActiveWindows(int metricsActiveWindows); /* + ImGui::GetIO().MetricsActiveWindows = metricsActiveWindows; + */ + + // MetricsActiveAllocations + // Number of active allocations, updated by MemAlloc/MemFree based on current context. May be off if you have multiple imgui contexts. + // + public native int getMetricsActiveAllocations(); /* + return ImGui::GetIO().MetricsActiveAllocations; + */ + + public native void setMetricsActiveAllocations(int metricsActiveAllocations); /* + ImGui::GetIO().MetricsActiveAllocations = metricsActiveAllocations; + */ + + // MouseDelta + // Mouse delta. Note that this is zero if either current or previous position are invalid (-FLT_MAX,-FLT_MAX), so a disappearing/reappearing mouse won't have a huge delta. + // + public native void getMouseDelta(ImVec2 dstImVec2); /* + Jni::ImVec2Cpy(env, &ImGui::GetIO().MouseDelta, dstImVec2); + */ + + public native void setMouseDelta(float x, float y); /* + ImGui::GetIO().MouseDelta.x = x; + ImGui::GetIO().MouseDelta.y = y; + */ + + // Functions + + /** + * Queue new character input. + */ + public native void AddInputCharacter(int c); /* + if (c > 0 && c < 0x10000) + ImGui::GetIO().AddInputCharacter((unsigned short)c); + */; + + /** + * Queue new characters input from an UTF-8 string. + */ + public native void AddInputCharactersUTF8(String str); /* + ImGui::GetIO().AddInputCharactersUTF8(str); + */ + + /** + * Clear the text input buffer manually. + */ + public native void ClearInputCharacters(); /* + ImGui::GetIO().ClearInputCharacters(); + */ } diff --git a/imgui-binding/src/main/java/imgui/ImGuiInputTextData.java b/imgui-binding/src/main/java/imgui/ImGuiInputTextData.java index 97f7f21..f573b5a 100644 --- a/imgui-binding/src/main/java/imgui/ImGuiInputTextData.java +++ b/imgui-binding/src/main/java/imgui/ImGuiInputTextData.java @@ -1,6 +1,6 @@ package imgui; -public class ImGuiInputTextData { +public final class ImGuiInputTextData { public int size; public int maxChar = -1; public String allowedChar = ""; diff --git a/imgui-binding/src/main/java/imgui/ImGuiStyle.java b/imgui-binding/src/main/java/imgui/ImGuiStyle.java index f66466d..90acafb 100644 --- a/imgui-binding/src/main/java/imgui/ImGuiStyle.java +++ b/imgui-binding/src/main/java/imgui/ImGuiStyle.java @@ -1,7 +1,440 @@ package imgui; -public class ImGuiStyle { +/** + * You may modify the ImGui::GetStyle() main instance during initialization and before NewFrame(). + * During the frame, use ImGui::PushStyleVar(ImGuiStyleVar_XXXX)/PopStyleVar() to alter the main style values, + * and ImGui::PushStyleColor(ImGuiCol_XXX)/PopStyleColor() for colors. + * + * BINDING NOTICE: This is not a fully featured representation of ImGuiStyle struct from C++. + * Mostly it's a stub which communicates with default ImGuiStyle used by ImGuiIO. + * Still can be used to make your interface look different, since all of the fields from the original header file are represented here. + */ +public final class ImGuiStyle { + ImGuiStyle() { + } - public float ItemInnerSpacingX; - public float ItemInnerSpacingY; + /*JNI + #include + #include "jni_common.h" + */ + + // Alpha + // Global alpha applies to everything in Dear ImGui. + // + public native float getAlpha(); /* + return ImGui::GetStyle().Alpha; + */ + + public native void setAlpha(float alpha); /* + ImGui::GetStyle().Alpha = alpha; + */ + + // WindowPadding + // Padding within a window. + // + public native void getWindowPadding(ImVec2 dstImVec2); /* + Jni::ImVec2Cpy(env, &ImGui::GetStyle().WindowPadding, dstImVec2); + */ + + public native void setWindowPadding(float x, float y); /* + ImGui::GetStyle().WindowPadding.x = x; + ImGui::GetStyle().WindowPadding.y = y; + */ + + // WindowRounding + // Radius of window corners rounding. Set to 0.0f to have rectangular windows. + // + public native float getWindowRounding(); /* + return ImGui::GetStyle().WindowRounding; + */ + + public native void setWindowRounding(float windowRounding); /* + ImGui::GetStyle().WindowRounding = windowRounding; + */ + + // WindowBorderSize + // Thickness of border around windows. Generally set to 0.0f or 1.0f. (Other values are not well tested and more CPU/GPU costly). + // + public native float getWindowBorderSize(); /* + return ImGui::GetStyle().WindowBorderSize; + */ + + public native void setWindowBorderSize(float windowBorderSize); /* + ImGui::GetStyle().WindowBorderSize = windowBorderSize; + */ + + // WindowMinSize + // Minimum window size. This is a global setting. If you want to constraint individual windows, use SetNextWindowSizeConstraints(). + // + public native void getWindowMinSize(ImVec2 dstImVec2); /* + Jni::ImVec2Cpy(env, &ImGui::GetStyle().WindowMinSize, dstImVec2); + */ + + public native void setWindowMinSize(float x, float y); /* + ImGui::GetStyle().WindowMinSize.x = x; + ImGui::GetStyle().WindowMinSize.y = y; + */ + + // WindowTitleAlign + // Alignment for title bar text. Defaults to (0.0f,0.5f) for left-aligned,vertically centered. + // + public native void getWindowTitleAlign(ImVec2 dstImVec2); /* + Jni::ImVec2Cpy(env, &ImGui::GetStyle().WindowTitleAlign, dstImVec2); + */ + + public native void setWindowTitleAlign(float x, float y); /* + ImGui::GetStyle().WindowTitleAlign.x = x; + ImGui::GetStyle().WindowTitleAlign.y = y; + */ + + // WindowMenuButtonPosition + // Side of the collapsing/docking button in the title bar (None/Left/Right). Defaults to ImGuiDir_Left. + // + public native int getWindowMenuButtonPosition(); /* + return (int)ImGui::GetStyle().WindowMenuButtonPosition; + */ + + public native void setWindowMenuButtonPosition(int windowMenuButtonPosition); /* + ImGui::GetStyle().WindowMenuButtonPosition = windowMenuButtonPosition; + */ + + // ChildRounding + // Radius of child window corners rounding. Set to 0.0f to have rectangular windows. + // + public native float getChildRounding(); /* + return ImGui::GetStyle().ChildRounding; + */ + + public native void setChildRounding(float childRounding); /* + ImGui::GetStyle().ChildRounding = childRounding; + */ + + // ChildBorderSize + // Thickness of border around child windows. Generally set to 0.0f or 1.0f. (Other values are not well tested and more CPU/GPU costly). + // + public native float getChildBorderSize(); /* + return ImGui::GetStyle().ChildBorderSize; + */ + + public native void setChildBorderSize(float childBorderSize); /* + ImGui::GetStyle().ChildBorderSize = childBorderSize; + */ + + // PopupRounding + // Radius of popup window corners rounding. (Note that tooltip windows use WindowRounding) + // + public native float getPopupRounding(); /* + return ImGui::GetStyle().PopupRounding; + */ + + public native void setPopupRounding(float popupRounding); /* + ImGui::GetStyle().PopupRounding = popupRounding; + */ + + // PopupBorderSize + // Thickness of border around popup/tooltip windows. Generally set to 0.0f or 1.0f. (Other values are not well tested and more CPU/GPU costly). + // + public native float getPopupBorderSize(); /* + return ImGui::GetStyle().PopupBorderSize; + */ + + public native void setPopupBorderSize(float popupBorderSize); /* + ImGui::GetStyle().PopupBorderSize = popupBorderSize; + */ + + // FramePadding + // Padding within a framed rectangle (used by most widgets). + // + public native void getFramePadding(ImVec2 dstImVec2); /* + Jni::ImVec2Cpy(env, &ImGui::GetStyle().FramePadding, dstImVec2); + */ + + public native void setFramePadding(float x, float y); /* + ImGui::GetStyle().FramePadding.x = x; + ImGui::GetStyle().FramePadding.y = y; + */ + + // FrameRounding + // Radius of frame corners rounding. Set to 0.0f to have rectangular frame (used by most widgets). + // + public native float getFrameRounding(); /* + return ImGui::GetStyle().FrameRounding; + */ + + public native void setFrameRounding(float frameRounding); /* + ImGui::GetStyle().FrameRounding = frameRounding; + */ + + // FrameBorderSize + // Thickness of border around frames. Generally set to 0.0f or 1.0f. (Other values are not well tested and more CPU/GPU costly). + // + public native float getFrameBorderSize(); /* + return ImGui::GetStyle().FrameBorderSize; + */ + + public native void setFrameBorderSize(float frameBorderSize); /* + ImGui::GetStyle().FrameBorderSize = frameBorderSize; + */ + + // ItemSpacing + // Horizontal and vertical spacing between widgets/lines. + // + public native void getItemSpacing(ImVec2 dstImVec2); /* + Jni::ImVec2Cpy(env, &ImGui::GetStyle().ItemSpacing, dstImVec2); + */ + + public native void setItemSpacing(float x, float y); /* + ImGui::GetStyle().ItemSpacing.x = x; + ImGui::GetStyle().ItemSpacing.y = y; + */ + // ItemInnerSpacing + // Horizontal and vertical spacing between within elements of a composed widget (e.g. a slider and its label). + // + public native void getItemInnerSpacing(ImVec2 dstImVec2); /* + Jni::ImVec2Cpy(env, &ImGui::GetStyle().ItemInnerSpacing, dstImVec2); + */ + + public native void setItemInnerSpacing(float x, float y); /* + ImGui::GetStyle().ItemInnerSpacing.x = x; + ImGui::GetStyle().ItemInnerSpacing.y = y; + */ + // TouchExtraPadding + // Expand reactive bounding box for touch-based system where touch position is not accurate enough. + // Unfortunately we don't sort widgets so priority on overlap will always be given to the first widget. So don't grow this too much! + // + public native void getTouchExtraPadding(ImVec2 dstImVec2); /* + Jni::ImVec2Cpy(env, &ImGui::GetStyle().TouchExtraPadding, dstImVec2); + */ + + public native void setTouchExtraPadding(float x, float y); /* + ImGui::GetStyle().TouchExtraPadding.x = x; + ImGui::GetStyle().TouchExtraPadding.y = y; + */ + + // IndentSpacing + // Horizontal indentation when e.g. entering a tree node. Generally == (FontSize + FramePadding.x*2). + // + public native float getIndentSpacing(); /* + return ImGui::GetStyle().IndentSpacing; + */ + + public native void setIndentSpacing(float indentSpacing); /* + ImGui::GetStyle().IndentSpacing = indentSpacing; + */ + + // ColumnsMinSpacing + // Minimum horizontal spacing between two columns. Preferably > (FramePadding.x + 1). + // + public native float getColumnsMinSpacing(); /* + return ImGui::GetStyle().ColumnsMinSpacing; + */ + + public native void setColumnsMinSpacing(float columnsMinSpacing); /* + ImGui::GetStyle().ColumnsMinSpacing = columnsMinSpacing; + */ + + // ScrollbarSize + // Width of the vertical scrollbar, Height of the horizontal scrollbar. + // + public native float getScrollbarSize(); /* + return ImGui::GetStyle().ScrollbarSize; + */ + + public native void setScrollbarSize(float scrollbarSize); /* + ImGui::GetStyle().ScrollbarSize = scrollbarSize; + */ + + // ScrollbarRounding + // Radius of grab corners for scrollbar. + // + public native float getScrollbarRounding(); /* + return ImGui::GetStyle().ScrollbarRounding; + */ + + public native void setScrollbarRounding(float scrollbarRounding); /* + ImGui::GetStyle().ScrollbarRounding = scrollbarRounding; + */ + + // GrabMinSize + // Minimum width/height of a grab box for slider/scrollbar. + // + public native float getGrabMinSize(); /* + return ImGui::GetStyle().GrabMinSize; + */ + + public native void setGrabMinSize(float grabMinSize); /* + ImGui::GetStyle().GrabMinSize = grabMinSize; + */ + + // GrabRounding + // Radius of grabs corners rounding. Set to 0.0f to have rectangular slider grabs. + // + public native float getGrabRounding(); /* + return ImGui::GetStyle().GrabRounding; + */ + + public native void setGrabRounding(float grabRounding); /* + ImGui::GetStyle().GrabRounding = grabRounding; + */ + + // TabRounding + // Radius of upper corners of a tab. Set to 0.0f to have rectangular tabs. + // + public native float getTabRounding(); /* + return ImGui::GetStyle().TabRounding; + */ + + public native void setTabRounding(float tabRounding); /* + ImGui::GetStyle().TabRounding = tabRounding; + */ + + // TabBorderSize + // Thickness of border around tabs. + // + public native float getTabBorderSize(); /* + return ImGui::GetStyle().TabBorderSize; + */ + + public native void setTabBorderSize(float tabBorderSize); /* + ImGui::GetStyle().TabBorderSize = tabBorderSize; + */ + + // ColorButtonPosition + // Side of the color button in the ColorEdit4 widget (left/right). Defaults to ImGuiDir_Right. + // + public native int getColorButtonPosition(); /* + return ImGui::GetStyle().ColorButtonPosition; + */ + public native void setColorButtonPosition(int colorButtonPosition); /* + ImGui::GetStyle().ColorButtonPosition = colorButtonPosition; + */ + + // ButtonTextAlign + // Alignment of button text when button is larger than text. Defaults to (0.5f, 0.5f) (centered). + // + public native void getButtonTextAlign(ImVec2 dstImVec2); /* + Jni::ImVec2Cpy(env, &ImGui::GetStyle().ButtonTextAlign, dstImVec2); + */ + + public native void setButtonTextAlign(float x, float y); /* + ImGui::GetStyle().ButtonTextAlign.x = x; + ImGui::GetStyle().ButtonTextAlign.y = y; + */ + + // SelectableTextAlign + // Alignment of selectable text when selectable is larger than text. Defaults to (0.0f, 0.0f) (top-left aligned). + // + public native void getSelectableTextAlign(ImVec2 dstImVec2); /* + Jni::ImVec2Cpy(env, &ImGui::GetStyle().SelectableTextAlign, dstImVec2); + */ + + public native void setSelectableTextAlign(float x, float y); /* + ImGui::GetStyle().SelectableTextAlign.x = x; + ImGui::GetStyle().SelectableTextAlign.y = y; + */ + + // DisplayWindowPadding + // Window position are clamped to be visible within the display area by at least this amount. Only applies to regular windows. + // + public native void getDisplayWindowPadding(ImVec2 dstImVec2); /* + Jni::ImVec2Cpy(env, &ImGui::GetStyle().DisplayWindowPadding, dstImVec2); + */ + + public native void setDisplayWindowPadding(float x, float y); /* + ImGui::GetStyle().DisplayWindowPadding.x = x; + ImGui::GetStyle().DisplayWindowPadding.y = y; + */ + + // DisplaySafeAreaPadding + // If you cannot see the edges of your screen (e.g. on a TV) increase the safe area padding. + // Apply to popups/tooltips as well regular windows. NB: Prefer configuring your TV sets correctly! + // + public native void getDisplaySafeAreaPadding(ImVec2 dstImVec2); /* + Jni::ImVec2Cpy(env, &ImGui::GetStyle().DisplaySafeAreaPadding, dstImVec2); + */ + + public native void setDisplaySafeAreaPadding(float x, float y); /* + ImGui::GetStyle().DisplaySafeAreaPadding.x = x; + ImGui::GetStyle().DisplaySafeAreaPadding.y = y; + */ + + // MouseCursorScale + // Scale software rendered mouse cursor (when io.MouseDrawCursor is enabled). May be removed later. + // + public native float getMouseCursorScale(); /* + return ImGui::GetStyle().MouseCursorScale; + */ + + public native void setMouseCursorScale(float mouseCursorScale); /* + ImGui::GetStyle().MouseCursorScale = mouseCursorScale; + */ + + // AntiAliasedLines + // Enable anti-aliasing on lines/borders. Disable if you are really tight on CPU/GPU. + // + public native boolean getAntiAliasedLines(); /* + return ImGui::GetStyle().AntiAliasedLines; + */ + + public native void setAntiAliasedLines(boolean antiAliasedLines); /* + ImGui::GetStyle().AntiAliasedLines = antiAliasedLines; + */ + + // AntiAliasedFill + // Enable anti-aliasing on filled shapes (rounded rectangles, circles, etc.) + // + public native boolean getAntiAliasedFill(); /* + return ImGui::GetStyle().AntiAliasedFill; + */ + + public native void setAntiAliasedFill(boolean antiAliasedFill); /* + ImGui::GetStyle().AntiAliasedFill = antiAliasedFill; + */ + + // CurveTessellationTol + // Tessellation tolerance when using PathBezierCurveTo() without a specific number of segments. + // Decrease for highly tessellated curves (higher quality, more polygons), increase to reduce quality. + // + public native float getCurveTessellationTol(); /* + return ImGui::GetStyle().CurveTessellationTol; + */ + + public native void setCurveTessellationTol(float curveTessellationTol); /* + ImGui::GetStyle().CurveTessellationTol = curveTessellationTol; + */ + + // Colors + // BINDING NOTICE: buff is a 2d array with sizes: [ImGuiCol_COUNT][4] + // + public native void getColors(float[][] buff); /* + for (int i = 0; i < ImGuiCol_COUNT; i++) { + jfloatArray jColors = (jfloatArray)env->GetObjectArrayElement(buff, i); + jfloat* jBuffColor = env->GetFloatArrayElements(jColors, 0); + + jBuffColor[0] = ImGui::GetStyle().Colors[i].x; + jBuffColor[1] = ImGui::GetStyle().Colors[i].y; + jBuffColor[2] = ImGui::GetStyle().Colors[i].z; + jBuffColor[3] = ImGui::GetStyle().Colors[i].w; + + env->ReleaseFloatArrayElements(jColors, jBuffColor, 0); + env->DeleteLocalRef(jColors); + } + */ + + // BINDING NOTICE: colors is a 2d array with sizes: [ImGuiCol_COUNT][4] + // + public native void setColors(float[][] colors); /* + for (int i = 0; i < ImGuiCol_COUNT; i++) { + jfloatArray jColors = (jfloatArray)env->GetObjectArrayElement(colors, i); + jfloat* jColor = env->GetFloatArrayElements(jColors, 0); + + ImGui::GetStyle().Colors[i].x = jColor[0]; + ImGui::GetStyle().Colors[i].y = jColor[1]; + ImGui::GetStyle().Colors[i].z = jColor[2]; + ImGui::GetStyle().Colors[i].w = jColor[3]; + + env->ReleaseFloatArrayElements(jColors, jColor, 0); + env->DeleteLocalRef(jColors); + } + */ } diff --git a/imgui-binding/src/main/java/imgui/ImGuiInt.java b/imgui-binding/src/main/java/imgui/ImInt.java similarity index 71% rename from imgui-binding/src/main/java/imgui/ImGuiInt.java rename to imgui-binding/src/main/java/imgui/ImInt.java index 40e1e0f..b46af37 100644 --- a/imgui-binding/src/main/java/imgui/ImGuiInt.java +++ b/imgui-binding/src/main/java/imgui/ImInt.java @@ -1,14 +1,14 @@ package imgui; -public class ImGuiInt { - public static ImGuiInt TMP = new ImGuiInt(); +public final class ImInt { + public static ImInt TMP = new ImInt(); int[] data = new int[]{0}; - public ImGuiInt() { + public ImInt() { } - public ImGuiInt(int value) { + public ImInt(int value) { setValue(value); } diff --git a/imgui-binding/src/main/java/imgui/ImLong.java b/imgui-binding/src/main/java/imgui/ImLong.java new file mode 100644 index 0000000..6a306c7 --- /dev/null +++ b/imgui-binding/src/main/java/imgui/ImLong.java @@ -0,0 +1,25 @@ +package imgui; + +public class ImLong { + long[] data = new long[]{0}; + + public ImLong() { + } + + public ImLong(long value) { + setValue(value); + } + + public long getValue() { + return this.data[0]; + } + + public void setValue(long value) { + this.data[0] = value; + } + + @Override + public String toString() { + return String.valueOf(getValue()); + } +} diff --git a/imgui-binding/src/main/java/imgui/ImShort.java b/imgui-binding/src/main/java/imgui/ImShort.java new file mode 100644 index 0000000..679ff6a --- /dev/null +++ b/imgui-binding/src/main/java/imgui/ImShort.java @@ -0,0 +1,25 @@ +package imgui; + +public class ImShort { + short[] data = new short[]{0}; + + public ImShort() { + } + + public ImShort(short value) { + setValue(value); + } + + public short getValue() { + return this.data[0]; + } + + public void setValue(short value) { + this.data[0] = value; + } + + @Override + public String toString() { + return String.valueOf(getValue()); + } +} diff --git a/imgui-binding/src/main/java/imgui/ImGuiString.java b/imgui-binding/src/main/java/imgui/ImString.java similarity index 71% rename from imgui-binding/src/main/java/imgui/ImGuiString.java rename to imgui-binding/src/main/java/imgui/ImString.java index cc4332f..29b9d94 100644 --- a/imgui-binding/src/main/java/imgui/ImGuiString.java +++ b/imgui-binding/src/main/java/imgui/ImString.java @@ -1,25 +1,25 @@ package imgui; -public class ImGuiString { - public static ImGuiString TMP = new ImGuiString(); - final ImGuiInputTextData inputData = new ImGuiInputTextData(); +public final class ImString { + public static ImString TMP = new ImString(); + ImGuiInputTextData inputData = new ImGuiInputTextData(); byte[] data; private String text; - public ImGuiString() { + public ImString() { this(100); } - public ImGuiString(int size) { + public ImString(int size) { data = new byte[size]; } - public ImGuiString(String text) { + public ImString(String text) { this(text.length()); setValue(text); } - public ImGuiString(String text, int size) { + public ImString(String text, int size) { this(size); setValue(text); } diff --git a/imgui-binding/src/main/java/imgui/ImVec2.java b/imgui-binding/src/main/java/imgui/ImVec2.java index fb3b049..f5e99e9 100644 --- a/imgui-binding/src/main/java/imgui/ImVec2.java +++ b/imgui-binding/src/main/java/imgui/ImVec2.java @@ -1,7 +1,8 @@ package imgui; -public class ImVec2 { - public static ImVec2 TMP = new ImVec2(); +import java.util.Objects; + +public final class ImVec2 { public float x; public float y; @@ -12,4 +13,25 @@ public class ImVec2 { this.x = x; this.y = y; } + + @Override + public String toString() { + return "ImVec2{" + + "x=" + x + + ", y=" + y + + '}'; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + 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); + } } diff --git a/imgui-binding/src/main/java/imgui/ImVec4.java b/imgui-binding/src/main/java/imgui/ImVec4.java index ad156aa..69e21fd 100644 --- a/imgui-binding/src/main/java/imgui/ImVec4.java +++ b/imgui-binding/src/main/java/imgui/ImVec4.java @@ -1,8 +1,43 @@ package imgui; -public class ImVec4 extends ImVec2 { - public static ImVec4 TMP = new ImVec4(); +import java.util.Objects; +public final class ImVec4 { + public float x; + public float y; public float z; public float w; + + public ImVec4() { + } + + public ImVec4(float x, float y, float z, float w) { + this.x = x; + this.y = y; + this.z = z; + this.w = w; + } + + @Override + public String toString() { + return "ImVec4{" + + "x=" + x + + ", y=" + y + + ", z=" + z + + ", w=" + w + + '}'; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + 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); + } } diff --git a/imgui-binding/src/main/java/imgui/Native.java b/imgui-binding/src/main/java/imgui/Native.java deleted file mode 100644 index 2417348..0000000 --- a/imgui-binding/src/main/java/imgui/Native.java +++ /dev/null @@ -1,2162 +0,0 @@ -package imgui; - -import imgui.enums.ImGuiMouseCursor; - -import java.nio.Buffer; - -/** - * The bridge between Java and native APIs. - * Class itself used by "gdx-jnigen" util to generate JNI headers. - */ -class Native { - // @formatter:off - - /*JNI - #include - #include - - jfieldID totalVtxCountID; - jfieldID totalIdxCountID; - jfieldID totalCmdCountID; - jfieldID CmdListsCountID; - jfieldID displayPosXID; - jfieldID displayPosYID; - jfieldID displaySizeXID; - jfieldID displaySizeYID; - jfieldID framebufferScaleXID; - jfieldID framebufferScaleYID; - - // ImGuiIO - - jfieldID WantCaptureMouseID; - jfieldID WantCaptureKeyboardID; - jfieldID WantTextInputID; - jfieldID WantSetMousePosID; - jfieldID WantSaveIniSettingsID; - jfieldID NavActiveID; - jfieldID NavVisibleID; - jfieldID FramerateID; - jfieldID MetricsRenderVerticesID; - jfieldID MetricsRenderIndicesID; - jfieldID MetricsRenderWindowsID; - jfieldID MetricsActiveWindowsID; - jfieldID MetricsActiveAllocationsID; - jfieldID MouseDeltaXID; - jfieldID MouseDeltaYID; - - // ImGuiStyle - - jfieldID ItemInnerSpacingXID; - jfieldID ItemInnerSpacingYID; - - jfieldID imVec2XID; - jfieldID imVec2YID; - jfieldID imVec4ZID; - jfieldID imVec4WID; - - jfieldID imTextInputDataSizeID; - jfieldID imTextInputDataIsDirtyID; - - static int DRAWLIST_TYPE_DEFAULT = 0; - static int DRAWLIST_TYPE_BACKGROUND = 1; - static int DRAWLIST_TYPE_FOREGROUND = 2; - */ - - private Native() {} - - static native void init(); /* - jclass jDrawDataClass = env->FindClass("imgui/DrawData"); - jclass jImGuiIOClass = env->FindClass("imgui/ImGuiIO"); - jclass jImGuiStyleClass = env->FindClass("imgui/ImGuiStyle"); - jclass jImVec2Class = env->FindClass("imgui/ImVec2"); - jclass jImVec4Class = env->FindClass("imgui/ImVec4"); - jclass jImInputTextDataClass = env->FindClass("imgui/ImGuiInputTextData"); - - // DrawData Prepare IDs - totalVtxCountID = env->GetFieldID(jDrawDataClass, "totalVtxCount", "I"); - totalIdxCountID = env->GetFieldID(jDrawDataClass, "totalIdxCount", "I"); - totalCmdCountID = env->GetFieldID(jDrawDataClass, "totalCmdCount", "I"); - CmdListsCountID = env->GetFieldID(jDrawDataClass, "cmdListsCount", "I"); - displayPosXID = env->GetFieldID(jDrawDataClass, "displayPosX", "F"); - displayPosYID = env->GetFieldID(jDrawDataClass, "displayPosY", "F"); - displaySizeXID = env->GetFieldID(jDrawDataClass, "displaySizeX", "F"); - displaySizeYID = env->GetFieldID(jDrawDataClass, "displaySizeY", "F"); - framebufferScaleXID = env->GetFieldID(jDrawDataClass, "framebufferScaleX", "F"); - framebufferScaleYID = env->GetFieldID(jDrawDataClass, "framebufferScaleY", "F"); - - // ImGuiIO Prepare IDs - WantCaptureMouseID = env->GetFieldID(jImGuiIOClass, "WantCaptureMouse", "Z"); - WantCaptureKeyboardID = env->GetFieldID(jImGuiIOClass, "WantCaptureKeyboard", "Z"); - WantTextInputID = env->GetFieldID(jImGuiIOClass, "WantTextInput", "Z"); - WantSetMousePosID = env->GetFieldID(jImGuiIOClass, "WantSetMousePos", "Z"); - WantSaveIniSettingsID = env->GetFieldID(jImGuiIOClass, "WantSaveIniSettings", "Z"); - NavActiveID = env->GetFieldID(jImGuiIOClass, "NavActive", "Z"); - NavVisibleID = env->GetFieldID(jImGuiIOClass, "NavVisible", "Z"); - FramerateID = env->GetFieldID(jImGuiIOClass, "Framerate", "F"); - MetricsRenderVerticesID = env->GetFieldID(jImGuiIOClass, "MetricsRenderVertices", "I"); - MetricsRenderIndicesID = env->GetFieldID(jImGuiIOClass, "MetricsRenderIndices", "I"); - MetricsRenderWindowsID = env->GetFieldID(jImGuiIOClass, "MetricsRenderWindows", "I"); - MetricsActiveWindowsID = env->GetFieldID(jImGuiIOClass, "MetricsActiveWindows", "I"); - MetricsActiveAllocationsID = env->GetFieldID(jImGuiIOClass, "MetricsActiveAllocations", "I"); - MouseDeltaXID = env->GetFieldID(jImGuiIOClass, "MouseDeltaX", "F"); - MouseDeltaYID = env->GetFieldID(jImGuiIOClass, "MouseDeltaY", "F"); - - // ImGuiStyle Prepare IDs - ItemInnerSpacingXID = env->GetFieldID(jImGuiStyleClass, "ItemInnerSpacingX", "F"); - ItemInnerSpacingYID = env->GetFieldID(jImGuiStyleClass, "ItemInnerSpacingY", "F"); - - //ImVec2 Prepare IDs - imVec2XID = env->GetFieldID(jImVec2Class, "x", "F"); - imVec2YID = env->GetFieldID(jImVec2Class, "y", "F"); - - //ImVec4 Prepare IDs - imVec4ZID = env->GetFieldID(jImVec4Class, "z", "F"); - imVec4WID = env->GetFieldID(jImVec4Class, "w", "F"); - - imTextInputDataSizeID = env->GetFieldID(jImInputTextDataClass, "size", "I"); - imTextInputDataIsDirtyID = env->GetFieldID(jImInputTextDataClass, "isDirty", "Z"); - */ - - static native void CreateContext(); /* - ImGui::CreateContext(); - ImGui::GetIO().IniFilename = NULL; - ImGui::GetIO().BackendFlags |= ImGuiBackendFlags_HasMouseCursors; - */ - - static native void DestroyContext(); /* - ImGui::DestroyContext(); - */ - - static native void initKeyMap(int [] keys); /* - ImGuiIO& io = ImGui::GetIO(); - - for(int i = 0; i < ImGuiKey_COUNT; i++) { - io.KeyMap[i] = keys[i]; - } - */ - - static native void SetConfigFlags(int flag); /* - ImGuiIO& io = ImGui::GetIO(); - io.ConfigFlags = flag; - */ - - // TODO: Available after docking comes from BETA -// static native void SetDockingFlags(boolean ConfigDockingNoSplit, boolean ConfigDockingWithShift, boolean ConfigDockingAlwaysTabBar, boolean ConfigDockingTransparentPayload); /* -// ImGuiIO& io = ImGui::GetIO(); -// io.ConfigDockingNoSplit = ConfigDockingNoSplit; -// io.ConfigDockingWithShift = ConfigDockingWithShift; -// io.ConfigDockingAlwaysTabBar = ConfigDockingAlwaysTabBar; -// io.ConfigDockingTransparentPayload = ConfigDockingTransparentPayload; -// */ - - static native void UpdateDisplaySize(float w, float h, float fb_w, float fb_h); /* - ImGuiIO& io = ImGui::GetIO(); - io.DisplaySize = ImVec2(w, h); - if (w > 0 && h > 0) { - io.DisplayFramebufferScale = ImVec2((float) fb_w / w, (float) fb_h / h); - } - */ - - static native void UpdateDeltaTime(float delta_time); /* - ImGuiIO& io = ImGui::GetIO(); - io.DeltaTime = delta_time; - */ - - static native void UpdateMousePos(float mouseX, float mouseY); /* - ImGuiIO& io = ImGui::GetIO(); - if (io.WantSetMousePos == false) { - io.MousePos = ImVec2(mouseX, mouseY); - } - */ - - static native void UpdateMouseState(boolean mouseDown0, boolean mouseDown1, boolean mouseDown2, boolean mouseDown3, boolean mouseDown4, boolean mouseDown5); /* - ImGuiIO& io = ImGui::GetIO(); - - bool m0 = mouseDown0; - bool m1 = mouseDown1; - bool m2 = mouseDown2; - bool m3 = mouseDown3; - bool m4 = mouseDown4; - bool m5 = mouseDown5; - - io.MouseDown[0] = m0; - io.MouseDown[1] = m1; - io.MouseDown[2] = m2; - io.MouseDown[3] = m3; - io.MouseDown[4] = m4; - io.MouseDown[5] = m5; - */ - - static native void UpdateImGui(ImGuiIO jImguiIO, ImGuiStyle jImguiStyle); /* - ImGuiIO& io = ImGui::GetIO(); - - // Update ImGuiIO - env->SetBooleanField (jImguiIO, WantCaptureMouseID, io.WantCaptureMouse); - env->SetBooleanField (jImguiIO, WantCaptureKeyboardID, io.WantCaptureKeyboard); - env->SetBooleanField (jImguiIO, WantTextInputID, io.WantTextInput); - env->SetBooleanField (jImguiIO, WantSetMousePosID, io.WantSetMousePos); - env->SetBooleanField (jImguiIO, WantSaveIniSettingsID, io.WantSaveIniSettings); - env->SetBooleanField (jImguiIO, NavActiveID, io.NavActive); - env->SetBooleanField (jImguiIO, NavVisibleID, io.NavVisible); - env->SetBooleanField (jImguiIO, FramerateID, io.Framerate); - env->SetBooleanField (jImguiIO, MetricsRenderVerticesID, io.MetricsRenderVertices); - env->SetBooleanField (jImguiIO, MetricsRenderIndicesID, io.MetricsRenderIndices); - env->SetBooleanField (jImguiIO, MetricsRenderWindowsID, io.MetricsRenderWindows); - env->SetBooleanField (jImguiIO, MetricsActiveWindowsID, io.MetricsActiveWindows); - env->SetBooleanField (jImguiIO, MetricsActiveAllocationsID, io.MetricsActiveAllocations); - env->SetBooleanField (jImguiIO, MouseDeltaXID, io.MouseDelta.x); - - // Update ImGuiStyle - ImGuiStyle & style = ImGui::GetStyle(); - - env->SetFloatField (jImguiStyle, ItemInnerSpacingXID, style.ItemInnerSpacing.x); - env->SetFloatField (jImguiStyle, ItemInnerSpacingYID, style.ItemInnerSpacing.y); - */ - - static native void UpdateKey(int key, boolean pressed, boolean released, boolean ctrlKey, boolean shiftKey, boolean altKey, boolean superKey); /* - ImGuiIO& io = ImGui::GetIO(); - if (pressed) - io.KeysDown[key] = true; - if (released) - io.KeysDown[key] = false; - io.KeyCtrl = ctrlKey; - io.KeyShift = shiftKey; - io.KeyAlt = altKey; - io.KeySuper = superKey; - */ - - static native void UpdateScroll(float amountX, float amountY); /* - ImGuiIO& io = ImGui::GetIO(); - io.MouseWheelH += amountX; - io.MouseWheel += amountY; - */ - - static native void UpdateKeyTyped(int c); /* - ImGuiIO& io = ImGui::GetIO(); - if (c > 0 && c < 0x10000) - io.AddInputCharacter((unsigned short)c); - */ - - static native void NewFrame(); /* - ImGui::NewFrame(); - */ - - static native void EndFrame(); /* - ImGui::EndFrame(); - */ - - static native void Render(); /* - ImGui::Render(); - */ - - static native void ShowStyleEditor(); /* - ImGui::ShowStyleEditor(); - */ - - static native void ShowDemoWindow(); /* - ImGui::ShowDemoWindow(); - */ - - static native void ShowDemoWindow(boolean open); /* - bool toOpen = open; - ImGui::ShowDemoWindow(&toOpen); - */ - - static native void ShowMetricsWindow(); /* - ImGui::ShowMetricsWindow(); - */ - - static native void ShowMetricsWindow(boolean open); /* - bool toOpen = open; - ImGui::ShowMetricsWindow(&toOpen); - */ - - static native void GetTexDataAsRGBA32(TexDataRGBA32 jTexData, Buffer pixelBuffer); /* - jclass jTexDataClass = env->GetObjectClass(jTexData); - if(jTexDataClass == NULL) - return; - - jfieldID widthID = env->GetFieldID(jTexDataClass, "width", "I"); - jfieldID heightID = env->GetFieldID(jTexDataClass, "height", "I"); - - unsigned char* pixels; - int width, height; - - ImGuiIO& io = ImGui::GetIO(); - io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); - - env->SetIntField (jTexData, widthID, width); - env->SetIntField (jTexData, heightID, height); - - memcpy(pixelBuffer, pixels, width * height * 4); - */ - - static native void SetFontTexID(int id); /* - ImGuiIO& io = ImGui::GetIO(); - io.Fonts->TexID = (ImTextureID)id; - */ - - static native void GetDrawData(DrawData jDrawData, Buffer indexBuffer, Buffer vertexBuffer, Buffer cmdBuffer); /* - ImDrawData * drawData = ImGui::GetDrawData(); - - if(drawData != NULL) { - int cmdListsCount = drawData->CmdListsCount; - - // Set values - env->SetIntField (jDrawData, totalVtxCountID, drawData->TotalVtxCount); - env->SetIntField (jDrawData, totalIdxCountID, drawData->TotalIdxCount); - env->SetIntField (jDrawData, CmdListsCountID, cmdListsCount); - - env->SetFloatField (jDrawData, displayPosXID, drawData->DisplayPos.x); - env->SetFloatField (jDrawData, displayPosYID, drawData->DisplayPos.y); - - env->SetFloatField (jDrawData, displaySizeXID, drawData->DisplaySize.x); - env->SetFloatField (jDrawData, displaySizeYID, drawData->DisplaySize.y); - - env->SetFloatField (jDrawData, framebufferScaleXID, drawData->FramebufferScale.x); - env->SetFloatField (jDrawData, framebufferScaleYID, drawData->FramebufferScale.y); - - ImDrawList** drawLists = drawData->CmdLists; - - int verticeOffset = 0; - int indicesOffset = 0; - int cmdOffset = 0; - int cmdCount = 0; - - for(int i = 0; i < cmdListsCount; i++) { - ImDrawList & drawList = *drawLists[i]; - ImVector & imDrawCmdList = drawList.CmdBuffer; - ImVector & idxBuffer = drawList.IdxBuffer; - ImVector & vtxBuffer = drawList.VtxBuffer; - - int verticeSize = sizeof(ImDrawVert); - int indicesSize = sizeof(ImDrawIdx); - - float * vertexArraySource = (float *)vtxBuffer.Data; - short * indexArraySource = (short *)idxBuffer.Data; - float * vertexArrayDest = (float *)vertexBuffer; - short * indexArrayDest = (short *)indexBuffer; - - int colorSize = 1; - - int verticeItemSize = (4 + colorSize); - - vertexArrayDest[verticeOffset++] = vtxBuffer.Size; - // copy vertices to Destination buffer - for(int j = 0; j < vtxBuffer.Size; j++) { - ImDrawVert v = vtxBuffer[j]; - float posX = v.pos.x; - float posY = v.pos.y; - float uvX = v.uv.x; - float uvY = v.uv.y; - - int byteIndex = (j * verticeItemSize) + verticeOffset; - - float color = 0; - memcpy(&color, &v.col, 4); // move unsigned int color to float - - vertexArrayDest[byteIndex + 0] = posX; - vertexArrayDest[byteIndex + 1] = posY; - vertexArrayDest[byteIndex + 2] = uvX; - vertexArrayDest[byteIndex + 3] = uvY; - vertexArrayDest[byteIndex + 4] = color; - } - verticeOffset += vtxBuffer.Size * verticeItemSize; - - // copy index to destination buffer - indexArrayDest[indicesOffset++] = idxBuffer.Size; - for(int j = 0; j < idxBuffer.Size; j++) { - - indexArrayDest[j + indicesOffset] = idxBuffer[j]; - } - indicesOffset += idxBuffer.Size; - - float * cmdArrayDest = (float *)cmdBuffer; - - cmdArrayDest[cmdOffset++] = imDrawCmdList.Size; - int bytesOffset = 0; - int imDrawCmdSize = 1 + 4 + 1; - for (int cmd_i = 0; cmd_i < imDrawCmdList.Size; cmd_i++) { - const ImDrawCmd * pcmd = &imDrawCmdList[cmd_i]; - - float textureID = (float)(intptr_t)pcmd->TextureId; - float tempArray [6] = { - pcmd->ElemCount, - pcmd->ClipRect.x, - pcmd->ClipRect.y, - pcmd->ClipRect.z, - pcmd->ClipRect.w, - textureID - }; - - memcpy((cmdArrayDest + (cmd_i * imDrawCmdSize) + cmdOffset), tempArray, imDrawCmdSize * 4); - bytesOffset = bytesOffset + imDrawCmdSize; - } - cmdOffset += imDrawCmdList.Size * imDrawCmdSize; - cmdCount += imDrawCmdList.Size; - } - - env->SetIntField (jDrawData, totalCmdCountID, cmdCount); - } - */ - - static native void StyleColorsDark(); /* - ImGui::StyleColorsDark(); - */ - - static native void StyleColorsClassic(); /* - ImGui::StyleColorsClassic(); - */ - - static native void StyleColorsLight(); /* - ImGui::StyleColorsLight(); - */ - - static native boolean Begin(String title); /* - return ImGui::Begin(title); - */ - - static native boolean Begin(String title, boolean [] p_open, int imGuiWindowFlags); /* - return ImGui::Begin(title, &p_open[0], imGuiWindowFlags); - */ - - static native void End(); /* - ImGui::End(); - */ - - static native boolean BeginChild(String str_id); /* - return ImGui::BeginChild(str_id); - */ - - static native boolean BeginChild(String str_id, float width, float height); /* - return ImGui::BeginChild(str_id, ImVec2(width, height)); - */ - - static native boolean BeginChild(String str_id, float width, float height, boolean border); /* - return ImGui::BeginChild(str_id, ImVec2(width, height), border); - */ - - static native boolean BeginChild(String str_id, float width, float height, boolean border, int flags); /* - return ImGui::BeginChild(str_id, ImVec2(width, height), border, flags); - */ - - static native boolean BeginChild(int imGuiID); /* - return ImGui::BeginChild(imGuiID); - */ - - static native boolean BeginChild(int imGuiID, float width, float height, boolean border); /* - return ImGui::BeginChild(imGuiID, ImVec2(width, height), border); - */ - - static native boolean BeginChild(int imGuiID, float width, float height, boolean border, int flags); /* - return ImGui::BeginChild(imGuiID, ImVec2(width, height), border, flags); - */ - - static native void EndChild(); /* - ImGui::EndChild(); - */ - - static native boolean IsWindowAppearing(); /* - return ImGui::IsWindowAppearing(); - */ - - static native boolean IsWindowCollapsed(); /* - return ImGui::IsWindowCollapsed(); - */ - - static native boolean IsWindowFocused(); /* - return ImGui::IsWindowFocused(); - */ - - static native boolean IsWindowFocused(int flags); /* - return ImGui::IsWindowFocused(flags); - */ - - static native boolean IsWindowHovered(); /* - return ImGui::IsWindowHovered(); - */ - - // DrawList - - /*JNI - ImDrawList * getDrawList(int type) { - ImDrawList* drawList = NULL; - if(type == DRAWLIST_TYPE_DEFAULT) - drawList = ImGui::GetWindowDrawList(); - else if(type == DRAWLIST_TYPE_BACKGROUND) - drawList = ImGui::GetBackgroundDrawList(); - else if(type == DRAWLIST_TYPE_FOREGROUND) - drawList = ImGui::GetForegroundDrawList(); - return drawList; - } - - */ - - static native boolean IsWindowHovered(int flags); /* - return ImGui::IsWindowHovered(flags); - */ - - static native boolean AddLine(int type, float a_x, float a_y, float b_x, float b_y, int col); /* - ImDrawList* drawList = getDrawList(type); - drawList->AddLine(ImVec2(a_x, a_y), ImVec2(b_x, b_y), col); - */ - - static native boolean AddLine(int type, float a_x, float a_y, float b_x, float b_y, int col, float thinkness); /* - ImDrawList* drawList = getDrawList(type); - drawList->AddLine(ImVec2(a_x, a_y), ImVec2(b_x, b_y), col, thinkness); - */ - - static native boolean AddRect(int type, float a_x, float a_y, float b_x, float b_y, int col); /* - ImDrawList* drawList = getDrawList(type); - drawList->AddRect(ImVec2(a_x, a_y), ImVec2(b_x, b_y), col); - */ - - static native boolean AddRect(int type, float a_x, float a_y, float b_x, float b_y, int col, float rounding); /* - ImDrawList* drawList = getDrawList(type); - drawList->AddRect(ImVec2(a_x, a_y), ImVec2(b_x, b_y), col, rounding); - */ - - static native boolean AddRect(int type, float a_x, float a_y, float b_x, float b_y, int col, float rounding, int rounding_corners_flags); /* - ImDrawList* drawList = getDrawList(type); - drawList->AddRect(ImVec2(a_x, a_y), ImVec2(b_x, b_y), col, rounding, rounding_corners_flags); - */ - - static native boolean AddRect(int type, float a_x, float a_y, float b_x, float b_y, int col, float rounding, int rounding_corners_flags, float thickness); /* - ImDrawList* drawList = getDrawList(type); - drawList->AddRect(ImVec2(a_x, a_y), ImVec2(b_x, b_y), col, rounding, rounding_corners_flags, thickness); - */ - - static native boolean AddRectFilled(int type, float a_x, float a_y, float b_x, float b_y, int col); /* - ImDrawList* drawList = getDrawList(type); - drawList->AddRectFilled(ImVec2(a_x, a_y), ImVec2(b_x, b_y), col); - */ - - static native boolean AddRectFilled(int type, float a_x, float a_y, float b_x, float b_y, int col, float rounding); /* - ImDrawList* drawList = getDrawList(type); - drawList->AddRectFilled(ImVec2(a_x, a_y), ImVec2(b_x, b_y), col, rounding); - */ - - static native boolean AddRectFilled(int type, float a_x, float a_y, float b_x, float b_y, int col, float rounding, int rounding_corners_flags); /* - ImDrawList* drawList = getDrawList(type); - drawList->AddRectFilled(ImVec2(a_x, a_y), ImVec2(b_x, b_y), col, rounding, rounding_corners_flags); - */ - - static native boolean AddRectFilledMultiColor(int type, float a_x, float a_y, float b_x, float b_y, int col_upr_left, float col_upr_right, int col_bot_right, int col_bot_left); /* - ImDrawList* drawList = getDrawList(type); - drawList->AddRectFilledMultiColor(ImVec2(a_x, a_y), ImVec2(b_x, b_y), col_upr_left, col_upr_right, col_bot_right, col_bot_left); - */ - - static native boolean AddQuad(int type, float a_x, float a_y, float b_x, float b_y, float c_x, float c_y, float d_x, float d_y, int col); /* - ImDrawList* drawList = getDrawList(type); - drawList->AddQuad(ImVec2(a_x, a_y), ImVec2(b_x, b_y), ImVec2(c_x, c_y), ImVec2(d_x, d_y), col); - */ - - static native boolean AddQuad(int type, float a_x, float a_y, float b_x, float b_y, float c_x, float c_y, float d_x, float d_y, int col, float thickness); /* - ImDrawList* drawList = getDrawList(type); - drawList->AddQuad(ImVec2(a_x, a_y), ImVec2(b_x, b_y), ImVec2(c_x, c_y), ImVec2(d_x, d_y), col, thickness); - */ - - static native boolean AddQuadFilled(int type, float a_x, float a_y, float b_x, float b_y, float c_x, float c_y, float d_x, float d_y, int col); /* - ImDrawList* drawList = getDrawList(type); - drawList->AddQuadFilled(ImVec2(a_x, a_y), ImVec2(b_x, b_y), ImVec2(c_x, c_y), ImVec2(d_x, d_y), col); - */ - - static native boolean AddTriangle(int type, float a_x, float a_y, float b_x, float b_y, float c_x, float c_y, int col); /* - ImDrawList* drawList = getDrawList(type); - drawList->AddTriangle(ImVec2(a_x, a_y), ImVec2(b_x, b_y), ImVec2(c_x, c_y), col); - */ - - static native boolean AddTriangle(int type, float a_x, float a_y, float b_x, float b_y, float c_x, float c_y, int col, float thickness); /* - ImDrawList* drawList = getDrawList(type); - drawList->AddTriangle(ImVec2(a_x, a_y), ImVec2(b_x, b_y), ImVec2(c_x, c_y), col, thickness); - */ - - static native boolean AddTriangleFilled(int type, float a_x, float a_y, float b_x, float b_y, float c_x, float c_y, int col); /* - ImDrawList* drawList = getDrawList(type); - drawList->AddTriangleFilled(ImVec2(a_x, a_y), ImVec2(b_x, b_y), ImVec2(c_x, c_y), col); - */ - - static native boolean AddCircle(int type, float centre_x, float centre_y, float radius, float col); /* - ImDrawList* drawList = getDrawList(type); - drawList->AddCircle(ImVec2(centre_x, centre_y), radius, col); - */ - - static native boolean AddCircle(int type, float centre_x, float centre_y, float radius, float col, int num_segments, float thickness); /* - ImDrawList* drawList = getDrawList(type); - drawList->AddCircle(ImVec2(centre_x, centre_y), radius, col, num_segments, thickness); - */ - - static native boolean AddCircleFilled(int type, float centre_x, float centre_y, float radius, float col); /* - ImDrawList* drawList = getDrawList(type); - drawList->AddCircleFilled(ImVec2(centre_x, centre_y), radius, col); - */ - - static native boolean AddCircleFilled(int type, float centre_x, float centre_y, float radius, float col, int num_segments); /* - ImDrawList* drawList = getDrawList(type); - drawList->AddCircleFilled(ImVec2(centre_x, centre_y), radius, col, num_segments); - */ - - static native boolean AddText(int type, float pos_x, float pos_y, int col, String text_begin); /* - ImDrawList* drawList = getDrawList(type); - drawList->AddText(ImVec2(pos_x, pos_y), col, text_begin); - */ - - // TODO AddText - - static native boolean AddText(int type, float pos_x, float pos_y, int col, String text_begin, String text_end); /* - ImDrawList* drawList = getDrawList(type); - drawList->AddText(ImVec2(pos_x, pos_y), col, text_begin, text_end); - */ - - static native boolean AddImage(int type, int textureID, float a_x, float a_y, float b_x, float b_y); /* - ImDrawList* drawList = getDrawList(type); - drawList->AddImage((void *)textureID, ImVec2(a_x, a_y), ImVec2(b_x, b_y)); - */ - - //TODO AddImageQuad, AddImageRounded, AddPolyline, AddConvexPolyFilled - - static native boolean AddImage(int type, int textureID, float a_x, float a_y, float b_x, float b_y, float uv_a_x, float uv_a_y, float uv_b_x, float uv_b_y); /* - ImDrawList* drawList = getDrawList(type); - drawList->AddImage((void *)textureID, ImVec2(a_x, a_y), ImVec2(b_x, b_y), ImVec2(uv_a_x, uv_a_y), ImVec2(uv_b_x, uv_b_y)); - */ - - static native boolean AddBezierCurve(int type, float pos0_x, float pos0_y, float cp0_x, float cp0_y, float cp1_x, float cp1_y, float pos1_x, float pos1_y, float col, float thickness); /* - ImDrawList* drawList = getDrawList(type); - drawList->AddBezierCurve(ImVec2(pos0_x, pos0_y), ImVec2(cp0_x, cp0_y), ImVec2(cp1_x, cp1_y), ImVec2(pos1_x, pos1_y), col, thickness); - */ - - static native boolean AddBezierCurve(int type, float pos0_x, float pos0_y, float cp0_x, float cp0_y, float cp1_x, float cp1_y, float pos1_x, float pos1_y, float col, float thickness, int num_segments); /* - ImDrawList* drawList = getDrawList(type); - drawList->AddBezierCurve(ImVec2(pos0_x, pos0_y), ImVec2(cp0_x, cp0_y), ImVec2(cp1_x, cp1_y), ImVec2(pos1_x, pos1_y), col, thickness, num_segments); - */ - - static native void ChannelsSplit(int type, int count); /* - ImDrawList* drawList = getDrawList(type); - drawList->ChannelsSplit(count); - */ - - static native void ChannelsMerge(int type); /* - ImDrawList* drawList = getDrawList(type); - drawList->ChannelsMerge(); - */ - - static native void ChannelsSetCurrent(int type, int n); /* - ImDrawList* drawList = getDrawList(type); - drawList->ChannelsSetCurrent(n); - */ - - static native void GetWindowPos(ImVec2 jImVec2); /* - ImVec2 vec = ImGui::GetWindowPos(); - env->SetFloatField (jImVec2, imVec2XID, vec.x); - env->SetFloatField (jImVec2, imVec2YID, vec.y); - */ - - static native float GetWindowPosX(); /* - return ImGui::GetWindowPos().x; - */ - - static native float GetWindowPosY(); /* - return ImGui::GetWindowPos().y; - */ - - static native void GetWindowSize(ImVec2 jImVec2); /* - ImVec2 vec = ImGui::GetWindowSize(); - env->SetFloatField (jImVec2, imVec2XID, vec.x); - env->SetFloatField (jImVec2, imVec2YID, vec.y); - */ - - static native float GetWindowWidth(); /* - return ImGui::GetWindowWidth(); - */ - - // Prefer using SetNextXXX functions (before Begin) rather that SetXXX functions (after Begin). - - public static native float GetWindowHeight(); /* - return ImGui::GetWindowHeight(); - */ - - static native void SetNextWindowPos(float x, float y); /* - ImGui::SetNextWindowPos(ImVec2(x, y)); - */ - - static native void SetNextWindowPos(float x, float y, int cond); /* - ImGui::SetNextWindowPos(ImVec2(x, y), cond); - */ - - static native void SetNextWindowPos(float x, float y, int cond, float pivot_x, float pivot_y); /* - ImGui::SetNextWindowPos(ImVec2(x, y), cond, ImVec2(pivot_x, pivot_y)); - */ - - static native void SetNextWindowSize(float width, float height); /* - ImGui::SetNextWindowSize(ImVec2(width, height)); - */ - - static native void SetNextWindowSize(float width, float height, int cond); /* - ImGui::SetNextWindowSize(ImVec2(width, height), cond); - */ - - static native void SetNextWindowSizeConstraints(float min_width, float min_height, float max_width, float max_height); /* - ImGui::SetNextWindowSizeConstraints(ImVec2(min_width, min_height), ImVec2(max_width, max_height)); - */ - - static native void SetNextWindowContentSize(float width, float height); /* - ImGui::SetNextWindowContentSize(ImVec2(width, height)); - */ - - static native void SetNextWindowCollapsed(boolean collapsed); /* - ImGui::SetNextWindowCollapsed(collapsed); - */ - - static native void SetNextWindowCollapsed(boolean collapsed, int cond); /* - ImGui::SetNextWindowCollapsed(collapsed, cond); - */ - - static native void SetNextWindowFocus(); /* - ImGui::SetNextWindowFocus(); - */ - - static native void SetNextWindowBgAlpha(float alpha); /* - ImGui::SetNextWindowBgAlpha(alpha); - */ - - static native void SetWindowPos(float x, float y); /* - ImGui::SetWindowPos(ImVec2(x, y)); - */ - - static native void SetWindowPos(float x, float y, int cond); /* - ImGui::SetWindowPos(ImVec2(x, y), cond); - */ - - static native void SetWindowSize(float width, float height); /* - ImGui::SetWindowSize(ImVec2(width, height)); - */ - - static native void SetWindowSize(float width, float height, int cond); /* - ImGui::SetWindowSize(ImVec2(width, height), cond); - */ - - static native void SetWindowCollapsed(boolean collapsed, int cond); /* - ImGui::SetWindowCollapsed(collapsed, cond); - */ - - static native void SetWindowFocus(); /* - ImGui::SetWindowFocus(); - */ - - static native void SetWindowFocus(float scale); /* - ImGui::SetWindowFontScale(scale); - */ - - static native void SetWindowPos(String name, float x, float y); /* - ImGui::SetWindowPos(name, ImVec2(x, y)); - */ - - static native void SetWindowPos(String name, float x, float y, int cond); /* - ImGui::SetWindowPos(name, ImVec2(x, y), cond); - */ - - static native void SetWindowCollapsed(String name, boolean collapsed); /* - bool flag = collapsed; - ImGui::SetWindowCollapsed(name, flag); - */ - - static native void SetWindowCollapsed(String name, boolean collapsed, int cond); /* - ImGui::SetWindowCollapsed(name, collapsed, cond); - */ - - static native void SetWindowFocus(String name); /* - ImGui::SetWindowFocus(name); - */ - - // Content region - // - Those functions are bound to be redesigned soon (they are confusing, incomplete and return values in local window coordinates which increases confusion) - - static native void RemoveWindowFocus(); /* - ImGui::SetWindowFocus(NULL); - */ - - static native void GetContentRegionMax(ImVec2 jImVec2); /* - ImVec2 vec = ImGui::GetContentRegionMax(); - env->SetFloatField (jImVec2, imVec2XID, vec.x); - env->SetFloatField (jImVec2, imVec2YID, vec.y); - */ - - static native void GetContentRegionAvail(ImVec2 jImVec2); /* - ImVec2 vec = ImGui::GetContentRegionAvail(); - env->SetFloatField (jImVec2, imVec2XID, vec.x); - env->SetFloatField (jImVec2, imVec2YID, vec.y); - */ - - static native float GetContentRegionAvailWidth(); /* - return ImGui::GetContentRegionAvailWidth(); - */ - - static native void GetWindowContentRegionMin(ImVec2 jImVec2); /* - ImVec2 vec = ImGui::GetWindowContentRegionMin(); - env->SetFloatField (jImVec2, imVec2XID, vec.x); - env->SetFloatField (jImVec2, imVec2YID, vec.y); - */ - - static native void GetWindowContentRegionMax(ImVec2 jImVec2); /* - ImVec2 vec = ImGui::GetWindowContentRegionMax(); - env->SetFloatField (jImVec2, imVec2XID, vec.x); - env->SetFloatField (jImVec2, imVec2YID, vec.y); - */ - - // Windows Scrolling - - static native float GetWindowContentRegionWidth(); /* - return ImGui::GetWindowContentRegionWidth(); - */ - - static native float GetScrollX(); /* - return ImGui::GetScrollX(); - */ - - static native float GetScrollY(); /* - return ImGui::GetScrollY(); - */ - - static native float GetScrollMaxX(); /* - return ImGui::GetScrollMaxX(); - */ - - static native float GetScrollMaxY(); /* - return ImGui::GetScrollMaxY(); - */ - - static native void SetScrollX(float scroll_x); /* - ImGui::SetScrollX(scroll_x); - */ - - static native void SetScrollY(float scroll_y); /* - ImGui::SetScrollY(scroll_y); - */ - - static native void SetScrollHereY(); /* - ImGui::SetScrollHereY(); - */ - - static native void SetScrollHereY(float center_y_ratio); /* - ImGui::SetScrollHereY(center_y_ratio); - */ - - static native void SetScrollFromPosY(float local_y); /* - ImGui::SetScrollFromPosY(local_y); - */ - - // Parameters stacks (shared) - - static native void SetScrollFromPosY(float local_y, float center_y_ratio); /* - ImGui::SetScrollFromPosY(local_y, center_y_ratio); - */ - - //TODO impl - static native void PushFont(int index); /* - ImGuiIO& io = ImGui::GetIO(); - ImFontAtlas* atlas = io.Fonts; - ImFont* font = atlas->Fonts[index]; - ImGui::PushFont(font); - */ - - static native void PopFont(); /* - ImGui::PopFont(); - */ - - static native void PushStyleColor(int idx, int col); /* - ImGui::PushStyleColor(idx, col); - */ - - static native void PushStyleColor(int idx, float r, float g, float b, float a); /* - ImGui::PushStyleColor(idx, ImVec4(r, g, b, a)); - */ - - static native void PopStyleColor(); /* - ImGui::PopStyleColor(); - */ - - static native void PopStyleColor(int count); /* - ImGui::PopStyleColor(count); - */ - - static native void PushStyleVar(int idx, float val); /* - ImGui::PushStyleVar(idx, val); - */ - - static native void PushStyleVar(int idx, float val_x, float val_y); /* - ImGui::PushStyleVar(idx, ImVec2(val_x, val_y)); - */ - - static native void PopStyleVar(); /* - ImGui::PopStyleVar(); - */ - - static native void PopStyleVar(int count); /* - ImGui::PopStyleVar(count); - */ - - static native void GetStyleColorVec4(int idx, float [] value); /* - ImVec4 val = ImGui::GetStyleColorVec4(idx); - value[0] = val.x; - value[1] = val.y; - value[2] = val.z; - value[3] = val.w; - */ - - //TODO impl - static native void GetFont(); /* - ImFont * font = ImGui::GetFont(); - */ - - static native int GetFontSize(); /* - return ImGui::GetFontSize(); - */ - - static native void GetFontTexUvWhitePixel(float [] value); /* - ImVec2 val = ImGui::GetFontTexUvWhitePixel(); - value[0] = val.x; - value[1] = val.y; - */ - - static native int GetColorU32(int idx); /* - return ImGui::GetColorU32((ImGuiCol)idx); - */ - - static native int GetColorU32(int idx, float alpha_mul); /* - return ImGui::GetColorU32(idx, alpha_mul); - */ - - // Parameters stacks (current window) - - static native int GetColorU32(float col_x, float col_y, float col_z, float col_w); /* - return ImGui::GetColorU32(ImVec4(col_x, col_y, col_z, col_w)); - */ - - static native void PushItemWidth(float item_width); /* - ImGui::PushItemWidth(item_width); - */ - - static native void PopItemWidth(); /* - ImGui::PopItemWidth(); - */ - - static native void SetNextItemWidth(float item_width); /* - ImGui::SetNextItemWidth(item_width); - */ - - static native float CalcItemWidth(); /* - return ImGui::CalcItemWidth(); - */ - - static native void PushTextWrapPos(float wrap_local_pos_x); /* - ImGui::PushTextWrapPos(wrap_local_pos_x); - */ - - static native void PushTextWrapPos(); /* - ImGui::PushTextWrapPos(); - */ - - static native void PopTextWrapPos(); /* - ImGui::PopTextWrapPos(); - */ - - static native void PushAllowKeyboardFocus(boolean allow_keyboard_focus); /* - ImGui::PushAllowKeyboardFocus(allow_keyboard_focus); - */ - - static native void PopAllowKeyboardFocus(); /* - ImGui::PopAllowKeyboardFocus(); - */ - - static native void PushButtonRepeat(boolean repeat); /* - ImGui::PushButtonRepeat(repeat); - */ - - // Cursor / Layout - // - By "cursor" we mean the current output position. - // - The typical widget behavior is to output themselves at the current cursor position, then move the cursor one line down. - - static native void PopButtonRepeat(); /* - ImGui::PopButtonRepeat(); - */ - - static native void Separator(); /* - ImGui::Separator(); - */ - - static native void SameLine(); /* - ImGui::SameLine(); - */ - - static native void SameLine(float offsetFromStartX); /* - ImGui::SameLine(offsetFromStartX); - */ - - static native void SameLine(float offsetFromStartX, float spacing); /* - ImGui::SameLine(offsetFromStartX, spacing); - */ - - static native void NewLine(); /* - ImGui::NewLine(); - */ - - static native void Spacing(); /* - ImGui::Spacing(); - */ - - static native void Dummy(float width, float height); /* - ImGui::Dummy(ImVec2(width, height)); - */ - - static native void Indent(); /* - ImGui::Indent(); - */ - - static native void Indent(float indentW); /* - ImGui::Indent(indentW); - */ - - static native void Unindent(); /* - ImGui::Unindent(); - */ - - static native void Unindent(float indentW); /* - ImGui::Unindent(indentW); - */ - - static native void BeginGroup(); /* - ImGui::BeginGroup(); - */ - - static native void EndGroup(); /* - ImGui::EndGroup(); - */ - - static native void GetCursorPos(float [] vec2); /* - ImVec2 vec = ImGui::GetCursorPos(); - vec2[0] = vec.x; - vec2[1] = vec.y; - */ - - static native float GetCursorPosX(); /* - return ImGui::GetCursorPosX(); - */ - - static native float GetCursorPosY(); /* - return ImGui::GetCursorPosY(); - */ - - static native void SetCursorPos(float x, float y); /* - ImGui::SetCursorPos(ImVec2(x, y)); - */ - - static native void SetCursorPosX(float x); /* - ImGui::SetCursorPosX(x); - */ - - static native void SetCursorPosY(float y); /* - ImGui::SetCursorPosY(y); - */ - - static native void GetCursorStartPos(ImVec2 jImVec2); /* - ImVec2 vec = ImGui::GetCursorStartPos(); - env->SetFloatField (jImVec2, imVec2XID, vec.x); - env->SetFloatField (jImVec2, imVec2YID, vec.y); - */ - - static native void GetCursorScreenPos(ImVec2 jImVec2); /* - ImVec2 vec = ImGui::GetCursorScreenPos(); - env->SetFloatField (jImVec2, imVec2XID, vec.x); - env->SetFloatField (jImVec2, imVec2YID, vec.y); - */ - - static native void SetCursorScreenPos(float x, float y); /* - ImGui::SetCursorScreenPos(ImVec2(x, y)); - */ - - static native void AlignTextToFramePadding(); /* - ImGui::AlignTextToFramePadding(); - */ - - static native float GetTextLineHeight(); /* - return ImGui::GetTextLineHeight(); - */ - - static native float GetTextLineHeightWithSpacing(); /* - return ImGui::GetTextLineHeightWithSpacing(); - */ - - static native float GetFrameHeight(); /* - return ImGui::GetFrameHeight(); - */ - - // ID stack/scopes - // - Read the FAQ for more details about how ID are handled in dear imgui. If you are creating widgets in a loop you most - // likely want to push a unique identifier (e.g. object pointer, loop index) to uniquely differentiate them. - // - The resulting ID are hashes of the entire stack. - // - You can also use the "Label##foobar" syntax within widget label to distinguish them from each others. - // - In this header file we use the "label"/"name" terminology to denote a string that will be displayed and used as an ID, - // whereas "str_id" denote a string that is only used as an ID and not normally displayed. - - static native float GetFrameHeightWithSpacing(); /* - return ImGui::GetFrameHeightWithSpacing(); - */ - - static native void PushID(String str_id); /* - ImGui::PushID(str_id); - */ - - static native void PushID(String str_id_begin, String str_id_end); /* - ImGui::PushID(str_id_begin, str_id_end); - */ - - static native void PushID(int int_id); /* - ImGui::PushID(int_id); - */ - - static native void PopID(); /* - ImGui::PopID(); - */ - - static native int GetID(String str_id); /* - return ImGui::GetID(str_id); - */ - - // Widgets: Text - - static native int GetID(String str_id_begin, String str_id_end); /* - return ImGui::GetID(str_id_begin, str_id_end); - */ - - static native void TextUnformatted(String text); /* - ImGui::TextUnformatted(text); - */ - - static native void TextUnformatted(String text, String text_end); /* - ImGui::TextUnformatted(text, text_end); - */ - - static native void Text(String text); /* - ImGui::Text(text); - */ - - static native void TextColored(float r, float g, float b, float a, String text); /* - ImGui::TextColored(ImVec4(r, g, b, a), text); - */ - - static native void TextDisabled(String text); /* - ImGui::TextDisabled(text); - */ - - static native void TextWrapped(String text); /* - ImGui::TextWrapped(text); - */ - - static native void LabelText(String label, String text); /* - ImGui::LabelText(label, text); - */ - - // Widgets: Main - // - Most widgets return true when the value has been changed or when pressed/selected - - static native void BulletText(String text); /* - ImGui::BulletText(text); - */ - - static native boolean Button(String label); /* - return ImGui::Button(label); - */ - - static native boolean Button(String label, float width, float height); /* - return ImGui::Button(label, ImVec2(width, height)); - */ - - static native boolean SmallButton(String label); /* - return ImGui::SmallButton(label); - */ - - static native boolean InvisibleButton(String strId, float width, float height); /* - return ImGui::InvisibleButton(strId, ImVec2(width, height)); - */ - - static native boolean ArrowButton(String strId, int dir); /* - return ImGui::ArrowButton(strId, dir); - */ - - static native void Image(int textureID, float sizeX, float sizeY); /* - ImGui::Image((ImTextureID)textureID, ImVec2(sizeX, sizeY)); - */ - - static native void Image(int textureID, float sizeX, float sizeY, float uv0_x, float uv0_y, float uv1_x, float uv1_y); /* - ImGui::Image((ImTextureID)textureID, ImVec2(sizeX, sizeY), ImVec2(uv0_x, uv0_y), ImVec2(uv1_x, uv1_y)); - */ - - static native void Image(int textureID, float sizeX, float sizeY, float uv0_x, float uv0_y, float uv1_x, float uv1_y, float tint_color_r, float tint_color_g, float tint_color_b, float tint_color_a, float border_col_r, float border_col_g, float border_col_b, float border_col_a); /* - ImGui::Image((ImTextureID)textureID, ImVec2(sizeX, sizeY), ImVec2(uv0_x, uv0_y), ImVec2(uv1_x, uv1_y), ImVec4(tint_color_r, tint_color_g, tint_color_b, tint_color_a), ImVec4(border_col_r, border_col_g, border_col_b, border_col_a)); - */ - - static native boolean ImageButton(int textureID, float sizeX, float sizeY); /* - return ImGui::ImageButton((ImTextureID)textureID, ImVec2(sizeX, sizeY)); - */ - - static native boolean ImageButton(int textureID, float sizeX, float sizeY, float uv0_x, float uv0_y, float uv1_x, float uv1_y, int frame_padding); /* - return ImGui::ImageButton((ImTextureID)textureID, ImVec2(sizeX, sizeY), ImVec2(uv0_x, uv0_y), ImVec2(uv1_x, uv1_y), frame_padding); - */ - - static native boolean ImageButton(int textureID, float sizeX, float sizeY, float uv0_x, float uv0_y, float uv1_x, float uv1_y, int frame_padding, float bg_color_r, float bg_color_g, float bg_color_b, float bg_color_a, float tint_col_r, float tint_col_g, float tint_col_b, float tint_col_a); /* - return ImGui::ImageButton((ImTextureID)textureID, ImVec2(sizeX, sizeY), ImVec2(uv0_x, uv0_y), ImVec2(uv1_x, uv1_y), frame_padding, ImVec4(bg_color_r, bg_color_g, bg_color_b, bg_color_a), ImVec4(tint_col_r, tint_col_g, tint_col_b, tint_col_a)); - */ - - static native boolean Checkbox(String label, boolean [] data); /* - return ImGui::Checkbox(label, &data[0]); - */ - - //TODO check if its working - static native boolean CheckboxFlags(String label, int [] data, int flagsValue); /* - return ImGui::CheckboxFlags(label, (unsigned int*)&data[0], flagsValue); - */ - - static native boolean RadioButton(String label, boolean active); /* - return ImGui::RadioButton(label, active); - */ - - static native boolean RadioButton(String label, int [] data, int v_button); /* - return ImGui::RadioButton(label, &data[0], v_button); - */ - - static native void ProgressBar(float fraction); /* - ImGui::ProgressBar(fraction); - */ - - static native void ProgressBar(float fraction, float size_arg_x, float size_arg_y); /* - ImGui::ProgressBar(fraction, ImVec2(size_arg_x, size_arg_y)); - */ - - // Widgets: Combo Box - // - The new BeginCombo()/EndCombo() api allows you to manage your contents and selection state however you want it, by creating e.g. Selectable() items. - // - The old Combo() api are helpers over BeginCombo()/EndCombo() which are kept available for convenience purpose. - - static native void Bullet(); /* - ImGui::Bullet(); - */ - - static native boolean BeginCombo(String label, String preview_value); /* - return ImGui::BeginCombo(label, preview_value); - */ - - static native boolean BeginCombo(String label, String preview_value, int flags); /* - return ImGui::BeginCombo(label, preview_value, flags); - */ - - static native void EndCombo(); /* - ImGui::EndCombo(); - */ - - static native boolean Combo(String label, int [] current_item, String [] items, int items_count); /* - const char* listbox_items[items_count]; - for(int i = 0; i < items_count; i++) { - jstring string = (jstring) (env->GetObjectArrayElement(items, i)); - const char *rawString = env->GetStringUTFChars(string, 0); - listbox_items[i] = rawString; - } - return ImGui::Combo(label, ¤t_item[0], listbox_items, items_count); - */ - - static native boolean Combo(String label, int [] current_item, String [] items, int items_count, int popup_max_height_in_items); /* - const char* listbox_items[items_count]; - for(int i = 0; i < items_count; i++) { - jstring string = (jstring) (env->GetObjectArrayElement(items, i)); - const char *rawString = env->GetStringUTFChars(string, 0); - listbox_items[i] = rawString; - } - return ImGui::Combo(label, ¤t_item[0], listbox_items, items_count, popup_max_height_in_items); - */ - - static native boolean Combo(String label, int [] current_item, String items_separated_by_zeros); /* - return ImGui::Combo(label, ¤t_item[0], items_separated_by_zeros); - */ - - // Widgets: Drags - // - CTRL+Click on any drag box to turn them into an input box. Manually input values aren't clamped and can go off-bounds. - // - For all the Float2/Float3/Float4/Int2/Int3/Int4 versions of every functions, note that a 'float v[X]' function argument is the same as 'float* v', the array syntax is just a way to document the number of elements that are expected to be accessible. You can pass address of your first element out of a contiguous set, e.g. &myvector.x - // - Adjust format string to decorate the value with a prefix, a suffix, or adapt the editing and display precision e.g. "%.3f" -> 1.234; "%5.2f secs" -> 01.23 secs; "Biscuit: %.0f" -> Biscuit: 1; etc. - // - Speed are per-pixel of mouse movement (v_speed=0.2f: mouse needs to move by 5 pixels to increase value by 1). For gamepad/keyboard navigation, minimum speed is Max(v_speed, minimum_step_at_given_precision). - - static native boolean Combo(String label, int [] current_item, String items_separated_by_zeros, int popup_max_height_in_items); /* - return ImGui::Combo(label, ¤t_item[0], items_separated_by_zeros, popup_max_height_in_items); - */ - - static native boolean DragFloat(String label, float [] v); /* - return ImGui::DragFloat(label, &v[0]); - */ - - static native boolean DragFloat(String label, float [] v, float v_speed); /* - return ImGui::DragFloat(label, &v[0], v_speed); - */ - - static native boolean DragFloat(String label, float [] v, float v_speed, float v_min, float v_max, String format); /* - return ImGui::DragFloat(label, &v[0], v_speed, v_min, v_max, format); - */ - - static native boolean DragFloat(String label, float [] v, float v_speed, float v_min, float v_max, String format, float power); /* - return ImGui::DragFloat(label, &v[0], v_speed, v_min, v_max, format, power); - */ - - static native boolean DragFloat2(String label, float [] v); /* - return ImGui::DragFloat2(label, v); - */ - - static native boolean DragFloat2(String label, float [] v, float v_speed, float v_min, float v_max, String format, float power); /* - return ImGui::DragFloat2(label, v, v_speed, v_min, v_max, format, power); - */ - - static native boolean DragFloat3(String label, float [] v); /* - return ImGui::DragFloat3(label, v); - */ - - static native boolean DragFloat3(String label, float [] v, float v_speed, float v_min, float v_max, String format, float power); /* - return ImGui::DragFloat3(label, v, v_speed, v_min, v_max, format, power); - */ - - static native boolean DragFloat4(String label, float [] v); /* - return ImGui::DragFloat4(label, v); - */ - - static native boolean DragFloat4(String label, float [] v, float v_speed, float v_min, float v_max, String format, float power); /* - return ImGui::DragFloat4(label, v, v_speed, v_min, v_max, format, power); - */ - - static native boolean DragFloatRange2(String label, float [] v_current_min, float [] v_current_max); /* - return ImGui::DragFloatRange2(label, &v_current_min[0], &v_current_max[0]); - */ - - static native boolean DragFloatRange2(String label, float [] v_current_min, float [] v_current_max, float v_speed, float v_min, float v_max, String format, String format_max, float power); /* - return ImGui::DragFloatRange2(label, &v_current_min[0], &v_current_max[0], v_speed, v_min, v_max, format, format_max, power); - */ - - static native boolean DragInt(String label, int [] v); /* - return ImGui::DragInt(label, &v[0]); - */ - - static native boolean DragInt(String label, int [] v, float v_speed); /* - return ImGui::DragInt(label, &v[0], v_speed); - */ - - static native boolean DragInt(String label, int [] v, float v_speed, float v_min, float v_max, String format); /* - return ImGui::DragInt(label, &v[0], v_speed, v_min, v_max, format); - */ - - static native boolean DragInt2(String label, int [] v); /* - return ImGui::DragInt2(label, v); - */ - - static native boolean DragInt2(String label, int [] v, float v_speed, float v_min, float v_max, String format); /* - return ImGui::DragInt2(label, v, v_speed, v_min, v_max, format); - */ - - static native boolean DragInt3(String label, int [] v); /* - return ImGui::DragInt2(label, v); - */ - - static native boolean DragInt3(String label, int [] v, float v_speed, float v_min, float v_max, String format); /* - return ImGui::DragInt2(label, v, v_speed, v_min, v_max, format); - */ - - static native boolean DragInt4(String label, int [] v); /* - return ImGui::DragInt4(label, v); - */ - - static native boolean DragInt4(String label, int [] v, float v_speed, float v_min, float v_max, String format); /* - return ImGui::DragInt4(label, v, v_speed, v_min, v_max, format); - */ - - static native boolean DragIntRange2(String label, int [] v_current_min, int [] v_current_max); /* - return ImGui::DragIntRange2(label, &v_current_min[0], &v_current_max[0]); - */ - - static native boolean DragIntRange2(String label, int [] v_current_min, int [] v_current_max, float v_speed, float v_min, float v_max, String format, String format_max); /* - return ImGui::DragIntRange2(label, &v_current_min[0], &v_current_max[0], v_speed, v_min, v_max, format, format_max); - */ - - //TODO impl other types - static native boolean DragScalar(String label, int data_type, int[] v, float v_speed); /* - return ImGui::DragScalar(label, data_type, &v[0], v_speed); - */ - - // Widgets: Sliders - // - CTRL+Click on any slider to turn them into an input box. Manually input values aren't clamped and can go off-bounds. - // - Adjust format string to decorate the value with a prefix, a suffix, or adapt the editing and display precision e.g. "%.3f" -> 1.234; "%5.2f secs" -> 01.23 secs; "Biscuit: %.0f" -> Biscuit: 1; etc. - - //TODO impl other types - static native boolean DragScalar(String label, int data_type, int[] v, float v_speed, float v_min, float v_max, String format, float power); /* - return ImGui::DragScalar(label, data_type, &v[0], v_speed, &v_min, &v_max, format, power); - */ - - static native boolean SliderFloat(String label, float [] v, float v_min, float v_max); /* - return ImGui::SliderFloat(label, &v[0],v_min, v_max); - */ - - static native boolean SliderFloat(String label, float [] v, float v_min, float v_max, String format); /* - return ImGui::SliderFloat(label, &v[0], v_min, v_max, format); - */ - - static native boolean SliderFloat(String label, float [] v, float v_min, float v_max, String format, float power); /* - return ImGui::SliderFloat(label, &v[0], v_min, v_max, format, power); - */ - - static native boolean SliderFloat2(String label, float [] v, float v_min, float v_max); /* - return ImGui::SliderFloat2(label, v, v_min, v_max); - */ - - static native boolean SliderFloat2(String label, float [] v, float v_min, float v_max, String format, float power); /* - return ImGui::SliderFloat2(label, v, v_min, v_max, format, power); - */ - - static native boolean SliderFloat3(String label, float [] v, float v_min, float v_max); /* - return ImGui::SliderFloat3(label, v, v_min, v_max); - */ - - static native boolean SliderFloat3(String label, float [] v, float v_min, float v_max, String format, float power); /* - return ImGui::SliderFloat3(label, v, v_min, v_max, format, power); - */ - - static native boolean SliderFloat4(String label, float [] v, float v_min, float v_max); /* - return ImGui::SliderFloat4(label, v, v_min, v_max); - */ - - static native boolean SliderFloat4(String label, float [] v, float v_min, float v_max, String format, float power); /* - return ImGui::SliderFloat4(label, v, v_min, v_max, format, power); - */ - - static native boolean SliderAngle(String label, float [] v_rad); /* - return ImGui::SliderAngle(label, &v_rad[0]); - */ - - static native boolean SliderAngle(String label, float [] v_rad, float v_degrees_min, float v_degrees_max, String format); /* - return ImGui::SliderAngle(label, &v_rad[0], v_degrees_min, v_degrees_max, format); - */ - - static native boolean SliderInt(String label, int [] v, int v_min, int v_max); /* - return ImGui::SliderInt(label, &v[0], v_min, v_max); - */ - - static native boolean SliderInt(String label, int [] v, int v_min, int v_max, String format); /* - return ImGui::SliderInt(label, &v[0], v_min, v_max, format); - */ - - static native boolean SliderInt2(String label, int [] v, int v_min, int v_max); /* - return ImGui::SliderInt2(label, v, v_min, v_max); - */ - - static native boolean SliderInt2(String label, int [] v, int v_min, int v_max, String format); /* - return ImGui::SliderInt2(label, v, v_min, v_max, format); - */ - - static native boolean SliderInt3(String label, int [] v, int v_min, int v_max); /* - return ImGui::SliderInt3(label, v, v_min, v_max); - */ - - static native boolean SliderInt3(String label, int [] v, int v_min, int v_max, String format); /* - return ImGui::SliderInt3(label, v, v_min, v_max, format); - */ - - static native boolean SliderInt4(String label, int [] v, int v_min, int v_max); /* - return ImGui::SliderInt4(label, v, v_min, v_max); - */ - - static native boolean SliderInt4(String label, int [] v, int v_min, int v_max, String format); /* - return ImGui::SliderInt4(label, v, v_min, v_max, format); - */ - - //TODO impl other types - static native boolean SliderScalar(String label, int data_type, int[] v, int v_min, int v_max); /* - return ImGui::SliderScalar(label, data_type, &v[0], &v_min, &v_max); - */ - - static native boolean SliderScalar(String label, int data_type, int[] v, float v_min, float v_max, String format, float power); /* - return ImGui::SliderScalar(label, data_type, &v[0], &v_min, &v_max, format, power); - */ - - static native boolean SliderScalar(String label, int data_type, float[] v, float v_min, float v_max); /* - return ImGui::SliderScalar(label, data_type, &v[0], &v_min, &v_max); - */ - - static native boolean SliderScalar(String label, int data_type, float[] v, float v_min, float v_max, String format, float power); /* - return ImGui::SliderScalar(label, data_type, &v[0], &v_min, &v_max, format, power); - */ - - static native boolean VSliderFloat(String label, float sizeX, float sizeY, float [] v, float v_min, float v_max); /* - return ImGui::VSliderFloat(label, ImVec2(sizeX, sizeY), &v[0], v_min, v_max); - */ - - static native boolean VSliderFloat(String label, float sizeX, float sizeY, float [] v, float v_min, float v_max, String format, float power); /* - return ImGui::VSliderFloat(label, ImVec2(sizeX, sizeY), &v[0], v_min, v_max, format, power); - */ - - static native boolean VSliderInt(String label, float sizeX, float sizeY, int [] v, int v_min, int v_max); /* - return ImGui::VSliderInt(label, ImVec2(sizeX, sizeY), &v[0], v_min, v_max); - */ - - static native boolean VSliderInt(String label, float sizeX, float sizeY, int [] v, int v_min, int v_max, String format); /* - return ImGui::VSliderInt(label, ImVec2(sizeX, sizeY), &v[0], v_min, v_max, format); - */ - - //TODO impl other types - static native boolean VSliderScalar(String label, float sizeX, float sizeY, int data_type, int [] v, int v_min, int v_max); /* - return ImGui::VSliderScalar(label, ImVec2(sizeX, sizeY), data_type, &v[0], &v_min, &v_max); - */ - - static native boolean VSliderScalar(String label, float sizeX, float sizeY, int data_type, int [] v, int v_min, int v_max, String format, float power); /* - return ImGui::VSliderScalar(label, ImVec2(sizeX, sizeY), data_type, &v[0], &v_min, &v_max, format, power); - */ - - static native boolean VSliderScalar(String label, float sizeX, float sizeY, int data_type, float [] v, float v_min, float v_max); /* - return ImGui::VSliderScalar(label, ImVec2(sizeX, sizeY), data_type, &v[0], &v_min, &v_max); - */ - - // Widgets: Input with Keyboard - // - If you want to use InputText() with a dynamic string type such as std::string or your own, see misc/cpp/imgui_stdlib.h - // - Most of the ImGuiInputTextFlags flags are only useful for InputText() and not for InputFloatX, InputIntX, InputDouble etc. - - /*JNI - - struct InputTextCallback_UserData { - jobject* textInputData; - JNIEnv* env; - int maxChar; - char* allowedChar; - int allowedCharLength; - int maxSize; - int curSize; - }; - - static int TextEditCallbackStub(ImGuiInputTextCallbackData* data) { - InputTextCallback_UserData* userData = (InputTextCallback_UserData*)data->UserData; - - if (data->EventFlag == ImGuiInputTextFlags_CallbackCharFilter) { - if(userData->allowedCharLength > 0) { - bool found = false; - for(int i = 0; i < userData->allowedCharLength; i++) { - if(userData->allowedChar[i] == data->EventChar) { - found = true; - break; - } - } - return found ? 0 : 1; - } - } - - return 0; - } - */ - - static native boolean VSliderScalar(String label, float sizeX, float sizeY, int data_type, float [] v, float v_min, float v_max, String format, float power); /* - return ImGui::VSliderScalar(label, ImVec2(sizeX, sizeY), data_type, &v[0], &v_min, &v_max, format, power); - */ - - static native boolean InputText(String label, byte[] buff, int maxSize, int flags, ImGuiInputTextData textInputData, int maxChar, String allowedChar, int allowedCharLength); /* - int size = (int)strlen(buff); - InputTextCallback_UserData cb_user_data; - cb_user_data.textInputData = &textInputData; - cb_user_data.env = env; - cb_user_data.curSize = size; - cb_user_data.maxSize = maxSize; - cb_user_data.maxChar = maxChar; - cb_user_data.allowedChar = allowedChar; - cb_user_data.allowedCharLength = allowedCharLength; - - char tempArray[maxSize]; - - memset(tempArray, 0, sizeof(tempArray)); - memcpy(tempArray, buff, size); - - if(maxChar >= 0 && maxChar < maxSize) { - maxSize = maxChar; - } - - bool flag = ImGui::InputText(label, tempArray, maxSize, flags | ImGuiInputTextFlags_CallbackCharFilter, &TextEditCallbackStub, &cb_user_data); - - if (flag) { - size = (int)strlen(tempArray); - env->SetIntField (textInputData, imTextInputDataSizeID, size); - env->SetBooleanField (textInputData, imTextInputDataIsDirtyID, true); - memset(buff, 0, maxSize); - memcpy(buff, tempArray, size); - } - - return flag; - */ - - static native boolean InputFloat(String label, float [] v); /* - ImGui::InputFloat(label, &v[0]); - */ - - static native boolean InputFloat(String label, float [] v, float step, float step_fast, String format); /* - ImGui::InputFloat(label, &v[0], step, step_fast, format); - */ - - static native boolean InputFloat(String label, float [] v, float step, float step_fast, String format, int flags); /* - ImGui::InputFloat(label, &v[0], step, step_fast, format, flags); - */ - - static native boolean InputInt(String label, int [] v); /* - ImGui::InputInt(label, &v[0]); - */ - - static native boolean InputInt(String label, int [] v, float step, float step_fast); /* - ImGui::InputInt(label, &v[0], step, step_fast); - */ - - static native boolean InputInt(String label, int [] v, float step, float step_fast, int flags); /* - ImGui::InputInt(label, &v[0], step, step_fast, flags); - */ - - static native boolean InputDouble(String label, double [] v); /* - ImGui::InputDouble(label, &v[0]); - */ - - static native boolean InputDouble(String label, double [] v, float step, float step_fast, String format); /* - ImGui::InputDouble(label, &v[0], step, step_fast, format); - */ - - static native boolean InputDouble(String label, double [] v, float step, float step_fast, String format, int flags); /* - ImGui::InputDouble(label, &v[0], step, step_fast, format, flags); - */ - - // Widgets: Trees - // - TreeNode functions return true when the node is open, in which case you need to also call TreePop() when you are finished displaying the tree node contents. - - static native boolean TreeNode(String label); /* - return ImGui::TreeNode(label); - */ - - static native boolean TreeNode(String str_id, String label); /* - return ImGui::TreeNode(str_id, label); - */ - - static native boolean TreeNode(int ptr_id, String label); /* - return ImGui::TreeNode((void*)(intptr_t)ptr_id, label); - */ - - static native boolean TreeNodeEx(String label); /* - return ImGui::TreeNodeEx(label); - */ - - static native boolean TreeNodeEx(String label, int flags); /* - return ImGui::TreeNodeEx(label, flags); - */ - - static native boolean TreeNodeEx(String str_id, int flags, String label); /* - return ImGui::TreeNodeEx(str_id, flags, label); - */ - - static native boolean TreeNodeEx(int ptr_id, int flags, String label); /* - return ImGui::TreeNodeEx((void*)(intptr_t)ptr_id, flags, label); - */ - - static native void TreePush(); /* - ImGui::TreePush(); - */ - - static native void TreePush(String str_id); /* - ImGui::TreePush(str_id); - */ - - static native void TreePush(int ptr_id); /* - ImGui::TreePush((void*)(intptr_t)ptr_id); - */ - - static native void TreePop(); /* - ImGui::TreePop(); - */ - - static native void TreeAdvanceToLabelPos(); /* - ImGui::TreeAdvanceToLabelPos(); - */ - - static native float GetTreeNodeToLabelSpacing(); /* - return ImGui::GetTreeNodeToLabelSpacing(); - */ - - static native void SetNextTreeNodeOpen(boolean is_open); /* - ImGui::SetNextTreeNodeOpen(is_open); - */ - - static native void SetNextTreeNodeOpen(boolean is_open, int cond); /* - ImGui::SetNextTreeNodeOpen(is_open, cond); - */ - - static native boolean CollapsingHeader(String label); /* - return ImGui::CollapsingHeader(label); - */ - - static native boolean CollapsingHeader(String label, int flags); /* - return ImGui::CollapsingHeader(label, flags); - */ - - static native boolean CollapsingHeader(String label, boolean [] p_open); /* - return ImGui::CollapsingHeader(label, p_open); - */ - - // Widgets: Selectables - // - A selectable highlights when hovered, and can display another color when selected. - // - Neighbors selectable extend their highlight bounds in order to leave no gap between them. - - static native boolean CollapsingHeader(String label, boolean [] p_open, int flags); /* - return ImGui::CollapsingHeader(label, p_open, flags); - */ - - static native boolean Selectable(String label); /* - return ImGui::Selectable(label); - */ - - static native boolean Selectable(String label, boolean selected); /* - return ImGui::Selectable(label, selected); - */ - - static native boolean Selectable(String label, boolean selected, int flags, float sizeX, float sizeY); /* - return ImGui::Selectable(label, selected, flags, ImVec2(sizeX, sizeY)); - */ - - static native boolean Selectable(String label, boolean [] selected); /* - return ImGui::Selectable(label, &selected[0]); - */ - - // Widgets: List Boxes - // - FIXME: To be consistent with all the newer API, ListBoxHeader/ListBoxFooter should in reality be called BeginListBox/EndListBox. Will rename them. - - static native boolean Selectable(String label, boolean [] selected, int flags, float sizeX, float sizeY); /* - return ImGui::Selectable(label, &selected[0], flags, ImVec2(sizeX, sizeY)); - */ - - static native boolean ListBox(String label, int [] current_item, String [] items, int items_count); /* - const char* listbox_items[items_count]; - for(int i = 0; i < items_count; i++) { - jstring string = (jstring) (env->GetObjectArrayElement(items, i)); - const char *rawString = env->GetStringUTFChars(string, 0); - listbox_items[i] = rawString; - } - return ImGui::ListBox(label, ¤t_item[0], listbox_items, items_count); - */ - - static native boolean ListBoxHeader(String label); /* - return ImGui::ListBoxHeader(label); - */ - - static native boolean ListBoxHeader(String label, float sizeX, float sizeY); /* - return ImGui::ListBoxHeader(label, ImVec2(sizeX, sizeY)); - */ - - static native boolean ListBoxHeader(String label, int items_count); /* - return ImGui::ListBoxHeader(label, items_count); - */ - - static native boolean ListBoxHeader(String label, int items_count, int height_in_items); /* - return ImGui::ListBoxHeader(label, items_count, height_in_items); - */ - - // Widgets: Menus - - static native void ListBoxFooter(); /* - ImGui::ListBoxFooter(); - */ - - static native boolean BeginMainMenuBar(); /* - return ImGui::BeginMainMenuBar(); - */ - - static native void EndMainMenuBar(); /* - ImGui::EndMainMenuBar(); - */ - - static native boolean BeginMenuBar(); /* - return ImGui::BeginMenuBar(); - */ - - static native void EndMenuBar(); /* - ImGui::EndMenuBar(); - */ - - static native boolean BeginMenu(String label); /* - return ImGui::BeginMenu(label); - */ - - static native boolean BeginMenu(String label, boolean enabled); /* - return ImGui::BeginMenu(label, enabled); - */ - - static native void EndMenu(); /* - ImGui::EndMenu(); - */ - - static native boolean MenuItem(String label); /* - return ImGui::MenuItem(label); - */ - - static native boolean MenuItem(String label, String shortcut, boolean selected, boolean enabled); /* - return ImGui::MenuItem(label, shortcut, selected, enabled); - */ - - static native boolean MenuItem(String label, String shortcut, boolean [] p_selected); /* - return ImGui::MenuItem(label, shortcut, &p_selected[0]); - */ - - // Tooltips - - static native boolean MenuItem(String label, String shortcut, boolean [] p_selected, boolean enabled); /* - return ImGui::MenuItem(label, shortcut, &p_selected[0], enabled); - */ - - static native void BeginTooltip(); /* - ImGui::BeginTooltip(); - */ - - static native void EndTooltip(); /* - ImGui::EndTooltip(); - */ - - // Popups, Modals - // The properties of popups windows are: - // - They block normal mouse hovering detection outside them. (*) - // - Unless modal, they can be closed by clicking anywhere outside them, or by pressing ESCAPE. - // - Their visibility state (~bool) is held internally by imgui instead of being held by the programmer as we are used to with regular Begin() calls. - // User can manipulate the visibility state by calling OpenPopup(). - // (*) One can use IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup) to bypass it and detect hovering even when normally blocked by a popup. - // Those three properties are connected. The library needs to hold their visibility state because it can close popups at any time. - - static native void SetTooltip(String text); /* - ImGui::SetTooltip(text); - */ - - static native void OpenPopup(String str_id); /* - ImGui::OpenPopup(str_id); - */ - - static native boolean BeginPopup(String str_id); /* - return ImGui::BeginPopup(str_id); - */ - - static native boolean BeginPopup(String str_id, int flags); /* - return ImGui::BeginPopup(str_id, flags); - */ - - static native boolean BeginPopupContextItem(); /* - return ImGui::BeginPopupContextItem(); - */ - - static native boolean BeginPopupContextItem(String str_id, int mouse_button); /* - return ImGui::BeginPopupContextItem(str_id, mouse_button); - */ - - static native boolean BeginPopupContextWindow(); /* - return ImGui::BeginPopupContextWindow(); - */ - - static native boolean BeginPopupContextWindow(String str_id, int mouse_button, boolean also_over_items); /* - return ImGui::BeginPopupContextWindow(str_id, mouse_button, also_over_items); - */ - - static native boolean BeginPopupContextVoid(); /* - return ImGui::BeginPopupContextVoid(); - */ - - static native boolean BeginPopupContextVoid(String str_id, int mouse_button); /* - return ImGui::BeginPopupContextVoid(str_id, mouse_button); - */ - - static native boolean BeginPopupModal(String name); /* - return ImGui::BeginPopupModal(name); - */ - - static native boolean BeginPopupModal(String name, boolean [] p_open, int flags); /* - return ImGui::BeginPopupModal(name, &p_open[0], flags); - */ - - static native void EndPopup(); /* - ImGui::EndPopup(); - */ - - static native boolean OpenPopupOnItemClick(); /* - return ImGui::OpenPopupOnItemClick(); - */ - - static native boolean OpenPopupOnItemClick(String str_id, int mouse_button); /* - return ImGui::OpenPopupOnItemClick(str_id, mouse_button); - */ - - static native boolean IsPopupOpen(String str_id); /* - return ImGui::IsPopupOpen(str_id); - */ - - // Columns - // - You can also use SameLine(pos_x) to mimic simplified columns. - // - The columns API is work-in-progress and rather lacking (columns are arguably the worst part of dear imgui at the moment!) - - static native void CloseCurrentPopup(); /* - ImGui::CloseCurrentPopup(); - */ - - static native void Columns(); /* - ImGui::Columns(); - */ - - static native void Columns(int count); /* - ImGui::Columns(count); - */ - - static native void Columns(int count, String id); /* - ImGui::Columns(count, id); - */ - - static native void Columns(int count, String id, boolean border); /* - ImGui::Columns(count, id, border); - */ - - static native void NextColumn(); /* - ImGui::NextColumn(); - */ - - static native int GetColumnIndex(); /* - return ImGui::GetColumnIndex(); - */ - - static native float GetColumnWidth(); /* - return ImGui::GetColumnWidth(); - */ - - static native float GetColumnWidth(int column_index); /* - return ImGui::GetColumnWidth(column_index); - */ - - static native void SetColumnWidth(int column_index, float width); /* - ImGui::SetColumnWidth(column_index, width); - */ - - static native float GetColumnOffset(); /* - return ImGui::GetColumnOffset(); - */ - - static native float GetColumnOffset(int column_index); /* - return ImGui::GetColumnOffset(column_index); - */ - - static native void SetColumnOffset(int column_index, float offset_x); /* - ImGui::SetColumnOffset(column_index, offset_x); - */ - - // Tab Bars, Tabs - // [BETA API] API may evolve! - - static native int GetColumnsCount(); /* - return ImGui::GetColumnsCount(); - */ - - static native boolean BeginTabBar(String str_id); /* - return ImGui::BeginTabBar(str_id); - */ - - static native boolean BeginTabBar(String str_id, int flags); /* - return ImGui::BeginTabBar(str_id, flags); - */ - - static native void EndTabBar(); /* - ImGui::EndTabBar(); - */ - - static native boolean BeginTabItem(String label); /* - return ImGui::BeginTabItem(label); - */ - - static native boolean BeginTabItem(String label, boolean [] p_open, int flags); /* - return ImGui::BeginTabItem(label, &p_open[0], flags); - */ - - static native void EndTabItem(); /* - ImGui::EndTabItem(); - */ - - // Docking - // [BETA API] Enable with io.ConfigFlags |= ImGuiConfigFlags_DockingEnable. - // Note: you DO NOT need to call DockSpace() to use most Docking facilities! - // To dock windows: if io.ConfigDockingWithShift == false: drag window from their title bar. - // To dock windows: if io.ConfigDockingWithShift == true: hold SHIFT anywhere while moving windows. - // Use DockSpace() to create an explicit dock node _within_ an existing window. See Docking demo for details. - - static native void SetTabItemClosed(String tab_or_docked_window_label); /* - ImGui::SetTabItemClosed(tab_or_docked_window_label); - */ - - // TODO: Available after docking comes from BETA -// static native void DockSpace(int id); /* -// ImGui::DockSpace(id); -// */ - - // TODO: Available after docking comes from BETA -// static native void DockSpace(int id, float sizeX, float sizeY); /* -// ImGui::DockSpace(id, ImVec2(sizeX, sizeY)); -// */ - - // Focus, Activation - // - Prefer using "SetItemDefaultFocus()" over "if (IsWindowAppearing()) SetScrollHereY()" when applicable to signify "this is the default item" - - // TODO: Available after docking comes from BETA -// static native void DockSpace(int id, float sizeX, float sizeY, int flags); /* -// ImGui::DockSpace(id, ImVec2(sizeX, sizeY), flags); -// */ - - static native void SetItemDefaultFocus(); /* - ImGui::SetItemDefaultFocus(); - */ - - static native boolean SetKeyboardFocusHere(); /* - ImGui::SetKeyboardFocusHere(); - */ - - // Item/Widgets Utilities - // - Most of the functions are referring to the last/previous item we submitted. - // - See Demo Window under "Widgets->Querying Status" for an interactive visualization of most of those functions. - - static native boolean SetKeyboardFocusHere(int offset); /* - ImGui::SetKeyboardFocusHere(offset); - */ - - static native boolean IsItemHovered(); /* - return ImGui::IsItemHovered(); - */ - - static native boolean IsItemHovered(int flags); /* - return ImGui::IsItemHovered(flags); - */ - - static native boolean IsItemActive(); /* - return ImGui::IsItemActive(); - */ - - static native boolean IsItemFocused(); /* - return ImGui::IsItemFocused(); - */ - - static native boolean IsItemClicked(); /* - return ImGui::IsItemClicked(); - */ - - static native boolean IsItemClicked(int mouse_button); /* - return ImGui::IsItemClicked(mouse_button); - */ - - static native boolean IsItemVisible(); /* - return ImGui::IsItemVisible(); - */ - - static native boolean IsItemEdited(); /* - return ImGui::IsItemEdited(); - */ - - static native boolean IsItemActivated(); /* - return ImGui::IsItemActivated(); - */ - - static native boolean IsItemDeactivated(); /* - return ImGui::IsItemDeactivated(); - */ - - static native boolean IsItemDeactivatedAfterEdit(); /* - return ImGui::IsItemDeactivatedAfterEdit(); - */ - - static native boolean IsAnyItemHovered(); /* - return ImGui::IsAnyItemHovered(); - */ - - static native boolean IsAnyItemActive(); /* - return ImGui::IsAnyItemActive(); - */ - - static native boolean IsAnyItemFocused(); /* - return ImGui::IsAnyItemFocused(); - */ - - static native void GetItemRectMin(ImVec2 jImVec2); /* - ImVec2 vec = ImGui::GetItemRectMin(); - env->SetFloatField (jImVec2, imVec2XID, vec.x); - env->SetFloatField (jImVec2, imVec2YID, vec.y); - */ - - static native void GetItemRectMax(ImVec2 jImVec2); /* - ImVec2 vec = ImGui::GetItemRectMax(); - env->SetFloatField (jImVec2, imVec2XID, vec.x); - env->SetFloatField (jImVec2, imVec2YID, vec.y); - */ - - static native void GetItemRectSize(ImVec2 jImVec2); /* - ImVec2 vec = ImGui::GetItemRectSize(); - env->SetFloatField (jImVec2, imVec2XID, vec.x); - env->SetFloatField (jImVec2, imVec2YID, vec.y); - */ - - // Miscellaneous Utilities - - static native void SetItemAllowOverlap(); /* - ImGui::SetItemAllowOverlap(); - */ - - static native boolean BeginChildFrame(int id, float width, float height); /* - return ImGui::BeginChildFrame(id, ImVec2(width, height)); - */ - - static native boolean BeginChildFrame(int id, float width, float height, int flags); /* - return ImGui::BeginChildFrame(id, ImVec2(width, height), flags); - */ - - // Inputs Utilities - - static native void EndChildFrame(); /* - ImGui::EndChildFrame(); - */ - - static native boolean IsMouseDown(int button); /* - return ImGui::IsMouseDown(button); - */ - - static native boolean IsMouseClicked(int button); /* - return ImGui::IsMouseClicked(button); - */ - - static native boolean IsMouseClicked(int button, boolean repeat); /* - return ImGui::IsMouseClicked(button, repeat); - */ - - static native boolean IsMouseReleased(int button); /* - return ImGui::IsMouseReleased(button); - */ - - static native boolean IsMouseDragging(); /* - return ImGui::IsMouseDragging(); - */ - - static native boolean IsMouseDragging(int button); /* - return ImGui::IsMouseDragging(button); - */ - - static native boolean IsMouseDragging(int button, float lock_threshold); /* - return ImGui::IsMouseDragging(button, lock_threshold); - */ - - static native boolean IsMouseHoveringRect(float minX, float minY, float maxX, float maxY); /* - return ImGui::IsMouseHoveringRect(ImVec2(minX, minY), ImVec2(maxX, maxY)); - */ - - static native boolean IsMouseHoveringRect(float minX, float minY, float maxX, float maxY, boolean clip); /* - return ImGui::IsMouseHoveringRect(ImVec2(minX, minY), ImVec2(maxX, maxY), clip); - */ - - static native int GetMouseCursor(); /* - return (int)ImGui::GetMouseCursor(); - */ - - static native void SetMouseCursor(int type); /* - ImGui::SetMouseCursor(type); - */ - - // @formatter:on -} diff --git a/imgui-binding/src/main/java/imgui/TexDataRGBA32.java b/imgui-binding/src/main/java/imgui/TexDataRGBA32.java index 63c15ae..e655455 100644 --- a/imgui-binding/src/main/java/imgui/TexDataRGBA32.java +++ b/imgui-binding/src/main/java/imgui/TexDataRGBA32.java @@ -1,18 +1,48 @@ package imgui; +import java.nio.Buffer; import java.nio.ByteBuffer; import java.nio.ByteOrder; -public class TexDataRGBA32 { +public final class TexDataRGBA32 { public int width; public int height; public ByteBuffer pixelBuffer; - public TexDataRGBA32() { + private TexDataRGBA32() { int pixelMax = 131072; - ByteBuffer buffer = ByteBuffer.allocateDirect(pixelMax); - buffer.order(ByteOrder.nativeOrder()); - pixelBuffer = buffer; + pixelBuffer = ByteBuffer.allocateDirect(pixelMax).order(ByteOrder.nativeOrder()); } + + public static TexDataRGBA32 create() { + TexDataRGBA32 data = new TexDataRGBA32(); + data.nFillData(data.pixelBuffer); + return data; + } + + /*JNI + #include + */ + + private native void nFillData(Buffer pixelBuffer); /* + jclass jTexDataClass = env->GetObjectClass(object); + + if(jTexDataClass == NULL) + return; + + jfieldID widthID = env->GetFieldID(jTexDataClass, "width", "I"); + jfieldID heightID = env->GetFieldID(jTexDataClass, "height", "I"); + + unsigned char* pixels; + int width, height; + + ImGuiIO& io = ImGui::GetIO(); + io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); + + env->SetIntField(object, widthID, width); + env->SetIntField(object, heightID, height); + + memcpy(pixelBuffer, pixels, width * height * 4); + */ } diff --git a/imgui-binding/src/main/java/imgui/enums/ImDrawCornerFlags.java b/imgui-binding/src/main/java/imgui/enums/ImDrawCornerFlags.java index 3fb772a..0e5abae 100644 --- a/imgui-binding/src/main/java/imgui/enums/ImDrawCornerFlags.java +++ b/imgui-binding/src/main/java/imgui/enums/ImDrawCornerFlags.java @@ -1,6 +1,6 @@ package imgui.enums; -public class ImDrawCornerFlags { +public final class ImDrawCornerFlags { public static ImDrawCornerFlags TopLeft = new ImDrawCornerFlags(1 << 0); public static ImDrawCornerFlags TopRight = new ImDrawCornerFlags(1 << 1); public static ImDrawCornerFlags BotLeft = new ImDrawCornerFlags(1 << 2); diff --git a/imgui-binding/src/main/java/imgui/enums/ImGuiBackendFlags.java b/imgui-binding/src/main/java/imgui/enums/ImGuiBackendFlags.java index 0941c14..76b3134 100644 --- a/imgui-binding/src/main/java/imgui/enums/ImGuiBackendFlags.java +++ b/imgui-binding/src/main/java/imgui/enums/ImGuiBackendFlags.java @@ -3,7 +3,7 @@ package imgui.enums; /** * Back-end capabilities flags stored in io.BackendFlags. Set by imgui_impl_xxx or custom back-end. */ -public class ImGuiBackendFlags { +public final class ImGuiBackendFlags { public static ImGuiBackendFlags None = new ImGuiBackendFlags(0); public static ImGuiBackendFlags HasGamepad = new ImGuiBackendFlags(1 << 0); public static ImGuiBackendFlags HasMouseCursors = new ImGuiBackendFlags(1 << 1); diff --git a/imgui-binding/src/main/java/imgui/enums/ImGuiColorEditFlags.java b/imgui-binding/src/main/java/imgui/enums/ImGuiColorEditFlags.java index 5c7b8d7..7b27e87 100644 --- a/imgui-binding/src/main/java/imgui/enums/ImGuiColorEditFlags.java +++ b/imgui-binding/src/main/java/imgui/enums/ImGuiColorEditFlags.java @@ -4,7 +4,7 @@ package imgui.enums; * Enumeration for GetMouseCursor() * User code may request binding to display given cursor by calling SetMouseCursor(), which is why we have some cursors that are marked unused here */ -public class ImGuiColorEditFlags { +public final class ImGuiColorEditFlags { public static ImGuiColorEditFlags None = new ImGuiColorEditFlags(0); public static ImGuiColorEditFlags NoAlpha = new ImGuiColorEditFlags(1 << 1); public static ImGuiColorEditFlags NoPicker = new ImGuiColorEditFlags(1 << 2); diff --git a/imgui-binding/src/main/java/imgui/enums/ImGuiComboFlags.java b/imgui-binding/src/main/java/imgui/enums/ImGuiComboFlags.java index be97ac5..1a6d8e0 100644 --- a/imgui-binding/src/main/java/imgui/enums/ImGuiComboFlags.java +++ b/imgui-binding/src/main/java/imgui/enums/ImGuiComboFlags.java @@ -3,7 +3,7 @@ package imgui.enums; /** * Flags for ImGui::BeginCombo() */ -public class ImGuiComboFlags { +public final class ImGuiComboFlags { public static ImGuiComboFlags None = new ImGuiComboFlags(0); public static ImGuiComboFlags PopupAlignLeft = new ImGuiComboFlags(1 << 0); public static ImGuiComboFlags HeightSmall = new ImGuiComboFlags(1 << 1); diff --git a/imgui-binding/src/main/java/imgui/enums/ImGuiCond.java b/imgui-binding/src/main/java/imgui/enums/ImGuiCond.java index 85d6405..1ef2c93 100644 --- a/imgui-binding/src/main/java/imgui/enums/ImGuiCond.java +++ b/imgui-binding/src/main/java/imgui/enums/ImGuiCond.java @@ -5,7 +5,7 @@ package imgui.enums; * Represent a condition. * Important: Treat as a regular enum! Do NOT combine multiple values using binary operators! All the functions above treat 0 as a shortcut to ImGuiCond_Always. */ -public class ImGuiCond { +public final class ImGuiCond { public static ImGuiCond Always = new ImGuiCond(1 << 0); public static ImGuiCond Once = new ImGuiCond(1 << 1); public static ImGuiCond FirstUseEver = new ImGuiCond(1 << 2); diff --git a/imgui-binding/src/main/java/imgui/enums/ImGuiConfigFlags.java b/imgui-binding/src/main/java/imgui/enums/ImGuiConfigFlags.java index 0796c2d..7b8a758 100644 --- a/imgui-binding/src/main/java/imgui/enums/ImGuiConfigFlags.java +++ b/imgui-binding/src/main/java/imgui/enums/ImGuiConfigFlags.java @@ -3,7 +3,7 @@ package imgui.enums; /** * Configuration flags stored in io.ConfigFlags. Set by user/application. */ -public class ImGuiConfigFlags { +public final class ImGuiConfigFlags { public static ImGuiConfigFlags None = new ImGuiConfigFlags(0); public static ImGuiConfigFlags NavEnableKeyboard = new ImGuiConfigFlags(1 << 0); public static ImGuiConfigFlags NavEnableGamepad = new ImGuiConfigFlags(1 << 1); diff --git a/imgui-binding/src/main/java/imgui/enums/ImGuiDir.java b/imgui-binding/src/main/java/imgui/enums/ImGuiDir.java index d639acf..b07ad48 100644 --- a/imgui-binding/src/main/java/imgui/enums/ImGuiDir.java +++ b/imgui-binding/src/main/java/imgui/enums/ImGuiDir.java @@ -8,7 +8,7 @@ public enum ImGuiDir { Down(3), COUNT(4); - private final int code; + private int code; ImGuiDir(int code) { this.code = code; diff --git a/imgui-binding/src/main/java/imgui/enums/ImGuiDockNodeFlags.java b/imgui-binding/src/main/java/imgui/enums/ImGuiDockNodeFlags.java index c14384f..d972963 100644 --- a/imgui-binding/src/main/java/imgui/enums/ImGuiDockNodeFlags.java +++ b/imgui-binding/src/main/java/imgui/enums/ImGuiDockNodeFlags.java @@ -1,6 +1,6 @@ package imgui.enums; -public class ImGuiDockNodeFlags { +public final class ImGuiDockNodeFlags { public static ImGuiDockNodeFlags KeepAliveOnly = new ImGuiDockNodeFlags(1 << 0); public static ImGuiDockNodeFlags NoDockingInCentralNode = new ImGuiDockNodeFlags(1 << 2); public static ImGuiDockNodeFlags PassthruCentralNode = new ImGuiDockNodeFlags(1 << 3); diff --git a/imgui-binding/src/main/java/imgui/enums/ImGuiDragDropFlags.java b/imgui-binding/src/main/java/imgui/enums/ImGuiDragDropFlags.java index fb797af..3740f40 100644 --- a/imgui-binding/src/main/java/imgui/enums/ImGuiDragDropFlags.java +++ b/imgui-binding/src/main/java/imgui/enums/ImGuiDragDropFlags.java @@ -5,7 +5,7 @@ package imgui.enums; * Note: if you are trying to check whether your mouse should be dispatched to imgui or to your app, you should use the 'io.WantCaptureMouse' boolean for that. Please read the FAQ! * Note: windows with the ImGuiWindowFlags_NoInputs flag are ignored by IsWindowHovered() calls. */ -public class ImGuiDragDropFlags { +public final class ImGuiDragDropFlags { public static ImGuiDragDropFlags None = new ImGuiDragDropFlags(0); // BeginDragDropSource() flags public static ImGuiDragDropFlags SourceNoPreviewTooltip = new ImGuiDragDropFlags(1 << 0); diff --git a/imgui-binding/src/main/java/imgui/enums/ImGuiFocusedFlags.java b/imgui-binding/src/main/java/imgui/enums/ImGuiFocusedFlags.java index 101e498..937bf85 100644 --- a/imgui-binding/src/main/java/imgui/enums/ImGuiFocusedFlags.java +++ b/imgui-binding/src/main/java/imgui/enums/ImGuiFocusedFlags.java @@ -3,7 +3,7 @@ package imgui.enums; /** * Flags for ImGui::IsWindowFocused() */ -public class ImGuiFocusedFlags { +public final class ImGuiFocusedFlags { public static ImGuiFocusedFlags None = new ImGuiFocusedFlags(0); public static ImGuiFocusedFlags ChildWindows = new ImGuiFocusedFlags(1 << 0); public static ImGuiFocusedFlags RootWindow = new ImGuiFocusedFlags(1 << 1); diff --git a/imgui-binding/src/main/java/imgui/enums/ImGuiHoveredFlags.java b/imgui-binding/src/main/java/imgui/enums/ImGuiHoveredFlags.java index f6689ef..27c6207 100644 --- a/imgui-binding/src/main/java/imgui/enums/ImGuiHoveredFlags.java +++ b/imgui-binding/src/main/java/imgui/enums/ImGuiHoveredFlags.java @@ -5,7 +5,7 @@ package imgui.enums; * Note: if you are trying to check whether your mouse should be dispatched to imgui or to your app, you should use the 'io.WantCaptureMouse' boolean for that. Please read the FAQ! * Note: windows with the ImGuiWindowFlags_NoInputs flag are ignored by IsWindowHovered() calls. */ -public class ImGuiHoveredFlags { +public final class ImGuiHoveredFlags { public static ImGuiHoveredFlags None = new ImGuiHoveredFlags(0); public static ImGuiHoveredFlags ChildWindows = new ImGuiHoveredFlags(1 << 0); public static ImGuiHoveredFlags RootWindow = new ImGuiHoveredFlags(1 << 1); diff --git a/imgui-binding/src/main/java/imgui/enums/ImGuiInputTextFlags.java b/imgui-binding/src/main/java/imgui/enums/ImGuiInputTextFlags.java index 18c04bd..696630b 100644 --- a/imgui-binding/src/main/java/imgui/enums/ImGuiInputTextFlags.java +++ b/imgui-binding/src/main/java/imgui/enums/ImGuiInputTextFlags.java @@ -3,7 +3,7 @@ package imgui.enums; /** * Flags for ImGui::InputText() */ -public class ImGuiInputTextFlags { +public final class ImGuiInputTextFlags { public static ImGuiInputTextFlags None = new ImGuiInputTextFlags(0); /** * Allow 0123456789.+-* diff --git a/imgui-binding/src/main/java/imgui/enums/ImGuiKey.java b/imgui-binding/src/main/java/imgui/enums/ImGuiKey.java index 74dc6a0..e408384 100644 --- a/imgui-binding/src/main/java/imgui/enums/ImGuiKey.java +++ b/imgui-binding/src/main/java/imgui/enums/ImGuiKey.java @@ -28,5 +28,5 @@ public enum ImGuiKey { Z, COUNT; - public final int code = ordinal(); + public int code = ordinal(); } diff --git a/imgui-binding/src/main/java/imgui/enums/ImGuiMouseCursor.java b/imgui-binding/src/main/java/imgui/enums/ImGuiMouseCursor.java index 75e28a4..613983a 100644 --- a/imgui-binding/src/main/java/imgui/enums/ImGuiMouseCursor.java +++ b/imgui-binding/src/main/java/imgui/enums/ImGuiMouseCursor.java @@ -22,10 +22,6 @@ public enum ImGuiMouseCursor { value = code; } - public int getValue() { - return value; - } - public static ImGuiMouseCursor valueOf(int value) { for (ImGuiMouseCursor cursor : values()) { if (cursor.value == value) { @@ -34,4 +30,8 @@ public enum ImGuiMouseCursor { } throw new IllegalArgumentException("Invalid cursor value: " + value); } + + public int getValue() { + return value; + } } diff --git a/imgui-binding/src/main/java/imgui/enums/ImGuiNavInput.java b/imgui-binding/src/main/java/imgui/enums/ImGuiNavInput.java index d60b8f5..b1e0fb5 100644 --- a/imgui-binding/src/main/java/imgui/enums/ImGuiNavInput.java +++ b/imgui-binding/src/main/java/imgui/enums/ImGuiNavInput.java @@ -22,9 +22,10 @@ public enum ImGuiNavInput { FocusPrev(12), FocusNext(13), TweakSlow(14), - TweakFast(15); + TweakFast(15), + COUNT(16); - private final int code; + private int code; ImGuiNavInput(int code) { this.code = code; diff --git a/imgui-binding/src/main/java/imgui/enums/ImGuiSelectableFlags.java b/imgui-binding/src/main/java/imgui/enums/ImGuiSelectableFlags.java index 2e3623a..b8dfdcf 100644 --- a/imgui-binding/src/main/java/imgui/enums/ImGuiSelectableFlags.java +++ b/imgui-binding/src/main/java/imgui/enums/ImGuiSelectableFlags.java @@ -3,7 +3,7 @@ package imgui.enums; /** * Flags for ImGui::Selectable() */ -public class ImGuiSelectableFlags { +public final class ImGuiSelectableFlags { public static ImGuiSelectableFlags None = new ImGuiSelectableFlags(0); public static ImGuiSelectableFlags DontClosePopups = new ImGuiSelectableFlags(1 << 0); public static ImGuiSelectableFlags SpanAllColumns = new ImGuiSelectableFlags(1 << 1); diff --git a/imgui-binding/src/main/java/imgui/enums/ImGuiTabBarFlags.java b/imgui-binding/src/main/java/imgui/enums/ImGuiTabBarFlags.java index 4ccd908..5072a43 100644 --- a/imgui-binding/src/main/java/imgui/enums/ImGuiTabBarFlags.java +++ b/imgui-binding/src/main/java/imgui/enums/ImGuiTabBarFlags.java @@ -3,7 +3,7 @@ package imgui.enums; /** * Flags for ImGui::BeginTabBar() */ -public class ImGuiTabBarFlags { +public final class ImGuiTabBarFlags { public static ImGuiTabBarFlags None = new ImGuiTabBarFlags(0); public static ImGuiTabBarFlags Reorderable = new ImGuiTabBarFlags(1 << 0); public static ImGuiTabBarFlags AutoSelectNewTabs = new ImGuiTabBarFlags(1 << 1); diff --git a/imgui-binding/src/main/java/imgui/enums/ImGuiTabItemFlags.java b/imgui-binding/src/main/java/imgui/enums/ImGuiTabItemFlags.java index c9fe2cd..abfc2ef 100644 --- a/imgui-binding/src/main/java/imgui/enums/ImGuiTabItemFlags.java +++ b/imgui-binding/src/main/java/imgui/enums/ImGuiTabItemFlags.java @@ -3,7 +3,7 @@ package imgui.enums; /** * Flags for ImGui::BeginTabItem() */ -public class ImGuiTabItemFlags { +public final class ImGuiTabItemFlags { public static ImGuiTabItemFlags None = new ImGuiTabItemFlags(0); public static ImGuiTabItemFlags UnsavedDocument = new ImGuiTabItemFlags(1 << 0); public static ImGuiTabItemFlags SetSelected = new ImGuiTabItemFlags(1 << 1); diff --git a/imgui-binding/src/main/java/imgui/enums/ImGuiTreeNodeFlags.java b/imgui-binding/src/main/java/imgui/enums/ImGuiTreeNodeFlags.java index fb6daca..4f68276 100644 --- a/imgui-binding/src/main/java/imgui/enums/ImGuiTreeNodeFlags.java +++ b/imgui-binding/src/main/java/imgui/enums/ImGuiTreeNodeFlags.java @@ -3,7 +3,7 @@ package imgui.enums; /** * Flags for ImGui::TreeNodeEx(), ImGui::CollapsingHeader*() */ -public class ImGuiTreeNodeFlags { +public final class ImGuiTreeNodeFlags { public static ImGuiTreeNodeFlags None = new ImGuiTreeNodeFlags(0); public static ImGuiTreeNodeFlags Selected = new ImGuiTreeNodeFlags(1 << 0); public static ImGuiTreeNodeFlags Framed = new ImGuiTreeNodeFlags(1 << 1); diff --git a/imgui-binding/src/main/java/imgui/enums/ImGuiWindowFlags.java b/imgui-binding/src/main/java/imgui/enums/ImGuiWindowFlags.java index fca7312..ea58c08 100644 --- a/imgui-binding/src/main/java/imgui/enums/ImGuiWindowFlags.java +++ b/imgui-binding/src/main/java/imgui/enums/ImGuiWindowFlags.java @@ -3,7 +3,7 @@ package imgui.enums; /** * Flags for ImGui::Begin() */ -public class ImGuiWindowFlags { +public final class ImGuiWindowFlags { public static ImGuiWindowFlags None = new ImGuiWindowFlags(0); public static ImGuiWindowFlags NoTitleBar = new ImGuiWindowFlags(1 << 0); public static ImGuiWindowFlags NoResize = new ImGuiWindowFlags(1 << 1); diff --git a/imgui-binding/src/main/java/imgui/enums/ImLayout.java b/imgui-binding/src/main/java/imgui/enums/ImLayout.java index a787fbf..4b4079c 100644 --- a/imgui-binding/src/main/java/imgui/enums/ImLayout.java +++ b/imgui-binding/src/main/java/imgui/enums/ImLayout.java @@ -1,6 +1,6 @@ package imgui.enums; -public class ImLayout { +public final class ImLayout { public static float MATCH_PARENT = -0.1f; public static float WRAP_PARENT = 0.0f; } diff --git a/imgui-binding/src/main/native/jni_common.cpp b/imgui-binding/src/main/native/jni_common.cpp new file mode 100644 index 0000000..85b3955 --- /dev/null +++ b/imgui-binding/src/main/native/jni_common.cpp @@ -0,0 +1,58 @@ +#include "jni_common.h" + +jfieldID imVec2XID; +jfieldID imVec2YID; + +jfieldID imVec4XID; +jfieldID imVec4YID; +jfieldID imVec4ZID; +jfieldID imVec4WID; + +namespace Jni +{ +void InitCommon(JNIEnv* env) { + jclass jImVec2Class = env->FindClass("imgui/ImVec2"); + imVec2XID = env->GetFieldID(jImVec2Class, "x", "F"); + imVec2YID = env->GetFieldID(jImVec2Class, "y", "F"); + + jclass jImVec4Class = env->FindClass("imgui/ImVec4"); + imVec4XID = env->GetFieldID(jImVec4Class, "x", "F"); + imVec4YID = env->GetFieldID(jImVec4Class, "y", "F"); + imVec4ZID = env->GetFieldID(jImVec4Class, "z", "F"); + imVec4WID = env->GetFieldID(jImVec4Class, "w", "F"); +} + +void ImVec2Cpy(JNIEnv* env, ImVec2* src, jobject dst) { + env->SetFloatField(dst, imVec2XID, src->x); + env->SetFloatField(dst, imVec2YID, src->y); +} + +void ImVec2Cpy(JNIEnv* env, ImVec2 src, jobject dst) { + env->SetFloatField(dst, imVec2XID, src.x); + env->SetFloatField(dst, imVec2YID, src.y); +} + +void ImVec2Cpy(JNIEnv* env, jobject src, ImVec2* dst) { + dst->x = env->GetFloatField(src, imVec2XID); + dst->y = env->GetFloatField(src, imVec2YID); +} + +void ImVec2Cpy(JNIEnv* env, jobject src, ImVec2 dst) { + dst.x = env->GetFloatField(src, imVec2XID); + dst.y = env->GetFloatField(src, imVec2YID); +} + +void ImVec4Cpy(JNIEnv* env, ImVec4* src, jobject dst) { + env->SetFloatField(dst, imVec4XID, src->x); + env->SetFloatField(dst, imVec4YID, src->y); + env->SetFloatField(dst, imVec4ZID, src->z); + env->SetFloatField(dst, imVec4WID, src->w); +} + +void ImVec4Cpy(JNIEnv* env, ImVec4 src, jobject dst) { + env->SetFloatField(dst, imVec4XID, src.x); + env->SetFloatField(dst, imVec4YID, src.y); + env->SetFloatField(dst, imVec4ZID, src.z); + env->SetFloatField(dst, imVec4WID, src.w); +} +} diff --git a/imgui-binding/src/main/native/jni_common.h b/imgui-binding/src/main/native/jni_common.h new file mode 100644 index 0000000..2816f0a --- /dev/null +++ b/imgui-binding/src/main/native/jni_common.h @@ -0,0 +1,21 @@ +#include +#include + +#ifndef JNI_COMMON_H +#define JNI_COMMON_H + +namespace Jni +{ +void InitCommon(JNIEnv* env); + +void ImVec2Cpy(JNIEnv* env, ImVec2* src, jobject dst); +void ImVec2Cpy(JNIEnv* env, ImVec2 src, jobject dst); + +void ImVec2Cpy(JNIEnv* env, jobject src, ImVec2* dst); +void ImVec2Cpy(JNIEnv* env, jobject src, ImVec2 dst); + +void ImVec4Cpy(JNIEnv* env, ImVec4* src, jobject dst); +void ImVec4Cpy(JNIEnv* env, ImVec4 src, jobject dst); +} + +#endif diff --git a/imgui-lwjgl3/src/main/java/imgui/gl3/ImGuiImplGl3.java b/imgui-lwjgl3/src/main/java/imgui/gl3/ImGuiImplGl3.java index ab9159e..9cae374 100644 --- a/imgui-lwjgl3/src/main/java/imgui/gl3/ImGuiImplGl3.java +++ b/imgui-lwjgl3/src/main/java/imgui/gl3/ImGuiImplGl3.java @@ -1,6 +1,6 @@ package imgui.gl3; -import imgui.DrawData; +import imgui.ImDrawData; import imgui.ImGui; import imgui.TexDataRGBA32; @@ -59,7 +59,7 @@ public final class ImGuiImplGl3 { private boolean lastEnableScissorTest = false; /** - * This method SHOULD be called before calling of {@link ImGuiImplGl3#render(DrawData)} method. + * This method SHOULD be called before calling of {@link ImGuiImplGl3#render(ImDrawData)} method. */ public void init() { prepareShader(); @@ -67,11 +67,11 @@ public final class ImGuiImplGl3 { } /** - * Method which renders {@link DrawData} from ImGui. + * Method which renders {@link ImDrawData} from ImGui. * * @param drawData data used to draw ImGui interface to your current OpenGL context */ - public void render(final DrawData drawData) { + public void render(final ImDrawData drawData) { if (drawData.cmdListsCount <= 0) { return; } @@ -113,8 +113,8 @@ public final class ImGuiImplGl3 { drawData.vByteBuffer.position(verticesStartOffset); drawData.iByteBuffer.position(indexStartOffset); - final int newVlimit = verticesStartOffset + verticesSize * DrawData.vBufferSize; - final int newIlimit = indexStartOffset + indexSize * DrawData.iBufferSize; + final int newVlimit = verticesStartOffset + verticesSize * ImDrawData.V_BUFFER_SIZE; + final int newIlimit = indexStartOffset + indexSize * ImDrawData.I_BUFFER_SIZE; drawData.vByteBuffer.limit(newVlimit); drawData.iByteBuffer.limit(newIlimit); @@ -122,8 +122,8 @@ public final class ImGuiImplGl3 { glBufferData(GL_ARRAY_BUFFER, drawData.vByteBuffer, GL_STATIC_DRAW); glBufferData(GL_ELEMENT_ARRAY_BUFFER, drawData.iByteBuffer, GL_STATIC_DRAW); - verticesOffset += ((verticesSize) * DrawData.vBufferSize) + 4; - indexOffset += ((indexSize) * DrawData.iBufferSize) + 2; + verticesOffset += ((verticesSize) * ImDrawData.V_BUFFER_SIZE) + 4; + indexOffset += ((indexSize) * ImDrawData.I_BUFFER_SIZE) + 2; final float clipOffX = drawData.displayPosX; // (0,0) unless using multi-viewports final float clipOffY = drawData.displayPosY; @@ -190,8 +190,7 @@ public final class ImGuiImplGl3 { } private void prepareFont() { - final TexDataRGBA32 texData = new TexDataRGBA32(); - ImGui.GetTexDataAsRGBA32(texData, texData.pixelBuffer); + final TexDataRGBA32 texData = TexDataRGBA32.create(); gFontTexture = glGenTextures(); @@ -202,7 +201,7 @@ public final class ImGuiImplGl3 { glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texData.width, texData.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, texData.pixelBuffer); - ImGui.SetFontTexID(gFontTexture); + ImGui.GetIO().SetFontsTexID(gFontTexture); } private void backupGlState() { @@ -244,7 +243,7 @@ public final class ImGuiImplGl3 { glScissor(lastScissorBox[0], lastScissorBox[1], lastScissorBox[2], lastScissorBox[3]); } - private void bind(final DrawData drawData) { + private void bind(final ImDrawData drawData) { glViewport(0, 0, (int) drawData.displaySizeX, (int) drawData.displaySizeY); glActiveTexture(GL_TEXTURE0); glEnable(GL_BLEND); diff --git a/imgui-lwjgl3/src/test/java/ImGuiGlfwExample.java b/imgui-lwjgl3/src/test/java/ImGuiGlfwExample.java index 78f8116..78ef3db 100644 --- a/imgui-lwjgl3/src/test/java/ImGuiGlfwExample.java +++ b/imgui-lwjgl3/src/test/java/ImGuiGlfwExample.java @@ -1,10 +1,14 @@ +import imgui.ImBool; import imgui.ImGui; -import imgui.ImGuiString; +import imgui.ImGuiIO; +import imgui.ImString; +import imgui.enums.ImGuiBackendFlags; +import imgui.enums.ImGuiColorEditFlags; import imgui.enums.ImGuiCond; +import imgui.enums.ImGuiConfigFlags; import imgui.enums.ImGuiInputTextFlags; import imgui.enums.ImGuiKey; import imgui.enums.ImGuiMouseCursor; -import imgui.enums.ImGuiTreeNodeFlags; import imgui.gl3.ImGuiImplGl3; import org.lwjgl.glfw.GLFWErrorCallback; import org.lwjgl.glfw.GLFWVidMode; @@ -25,7 +29,7 @@ public final class ImGuiGlfwExample { private static final int DEFAULT_WIDTH = 1024; private static final int DEFAULT_HEIGHT = 768; - private long window; // current GLFW window ID + private long window; // current GLFW window pointer // Those are used to track window size properties private final int[] winWidth = new int[1]; @@ -37,19 +41,19 @@ public final class ImGuiGlfwExample { private final double[] mousePosX = new double[1]; private final double[] mousePosY = new double[1]; - // TODO move this into ImGuiIO.KeysDown - private boolean ctrlKeyDown; - private boolean shiftKeyDown; - private boolean altKeyDown; - private boolean superKeyDown; - + // Mouse cursors provided by GLFW private final long[] mouseCursors = new long[ImGuiMouseCursor.COUNT.getValue()]; private final ImGuiImplGl3 imGuiGl3 = new ImGuiImplGl3(); // Local app variables go here - private final ImGuiString imguiDemoLink = new ImGuiString("https://raw.githubusercontent.com/ocornut/imgui/v1.74/imgui_demo.cpp"); + private final ImString imguiDemoLink = new ImString("https://raw.githubusercontent.com/ocornut/imgui/v1.74/imgui_demo.cpp"); + private float[] backgroundColor = new float[]{0.5f, 0, 0}; private int clickCount = 0; + private final byte[] testPayload = "Test Payload".getBytes(); + private String dropTargetText = "Drop Here"; + + private final ImBool showDemoWindow = new ImBool(); public void run() { initGlfw(); @@ -116,39 +120,47 @@ public final class ImGuiGlfwExample { private void initImGui() { // IMPORTANT!! // This line is critical for ImGui to work. - // It loads native library, creates ImGui context and does other necessary stuff. - ImGui.init(); + ImGui.CreateContext(); // ImGui provides three different color schemas for styling. We will use the classic one here. ImGui.StyleColorsClassic(); // ImGui.StyleColorsDark(); // This is a default style for ImGui // ImGui.StyleColorsLight(); + // Initialize ImGuiIO config + final ImGuiIO io = ImGui.GetIO(); + + io.setIniFilename(null); + io.setConfigFlags(ImGuiConfigFlags.NavEnableKeyboard.getValue()); + io.setBackendFlags(ImGuiBackendFlags.HasMouseCursors.getValue()); + io.setBackendPlatformName("imgui_java_impl_glfw"); + io.setBackendRendererName("imgui_java_impl_lwjgl"); + // Keyboard mapping. ImGui will use those indices to peek into the io.KeysDown[] array. - final int[] keys = new int[ImGuiKey.COUNT.code]; - keys[ImGuiKey.Tab.code] = GLFW_KEY_TAB; - keys[ImGuiKey.LeftArrow.code] = GLFW_KEY_LEFT; - keys[ImGuiKey.RightArrow.code] = GLFW_KEY_RIGHT; - keys[ImGuiKey.UpArrow.code] = GLFW_KEY_UP; - keys[ImGuiKey.DownArrow.code] = GLFW_KEY_DOWN; - keys[ImGuiKey.PageUp.code] = GLFW_KEY_PAGE_UP; - keys[ImGuiKey.PageDown.code] = GLFW_KEY_PAGE_DOWN; - keys[ImGuiKey.Home.code] = GLFW_KEY_HOME; - keys[ImGuiKey.End.code] = GLFW_KEY_END; - keys[ImGuiKey.Insert.code] = GLFW_KEY_INSERT; - keys[ImGuiKey.Delete.code] = GLFW_KEY_DELETE; - keys[ImGuiKey.Backspace.code] = GLFW_KEY_BACKSPACE; - keys[ImGuiKey.Space.code] = GLFW_KEY_SPACE; - keys[ImGuiKey.Enter.code] = GLFW_KEY_ENTER; - keys[ImGuiKey.Escape.code] = GLFW_KEY_ESCAPE; - keys[ImGuiKey.KeyPadEnter.code] = GLFW_KEY_KP_ENTER; - keys[ImGuiKey.A.code] = GLFW_KEY_A; - keys[ImGuiKey.C.code] = GLFW_KEY_C; - keys[ImGuiKey.V.code] = GLFW_KEY_V; - keys[ImGuiKey.X.code] = GLFW_KEY_X; - keys[ImGuiKey.Y.code] = GLFW_KEY_Y; - keys[ImGuiKey.Z.code] = GLFW_KEY_Z; - ImGui.initKeyMap(keys); + final int[] keyMap = new int[ImGuiKey.COUNT.code]; + keyMap[ImGuiKey.Tab.code] = GLFW_KEY_TAB; + keyMap[ImGuiKey.LeftArrow.code] = GLFW_KEY_LEFT; + keyMap[ImGuiKey.RightArrow.code] = GLFW_KEY_RIGHT; + keyMap[ImGuiKey.UpArrow.code] = GLFW_KEY_UP; + keyMap[ImGuiKey.DownArrow.code] = GLFW_KEY_DOWN; + keyMap[ImGuiKey.PageUp.code] = GLFW_KEY_PAGE_UP; + keyMap[ImGuiKey.PageDown.code] = GLFW_KEY_PAGE_DOWN; + keyMap[ImGuiKey.Home.code] = GLFW_KEY_HOME; + keyMap[ImGuiKey.End.code] = GLFW_KEY_END; + keyMap[ImGuiKey.Insert.code] = GLFW_KEY_INSERT; + keyMap[ImGuiKey.Delete.code] = GLFW_KEY_DELETE; + keyMap[ImGuiKey.Backspace.code] = GLFW_KEY_BACKSPACE; + keyMap[ImGuiKey.Space.code] = GLFW_KEY_SPACE; + keyMap[ImGuiKey.Enter.code] = GLFW_KEY_ENTER; + keyMap[ImGuiKey.Escape.code] = GLFW_KEY_ESCAPE; + keyMap[ImGuiKey.KeyPadEnter.code] = GLFW_KEY_KP_ENTER; + keyMap[ImGuiKey.A.code] = GLFW_KEY_A; + keyMap[ImGuiKey.C.code] = GLFW_KEY_C; + keyMap[ImGuiKey.V.code] = GLFW_KEY_V; + keyMap[ImGuiKey.X.code] = GLFW_KEY_X; + keyMap[ImGuiKey.Y.code] = GLFW_KEY_Y; + keyMap[ImGuiKey.Z.code] = GLFW_KEY_Z; + io.setKeyMap(keyMap); // Mouse cursors mapping mouseCursors[ImGuiMouseCursor.Arrow.getValue()] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR); @@ -162,42 +174,44 @@ public final class ImGuiGlfwExample { // Here goes GLFW callbacks to update user input stuff in ImGui glfwSetKeyCallback(window, (w, key, scancode, action, mods) -> { - final boolean isKeyDown = action == GLFW_PRESS; - - if (key == GLFW_KEY_LEFT_CONTROL || key == GLFW_KEY_RIGHT_CONTROL) { - ctrlKeyDown = isKeyDown; - } else if (key == GLFW_KEY_LEFT_SHIFT || key == GLFW_KEY_RIGHT_SHIFT) { - shiftKeyDown = isKeyDown; - } else if (key == GLFW_KEY_LEFT_ALT || key == GLFW_KEY_RIGHT_ALT) { - altKeyDown = isKeyDown; - } else if (key == GLFW_KEY_LEFT_SUPER || key == GLFW_KEY_RIGHT_SUPER) { - superKeyDown = isKeyDown; + if (action == GLFW_PRESS) { + io.setKeysDown(key, true); + } else if (action == GLFW_RELEASE) { + io.setKeysDown(key, false); } - ImGui.UpdateKey(key, isKeyDown, action == GLFW_RELEASE, ctrlKeyDown, shiftKeyDown, altKeyDown, superKeyDown); + io.setKeyCtrl(io.getKeysDown(GLFW_KEY_LEFT_CONTROL) || io.getKeysDown(GLFW_KEY_RIGHT_CONTROL)); + io.setKeyShift(io.getKeysDown(GLFW_KEY_LEFT_SHIFT) || io.getKeysDown(GLFW_KEY_RIGHT_SHIFT)); + io.setKeyAlt(io.getKeysDown(GLFW_KEY_LEFT_ALT) || io.getKeysDown(GLFW_KEY_RIGHT_ALT)); + io.setKeySuper(io.getKeysDown(GLFW_KEY_LEFT_SUPER) || io.getKeysDown(GLFW_KEY_RIGHT_SUPER)); }); glfwSetCharCallback(window, (w, c) -> { if (c != GLFW_KEY_DELETE) { - ImGui.UpdateKeyTyped(c); + io.AddInputCharacter(c); } }); glfwSetMouseButtonCallback(window, (w, button, action, mods) -> { - final boolean mouseDown0 = button == GLFW_MOUSE_BUTTON_1 && action != GLFW_RELEASE; - final boolean mouseDown1 = button == GLFW_MOUSE_BUTTON_2 && action != GLFW_RELEASE; - final boolean mouseDown2 = button == GLFW_MOUSE_BUTTON_3 && action != GLFW_RELEASE; - final boolean mouseDown3 = button == GLFW_MOUSE_BUTTON_4 && action != GLFW_RELEASE; - final boolean mouseDown4 = button == GLFW_MOUSE_BUTTON_5 && action != GLFW_RELEASE; - final boolean mouseDown5 = button == GLFW_MOUSE_BUTTON_6 && action != GLFW_RELEASE; - ImGui.UpdateMouseState(mouseDown0, mouseDown1, mouseDown2, mouseDown3, mouseDown4, mouseDown5); + final boolean[] mouseDown = new boolean[5]; - if (!ImGui.GetIO().WantCaptureMouse && mouseDown1) { + mouseDown[0] = button == GLFW_MOUSE_BUTTON_1 && action != GLFW_RELEASE; + mouseDown[1] = button == GLFW_MOUSE_BUTTON_2 && action != GLFW_RELEASE; + mouseDown[2] = button == GLFW_MOUSE_BUTTON_3 && action != GLFW_RELEASE; + mouseDown[3] = button == GLFW_MOUSE_BUTTON_4 && action != GLFW_RELEASE; + mouseDown[4] = button == GLFW_MOUSE_BUTTON_5 && action != GLFW_RELEASE; + + io.setMouseDown(mouseDown); + + if (!io.getWantCaptureMouse() && mouseDown[1]) { ImGui.SetWindowFocus(null); } }); - glfwSetScrollCallback(window, (w, xOffset, yOffset) -> ImGui.UpdateScroll((float) xOffset, (float) yOffset)); + glfwSetScrollCallback(window, (w, xOffset, yOffset) -> { + io.setMouseWheelH(io.getMouseWheelH() + (float) xOffset); + io.setMouseWheel(io.getMouseWheel() + (float) yOffset); + }); // Initialize renderer itself imGuiGl3.init(); @@ -206,9 +220,6 @@ public final class ImGuiGlfwExample { private void loop() { double time = 0; // to track our frame delta value - // Set the clear color - glClearColor(0.5f, 0.0f, 0.0f, 0.0f); - // Run the rendering loop until the user has attempted to close the window while (!glfwWindowShouldClose(window)) { // Count frame delta value @@ -216,6 +227,9 @@ public final class ImGuiGlfwExample { final double deltaTime = (time > 0) ? (currentTime - time) : 1f / 60f; time = currentTime; + // Set the clear color + glClearColor(backgroundColor[0], backgroundColor[1], backgroundColor[2], 0.0f); + // Get window size properties and mouse position glfwGetWindowSize(window, winWidth, winHeight); glfwGetFramebufferSize(window, fbWidth, fbHeight); @@ -223,14 +237,15 @@ public final class ImGuiGlfwExample { // IMPORTANT!! // We SHOULD call those methods to update ImGui state for current frame - ImGui.UpdateImGui(); - ImGui.UpdateDisplaySize(winWidth[0], winHeight[0], fbWidth[0], fbHeight[0]); - ImGui.UpdateMousePos((float) mousePosX[0], (float) mousePosY[0]); - ImGui.UpdateDeltaTime((float) deltaTime); + final ImGuiIO io = ImGui.GetIO(); + io.setDisplaySize(winWidth[0], winHeight[0]); + io.setDisplayFramebufferScale((float) fbWidth[0] / winWidth[0], (float) fbHeight[0] / winHeight[0]); + io.setMousePos((float) mousePosX[0], (float) mousePosY[0]); + io.setDeltaTime((float) deltaTime); // Update mouse cursor - final ImGuiMouseCursor imguiCursor = ImGui.GetMouseCursor(); - glfwSetCursor(window, mouseCursors[imguiCursor.getValue()]); + final int imguiCursor = ImGui.GetMouseCursor(); + glfwSetCursor(window, mouseCursors[imguiCursor]); glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL); // Render itself starts here @@ -239,44 +254,13 @@ public final class ImGuiGlfwExample { // IMPORTANT!! // Any ImGui code SHOULD go between NewFrame()/Render() methods ImGui.NewFrame(); - - ImGui.SetNextWindowSize(600, 200, ImGuiCond.Once); - ImGui.SetNextWindowPos(10, 10, ImGuiCond.Once); - - ImGui.Begin("Custom window"); - ImGui.Text("Hello from Java!"); - if (ImGui.Button("Click")) { - clickCount++; - } - if (ImGui.IsItemHovered()) { - ImGui.SetMouseCursor(ImGuiMouseCursor.Hand); - } - ImGui.SameLine(); - ImGui.Text("Count: " + clickCount); - ImGui.Separator(); - - ImGui.BeginChild("##custom_window_child", 200, 50); - if (ImGui.TreeNode("Simple..")) { - ImGui.TreeNodeEx("..tree", ImGuiTreeNodeFlags.Leaf.or(ImGuiTreeNodeFlags.Bullet).or(ImGuiTreeNodeFlags.NoTreePushOnOpen)); - ImGui.TreePop(); - } - ImGui.EndChild(); - - ImGui.Separator(); - ImGui.Text("Consider to look the original ImGui demo: "); - ImGui.SetNextItemWidth(500); - ImGui.InputText("##input_to_copy_link", imguiDemoLink, ImGuiInputTextFlags.ReadOnly); - if (ImGui.IsItemHovered()) { - ImGui.SetMouseCursor(ImGuiMouseCursor.TextInput); - } - ImGui.SameLine(); - ImGui.Text("(?)"); - if (ImGui.IsItemHovered()) { - ImGui.SetTooltip("You can copy and paste this link to browser"); - } + showUi(); ImGui.End(); - ImGui.ShowDemoWindow(); + if (showDemoWindow.get()) { + ImGui.ShowDemoWindow(showDemoWindow); + } + ImGui.Render(); imGuiGl3.render(ImGui.GetDrawData()); // render DrawData from ImGui into our OpenGL context @@ -288,10 +272,61 @@ public final class ImGuiGlfwExample { } } + private void showUi() { + ImGui.SetNextWindowSize(600, 210, ImGuiCond.Once.getValue()); + ImGui.SetNextWindowPos(10, 10, ImGuiCond.FirstUseEver.getValue()); + + ImGui.Begin("Custom window"); + ImGui.Text("Hello from Java!"); + ImGui.Button("Drag me"); + if (ImGui.BeginDragDropSource()) { + ImGui.SetDragDropPayload("payload_type", testPayload, testPayload.length); + ImGui.Text("Drag started"); + ImGui.EndDragDropSource(); + } + ImGui.SameLine(); + ImGui.Text(dropTargetText); + if (ImGui.BeginDragDropTarget()) { + final byte[] payload = ImGui.AcceptDragDropPayload("payload_type"); + if (payload != null) { + dropTargetText = new String(payload); + } + ImGui.EndDragDropTarget(); + } + + ImGui.AlignTextToFramePadding(); + ImGui.Text("Background color:"); + ImGui.SameLine(); + ImGui.ColorEdit3("##click_counter_col", backgroundColor, ImGuiColorEditFlags.NoInputs.or(ImGuiColorEditFlags.NoDragDrop).getValue()); + if (ImGui.Button("Click")) { + clickCount++; + } + if (ImGui.IsItemHovered()) { + ImGui.SetMouseCursor(ImGuiMouseCursor.Hand.getValue()); + } + ImGui.SameLine(); + ImGui.Text("Count: " + clickCount); + ImGui.Checkbox("Show demo window", showDemoWindow); + ImGui.NewLine(); + + ImGui.Separator(); + ImGui.Text("Consider to look the original ImGui demo: "); + ImGui.SetNextItemWidth(500); + ImGui.InputText("##input_to_copy_link", imguiDemoLink, ImGuiInputTextFlags.ReadOnly); + if (ImGui.IsItemHovered()) { + ImGui.SetMouseCursor(ImGuiMouseCursor.TextInput.getValue()); + } + ImGui.SameLine(); + ImGui.Text("(?)"); + if (ImGui.IsItemHovered()) { + ImGui.SetTooltip("You can copy and paste this link to browser"); + } + } + // If you want to clean a room after yourself - do it by yourself private void destroyImGui() { imGuiGl3.dispose(); - ImGui.destroy(); + ImGui.DestroyContext(); } private void destroyGlfw() {