[Binding] Fix ImNodes minor probs and add Style struct
This commit is contained in:
1 parent
a2d5ba0035
commit
5beb896b50
10 files changed
+233
-38
No files matched your search
@@ -39,11 +39,9 @@ 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('imnodes')) { CopySpec it -> it.include('*.h', '*.cpp') }
|
||||
|
||||
spec.from(project.rootProject.file('imgui-node-editor')) { CopySpec it -> it.include('*.h', '*.cpp', '*.inl') }
|
||||
['imgui', 'imnodes', 'imgui-node-editor'].each {
|
||||
spec.from(project.rootProject.file(it)) { CopySpec s -> s.include('*.h', '*.cpp', '*.inl') }
|
||||
}
|
||||
|
||||
if (withFreeType) {
|
||||
spec.from(project.rootProject.file('imgui/misc/freetype')) { CopySpec it -> it.include('*.h', '*.cpp') }
|
||||
|
||||
@@ -7,19 +7,20 @@ import imgui.type.ImInt;
|
||||
/**
|
||||
* Bindings for Imnodes (https://github.com/Nelarius/imnodes/)
|
||||
* Original library author - Johann Muszynski (https://github.com/Nelarius)
|
||||
*
|
||||
* <p>
|
||||
* Refer to the library's Github page for examples and support
|
||||
*/
|
||||
public final class ImNodes {
|
||||
private static ImNodesStyle style;
|
||||
|
||||
private ImNodes() { }
|
||||
private ImNodes() {
|
||||
}
|
||||
|
||||
/*JNI
|
||||
#include <stdint.h>
|
||||
#include <imgui.h>
|
||||
#include <imnodes.h>
|
||||
#include "jni_common.h"
|
||||
#include "jni_binding_struct.h"
|
||||
*/
|
||||
|
||||
// An editor context corresponds to a set of nodes in a single workspace (created with a single
|
||||
@@ -55,14 +56,30 @@ public final class ImNodes {
|
||||
imnodes::Shutdown();
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns the global style struct. See the struct declaration for default values.
|
||||
*/
|
||||
public static ImNodesStyle getStyle() {
|
||||
if (style == null) {
|
||||
style = new ImNodesStyle(nGetStyle());
|
||||
}
|
||||
return style;
|
||||
}
|
||||
|
||||
private static native long nGetStyle(); /*
|
||||
return (intptr_t)&imnodes::GetStyle();
|
||||
*/
|
||||
|
||||
// Style presets matching the dear imgui styles of the same name.
|
||||
|
||||
public static native void styleColorsDark(); /*
|
||||
imnodes::StyleColorsDark();
|
||||
*/
|
||||
|
||||
public static native void styleColorsClassic(); /*
|
||||
imnodes::StyleColorsClassic();
|
||||
*/
|
||||
|
||||
public static native void styleColorsLight(); /*
|
||||
imnodes::StyleColorsLight();
|
||||
*/
|
||||
@@ -137,7 +154,6 @@ public final class ImNodes {
|
||||
//
|
||||
// Each attribute id must be unique.
|
||||
|
||||
|
||||
/**
|
||||
* Create a static attribute block. A static attribute has no pin, and therefore can't be linked to
|
||||
* anything. However, you can still use IsAttributeActive() and IsAnyAttributeActive() to check for
|
||||
@@ -196,25 +212,32 @@ public final class ImNodes {
|
||||
return imnodes::IsEditorHovered();
|
||||
*/
|
||||
|
||||
/**
|
||||
* Binding notice: getHoveredNode(), getHoveredLink() and getHoveredPin()
|
||||
* return id of the hovered object. If there is no such object -1 will be returned.
|
||||
* Use these functions after endNodeEditor() has been called.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
// Binding notice: getHoveredNode(), getHoveredLink() and getHoveredPin()
|
||||
// return id of the hovered object. If there is no such object -1 will be returned.
|
||||
// Use these functions after endNodeEditor() has been called.
|
||||
//
|
||||
// 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.
|
||||
|
||||
/**
|
||||
* @return id of the hovered node or -1 if there is no such object
|
||||
*/
|
||||
public static native int getHoveredNode(); /*
|
||||
int i;
|
||||
return imnodes::IsNodeHovered(&i) ? i : -1;
|
||||
*/
|
||||
|
||||
/**
|
||||
* @return id of the hovered link or -1 if there is no such object
|
||||
*/
|
||||
public static native int getHoveredLink(); /*
|
||||
int i;
|
||||
return imnodes::IsLinkHovered(&i) ? i : -1;
|
||||
*/
|
||||
|
||||
/**
|
||||
* @return id of the hovered pin or -1 if there is no such object
|
||||
*/
|
||||
public static native int getHoveredPin(); /*
|
||||
int i;
|
||||
return imnodes::IsPinHovered(&i) ? i : -1;
|
||||
@@ -222,7 +245,7 @@ public final class ImNodes {
|
||||
|
||||
/**
|
||||
* Binding notice: getActiveAttribute() returns id the active attribute. If there is no active attribute -1 will be returned.
|
||||
*
|
||||
* <p>
|
||||
* This method implemented instead of the original bool imnodes::IsAnyAttributeActive(int* attribute_id) for convenience.
|
||||
*/
|
||||
public static native int getActiveAttribute(); /*
|
||||
@@ -337,7 +360,6 @@ public final class ImNodes {
|
||||
imnodes::ClearLinkSelection();
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Enable or disable the ability to click and drag a specific node.
|
||||
*/
|
||||
@@ -476,5 +498,4 @@ public final class ImNodes {
|
||||
private static native void nLoadEditorStateFromIniFile(long context, String fileName); /*
|
||||
imnodes::LoadEditorStateFromIniFile((imnodes::EditorContext*)context, fileName);
|
||||
*/
|
||||
|
||||
}
|
||||
@@ -15,7 +15,7 @@ public final class ImNodesAttributeFlags {
|
||||
* NOTE: the user has to actually delete the link for this to work. A deleted link can be
|
||||
* detected by calling IsLinkDestroyed() after EndNodeEditor().
|
||||
*/
|
||||
public static final int EnableLinkDetachWithDragClick = 1 << 0;
|
||||
public static final int EnableLinkDetachWithDragClick = 1;
|
||||
|
||||
/**
|
||||
* Visual snapping of an in progress link will trigger IsLink Created/Destroyed events. Allows
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package imgui.imnodes;
|
||||
|
||||
public final class ImNodesColorStyle {
|
||||
|
||||
private ImNodesColorStyle() {
|
||||
}
|
||||
|
||||
@@ -21,5 +20,4 @@ public final class ImNodesColorStyle {
|
||||
public static final int BoxSelectorOutline = 13;
|
||||
public static final int GridBackground = 14;
|
||||
public static final int GridLine = 15;
|
||||
|
||||
}
|
||||
@@ -4,6 +4,13 @@ import imgui.binding.ImGuiStructDestroyable;
|
||||
|
||||
public final class ImNodesContext extends ImGuiStructDestroyable {
|
||||
|
||||
public ImNodesContext() {
|
||||
}
|
||||
|
||||
public ImNodesContext(final long ptr) {
|
||||
super(ptr);
|
||||
}
|
||||
|
||||
/*JNI
|
||||
#include <stdint.h>
|
||||
#include <imgui.h>
|
||||
@@ -14,14 +21,6 @@ public final class ImNodesContext extends ImGuiStructDestroyable {
|
||||
#define IMNODES_CONTEXT ((imnodes::EditorContext*)STRUCT_PTR)
|
||||
*/
|
||||
|
||||
public ImNodesContext() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ImNodesContext(final long ptr) {
|
||||
super(ptr);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected long create() {
|
||||
return nCreate();
|
||||
@@ -33,11 +32,10 @@ public final class ImNodesContext extends ImGuiStructDestroyable {
|
||||
}
|
||||
|
||||
private native long nCreate(); /*
|
||||
return (jlong)imnodes::EditorContextCreate();
|
||||
return (intptr_t)imnodes::EditorContextCreate();
|
||||
*/
|
||||
|
||||
private native void nDestroy(); /*
|
||||
imnodes::EditorContextFree(IMNODES_CONTEXT);
|
||||
*/
|
||||
|
||||
}
|
||||
@@ -4,7 +4,6 @@ package imgui.imnodes;
|
||||
* This enum controls the way attribute pins look.
|
||||
*/
|
||||
public final class ImNodesPinShape {
|
||||
|
||||
private ImNodesPinShape() {
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,175 @@
|
||||
package imgui.imnodes;
|
||||
|
||||
import imgui.binding.ImGuiStruct;
|
||||
|
||||
public final class ImNodesStyle extends ImGuiStruct {
|
||||
public ImNodesStyle(final long ptr) {
|
||||
super(ptr);
|
||||
}
|
||||
|
||||
/*JNI
|
||||
#include <stdint.h>
|
||||
#include <imgui.h>
|
||||
#include <imnodes.h>
|
||||
#include "jni_common.h"
|
||||
#include "jni_binding_struct.h"
|
||||
|
||||
#define IMNODES_STYLE ((imnodes::Style*)STRUCT_PTR)
|
||||
*/
|
||||
|
||||
public native float getGridSpacing(); /*
|
||||
return IMNODES_STYLE->grid_spacing;
|
||||
*/
|
||||
|
||||
public native void setGridSpacing(float gridSpacing); /*
|
||||
IMNODES_STYLE->grid_spacing = gridSpacing;
|
||||
*/
|
||||
|
||||
public native float getNodeCornerRounding(); /*
|
||||
return IMNODES_STYLE->node_corner_rounding;
|
||||
*/
|
||||
|
||||
public native void setNodeCornerRounding(float nodeCornerRounding); /*
|
||||
IMNODES_STYLE->node_corner_rounding = nodeCornerRounding;
|
||||
*/
|
||||
|
||||
public native float getNodePaddingHorizontal(); /*
|
||||
return IMNODES_STYLE->node_padding_horizontal;
|
||||
*/
|
||||
|
||||
public native void setNodePaddingHorizontal(float nodePaddingHorizontal); /*
|
||||
IMNODES_STYLE->node_padding_horizontal = nodePaddingHorizontal;
|
||||
*/
|
||||
|
||||
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(); /*
|
||||
return IMNODES_STYLE->node_border_thickness;
|
||||
*/
|
||||
|
||||
public native void setNodeBorderThickness(float nodeBorderThickness); /*
|
||||
IMNODES_STYLE->node_border_thickness = nodeBorderThickness;
|
||||
*/
|
||||
|
||||
public native float getLinkThickness(); /*
|
||||
return IMNODES_STYLE->link_thickness;
|
||||
*/
|
||||
|
||||
public native void setLinkThickness(float linkThickness); /*
|
||||
IMNODES_STYLE->link_thickness = linkThickness;
|
||||
*/
|
||||
|
||||
public native float getLinkLineSegmentsPerLength(); /*
|
||||
return IMNODES_STYLE->link_line_segments_per_length;
|
||||
*/
|
||||
|
||||
public native void setLinkLineSegmentsPerLength(float linkLineSegmentsPerLength); /*
|
||||
IMNODES_STYLE->link_line_segments_per_length = linkLineSegmentsPerLength;
|
||||
*/
|
||||
|
||||
public native float getLinkHoverDistance(); /*
|
||||
return IMNODES_STYLE->link_hover_distance;
|
||||
*/
|
||||
|
||||
public native void setLinkHoverDistance(float linkHoverDistance); /*
|
||||
IMNODES_STYLE->link_hover_distance = linkHoverDistance;
|
||||
*/
|
||||
|
||||
/**
|
||||
* The circle radius used when the pin shape is either PinShape_Circle or PinShape_CircleFilled.
|
||||
*/
|
||||
public native float getPinCircleRadius(); /*
|
||||
return IMNODES_STYLE->pin_circle_radius;
|
||||
*/
|
||||
|
||||
/**
|
||||
* The circle radius used when the pin shape is either PinShape_Circle or PinShape_CircleFilled.
|
||||
*/
|
||||
public native void setPinCircleRadius(float pinCircleRadius); /*
|
||||
IMNODES_STYLE->pin_circle_radius = pinCircleRadius;
|
||||
*/
|
||||
|
||||
/**
|
||||
* The quad side length used when the shape is either PinShape_Quad or PinShape_QuadFilled.
|
||||
*/
|
||||
public native float getPinQuadSideLength(); /*
|
||||
return IMNODES_STYLE->pin_quad_side_length;
|
||||
*/
|
||||
|
||||
/**
|
||||
* The quad side length used when the shape is either PinShape_Quad or PinShape_QuadFilled.
|
||||
*/
|
||||
public native void setPinQuadSideLength(float pinQuadSideLength); /*
|
||||
IMNODES_STYLE->pin_quad_side_length = pinQuadSideLength;
|
||||
*/
|
||||
|
||||
/**
|
||||
* The equilateral triangle side length used when the pin shape is either PinShape_Triangle or PinShape_TriangleFilled.
|
||||
*/
|
||||
public native float getPinTriangleSideLength(); /*
|
||||
return IMNODES_STYLE->pin_triangle_side_length;
|
||||
*/
|
||||
|
||||
/**
|
||||
* The equilateral triangle side length used when the pin shape is either PinShape_Triangle or PinShape_TriangleFilled.
|
||||
*/
|
||||
public native void setPinTriangleSideLength(float pinTriangleSideLength); /*
|
||||
IMNODES_STYLE->pin_triangle_side_length = pinTriangleSideLength;
|
||||
*/
|
||||
|
||||
/**
|
||||
* The thickness of the line used when the pin shape is not filled.
|
||||
*/
|
||||
public native float getPinLineThickness(); /*
|
||||
return IMNODES_STYLE->pin_line_thickness;
|
||||
*/
|
||||
|
||||
/**
|
||||
* The thickness of the line used when the pin shape is not filled.
|
||||
*/
|
||||
public native void setPinLineThickness(float pinLineThickness); /*
|
||||
IMNODES_STYLE->pin_line_thickness = pinLineThickness;
|
||||
*/
|
||||
|
||||
/**
|
||||
* The radius from the pin's center position inside of which it is detected as being hovered over.
|
||||
*/
|
||||
public native float getPinHoverRadius(); /*
|
||||
return IMNODES_STYLE->pin_hover_radius;
|
||||
*/
|
||||
|
||||
/**
|
||||
* The radius from the pin's center position inside of which it is detected as being hovered over.
|
||||
*/
|
||||
public native void setPinHoverRadius(float pinHoverRadius); /*
|
||||
IMNODES_STYLE->pin_hover_radius = pinHoverRadius;
|
||||
*/
|
||||
|
||||
/**
|
||||
* Offsets the pins' positions from the edge of the node to the outside of the node.
|
||||
*/
|
||||
public native float getPinOffset(); /*
|
||||
return IMNODES_STYLE->pin_offset;
|
||||
*/
|
||||
|
||||
/**
|
||||
* Offsets the pins' positions from the edge of the node to the outside of the node.
|
||||
*/
|
||||
public native void setPinOffset(float pinOffset); /*
|
||||
IMNODES_STYLE->pin_offset = pinOffset;
|
||||
*/
|
||||
|
||||
public native int getFlags(); /*
|
||||
return IMNODES_STYLE->flags;
|
||||
*/
|
||||
|
||||
public native void setFlags(int imNodesStyleFlags); /*
|
||||
IMNODES_STYLE->flags = (imnodes::StyleFlags)imNodesStyleFlags;
|
||||
*/
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package imgui.imnodes;
|
||||
|
||||
public final class ImNodesStyleFlags {
|
||||
private ImNodesStyleFlags() {
|
||||
}
|
||||
|
||||
public static final int None = 0;
|
||||
public static final int NodeOutline = 1;
|
||||
public static final int GridLines = 1 << 2;
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package imgui.imnodes;
|
||||
|
||||
public final class ImNodesStyleVar {
|
||||
|
||||
private ImNodesStyleVar() {
|
||||
}
|
||||
|
||||
|
||||
@@ -246,7 +246,6 @@ final class ExampleUi {
|
||||
|
||||
ImGui.text("This a demo graph editor for ImNodes");
|
||||
|
||||
|
||||
ImNodes.editorContextSet(imNodesContext);
|
||||
ImNodes.beginNodeEditor();
|
||||
|
||||
@@ -507,6 +506,4 @@ final class ExampleUi {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user