[API] Update imnodes with minimap support (#87)

* Attempt to get imnodes minimap working

* Working minimap

* Bottom right minimap in demo

* Restoring bin/libimgui-java.so

* Fix style issue + typo

* Restoring node editor

* Fix example indents

Co-authored-by: SpaiR <klimbetoo@gmail.com>
This commit is contained in:
TyruiopandSpaiR authored and GitHub committed 2021-12-05 20:32:46 +02:00
1 parent 0d70edc26e
commit a78f0b9e71
8 files changed
+172 -119

No files matched your search

+3 -3
View File
@@ -1,9 +1,6 @@
[submodule "include/imgui"] [submodule "include/imgui"]
path = include/imgui path = include/imgui
url = https://github.com/ocornut/imgui url = https://github.com/ocornut/imgui
[submodule "include/imgui-node-editor"]
path = include/imgui-node-editor
url = https://github.com/thedmd/imgui-node-editor
[submodule "include/imnodes"] [submodule "include/imnodes"]
path = include/imnodes path = include/imnodes
url = https://github.com/Nelarius/imnodes url = https://github.com/Nelarius/imnodes
@@ -19,3 +16,6 @@
[submodule "include/ImGuiFileDialog"] [submodule "include/ImGuiFileDialog"]
path = include/ImGuiFileDialog path = include/ImGuiFileDialog
url = https://github.com/aiekick/ImGuiFileDialog url = https://github.com/aiekick/ImGuiFileDialog
[submodule "include/imgui-node-editor"]
path = include/imgui-node-editor
url = https://github.com/thedmd/imgui-node-editor
@@ -1,6 +1,7 @@
import imgui.extension.imnodes.ImNodes; import imgui.extension.imnodes.ImNodes;
import imgui.extension.imnodes.ImNodesContext; import imgui.extension.imnodes.ImNodesContext;
import imgui.extension.imnodes.flag.ImNodesPinShape; import imgui.extension.imnodes.flag.ImNodesPinShape;
import imgui.extension.imnodes.flag.ImNodesMiniMapLocation;
import imgui.flag.ImGuiCond; import imgui.flag.ImGuiCond;
import imgui.flag.ImGuiMouseButton; import imgui.flag.ImGuiMouseButton;
import imgui.internal.ImGui; import imgui.internal.ImGui;
@@ -70,6 +71,7 @@ public class ExampleImNodes {
final boolean isEditorHovered = ImNodes.isEditorHovered(); final boolean isEditorHovered = ImNodes.isEditorHovered();
ImNodes.miniMap(0.2f, ImNodesMiniMapLocation.BottomRight);
ImNodes.endNodeEditor(); ImNodes.endNodeEditor();
if (ImNodes.isLinkCreated(LINK_A, LINK_B)) { if (ImNodes.isLinkCreated(LINK_A, LINK_B)) {
@@ -24,7 +24,7 @@ public final class ImNodes {
// An editor context corresponds to a set of nodes in a single workspace (created with a single // An editor context corresponds to a set of nodes in a single workspace (created with a single
// Begin/EndNodeEditor pair) // Begin/EndNodeEditor pair)
// //
// By default, the library creates an editor context behind the scenes, so using any of the imnodes // By default, the library creates an editor context behind the scenes, so using any of the ImNodes
// functions doesn't require you to explicitly create a context. // functions doesn't require you to explicitly create a context.
public static ImNodesContext editorContextCreate() { public static ImNodesContext editorContextCreate() {
@@ -40,18 +40,18 @@ public final class ImNodes {
} }
private static native void nEditorContextSet(long ptr); /* private static native void nEditorContextSet(long ptr); /*
imnodes::EditorContextSet((imnodes::EditorContext*)ptr); ImNodes::EditorContextSet((ImNodesEditorContext*)ptr);
*/ */
/** /**
* Initialize the node editor system. * Initialize the node editor system.
*/ */
public static native void createContext(); /* public static native void createContext(); /*
imnodes::CreateContext(); ImNodes::CreateContext();
*/ */
public static native void destroyContext(); /* public static native void destroyContext(); /*
imnodes::DestroyContext(); ImNodes::DestroyContext();
*/ */
/** /**
@@ -63,40 +63,40 @@ public final class ImNodes {
} }
private static native long nGetStyle(); /* private static native long nGetStyle(); /*
return (intptr_t)&imnodes::GetStyle(); return (intptr_t)&ImNodes::GetStyle();
*/ */
// Style presets matching the dear imgui styles of the same name. // Style presets matching the dear imgui styles of the same name.
public static native void styleColorsDark(); /* public static native void styleColorsDark(); /*
imnodes::StyleColorsDark(); ImNodes::StyleColorsDark();
*/ */
public static native void styleColorsClassic(); /* public static native void styleColorsClassic(); /*
imnodes::StyleColorsClassic(); ImNodes::StyleColorsClassic();
*/ */
public static native void styleColorsLight(); /* public static native void styleColorsLight(); /*
imnodes::StyleColorsLight(); ImNodes::StyleColorsLight();
*/ */
/** /**
* Use PushColorStyle and PopColorStyle to modify ImNodesColorStyle mid-frame. * Use PushColorStyle and PopColorStyle to modify ImNodesColorStyle mid-frame.
*/ */
public static native void pushColorStyle(int imNodesStyleColor, int color); /* public static native void pushColorStyle(int imNodesStyleColor, int color); /*
imnodes::PushColorStyle((imnodes::ColorStyle)imNodesStyleColor, color); ImNodes::PushColorStyle((ImNodesCol)imNodesStyleColor, color);
*/ */
public static native void popColorStyle(); /* public static native void popColorStyle(); /*
imnodes::PopColorStyle(); ImNodes::PopColorStyle();
*/ */
public static native void pushStyleVar(int imNodesStyleVar, float value); /* public static native void pushStyleVar(int imNodesStyleVar, float value); /*
imnodes::PushStyleVar((imnodes::StyleVar)imNodesStyleVar, value); ImNodes::PushStyleVar((ImNodesStyleVar)imNodesStyleVar, value);
*/ */
public static native void popStyleVar(); /* public static native void popStyleVar(); /*
imnodes::PopStyleVar(); ImNodes::PopStyleVar();
*/ */
/** /**
@@ -104,19 +104,19 @@ public final class ImNodes {
* will result the node editor grid workspace being rendered. * will result the node editor grid workspace being rendered.
*/ */
public static native void beginNodeEditor(); /* public static native void beginNodeEditor(); /*
imnodes::BeginNodeEditor(); ImNodes::BeginNodeEditor();
*/ */
public static native void endNodeEditor(); /* public static native void endNodeEditor(); /*
imnodes::EndNodeEditor(); ImNodes::EndNodeEditor();
*/ */
public static native void beginNode(int node); /* public static native void beginNode(int node); /*
imnodes::BeginNode(node); ImNodes::BeginNode(node);
*/ */
public static native void endNode(); /* public static native void endNode(); /*
imnodes::EndNode(); ImNodes::EndNode();
*/ */
/** /**
@@ -125,7 +125,7 @@ public final class ImNodes {
* calls. The order of source and target doesn't make a difference for rendering the link. * calls. The order of source and target doesn't make a difference for rendering the link.
*/ */
public static native void link(int id, int source, int target); /* public static native void link(int id, int source, int target); /*
imnodes::Link(id, source, target); ImNodes::Link(id, source, target);
*/ */
/** /**
@@ -134,11 +134,11 @@ public final class ImNodes {
* layout of the node will be incorrect. * layout of the node will be incorrect.
*/ */
public static native void beginNodeTitleBar(); /* public static native void beginNodeTitleBar(); /*
imnodes::BeginNodeTitleBar(); ImNodes::BeginNodeTitleBar();
*/ */
public static native void endNodeTitleBar(); /* public static native void endNodeTitleBar(); /*
imnodes::EndNodeTitleBar(); ImNodes::EndNodeTitleBar();
*/ */
// Attributes are ImGui UI elements embedded within the node. Attributes can have pin shapes // Attributes are ImGui UI elements embedded within the node. Attributes can have pin shapes
@@ -156,11 +156,11 @@ public final class ImNodes {
* attribute activity. * attribute activity.
*/ */
public static native void beginStaticAttribute(int id); /* public static native void beginStaticAttribute(int id); /*
imnodes::BeginStaticAttribute(id); ImNodes::BeginStaticAttribute(id);
*/ */
public static native void endStaticAttribute(); /* public static native void endStaticAttribute(); /*
imnodes::EndStaticAttribute(); ImNodes::EndStaticAttribute();
*/ */
/** /**
@@ -171,11 +171,11 @@ public final class ImNodes {
} }
public static native void beginInputAttribute(int id, int imNodesPinShape); /* public static native void beginInputAttribute(int id, int imNodesPinShape); /*
imnodes::BeginInputAttribute(id, (imnodes::PinShape)imNodesPinShape); ImNodes::BeginInputAttribute(id, (ImNodesPinShape)imNodesPinShape);
*/ */
public static native void endInputAttribute(); /* public static native void endInputAttribute(); /*
imnodes::EndInputAttribute(); ImNodes::EndInputAttribute();
*/ */
/** /**
@@ -186,18 +186,18 @@ public final class ImNodes {
} }
public static native void beginOutputAttribute(int id, int imNodesPinShape); /* public static native void beginOutputAttribute(int id, int imNodesPinShape); /*
imnodes::BeginOutputAttribute(id, (imnodes::PinShape)imNodesPinShape); ImNodes::BeginOutputAttribute(id, (ImNodesPinShape)imNodesPinShape);
*/ */
/** /**
* Push a single AttributeFlags value. By default, only AttributeFlags_None is set. * Push a single AttributeFlags value. By default, only AttributeFlags_None is set.
*/ */
public static native void pushAttributeFlag(int imNodesAttributeFlags); /* public static native void pushAttributeFlag(int imNodesAttributeFlags); /*
imnodes::PushAttributeFlag((imnodes::AttributeFlags)imNodesAttributeFlags); ImNodes::PushAttributeFlag((ImNodesAttributeFlags)imNodesAttributeFlags);
*/ */
public static native void endOutputAttribute(); /* public static native void endOutputAttribute(); /*
imnodes::EndOutputAttribute(); ImNodes::EndOutputAttribute();
*/ */
/** /**
@@ -205,22 +205,22 @@ public final class ImNodes {
* blocked by any other windows. * blocked by any other windows.
*/ */
public static native boolean isEditorHovered(); /* public static native boolean isEditorHovered(); /*
return imnodes::IsEditorHovered(); return ImNodes::IsEditorHovered();
*/ */
// Binding notice: getHoveredNode(), getHoveredLink() and getHoveredPin() // Binding notice: getHoveredNode(), getHoveredLink() and getHoveredPin()
// return id of the hovered object. If there is no such object -1 will be returned. // return id of the hovered object. If there is no such object -1 will be returned.
// Use these functions after endNodeEditor() has been called. // Use these functions after endNodeEditor() has been called.
// //
// These methods implemented instead of the original bool imnodes::IsNodeHovered(int* node_id), // These methods implemented instead of the original bool ImNodes::IsNodeHovered(int* node_id),
// bool imnodes::IsLinkHovered(int* link_id) and bool imnodes::IsPinHovered(int* attribute_id) for convenience. // bool ImNodes::IsLinkHovered(int* link_id) and bool ImNodes::IsPinHovered(int* attribute_id) for convenience.
/** /**
* @return id of the hovered node or -1 if there is no such object * @return id of the hovered node or -1 if there is no such object
*/ */
public static native int getHoveredNode(); /* public static native int getHoveredNode(); /*
int i; int i;
return imnodes::IsNodeHovered(&i) ? i : -1; return ImNodes::IsNodeHovered(&i) ? i : -1;
*/ */
/** /**
@@ -228,7 +228,7 @@ public final class ImNodes {
*/ */
public static native int getHoveredLink(); /* public static native int getHoveredLink(); /*
int i; int i;
return imnodes::IsLinkHovered(&i) ? i : -1; return ImNodes::IsLinkHovered(&i) ? i : -1;
*/ */
/** /**
@@ -236,17 +236,17 @@ public final class ImNodes {
*/ */
public static native int getHoveredPin(); /* public static native int getHoveredPin(); /*
int i; int i;
return imnodes::IsPinHovered(&i) ? i : -1; return ImNodes::IsPinHovered(&i) ? i : -1;
*/ */
/** /**
* Binding notice: getActiveAttribute() returns id the active attribute. If there is no active attribute -1 will be returned. * Binding notice: getActiveAttribute() returns id the active attribute. If there is no active attribute -1 will be returned.
* <p> * <p>
* This method implemented instead of the original bool imnodes::IsAnyAttributeActive(int* attribute_id) for convenience. * This method implemented instead of the original bool ImNodes::IsAnyAttributeActive(int* attribute_id) for convenience.
*/ */
public static native int getActiveAttribute(); /* public static native int getActiveAttribute(); /*
int i; int i;
return imnodes::IsAnyAttributeActive(&i) ? i : -1; return ImNodes::IsAnyAttributeActive(&i) ? i : -1;
*/ */
/** /**
@@ -254,7 +254,7 @@ public final class ImNodes {
* is being pressed over the UI content of the attribute. * is being pressed over the UI content of the attribute.
*/ */
public static native boolean isAttributeActive(); /* public static native boolean isAttributeActive(); /*
return imnodes::IsAttributeActive(); return ImNodes::IsAttributeActive();
*/ */
// Use the following functions to query a change of state for an existing link, or new link. Call // Use the following functions to query a change of state for an existing link, or new link. Call
@@ -268,7 +268,7 @@ public final class ImNodes {
} }
private static native boolean nIsLinkStarted(int[] data); /* private static native boolean nIsLinkStarted(int[] data); /*
return imnodes::IsLinkStarted(&data[0]); return ImNodes::IsLinkStarted(&data[0]);
*/ */
/** /**
@@ -284,7 +284,7 @@ public final class ImNodes {
} }
private static native boolean nIsLinkDropped(int[] data, boolean includingDetachedLinks); /* private static native boolean nIsLinkDropped(int[] data, boolean includingDetachedLinks); /*
return imnodes::IsLinkDropped(&data[0], includingDetachedLinks); return ImNodes::IsLinkDropped(&data[0], includingDetachedLinks);
*/ */
/** /**
@@ -295,7 +295,7 @@ public final class ImNodes {
} }
private static native boolean nIsLinkCreated(int[] sourceAttribute, int[] targetAttribute); /* private static native boolean nIsLinkCreated(int[] sourceAttribute, int[] targetAttribute); /*
return imnodes::IsLinkCreated(&sourceAttribute[0], &targetAttribute[0]); return ImNodes::IsLinkCreated(&sourceAttribute[0], &targetAttribute[0]);
*/ */
public static boolean isLinkCreated(final ImInt startedAtNodeId, final ImInt startedAtAttributeId, public static boolean isLinkCreated(final ImInt startedAtNodeId, final ImInt startedAtAttributeId,
@@ -305,7 +305,7 @@ public final class ImNodes {
} }
private static native boolean nIsLinkCreated(int[] startedAtNodeId, int[] startedAtAttributeId, int[] endedAtNodeId, int[] endedAtAttributeId, boolean[] createdFromSnap); /* private static native boolean nIsLinkCreated(int[] startedAtNodeId, int[] startedAtAttributeId, int[] endedAtNodeId, int[] endedAtAttributeId, boolean[] createdFromSnap); /*
return imnodes::IsLinkCreated(&startedAtNodeId[0], &startedAtAttributeId[0], &endedAtNodeId[0], &endedAtAttributeId[0], &createdFromSnap[0]); return ImNodes::IsLinkCreated(&startedAtNodeId[0], &startedAtAttributeId[0], &endedAtNodeId[0], &endedAtAttributeId[0], &createdFromSnap[0]);
*/ */
/** /**
@@ -317,7 +317,7 @@ public final class ImNodes {
} }
private static native boolean nIsLinkDestroyed(int[] linkId); /* private static native boolean nIsLinkDestroyed(int[] linkId); /*
return imnodes::IsLinkDestroyed(&linkId[0]); return ImNodes::IsLinkDestroyed(&linkId[0]);
*/ */
/** /**
@@ -325,11 +325,11 @@ public final class ImNodes {
* editor. Use after calling EndNodeEditor(). * editor. Use after calling EndNodeEditor().
*/ */
public static native int numSelectedNodes(); /* public static native int numSelectedNodes(); /*
return imnodes::NumSelectedNodes(); return ImNodes::NumSelectedNodes();
*/ */
public static native int numSelectedLinks(); /* public static native int numSelectedLinks(); /*
return imnodes::NumSelectedLinks(); return ImNodes::NumSelectedLinks();
*/ */
/** /**
@@ -338,42 +338,42 @@ public final class ImNodes {
* returned. * returned.
*/ */
public static native void getSelectedNodes(int[] nodeIds); /* public static native void getSelectedNodes(int[] nodeIds); /*
imnodes::GetSelectedNodes(&nodeIds[0]); ImNodes::GetSelectedNodes(&nodeIds[0]);
*/ */
public static native void getSelectedLinks(int[] linkIds); /* public static native void getSelectedLinks(int[] linkIds); /*
imnodes::GetSelectedLinks(&linkIds[0]); ImNodes::GetSelectedLinks(&linkIds[0]);
*/ */
/** /**
* Clears the list of selected nodes/links. Useful if you want to delete a selected node or link. * Clears the list of selected nodes/links. Useful if you want to delete a selected node or link.
*/ */
public static native void clearNodeSelection(); /* public static native void clearNodeSelection(); /*
imnodes::ClearNodeSelection(); ImNodes::ClearNodeSelection();
*/ */
public static native void clearLinkSelection(); /* public static native void clearLinkSelection(); /*
imnodes::ClearLinkSelection(); ImNodes::ClearLinkSelection();
*/ */
/** /**
* Enable or disable the ability to click and drag a specific node. * Enable or disable the ability to click and drag a specific node.
*/ */
public static native void setNodeDraggable(int node, boolean isDraggable); /* public static native void setNodeDraggable(int node, boolean isDraggable); /*
imnodes::SetNodeDraggable(node, isDraggable); ImNodes::SetNodeDraggable(node, isDraggable);
*/ */
public static native void getNodeDimensions(int node, ImVec2 result); /* public static native void getNodeDimensions(int node, ImVec2 result); /*
ImVec2 dst = imnodes::GetNodeDimensions(node); ImVec2 dst = ImNodes::GetNodeDimensions(node);
Jni::ImVec2Cpy(env, &dst, result); Jni::ImVec2Cpy(env, &dst, result);
*/ */
public static native float getNodeDimensionsX(int node); /* public static native float getNodeDimensionsX(int node); /*
return imnodes::GetNodeDimensions(node).x; return ImNodes::GetNodeDimensions(node).x;
*/ */
public static native float getNodeDimensionsY(int node); /* public static native float getNodeDimensionsY(int node); /*
return imnodes::GetNodeDimensions(node).y; return ImNodes::GetNodeDimensions(node).y;
*/ */
@@ -386,69 +386,69 @@ public final class ImNodes {
// Use the following functions to get and set the node's coordinates in these coordinate systems. // Use the following functions to get and set the node's coordinates in these coordinate systems.
public static native void setNodeScreenSpacePos(int node, float x, float y); /* public static native void setNodeScreenSpacePos(int node, float x, float y); /*
imnodes::SetNodeScreenSpacePos(node, ImVec2(x, y)); ImNodes::SetNodeScreenSpacePos(node, ImVec2(x, y));
*/ */
public static native void setNodeEditorSpacePos(int node, float x, float y); /* public static native void setNodeEditorSpacePos(int node, float x, float y); /*
imnodes::SetNodeEditorSpacePos(node, ImVec2(x, y)); ImNodes::SetNodeEditorSpacePos(node, ImVec2(x, y));
*/ */
public static native void setNodeGridSpacePos(int node, float x, float y); /* public static native void setNodeGridSpacePos(int node, float x, float y); /*
imnodes::SetNodeGridSpacePos(node, ImVec2(x, y)); ImNodes::SetNodeGridSpacePos(node, ImVec2(x, y));
*/ */
public static native void getNodeScreenSpacePos(int node, ImVec2 result); /* public static native void getNodeScreenSpacePos(int node, ImVec2 result); /*
ImVec2 dst = imnodes::GetNodeScreenSpacePos(node); ImVec2 dst = ImNodes::GetNodeScreenSpacePos(node);
Jni::ImVec2Cpy(env, &dst, result); Jni::ImVec2Cpy(env, &dst, result);
*/ */
public static native float getNodeScreenSpacePosX(int node); /* public static native float getNodeScreenSpacePosX(int node); /*
return imnodes::GetNodeScreenSpacePos(node).x; return ImNodes::GetNodeScreenSpacePos(node).x;
*/ */
public static native float getNodeScreenSpacePosY(int node); /* public static native float getNodeScreenSpacePosY(int node); /*
return imnodes::GetNodeScreenSpacePos(node).y; return ImNodes::GetNodeScreenSpacePos(node).y;
*/ */
public static native void getNodeEditorSpacePos(int node, ImVec2 result); /* public static native void getNodeEditorSpacePos(int node, ImVec2 result); /*
ImVec2 dst = imnodes::GetNodeEditorSpacePos(node); ImVec2 dst = ImNodes::GetNodeEditorSpacePos(node);
Jni::ImVec2Cpy(env, &dst, result); Jni::ImVec2Cpy(env, &dst, result);
*/ */
public static native float getNodeEditorSpacePosX(int node); /* public static native float getNodeEditorSpacePosX(int node); /*
return imnodes::GetNodeEditorSpacePos(node).x; return ImNodes::GetNodeEditorSpacePos(node).x;
*/ */
public static native float getNodeEditorSpacePosY(int node); /* public static native float getNodeEditorSpacePosY(int node); /*
return imnodes::GetNodeEditorSpacePos(node).y; return ImNodes::GetNodeEditorSpacePos(node).y;
*/ */
public static native void getNodeGridSpacePos(int node, ImVec2 dst); /* public static native void getNodeGridSpacePos(int node, ImVec2 dst); /*
ImVec2 result = imnodes::GetNodeGridSpacePos(node); ImVec2 result = ImNodes::GetNodeGridSpacePos(node);
Jni::ImVec2Cpy(env, &result, dst); Jni::ImVec2Cpy(env, &result, dst);
*/ */
public static native float getNodeGridSpacePosX(int node); /* public static native float getNodeGridSpacePosX(int node); /*
return imnodes::GetNodeGridSpacePos(node).x; return ImNodes::GetNodeGridSpacePos(node).x;
*/ */
public static native float getNodeGridSpacePosY(int node); /* public static native float getNodeGridSpacePosY(int node); /*
return imnodes::GetNodeGridSpacePos(node).y; return ImNodes::GetNodeGridSpacePos(node).y;
*/ */
public static native void editorResetPanning(float x, float y); /* public static native void editorResetPanning(float x, float y); /*
imnodes::EditorContextResetPanning(ImVec2(x, y)); ImNodes::EditorContextResetPanning(ImVec2(x, y));
*/ */
public static native void editorMoveToNode(int node); /* public static native void editorMoveToNode(int node); /*
imnodes::EditorContextMoveToNode(node); ImNodes::EditorContextMoveToNode(node);
*/ */
// Use the following functions to write the editor context's state to a string, or directly to a // Use the following functions to write the editor context's state to a string, or directly to a
// file. The editor context is serialized in the INI file format. // file. The editor context is serialized in the INI file format.
public static native String saveCurrentEditorStateToIniString(); /* public static native String saveCurrentEditorStateToIniString(); /*
return env->NewStringUTF(imnodes::SaveCurrentEditorStateToIniString(NULL)); return env->NewStringUTF(ImNodes::SaveCurrentEditorStateToIniString(NULL));
*/ */
public static String saveEditorStateToIniString(final ImNodesContext context) { public static String saveEditorStateToIniString(final ImNodesContext context) {
@@ -456,11 +456,11 @@ public final class ImNodes {
} }
private static native String nSaveEditorStateToIniString(long context); /* private static native String nSaveEditorStateToIniString(long context); /*
return env->NewStringUTF(imnodes::SaveEditorStateToIniString((imnodes::EditorContext*)context, NULL)); return env->NewStringUTF(ImNodes::SaveEditorStateToIniString((ImNodesEditorContext*)context, NULL));
*/ */
public static native void loadCurrentEditorStateFromIniString(String data, int dataSize); /* public static native void loadCurrentEditorStateFromIniString(String data, int dataSize); /*
imnodes::LoadCurrentEditorStateFromIniString(data, dataSize); ImNodes::LoadCurrentEditorStateFromIniString(data, dataSize);
*/ */
public static void loadEditorStateFromIniString(final ImNodesContext context, final String data, final int dataSize) { public static void loadEditorStateFromIniString(final ImNodesContext context, final String data, final int dataSize) {
@@ -468,11 +468,11 @@ public final class ImNodes {
} }
private static native void nLoadEditorStateFromIniString(long context, String data, int dataSize); /* private static native void nLoadEditorStateFromIniString(long context, String data, int dataSize); /*
imnodes::LoadEditorStateFromIniString((imnodes::EditorContext*)context, data, dataSize); ImNodes::LoadEditorStateFromIniString((ImNodesEditorContext*)context, data, dataSize);
*/ */
public static native void saveCurrentEditorStateToIniFile(String fileName); /* public static native void saveCurrentEditorStateToIniFile(String fileName); /*
imnodes::SaveCurrentEditorStateToIniFile(fileName); ImNodes::SaveCurrentEditorStateToIniFile(fileName);
*/ */
public static void saveEditorStateToIniFile(final ImNodesContext context, final String fileName) { public static void saveEditorStateToIniFile(final ImNodesContext context, final String fileName) {
@@ -480,11 +480,11 @@ public final class ImNodes {
} }
private static native void nSaveEditorStateToIniFile(long context, String fileName); /* private static native void nSaveEditorStateToIniFile(long context, String fileName); /*
imnodes::SaveEditorStateToIniFile((imnodes::EditorContext*)context, fileName); ImNodes::SaveEditorStateToIniFile((ImNodesEditorContext*)context, fileName);
*/ */
public static native void loadCurrentEditorStateFromIniFile(String fileName); /* public static native void loadCurrentEditorStateFromIniFile(String fileName); /*
imnodes::LoadCurrentEditorStateFromIniFile(fileName); ImNodes::LoadCurrentEditorStateFromIniFile(fileName);
*/ */
public static void loadEditorStateFromIniFile(final ImNodesContext context, final String fileName) { public static void loadEditorStateFromIniFile(final ImNodesContext context, final String fileName) {
@@ -492,6 +492,10 @@ public final class ImNodes {
} }
private static native void nLoadEditorStateFromIniFile(long context, String fileName); /* private static native void nLoadEditorStateFromIniFile(long context, String fileName); /*
imnodes::LoadEditorStateFromIniFile((imnodes::EditorContext*)context, fileName); ImNodes::LoadEditorStateFromIniFile((ImNodesEditorContext*)context, fileName);
*/
public static native void miniMap(float miniMapSizeFraction, int miniMapLocation); /*
ImNodes::MiniMap(miniMapSizeFraction, (ImNodesMiniMapLocation)miniMapLocation);
*/ */
} }
@@ -13,7 +13,7 @@ public final class ImNodesContext extends ImGuiStructDestroyable {
/*JNI /*JNI
#include "_imnodes.h" #include "_imnodes.h"
#define IMNODES_CONTEXT ((imnodes::EditorContext*)STRUCT_PTR) #define IMNODES_CONTEXT ((ImNodesEditorContext*)STRUCT_PTR)
*/ */
@Override @Override
@@ -27,10 +27,10 @@ public final class ImNodesContext extends ImGuiStructDestroyable {
} }
private native long nCreate(); /* private native long nCreate(); /*
return (intptr_t)imnodes::EditorContextCreate(); return (intptr_t)ImNodes::EditorContextCreate();
*/ */
private native void nDestroy(); /* private native void nDestroy(); /*
imnodes::EditorContextFree(IMNODES_CONTEXT); ImNodes::EditorContextFree(IMNODES_CONTEXT);
*/ */
} }
@@ -1,5 +1,6 @@
package imgui.extension.imnodes; package imgui.extension.imnodes;
import imgui.ImVec2;
import imgui.binding.ImGuiStruct; import imgui.binding.ImGuiStruct;
public final class ImNodesStyle extends ImGuiStruct { public final class ImNodesStyle extends ImGuiStruct {
@@ -10,162 +11,182 @@ public final class ImNodesStyle extends ImGuiStruct {
/*JNI /*JNI
#include "_imnodes.h" #include "_imnodes.h"
#define IMNODES_STYLE ((imnodes::Style*)STRUCT_PTR) #define IMNODES_STYLE ((ImNodesStyle*)STRUCT_PTR)
*/ */
public native float getGridSpacing(); /* public native float getGridSpacing(); /*
return IMNODES_STYLE->grid_spacing; return IMNODES_STYLE->GridSpacing;
*/ */
public native void setGridSpacing(float gridSpacing); /* public native void setGridSpacing(float gridSpacing); /*
IMNODES_STYLE->grid_spacing = gridSpacing; IMNODES_STYLE->GridSpacing = gridSpacing;
*/ */
public native float getNodeCornerRounding(); /* public native float getNodeCornerRounding(); /*
return IMNODES_STYLE->node_corner_rounding; return IMNODES_STYLE->NodeCornerRounding;
*/ */
public native void setNodeCornerRounding(float nodeCornerRounding); /* public native void setNodeCornerRounding(float nodeCornerRounding); /*
IMNODES_STYLE->node_corner_rounding = nodeCornerRounding; IMNODES_STYLE->NodeCornerRounding = nodeCornerRounding;
*/ */
public native float getNodePaddingHorizontal(); /* public native void getNodePadding(ImVec2 result); /*
return IMNODES_STYLE->node_padding_horizontal; Jni::ImVec2Cpy(env, &IMNODES_STYLE->NodePadding, result);
*/ */
public native void setNodePaddingHorizontal(float nodePaddingHorizontal); /* public native void setNodePadding(float x, float y); /*
IMNODES_STYLE->node_padding_horizontal = nodePaddingHorizontal; IMNODES_STYLE->NodePadding = ImVec2(x, y);
*/
public native float getNodePaddingVertical(); /*
return IMNODES_STYLE->node_padding_vertical;
*/
public native void setNodePaddingVertical(float nodePaddingVertical); /*
IMNODES_STYLE->node_padding_vertical = nodePaddingVertical;
*/ */
public native float getNodeBorderThickness(); /* public native float getNodeBorderThickness(); /*
return IMNODES_STYLE->node_border_thickness; return IMNODES_STYLE->NodeBorderThickness;
*/ */
public native void setNodeBorderThickness(float nodeBorderThickness); /* public native void setNodeBorderThickness(float nodeBorderThickness); /*
IMNODES_STYLE->node_border_thickness = nodeBorderThickness; IMNODES_STYLE->NodeBorderThickness = nodeBorderThickness;
*/ */
public native float getLinkThickness(); /* public native float getLinkThickness(); /*
return IMNODES_STYLE->link_thickness; return IMNODES_STYLE->LinkThickness;
*/ */
public native void setLinkThickness(float linkThickness); /* public native void setLinkThickness(float linkThickness); /*
IMNODES_STYLE->link_thickness = linkThickness; IMNODES_STYLE->LinkThickness = linkThickness;
*/ */
public native float getLinkLineSegmentsPerLength(); /* public native float getLinkLineSegmentsPerLength(); /*
return IMNODES_STYLE->link_line_segments_per_length; return IMNODES_STYLE->LinkLineSegmentsPerLength;
*/ */
public native void setLinkLineSegmentsPerLength(float linkLineSegmentsPerLength); /* public native void setLinkLineSegmentsPerLength(float linkLineSegmentsPerLength); /*
IMNODES_STYLE->link_line_segments_per_length = linkLineSegmentsPerLength; IMNODES_STYLE->LinkLineSegmentsPerLength = linkLineSegmentsPerLength;
*/ */
public native float getLinkHoverDistance(); /* public native float getLinkHoverDistance(); /*
return IMNODES_STYLE->link_hover_distance; return IMNODES_STYLE->LinkHoverDistance;
*/ */
public native void setLinkHoverDistance(float linkHoverDistance); /* public native void setLinkHoverDistance(float linkHoverDistance); /*
IMNODES_STYLE->link_hover_distance = linkHoverDistance; IMNODES_STYLE->LinkHoverDistance = linkHoverDistance;
*/ */
/** /**
* The circle radius used when the pin shape is either PinShape_Circle or PinShape_CircleFilled. * The circle radius used when the pin shape is either PinShape_Circle or PinShape_CircleFilled.
*/ */
public native float getPinCircleRadius(); /* public native float getPinCircleRadius(); /*
return IMNODES_STYLE->pin_circle_radius; return IMNODES_STYLE->PinCircleRadius;
*/ */
/** /**
* The circle radius used when the pin shape is either PinShape_Circle or PinShape_CircleFilled. * The circle radius used when the pin shape is either PinShape_Circle or PinShape_CircleFilled.
*/ */
public native void setPinCircleRadius(float pinCircleRadius); /* public native void setPinCircleRadius(float pinCircleRadius); /*
IMNODES_STYLE->pin_circle_radius = pinCircleRadius; IMNODES_STYLE->PinCircleRadius = pinCircleRadius;
*/ */
/** /**
* The quad side length used when the shape is either PinShape_Quad or PinShape_QuadFilled. * The quad side length used when the shape is either PinShape_Quad or PinShape_QuadFilled.
*/ */
public native float getPinQuadSideLength(); /* public native float getPinQuadSideLength(); /*
return IMNODES_STYLE->pin_quad_side_length; return IMNODES_STYLE->PinQuadSideLength;
*/ */
/** /**
* The quad side length used when the shape is either PinShape_Quad or PinShape_QuadFilled. * The quad side length used when the shape is either PinShape_Quad or PinShape_QuadFilled.
*/ */
public native void setPinQuadSideLength(float pinQuadSideLength); /* public native void setPinQuadSideLength(float pinQuadSideLength); /*
IMNODES_STYLE->pin_quad_side_length = pinQuadSideLength; IMNODES_STYLE->PinQuadSideLength = pinQuadSideLength;
*/ */
/** /**
* The equilateral triangle side length used when the pin shape is either PinShape_Triangle or PinShape_TriangleFilled. * The equilateral triangle side length used when the pin shape is either PinShape_Triangle or PinShape_TriangleFilled.
*/ */
public native float getPinTriangleSideLength(); /* public native float getPinTriangleSideLength(); /*
return IMNODES_STYLE->pin_triangle_side_length; return IMNODES_STYLE->PinTriangleSideLength;
*/ */
/** /**
* The equilateral triangle side length used when the pin shape is either PinShape_Triangle or PinShape_TriangleFilled. * The equilateral triangle side length used when the pin shape is either PinShape_Triangle or PinShape_TriangleFilled.
*/ */
public native void setPinTriangleSideLength(float pinTriangleSideLength); /* public native void setPinTriangleSideLength(float pinTriangleSideLength); /*
IMNODES_STYLE->pin_triangle_side_length = pinTriangleSideLength; IMNODES_STYLE->PinTriangleSideLength = pinTriangleSideLength;
*/ */
/** /**
* The thickness of the line used when the pin shape is not filled. * The thickness of the line used when the pin shape is not filled.
*/ */
public native float getPinLineThickness(); /* public native float getPinLineThickness(); /*
return IMNODES_STYLE->pin_line_thickness; return IMNODES_STYLE->PinLineThickness;
*/ */
/** /**
* The thickness of the line used when the pin shape is not filled. * The thickness of the line used when the pin shape is not filled.
*/ */
public native void setPinLineThickness(float pinLineThickness); /* public native void setPinLineThickness(float pinLineThickness); /*
IMNODES_STYLE->pin_line_thickness = pinLineThickness; IMNODES_STYLE->PinLineThickness = pinLineThickness;
*/ */
/** /**
* The radius from the pin's center position inside of which it is detected as being hovered over. * The radius from the pin's center position inside of which it is detected as being hovered over.
*/ */
public native float getPinHoverRadius(); /* public native float getPinHoverRadius(); /*
return IMNODES_STYLE->pin_hover_radius; return IMNODES_STYLE->PinHoverRadius;
*/ */
/** /**
* The radius from the pin's center position inside of which it is detected as being hovered over. * The radius from the pin's center position inside of which it is detected as being hovered over.
*/ */
public native void setPinHoverRadius(float pinHoverRadius); /* public native void setPinHoverRadius(float pinHoverRadius); /*
IMNODES_STYLE->pin_hover_radius = pinHoverRadius; IMNODES_STYLE->PinHoverRadius = pinHoverRadius;
*/ */
/** /**
* Offsets the pins' positions from the edge of the node to the outside of the node. * Offsets the pins' positions from the edge of the node to the outside of the node.
*/ */
public native float getPinOffset(); /* public native float getPinOffset(); /*
return IMNODES_STYLE->pin_offset; return IMNODES_STYLE->PinOffset;
*/ */
/** /**
* Offsets the pins' positions from the edge of the node to the outside of the node. * Offsets the pins' positions from the edge of the node to the outside of the node.
*/ */
public native void setPinOffset(float pinOffset); /* public native void setPinOffset(float pinOffset); /*
IMNODES_STYLE->pin_offset = pinOffset; IMNODES_STYLE->PinOffset = pinOffset;
*/
/**
* Mini-map padding size between mini-map edge and mini-map content.
*/
public native void getMiniMapPadding(ImVec2 result); /*
Jni::ImVec2Cpy(env, &IMNODES_STYLE->MiniMapPadding, result);
*/
/**
* Mini-map padding size between mini-map edge and mini-map content.
*/
public native void setMiniMapPadding(float x, float y); /*
IMNODES_STYLE->MiniMapPadding = ImVec2(x, y);
*/
/**
* Mini-map offset from the screen side.
*/
public native ImVec2 getMiniMapOffset(ImVec2 result); /*
Jni::ImVec2Cpy(env, &IMNODES_STYLE->MiniMapOffset, result);
*/
/**
* Mini-map offset from the screen side.
*/
public native void setMiniMapOffset(float x, float y); /*
IMNODES_STYLE->MiniMapOffset = ImVec2(x, y);
*/ */
public native int getFlags(); /* public native int getFlags(); /*
return IMNODES_STYLE->flags; return IMNODES_STYLE->Flags;
*/ */
public native void setFlags(int imNodesStyleFlags); /* public native void setFlags(int imNodesStyleFlags); /*
IMNODES_STYLE->flags = (imnodes::StyleFlags)imNodesStyleFlags; IMNODES_STYLE->Flags = (ImNodesStyleFlags)imNodesStyleFlags;
*/ */
} }
@@ -20,5 +20,17 @@ public final class ImNodesColorStyle {
public static final int BoxSelectorOutline = 13; public static final int BoxSelectorOutline = 13;
public static final int GridBackground = 14; public static final int GridBackground = 14;
public static final int GridLine = 15; public static final int GridLine = 15;
public static final int COUNT = 16; public static final int MiniMapBackground = 16;
public static final int MiniMapBackgroundHovered = 17;
public static final int MiniMapOutline = 18;
public static final int MiniMapOutlineHovered = 19;
public static final int MiniMapNodeBackground = 20;
public static final int MiniMapNodeBackgroundHovered = 21;
public static final int MiniMapNodeBackgroundSelected = 22;
public static final int MiniMapNodeOutline = 23;
public static final int MiniMapLink = 24;
public static final int MiniMapLinkSelected = 25;
public static final int MiniMapCanvas = 26;
public static final int MiniMapCanvasOutline = 27;
public static final int COUNT = 28;
} }
@@ -0,0 +1,14 @@
package imgui.extension.imnodes.flag;
/**
* This enum controls the minimap's location.
*/
public final class ImNodesMiniMapLocation {
private ImNodesMiniMapLocation() {
}
public static final int BottomLeft = 0;
public static final int BottomRight = 1;
public static final int TopLeft = 2;
public static final int TopRight = 3;
}