feat: introduce binding generator
A squash of hundreds of commits with a binding API generator. The API generator works with a hybrid model: 1. We define methods and fields in the code. 2. Mark them with API annotations. 3. For specific use cases, we use the old approach with JNI generation comments. There is also an API to generate an AST tree, which is saved to JSON. This JSON can be used for full API generation by declaring only field/method names. Currently, it is used to generate constants. By eyeballing, 95% of the API has been converted to the new approach. This is sufficient for the current moment. Only edge cases with specific API calls are left. fix: ambiguous call for ImGui::GetColorU32 build: disable checkstyle for imgui-binding module Since the module is heavily generated, checkstyle for it doesn't make sense. build: make buildSrc to use JDK 11 build: make generateApi optional when compiling project Initially generated module was not included to the project VCS. Since it's now in the separate src folder, we don't need to call generator every time. Only when a new generation result is required.
This commit is contained in:
1 parent
e64df5a433
commit
8a8cd22ed6
323 files changed
+113518
-15318
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import imgui.ImGui;
|
||||
import imgui.extension.texteditor.TextEditor;
|
||||
import imgui.extension.texteditor.TextEditorCoordinates;
|
||||
import imgui.extension.texteditor.TextEditorLanguageDefinition;
|
||||
import imgui.flag.ImGuiWindowFlags;
|
||||
import imgui.type.ImBoolean;
|
||||
@@ -11,7 +12,7 @@ public class ExampleImGuiColorTextEdit {
|
||||
private static final TextEditor EDITOR = new TextEditor();
|
||||
|
||||
static {
|
||||
TextEditorLanguageDefinition lang = TextEditorLanguageDefinition.c();
|
||||
TextEditorLanguageDefinition lang = TextEditorLanguageDefinition.C();
|
||||
|
||||
String[] ppnames = {
|
||||
"NULL", "PM_REMOVE",
|
||||
@@ -122,13 +123,12 @@ public class ExampleImGuiColorTextEdit {
|
||||
ImGui.endMenuBar();
|
||||
}
|
||||
|
||||
int cposX = EDITOR.getCursorPositionLine();
|
||||
int cposY = EDITOR.getCursorPositionColumn();
|
||||
TextEditorCoordinates cpos = EDITOR.getCursorPosition();
|
||||
|
||||
String overwrite = EDITOR.isOverwrite() ? "Ovr" : "Ins";
|
||||
String canUndo = EDITOR.canUndo() ? "*" : " ";
|
||||
|
||||
ImGui.text(cposX + "/" + cposY + " " + EDITOR.getTotalLines() + " lines | " + overwrite + " | " + canUndo);
|
||||
ImGui.text(cpos.mLine + "/" + cpos.mColumn + " " + EDITOR.getTotalLines() + " lines | " + overwrite + " | " + canUndo);
|
||||
|
||||
EDITOR.render("TextEditor");
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ public class ExampleImGuiFileDialog {
|
||||
private static long userData = 0;
|
||||
private static ImGuiFileDialogPaneFun callback = new ImGuiFileDialogPaneFun() {
|
||||
@Override
|
||||
public void paneFun(String filter, long userDatas, boolean canContinue) {
|
||||
public void accept(String filter, long userDatas, boolean canContinue) {
|
||||
ImGui.text("Filter: " + filter);
|
||||
}
|
||||
};
|
||||
@@ -51,7 +51,7 @@ public class ExampleImGuiFileDialog {
|
||||
}
|
||||
|
||||
if (ImGui.button("Browse Folder")) {
|
||||
ImGuiFileDialog.openDialog("browse-folder-key", "Choose Folder", null, ".", "", 1, 7, ImGuiFileDialogFlags.None);
|
||||
ImGuiFileDialog.openDialog("browse-folder-key", "Choose Folder", null, ".", "", callback, 1, 7L, ImGuiFileDialogFlags.None);
|
||||
}
|
||||
|
||||
if (ImGuiFileDialog.display("browse-folder-key", ImGuiFileDialogFlags.None, 200, 400, 800, 600)) {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import imgui.ImVec2;
|
||||
import imgui.extension.nodeditor.NodeEditor;
|
||||
import imgui.extension.nodeditor.NodeEditorConfig;
|
||||
import imgui.extension.nodeditor.NodeEditorContext;
|
||||
@@ -17,7 +18,7 @@ public class ExampleImGuiNodeEditor {
|
||||
static {
|
||||
NodeEditorConfig config = new NodeEditorConfig();
|
||||
config.setSettingsFile(null);
|
||||
CONTEXT = new NodeEditorContext(config);
|
||||
CONTEXT = NodeEditor.createEditor(config);
|
||||
}
|
||||
|
||||
public static void show(final ImBoolean showImNodeEditorWindow, final Graph graph) {
|
||||
@@ -108,9 +109,8 @@ public class ExampleImGuiNodeEditor {
|
||||
if (ImGui.beginPopup("node_editor_context")) {
|
||||
if (ImGui.button("Create New Node")) {
|
||||
final Graph.GraphNode node = graph.createGraphNode();
|
||||
final float canvasX = NodeEditor.toCanvasX(ImGui.getMousePosX());
|
||||
final float canvasY = NodeEditor.toCanvasY(ImGui.getMousePosY());
|
||||
NodeEditor.setNodePosition(node.nodeId, canvasX, canvasY);
|
||||
final ImVec2 canvas = NodeEditor.screenToCanvas(ImGui.getMousePos());
|
||||
NodeEditor.setNodePosition(node.nodeId, canvas);
|
||||
ImGui.closeCurrentPopup();
|
||||
}
|
||||
ImGui.endPopup();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import imgui.ImGui;
|
||||
import imgui.ImVec2;
|
||||
import imgui.extension.imguizmo.ImGuizmo;
|
||||
import imgui.extension.imguizmo.flag.Mode;
|
||||
import imgui.extension.imguizmo.flag.Operation;
|
||||
@@ -59,8 +60,6 @@ public class ExampleImGuizmo {
|
||||
0.f, 0.f, 0.f, 1.f
|
||||
};
|
||||
|
||||
private static final float[] VIEW_MANIPULATE_SIZE = new float[]{128f, 128f};
|
||||
|
||||
private static final float[] EMPTY = new float[]{0};
|
||||
|
||||
private static final float[] INPUT_CAMERA_VIEW = {
|
||||
@@ -166,7 +165,7 @@ public class ExampleImGuizmo {
|
||||
ImGui.inputFloat3("Sc", INPUT_MATRIX_SCALE, "%.3f", ImGuiInputTextFlags.ReadOnly);
|
||||
|
||||
if (ImGuizmo.isUsing()) {
|
||||
ImGuizmo.recomposeMatrixFromComponents(OBJECT_MATRICES[0], INPUT_MATRIX_TRANSLATION, INPUT_MATRIX_ROTATION, INPUT_MATRIX_SCALE);
|
||||
ImGuizmo.recomposeMatrixFromComponents(INPUT_MATRIX_TRANSLATION, INPUT_MATRIX_ROTATION, INPUT_MATRIX_SCALE, OBJECT_MATRICES[0]);
|
||||
}
|
||||
|
||||
if (currentGizmoOperation != Operation.SCALE) {
|
||||
@@ -217,7 +216,7 @@ public class ExampleImGuizmo {
|
||||
float[] cameraProjection = perspective(27, aspect, 0.1f, 100f);
|
||||
|
||||
ImGuizmo.setOrthographic(false);
|
||||
ImGuizmo.setEnabled(true);
|
||||
ImGuizmo.enable(true);
|
||||
ImGuizmo.setDrawList();
|
||||
|
||||
float windowWidth = ImGui.getWindowWidth();
|
||||
@@ -225,26 +224,26 @@ public class ExampleImGuizmo {
|
||||
ImGuizmo.setRect(ImGui.getWindowPosX(), ImGui.getWindowPosY(), windowWidth, windowHeight);
|
||||
|
||||
ImGuizmo.drawGrid(INPUT_CAMERA_VIEW, cameraProjection, IDENTITY_MATRIX, 100);
|
||||
ImGuizmo.setId(0);
|
||||
ImGuizmo.setID(0);
|
||||
ImGuizmo.drawCubes(INPUT_CAMERA_VIEW, cameraProjection, OBJECT_MATRICES[0]);
|
||||
|
||||
if (USE_SNAP.get() && BOUNDING_SIZE.get() && boundSizingSnap) {
|
||||
ImGuizmo.manipulate(INPUT_CAMERA_VIEW, cameraProjection, OBJECT_MATRICES[0], currentGizmoOperation, currentMode, INPUT_SNAP_VALUE, INPUT_BOUNDS, INPUT_BOUNDS_SNAP);
|
||||
ImGuizmo.manipulate(INPUT_CAMERA_VIEW, cameraProjection, currentGizmoOperation, currentMode, OBJECT_MATRICES[0], null, INPUT_SNAP_VALUE, INPUT_BOUNDS, INPUT_BOUNDS_SNAP);
|
||||
} else if (USE_SNAP.get() && BOUNDING_SIZE.get()) {
|
||||
ImGuizmo.manipulate(INPUT_CAMERA_VIEW, cameraProjection, OBJECT_MATRICES[0], currentGizmoOperation, currentMode, INPUT_SNAP_VALUE, INPUT_BOUNDS);
|
||||
ImGuizmo.manipulate(INPUT_CAMERA_VIEW, cameraProjection, currentGizmoOperation, currentMode, OBJECT_MATRICES[0], null, INPUT_SNAP_VALUE, INPUT_BOUNDS);
|
||||
} else if (BOUNDING_SIZE.get() && boundSizingSnap) {
|
||||
ImGuizmo.manipulate(INPUT_CAMERA_VIEW, cameraProjection, OBJECT_MATRICES[0], currentGizmoOperation, currentMode, EMPTY, INPUT_BOUNDS, INPUT_BOUNDS_SNAP);
|
||||
ImGuizmo.manipulate(INPUT_CAMERA_VIEW, cameraProjection, currentGizmoOperation, currentMode, OBJECT_MATRICES[0], null, EMPTY, INPUT_BOUNDS, INPUT_BOUNDS_SNAP);
|
||||
} else if (BOUNDING_SIZE.get()) {
|
||||
ImGuizmo.manipulate(INPUT_CAMERA_VIEW, cameraProjection, OBJECT_MATRICES[0], currentGizmoOperation, currentMode, EMPTY, INPUT_BOUNDS);
|
||||
ImGuizmo.manipulate(INPUT_CAMERA_VIEW, cameraProjection, currentGizmoOperation, currentMode, OBJECT_MATRICES[0], null, EMPTY, INPUT_BOUNDS);
|
||||
} else if (USE_SNAP.get()) {
|
||||
ImGuizmo.manipulate(INPUT_CAMERA_VIEW, cameraProjection, OBJECT_MATRICES[0], currentGizmoOperation, currentMode, INPUT_SNAP_VALUE);
|
||||
ImGuizmo.manipulate(INPUT_CAMERA_VIEW, cameraProjection, currentGizmoOperation, currentMode, OBJECT_MATRICES[0], null, INPUT_SNAP_VALUE);
|
||||
} else {
|
||||
ImGuizmo.manipulate(INPUT_CAMERA_VIEW, cameraProjection, OBJECT_MATRICES[0], currentGizmoOperation, currentMode);
|
||||
ImGuizmo.manipulate(INPUT_CAMERA_VIEW, cameraProjection, currentGizmoOperation, currentMode, OBJECT_MATRICES[0]);
|
||||
}
|
||||
|
||||
float viewManipulateRight = ImGui.getWindowPosX() + windowWidth;
|
||||
float viewManipulateTop = ImGui.getWindowPosY();
|
||||
ImGuizmo.viewManipulate(INPUT_CAMERA_VIEW, CAM_DISTANCE, new float[]{viewManipulateRight - 128, viewManipulateTop}, VIEW_MANIPULATE_SIZE, 0x10101010);
|
||||
ImGuizmo.viewManipulate(INPUT_CAMERA_VIEW, CAM_DISTANCE, viewManipulateRight - 128, viewManipulateTop, 128, 128, 0x10101010);
|
||||
|
||||
ImGui.endChild();
|
||||
ImGui.end();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import imgui.extension.imnodes.ImNodes;
|
||||
import imgui.extension.imnodes.ImNodesContext;
|
||||
import imgui.extension.imnodes.ImNodesEditorContext;
|
||||
import imgui.extension.imnodes.flag.ImNodesPinShape;
|
||||
import imgui.extension.imnodes.flag.ImNodesMiniMapLocation;
|
||||
import imgui.flag.ImGuiCond;
|
||||
@@ -12,14 +13,16 @@ import java.awt.Desktop;
|
||||
import java.net.URI;
|
||||
|
||||
public class ExampleImNodes {
|
||||
private static final ImNodesContext CONTEXT = new ImNodesContext();
|
||||
private static final String URL = "https://github.com/Nelarius/imnodes/tree/857cc86";
|
||||
|
||||
private static final ImInt LINK_A = new ImInt();
|
||||
private static final ImInt LINK_B = new ImInt();
|
||||
|
||||
private static ImNodesEditorContext editorContext = null;
|
||||
|
||||
static {
|
||||
ImNodes.createContext();
|
||||
editorContext = ImNodes.editorContextCreate();
|
||||
}
|
||||
|
||||
public static void show(final ImBoolean showImNodesWindow, final Graph graph) {
|
||||
@@ -39,7 +42,7 @@ public class ExampleImNodes {
|
||||
}
|
||||
}
|
||||
|
||||
ImNodes.editorContextSet(CONTEXT);
|
||||
ImNodes.editorContextSet(editorContext);
|
||||
ImNodes.beginNodeEditor();
|
||||
|
||||
for (Graph.GraphNode node : graph.nodes.values()) {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import imgui.extension.implot.ImPlot;
|
||||
import imgui.extension.implot.ImPlotPoint;
|
||||
import imgui.flag.ImGuiCond;
|
||||
import imgui.internal.ImGui;
|
||||
import imgui.type.ImBoolean;
|
||||
@@ -10,10 +11,10 @@ public class ExampleImPlot {
|
||||
private static final String URL = "https://github.com/epezent/implot/tree/555ff68";
|
||||
private static final ImBoolean showDemo = new ImBoolean(false);
|
||||
|
||||
private static final Integer[] xs = {0, 1, 2, 3, 4, 5};
|
||||
private static final Integer[] ys = {0, 1, 2, 3, 4, 5};
|
||||
private static final Integer[] ys1 = {0, 0, 1, 2, 3, 4};
|
||||
private static final Integer[] ys2 = {1, 2, 3, 4, 5, 6};
|
||||
private static final int[] xs = {0, 1, 2, 3, 4, 5};
|
||||
private static final int[] ys = {0, 1, 2, 3, 4, 5};
|
||||
private static final int[] ys1 = {0, 0, 1, 2, 3, 4};
|
||||
private static final int[] ys2 = {1, 2, 3, 4, 5, 6};
|
||||
|
||||
static {
|
||||
ImPlot.createContext();
|
||||
@@ -38,20 +39,30 @@ public class ExampleImPlot {
|
||||
|
||||
ImGui.checkbox("Show ImPlot Built-In Demo", showDemo);
|
||||
|
||||
if (ImPlot.beginPlot("Example Plot")) {
|
||||
ImPlot.plotShaded("Shaded", xs, ys1, ys2);
|
||||
ImPlot.plotLine("Line", xs, ys);
|
||||
ImPlot.plotBars("Bars", xs, ys);
|
||||
ImPlot.endPlot();
|
||||
}
|
||||
|
||||
if (ImPlot.beginPlot("Example Scatterplot")) {
|
||||
ImPlot.plotScatter("Scatter", xs, ys);
|
||||
ImPlot.endPlot();
|
||||
}
|
||||
|
||||
if (showDemo.get()) {
|
||||
ImPlot.showDemoWindow(showDemo);
|
||||
} else {
|
||||
if (ImPlot.beginPlot("Example Plot")) {
|
||||
ImPlot.plotShaded("Shaded", xs, ys1, ys2);
|
||||
ImPlot.plotLine("Line", xs, ys);
|
||||
ImPlot.plotBars("Bars", xs, ys);
|
||||
ImPlot.endPlot();
|
||||
}
|
||||
|
||||
if (ImPlot.beginPlot("Example Scatterplot")) {
|
||||
ImPlot.plotScatter("Scatter", xs, ys);
|
||||
ImPlot.endPlot();
|
||||
}
|
||||
|
||||
if (ImPlot.beginPlot("Example Piechart")) {
|
||||
ImPlot.plotPieChart(new String[]{"1", "2", "3", "4", "5", "6"}, xs, .5, .5, .4);
|
||||
ImPlot.endPlot();
|
||||
}
|
||||
|
||||
if (ImPlot.beginPlot("Example Heatmap")) {
|
||||
ImPlot.plotHeatmap("Heatmap", new int[]{1, 3, 6, 2, 8, 5, 4, 3}, 2, 4, 0, 0, "%d", new ImPlotPoint(0, 0), new ImPlotPoint(10, 10));
|
||||
ImPlot.endPlot();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,19 +23,13 @@ public class ExampleKnobs {
|
||||
if (ImGui.begin("Knobs Demo Window", showKnobsWindow, ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse)) {
|
||||
ImGui.textWrapped("This is a demo for dear ImGui Knobs");
|
||||
if (ImGui.beginChild("Float Knobs")) {
|
||||
ImGuiKnobs.knobFloat("Example Tick Knob", EXAMPLE_TICK_KNOB_VAL, 0.0f, 10.0f, 0.2f, "%.1f", ImGuiKnobVariant.TICK, 50.0f, ImGuiKnobFlags.NONE, 1);
|
||||
|
||||
ImGuiKnobs.knobFloat("Example Dot Knob", EXAMPLE_DOT_KNOB_VAL, 0.0f, 10.0f, 0.2f, "%.1f", ImGuiKnobVariant.DOT, 50.0f, ImGuiKnobFlags.NONE, 1);
|
||||
|
||||
ImGuiKnobs.knobFloat("Example Space Knob", EXAMPLE_SPACE_KNOB_VAL, 0.0f, 10.0f, 0.2f, "%.1f", ImGuiKnobVariant.SPACE, 50.0f, ImGuiKnobFlags.NONE, 1);
|
||||
|
||||
ImGuiKnobs.knobFloat("Example Wiper Knob", EXAMPLE_WIPER_KNOB_VAL, 0.0f, 10.0f, 0.2f, "%.1f", ImGuiKnobVariant.WIPER, 50.0f, ImGuiKnobFlags.NONE, 1);
|
||||
|
||||
ImGuiKnobs.knobFloat("Example Wiper Dot Knob", EXAMPLE_WIPER_DOT_KNOB_VAL, 0.0f, 10.0f, 0.2f, "%.1f", ImGuiKnobVariant.WIPER_DOT, 50.0f, ImGuiKnobFlags.NONE, 1);
|
||||
|
||||
ImGuiKnobs.knobFloat("Example Wiper Only Knob", EXAMPLE_WIPER_ONLY_KNOB_VAL, 0.0f, 10.0f, 0.2f, "%.1f", ImGuiKnobVariant.WIPER_ONLY, 50.0f, ImGuiKnobFlags.NONE, 1);
|
||||
|
||||
ImGuiKnobs.knobFloat("Example Stepped Knob", EXAMPLE_STEPPED_KNOB_VAL, 0.0f, 10.0f, 0.2f, "%.1f", ImGuiKnobVariant.STEPPED, 50.0f, ImGuiKnobFlags.NONE, 1);
|
||||
ImGuiKnobs.knob("Example Tick Knob", EXAMPLE_TICK_KNOB_VAL, 0.0f, 10.0f, 0.2f, "%.1f", ImGuiKnobVariant.Tick, 50.0f, ImGuiKnobFlags.None, 1);
|
||||
ImGuiKnobs.knob("Example Dot Knob", EXAMPLE_DOT_KNOB_VAL, 0.0f, 10.0f, 0.2f, "%.1f", ImGuiKnobVariant.Dot, 50.0f, ImGuiKnobFlags.None, 1);
|
||||
ImGuiKnobs.knob("Example Space Knob", EXAMPLE_SPACE_KNOB_VAL, 0.0f, 10.0f, 0.2f, "%.1f", ImGuiKnobVariant.Space, 50.0f, ImGuiKnobFlags.None, 1);
|
||||
ImGuiKnobs.knob("Example Wiper Knob", EXAMPLE_WIPER_KNOB_VAL, 0.0f, 10.0f, 0.2f, "%.1f", ImGuiKnobVariant.Wiper, 50.0f, ImGuiKnobFlags.None, 1);
|
||||
ImGuiKnobs.knob("Example Wiper Dot Knob", EXAMPLE_WIPER_DOT_KNOB_VAL, 0.0f, 10.0f, 0.2f, "%.1f", ImGuiKnobVariant.WiperDot, 50.0f, ImGuiKnobFlags.None, 1);
|
||||
ImGuiKnobs.knob("Example Wiper Only Knob", EXAMPLE_WIPER_ONLY_KNOB_VAL, 0.0f, 10.0f, 0.2f, "%.1f", ImGuiKnobVariant.WiperOnly, 50.0f, ImGuiKnobFlags.None, 1);
|
||||
ImGuiKnobs.knob("Example Stepped Knob", EXAMPLE_STEPPED_KNOB_VAL, 0.0f, 10.0f, 0.2f, "%.1f", ImGuiKnobVariant.Stepped, 50.0f, ImGuiKnobFlags.None, 1);
|
||||
ImGui.endChild();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user