feat: introduce binding generator

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

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

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

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

fix: ambiguous call for ImGui::GetColorU32

build: disable checkstyle for imgui-binding module

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

build: make buildSrc to use JDK 11

build: make generateApi optional when compiling project

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

No files matched your search

@@ -1,46 +1,41 @@
package imgui.internal;
import imgui.ImVec2;
import imgui.binding.annotation.ArgValue;
import imgui.binding.annotation.BindingMethod;
import imgui.binding.annotation.BindingSource;
import imgui.binding.annotation.OptArg;
import imgui.type.ImFloat;
import imgui.type.ImInt;
@BindingSource
public final class ImGui extends imgui.ImGui {
private static final ImGuiDockNode DOCK_NODE = new ImGuiDockNode(0);
private static final ImGuiWindow IMGUI_CURRENT_WINDOW = new ImGuiWindow(0);
/*JNI
#include "_common.h"
#include <imgui_internal.h>
#include "_internal.h"
*/
static {
nInit();
}
public static void init() {
}
private static native void nInit(); /*
Jni::InitInternal(env);
*/
// Basic Helpers for widget code
public static ImVec2 calcItemSize(float sizeX, float sizeY, float defaultW, float defaultH) {
final ImVec2 value = new ImVec2();
calcItemSize(sizeX, sizeY, defaultW, defaultH, value);
return value;
}
@BindingMethod
public static native ImVec2 CalcItemSize(ImVec2 size, float defaultW, float defaultH);
public static native void calcItemSize(float sizeX, float sizeY, float defaultW, float defaultH, ImVec2 dstImVec2); /*
Jni::ImVec2Cpy(env, ImGui::CalcItemSize(ImVec2(sizeX, sizeY), defaultW, defaultH), dstImVec2);
*/
@BindingMethod
public static native void PushItemFlag(int imGuiItemFlags, boolean enabled);
public static native float calcItemSizeX(float sizeX, float sizeY, float defaultW, float defaultH); /*
return ImGui::CalcItemSize(ImVec2(sizeX, sizeY), defaultW, defaultH).x;
*/
public static native float calcItemSizeY(float sizeX, float sizeY, float defaultW, float defaultH); /*
return ImGui::CalcItemSize(ImVec2(sizeX, sizeY), defaultW, defaultH).y;
*/
public static native void pushItemFlag(int imGuiItemFlags, boolean enabled); /*
ImGui::PushItemFlag(imGuiItemFlags, enabled);
*/
public static native void popItemFlag(); /*
ImGui::PopItemFlag();
*/
@BindingMethod
public static native void PopItemFlag();
// Docking - Builder function needs to be generally called before the node is used/submitted.
// - The DockBuilderXXX functions are designed to _eventually_ become a public API, but it is too early to expose it and guarantee stability.
@@ -52,147 +47,61 @@ public final class ImGui extends imgui.ImGui {
// to call DockBuilderSetNodeSize() beforehand. If you don't, the resulting split sizes may not be reliable.
// - Call DockBuilderFinish() after you are done.
public static native void dockBuilderDockWindow(String windowName, int nodeId); /*
ImGui::DockBuilderDockWindow(windowName, nodeId);
*/
@BindingMethod
public static native void DockBuilderDockWindow(String windowName, int nodeId);
public static ImGuiDockNode dockBuilderGetNode(final int nodeId) {
DOCK_NODE.ptr = nDockBuilderGetNode(nodeId);
return DOCK_NODE;
}
@BindingMethod
public static native ImGuiDockNode DockBuilderGetNode(final int nodeId);
private static native long nDockBuilderGetNode(int nodeId); /*
return (intptr_t)ImGui::DockBuilderGetNode(nodeId);
*/
@BindingMethod
public static native ImGuiDockNode DockBuilderGetCentralNode(final int nodeId);
public static ImGuiDockNode dockBuilderGetCentralNode(final int nodeId) {
DOCK_NODE.ptr = nDockBuilderGetCentralNode(nodeId);
return DOCK_NODE;
}
private static native long nDockBuilderGetCentralNode(int nodeId); /*
return (intptr_t)ImGui::DockBuilderGetCentralNode(nodeId);
*/
public static native int dockBuilderAddNode(); /*
return ImGui::DockBuilderAddNode();
*/
public static native int dockBuilderAddNode(int nodeId); /*
return ImGui::DockBuilderAddNode(nodeId);
*/
public static native int dockBuilderAddNode(int nodeId, int flags); /*
return ImGui::DockBuilderAddNode(nodeId, flags);
*/
@BindingMethod
public static native int DockBuilderAddNode(@OptArg int nodeId, @OptArg int flags);
/**
* Remove node and all its child, undock all windows.
*/
public static native void dockBuilderRemoveNode(int nodeId); /*
ImGui::DockBuilderRemoveNode(nodeId);
*/
@BindingMethod
public static native void DockBuilderRemoveNode(int nodeId);
public static native void dockBuilderRemoveNodeDockedWindows(int nodeId); /*
ImGui::DockBuilderRemoveNodeDockedWindows(nodeId);
*/
public static native void dockBuilderRemoveNodeDockedWindows(int nodeId, boolean clearSettingsRefs); /*
ImGui::DockBuilderRemoveNodeDockedWindows(nodeId, clearSettingsRefs);
*/
@BindingMethod
public static native void DockBuilderRemoveNodeDockedWindows(int nodeId, @OptArg boolean clearSettingsRefs);
/**
* Remove all split/hierarchy. All remaining docked windows will be re-docked to the remaining root node (node_id).
*/
public static native void dockBuilderRemoveNodeChildNodes(int nodeId); /*
ImGui::DockBuilderRemoveNodeChildNodes(nodeId);
*/
@BindingMethod
public static native void DockBuilderRemoveNodeChildNodes(int nodeId);
public static native void dockBuilderSetNodePos(int nodeId, float posX, float posY); /*
ImGui::DockBuilderSetNodePos(nodeId, ImVec2(posX, posY));
*/
@BindingMethod
public static native void DockBuilderSetNodePos(int nodeId, ImVec2 pos);
public static native void dockBuilderSetNodeSize(int nodeId, float sizeX, float sizeY); /*
ImGui::DockBuilderSetNodeSize(nodeId, ImVec2(sizeX, sizeY));
*/
@BindingMethod
public static native void DockBuilderSetNodeSize(int nodeId, ImVec2 size);
/**
* Create 2 child nodes in this parent node.
*/
public static int dockBuilderSplitNode(int nodeId, int splitDir, float sizeRatioForNodeAtDir, ImInt outIdAtDir, ImInt outIdAtOppositeDir) {
if (outIdAtDir == null && outIdAtOppositeDir != null) {
return nDockBuilderSplitNode(nodeId, splitDir, sizeRatioForNodeAtDir, 0, outIdAtOppositeDir.getData());
} else if (outIdAtDir != null && outIdAtOppositeDir == null) {
return nDockBuilderSplitNode(nodeId, splitDir, sizeRatioForNodeAtDir, outIdAtDir.getData());
} else if (outIdAtDir != null) {
return nDockBuilderSplitNode(nodeId, splitDir, sizeRatioForNodeAtDir, outIdAtDir.getData(), outIdAtOppositeDir.getData());
} else {
return nDockBuilderSplitNode(nodeId, splitDir, sizeRatioForNodeAtDir);
}
}
private static native int nDockBuilderSplitNode(int nodeId, int splitDir, float sizeRatioForNodeAtDir, int[] outIdAtDir, int[] outIdAtOppositeDir); /*
return ImGui::DockBuilderSplitNode(nodeId, splitDir, sizeRatioForNodeAtDir, (ImGuiID*)&outIdAtDir[0], (ImGuiID*)&outIdAtOppositeDir[0]);
*/
private static native int nDockBuilderSplitNode(int nodeId, int splitDir, float sizeRatioForNodeAtDir); /*
return ImGui::DockBuilderSplitNode(nodeId, splitDir, sizeRatioForNodeAtDir, NULL, NULL);
*/
private static native int nDockBuilderSplitNode(int nodeId, int splitDir, float sizeRatioForNodeAtDir, int[] outIdAtDir); /*
return ImGui::DockBuilderSplitNode(nodeId, splitDir, sizeRatioForNodeAtDir, (ImGuiID*)&outIdAtDir[0], NULL);
*/
private static native int nDockBuilderSplitNode(int nodeId, int splitDir, float sizeRatioForNodeAtDir, int o, int[] outIdAtOppositeDir); /*
return ImGui::DockBuilderSplitNode(nodeId, splitDir, sizeRatioForNodeAtDir, NULL, (ImGuiID*)&outIdAtOppositeDir[0]);
*/
@BindingMethod
public static native int DockBuilderSplitNode(int nodeId, int splitDir, float sizeRatioForNodeAtDir, @ArgValue(reinterpretCast = "ImGuiID*") ImInt outIdAtDir, @ArgValue(reinterpretCast = "ImGuiID*") ImInt outIdAtOppositeDir);
// TODO DockBuilderCopyDockSpace, DockBuilderCopyNode
public static native void dockBuilderCopyWindowSettings(String srcName, String dstName); /*
ImGui::DockBuilderCopyWindowSettings(srcName, dstName);
*/
@BindingMethod
public static native void DockBuilderCopyWindowSettings(String srcName, String dstName);
public static native void dockBuilderFinish(int nodeId); /*
ImGui::DockBuilderFinish(nodeId);
*/
@BindingMethod
public static native void DockBuilderFinish(int nodeId);
// Widgets low-level behaviors
public static boolean splitterBehavior(float bbMinX, float bbMinY, float bbMaxX, float bbMaxY, int id, int imGuiAxis, ImFloat size1, ImFloat size2, float minSize1, float minSize2) {
return splitterBehavior(bbMinX, bbMinY, bbMaxX, bbMaxY, id, imGuiAxis, size1, size2, minSize1, minSize2, 0, 0, 0);
}
@BindingMethod
public static native boolean SplitterBehavior(ImRect bb, int id, @ArgValue(staticCast = "ImGuiAxis") int axis, ImFloat size1, ImFloat size2, float minSize1, float minSize2, @OptArg float hoverExtend, @OptArg float hoverVisibilityDelay, @OptArg int bgCol);
public static boolean splitterBehavior(float bbMinX, float bbMinY, float bbMaxX, float bbMaxY, int id, int imGuiAxis, ImFloat size1, ImFloat size2, float minSize1, float minSize2, float hoverExtend) {
return splitterBehavior(bbMinX, bbMinY, bbMaxX, bbMaxY, id, imGuiAxis, size1, size2, minSize1, minSize2, hoverExtend, 0, 0);
}
@BindingMethod
public static native ImGuiWindow GetCurrentWindow();
public static boolean splitterBehavior(float bbMinX, float bbMinY, float bbMaxX, float bbMaxY, int id, int imGuiAxis, ImFloat size1, ImFloat size2, float minSize1, float minSize2, float hoverExtend, float hoverVisibilityDelay, int bgCol) {
return nSplitterBehaviour(bbMinX, bbMinY, bbMaxX, bbMaxY, id, imGuiAxis, size1.getData(), size2.getData(), minSize1, minSize2, hoverExtend, hoverVisibilityDelay, bgCol);
}
private static native boolean nSplitterBehaviour(float bbMinX, float bbMinY, float bbMaxX, float bbMaxY, int id, int imGuiAxis, float[] size1, float[] size2, float minSize1, float minSize2, float hoverExtend, float hoverVisibilityDelay, int bgCol); /*
return ImGui::SplitterBehavior(ImRect(bbMinX, bbMinY, bbMaxX, bbMaxY), id, (ImGuiAxis)imGuiAxis, &size1[0], &size2[0], minSize1, minSize2, hoverExtend, hoverVisibilityDelay, bgCol);
*/
public static ImGuiWindow getCurrentWindow() {
IMGUI_CURRENT_WINDOW.ptr = nGetCurrentWindow();
return IMGUI_CURRENT_WINDOW;
}
private static native long nGetCurrentWindow(); /*
return (intptr_t)ImGui::GetCurrentWindow();
*/
public static ImRect getWindowScrollbarRect(final ImGuiWindow imGuiWindow, int axis) {
final ImRect imRect = new ImRect();
nGetWindowScrollbarRect(imGuiWindow.ptr, axis, imRect.min, imRect.max);
return imRect;
}
private static native void nGetWindowScrollbarRect(long windowPtr, int axis, ImVec2 minDstImVec2, ImVec2 maxDstImVec2); /*
ImRect rect = ImGui::GetWindowScrollbarRect((ImGuiWindow*)windowPtr, static_cast<ImGuiAxis>(axis));
Jni::ImVec2Cpy(env, &rect.Min, minDstImVec2);
Jni::ImVec2Cpy(env, &rect.Max, maxDstImVec2);
*/
@BindingMethod
public static native ImRect GetWindowScrollbarRect(ImGuiWindow imGuiWindow, @ArgValue(staticCast = "ImGuiAxis") int axis);
}
@@ -5,5 +5,6 @@ import imgui.binding.ImGuiStruct;
public class ImGuiContext extends ImGuiStruct {
public ImGuiContext(final long ptr) {
super(ptr);
ImGui.init();
}
}
@@ -3,150 +3,65 @@ package imgui.internal;
import imgui.ImGuiWindowClass;
import imgui.ImVec2;
import imgui.binding.ImGuiStruct;
import imgui.binding.annotation.BindingField;
import imgui.binding.annotation.BindingMethod;
import imgui.binding.annotation.BindingSource;
import imgui.binding.annotation.ReturnValue;
@BindingSource
public final class ImGuiDockNode extends ImGuiStruct {
private static final ImGuiDockNode PARENT_NODE = new ImGuiDockNode(0);
private static final ImGuiDockNode CHILD_NODE_FIRST = new ImGuiDockNode(0);
private static final ImGuiDockNode CHILD_NODE_SECOND = new ImGuiDockNode(0);
private static final ImGuiWindowClass WINDOW_CLASS = new ImGuiWindowClass(0);
private static final ImGuiDockNode CENTRAL_NODE = new ImGuiDockNode(0);
private static final ImGuiDockNode ONLY_NODE_WITH_WINDOWS = new ImGuiDockNode(0);
private static final ImRect RECT = new ImRect();
public ImGuiDockNode(final long ptr) {
super(ptr);
ImGui.init();
}
/*JNI
#include "_common.h"
#include <imgui_internal.h>
#define IMGUI_DOCK_NODE ((ImGuiDockNode*)STRUCT_PTR)
#include "_internal.h"
#define THIS ((ImGuiDockNode*)STRUCT_PTR)
*/
public native int getID(); /*
return IMGUI_DOCK_NODE->ID;
*/
public native void setID(int imGuiID); /*
IMGUI_DOCK_NODE->ID = imGuiID;
*/
@BindingField
public int ID;
/**
* Flags shared by all nodes of a same dockspace hierarchy (inherited from the root node)
*/
public native int getSharedFlags(); /*
return IMGUI_DOCK_NODE->SharedFlags;
*/
/**
* Flags shared by all nodes of a same dockspace hierarchy (inherited from the root node)
*/
public native void setSharedFlags(int sharedFlags); /*
IMGUI_DOCK_NODE->SharedFlags = sharedFlags;
*/
/**
* Flags shared by all nodes of a same dockspace hierarchy (inherited from the root node)
*/
public void addSharedFlags(final int flags) {
setSharedFlags(getSharedFlags() | flags);
}
/**
* Flags shared by all nodes of a same dockspace hierarchy (inherited from the root node)
*/
public void removeSharedFlags(final int flags) {
setSharedFlags(getSharedFlags() & ~(flags));
}
@BindingField(isFlag = true)
public int SharedFlags;
/**
* Flags specific to this node
*/
public native int getLocalFlags(); /*
return IMGUI_DOCK_NODE->LocalFlags;
*/
/**
* Flags specific to this node
*/
public native void setLocalFlags(int flags); /*
IMGUI_DOCK_NODE->SetLocalFlags(flags);
*/
/**
* Flags specific to this node
*/
public void addLocalFlags(final int flags) {
setLocalFlags(getLocalFlags() | flags);
}
/**
* Flags specific to this node
*/
public void removeLocalFlags(final int flags) {
setLocalFlags(getLocalFlags() & ~(flags));
}
/**
* Flags specific to this node, applied from windows
*/
public native int getLocalFlagsInWindows(); /*
return IMGUI_DOCK_NODE->LocalFlagsInWindows;
*/
@BindingField(isFlag = true)
public int LocalFlags;
/**
* Flags specific to this node, applied from windows
*/
public native void setLocalFlagsInWindows(int flags); /*
IMGUI_DOCK_NODE->LocalFlagsInWindows = flags;
*/
@BindingField(isFlag = true)
public int LocalFlagsInWindows;
/**
* Flags specific to this node, applied from windows
* Effective flags (== SharedFlags | LocalFlagsInNode | LocalFlagsInWindows)
*/
public void addLocalFlagsInWindows(final int flags) {
setLocalFlagsInWindows(getLocalFlagsInWindows() | flags);
}
@BindingField(isFlag = true, accessors = BindingField.Accessor.GETTER)
public int MergedFlags;
/**
* Flags specific to this node, applied from windows
*/
public void removeLocalFlagsInWindows(final int flags) {
setLocalFlagsInWindows(getLocalFlagsInWindows() & ~(flags));
}
// TODO: State
public native int getMergedFlags(); /*
return IMGUI_DOCK_NODE->MergedFlags;
*/
public ImGuiDockNode getParentNode() {
PARENT_NODE.ptr = nGetParentNode();
return PARENT_NODE;
}
private native long nGetParentNode(); /*
return (intptr_t)IMGUI_DOCK_NODE->ParentNode;
*/
public void setParentNode(final ImGuiDockNode imGuiDockNode) {
nSetParentNode(imGuiDockNode.ptr);
}
private native void nSetParentNode(long imGuiDockNodePtr); /*
IMGUI_DOCK_NODE->ParentNode = (ImGuiDockNode*)imGuiDockNodePtr;
*/
@BindingField
public ImGuiDockNode ParentNode;
/**
* [Split node only] Child nodes (left/right or top/bottom). Consider switching to an array.
*/
public ImGuiDockNode getChildNodeFirst() {
CHILD_NODE_FIRST.ptr = nGetChildNodeFirst();
return CHILD_NODE_FIRST;
return new ImGuiDockNode(nGetChildNodeFirst());
}
private native long nGetChildNodeFirst(); /*
return (intptr_t)IMGUI_DOCK_NODE->ChildNodes[0];
return (intptr_t)THIS->ChildNodes[0];
*/
/**
@@ -157,19 +72,18 @@ public final class ImGuiDockNode extends ImGuiStruct {
}
private native void nSetChildNodeFirst(long imGuiDockNodePtr); /*
IMGUI_DOCK_NODE->ChildNodes[0] = (ImGuiDockNode*)imGuiDockNodePtr;
THIS->ChildNodes[0] = (ImGuiDockNode*)imGuiDockNodePtr;
*/
/**
* [Split node only] Child nodes (left/right or top/bottom). Consider switching to an array.
*/
public ImGuiDockNode getChildNodeSecond() {
CHILD_NODE_SECOND.ptr = nGetChildNodeSecond();
return CHILD_NODE_SECOND;
return new ImGuiDockNode(nGetChildNodeSecond());
}
private native long nGetChildNodeSecond(); /*
return (intptr_t)IMGUI_DOCK_NODE->ChildNodes[1];
return (intptr_t)THIS->ChildNodes[1];
*/
/**
@@ -180,493 +94,190 @@ public final class ImGuiDockNode extends ImGuiStruct {
}
private native void nSetChildNodeSecond(long imGuiDockNodePtr); /*
IMGUI_DOCK_NODE->ChildNodes[1] = (ImGuiDockNode*)imGuiDockNodePtr;
THIS->ChildNodes[1] = (ImGuiDockNode*)imGuiDockNodePtr;
*/
// TODO Windows, TabBar
/**
* [Root node only]
*/
public ImGuiWindowClass getWindowClass() {
WINDOW_CLASS.ptr = nGetWindowClass();
return WINDOW_CLASS;
}
/**
* [Root node only]
*/
private native long nGetWindowClass(); /*
return (intptr_t)&IMGUI_DOCK_NODE->WindowClass;
*/
/**
* [Root node only]
*/
public void setWindowClass(final ImGuiWindowClass imGuiWindowClass) {
nSetWindowClass(imGuiWindowClass.ptr);
}
/**
* [Root node only]
*/
private native void nSetWindowClass(long imGuiWindowClassPtr); /*
IMGUI_DOCK_NODE->WindowClass = *((ImGuiWindowClass*)imGuiWindowClassPtr);
*/
/**
* Current position
*/
public ImVec2 getPos() {
final ImVec2 value = new ImVec2();
getPos(value);
return value;
}
/**
* Current position
*/
public native void getPos(ImVec2 dstImVec2); /*
Jni::ImVec2Cpy(env, &IMGUI_DOCK_NODE->Pos, dstImVec2);
*/
/**
* Current position
*/
public native float getPosX(); /*
return IMGUI_DOCK_NODE->Pos.x;
*/
/**
* Current position
*/
public native float getPosY(); /*
return IMGUI_DOCK_NODE->Pos.y;
*/
/**
* Current position
*/
public native void setPos(float x, float y); /*
IMGUI_DOCK_NODE->Pos.x = x;
IMGUI_DOCK_NODE->Pos.y = y;
*/
@BindingField
public ImVec2 Pos;
/**
* Current size
*/
public ImVec2 getSize() {
final ImVec2 value = new ImVec2();
getSize(value);
return value;
}
/**
* Current size
*/
public native void getSize(ImVec2 dstImVec2); /*
Jni::ImVec2Cpy(env, &IMGUI_DOCK_NODE->Size, dstImVec2);
*/
/**
* Current size
*/
public native float getSizeX(); /*
return IMGUI_DOCK_NODE->Size.x;
*/
/**
* Current size
*/
public native float getSizeY(); /*
return IMGUI_DOCK_NODE->Size.y;
*/
/**
* Current size
*/
public native void setSize(float x, float y); /*
IMGUI_DOCK_NODE->Size.x = x;
IMGUI_DOCK_NODE->Size.y = y;
*/
@BindingField
public ImVec2 Size;
/**
* [Split node only] Last explicitly written-to size (overridden when using a splitter affecting the node), used to calculate Size.
*/
public ImVec2 getSizeRef() {
final ImVec2 value = new ImVec2();
getSizeRef(value);
return value;
}
/**
* [Split node only] Last explicitly written-to size (overridden when using a splitter affecting the node), used to calculate Size.
*/
public native void getSizeRef(ImVec2 dstImVec2); /*
Jni::ImVec2Cpy(env, &IMGUI_DOCK_NODE->SizeRef, dstImVec2);
*/
/**
* [Split node only] Last explicitly written-to size (overridden when using a splitter affecting the node), used to calculate Size.
*/
public native float getSizeRefX(); /*
return IMGUI_DOCK_NODE->SizeRef.x;
*/
/**
* [Split node only] Last explicitly written-to size (overridden when using a splitter affecting the node), used to calculate Size.
*/
public native float getSizeRefY(); /*
return IMGUI_DOCK_NODE->SizeRef.y;
*/
/**
* [Split node only] Last explicitly written-to size (overridden when using a splitter affecting the node), used to calculate Size.
*/
public native void setSizeRef(float x, float y); /*
IMGUI_DOCK_NODE->SizeRef.x = x;
IMGUI_DOCK_NODE->SizeRef.y = y;
*/
@BindingField
public ImVec2 SizeRef;
/**
* [Split node only] Split axis (X or Y)
*/
public native int getSplitAxis(); /*
return IMGUI_DOCK_NODE->SplitAxis;
*/
@BindingField(accessors = BindingField.Accessor.GETTER)
public int SplitAxis;
/**
* [Split node only] Split axis (X or Y)
* [Root node only]
*/
public native void setSplitAxis(int splitAxis); /*
IMGUI_DOCK_NODE->SplitAxis = (ImGuiAxis)splitAxis;
*/
@BindingField(accessors = BindingField.Accessor.GETTER)
@ReturnValue(callPrefix = "&")
public ImGuiWindowClass WindowClass;
@BindingField
public int LastBgColor;
public native int getState(); /*
return IMGUI_DOCK_NODE->State;
*/
@BindingField
public ImGuiWindow HostWindow;
public native void setState(int state); /*
IMGUI_DOCK_NODE->State = (ImGuiDockNodeState)state;
*/
// TODO HostWindow, VisibleWindow
/**
* Generally point to window which is ID is == SelectedTabID, but when CTRL+Tabbing this can be a different window.
*/
@BindingField
public ImGuiWindow VisibleWindow;
/**
* [Root node only] Pointer to central node.
*/
public ImGuiDockNode getCentralNode() {
CENTRAL_NODE.ptr = nGetCentralNode();
return PARENT_NODE;
}
private native long nGetCentralNode(); /*
return (intptr_t)IMGUI_DOCK_NODE->CentralNode;
*/
/**
* [Root node only] Pointer to central node.
*/
public void setCentralNode(final ImGuiDockNode imGuiDockNode) {
nSetCentralNode(imGuiDockNode.ptr);
}
private native void nSetCentralNode(long imGuiDockNodePtr); /*
IMGUI_DOCK_NODE->CentralNode = (ImGuiDockNode*)imGuiDockNodePtr;
*/
@BindingField
public ImGuiDockNode CentralNode;
/**
* [Root node only] Set when there is a single visible node within the hierarchy.
*/
public ImGuiDockNode getOnlyNodeWithWindows() {
ONLY_NODE_WITH_WINDOWS.ptr = nGetOnlyNodeWithWindows();
return PARENT_NODE;
}
private native long nGetOnlyNodeWithWindows(); /*
return (intptr_t)IMGUI_DOCK_NODE->OnlyNodeWithWindows;
*/
/**
* [Root node only] Set when there is a single visible node within the hierarchy.
*/
public void setOnlyNodeWithWindows(final ImGuiDockNode imGuiDockNode) {
nSetOnlyNodeWithWindows(imGuiDockNode.ptr);
}
private native void nSetOnlyNodeWithWindows(long imGuiDockNodePtr); /*
IMGUI_DOCK_NODE->OnlyNodeWithWindows = (ImGuiDockNode*)imGuiDockNodePtr;
*/
@BindingField
public ImGuiDockNode OnlyNodeWithWindows;
/**
* Last frame number the node was updated or kept alive explicitly with DockSpace() + int_KeepAliveOnly
*/
public native int getLastFrameAlive(); /*
return IMGUI_DOCK_NODE->LastFrameAlive;
*/
/**
* Last frame number the node was updated or kept alive explicitly with DockSpace() + int_KeepAliveOnly
*/
public native void setLastFrameAlive(int lastFrameAlive); /*
IMGUI_DOCK_NODE->LastFrameAlive = lastFrameAlive;
*/
@BindingField
public int LastFrameAlive;
/**
* Last frame number the node was updated.
*/
public native int getLastFrameActive(); /*
return IMGUI_DOCK_NODE->LastFrameActive;
*/
/**
* Last frame number the node was updated.
*/
public native void setLastFrameActive(int lastFrameActive); /*
IMGUI_DOCK_NODE->LastFrameActive = lastFrameActive;
*/
@BindingField
public int LastFrameActive;
/**
* Last frame number the node was focused.
*/
public native int getLastFrameFocused(); /*
return IMGUI_DOCK_NODE->LastFrameFocused;
*/
/**
* Last frame number the node was focused.
*/
public native void setLastFrameFocused(int lastFrameFocused); /*
IMGUI_DOCK_NODE->LastFrameFocused = lastFrameFocused;
*/
@BindingField
public int LastFrameFocused;
/**
* [Root node only] Which of our child docking node (any ancestor in the hierarchy) was last focused.
*/
public native int getLastFocusedNodeId(); /*
return IMGUI_DOCK_NODE->LastFocusedNodeId;
*/
/**
* [Root node only] Which of our child docking node (any ancestor in the hierarchy) was last focused.
*/
public native void setLastFocusedNodeId(int lastFocusedNodeId); /*
IMGUI_DOCK_NODE->LastFocusedNodeId = lastFocusedNodeId;
*/
@BindingField
public int LastFocusedNodeId;
/**
* [Leaf node only] Which of our tab/window is selected.
*/
public native int getSelectedTabId(); /*
return IMGUI_DOCK_NODE->SelectedTabId;
*/
/**
* [Leaf node only] Which of our tab/window is selected.
*/
public native void setSelectedTabId(int selectedTabId); /*
IMGUI_DOCK_NODE->SelectedTabId = selectedTabId;
*/
@BindingField
public int SelectedTabId;
/**
* [Leaf node only] Set when closing a specific tab/window.
*/
public native int getWantCloseTabId(); /*
return IMGUI_DOCK_NODE->WantCloseTabId;
*/
@BindingField
public int WantCloseTabId;
/**
* [Leaf node only] Set when closing a specific tab/window.
*/
public native void setWantCloseTabId(int wantCloseTabId); /*
IMGUI_DOCK_NODE->WantCloseTabId = wantCloseTabId;
*/
@BindingField
public int AuthorityForPos;
@BindingField
public int AuthorityForSize;
public native int getAuthorityForPos(); /*
return IMGUI_DOCK_NODE->AuthorityForPos;
*/
public native void setAuthorityForPos(int authorityForPos); /*
IMGUI_DOCK_NODE->AuthorityForPos = authorityForPos;
*/
public native int getAuthorityForSize(); /*
return IMGUI_DOCK_NODE->AuthorityForSize;
*/
public native void setAuthorityForSize(int authorityForSize); /*
IMGUI_DOCK_NODE->AuthorityForSize = authorityForSize;
*/
public native int getAuthorityForViewport(); /*
return IMGUI_DOCK_NODE->AuthorityForViewport;
*/
public native void setAuthorityForViewport(int authorityForViewport); /*
IMGUI_DOCK_NODE->AuthorityForViewport = authorityForViewport;
*/
@BindingField
public int AuthorityForViewport;
/**
* Set to false when the node is hidden (usually disabled as it has no active window)
*/
public native boolean getIsVisible(); /*
return IMGUI_DOCK_NODE->IsVisible;
*/
@BindingField
public boolean IsVisible;
/**
* Set to false when the node is hidden (usually disabled as it has no active window)
*/
public native void setIsVisible(boolean isVisible); /*
IMGUI_DOCK_NODE->IsVisible = isVisible;
*/
@BindingField
public boolean IsFocused;
@BindingField
public boolean HasCloseButton;
public native boolean getIsFocused(); /*
return IMGUI_DOCK_NODE->IsFocused;
*/
@BindingField
public boolean HasWindowMenuButton;
public native void setIsFocused(boolean isFocused); /*
IMGUI_DOCK_NODE->IsFocused = isFocused;
*/
public native boolean getHasCloseButton(); /*
return IMGUI_DOCK_NODE->HasCloseButton;
*/
public native void setHasCloseButton(boolean hasCloseButton); /*
IMGUI_DOCK_NODE->HasCloseButton = hasCloseButton;
*/
public native boolean getHasWindowMenuButton(); /*
return IMGUI_DOCK_NODE->HasWindowMenuButton;
*/
public native void setHasWindowMenuButton(boolean hasWindowMenuButton); /*
IMGUI_DOCK_NODE->HasWindowMenuButton = hasWindowMenuButton;
*/
@BindingField
public boolean HasCentralNodeChild;
/**
* Set when closing all tabs at once.
*/
public native boolean getWantCloseAll(); /*
return IMGUI_DOCK_NODE->WantCloseAll;
*/
@BindingField
public boolean WantCloseAll;
/**
* Set when closing all tabs at once.
*/
public native void setWantCloseAll(boolean wantCloseAll); /*
IMGUI_DOCK_NODE->WantCloseAll = wantCloseAll;
*/
public native boolean getWantLockSizeOnce(); /*
return IMGUI_DOCK_NODE->WantLockSizeOnce;
*/
public native void setWantLockSizeOnce(boolean wantLockSizeOnce); /*
IMGUI_DOCK_NODE->WantLockSizeOnce = wantLockSizeOnce;
*/
@BindingField
public boolean WantLockSizeOnce;
/**
* After a node extraction we need to transition toward moving the newly created host window
*/
public native boolean getWantMouseMove(); /*
return IMGUI_DOCK_NODE->WantMouseMove;
*/
@BindingField
public boolean WantMouseMove;
/**
* After a node extraction we need to transition toward moving the newly created host window
*/
public native void setWantMouseMove(boolean wantMouseMove); /*
IMGUI_DOCK_NODE->WantMouseMove = wantMouseMove;
*/
@BindingField
public boolean WantHiddenTabBarUpdate;
@BindingField
public boolean WantHiddenTabBarToggle;
public native boolean getWantHiddenTabBarUpdate(); /*
return IMGUI_DOCK_NODE->WantHiddenTabBarUpdate;
*/
@BindingMethod
public native boolean IsRootNode();
@BindingMethod
public native boolean IsDockSpace();
public native void setWantHiddenTabBarUpdate(boolean wantHiddenTabBarUpdate); /*
IMGUI_DOCK_NODE->WantHiddenTabBarUpdate = wantHiddenTabBarUpdate;
*/
@BindingMethod
public native boolean IsFloatingNode();
public native boolean getWantHiddenTabBarToggle(); /*
return IMGUI_DOCK_NODE->WantHiddenTabBarToggle;
*/
public native void setWantHiddenTabBarToggle(boolean wantHiddenTabBarToggle); /*
IMGUI_DOCK_NODE->WantHiddenTabBarToggle = wantHiddenTabBarToggle;
*/
public native boolean isRootNode(); /*
return IMGUI_DOCK_NODE->IsRootNode();
*/
public native boolean isDockSpace(); /*
return IMGUI_DOCK_NODE->IsDockSpace();
*/
public native boolean isFloatingNode(); /*
return IMGUI_DOCK_NODE->IsFloatingNode();
*/
public native boolean isCentralNode(); /*
return IMGUI_DOCK_NODE->IsCentralNode();
*/
@BindingMethod
public native boolean IsCentralNode();
/**
* Hidden tab bar can be shown back by clicking the small triangle
*/
public native boolean isHiddenTabBar(); /*
return IMGUI_DOCK_NODE->IsHiddenTabBar();
*/
@BindingMethod
public native boolean IsHiddenTabBar();
/**
* Never show a tab bar
*/
public native boolean isNoTabBar(); /*
return IMGUI_DOCK_NODE->IsNoTabBar();
*/
@BindingMethod
public native boolean IsNoTabBar();
public native boolean isSplitNode(); /*
return IMGUI_DOCK_NODE->IsSplitNode();
*/
@BindingMethod
public native boolean IsSplitNode();
public native boolean isLeafNode(); /*
return IMGUI_DOCK_NODE->IsLeafNode();
*/
@BindingMethod
public native boolean IsLeafNode();
public native boolean isEmpty(); /*
return IMGUI_DOCK_NODE->IsEmpty();
*/
@BindingMethod
public native boolean IsEmpty();
public ImRect rect() {
nRect(RECT.min, RECT.max);
return RECT;
}
@BindingMethod
public native ImRect Rect();
private native void nRect(ImVec2 minDstImVec2, ImVec2 maxDstImVec2); /*
ImRect rect = IMGUI_DOCK_NODE->Rect();
Jni::ImVec2Cpy(env, &rect.Min, minDstImVec2);
Jni::ImVec2Cpy(env, &rect.Max, maxDstImVec2);
*/
@BindingMethod
public native void UpdateMergedFlags();
/*JNI
#undef THIS
*/
}
@@ -1,31 +1,35 @@
package imgui.internal;
import imgui.binding.ImGuiStruct;
import imgui.binding.annotation.BindingField;
import imgui.binding.annotation.BindingSource;
@BindingSource
public class ImGuiWindow extends ImGuiStruct {
public ImGuiWindow(final long ptr) {
super(ptr);
ImGui.init();
}
/*JNI
#include "_common.h"
#include <imgui_internal.h>
#define IMGUI_WINDOW ((ImGuiWindow*)STRUCT_PTR)
#include "_internal.h"
#define THIS ((ImGuiWindow*)STRUCT_PTR)
*/
/**
* Is scrollbar visible?
*/
public native boolean isScrollbarX(); /*
return IMGUI_WINDOW->ScrollbarX;
*/
@BindingField(accessors = BindingField.Accessor.GETTER)
public boolean ScrollbarX;
/**
* Is scrollbar visible?
*/
public native boolean isScrollbarY(); /*
return IMGUI_WINDOW->ScrollbarY;
*/
@BindingField(accessors = BindingField.Accessor.GETTER)
public boolean ScrollbarY;
/*JNI
#undef THIS
*/
}
@@ -21,29 +21,31 @@ public final class ImRect implements Cloneable {
public ImRect() {
}
public ImRect(final float minX, final float minY, final float maxX, final float maxY) {
set(minX, minY, maxX, maxY);
}
public ImRect(final ImVec2 min, final ImVec2 max) {
this.min.x = min.x;
this.min.y = min.y;
this.max.x = max.x;
this.max.y = max.y;
set(min, max);
}
public ImRect(final float x1, final float y1, final float x2, final float y2) {
min.x = x1;
min.y = y1;
max.x = x2;
max.y = y2;
public ImRect(final ImRect value) {
set(value);
}
public ImRect(final ImRect imRect) {
this(imRect.min, imRect.max);
public void set(final float minX, final float minY, final float maxX, final float maxY) {
this.min.x = minX;
this.min.y = minY;
this.max.x = maxX;
this.max.y = maxY;
}
public void set(final ImVec2 min, final ImVec2 max) {
set(min.x, min.y, max.x, max.y);
}
public void set(final ImRect value) {
min.x = value.min.x;
min.y = value.min.y;
max.x = value.max.x;
max.y = value.max.y;
set(value.min, value.max);
}
@Override
@@ -74,6 +76,7 @@ public final class ImRect implements Cloneable {
}
@Override
@SuppressWarnings("MethodDoesntCallSuperMethod")
public ImRect clone() {
return new ImRect(this);
}
@@ -1,10 +1,13 @@
package imgui.internal.flag;
import imgui.binding.annotation.BindingAstEnum;
import imgui.binding.annotation.BindingSource;
@BindingSource
public final class ImGuiAxis {
private ImGuiAxis() {
}
public static final int None = -1;
public static final int X = 0;
public static final int Y = 1;
@BindingAstEnum(file = "ast-imgui_internal.json", qualType = "ImGuiAxis", sanitizeName = "ImGuiAxis_")
public Void __;
}
@@ -1,13 +1,16 @@
package imgui.internal.flag;
import imgui.binding.annotation.BindingAstEnum;
import imgui.binding.annotation.BindingSource;
/**
* Store the source authority (dock node vs window) of a field
*/
@BindingSource
public final class ImGuiDataAuthority {
private ImGuiDataAuthority() {
}
public static final int Auto = 0;
public static final int DockNode = 1;
public static final int Window = 2;
@BindingAstEnum(file = "ast-imgui_internal.json", qualType = "ImGuiDataAuthority_")
public Void __;
}
@@ -1,53 +1,19 @@
package imgui.internal.flag;
import imgui.binding.annotation.BindingAstEnum;
import imgui.binding.annotation.BindingSource;
/**
* Extend ImGuiDockNodeFlags
*/
public final class ImGuiDockNodeFlags extends imgui.flag.ImGuiDockNodeFlags {
@BindingSource
public final class ImGuiDockNodeFlags {
private ImGuiDockNodeFlags() {
}
/**
* A dockspace is a node that occupy space within an existing user window. Otherwise the node is floating and create its own window.
*/
public static final int DockSpace = 1 << 10;
/**
* The central node has 2 main properties: stay visible when empty, only use "remaining" spaces from its neighbor.
*/
public static final int CentralNode = 1 << 11;
/**
* Tab bar is completely unavailable. No triangle in the corner to enable it back.
*/
public static final int NoTabBar = 1 << 12;
/**
* Tab bar is hidden, with a triangle in the corner to show it again (NB: actual tab-bar instance may be destroyed as this is only used for single-window tab bar)
*/
public static final int HiddenTabBar = 1 << 13;
/**
* Disable window/docking menu (that one that appears instead of the collapse button)
*/
public static final int NoWindowMenuButton = 1 << 14;
public static final int NoCloseButton = 1 << 15;
/**
* Disable any form of docking in this dockspace or individual node. (On a whole dockspace, this pretty much defeat the purpose of using a dockspace at all). Note: when turned on, existing docked nodes will be preserved.
*/
public static final int NoDocking = 1 << 16;
/**
* [EXPERIMENTAL] Prevent another window/node from splitting this node.
*/
public static final int NoDockingSplitMe = 1 << 17;
/**
* [EXPERIMENTAL] Prevent this node from splitting another window/node.
*/
public static final int NoDockingSplitOther = 1 << 18;
/**
* [EXPERIMENTAL] Prevent another window/node to be docked over this node.
*/
public static final int NoDockingOverMe = 1 << 19;
/**
* [EXPERIMENTAL] Prevent this node to be docked over another window/node.
*/
public static final int NoDockingOverOther = 1 << 20;
public static final int NoResizeX = 1 << 21;
public static final int NoResizeY = 1 << 22;
@BindingAstEnum(file = "ast-imgui.json", qualType = "ImGuiDockNodeFlags_")
public Void __;
@BindingAstEnum(file = "ast-imgui_internal.json", qualType = "ImGuiDockNodeFlagsPrivate_", sanitizeName = "ImGuiDockNodeFlags_")
public Void ___;
}
@@ -1,11 +1,13 @@
package imgui.internal.flag;
import imgui.binding.annotation.BindingAstEnum;
import imgui.binding.annotation.BindingSource;
@BindingSource
public final class ImGuiDockNodeState {
private ImGuiDockNodeState() {
}
public static final int Unknown = 0;
public static final int HostWindowHiddenBecauseSingleWindow = 1;
public static final int HostWindowHiddenBecauseWindowsAreResizing = 2;
public static final int HostWindowVisible = 3;
@BindingAstEnum(file = "ast-imgui_internal.json", qualType = "ImGuiDockNodeState", sanitizeName = "ImGuiDockNodeState_")
public Void __;
}
@@ -1,36 +1,17 @@
package imgui.internal.flag;
import imgui.binding.annotation.BindingAstEnum;
import imgui.binding.annotation.BindingSource;
/**
* Transient per-window flags, reset at the beginning of the frame. For child window, inherited from parent on first Begin().
* This is going to be exposed in imgui.h when stabilized enough.
*/
@BindingSource
public final class ImGuiItemFlags {
private ImGuiItemFlags() {
}
public static final int None = 0;
public static final int NoTabStop = 1;
/**
* Button() will return true multiple times based on io.KeyRepeatDelay and io.KeyRepeatRate settings.
*/
public static final int ButtonRepeat = 1 << 1;
/**
* [BETA] Disable interactions but doesn't affect visuals yet. See github.com/ocornut/imgui/issues/211
*/
public static final int Disabled = 1 << 2;
public static final int NoNav = 1 << 3;
public static final int NoNavDefaultFocus = 1 << 4;
/**
* MenuItem/Selectable() automatically closes current Popup window
*/
public static final int SelectableDontClosePopup = 1 << 5;
/**
* [BETA] Represent a mixed/indeterminate value, generally multi-selection where values differ.
* Currently only supported by Checkbox() (later should support all sorts of widgets)
*/
public static final int MixedValue = 1 << 6;
/**
* [ALPHA] Allow hovering interactions but underlying value is not changed.
*/
public static final int ReadOnly = 1 << 7;
@BindingAstEnum(file = "ast-imgui_internal.json", qualType = "ImGuiItemFlags_")
public Void __;
}